-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
297 lines (231 loc) · 7.59 KB
/
index.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<?php
/*
Urt Admin Web Interface
Developed By: |ALPHA|mission
Read the README.txt file for copyrite info
Version: 1.1
Version Date: Oct 4, 2010
*/
preg_match("/[^\.\/]+\.[^\.\/]+$/", $_SERVER['HTTP_HOST'], $matches);
$domain = $matches[0];
define('INCLUDE_CHECK',true);
require("classes/ipcheck.php");
require 'classes/functions.php';
require 'classes/functions2.php';
require 'classes/q3status.php';
require 'classes/q3rcon.php';
require 'classes/config_inc.php';
$userIP = $_SERVER['REMOTE_ADDR'];
if ($CONFIG['ip_check'] == "On") {
$c = new ipcheck;
$c->checkip($userIP);
}
// Those two files can be included only if INCLUDE_CHECK is defined
session_name('Login');
// Starting the session
session_set_cookie_params(2*7*24*60*60);
// Making the cookie live for 2 weeks
session_start();
$theme = $_REQUEST['settheme'];
if ($theme != '') {
$_SESSION['theme'] = $theme;
$dblink = mysql_connect($db_host,$db_user,$db_pass) or die('Unable to establish a DB connection');
mysql_select_db($db_database, $dblink);
$query = "update `".$db_table."` set `theme`=\"".$theme."\" where `id`='".$_SESSION['id']."'";
mysql_query($query);
$oneyear = 60 * 60 * 24 * 365 + time();
setcookie('currenttheme', $_SESSION['theme'], $oneyear);
}
if($_SESSION['id'] && !isset($_COOKIE['urtAdminRemember']) && !$_SESSION['rememberMe'])
{
// If you are logged in, but you don't have the tzRemember cookie (browser restart)
// and you have not checked the rememberMe checkbox:
$_SESSION = array();
session_destroy();
// Destroy the session
}
if(isset($_GET['logoff']))
{
$_SESSION = array();
session_destroy();
header("Location: index.php");
exit;
}
if($_POST['submit']=='Login')
{
// Checking whether the Login form has been submitted
$err = array();
// Will hold our errors
if(!$_POST['username'] || !$_POST['password'])
$err[] = 'All the fields must be filled in!';
if(!count($err))
{
$_POST['username'] = mysql_real_escape_string($_POST['username']);
$_POST['password'] = mysql_real_escape_string($_POST['password']);
$_POST['rememberMe'] = (int)$_POST['rememberMe'];
// Escaping all input data
$row = mysql_fetch_assoc(mysql_query("SELECT id,usr,admin,fullname,theme FROM ".$db_table." WHERE usr='{$_POST['username']}' AND pass='".md5($_POST['password'])."'"));
if($row['usr'])
{
// If everything is OK login
$_SESSION['usr']=$row['usr'];
$_SESSION['id'] = $row['id'];
$_SESSION['admin'] = $row['admin'];
$_SESSION['userName'] = $row['usr'];
$_SESSION['password'] = $row['password'];
$_SESSION['userFull'] = $row['fullname'];
$_SESSION['userIP'] = $row['ipaddress'];
$_SESSION['userRole'] = $row['userRole'];
$_SESSION['rememberMe'] = $_POST['rememberMe'];
$_SESSION['timeout'] = time();
$_SESSION['theme'] = $row['theme'];
$oneyear = 60 * 60 * 24 * 365 + time();
setcookie('currenttheme', $_SESSION['theme'], $oneyear);
// Store some data in the session
setcookie('urtAdminRemember',$_POST['rememberMe']);
}
else $err[]='Wrong username and/or password!';
}
if($err)
$_SESSION['msg']['login-err'] = implode('<br />',$err);
// Save the error messages in the session
header("Location: index.php");
exit;
}
$script = '';
if($_SESSION['msg'])
{
// The script below shows the sliding panel on page load
$script = '
<script type="text/javascript">
$(function(){
$("div#panel").show();
$("#toggle a").toggle();
});
</script>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $title;?></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<?php include "classes/head.php" ?>
<?php echo $script; ?>
<!-- PNG FIX for IE6 -->
<!-- http://24ways.org/2007/supersleight-transparent-png-in-ie6 -->
<!--[if lte IE 6]>
<script type="text/javascript" src="login_panel/js/pngfix/supersleight-min.js"></script>
<![endif]-->
<script src="login_panel/js/slide.js" type="text/javascript"></script>
</head>
<body class='flexcroll'>
<!-- Panel -->
<div id="toppanel">
<div id="panel">
<div class="content clearfix">
<div class="left">
<?php echo getmod(news); ?>
</div>
<?php
if(!$_SESSION['id']):
?>
<div class="left">
<!-- Login Form -->
<form class="clearfix" action="" method="post">
<h1>Administrator Login</h1>
<?php
if($_SESSION['msg']['login-err'])
{
echo '<div class="err">'.$_SESSION['msg']['login-err'].'</div>';
unset($_SESSION['msg']['login-err']);
}
?>
<label class="grey" for="username">Username:</label>
<input class="field" type="text" name="username" id="username" value="" size="23" />
<label class="grey" for="password">Password:</label>
<input class="field" type="password" name="password" id="password" size="23" />
<label><input name="rememberMe" id="rememberMe" type="checkbox" checked="checked" value="1" /> Remember me</label>
<div class="clear"></div>
<input type="submit" name="submit" value="Login" class="bt_login" />
</form>
</div>
<div class="left right">
<?php
if ($_SESSION['id']) {
echo getmod(reg);
}
?>
</div>
<?php
else:
?>
<div class="left">
<h1>Administrators panel</h1>
<a href="?logoff">Log off</a>
</div>
<div class="left right">
<?php
if ($_SESSION['id']) {
echo getmod(admin);
}?>
</div>
<?php
endif;
?>
</div>
</div> <!-- /login -->
<!-- The tab on top -->
<div class="tab">
<ul class="login">
<li class="left"> </li>
<li>Hello <?php echo $_SESSION['userFull'] ? $_SESSION['userFull'] : 'Guest';?>!</li>
<li class="sep">|</li>
<li id="toggle">
<a id="open" class="open" href="#"><?php echo $_SESSION['id']?'Open Panel':'Log In | Register';?></a>
<a id="close" style="display: none;" class="close" href="#">Close Panel</a>
</li>
<li class="right"> </li>
</ul>
</div> <!-- / top -->
</div> <!--panel -->
<div class="pageContent">
<div id="main" align="center">
<?php
if ($_SESSION['id']) {
echo "<table><tr><td valign='top' width='15%'>";
//left panel content
echo getmod(left);
echo "</td><td valign='top'>
<div class='container2'>
<br><br></div>
<div class='container3'>
<h1>{$CONFIG['header']}</h1>
<h2>{$CONFIG['subheader']}</h2>
</div>";
//body content
echo getmod(body);
// User Content;
echo "<table><tr><td valign='top' width='220px'>";
echo getmod(user1);
echo"</td><td valign='top' width='220px'>";
echo getmod(user2);
echo "</td><td valign='top' width='220px'>";
echo getmod(user3);
echo "</td></tr></table>";
//footer
echo getmod(footer);
echo "</td></tr></table>";
if($_SESSION['admin'] == 'Yes') {
echo "<br><br><div align='center'><a href='admin/'><button class='nav'>Admin Backend</button></a></div>";
}
} else {
echo "<div class='container'><div align='center'><h1>You need to login to view this site!<h1></div></div>";
}
echo "<br><br><div align='center'><font color='white'>{$domain}, Powered by UrtAdmin Web Interface v1.1</font></div>";
?>
</div>
</div>
</body>
</html>