-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGenerateKey.php
44 lines (31 loc) · 1.08 KB
/
GenerateKey.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
<?php
include_once("config.php"); //import config file.
$token = $_POST["token"];
$key = $_POST["key"];
$trueToken = $_token; //The true token.
$jsonFile = json_decode(file_get_contents("OneCode.json"));
$codeUsed = $jsonFile -> USED;
$codeTime = $jsonFile -> TIME;
$returnJSON = array();
if($codeUsed == "false"){
if($token == $trueToken && $key == $_key){
$oneCode = rand(100000,999999);
$oneCodeEncrypt = $oneCode.$_salt;
$oneCodeEncrypt = hash("sha256", $oneCodeEncrypt); //Hash the OneCode.
$onceCodeJSON = array();
$onceCodeJSON['ONECODE'] = $oneCodeEncrypt;
$onceCodeJSON['TIME'] = date("Y-m-d H:i:s",intval(time()));
$onceCodeJSON['USED'] = "false";
$onceCodeJSON['ERRORTIME'] = 0;
file_put_contents('OneCode.json', json_encode($onceCodeJSON));
$returnJSON['CODE'] = 200;
$returnJSON['Message'] = "OK";
$returnJSON['oneCode'] = $oneCode;
echo json_encode($returnJSON);
}else{
$returnJSON['CODE'] = 501;
$returnJSON['Message'] = "Authorization Error!";
echo json_encode($returnJSON);
}
}
?>