-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathinclude.php
168 lines (138 loc) · 4.51 KB
/
include.php
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* LICENSE:
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* @categories Games/Entertainment, Systems Administration
* @package Bright Game Panel
* @author warhawk3407 <[email protected]> @NOSPAM
* @copyleft 2013
* @license GNU General Public License version 3.0 (GPLv3)
* @version (Release 0) DEVELOPER BETA 8
* @link http://www.bgpanel.net/
*/
//Prevent direct access
if (!defined('LICENSE'))
{
exit('Access Denied');
}
if (is_dir("install"))
{
header( "Location: install" );
die();
}
require("./includes/functions.php");
require("./includes/mysql.php");
require("./libs/php-gettext/gettext.inc.php");
/**
* Authentication
*/
session_start();
if (isClientLoggedIn() == FALSE) //Check if the user have wanted to access to a protected resource without being logged in
{
if (!empty($return)) //Retrieve the last page where the user wanted to go
{
if ($return === TRUE) //Process protection
{
header( "Location: login.php" );
die();
}
else
{
header( "Location: login.php?return=".urldecode($return) );
die();
}
}
}
/**
* SESSION check up (Test if the information stored in the globals $_SESSION are valid)
*/
if (isClientLoggedIn() == TRUE)
{
$clientverify = mysql_query( "SELECT `username`, `firstname`, `lastname`, `token`, `lastip` FROM `".DBPREFIX."client` WHERE `clientid` = '".$_SESSION['clientid']."' && `status` = 'Active'" );
###
$clientverify = mysql_fetch_assoc($clientverify);
if (
($clientverify['username'] != $_SESSION['clientusername']) ||
($clientverify['firstname'] != $_SESSION['clientfirstname']) ||
($clientverify['lastname'] != $_SESSION['clientlastname']) ||
($clientverify['token'] != session_id()) ||
($clientverify['lastip'] != $_SERVER['REMOTE_ADDR'])
)
{
session_destroy();
header( "Location: login.php" );
die();
}
/**
* Define Language Using 'php gettext'
*/
defineLanguage($_SESSION['clientlang']);
query_basic( "UPDATE `".DBPREFIX."client` SET `lastactivity` = '".$_SERVER['REQUEST_TIME']."' WHERE `clientid` = '".$_SESSION['clientid']."'" );
}
/**
* GET BrightGamePanel Database INFORMATION
* Load 'values' from `config` Table
*/
$panelName = query_fetch_assoc( "SELECT `value` FROM `".DBPREFIX."config` WHERE `setting` = 'panelname' LIMIT 1" );
$panelVersion = query_fetch_assoc( "SELECT `value` FROM `".DBPREFIX."config` WHERE `setting` = 'panelversion' LIMIT 1" );
$template = query_fetch_assoc( "SELECT `value` FROM `".DBPREFIX."config` WHERE `setting` = 'clienttemplate' LIMIT 1" );
$maintenance = query_fetch_assoc( "SELECT `value` FROM `".DBPREFIX."config` WHERE `setting` = 'maintenance' LIMIT 1" );
/**
* GET BGP CORE FILES INFORMATION
* Load version.xml (ROOT/.version/version.xml)
*/
$bgpCoreInfo = simplexml_load_file('./.version/version.xml');
/**
* VERSION CONTROL
* Check that core files are compatible with the current BrightGamePanel Database
*/
if ($panelVersion['value'] != $bgpCoreInfo->{'version'})
{
die();
}
/**
* CONSTANTS
*/
define( 'SITENAME', $panelName['value'] );
define( 'DBVERSION', $panelVersion['value'] );
define( 'TEMPLATE', $template['value'] );
define( 'MAINTENANCE', $maintenance['value'] );
unset($panelName, $panelVersion, $template, $maintenance);
define( 'PROJECT', $bgpCoreInfo->{'project'} );
define( 'PACKAGE', $bgpCoreInfo->{'package'} );
define( 'BRANCH', $bgpCoreInfo->{'branch'} );
define( 'COREVERSION', $bgpCoreInfo->{'version'} );
define( 'RELEASEDATE', $bgpCoreInfo->{'date'} );
unset($bgpCoreInfo);
/**
* CRYPT_KEY is the Passphrase Used to Cipher/Decipher SSH Passwords
* The key is stored into the file: ".ssh/passphrase"
*/
define('CRYPT_KEY', file_get_contents("./.ssh/passphrase"));
/**
* MAINTENANCE CHECKER
* Logout client.
*/
if (MAINTENANCE == 1)
{
if (isClientLoggedIn() == TRUE)
{
logout();
exit('<h1><b>503 Service Unavailable</b></h1>'); //If the maintenance mode is ON, we drop the user.
}
}
?>