登录API及API修改
This commit is contained in:
parent
e67cc77134
commit
a888c83871
57
api/auth/login.php
Normal file
57
api/auth/login.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?PHP
|
||||
/*
|
||||
* wxxy_class 项目组
|
||||
* 代码均开源
|
||||
*/
|
||||
|
||||
// 载入头
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/api/header-control.php');
|
||||
|
||||
// 载入组件
|
||||
$key = htmlspecialchars($_GET['key']);
|
||||
|
||||
// 获取参数
|
||||
$post = file_get_contents('php://input');
|
||||
$POST_INFO = json_decode($post,true);
|
||||
|
||||
// 构建函数
|
||||
if ($key == $setting['Key']) {
|
||||
// 对数据进行转义,避免数据库注入
|
||||
$info['studentID'] = addslashes($POST_INFO['studentID']);
|
||||
$info['password'] = $POST_INFO['password'];
|
||||
|
||||
// 进行数据库匹配(由于没有设置过于复杂的密码则没有)
|
||||
$result_person = mysqli_query($conn,"SELECT * FROM ".$setting['SQL_DATA']['info']." WHERE studentID='".$info['studentID']."'");
|
||||
$result_person_object = mysqli_fetch_object($result_person);
|
||||
// 进行密码校验
|
||||
if (password_verify($info['password'],$result_person_object->password)) {
|
||||
// 编译数据
|
||||
$data = array(
|
||||
'output'=>'SUCCESS',
|
||||
'code'=>200,
|
||||
'info'=>'密码正确',
|
||||
);
|
||||
// 输出数据
|
||||
echo json_encode($data,JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
// 编译数据
|
||||
$data = array(
|
||||
'output'=>'PASSWORD_DENY',
|
||||
'code'=>403,
|
||||
'info'=>'密码错误'
|
||||
);
|
||||
// 输出数据
|
||||
echo json_encode($data,JSON_UNESCAPED_UNICODE);
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
}
|
||||
} else {
|
||||
// 编译数据
|
||||
$data = array(
|
||||
'output'=>'KEY_ERROR',
|
||||
'code'=>403,
|
||||
'info'=>'密钥错误'
|
||||
);
|
||||
// 输出数据
|
||||
echo json_encode($data,JSON_UNESCAPED_UNICODE);
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
}
|
|
@ -15,7 +15,6 @@ $time = date("Y-m-d H:i:s");
|
|||
// 构建函数
|
||||
if ($key == $setting['Key']) {
|
||||
// 对数据表进行检查
|
||||
|
||||
// 对数据表进行写入操作
|
||||
mysqli_query($conn,"LOCK TABLE ".$setting['SQL_DATA']['book']." WRITE");
|
||||
$result_book_person = mysqli_query($conn,"SELECT * FROM ".$setting['SQL_DATA']['book']." WHERE s_ID='$student'");
|
||||
|
|
Loading…
Reference in New Issue
Block a user