forked from ThomasMarangoni/WbbVerify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WbbVerify.php
68 lines (63 loc) · 1.74 KB
/
WbbVerify.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
<?php
/*
* This File is under the license of Creative Commons BY-NC 3.0 AT
* Author: Thomas Marangoni/DasChaos
* Created: 26.01.2018
*
* You are only allowed to use this file in non-commercial way.
* If you are using this file, you have to mark the author, add a link to the License
* and announce any changes.
*
* https://creativecommons.org/licenses/by-nc/3.0/at/
*
*/
require_once('global.php');
use wcf\data\user\User;
use wcf\data\user\group\UserGroup;
$code = 0;
$json = ["StatusCode" => $code, "UserData" => null];
checkPassword($_POST['Username'], $_POST['Password'], $_POST['Key']);
function checkPassword($username, $password, $key) {
$secretKey = ""; //128-Character Key
if (strcmp($key, $secretKey) != 0)
{
global $code;
global $json;
$code = 1;
$json = ["statusCode" => $code, "userData" => null];
return null;
}
if (empty($username) || empty($password)) {
global $code;
global $json;
$code = 2;
$json = ["statusCode" => $code, "userData" => null];
return null;
}
$user = User::getUserByUsername($username);
if(!$user->userID)
{
global $code;
global $json;
$code = 11;
$json = ["statusCode" => $code, "userData" => null];
return null;
}
else if (!$user->checkPassword($password)) {
global $code;
global $json;
$code = 11;
$json = ["statusCode" => $code, "userData" => null];
return null;
}
else {
global $code;
global $json;
$whitelisted = in_array(10 ,$user->getGroupIDs()); //Replace 10 with Group ID which is for whitelist
$code = 10;
$json = ["statusCode" => $code, "userData" => ["userId" => $user->userID, "username" => $user->username, "banned" => (bool)$user->banned, "banReason" => $user->banReason, "whitelisted" => (bool)$whitelisted]];
return null;
}
}
echo json_encode($json);
?>