forked from udsaxman/Sapphirev2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
processRegister.php
107 lines (80 loc) · 2.09 KB
/
processRegister.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
<?php
include 'connection.php';
session_start();
$theName = "";
$passwordOne = "";
$passwordTwo = "";
$fail = false;
$userSalt = "";
if (isset($_POST["name"])) {
$theName = $_POST["name"];
$strSearch = "'";
$strSearch2 = "*";
$strSearch3 = "\"";
$pos = stripos($theName, $strSearch);
$pos2 = stripos($theName, $strSearch2);
$pos3 = stripos($theName, $strSearch3);
if ($pos === false && $pos2 === false && $pos3 === false) {
} else {
$fail = true;
}
if (trim($theName) == "") {
$fail = true;
}
} else {
$fail = true;
}
if (isset($_POST["passwordOne"])) {
$passwordOne = $_POST["passwordOne"];
} else {
$fail = true;
}
if (isset($_POST["passwordTwo"])) {
$passwordTwo = $_POST["passwordTwo"];
} else {
$fail = true;
}
$strSearch = "'";
//$strSearch2 = "*";
$strSearch3 = "\"";
$pos = stripos($passwordOne, $strSearch);
//$pos2 = stripos($passwordOne, $strSearch2);
$pos3 = stripos($passwordOne, $strSearch3);
if ($pos === false && $pos3 === false) {
} else {
$fail = true;
}
$valid = 1;
$count = 0;
function fail()
{
header('Location: ./TDSInError.php?Error=Failed_To_Register_Please_Try_Again');
}
function success()
{
header('Location: ./TDSInPlayerPage.php');
}
if ($passwordOne != $passwordTwo || $fail) {
fail();
} else {
$sql = "Select LOWER(user_name) from Users where= '" . strtolower($theName) . "'";
//$sql = "SELECT user_name FROM Users";
$result = $mysqli->query($sql);
if ($result->num_rows != 0) {
// User not found. So, redirect to login_form again.
$valid = 0;
}
$userSalt = uniqid();
$hash = crypt($passwordOne, '$6$rounds=10000$' + $userSalt + '$');
if ($valid != 0) {
//id , user_name , password , isk , rank
//rank was changed to 5 by default so admins are considered 0
$sql = "Call sp_AddNewUser('" . $theName . "', '" . $hash . "', '" . $userSalt . "')";
$result = mysql_query($sql, $conn) or die(mysql_error());
$_SESSION["userName"] = $theName;
success();
} else {
fail();
}
}
?>