-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathauthenticate.php
executable file
·65 lines (63 loc) · 1.91 KB
/
authenticate.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
<?php
session_start();
if ($_POST['username'] == "" || $_POST['password'] == "")
{
die(
"<h3>breakthenet Error</h3>
You did not fill in the login form!<br />
<a href=login.php>> Back</a>");
}
include "mysql.php";
require "global_func.php";
$username =
(array_key_exists('username', $_POST) && is_string($_POST['username']))
? $_POST['username'] : '';
$password =
(array_key_exists('password', $_POST) && is_string($_POST['password']))
? $_POST['password'] : '';
if (empty($username) || empty($password))
{
die(
"<h3>breakthenet Error</h3>
You did not fill in the login form!<br />
<a href='login.php'>> Back</a>");
}
$form_username = mysql_real_escape_string(stripslashes($username), $c);
$raw_password = stripslashes($password);
$uq =
mysql_query(
"SELECT `userid`, `userpass`, `pass_salt`
FROM `users`
WHERE `login_name` = '$form_username'", $c);
if (mysql_num_rows($uq) == 0)
{
die(
"<h3>breakthenet Error</h3>
Invalid username or password!<br />
<a href='login.php'>> Back</a>");
}
else
{
$mem = mysql_fetch_assoc($uq);
$login_failed = !(verify_user_password($raw_password, $mem['userpass']));
if ($login_failed)
{
die(
"<h3>breakthenet Error</h3>
Invalid username or password!<br />
<a href='login.php'>> Back</a>");
}
if ($mem['userid'] == 1 && file_exists('./installer.php'))
{
die(
"<h3>breakthenet Error</h3>
The installer still exists! You need to delete installer.php immediately.<br />
<a href='login.php'>> Back</a>");
}
session_regenerate_id();
$_SESSION['loggedin'] = 1;
$_SESSION['userid'] = $mem['userid'];
$loggedin_url = 'http://' . determine_game_urlbase() . '/loggedin.php';
header("Location: {$loggedin_url}");
exit;
}