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.
 
 
 
 
 
 

41 lines
1.2 KiB

<?php
@include 'conn.conn';
$GLOBALS['conn'];
$conn = @mysqli_connect($DATAhst,$DATAusr,$DATApwd,$DATAdtb)or die("CONNECTION ERROR");
$content = null;
$content->status = 200;
$data = json_decode(file_get_contents("php://input"));
if(isset($_GET['act']) && $_GET['act'] == 'login') {
if(isset($data->usr) && $data->usr == 'admin' && isset($data->pwd) && $data->pwd == 'JohnHolmes') {
http_response_code(200);
$content->status = 200;
$content->authToken = base64_encode('admin:JohnHolmes'.date("Y-m-d"));
} else {
http_response_code(401);
$content->status = 401;
$content->action = 'login';
}
} else if(isset($_GET['act']) && $_GET['act'] == 'check') {
if(isset($data->token) && $data->token == base64_encode('admin:JohnHolmes'.date("Y-m-d"))) {
http_response_code(200);
$content->status = 200;
$content->authToken = base64_encode('admin:JohnHolmes'.date("Y-m-d"));
} else {
http_response_code(200);
$content->status = 401;
$content->action = 'check';
$content->token = $data->token;
}
}
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
echo json_encode($content);
?>