From 4d2d5e2d5e89852c13a80102bbb0f4b8132a0c61 Mon Sep 17 00:00:00 2001 From: monjack Date: Mon, 6 Jan 2025 19:52:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 +++ .idea/20250103.iml | 8 +++ .idea/modules.xml | 8 +++ .idea/php.xml | 20 ++++++ .idea/vcs.xml | 4 ++ acl_list.php | 17 +++++ api_183_1.php | 38 +++++++++++ api_183_2.php | 38 +++++++++++ create_tables.php | 102 ++++++++++++++++++++++++++++++ db_config.php | 7 +++ form_test_2.php | 43 +++++++++++++ form_test_74_2.php | 79 +++++++++++++++++++++++ list_72.php | 97 ++++++++++++++++++++++++++++ login.php | 52 +++++++++++++++ patient_register_90.php | 114 +++++++++++++++++++++++++++++++++ patient_register_list_90.php | 107 +++++++++++++++++++++++++++++++ r_1.php | 14 +++++ r_2.php | 9 +++ r_3.php | 8 +++ register.php | 73 ++++++++++++++++++++++ robot_251_1.php | 5 ++ setup.html | 50 +++++++++++++++ setup.php | 118 +++++++++++++++++++++++++++++++++++ spider_251_2.php | 38 +++++++++++ upload_1.php | 46 ++++++++++++++ user_info.php | 22 +++++++ www/admin/main.php | 7 +++ www/config/config.php | 7 +++ www/display.html | 10 +++ www/index.html | 10 +++ www/lib/class.php | 7 +++ www/list.html | 11 ++++ 32 files changed, 1177 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/20250103.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/vcs.xml create mode 100644 acl_list.php create mode 100644 api_183_1.php create mode 100644 api_183_2.php create mode 100644 create_tables.php create mode 100644 db_config.php create mode 100644 form_test_2.php create mode 100644 form_test_74_2.php create mode 100644 list_72.php create mode 100644 login.php create mode 100644 patient_register_90.php create mode 100644 patient_register_list_90.php create mode 100644 r_1.php create mode 100644 r_2.php create mode 100644 r_3.php create mode 100644 register.php create mode 100644 robot_251_1.php create mode 100644 setup.html create mode 100644 setup.php create mode 100644 spider_251_2.php create mode 100644 upload_1.php create mode 100644 user_info.php create mode 100644 www/admin/main.php create mode 100644 www/config/config.php create mode 100644 www/display.html create mode 100644 www/index.html create mode 100644 www/lib/class.php create mode 100644 www/list.html diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/20250103.iml b/.idea/20250103.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/20250103.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..965b76b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..1d26366 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..d843f34 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/acl_list.php b/acl_list.php new file mode 100644 index 0000000..f671e17 --- /dev/null +++ b/acl_list.php @@ -0,0 +1,17 @@ + array("r_1.php", "r_2.php", "r_3.php"), + "manager" => array("r_2.php", "r_3.php"), + "staff" => array("r_3.php") +); + +// 定义检查权限的函数 +function checkAccess($role, $resource) { + global $acl; + if (isset($acl[$role]) && in_array($resource, $acl[$role])) { + return true; // 有权限 + } + return false; // 无权限 +} + diff --git a/api_183_1.php b/api_183_1.php new file mode 100644 index 0000000..06e5c5c --- /dev/null +++ b/api_183_1.php @@ -0,0 +1,38 @@ + "Missing required parameters: student_id, english, math, computer" + ]); + exit; +} + +// 验证分数是否为数字 +if (!is_numeric($english) || !is_numeric($math) || !is_numeric($computer)) { + // 返回错误信息 + echo json_encode([ + "error" => "Parameters english, math, and computer must be numeric" + ]); + exit; +} + +// 计算总分 +$sum = $english + $math + $computer; + +// 封装为 JSON 格式 +$response = [ + "student_id" => $student_id, + "sum" => (string)$sum // 转为字符串以匹配返回格式 +]; + +// 输出 JSON +header('Content-Type: application/json'); +echo json_encode($response); +?> diff --git a/api_183_2.php b/api_183_2.php new file mode 100644 index 0000000..cdc25fd --- /dev/null +++ b/api_183_2.php @@ -0,0 +1,38 @@ + "Missing required parameters: student_id, english, math, computer" + ]); + exit; +} + +// 验证分数是否为数字 +if (!is_numeric($english) || !is_numeric($math) || !is_numeric($computer)) { + // 返回错误信息 + echo json_encode([ + "error" => "Parameters english, math, and computer must be numeric" + ]); + exit; +} + +// 计算最高分 +$max = max($english, $math, $computer); + +// 封装为 JSON 格式 +$response = [ + "student_id" => $student_id, + "max" => (string)$max // 转为字符串以匹配返回格式 +]; + +// 输出 JSON +header('Content-Type: application/json'); +echo json_encode($response); +?> diff --git a/create_tables.php b/create_tables.php new file mode 100644 index 0000000..6d8d48e --- /dev/null +++ b/create_tables.php @@ -0,0 +1,102 @@ +connect_error) { + die("数据库连接失败: " . $conn->connect_error); +} + +// 设置字符集 +$conn->set_charset("utf8"); + +// 创建患者表 +$sql_patient = " + CREATE TABLE IF NOT EXISTS patient_90 ( + patient_id CHAR(50), + patient_name CHAR(50), + patient_gender CHAR(1), + patient_address CHAR(50) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8; +"; + +if ($conn->query($sql_patient) === TRUE) { + echo "患者表创建成功!
"; +} else { + echo "创建患者表失败: " . $conn->error . "
"; +} + +// 创建医生表 +$sql_doctor = " + CREATE TABLE IF NOT EXISTS doctor_90 ( + doctor_id CHAR(50), + doctor_name CHAR(50), + doctor_gender CHAR(1), + department_id CHAR(50) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8; +"; + +if ($conn->query($sql_doctor) === TRUE) { + echo "医生表创建成功!
"; +} else { + echo "创建医生表失败: " . $conn->error . "
"; +} + +// 创建科室表 +$sql_department = " + CREATE TABLE IF NOT EXISTS department_90 ( + department_id CHAR(50), + department_name CHAR(50), + department_location CHAR(50) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8; +"; + +if ($conn->query($sql_department) === TRUE) { + echo "科室表创建成功!
"; +} else { + echo "创建科室表失败: " . $conn->error . "
"; +} + +// 创建挂号表 +$sql_register = " + CREATE TABLE IF NOT EXISTS register_90 ( + biz_id CHAR(50), + doctor_id CHAR(50), + patient_id CHAR(50), + register_date INT, + fee INT, + state CHAR(1) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8; +"; + +if ($conn->query($sql_register) === TRUE) { + echo "挂号表创建成功!
"; +} else { + echo "创建挂号表失败: " . $conn->error . "
"; +} + +// 插入测试数据 +$sql_insert = " + INSERT IGNORE INTO patient_90 (patient_id, patient_name, patient_gender, patient_address) VALUES + ('510103001', '张三', '1', '成都'), + ('510103002', '李四', '2', '重庆'); + + INSERT IGNORE INTO doctor_90 (doctor_id, doctor_name, doctor_gender, department_id) VALUES + ('510105001', '王医生', '2', '001'), + ('510105002', '罗医生', '1', '002'), + ('510105003', '陈医生', '1', '001'); + + INSERT IGNORE INTO department_90 (department_id, department_name, department_location) VALUES + ('001', '内科', '1楼2诊室'), + ('002', '外科', '1楼5诊室'); +"; + +if ($conn->multi_query($sql_insert) === TRUE) { + echo "测试数据插入成功!
"; +} else { + echo "插入测试数据失败: " . $conn->error . "
"; +} + +// 关闭数据库连接 +$conn->close(); +?> diff --git a/db_config.php b/db_config.php new file mode 100644 index 0000000..95ea00f --- /dev/null +++ b/db_config.php @@ -0,0 +1,7 @@ + + + + + 表单编程与现场恢复 + + + + + +
+ + +

+ + + +

+ + +
+ + + +

提交结果:

+

姓名:

+

处理后的密码:

+ + + diff --git a/form_test_74_2.php b/form_test_74_2.php new file mode 100644 index 0000000..0a80528 --- /dev/null +++ b/form_test_74_2.php @@ -0,0 +1,79 @@ + + + + + 表单提交与现场恢复 + + + + + +
+ + + +

+ + + 性别: + > + + > + +

+ + + 选课: + > + + > + + > + +

+ + + 籍贯: + +

+ + + +
+ + + +

提交结果:

+

姓名:

+

性别:

+

选课: + +

+

籍贯:

+ + + diff --git a/list_72.php b/list_72.php new file mode 100644 index 0000000..f810837 --- /dev/null +++ b/list_72.php @@ -0,0 +1,97 @@ +query($sql_count); +$total_records = $result_count->fetch_assoc()['total']; + +// 计算总页数 +$total_pages = ceil($total_records / $limit); + +// 根据action计算新的offset +switch ($action) { + case 'top': + $offset = 0; + break; + case 'previous': + $offset = max(0, $offset - $limit); + break; + case 'next': + $offset = min($total_records - $limit, $offset + $limit); + break; + case 'bottom': + $offset = max(0, ($total_pages - 1) * $limit); + break; + default: + $offset = 0; + break; +} + +// 查询当前页的数据 +$sql = "SELECT name FROM user_70 LIMIT $offset, $limit"; +$result = $conn->query($sql); + +?> + + + + + + 姓名列表 + + + + + + + + num_rows > 0) { + $index = $offset + 1; // 起始序号 + while ($row = $result->fetch_assoc()) { + echo ""; + $index++; + } + } else { + echo ""; + } + ?> + + + +
姓名列表
{$index}. {$row['name']}
没有数据
+ 首页 + 上一页 + 下一页 + 末页 +
+ + diff --git a/login.php b/login.php new file mode 100644 index 0000000..b8f99a3 --- /dev/null +++ b/login.php @@ -0,0 +1,52 @@ +prepare($sql); + $stmt->bind_param("ss", $name, $hashedPassword); + $stmt->execute(); + $result = $stmt->get_result(); + + if ($result->num_rows > 0) { + // 登录成功,设置 Session + $_SESSION['s_name'] = $name; + header("Location: user_info.php"); // 跳转到 user_info.php + exit(); + } else { + // 登录失败 + echo "用户名或密码错误!"; + } + } +} +?> + + + + + + 用户登录 + + +
+ +
+ +
+ +
+ + diff --git a/patient_register_90.php b/patient_register_90.php new file mode 100644 index 0000000..a77550e --- /dev/null +++ b/patient_register_90.php @@ -0,0 +1,114 @@ +query($sql_check); + + if ($result_check->num_rows > 0) { + // 更新挂号信息 + $sql_update = "UPDATE register_90 SET doctor_id = '$doctor_id', fee = $fee, state = '1' WHERE patient_id = '$patient_id' AND register_date = $current_date"; + if ($conn->query($sql_update)) { + $message = "挂号信息已更新!"; + } else { + $message = "更新失败: " . $conn->error; + } + } else { + // 插入新挂号记录 + $biz_id = generateUUID(); + $sql_insert = "INSERT INTO register_90 (biz_id, doctor_id, patient_id, register_date, fee, state) VALUES ('$biz_id', '$doctor_id', '$patient_id', $current_date, $fee, '1')"; + if ($conn->query($sql_insert)) { + $message = "挂号成功!"; + } else { + $message = "挂号失败: " . $conn->error; + } + } +} + +// 获取患者列表 +$sql_patients = "SELECT patient_id, patient_name FROM patient_90"; +$result_patients = $conn->query($sql_patients); + +// 获取医生和科室列表 +$sql_doctors = " + SELECT doctor_90.doctor_id, doctor_90.doctor_name, department_90.department_name + FROM doctor_90 + JOIN department_90 ON doctor_90.department_id = department_90.department_id"; +$result_doctors = $conn->query($sql_doctors); +?> + + + + + + 患者挂号 + + +

患者挂号

+
+ + + +

+ + + + +

+ + + + +

+ + + + +

+ + + +
+ +

+ + diff --git a/patient_register_list_90.php b/patient_register_list_90.php new file mode 100644 index 0000000..b2e779a --- /dev/null +++ b/patient_register_list_90.php @@ -0,0 +1,107 @@ +query($sql_query); +?> + + + + + + 患者挂号列表 + + + +

患者挂号列表

+
+ + + = + + +
+ +
+ + + + + + + + + + + + + num_rows > 0): ?> + fetch_assoc()) { ?> + + + + + + + + + + + + + + + +
科室医生患者就诊时间挂号费操作
+ 编辑 + | + 删除 +
暂无数据
+ + diff --git a/r_1.php b/r_1.php new file mode 100644 index 0000000..3207fc5 --- /dev/null +++ b/r_1.php @@ -0,0 +1,14 @@ + diff --git a/r_2.php b/r_2.php new file mode 100644 index 0000000..270a1e3 --- /dev/null +++ b/r_2.php @@ -0,0 +1,9 @@ + diff --git a/r_3.php b/r_3.php new file mode 100644 index 0000000..b15933c --- /dev/null +++ b/r_3.php @@ -0,0 +1,8 @@ +connect_error) { + die("连接失败: " . $conn->connect_error); +} + +// 检查是否提交表单 +if ($_SERVER["REQUEST_METHOD"] === "POST") { + $name = isset($_POST['name']) ? trim($_POST['name']) : ''; + $password = isset($_POST['password']) ? trim($_POST['password']) : ''; + + // 表单验证 + if (empty($name) || empty($password)) { + echo "姓名和密码不能为空!"; + } else { + // 密码加密 + $hashedPassword = md5($password); + + // 查询是否存在该用户 + $sql = "SELECT * FROM user_70 WHERE name = ?"; + $stmt = $conn->prepare($sql); + $stmt->bind_param("s", $name); + $stmt->execute(); + $result = $stmt->get_result(); + + if ($result->num_rows > 0) { + // 用户存在,更新密码 + $updateSql = "UPDATE user_70 SET password = ? WHERE name = ?"; + $updateStmt = $conn->prepare($updateSql); + $updateStmt->bind_param("ss", $hashedPassword, $name); + if ($updateStmt->execute()) { + echo "密码更新成功!"; + } else { + echo "密码更新失败:" . $conn->error; + } + } else { + // 用户不存在,插入新用户 + $insertSql = "INSERT INTO user_70 (name, password) VALUES (?, ?)"; + $insertStmt = $conn->prepare($insertSql); + $insertStmt->bind_param("ss", $name, $hashedPassword); + if ($insertStmt->execute()) { + echo "注册成功!"; + } else { + echo "注册失败:" . $conn->error; + } + } + } +} + +// 关闭数据库连接 +$conn->close(); +?> + + + + + + 用户注册与修改密码 + + +
+ +
+ +
+ +
+ + diff --git a/robot_251_1.php b/robot_251_1.php new file mode 100644 index 0000000..52f61f2 --- /dev/null +++ b/robot_251_1.php @@ -0,0 +1,5 @@ + + + + + 操作表 + + + + + + + + + + +
+
+ + \ No newline at end of file diff --git a/setup.php b/setup.php new file mode 100644 index 0000000..5a127b4 --- /dev/null +++ b/setup.php @@ -0,0 +1,118 @@ + 0) { + $tableExist = true; + }else{ + $tableExist = false; + } + if(!$tableExist){ + if($table == 'user_70'){ + $query_string = "create table user_70(name char(50),address char(50),password char(50))ENGINE=MyISAM DEFAULT CHARSET=utf8"; + mysqli_query($link,$query_string); + $query_string = "insert into user_70(name,address,password)values('mike','chengdu','c4ca4238a0b923820dcc509a6f75849b')"; + mysqli_query($link,$query_string); + $query_string = "insert into user_70(name,address,password)values('mike','beijing','c4ca4238a0b923820dcc509a6f75849b')"; + mysqli_query($link,$query_string); + $query_string = "insert into user_70(name,address,password)values('tom','chengdu','c4ca4238a0b923820dcc509a6f75849b')"; + mysqli_query($link,$query_string); + $query_string = "insert into user_70(name,address,password)values('rose','chengdu','c4ca4238a0b923820dcc509a6f75849b')"; + mysqli_query($link,$query_string); + } + else if($table == 'nucleic_acid_test_2'){ + $eventTime=mktime(12,12,12,12,12,2022); + $query_string = "create table nucleic_acid_test_2(id varchar(50),name varchar(50),address varchar(50),event_time int,insert_time int,code varchar(1))ENGINE=MyISAM DEFAULT CHARSET=utf8"; + mysqli_query($link,$query_string); + $query_string = "insert into nucleic_acid_test_2(id,name,address,event_time,insert_time,code)values('510103199010210012','mike','shanghai',$eventTime,'1597238637','3')"; + mysqli_query($link,$query_string); + $query_string ="insert into nucleic_acid_test_2(id,name,address,event_time,insert_time,code)values('510103198310607013','rose','beijing',$eventTime,'1597242237','2')"; + mysqli_query($link,$query_string); + }else if($table == 'patient_90'){ + $query_string = "create table patient_90(patient_id char(50),patient_name char(50),patient_gender char(1),patient_address char(50))ENGINE=MyISAM DEFAULT CHARSET=utf8"; + mysqli_query($link,$query_string); + $query_string = "insert into patient_90 values('123456','王某','1','1')"; + mysqli_query($link,$query_string); + } + + select_table($link, $table); + }else{ + echo "表已存在"; + } +} +function select_table($link, $table){ + $result = mysqli_query($link,"show tables like '$table'"); + var_dump($result); + echo "
"; + if ($result && mysqli_num_rows($result) > 0) { + $tableExist = true; + }else{ + $tableExist = false; + } + if($tableExist){ + if($table == 'user_70'){ + $query_string = "select * from user_70"; + $result = mysqli_query($link,$query_string); + echo "
"; + var_dump($result); + echo "

"; + while($row = mysqli_fetch_array($result)){ + echo $row['name']."
"; + echo $row['address']."
"; + echo $row['password']."
"; + echo "
"; + } + } + else if($table == 'nucleic_acid_test_2'){ + $query_string = "select * from nucleic_acid_test_2"; + $result = mysqli_query($link,$query_string); + echo "
"; + var_dump($result); + echo "

"; + while($row = mysqli_fetch_array($result)){ + echo $row['id']."
"; + echo $row['name']."
"; + echo $row['address']."
"; + echo $row['event_time']."
"; + echo $row['insert_time']."
"; + echo $row['code']."
"; + echo "
"; + } + } + else if($table == 'patient_90'){ + $query_string = "select * from patient_90"; + $result = mysqli_query($link,$query_string); + echo "
"; + var_dump($result); + echo "

"; + while($row = mysqli_fetch_array($result)){ + echo $row['patient_id']."
"; + echo $row['patient_name']."
"; + echo $row['patient_gender']."
"; + echo $row['patient_address']."
"; + echo "
"; + } + } + + } +} diff --git a/spider_251_2.php b/spider_251_2.php new file mode 100644 index 0000000..33c6b8e --- /dev/null +++ b/spider_251_2.php @@ -0,0 +1,38 @@ + "Missing required parameter: goods"]); + exit; +} + +// 定义目标地址 +$target_url = "http://localhost:8022/goods/flash_sale_1.php"; + +// 使用 cURL 抓取页面内容 +$ch = curl_init(); +curl_setopt($ch, CURLOPT_URL, $target_url); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_TIMEOUT, 10); // 设置超时时间 +$response = curl_exec($ch); + +if (curl_errno($ch)) { + echo json_encode(["error" => "Failed to fetch the target page"]); + curl_close($ch); + exit; +} +curl_close($ch); + +// 使用正则表达式匹配指定商品的价格 +// 根据提供的网页结构,价格在 价格 中 +$pattern = '/(\d+)元<\/span>/'; +if (preg_match($pattern, $response, $matches)) { + // 提取并输出价格 + echo json_encode([(int)$matches[1]]); +} else { + // 如果没有匹配到价格,返回提示信息 + echo json_encode(["error" => "Price not found for the specified goods"]); +} +?> diff --git a/upload_1.php b/upload_1.php new file mode 100644 index 0000000..bb78344 --- /dev/null +++ b/upload_1.php @@ -0,0 +1,46 @@ + + + + + 文件上传 + + +文件上传成功!文件名:{$fileName}

"; + echo "

存储路径:{$targetFile}

"; + } else { + echo "

文件上传失败,请检查目录权限!

"; + } + } else { + echo "

文件上传出错,错误码:" . $file["error"] . "

"; + } +} +?> + + +
+ + +

+ +
+ + diff --git a/user_info.php b/user_info.php new file mode 100644 index 0000000..80a5dc9 --- /dev/null +++ b/user_info.php @@ -0,0 +1,22 @@ + + + + + + + 用户信息 + + +

欢迎, !

+ + diff --git a/www/admin/main.php b/www/admin/main.php new file mode 100644 index 0000000..879657d --- /dev/null +++ b/www/admin/main.php @@ -0,0 +1,7 @@ + + + +main + + diff --git a/www/config/config.php b/www/config/config.php new file mode 100644 index 0000000..7645bd9 --- /dev/null +++ b/www/config/config.php @@ -0,0 +1,7 @@ + + + +config + + diff --git a/www/display.html b/www/display.html new file mode 100644 index 0000000..b9e7ca4 --- /dev/null +++ b/www/display.html @@ -0,0 +1,10 @@ + + + + + display + + + Index + + \ No newline at end of file diff --git a/www/index.html b/www/index.html new file mode 100644 index 0000000..4ff09bf --- /dev/null +++ b/www/index.html @@ -0,0 +1,10 @@ + + + + + index + + + list + + \ No newline at end of file diff --git a/www/lib/class.php b/www/lib/class.php new file mode 100644 index 0000000..0bd4b83 --- /dev/null +++ b/www/lib/class.php @@ -0,0 +1,7 @@ + + + +class + + diff --git a/www/list.html b/www/list.html new file mode 100644 index 0000000..1e97c65 --- /dev/null +++ b/www/list.html @@ -0,0 +1,11 @@ + + + + + list + + + display + index + + \ No newline at end of file