-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.php
More file actions
139 lines (108 loc) · 3.57 KB
/
Copy pathhandler.php
File metadata and controls
139 lines (108 loc) · 3.57 KB
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
<?php
/*
OpenSimulator Web Login
Copyright (C) 2019 VortexSystems and its Contributors
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 <https://www.gnu.org/licenses/>.
*/
// Report all errors
error_reporting(E_ALL);
require"config.php";
$return = $_POST["return"];
$last_name = $_POST["last"];
$first_name = $_POST["first"];
$password = $_POST["password"];
$remember = $_POST["remember"];
/**
* Returns a OpenSim UUID based on the Provided First and Last Name
* This Queries your Database to get the UUID of the User Logging In
* @param string $first The First Name of the User
* @param string $last The Last Name of the User
* @param object $db The Database Object Connected to the ROBUST DB
* @return string $uuid The UUID of your person
*/
function get_uuid_by_user($first, $last, $db){
$sql = "SELECT `PrincipalID` FROM `useraccounts` WHERE `FirstName` = '" . $first ."' AND `LastName` = '" . $last . "' LIMIT 1";
$result = mysqli_query($db, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
$uuid = $row["PrincipalID"];
}
} else {
die();
}
return $uuid;
}
/**
* Retrieves the Hash from the ROBUST AUTH Table
* @param string $uuid The UUID of your User
* @param object $db DB Object of your ROBUST Instance
* @return string $hash The UUID of your person
*/
function get_hash_by_uuid($uuid, $db){
$sql = "SELECT `passwordHash` FROM `auth` WHERE `UUID` = '" . $uuid . "' LIMIT 1";
$result = mysqli_query($db, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
$hash = $row["passwordHash"];
}
} else {
die();
}
return $hash;
}
/**
* Retrieves the Salt from the ROBUST AUTH Table
* @param string $uuid The UUID of your User
* @param object $db DB Object of your ROBUST Instance
* @return string $salt The SALT of your person
*/
function get_salt_by_uuid($uuid, $db){
$sql = "SELECT `passwordSalt` FROM `auth` WHERE `UUID` = '" . $uuid . "' LIMIT 1";
$result = mysqli_query($db, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
$salt = $row["passwordSalt"];
}
} else {
die();
}
return $salt;
}
/**
* Attemps to See if your so called person is correct in their auth
* @param string $salt The Salt
* @param string $hash Hash
* @param string $pass the password submitted
* @return bool $correct TRUE/False if all documents are in order
*/
function check_my_id($salt, $hash, $pass){
$p = md5($pass);
$attempt = md5($p.":".$salt);
//$a2 = md5($attempt);
if($attempt == $hash)
{
return TRUE;
}
else{
return FALSE;
}
}
/// get to work
$uuid = get_uuid_by_user($first_name, $last_name, $conn);
// echo "Hash : " . get_hash_by_uuid($uuid, $conn) . " | Salt : " . get_salt_by_uuid($uuid, $conn);
$r_hash = get_hash_by_uuid($uuid, $conn);
$r_salt = get_salt_by_uuid($uuid, $conn);
$validity = check_my_id($r_salt, $r_hash, $password);
echo $validity;