From 4e8012e95b976941ef4b72a022d785993506c374 Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Sat, 10 Sep 2022 15:58:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EAPI=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/get_book/change.php | 55 +++++++++++++++++++++++ api/get_book/index.php | 44 +++++++++++++++++++ api/header-control.php | 18 ++++++++ api/index.php | 18 ++++++++ get_book.php | 96 ++++++++++++++++++++++++++++++++++++++--- get_book_upload.php | 55 +++++++++++++++++++++++ module/menu.php | 2 +- 7 files changed, 280 insertions(+), 8 deletions(-) create mode 100644 api/get_book/change.php create mode 100644 api/get_book/index.php create mode 100644 api/header-control.php create mode 100644 api/index.php create mode 100644 get_book_upload.php diff --git a/api/get_book/change.php b/api/get_book/change.php new file mode 100644 index 0000000..5b64207 --- /dev/null +++ b/api/get_book/change.php @@ -0,0 +1,55 @@ +s_ID)) { + if (mysqli_query($conn,"INSERT INTO ".$setting['SQL_DATA']['book']." (s_ID,getbook,time) VALUES ('$student','TRUE','$time')")) { + // 编译数据 + $data = array( + 'output'=>'SUCCESS', + 'code'=>200, + 'info'=>'操作已完成', + ); + // 输出数据 + echo json_encode($data,JSON_UNESCAPED_UNICODE); + } + } else { + // 编译数据 + $data = array( + 'output'=>'SQL_DENY', + 'code'=>403, + 'info'=>'操作拒绝!已经有数据了' + ); + // 输出数据 + echo json_encode($data,JSON_UNESCAPED_UNICODE); + } + mysqli_query($conn,"UNLOCK TABLE"); +} else { + // 编译数据 + $data = array( + 'output'=>'KEY_ERROR', + 'code'=>403, + 'info'=>'密钥错误' + ); + // 输出数据 + echo json_encode($data,JSON_UNESCAPED_UNICODE); + header("HTTP/1.1 403 Forbidden"); +} \ No newline at end of file diff --git a/api/get_book/index.php b/api/get_book/index.php new file mode 100644 index 0000000..eb43ef3 --- /dev/null +++ b/api/get_book/index.php @@ -0,0 +1,44 @@ +studentID] = array( + 'studentID'=>$result_book_object->studentID, + 'name'=>$result_book_object->name, + 'need_book'=>$result_book_object->get_book, + 'get_book'=>$result_book_object->getbook + ); + } + // 编译数据 + $data = array( + 'output'=>'SUCCESS', + 'code'=>200, + 'info'=>'输出成功', + 'data'=>$array, + ); + // 输出数据 + echo json_encode($data,JSON_UNESCAPED_UNICODE); +} else { + // 编译数据 + $data = array( + 'output'=>'KEY_ERROR', + 'code'=>403, + 'info'=>'密钥错误' + ); + // 输出数据 + echo json_encode($data,JSON_UNESCAPED_UNICODE); + header("HTTP/1.1 403 Forbidden"); +} \ No newline at end of file diff --git a/api/header-control.php b/api/header-control.php new file mode 100644 index 0000000..79cbde6 --- /dev/null +++ b/api/header-control.php @@ -0,0 +1,18 @@ +'SUCCESS', + 'code'=>200, + 'info'=>'当看到此页面代表所有API项目正常运行' +); + +// 输出数据 +echo json_encode($data,JSON_UNESCAPED_UNICODE); \ No newline at end of file diff --git a/get_book.php b/get_book.php index 038c810..2342d0a 100644 --- a/get_book.php +++ b/get_book.php @@ -2,8 +2,19 @@ // 页面ID $menu_page = 7; // 载入组件 +include($_SERVER['DOCUMENT_ROOT'].'/setting.inc.php'); include($_SERVER['DOCUMENT_ROOT'].'/module/head-check.php'); include($_SERVER['DOCUMENT_ROOT'].'/plugins/function.php'); +// 配置信息 +$key = htmlspecialchars($_GET['key']); + +// 载入信息 +$book_url = $setting['API']['Domain'].'/get_book/?key='.$setting['Key']; +$book_ch = curl_init($book_url); +curl_setopt($book_ch,CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']); +curl_setopt($book_ch, CURLOPT_RETURNTRANSFER, true); +$book = curl_exec($book_ch); +$book = json_decode($book,true); ?> -
书本领取登记
+
书本领取登记