You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.0 KiB
47 lines
1.0 KiB
<?php |
|
|
|
include './functions.php'; |
|
|
|
$redis = new redis(); |
|
$redis->connect('redis',6379); |
|
|
|
|
|
$hash = $_REQUEST['hash']; |
|
|
|
if(!isset($hash)) die(); |
|
|
|
|
|
|
|
if($redis->exists('account/'.$hash)){ |
|
|
|
$cnn = db__connect(); |
|
$arr = json_decode($redis->get('account/'.$hash), true); |
|
|
|
if(!$arr['isExist']){ |
|
$arr_t = $arr; |
|
foreach($arr_t as $i => $t){ |
|
if($t == ''){ |
|
unset($arr_t[$i]); |
|
} |
|
} |
|
unset($arr_t['isExist']); |
|
$cnn = db__connect(); |
|
db__pushData($cnn, "account", $arr_t); |
|
$arr['isExist'] = true; |
|
$redis->set('account/'.$hash, json_encode($arr)); |
|
} |
|
|
|
$token = hash('sha256', $hash.time()); |
|
$redis->set('auth/token/'.$token, $hash); |
|
db__pushData($cnn, "token", array( |
|
"token"=>$token, |
|
"hash"=>$hash, |
|
"created_at"=>date("Y-m-d H:i:s", time()), |
|
"state"=>'1' |
|
)); |
|
|
|
echo json_encode(array("code"=> 200, "token"=>$token, "message" => "Verified successfully!")); |
|
|
|
}else{ |
|
echo json_encode(array("code"=> 500, "message"=>"Error!!")); |
|
}
|
|
|