summary refs log tree commit diff stats
path: root/includes/session.php
blob: 2e0824af09da98759d05c794cb4e56e5fe3c9a76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/*
       444444444  
      4::::::::4  
     4:::::::::4  
    4::::44::::4  
   4::::4 4::::4   Four Island
  4::::4  4::::4  
 4::::4   4::::4   Written and maintained by Starla Insigna
4::::444444::::444
4::::::::::::::::4  includes/session.php
4444444444:::::444
          4::::4   Please do not use, reproduce or steal the
          4::::4   contents of this file without explicit
          4::::4   permission from Hatkirby.
        44::::::44
        4::::::::4
        4444444444
*/

if (!defined('S_INCLUDE_FILE')) {define('S_INCLUDE_FILE',1);}

require('headerproc.php');

@session_start();

function getSessionID()
{
	$getconfig = "SELECT * FROM phpbb_config WHERE config_name LIKE \"cookie_name\"";
	$getconfig2 = mysql_query($getconfig);
	$getconfig3 = mysql_fetch_array($getconfig2);

	if (isset($_COOKIE[$getconfig3['config_value'] . '_sid']))
	{
		return $_COOKIE[$getconfig3['config_value'] . '_sid'];
	}

	return false;
}

function getSessionUserID()
{
	$getconfig = "SELECT * FROM phpbb_config WHERE config_name LIKE \"cookie_name\"";
	$getconfig2 = mysql_query($getconfig);
	$getconfig3 = mysql_fetch_array($getconfig2);

	if (isset($_COOKIE[$getconfig3['config_value'] . '_sid']))
	{
		$getsession = "SELECT * FROM phpbb_sessions WHERE session_id LIKE \"" . mysql_real_escape_string($_COOKIE[$getconfig3['config_value'] . '_sid']) . "\"";
		$getsession2 = mysql_query($getsession) or die($getsession);
		$getsession3 = mysql_fetch_array($getsession2);

		return $getsession3['session_user_id'];
	}

	return false;
}

function getSessionUsername()
{
	$getconfig = "SELECT * FROM phpbb_config WHERE config_name LIKE \"cookie_name\"";
	$getconfig2 = mysql_query($getconfig);
	$getconfig3 = mysql_fetch_array($getconfig2);

	if (isset($_COOKIE[$getconfig3['config_value'] . '_sid']))
	{
		$getsession = "SELECT * FROM phpbb_sessions AS s, phpbb_users AS u WHERE s.session_id LIKE \"" . mysql_real_escape_string($_COOKIE[$getconfig3['config_value'] . '_sid']) . "\" AND u.user_id = s.session_user_id";
		$getsession2 = mysql_query($getsession) or die($getsession);
		$getsession3 = mysql_fetch_array($getsession2);

		return $getsession3['username'];
	}

	return false;
}

function isLoggedIn()
{
	$getconfig = "SELECT * FROM phpbb_config WHERE config_name LIKE \"cookie_name\"";
	$getconfig2 = mysql_query($getconfig);
	$getconfig3 = mysql_fetch_array($getconfig2);

	if (isset($_COOKIE[$getconfig3['config_value'] . '_sid']))
	{
		$getsession = "SELECT * FROM phpbb_sessions WHERE session_id LIKE \"" . mysql_real_escape_string($_COOKIE[$getconfig3['config_value'] . '_sid']) . "\"";
		$getsession2 = mysql_query($getsession);
		$getsession3 = mysql_fetch_array($getsession2);

		if ($getsession3['session_user_id'] != '1')
		{
			return true;
		}
	}

	return false;
}

function isAdmin()
{
	if (isLoggedIn())
	{
		$getgroup = "SELECT COUNT(*) FROM phpbb_user_group, phpbb_users WHERE phpbb_user_group.user_id = phpbb_users.user_id AND phpbb_users.username = \"" . getSessionUsername() . "\" AND phpbb_user_group.group_id = 5";
		$getgroup2 = mysql_query($getgroup);
		$getgroup3 = mysql_fetch_array($getgroup2);

		if ($getgroup3['COUNT(*)'] == '1')
		{
			return true;
		}
	}

	return false;
}

?>