Initial commit
This commit is contained in:
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
Tesseract/
|
||||
Shadowsocks-4.4.1.0/
|
||||
chrome-win64/
|
||||
_internal/
|
||||
.idea/
|
||||
dist/
|
||||
build/
|
||||
node_modules/
|
||||
test.py
|
||||
main.exe
|
||||
main.spec
|
3
20241115/exam_config.php
Normal file
3
20241115/exam_config.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$link=mysqli_connect('localhost','user_20241115_58056','K6UJKaRLiipvw','exam_20241115_58056');
|
||||
mysqli_query($link,'set names utf8');
|
15
20241115/exam_setup.php
Normal file
15
20241115/exam_setup.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
require_once "exam_config.php";
|
||||
|
||||
//先删除在创建
|
||||
mysqli_query($link,"drop table user_70");
|
||||
|
||||
$queryString="create table user_70(name char(50),address char(50),password char(50))ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
||||
mysqli_query($link,$queryString);
|
||||
echo mysqli_error($link)."<br>";
|
||||
$queryString="insert into user_70(name,address,password)values('mike','shanghai','c4ca4238a0b923820dcc509a6f75849b')";
|
||||
mysqli_query($link,$queryString);
|
||||
echo mysqli_error($link)."<br>";
|
||||
$queryString="insert into user_70(name,address,password)values('rose','beijing','c4ca4238a0b923820dcc509a6f75849b')";
|
||||
mysqli_query($link,$queryString);
|
||||
echo mysqli_error($link)."<br>";
|
27
20241115/form_test_1.php
Normal file
27
20241115/form_test_1.php
Normal file
@ -0,0 +1,27 @@
|
||||
<meta charset="UTF-8">
|
||||
<?php
|
||||
//里程碑 拿到浏览器提交的数据,数据重现(现场恢复) 无状态协议模式 stateless
|
||||
//实现单选,复选,下拉框的数据重现
|
||||
if(isset($_POST['ok'])){
|
||||
//单选按钮与复选框在用户没有操作的情况下不会提交默认值到服务器,因此需要单独做逻辑处理
|
||||
//var_dump($_POST);
|
||||
echo $_POST['name'];
|
||||
echo $_POST['age'];
|
||||
$name=$_POST['name'];
|
||||
$age=$_POST['age'];
|
||||
|
||||
}else{
|
||||
$name="姓名不能为空";
|
||||
$age = "";
|
||||
}
|
||||
|
||||
?>
|
||||
<form action="" method="post">
|
||||
姓名:<input type="text" id="name" name="name" value="<?php echo $name;?>"><br>
|
||||
年龄:<input type="text" id="age" name="age" value="<?php echo $age;?>"><br></br>
|
||||
<br>
|
||||
<input type="submit" id="ok" name="ok" value="ok">
|
||||
</form>
|
||||
<script>
|
||||
|
||||
</script>
|
87
20241115/list_72.php
Normal file
87
20241115/list_72.php
Normal file
@ -0,0 +1,87 @@
|
||||
<meta charset="UTF-8">
|
||||
<?php
|
||||
//数据列表 带编辑,新增与删除操作
|
||||
//引入数据库配置文件
|
||||
/*
|
||||
* select * from student_1 limit 0,10
|
||||
* select * from student_1 limit 10,10
|
||||
*
|
||||
*/
|
||||
require_once "exam_config.php";
|
||||
|
||||
//取总记录数
|
||||
$queryString="select count(name) as maxRows from user_70";
|
||||
$rs=mysqli_query($link,$queryString);
|
||||
$row=mysqli_fetch_assoc($rs);
|
||||
$maxRows=$row['maxRows'];
|
||||
|
||||
$rowsOfPage=10;
|
||||
|
||||
if(isset($_GET['action'])){
|
||||
//翻页进入
|
||||
if($_GET['action']=="top"){
|
||||
$offset=0;
|
||||
}
|
||||
|
||||
if($_GET['action']=="previous"){
|
||||
$offset=$_GET['offset']-$rowsOfPage;
|
||||
if($offset<0){
|
||||
$offset=0;
|
||||
}
|
||||
}
|
||||
if($_GET['action']=="next"){
|
||||
$offset=$_GET['offset']+$rowsOfPage;
|
||||
//处理最后一页的计算逻辑
|
||||
if($offset>=$maxRows){
|
||||
$offset=$_GET['offset'];
|
||||
}
|
||||
}
|
||||
if($_GET['action']=='bottom'){
|
||||
if($maxRows%$rowsOfPage==0){
|
||||
//整页
|
||||
$offset=$maxRows-$rowsOfPage;
|
||||
}else{
|
||||
//非整页
|
||||
$offset=$maxRows-$maxRows%$rowsOfPage;
|
||||
//20 10 20-10 25-25%10 20
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
//第一次进入,偏移量为0
|
||||
$offset=0;
|
||||
}
|
||||
$queryString="select * from user_70 limit $offset,$rowsOfPage";
|
||||
$rs=mysqli_query($link,$queryString);
|
||||
//用循环语句,从数据集中读出每一条记录
|
||||
echo "<table border='1'>";
|
||||
//id,name,password,gender,birthday,course,hometown,resume
|
||||
echo "<tr><td>学号</td><td>姓名</td><td>班级</td><td>性别</td><td>出生日期</td><td>选课</td><td>籍贯</td><td>操作</td></tr>";
|
||||
while ($row=mysqli_fetch_assoc($rs)){
|
||||
/*
|
||||
echo $row['name'];
|
||||
|
||||
echo $row['course'];*/
|
||||
|
||||
echo "<tr>";
|
||||
|
||||
echo "<td>".$row['name']."</td>";
|
||||
echo "</tr>";
|
||||
|
||||
}
|
||||
//新增与编辑的差异在于新增是地id没有值,而编辑时id有一个值。新增与编辑90%的功能是一样的,因此在实际开发中都是调用的同一个模块
|
||||
echo "<tr><td colspan='10'>
|
||||
<a href='edit_5.php?id=&offset=0'>新增</a>
|
||||
|
|
||||
<a href='list_72.php?action=top&offset=$offset'>首页</a>
|
||||
|
|
||||
<a href='list_72.php?action=previous&offset=$offset'>上一页</a>
|
||||
|
|
||||
<a href='list_72.php?action=next&offset=$offset'>下一页</a>
|
||||
|
|
||||
<a href='list_72.php?action=bottom&offset=$offset'>尾页</a>
|
||||
</td></tr>";
|
||||
echo "</table>";
|
4
20241115/my_first_program.php
Normal file
4
20241115/my_first_program.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
$link=mysqli_connect("localhost",'user_20241115_58056','K6UJKaRLiipvw','exam_20241115_58056');
|
||||
mysqli_query($link,"set names utf8");
|
||||
var_dump($link);
|
1
20241115/upload/test_upload.txt
Normal file
1
20241115/upload/test_upload.txt
Normal file
@ -0,0 +1 @@
|
||||
6rlWseYg4VDRzwkAjLo
|
38
20241115/upload_1.php
Normal file
38
20241115/upload_1.php
Normal file
@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>文件上传</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>文件上传表单</h2>
|
||||
<!-- 文件上传表单 -->
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
<input type="file" id="my_upload_file" name="my_upload_file" required>
|
||||
<br><br>
|
||||
<input type="submit" id="ok" name="ok" value="上传文件">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
// 处理文件上传
|
||||
if (isset($_POST['ok'])) {
|
||||
// 检查是否选择了文件
|
||||
if (isset($_FILES['my_upload_file']) && $_FILES['my_upload_file']['error'] == 0) {
|
||||
$uploadDir = 'upload/'; // 文件上传目录
|
||||
$fileName = basename($_FILES['my_upload_file']['name']); // 获取文件名
|
||||
$targetFilePath = $uploadDir . $fileName; // 文件保存路径
|
||||
|
||||
// 移动上传的文件到指定目录
|
||||
if (move_uploaded_file($_FILES['my_upload_file']['tmp_name'], $targetFilePath)) {
|
||||
echo "<p>文件上传成功!文件路径:<a href='$targetFilePath'>$targetFilePath</a></p>";
|
||||
} else {
|
||||
echo "<p>文件上传失败,请重试。</p>";
|
||||
}
|
||||
} else {
|
||||
echo "<p>未选择文件或文件上传出错。</p>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
12
20241115/www/admin/main.php
Normal file
12
20241115/www/admin/main.php
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>main</title>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
|
||||
?>
|
10
20241115/www/config/config.php
Normal file
10
20241115/www/config/config.php
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>config</title>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
10
20241115/www/display.html
Normal file
10
20241115/www/display.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>display</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="list.html">list</a>
|
||||
</body>
|
||||
</html>
|
10
20241115/www/index.html
Normal file
10
20241115/www/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>index</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="list.html">list</a>
|
||||
</body>
|
||||
</html>
|
10
20241115/www/lib/class.php
Normal file
10
20241115/www/lib/class.php
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>class</title>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
11
20241115/www/list.html
Normal file
11
20241115/www/list.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>list</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="display.html">显示</a>
|
||||
<a href="index.html">返回</a>
|
||||
</body>
|
||||
</html>
|
7
20241208/acl_list.php
Normal file
7
20241208/acl_list.php
Normal file
@ -0,0 +1,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<?php
|
||||
$acl=array(
|
||||
"cto"=>array("r_1.php","r_2.php","r_3.php"),
|
||||
"manager"=>array("r_2.php","r_3.php"),
|
||||
"staff"=>array("r_3.php")
|
||||
);
|
27
20241208/api_73_5_e_insert.php
Normal file
27
20241208/api_73_5_e_insert.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// 数据库连接
|
||||
include 'db_config.php';
|
||||
|
||||
// 获取请求参数
|
||||
$id = $_GET['id'];
|
||||
$name = $_GET['name'];
|
||||
$address = $_GET['address'];
|
||||
$event_time = intval($_GET['event_time']);
|
||||
$code = $_GET['code'];
|
||||
|
||||
// 检查是否已有相同记录
|
||||
$sql_check = "SELECT * FROM nucleic_acid_test_2 WHERE id = '$id' AND address = '$address' AND event_time = $event_time";
|
||||
$result_check = $link->query($sql_check);
|
||||
|
||||
if ($result_check->num_rows > 0) {
|
||||
// 如果已有记录,直接返回码值
|
||||
echo $code;
|
||||
} else {
|
||||
// 插入新记录
|
||||
$sql_insert = "INSERT INTO nucleic_acid_test_2 (id, name, address, event_time, code) VALUES ('$id', '$name', '$address', $event_time, '$code')";
|
||||
if ($link->query($sql_insert) === TRUE) {
|
||||
echo $code;
|
||||
} else {
|
||||
echo "插入失败: " . $link->error;
|
||||
}
|
||||
}
|
50
20241208/api_73_5_e_select.php
Normal file
50
20241208/api_73_5_e_select.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// 数据库连接
|
||||
include "db_config.php";
|
||||
$conn = $link;
|
||||
|
||||
// 获取请求参数
|
||||
$id = $_GET['id'];
|
||||
$name = $_GET['name'];
|
||||
$address = $_GET['address'];
|
||||
$event_time = intval($_GET['event_time']);
|
||||
|
||||
// 查询是否存在红码时空交集
|
||||
$sql_red = "SELECT * FROM nucleic_acid_test_2
|
||||
WHERE address = '$address' AND ABS(event_time - $event_time) < 1800 AND code = '3'";
|
||||
$result_red = $conn->query($sql_red);
|
||||
|
||||
if ($result_red->num_rows > 0) {
|
||||
// 存在红码时空交集,赋红码并入库
|
||||
$sql_check = "SELECT * FROM nucleic_acid_test_2 WHERE id = '$id' AND address = '$address' AND event_time = $event_time";
|
||||
$result_check = $conn->query($sql_check);
|
||||
if ($result_check->num_rows == 0) {
|
||||
$sql_insert = "INSERT INTO nucleic_acid_test_2 (id, name, address, event_time, code) VALUES ('$id', '$name', '$address', $event_time, '3')";
|
||||
$conn->query($sql_insert);
|
||||
}
|
||||
echo "3";
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
// 查询是否存在黄码时空交集
|
||||
$sql_yellow = "SELECT * FROM nucleic_acid_test_2
|
||||
WHERE (address = '$address' OR ABS(event_time - $event_time) < 1800) AND code = '2'";
|
||||
$result_yellow = $conn->query($sql_yellow);
|
||||
|
||||
if ($result_yellow->num_rows > 0) {
|
||||
// 存在黄码时空交集,赋黄码并入库
|
||||
$sql_check = "SELECT * FROM nucleic_acid_test_2 WHERE id = '$id' AND address = '$address' AND event_time = $event_time";
|
||||
$result_check = $conn->query($sql_check);
|
||||
if ($result_check->num_rows == 0) {
|
||||
$sql_insert = "INSERT INTO nucleic_acid_test_2 (id, name, address, event_time, code) VALUES ('$id', '$name', '$address', $event_time, '2')";
|
||||
$conn->query($sql_insert);
|
||||
}
|
||||
echo "2";
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
// 无风险,返回绿码
|
||||
echo "1";
|
||||
?>
|
4
20241208/db_config.php
Normal file
4
20241208/db_config.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
$link=mysqli_connect('localhost','user_20241208_58012','JRWpcow0Ob6D4CV','exam_20241208_58012');
|
||||
mysqli_query($link,'set names utf8');
|
||||
|
28
20241208/drop_tables.php
Normal file
28
20241208/drop_tables.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
include_once("db_config.php");
|
||||
$conn = $link;
|
||||
$sql = "DROP TABLE IF EXISTS `user_70`;";
|
||||
$result = mysqli_query($conn, $sql);
|
||||
if ($result) {
|
||||
echo "Table users dropped successfully.";
|
||||
} else {
|
||||
echo "Error dropping table: " . mysqli_error($conn);
|
||||
}
|
||||
|
||||
$sql = "DROP TABLE IF EXISTS `nucleic_acid_test_2`;";
|
||||
$result = mysqli_query($conn, $sql);
|
||||
if ($result) {
|
||||
echo "Table users dropped successfully.";
|
||||
} else {
|
||||
echo "Error dropping table: " . mysqli_error($conn);
|
||||
}
|
||||
|
||||
$sql = "DROP TABLE IF EXISTS `patient_90`;";
|
||||
$result = mysqli_query($conn, $sql);
|
||||
if ($result) {
|
||||
echo "Table users dropped successfully.";
|
||||
} else {
|
||||
echo "Error dropping table: " . mysqli_error($conn);
|
||||
}
|
||||
mysqli_close($conn);
|
||||
|
3
20241208/exam_config.php
Normal file
3
20241208/exam_config.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$link=mysqli_connect('localhost','user_20241208_58011','7jT4K3plVvng0cn','exam_20241208_58011');
|
||||
mysqli_query($link,'set names utf8');
|
72
20241208/exam_setup.php
Normal file
72
20241208/exam_setup.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
include_once("db_config.php");
|
||||
mysqli_set_charset($link, 'utf8');
|
||||
$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);
|
||||
echo mysqli_error($link);
|
||||
$query_string = "insert into user_70(name,address,password)values('mike','shanghai','c4ca4238a0b923820dcc509a6f75849b')";
|
||||
mysqli_query($link,$query_string);
|
||||
echo mysqli_error($link);
|
||||
$query_string = "insert into user_70(name,address,password)values('rose','beijing','c4ca4238a0b923820dcc509a6f75849b')";
|
||||
mysqli_query($link,$query_string);
|
||||
echo mysqli_error($link);
|
||||
|
||||
$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);
|
||||
echo mysqli_error($link);
|
||||
$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);
|
||||
echo mysqli_error($link);
|
||||
$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);
|
||||
echo mysqli_error($link);
|
||||
|
||||
$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);
|
||||
echo mysqli_error($link);
|
||||
$query_string = "insert into patient_90 values('5100','张三','1','北京市西城区')";
|
||||
mysqli_query($link,$query_string);
|
||||
echo mysqli_error($link);
|
||||
|
||||
|
||||
echo "user_70:";
|
||||
$query_string = "select * from user_70;";
|
||||
$result =mysqli_query($link,$query_string);
|
||||
while($row = mysqli_fetch_array($result)){
|
||||
echo $row['name']."<br>";
|
||||
echo $row['address']."<br>";
|
||||
echo $row['password']."<br>";
|
||||
echo "<br>";
|
||||
}
|
||||
echo mysqli_error($link);
|
||||
|
||||
$query_string = "select * from nucleic_acid_test_2;";
|
||||
$result = mysqli_query($link,$query_string);
|
||||
echo mysqli_error($link);
|
||||
echo "<br>";
|
||||
echo "<br>";
|
||||
echo "nucleic_acid_test_2:";
|
||||
while($row = mysqli_fetch_array($result)){
|
||||
echo $row['id']."<br>";
|
||||
echo $row['name']."<br>";
|
||||
echo $row['address']."<br>";
|
||||
echo $row['event_time']."<br>";
|
||||
echo $row['insert_time']."<br>";
|
||||
echo $row['code']."<br>";
|
||||
echo "<br>";
|
||||
}
|
||||
|
||||
echo "<br>";
|
||||
echo "<br>";
|
||||
echo "patient_90:";
|
||||
$query_string = "select * from patient_90;";
|
||||
$result =mysqli_query($link,$query_string);
|
||||
while($row = mysqli_fetch_array($result)){
|
||||
echo $row['patient_id']."<br>";
|
||||
echo $row['patient_name']."<br>";
|
||||
echo $row['patient_gender']."<br>";
|
||||
echo $row['patient_address']."<br>";
|
||||
echo "<br>";
|
||||
}
|
||||
echo mysqli_error($link);
|
31
20241208/form_test_2.php
Normal file
31
20241208/form_test_2.php
Normal file
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Form Test 2</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// 获取表单提交数据
|
||||
$name = htmlspecialchars($_POST['name']);
|
||||
$password = md5($_POST['password']);
|
||||
|
||||
// 输出结果
|
||||
echo "<p>提交后的姓名:$name</p>";
|
||||
echo "<p>处理后的密码:$password</p>";
|
||||
}
|
||||
?>
|
||||
|
||||
<form action="form_test_2.php" method="post">
|
||||
<label for="name">姓名:</label>
|
||||
<input type="text" id="name" name="name" value=""><br><br>
|
||||
|
||||
<label for="password">密码:</label>
|
||||
<input type="password" id="password" name="password" value=""><br><br>
|
||||
|
||||
<input type="submit" id="ok" name="ok" value="提交">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
56
20241208/form_test_74_2.php
Normal file
56
20241208/form_test_74_2.php
Normal file
@ -0,0 +1,56 @@
|
||||
<meta charset="UTF-8">
|
||||
<?php
|
||||
//里程碑 拿到浏览器提交的数据,数据重现(现场恢复) 无状态协议模式 stateless
|
||||
//实现单选,复选,下拉框的数据重现
|
||||
if(isset($_POST['ok'])){
|
||||
//单选按钮与复选框在用户没有操作的情况下不会提交默认值到服务器,因此需要单独做逻辑处理
|
||||
//var_dump($_POST);
|
||||
//echo $_POST['name'];
|
||||
$name=$_POST['name'];
|
||||
|
||||
if(isset($_POST['gender'])){
|
||||
//echo $_POST['gender'];
|
||||
$gender=$_POST['gender'];
|
||||
}else{
|
||||
$gender="";
|
||||
}
|
||||
if(isset($_POST['course'])){
|
||||
//echo $_POST['course'][0];
|
||||
$course=$_POST['course'];
|
||||
}else{
|
||||
$course=array();
|
||||
//course=[]
|
||||
}
|
||||
$resume=$_POST['resume'];
|
||||
//下拉框默认会提交数据,因此不需要像单选按钮一样做逻辑处理
|
||||
$hometown=$_POST['hometown'];
|
||||
|
||||
//echo $_POST['hometown'];
|
||||
}else{
|
||||
$name="姓名不能为空";
|
||||
$resume="请写出您的故事";
|
||||
$gender="2";
|
||||
$course=array("english");//默认选修服务器端程序设计
|
||||
$hometown="chengdu";//默认选中成都
|
||||
}
|
||||
|
||||
?>
|
||||
<form action="" method="post">
|
||||
姓名:<input type="text" id="name" name="name" value="<?php echo $name;?>"><br>
|
||||
|
||||
性别:<input type="radio" id="male" name="gender" value="1" <?php echo $gender=="1"?"checked":"";?>>男
|
||||
<input type="radio" id="female" name="gender" value="2" <?php echo $gender=="2"?"checked":"";?>>女<br>
|
||||
|
||||
选课:<input type="checkbox" id="computer" name="course[]" value="computer" <?php echo in_array("computer",$course)?"checked":"";?>>computer
|
||||
<input type="checkbox" id="math" name="course[]" value="math" <?php echo in_array("math",$course)?"checked":"";?>>math
|
||||
<input type="checkbox" id="english" name="course[]" value="english" <?php echo in_array("english",$course)?"checked":"";?>>english
|
||||
籍贯:<select id="hometown" name="hometown">
|
||||
<option value="beijing" <?php echo $hometown=='beijing'?"selected":"";?>>北京</option>
|
||||
<option value="chengdu" <?php echo $hometown=='chengdu'?"selected":"";?>>成都</option>
|
||||
<option value="chongqing" <?php echo $hometown=='chongqing'?"selected":"";?>>重庆</option>
|
||||
</select> <br>
|
||||
<input type="submit" id="ok" name="ok" value="ok">
|
||||
</form>
|
||||
<script>
|
||||
|
||||
</script>
|
20
20241208/img_code_1.php
Normal file
20
20241208/img_code_1.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
//GD
|
||||
//phpinfo();
|
||||
//登录验证码
|
||||
session_start();
|
||||
|
||||
header("Content-type: image/png; charset=utf-8");
|
||||
//创建一个图片
|
||||
$image = imagecreate(120,30);
|
||||
//定义背景颜色
|
||||
$black = imagecolorallocate($image,255, 0, 0);//reb 000代表黑
|
||||
//定义前景颜色
|
||||
$white = imagecolorallocate($image,255, 255, 255);
|
||||
|
||||
imagefill($image, 0, 0, $black );//向图片中填充背景
|
||||
$string = $_GET['img_code'];
|
||||
//把文字写到图片中
|
||||
imagestring( $image, 5, 6, 4, $string, $white);
|
||||
//生成png格式图形
|
||||
imagepng( $image );
|
80
20241208/list_72_1.php
Normal file
80
20241208/list_72_1.php
Normal file
@ -0,0 +1,80 @@
|
||||
<meta charset="UTF-8">
|
||||
<?php
|
||||
//数据列表 带编辑,新增与删除操作
|
||||
//引入数据库配置文件
|
||||
/*
|
||||
* select * from student_1 limit 0,10
|
||||
* select * from student_1 limit 10,10
|
||||
*
|
||||
*/
|
||||
require_once "db_config.php";
|
||||
mysqli_set_charset($link, 'utf8');
|
||||
//取总记录数
|
||||
$queryString="select count(name) as maxRows from user_70";
|
||||
$rs=mysqli_query($link,$queryString);
|
||||
$row=mysqli_fetch_assoc($rs);
|
||||
$maxRows=$row['maxRows'];
|
||||
|
||||
$rowsOfPage = $_GET['rows_of_page'] ?? 10;
|
||||
|
||||
|
||||
|
||||
if(isset($_GET['action'])){
|
||||
//翻页进入
|
||||
if($_GET['action']=="top"){
|
||||
$offset=0;
|
||||
}
|
||||
|
||||
if($_GET['action']=="previous"){
|
||||
$offset=$_GET['offset']-$rowsOfPage;
|
||||
if($offset<0){
|
||||
$offset=0;
|
||||
}
|
||||
}
|
||||
if($_GET['action']=="next"){
|
||||
$offset=$_GET['offset']+$rowsOfPage;
|
||||
//处理最后一页的计算逻辑
|
||||
if($offset>=$maxRows){
|
||||
$offset=$_GET['offset'];
|
||||
}
|
||||
}
|
||||
if($_GET['action']=='bottom'){
|
||||
if($maxRows%$rowsOfPage==0){
|
||||
//整页
|
||||
$offset=$maxRows-$rowsOfPage;
|
||||
}else{
|
||||
//非整页
|
||||
$offset=$maxRows-$maxRows%$rowsOfPage;
|
||||
//20 10 20-10 25-25%10 20
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
//第一次进入,偏移量为0
|
||||
$offset=0;
|
||||
}
|
||||
$queryString="select * from user_70 limit $offset,$rowsOfPage";
|
||||
$rs=mysqli_query($link,$queryString);
|
||||
//用循环语句,从数据集中读出每一条记录
|
||||
echo "<table border='1'>";
|
||||
//id,name,password,gender,birthday,course,hometown,resume
|
||||
echo "<tr><td colspan='10'>姓名列表</td>";
|
||||
$pattern = '/(\d+)/';
|
||||
while ($row=mysqli_fetch_assoc($rs)){
|
||||
preg_match_all($pattern, $row['name'], $matches);
|
||||
echo "<tr>";
|
||||
echo "<td>".($matches[0][0]+1)."</td>";
|
||||
echo "<td>".$row['name']."</td>";
|
||||
|
||||
}
|
||||
echo "<tr><td colspan='10'>
|
||||
<a href='list_72_1.php?action=top&offset=$offset&rows_of_page=$rowsOfPage'>首页</a>
|
||||
|
|
||||
<a href='list_72_1.php?action=previous&offset=$offset&rows_of_page=$rowsOfPage'>上一页</a>
|
||||
|
|
||||
<a href='list_72_1.php?action=next&offset=$offset&rows_of_page=$rowsOfPage'>下一页</a>
|
||||
|
|
||||
<a href='list_72_1.php?action=bottom&offset=$offset&rows_of_page=$rowsOfPage'>末页</a>
|
||||
</td></tr>";
|
||||
echo "</table>";
|
32
20241208/login.php
Normal file
32
20241208/login.php
Normal file
@ -0,0 +1,32 @@
|
||||
<meta charset="utf-8">
|
||||
<?php
|
||||
session_start();
|
||||
include_once("db_config.php");
|
||||
if(isset($_POST['ok'])){
|
||||
$name = $_POST['name'];
|
||||
$password =$_POST['password'];
|
||||
$password = md5($password);
|
||||
//此为教学代码,有SQL注入漏洞
|
||||
$queryString = "select count(name) as counter from user_70 where name = '$name' and password = '$password'";
|
||||
$rs = mysqli_query($link,$queryString);
|
||||
if($row = mysqli_fetch_assoc($rs)){
|
||||
if($row['counter'] ==1){
|
||||
//自动跳转到指定页面
|
||||
$_SESSION['studentName'] = $name;
|
||||
header("Location:user_info.php");
|
||||
}else{
|
||||
echo "登录失败,请检查用户名和密码是否正确\t或";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$name = "";
|
||||
}
|
||||
?>
|
||||
<body>
|
||||
<div class="title">用户登录</div>
|
||||
<form action="" method="post">
|
||||
<label for="name">姓名:</label><input type="text" id="name" name="name" value="<?php echo $name;?>"><br>
|
||||
<label for="password_1">密码:</label><input type="password" id="password" name="password" value=""><br>
|
||||
<input type="submit" id="ok" name="ok" value="ok">
|
||||
</form>
|
||||
</body>
|
72
20241208/patient_90.php
Normal file
72
20241208/patient_90.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
require 'db_config.php';
|
||||
$conn = $link;
|
||||
mysqli_set_charset($link, 'utf8');
|
||||
// 初始化变量
|
||||
$patient_id = $patient_name = $patient_gender = $patient_address = "";
|
||||
|
||||
// 检查表单提交
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$patient_id = ($_POST['patient_id']);
|
||||
$patient_name = ($_POST['patient_name']);
|
||||
$patient_gender = ($_POST['patient_gender']);
|
||||
$patient_address = ($_POST['patient_address']);
|
||||
|
||||
// 保存数据
|
||||
try {
|
||||
// 检查是否存在该患者
|
||||
$query = "SELECT COUNT(*) AS count FROM patient_90 WHERE patient_id = '$patient_id'";
|
||||
$result = mysqli_query($conn, $query);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
|
||||
if ($row['count'] > 0) {
|
||||
// 更新记录
|
||||
$update_query = "UPDATE patient_90 SET
|
||||
patient_name = '$patient_name',
|
||||
patient_gender = '$patient_gender',
|
||||
patient_address = '$patient_address'
|
||||
WHERE patient_id = '$patient_id'";
|
||||
mysqli_query($conn, $update_query);
|
||||
} else {
|
||||
// 插入新记录
|
||||
$insert_query = "INSERT INTO patient_90
|
||||
(patient_id, patient_name, patient_gender, patient_address)
|
||||
VALUES
|
||||
('$patient_id', '$patient_name', '$patient_gender', '$patient_address')";
|
||||
mysqli_query($conn, $insert_query);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
die("数据保存失败: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>患者建档</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>患者建档</h1>
|
||||
<form action="patient_90.php" method="post">
|
||||
<label for="patient_name">姓名:</label>
|
||||
<input type="text" id="patient_name" name="patient_name" value=""><br>
|
||||
|
||||
<label for="patient_id">身份证:</label>
|
||||
<input type="text" id="patient_id" name="patient_id" value=""><br>
|
||||
|
||||
<label>性别:</label>
|
||||
<input type="radio" id="male" name="patient_gender" value="1" <?= $patient_gender === '1' ? 'checked' : '' ?>>
|
||||
<label for="male">男</label>
|
||||
<input type="radio" id="female" name="patient_gender" value="2" <?= $patient_gender === '2' ? 'checked' : '' ?>>
|
||||
<label for="female">女</label><br>
|
||||
|
||||
<label for="patient_address">家庭住址:</label>
|
||||
<input type="text" id="patient_address" name="patient_address" value=""><br>
|
||||
|
||||
<input type="submit" id="ok" name="ok" value="ok">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
29
20241208/program_85.php
Normal file
29
20241208/program_85.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// 自定义函数实现首尾字母交换
|
||||
function mySwap($string) {
|
||||
// 检查字符串是否为空或长度为1
|
||||
if (strlen($string) <= 1) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
// 获取首字母和尾字母
|
||||
$firstChar = $string[0];
|
||||
$lastChar = $string[strlen($string) - 1];
|
||||
|
||||
// 替换首尾字母
|
||||
$swappedString = $lastChar . substr($string, 1, -1) . $firstChar;
|
||||
|
||||
return $swappedString;
|
||||
}
|
||||
|
||||
// 获取URL传递的字符串
|
||||
if (isset($_GET['string'])) {
|
||||
$string = $_GET['string'];
|
||||
|
||||
// 输出结果
|
||||
echo mySwap($string);
|
||||
} else {
|
||||
echo "请通过URL传递字符串,例如:program_85.php?string=example";
|
||||
}
|
||||
?>
|
||||
<?php
|
27
20241208/r_1.php
Normal file
27
20241208/r_1.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
include_once("acl_list.php");
|
||||
//isAllow($acl, "ceo", "销售管理系统");
|
||||
$role = $_GET['role'];
|
||||
//foreach($acl[$role] as $key=>$value){
|
||||
// echo "<a href=''>$value</a><br>";
|
||||
//}
|
||||
isAllow($acl, $role,"r_1.php");
|
||||
function isAllow($acl, $role, $resource){
|
||||
if($role != ""){
|
||||
if(isset($acl[$role])){
|
||||
if(in_array($resource, $acl[$role])){
|
||||
// echo "角色".$role."可以访问".$resource."<br>";
|
||||
echo "欢迎光临";
|
||||
}else{
|
||||
// echo "角色无此权限,无法访问系统<br>";
|
||||
echo "无权访问";
|
||||
}
|
||||
}else{
|
||||
// echo "角色未定义,无权访问系统<br>";
|
||||
echo "无权访问";
|
||||
}
|
||||
}else{
|
||||
// echo "没有给定角色,无权访问系统<br>";
|
||||
echo "无权访问";
|
||||
}
|
||||
}
|
27
20241208/r_2.php
Normal file
27
20241208/r_2.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
include_once("acl_list.php");
|
||||
//isAllow($acl, "ceo", "销售管理系统");
|
||||
$role = $_GET['role'];
|
||||
//foreach($acl[$role] as $key=>$value){
|
||||
// echo "<a href=''>$value</a><br>";
|
||||
//}
|
||||
isAllow($acl, $role,"r_2.php");
|
||||
function isAllow($acl, $role, $resource){
|
||||
if($role != ""){
|
||||
if(isset($acl[$role])){
|
||||
if(in_array($resource, $acl[$role])){
|
||||
// echo "角色".$role."可以访问".$resource."<br>";
|
||||
echo "欢迎光临";
|
||||
}else{
|
||||
// echo "角色无此权限,无法访问系统<br>";
|
||||
echo "无权访问";
|
||||
}
|
||||
}else{
|
||||
// echo "角色未定义,无权访问系统<br>";
|
||||
echo "无权访问";
|
||||
}
|
||||
}else{
|
||||
// echo "没有给定角色,无权访问系统<br>";
|
||||
echo "无权访问";
|
||||
}
|
||||
}
|
27
20241208/r_3.php
Normal file
27
20241208/r_3.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
include_once("acl_list.php");
|
||||
//isAllow($acl, "ceo", "销售管理系统");
|
||||
$role = $_GET['role'];
|
||||
//foreach($acl[$role] as $key=>$value){
|
||||
// echo "<a href=''>$value</a><br>";
|
||||
//}
|
||||
isAllow($acl, $role,"r_3.php");
|
||||
function isAllow($acl, $role, $resource){
|
||||
if($role != ""){
|
||||
if(isset($acl[$role])){
|
||||
if(in_array($resource, $acl[$role])){
|
||||
// echo "角色".$role."可以访问".$resource."<br>";
|
||||
echo "欢迎光临";
|
||||
}else{
|
||||
// echo "角色无此权限,无法访问系统<br>";
|
||||
echo "无权访问";
|
||||
}
|
||||
}else{
|
||||
// echo "角色未定义,无权访问系统<br>";
|
||||
echo "无权访问";
|
||||
}
|
||||
}else{
|
||||
// echo "没有给定角色,无权访问系统<br>";
|
||||
echo "无权访问";
|
||||
}
|
||||
}
|
51
20241208/register.php
Normal file
51
20241208/register.php
Normal file
@ -0,0 +1,51 @@
|
||||
<meta charset="utf-8">
|
||||
<?php
|
||||
require_once("db_config.php");
|
||||
if(isset($_POST['ok'])){
|
||||
$name = $_POST['name'];
|
||||
$password_1 = $_POST['password'];
|
||||
//服务器端数据验证
|
||||
$valid = true;
|
||||
if($name == ""){
|
||||
echo "姓名不能为空<br>";
|
||||
$valid = false;
|
||||
}
|
||||
//判断姓名是否重复
|
||||
$queryString = "select count(name) as counter from user_70 where name = '$name'";
|
||||
$rs = mysqli_query($link,$queryString);
|
||||
$row = mysqli_fetch_assoc($rs);
|
||||
if($row['counter'] != 0){
|
||||
// echo "用户". $name."已存在,请换名<br>";
|
||||
$userExist = true;
|
||||
}else{
|
||||
$userExist = false;
|
||||
}
|
||||
|
||||
if($valid && !$userExist){
|
||||
//对密码加密
|
||||
$password_1 = md5($password_1);
|
||||
//如果验证通过,把注册信息写入表中
|
||||
$queryString = "insert into user_70(name,password) values('$name','$password_1') ";
|
||||
mysqli_query($link,$queryString);
|
||||
echo "恭喜,注册成功!";
|
||||
}
|
||||
if($valid && $userExist){
|
||||
$password_1 = md5($password_1);
|
||||
$queryString = "update user_70 set password = '$password_1' where name = '$name'";
|
||||
mysqli_query($link,$queryString);
|
||||
echo "密码更新成功";
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
$name = "";
|
||||
}
|
||||
?>
|
||||
<form action="" method="post">
|
||||
姓名:<input type="text" id="name" name="name" value="<?php echo $name;?>"><br>
|
||||
密码:<input type="password" id="password" name="password" value=""><br>
|
||||
<input type="submit" id="ok" name="ok" value="ok">
|
||||
</form>
|
||||
<script>
|
||||
//同学们自行完成浏览器数据验证
|
||||
</script>
|
5
20241208/robot_251.php
Normal file
5
20241208/robot_251.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
$content = file_get_contents("http://125.64.9.222:8022/goods/flash_sale.php");
|
||||
$pattern = '/\d+(?=元)/';
|
||||
preg_match_all($pattern, $content, $matches);
|
||||
echo "[".$matches[0][1]."]";
|
44
20241208/search_73.php
Normal file
44
20241208/search_73.php
Normal file
@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>姓名查询</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form method="POST" action="search_73.php">
|
||||
<label for="search_name">姓名查询:</label>
|
||||
<input type="text" id="search_name" name="search_name" required>
|
||||
<input type="submit" id="ok" name="ok" value="ok">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
include_once 'db_config.php';
|
||||
// 检查表单是否提交
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['search_name'])) {
|
||||
// 获取表单输入的姓名
|
||||
$searchName = $_POST['search_name'];
|
||||
// 设置字符集
|
||||
mysqli_set_charset($link, "utf8");
|
||||
|
||||
// 准备查询语句,使用准备语句以防SQL注入
|
||||
$query = $link->prepare("SELECT address FROM user_70 WHERE name = ?");
|
||||
$query->bind_param("s", $searchName);
|
||||
$query->execute();
|
||||
$result = $query->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
// 输出查询结果
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo "<p>地址: " . htmlspecialchars($row['address']) . "</p>";
|
||||
}
|
||||
} else {
|
||||
// 在没有查询到结果时显示
|
||||
echo "<p>查无此人</p>";
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
74
20241208/search_73_1.php
Normal file
74
20241208/search_73_1.php
Normal file
@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>姓名与地址查询</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form method="POST" action="search_73_1.php">
|
||||
<label for="searchName">姓名查询:</label>
|
||||
<input type="text" id="searchName" name="searchName">
|
||||
|
||||
<label for="searchAddress">地址查询:</label>
|
||||
<input type="text" id="searchAddress" name="searchAddress">
|
||||
|
||||
<label for="and">AND</label>
|
||||
<input type="radio" id="and" name="searchLogic" value="and" checked>
|
||||
|
||||
<label for="or">OR</label>
|
||||
<input type="radio" id="or" name="searchLogic" value="or">
|
||||
|
||||
<input type="submit" id="ok" name="ok" value="ok">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
include_once 'db_config.php';
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// 获取用户输入的查询条件
|
||||
$searchName = $_POST['searchName'] ?? '';
|
||||
$searchAddress = $_POST['searchAddress'] ?? '';
|
||||
$searchLogic = $_POST['searchLogic'] ?? 'and';
|
||||
|
||||
// 设置字符集
|
||||
mysqli_set_charset($link, "utf8");
|
||||
// 动态构建查询语句
|
||||
$conditions = [];
|
||||
$params = [];
|
||||
$types = '';
|
||||
|
||||
if (!empty($searchName)) {
|
||||
$conditions[] = "name = ?";
|
||||
$params[] = $searchName;
|
||||
$types .= 's';
|
||||
}
|
||||
|
||||
if (!empty($searchAddress)) {
|
||||
$conditions[] = "address = ?";
|
||||
$params[] = $searchAddress;
|
||||
$types .= 's';
|
||||
}
|
||||
|
||||
if (count($conditions) > 0) {
|
||||
$sql = "SELECT * FROM user_70 WHERE " . implode(" " . strtoupper($searchLogic) . " ", $conditions);
|
||||
$stmt = $link->prepare($sql);
|
||||
$stmt->bind_param($types, ...$params);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
$rowCount = $result->num_rows;
|
||||
echo "<p>[" . $rowCount . "]</p>"; // 显示记录数
|
||||
|
||||
if ($rowCount > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo "<p>姓名: " . htmlspecialchars($row['name']) . " 地址: " . htmlspecialchars($row['address']) . "</p>";
|
||||
}
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
// 如果没有提供查询条件则不执行查询
|
||||
echo "<p>[0]</p>";
|
||||
}
|
||||
}
|
||||
?>
|
3
20241208/user_info.php
Normal file
3
20241208/user_info.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
session_start();
|
||||
echo $_SESSION['studentName'];
|
14
20241208/www/admin/back_index.php
Normal file
14
20241208/www/admin/back_index.php
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
<?php
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="Zh-CN">
|
||||
<head>
|
||||
<title>main</title>
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="top.html"></iframe>
|
||||
<iframe src="left.html"></iframe>
|
||||
<iframe src="right.html"></iframe>
|
||||
</body>
|
||||
</html>
|
10
20241208/www/admin/left.html
Normal file
10
20241208/www/admin/left.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
10
20241208/www/admin/right.html
Normal file
10
20241208/www/admin/right.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
10
20241208/www/admin/top.html
Normal file
10
20241208/www/admin/top.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
10
20241208/www/display.html
Normal file
10
20241208/www/display.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>display</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="list.html">list.html</a>
|
||||
</body>
|
||||
</html>
|
10
20241208/www/index.html
Normal file
10
20241208/www/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>index</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="list.html">list.html</a>
|
||||
</body>
|
||||
</html>
|
11
20241208/www/list.html
Normal file
11
20241208/www/list.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>list</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="index.html">index.html</a>
|
||||
<a href="display.html">display.html</a>
|
||||
</body>
|
||||
</html>
|
17
20250103/acl_list.php
Normal file
17
20250103/acl_list.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
// 定义 ACL 表
|
||||
$acl = array(
|
||||
"cto" => 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; // 无权限
|
||||
}
|
||||
|
38
20250103/api_183_1.php
Normal file
38
20250103/api_183_1.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// 获取参数
|
||||
$student_id = $_GET['student_id'] ?? null;
|
||||
$english = $_GET['english'] ?? null;
|
||||
$math = $_GET['math'] ?? null;
|
||||
$computer = $_GET['computer'] ?? null;
|
||||
|
||||
// 校验参数是否完整
|
||||
if ($student_id === null || $english === null || $math === null || $computer === null) {
|
||||
// 返回错误信息
|
||||
echo json_encode([
|
||||
"error" => "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);
|
||||
?>
|
38
20250103/api_183_2.php
Normal file
38
20250103/api_183_2.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// 获取参数
|
||||
$student_id = $_GET['student_id'] ?? null;
|
||||
$english = $_GET['english'] ?? null;
|
||||
$math = $_GET['math'] ?? null;
|
||||
$computer = $_GET['computer'] ?? null;
|
||||
|
||||
// 校验参数是否完整
|
||||
if ($student_id === null || $english === null || $math === null || $computer === null) {
|
||||
// 返回错误信息
|
||||
echo json_encode([
|
||||
"error" => "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);
|
||||
?>
|
102
20250103/create_tables.php
Normal file
102
20250103/create_tables.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
include_once "db_config.php";
|
||||
// 创建数据库连接
|
||||
$conn = $link;
|
||||
// 检查连接是否成功
|
||||
if ($conn->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 "患者表创建成功!<br>";
|
||||
} else {
|
||||
echo "创建患者表失败: " . $conn->error . "<br>";
|
||||
}
|
||||
|
||||
// 创建医生表
|
||||
$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 "医生表创建成功!<br>";
|
||||
} else {
|
||||
echo "创建医生表失败: " . $conn->error . "<br>";
|
||||
}
|
||||
|
||||
// 创建科室表
|
||||
$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 "科室表创建成功!<br>";
|
||||
} else {
|
||||
echo "创建科室表失败: " . $conn->error . "<br>";
|
||||
}
|
||||
|
||||
// 创建挂号表
|
||||
$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 "挂号表创建成功!<br>";
|
||||
} else {
|
||||
echo "创建挂号表失败: " . $conn->error . "<br>";
|
||||
}
|
||||
|
||||
// 插入测试数据
|
||||
$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 "测试数据插入成功!<br>";
|
||||
} else {
|
||||
echo "插入测试数据失败: " . $conn->error . "<br>";
|
||||
}
|
||||
|
||||
// 关闭数据库连接
|
||||
$conn->close();
|
||||
?>
|
8
20250103/db_config.php
Normal file
8
20250103/db_config.php
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
<?php
|
||||
$link=mysqli_connect('localhost','user_20250103_58011','5BSVN9rMFNaiFGc','exam_20250103_58011');
|
||||
mysqli_query($link,'set names utf8');
|
||||
|
||||
// 设置默认时区
|
||||
date_default_timezone_set("Asia/Shanghai");
|
||||
|
43
20250103/form_test_2.php
Normal file
43
20250103/form_test_2.php
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>表单编程与现场恢复</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
// 定义变量用于回显数据
|
||||
$name = "";
|
||||
$password_md5 = "";
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// 获取提交的姓名和密码
|
||||
$name = isset($_POST['name']) ? htmlspecialchars($_POST['name']) : "";
|
||||
$password = isset($_POST['password']) ? $_POST['password'] : "";
|
||||
|
||||
// 使用 MD5 对密码进行加密
|
||||
$password_md5 = md5($password);
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- 表单 -->
|
||||
<form action="form_test_2.php" method="post">
|
||||
<label for="name">姓名:</label>
|
||||
<input type="text" id="name" name="name" value="<?php echo $name; ?>">
|
||||
<br><br>
|
||||
|
||||
<label for="password">密码:</label>
|
||||
<input type="password" id="password" name="password" value="">
|
||||
<br><br>
|
||||
|
||||
<input type="submit" id="ok" name="ok" value="提交">
|
||||
</form>
|
||||
|
||||
<!-- 输出提交结果 -->
|
||||
<?php if ($_SERVER["REQUEST_METHOD"] == "POST"): ?>
|
||||
<h3>提交结果:</h3>
|
||||
<p>姓名:<?php echo $name; ?></p>
|
||||
<p>处理后的密码:<?php echo $password_md5; ?></p>
|
||||
<?php endif; ?>
|
||||
</body>
|
||||
</html>
|
79
20250103/form_test_74_2.php
Normal file
79
20250103/form_test_74_2.php
Normal file
@ -0,0 +1,79 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>表单提交与现场恢复</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
// 定义变量,用于回显用户输入的数据
|
||||
$name = "";
|
||||
$gender = "";
|
||||
$courses = [];
|
||||
$hometown = "";
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// 获取表单数据
|
||||
$name = isset($_POST['name']) ? htmlspecialchars($_POST['name']) : "";
|
||||
$gender = isset($_POST['gender']) ? $_POST['gender'] : "";
|
||||
$courses = isset($_POST['course']) ? $_POST['course'] : [];
|
||||
$hometown = isset($_POST['hometown']) ? $_POST['hometown'] : "";
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- 表单 -->
|
||||
<form action="form_test_74_2.php" method="post">
|
||||
<!-- 姓名 -->
|
||||
<label for="name">姓名:</label>
|
||||
<input type="text" id="name" name="name" value="<?php echo $name; ?>">
|
||||
<br><br>
|
||||
|
||||
<!-- 性别 -->
|
||||
性别:
|
||||
<input type="radio" id="male" name="gender" value="1" <?php echo ($gender == "1") ? "checked" : ""; ?>>
|
||||
<label for="male">男</label>
|
||||
<input type="radio" id="female" name="gender" value="2" <?php echo ($gender == "2") ? "checked" : ""; ?>>
|
||||
<label for="female">女</label>
|
||||
<br><br>
|
||||
|
||||
<!-- 选课 -->
|
||||
选课:
|
||||
<input type="checkbox" id="computer" name="course[]" value="computer" <?php echo in_array("computer", $courses) ? "checked" : ""; ?>>
|
||||
<label for="computer">计算机</label>
|
||||
<input type="checkbox" id="math" name="course[]" value="math" <?php echo in_array("math", $courses) ? "checked" : ""; ?>>
|
||||
<label for="math">数学</label>
|
||||
<input type="checkbox" id="english" name="course[]" value="english" <?php echo in_array("english", $courses) ? "checked" : ""; ?>>
|
||||
<label for="english">英语</label>
|
||||
<br><br>
|
||||
|
||||
<!-- 籍贯 -->
|
||||
籍贯:
|
||||
<select id="hometown" name="hometown">
|
||||
<option value="beijing" <?php echo ($hometown == "beijing") ? "selected" : ""; ?>>北京</option>
|
||||
<option value="chengdu" <?php echo ($hometown == "chengdu") ? "selected" : ""; ?>>成都</option>
|
||||
<option value="chongqing" <?php echo ($hometown == "chongqing") ? "selected" : ""; ?>>重庆</option>
|
||||
</select>
|
||||
<br><br>
|
||||
|
||||
<!-- 提交按钮 -->
|
||||
<input type="submit" id="ok" name="ok" value="提交">
|
||||
</form>
|
||||
|
||||
<!-- 输出提交结果 -->
|
||||
<?php if ($_SERVER["REQUEST_METHOD"] == "POST"): ?>
|
||||
<h3>提交结果:</h3>
|
||||
<p>姓名:<?php echo $name; ?></p>
|
||||
<p>性别:<?php echo ($gender == "1") ? "男" : (($gender == "2") ? "女" : "未选择"); ?></p>
|
||||
<p>选课:
|
||||
<?php
|
||||
if (!empty($courses)) {
|
||||
echo implode(",", $courses);
|
||||
} else {
|
||||
echo "未选择";
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
<p>籍贯:<?php echo !empty($hometown) ? $hometown : "未选择"; ?></p>
|
||||
<?php endif; ?>
|
||||
</body>
|
||||
</html>
|
97
20250103/list_72.php
Normal file
97
20250103/list_72.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
require_once "db_config.php"; // 引入数据库配置文件
|
||||
$conn = $link;
|
||||
// 每页显示的记录数
|
||||
$limit = 10;
|
||||
|
||||
// 获取当前的action和offset参数
|
||||
$action = isset($_GET['action']) ? $_GET['action'] : 'top';
|
||||
$offset = isset($_GET['offset']) ? intval($_GET['offset']) : 0;
|
||||
|
||||
// 获取总记录数
|
||||
$sql_count = "SELECT COUNT(*) AS total FROM user_70";
|
||||
$result_count = $conn->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);
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>姓名列表</title>
|
||||
<style>
|
||||
table {
|
||||
width: 300px;
|
||||
border-collapse: collapse;
|
||||
margin: 20px auto;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid #000;
|
||||
text-align: center;
|
||||
padding: 8px;
|
||||
}
|
||||
a {
|
||||
margin: 0 5px;
|
||||
text-decoration: none;
|
||||
color: blue;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<tr>
|
||||
<th>姓名列表</th>
|
||||
</tr>
|
||||
<?php
|
||||
// 输出数据
|
||||
if ($result->num_rows > 0) {
|
||||
$index = $offset + 1; // 起始序号
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo "<tr><td>{$index}. {$row['name']}</td></tr>";
|
||||
$index++;
|
||||
}
|
||||
} else {
|
||||
echo "<tr><td>没有数据</td></tr>";
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="list_72.php?action=top&offset=0">首页</a>
|
||||
<a href="list_72.php?action=previous&offset=<?php echo $offset; ?>">上一页</a>
|
||||
<a href="list_72.php?action=next&offset=<?php echo $offset; ?>">下一页</a>
|
||||
<a href="list_72.php?action=bottom&offset=<?php echo ($total_pages - 1) * $limit; ?>">末页</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
52
20250103/login.php
Normal file
52
20250103/login.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
session_start(); // 启用 Session
|
||||
require_once "db_config.php"; // 引入数据库配置
|
||||
|
||||
$conn = $link;
|
||||
// 检查是否提交表单
|
||||
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 {
|
||||
// 将密码转换为 MD5 格式
|
||||
$hashedPassword = md5($password);
|
||||
|
||||
// 查询用户信息
|
||||
$sql = "SELECT * FROM user_70 WHERE name = ? AND password = ?";
|
||||
$stmt = $conn->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 "用户名或密码错误!";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>用户登录</title>
|
||||
</head>
|
||||
<body>
|
||||
<form method="POST" action="login.php">
|
||||
<label for="name">姓名:</label>
|
||||
<input type="text" id="name" name="name"><br>
|
||||
<label for="password">密码:</label>
|
||||
<input type="password" id="password" name="password"><br>
|
||||
<button type="submit" id="ok" name="ok">提交</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
114
20250103/patient_register_90.php
Normal file
114
20250103/patient_register_90.php
Normal file
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
include "db_config.php";
|
||||
date_default_timezone_set("Asia/Shanghai");
|
||||
$conn = $link;
|
||||
|
||||
// 生成UUID函数
|
||||
function generateUUID() {
|
||||
return bin2hex(random_bytes(16));
|
||||
}
|
||||
|
||||
// 初始化变量
|
||||
$patient_id = $doctor_id = $fee = "";
|
||||
$register_date = date("Y-m-d");
|
||||
$message = "";
|
||||
|
||||
// 提交表单处理
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$patient_id = $_POST["patient_id"];
|
||||
$doctor_id = $_POST["doctor_id"];
|
||||
$fee = empty($_POST["fee"]) ? 10 : (int)$_POST["fee"]; // 默认挂号费为10元
|
||||
$current_date = strtotime($register_date);
|
||||
|
||||
// 检查同一患者当天是否已挂号
|
||||
$sql_check = "SELECT * FROM register_90 WHERE patient_id = '$patient_id' AND register_date = $current_date";
|
||||
$result_check = $conn->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);
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>患者挂号</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>患者挂号</h2>
|
||||
<form action="patient_register_90.php" method="post">
|
||||
<!-- 患者选择 -->
|
||||
<label for="patient_id">选择患者:</label>
|
||||
<select id="patient_id" name="patient_id">
|
||||
<?php if ($result_patients->num_rows > 0): ?>
|
||||
<?php while ($row = $result_patients->fetch_assoc()) { ?>
|
||||
<option value="<?php echo $row['patient_id']; ?>" <?php echo ($patient_id == $row['patient_id']) ? "selected" : ""; ?>>
|
||||
<?php echo $row['patient_name']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php else: ?>
|
||||
<option value="">暂无患者数据</option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<br><br>
|
||||
|
||||
<!-- 医生选择 -->
|
||||
<label for="doctor_id">选择医生:</label>
|
||||
<select id="doctor_id" name="doctor_id">
|
||||
<?php if ($result_doctors->num_rows > 0): ?>
|
||||
<?php while ($row = $result_doctors->fetch_assoc()) { ?>
|
||||
<option value="<?php echo $row['doctor_id']; ?>" <?php echo ($doctor_id == $row['doctor_id']) ? "selected" : ""; ?>>
|
||||
<?php echo $row['doctor_name'] . "|" . $row['department_name']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php else: ?>
|
||||
<option value="">暂无医生数据</option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<br><br>
|
||||
|
||||
<!-- 挂号时间 -->
|
||||
<label for="register_date">挂号时间:</label>
|
||||
<input type="text" id="register_date" name="register_date" value="<?php echo $register_date; ?>" readonly>
|
||||
<br><br>
|
||||
|
||||
<!-- 挂号费 -->
|
||||
<label for="fee">挂号费:</label>
|
||||
<input type="text" id="fee" name="fee" value="<?php echo $fee; ?>">
|
||||
<br><br>
|
||||
|
||||
<!-- 提交按钮 -->
|
||||
<input type="submit" id="ok" name="ok" value="确定">
|
||||
</form>
|
||||
|
||||
<p><?php echo $message; ?></p>
|
||||
</body>
|
||||
</html>
|
107
20250103/patient_register_list_90.php
Normal file
107
20250103/patient_register_list_90.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
include "db_config.php";
|
||||
date_default_timezone_set("Asia/Shanghai");
|
||||
$conn = $link;
|
||||
|
||||
// 初始化变量
|
||||
$search_field = isset($_POST["search_field"]) ? $_POST["search_field"] : "doctor";
|
||||
$search_value = isset($_POST["search_value"]) ? $_POST["search_value"] : "";
|
||||
$message = "";
|
||||
|
||||
// 查询挂号信息
|
||||
$sql_query = "
|
||||
SELECT
|
||||
department_90.department_name,
|
||||
doctor_90.doctor_name,
|
||||
patient_90.patient_name,
|
||||
FROM_UNIXTIME(register_90.register_date, '%Y-%m-%d') AS register_date,
|
||||
register_90.fee,
|
||||
register_90.biz_id
|
||||
FROM register_90
|
||||
JOIN doctor_90 ON register_90.doctor_id = doctor_90.doctor_id
|
||||
JOIN department_90 ON doctor_90.department_id = department_90.department_id
|
||||
JOIN patient_90 ON register_90.patient_id = patient_90.patient_id";
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && !empty($search_value)) {
|
||||
if ($search_field == "doctor") {
|
||||
$sql_query .= " WHERE doctor_90.doctor_name LIKE '%$search_value%'";
|
||||
} elseif ($search_field == "patient") {
|
||||
$sql_query .= " WHERE patient_90.patient_name LIKE '%$search_value%'";
|
||||
}
|
||||
}
|
||||
|
||||
$result = $conn->query($sql_query);
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>患者挂号列表</title>
|
||||
<style>
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px;
|
||||
}
|
||||
th {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
tr:hover {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>患者挂号列表</h2>
|
||||
<form action="patient_register_list_90.php" method="post">
|
||||
<label for="search_field">查询条件:</label>
|
||||
<select id="search_field" name="search_field">
|
||||
<option value="doctor" <?php echo ($search_field == "doctor") ? "selected" : ""; ?>>医生</option>
|
||||
<option value="patient" <?php echo ($search_field == "patient") ? "selected" : ""; ?>>患者</option>
|
||||
</select>
|
||||
=
|
||||
<input type="text" id="search_value" name="search_value" value="<?php echo htmlspecialchars($search_value); ?>">
|
||||
<input type="submit" id="ok" name="ok" value="确定">
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>科室</th>
|
||||
<th>医生</th>
|
||||
<th>患者</th>
|
||||
<th>就诊时间</th>
|
||||
<th>挂号费</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ($result && $result->num_rows > 0): ?>
|
||||
<?php while ($row = $result->fetch_assoc()) { ?>
|
||||
<tr>
|
||||
<td><?php echo $row["department_name"]; ?></td>
|
||||
<td><?php echo $row["doctor_name"]; ?></td>
|
||||
<td><?php echo $row["patient_name"]; ?></td>
|
||||
<td><?php echo $row["register_date"]; ?></td>
|
||||
<td><?php echo $row["fee"]; ?></td>
|
||||
<td>
|
||||
<a href="edit_register_90.php?biz_id=<?php echo $row['biz_id']; ?>">编辑</a>
|
||||
|
|
||||
<a href="delete_register_90.php?biz_id=<?php echo $row['biz_id']; ?>" onclick="return confirm('确定要删除此记录吗?');">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="6" style="text-align: center;">暂无数据</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
14
20250103/r_1.php
Normal file
14
20250103/r_1.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
// 引入 ACL 文件
|
||||
include 'acl_list.php';
|
||||
|
||||
// 获取角色参数
|
||||
$role = $_GET['role'] ?? null;
|
||||
|
||||
// 检查权限
|
||||
if ($role && checkAccess($role, 'r_1.php')) {
|
||||
echo "欢迎光临";
|
||||
} else {
|
||||
echo "无权访问";
|
||||
}
|
||||
?>
|
9
20250103/r_2.php
Normal file
9
20250103/r_2.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
include 'acl_list.php';
|
||||
$role = $_GET['role'] ?? null;
|
||||
if ($role && checkAccess($role, 'r_2.php')) {
|
||||
echo "欢迎光临";
|
||||
} else {
|
||||
echo "无权访问";
|
||||
}
|
||||
?>
|
8
20250103/r_3.php
Normal file
8
20250103/r_3.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
include 'acl_list.php';
|
||||
$role = $_GET['role'] ?? null;
|
||||
if ($role && checkAccess($role, 'r_3.php')) {
|
||||
echo "欢迎光临";
|
||||
} else {
|
||||
echo "无权访问";
|
||||
}
|
73
20250103/register.php
Normal file
73
20250103/register.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
include_once "db_config.php";
|
||||
|
||||
$conn = $link;
|
||||
|
||||
// 检查连接
|
||||
if ($conn->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();
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>用户注册与修改密码</title>
|
||||
</head>
|
||||
<body>
|
||||
<form method="POST" action="register.php">
|
||||
<label for="name">姓名:</label>
|
||||
<input type="text" id="name" name="name"><br>
|
||||
<label for="password">密码:</label>
|
||||
<input type="password" id="password" name="password"><br>
|
||||
<button type="submit" id="ok" name="ok" value="ok">提交</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
5
20250103/robot_251_1.php
Normal file
5
20250103/robot_251_1.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
$content = file_get_contents("http://125.64.9.222:8022/goods/flash_sale.php");
|
||||
$pattern = '/\d+(?=元)/';
|
||||
preg_match_all($pattern, $content, $matches);
|
||||
echo "[".$matches[0][0]."]";
|
56
20250103/setup.html
Normal file
56
20250103/setup.html
Normal file
@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>操作表</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
|
||||
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
||||
<script>
|
||||
// 确保在文档加载完成后执行
|
||||
$(document).ready(function(operation, table) {
|
||||
function query(operation, table) {
|
||||
$.ajax({
|
||||
url: "/setup.php",
|
||||
type: "POST",
|
||||
data: {
|
||||
operation: operation,
|
||||
table: table
|
||||
}
|
||||
}).done((res) => {
|
||||
console.log(res)
|
||||
// 检查并使用返回的JSON数据
|
||||
$("#result").html(res);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
$('#result').html('Request failed: ' + textStatus);
|
||||
});
|
||||
}
|
||||
|
||||
// 按钮点击事件绑定
|
||||
$('button').click(function() {
|
||||
const operation = $(this).attr('data-operation');
|
||||
const table = $('#mySelect').val()
|
||||
query(operation, table);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 class="text-center mb-4 mt-3">操作表</h1>
|
||||
<div class="container-sm mt-4 w-75 border border-2 p-4 rounded-3">
|
||||
<div class="d-flex h-100 ">
|
||||
<button data-operation="del" class="btn btn-danger m-2">drop table</button>
|
||||
<button data-operation="create" class="btn btn-success m-2">create table</button>
|
||||
<button data-operation="select" class="btn btn-primary m-2">select table</button>
|
||||
<select class="form-select m-2 " aria-label="Select table">
|
||||
<option value="user_70" selected>user_70</option>
|
||||
<option value="nucleic_acid_test_2">nucleic_acid_test_2</option>
|
||||
<option value="patient_90">patient_90</option>
|
||||
</select>
|
||||
<button class="btn btn-secondary m-2" onclick="location.reload();">refresh</button>
|
||||
</div>
|
||||
<div class="m-4" id="result" style="margin-top:15px; margin-left: 20px; margin-right: 100px; padding: 50px">
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
118
20250103/setup.php
Normal file
118
20250103/setup.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
session_start();
|
||||
include_once("db_config.php");
|
||||
mysqli_set_charset($link, 'utf8');
|
||||
$table = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$operation = $_POST['operation'];
|
||||
$table = $_POST['table'];
|
||||
if ($operation == 'del') {
|
||||
drop_table($link, $table);
|
||||
} else if ($operation == 'create') {
|
||||
create_table($link, $table);
|
||||
} else {
|
||||
select_table($link, $table);
|
||||
}
|
||||
}
|
||||
function drop_table($link, $table){
|
||||
$query_string = "drop table if exists $table";
|
||||
mysqli_query($link,$query_string);
|
||||
echo "表删除成功";
|
||||
|
||||
}
|
||||
function create_table($link, $table){
|
||||
$result = mysqli_query($link,"show tables like '$table' ");
|
||||
if ($result && mysqli_num_rows($result) > 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 "<br>";
|
||||
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 "<div style='font-weight: bold;font-size: 18px;color: red; border-bottom: 1px solid #ccc;padding: 10px'>";
|
||||
var_dump($result);
|
||||
echo "</div><br>";
|
||||
while($row = mysqli_fetch_array($result)){
|
||||
echo $row['name']."<br>";
|
||||
echo $row['address']."<br>";
|
||||
echo $row['password']."<br>";
|
||||
echo "<br>";
|
||||
}
|
||||
}
|
||||
else if($table == 'nucleic_acid_test_2'){
|
||||
$query_string = "select * from nucleic_acid_test_2";
|
||||
$result = mysqli_query($link,$query_string);
|
||||
echo "<div style='font-weight: bold;font-size: 18px;color: red; border-bottom: 1px solid #ccc;padding: 10px'>";
|
||||
var_dump($result);
|
||||
echo "</div><br>";
|
||||
while($row = mysqli_fetch_array($result)){
|
||||
echo $row['id']."<br>";
|
||||
echo $row['name']."<br>";
|
||||
echo $row['address']."<br>";
|
||||
echo $row['event_time']."<br>";
|
||||
echo $row['insert_time']."<br>";
|
||||
echo $row['code']."<br>";
|
||||
echo "<br>";
|
||||
}
|
||||
}
|
||||
else if($table == 'patient_90'){
|
||||
$query_string = "select * from patient_90";
|
||||
$result = mysqli_query($link,$query_string);
|
||||
echo "<div style='font-weight: bold;font-size: 18px;color: red; border-bottom: 1px solid #ccc;padding: 10px'>";
|
||||
var_dump($result);
|
||||
echo "</div><br>";
|
||||
while($row = mysqli_fetch_array($result)){
|
||||
echo $row['patient_id']."<br>";
|
||||
echo $row['patient_name']."<br>";
|
||||
echo $row['patient_gender']."<br>";
|
||||
echo $row['patient_address']."<br>";
|
||||
echo "<br>";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
38
20250103/spider_251_2.php
Normal file
38
20250103/spider_251_2.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// 获取传入参数
|
||||
$goods = $_GET['goods'] ?? null;
|
||||
|
||||
// 检查参数是否提供
|
||||
if ($goods === null) {
|
||||
echo json_encode(["error" => "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);
|
||||
|
||||
// 使用正则表达式匹配指定商品的价格
|
||||
// 根据提供的网页结构,价格在 <span id="商品ID">价格</span> 中
|
||||
$pattern = '/<span id="' . preg_quote($goods, '/') . '">(\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"]);
|
||||
}
|
||||
?>
|
46
20250103/upload_1.php
Normal file
46
20250103/upload_1.php
Normal file
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>文件上传</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
// 定义文件上传目录
|
||||
$uploadDir = __DIR__ . "/upload/tmp/";
|
||||
|
||||
// 检查并创建目录
|
||||
if (!file_exists($uploadDir)) {
|
||||
mkdir($uploadDir, 0777, true);
|
||||
}
|
||||
|
||||
// 处理文件上传
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES["upload_file"])) {
|
||||
$file = $_FILES["upload_file"];
|
||||
$fileName = basename($file["name"]);
|
||||
$targetFile = $uploadDir . $fileName;
|
||||
|
||||
// 检查文件是否上传成功
|
||||
if ($file["error"] === UPLOAD_ERR_OK) {
|
||||
// 移动文件到指定目录
|
||||
if (move_uploaded_file($file["tmp_name"], $targetFile)) {
|
||||
echo "<p>文件上传成功!文件名:{$fileName}</p>";
|
||||
echo "<p>存储路径:{$targetFile}</p>";
|
||||
} else {
|
||||
echo "<p>文件上传失败,请检查目录权限!</p>";
|
||||
}
|
||||
} else {
|
||||
echo "<p>文件上传出错,错误码:" . $file["error"] . "</p>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- 文件上传表单 -->
|
||||
<form action="upload_1.php" method="post" enctype="multipart/form-data">
|
||||
<label for="upload_file">请选择文件:</label>
|
||||
<input type="file" id="upload_file" name="upload_file">
|
||||
<br><br>
|
||||
<input type="submit" id="ok" name="ok" value="上传">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
22
20250103/user_info.php
Normal file
22
20250103/user_info.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
session_start(); // 启用 Session
|
||||
|
||||
// 检查是否登录
|
||||
if (!isset($_SESSION['s_name'])) {
|
||||
echo "未登录!请先登录。";
|
||||
header("Location: login.php"); // 跳转到登录页面
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>用户信息</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>欢迎, <?php echo htmlspecialchars($_SESSION['s_name']); ?>!</h1>
|
||||
</body>
|
||||
</html>
|
7
20250103/www/admin/main.php
Normal file
7
20250103/www/admin/main.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>main</title>
|
||||
</head>
|
||||
</html>
|
7
20250103/www/config/config.php
Normal file
7
20250103/www/config/config.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>config</title>
|
||||
</head>
|
||||
</html>
|
10
20250103/www/display.html
Normal file
10
20250103/www/display.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>display</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="index.html">Index</a>
|
||||
</body>
|
||||
</html>
|
10
20250103/www/index.html
Normal file
10
20250103/www/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>index</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="list.html">list</a>
|
||||
</body>
|
||||
</html>
|
7
20250103/www/lib/class.php
Normal file
7
20250103/www/lib/class.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>class</title>
|
||||
</head>
|
||||
</html>
|
11
20250103/www/list.html
Normal file
11
20250103/www/list.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>list</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="display.html">display</a>
|
||||
<a href="index.html">index</a>
|
||||
</body>
|
||||
</html>
|
BIN
__pycache__/main.cpython-311.pyc
Normal file
BIN
__pycache__/main.cpython-311.pyc
Normal file
Binary file not shown.
1
blankFillingQ/textarea_student_answer_01
Normal file
1
blankFillingQ/textarea_student_answer_01
Normal file
@ -0,0 +1 @@
|
||||
ASP 解释型脚本 内容管理系统 FTP 80
|
5
blankFillingQ/textarea_student_answer_01_2.txt
Normal file
5
blankFillingQ/textarea_student_answer_01_2.txt
Normal file
@ -0,0 +1,5 @@
|
||||
新Spring应用的初始搭建以及开发过程
|
||||
注解和约定大于配置
|
||||
面向切面编程
|
||||
控制反转
|
||||
依赖注入
|
5
blankFillingQ/textarea_student_answer_01_2_e
Normal file
5
blankFillingQ/textarea_student_answer_01_2_e
Normal file
@ -0,0 +1,5 @@
|
||||
springboot
|
||||
XML
|
||||
面向切面编程
|
||||
控制反转
|
||||
依赖注入
|
5
blankFillingQ/textarea_student_answer_01_3.txt
Normal file
5
blankFillingQ/textarea_student_answer_01_3.txt
Normal file
@ -0,0 +1,5 @@
|
||||
@RequestMapping
|
||||
@SpringBootApplication
|
||||
@Controller
|
||||
@Service
|
||||
@Autowired
|
3
blankFillingQ/textarea_student_answer_01_3_e
Normal file
3
blankFillingQ/textarea_student_answer_01_3_e
Normal file
@ -0,0 +1,3 @@
|
||||
映射URL路径
|
||||
标识一个Java 类是一个控制器
|
||||
用于标识服务层组件
|
1
blankFillingQ/textarea_student_answer_02
Normal file
1
blankFillingQ/textarea_student_answer_02
Normal file
@ -0,0 +1 @@
|
||||
index.html 虚拟主机 获取对象 Math.random() js类库
|
5
blankFillingQ/textarea_student_answer_03.txt
Normal file
5
blankFillingQ/textarea_student_answer_03.txt
Normal file
@ -0,0 +1,5 @@
|
||||
JSP
|
||||
解释型脚本
|
||||
CMS
|
||||
21
|
||||
http
|
5
blankFillingQ/textarea_student_answer_04.txt
Normal file
5
blankFillingQ/textarea_student_answer_04.txt
Normal file
@ -0,0 +1,5 @@
|
||||
首页
|
||||
VPS
|
||||
document.getElementById("user_name")
|
||||
Date.getYear()
|
||||
ajax
|
20
blankFillingQ/textarea_student_answer_521.txt
Normal file
20
blankFillingQ/textarea_student_answer_521.txt
Normal file
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="div_1"></div>
|
||||
<script src="http://125.64.9.222:8022/public_libs/jquery.js"></script>
|
||||
<script>
|
||||
$.ajax({
|
||||
url: "http://125.64.9.222:8022/public_libs/server_ajax_1.php",
|
||||
type: "GET"
|
||||
}).then(result=>{
|
||||
$("#div_1").html(result);
|
||||
})
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
23
blankFillingQ/textarea_student_answer_521_1
Normal file
23
blankFillingQ/textarea_student_answer_521_1
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>AJAX获取服务器时间</title>
|
||||
<script src="/public_libs/jquery.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="div_1"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$.ajax({
|
||||
url: "/public_libs/server_ajax_1.php",
|
||||
type: "GET",
|
||||
success: function(response) {
|
||||
$("#div_1").html(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
103
blankFillingQ/textarea_student_answer_60_2_e
Normal file
103
blankFillingQ/textarea_student_answer_60_2_e
Normal file
@ -0,0 +1,103 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<form id="form_1">
|
||||
姓名:<input type="text" id="name" name="name" value="">
|
||||
<span id="span_name"></span><br>
|
||||
身份证:<input type="text" id="id" name="id" value="">
|
||||
<span id="span_id"></span><br>
|
||||
性别:<input type="radio" id="male" name="gender" value="1">男
|
||||
<input type="radio" id="female" name="gender" value="2">女
|
||||
<span id="span_gender"></span><br>
|
||||
家庭地址:<select id="province" name="province">
|
||||
<option value="510000000000">四川</option>
|
||||
<option value="130000000000">河北</option>
|
||||
<option value="530000000000">云南</option>
|
||||
</select>
|
||||
<span id="span_province"></span><br>
|
||||
<select id="city" name="city">
|
||||
<option checked value="510600000000">德阳</option>
|
||||
<option value="510700000000">绵阳</option>
|
||||
<option value="510100000000">成都</option>
|
||||
</select>
|
||||
<span id="span_city"></span><br>
|
||||
既往史:<input type="checkbox" id="hypertension" name="history" value="icd_01">高血压
|
||||
<input type="checkbox" id="diabetes" name="history" value="icd_02">糖尿病
|
||||
<input type="checkbox" id="psychosis" name="history" value="icd_03">精神病
|
||||
<span id="span_history"></span><br>
|
||||
<input type="button" id="ok" name="ok" value="ok" onclick="checkData()">
|
||||
|
||||
</form>
|
||||
|
||||
</body>
|
||||
<script>
|
||||
function checkData()
|
||||
{
|
||||
var objName=document.getElementById("name");
|
||||
var objSpanName=document.getElementById("span_name");
|
||||
var objid=document.getElementById("id");
|
||||
var objSpan_id=document.getElementById("span_id");
|
||||
var objgender=document.getElementById("span_gender");
|
||||
var objcity=document.getElementById("span_city");
|
||||
var objhistory=document.getElementById("span_history");
|
||||
|
||||
var name1=objName.value;
|
||||
var id1=objid.value;
|
||||
var gender1=objgender.value;
|
||||
var city1=objcity.value;
|
||||
var history1=objhistory.value;
|
||||
var errorMessage_1="";
|
||||
var errorMessage_2="";
|
||||
var errorMessage_3="";
|
||||
var errorMessage_4="";
|
||||
|
||||
if(name1=="")
|
||||
{
|
||||
errorMessage_1="姓名不能为空";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage_1="";
|
||||
|
||||
}
|
||||
objSpanName.innerHTML=errorMessage_1;
|
||||
|
||||
|
||||
if(gender1!="1"||gender1!="2")
|
||||
{
|
||||
errorMessage_2="请选择性别";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage_2="";
|
||||
}
|
||||
objgender.innerHTML=errorMessage_2;
|
||||
if(city1!="dy")
|
||||
{
|
||||
errorMessage_3="请选择德阳";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage_3="";
|
||||
}
|
||||
|
||||
objcity.innerHTML=errorMessage_3;
|
||||
if(history1!="icd_01"&&history1!="icd_02"&&history1!="icd_03")
|
||||
{
|
||||
errorMessage_4="请选择至少一项疾病";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage_4="";
|
||||
}
|
||||
objhistory.innerHTML=errorMessage_4;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<html>
|
||||
|
||||
|
BIN
captcha.png
Normal file
BIN
captcha.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 618 B |
BIN
chromedriver.exe
Normal file
BIN
chromedriver.exe
Normal file
Binary file not shown.
10
info.txt
Normal file
10
info.txt
Normal file
@ -0,0 +1,10 @@
|
||||
125.64.9.222
|
||||
58011
|
||||
user_20250103_58011
|
||||
5BSVN9rMFNaiFGc
|
||||
21
|
||||
exam_20250103_58011
|
||||
user_20250103_58011
|
||||
5BSVN9rMFNaiFGc
|
||||
58311
|
||||
58611
|
357
main.py
Normal file
357
main.py
Normal file
@ -0,0 +1,357 @@
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
import requests
|
||||
from PIL import Image
|
||||
import pytesseract
|
||||
import io
|
||||
import time
|
||||
import re
|
||||
import os
|
||||
import tkinter as tk
|
||||
import ftplib
|
||||
|
||||
#
|
||||
# def ftp_upload_with_proxy(server, username, password, local_file_path, remote_path, proxy):
|
||||
# """使用 pycurl 上传单个文件到 FTP 服务器"""
|
||||
# buffer = BytesIO()
|
||||
# c = pycurl.Curl()
|
||||
#
|
||||
# # 设置 FTP URL
|
||||
# ftp_url = f'ftp://{server}/{remote_path}'
|
||||
# c.setopt(c.URL, ftp_url)
|
||||
#
|
||||
# # 设置 FTP 认证
|
||||
# c.setopt(c.USERPWD, f"{username}:{password}")
|
||||
# c.setopt(c.READDATA, open(local_file_path, 'rb'))
|
||||
# c.setopt(c.UPLOAD, 1)
|
||||
# c.setopt(c.PREQUOTE, ['PASV'])
|
||||
#
|
||||
# # 设置代理
|
||||
# c.setopt(c.PROXY, proxy)
|
||||
#
|
||||
# try:
|
||||
# c.perform()
|
||||
# print(f"文件 {local_file_path} 成功上传到 {remote_path}!")
|
||||
# except pycurl.error as e:
|
||||
# print(f"FTP 错误: {e}")
|
||||
# finally:
|
||||
# c.close()
|
||||
|
||||
# def upload_directory_to_ftp(server, username, password, local_directory, remote_directory, proxy):
|
||||
# """上传整个目录及其子目录到FTP服务器"""
|
||||
# # 确保远程目录存在
|
||||
# try:
|
||||
# # 此段代码需要检查并创建远程目录
|
||||
# # pycurl 不直接提供创建目录的功能,需要手动实现
|
||||
#
|
||||
# # 上传文件和子目录
|
||||
# for root, dirs, files in os.walk(local_directory):
|
||||
# # 上传子文件夹
|
||||
# for dir_name in dirs:
|
||||
# remote_dir_path = os.path.join(remote_directory,
|
||||
# os.path.relpath(os.path.join(root, dir_name), local_directory)).replace(
|
||||
# "\\", "/")
|
||||
# print(f"准备上传目录: {remote_dir_path}")
|
||||
# # 假设已确认远程目录存在
|
||||
#
|
||||
# # 上传文件
|
||||
# for filename in files:
|
||||
# local_file_path = os.path.join(root, filename) # 本地文件的完整路径
|
||||
# relative_path = os.path.relpath(local_file_path, local_directory) # 计算相对路径
|
||||
# remote_file_path = os.path.join(remote_directory, relative_path).replace("\\", "/") # 计算远程文件路径
|
||||
#
|
||||
# # 上传文件
|
||||
# ftp_upload_with_proxy(server, username, password, local_file_path, remote_file_path, proxy)
|
||||
#
|
||||
# except Exception as e:
|
||||
# print(f"上传目录时发生错误: {e}")
|
||||
|
||||
def upload_file_to_ftp(server, username, password, file_path, remote_path):
|
||||
try:
|
||||
with ftplib.FTP(server) as ftp:
|
||||
ftp.login(user=username, passwd=password)
|
||||
with open(file_path, 'rb') as file:
|
||||
ftp.storbinary(f'STOR {remote_path}', file)
|
||||
print(f"文件 {file_path} 成功上传到 {remote_path}!")
|
||||
except ftplib.all_errors as e:
|
||||
print(f"FTP 错误: {e}")
|
||||
|
||||
def upload_directory_to_ftp(server, username, password, local_directory, remote_directory):
|
||||
"""上传整个目录及其子目录到FTP服务器"""
|
||||
try:
|
||||
with ftplib.FTP(server) as ftp:
|
||||
ftp.login(user=username, passwd=password)
|
||||
|
||||
# 确保远程目录存在
|
||||
try:
|
||||
ftp.cwd(remote_directory) # 改变到远程目录
|
||||
except ftplib.error_perm:
|
||||
ftp.mkd(remote_directory) # 如果远程目录不存在,则创建
|
||||
ftp.cwd(remote_directory) # 再次进入远程目录
|
||||
|
||||
# 遍历本地目录树
|
||||
for root, dirs, files in os.walk(local_directory):
|
||||
# 上传子文件夹
|
||||
for dir_name in dirs:
|
||||
remote_dir_path = os.path.join(remote_directory, os.path.relpath(os.path.join(root, dir_name), local_directory)).replace("\\", "/")
|
||||
try:
|
||||
ftp.mkd(remote_dir_path) # 在FTP服务器上创建子目录
|
||||
print(f"已创建远程目录: {remote_dir_path}")
|
||||
except ftplib.error_perm:
|
||||
pass # 如果目录已经存在则忽略
|
||||
|
||||
# 上传文件
|
||||
for filename in files:
|
||||
local_file_path = os.path.join(root, filename) # 本地文件的完整路径
|
||||
relative_path = os.path.relpath(local_file_path, local_directory) # 计算相对路径
|
||||
remote_file_path = os.path.join(remote_directory, relative_path).replace("\\", "/") # 计算远程文件路径
|
||||
ftp_upload_with_proxy(server, username, password, local_file_path, remote_file_path, proxy_url) # 上传文件
|
||||
|
||||
except ftplib.all_errors as e:
|
||||
print(f"上传目录时发生错误: {e}")
|
||||
|
||||
def launch_proxy():
|
||||
print("开启代理...")
|
||||
cmd = "start ./Shadowsocks-4.4.1.0/Shadowsocks.exe"
|
||||
os.system('chcp 65001')
|
||||
os.system(cmd)
|
||||
|
||||
def close_proxy():
|
||||
print("杀死代理进程")
|
||||
cmd = "taskkill /f /im Shadowsocks.exe"
|
||||
os.system('chcp 65001')
|
||||
os.system(cmd)
|
||||
cmd = """
|
||||
reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
|
||||
"""
|
||||
print(cmd)
|
||||
os.system(cmd)
|
||||
|
||||
|
||||
def shot(chromedriver_path ,chrome_path):
|
||||
|
||||
options = Options()
|
||||
options.add_experimental_option("detach", True)
|
||||
options.binary_location = chrome_path
|
||||
options.add_argument("--no-sandbox")
|
||||
# 初始化 WebDriver
|
||||
service = Service(chromedriver_path)
|
||||
driver = webdriver.Chrome(service=service, options=options)
|
||||
driver.get("http://125.64.9.222:8022/login_exam.php")
|
||||
|
||||
try:
|
||||
|
||||
launch_proxy()
|
||||
time.sleep(5)
|
||||
|
||||
exam_id = name_entry.get()
|
||||
student_id = id_entry.get()
|
||||
password = password_entry.get()
|
||||
|
||||
try:
|
||||
# 创建文件夹
|
||||
os.mkdir(folder_path) # 如果目录已存在,则会抛出OSError
|
||||
print(f"文件夹 '{folder_path}' 创建成功!")
|
||||
|
||||
except FileExistsError:
|
||||
print(f"文件夹 '{folder_path}' 已存在!")
|
||||
except Exception as e:
|
||||
print(f"创建文件夹时发生错误: {e}")
|
||||
|
||||
# 填写 exam_id, student_id 和 password
|
||||
driver.find_element(By.ID, "exam_id").send_keys(exam_id) # exam_id
|
||||
driver.find_element(By.ID, "student_id").send_keys(student_id) # student_id
|
||||
driver.find_element(By.ID, "password").send_keys(password) # password
|
||||
|
||||
# 获取验证码图片
|
||||
captcha_image = driver.find_element(By.CSS_SELECTOR, "img[src='./lib/image_code_1.php']")
|
||||
|
||||
# 截取验证码图片
|
||||
captcha = captcha_image.screenshot_as_png
|
||||
|
||||
# 打开验证码图片
|
||||
captcha = Image.open(io.BytesIO(captcha))
|
||||
captcha.save("captcha.png") # 可选,保存图片以供调试
|
||||
captcha_text = pytesseract.image_to_string(captcha, config="--psm 6")
|
||||
print(f"识别到的验证码: {captcha_text}")
|
||||
|
||||
# 填写验证码
|
||||
driver.find_element(By.ID, "imageCode").send_keys(captcha_text.strip())
|
||||
|
||||
# 提交表单
|
||||
driver.find_element(By.ID, "ok").click() # 替换为实际的提交按钮 ID
|
||||
|
||||
# 获取页面 Cookies
|
||||
cookies = driver.get_cookies()
|
||||
session_cookies = {cookie['name']: cookie['value'] for cookie in cookies}
|
||||
|
||||
# 用 requests 请求目标 URL
|
||||
url = "http://125.64.9.222:8022/paper/student_server_info.php"
|
||||
response = requests.get(url, cookies=session_cookies)
|
||||
response.raise_for_status() # 确保请求成功
|
||||
print(response.text) # 打印响应内容
|
||||
|
||||
matches = [match.strip() for match in re.findall(r"(?<=:).*?(?=<br>)", response.text)]
|
||||
print(matches)
|
||||
|
||||
|
||||
with open("info.txt", "w", encoding="utf-8") as f:
|
||||
for match in matches:
|
||||
f.write(match + "\n") # 保存结果到文件
|
||||
|
||||
# command = "start result.txt"
|
||||
# subprocess.Popen(command, shell=True) # 打开结果文件
|
||||
# 等待页面加载或处理结果
|
||||
# WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "result"))) # 替换为实际的结果 ID
|
||||
# print("登录成功!")
|
||||
|
||||
exam_config = f"""
|
||||
<?php
|
||||
$link=mysqli_connect('localhost','{matches[2]}','{matches[3]}','{matches[5]}');
|
||||
mysqli_query($link,'set names utf8');
|
||||
|
||||
// 设置默认时区
|
||||
date_default_timezone_set("Asia/Shanghai");
|
||||
"""
|
||||
|
||||
with open(folder_path + "db_config.php", "w", encoding="utf-8") as f:
|
||||
f.write(exam_config) # 保存 db_config.php 文件
|
||||
|
||||
ftp_server = matches[0]
|
||||
ftp_username = matches[2]
|
||||
ftp_password = matches[3]
|
||||
# 调用上传函数
|
||||
upload_directory_to_ftp(ftp_server, ftp_username, ftp_password, local_file_path, remote_file_path, proxy_url)
|
||||
|
||||
# url = f"http://{matches[0]}:{matches[1]}/exam_setup.php"
|
||||
# response = requests.get(url, cookies=session_cookies)
|
||||
# print(response.raise_for_status())
|
||||
# print(response.text)
|
||||
time.sleep(5)
|
||||
driver.get(f"http://{matches[0]}:{matches[1]}/setup.html")
|
||||
|
||||
# 等待页面加载完成
|
||||
# WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "kw")))
|
||||
# 输入搜索词
|
||||
try:
|
||||
button = WebDriverWait(driver, 10).until(
|
||||
EC.element_to_be_clickable((By.XPATH, "//button[text()='create table']")) # 使用按钮的文本查找元素
|
||||
)
|
||||
button.click() # 点击按钮
|
||||
except Exception as e:
|
||||
print(f"发生错误: {e}")
|
||||
finally:
|
||||
result_content = ""
|
||||
try:
|
||||
result_element = WebDriverWait(driver, 100).until(
|
||||
EC.presence_of_element_located((By.ID, "result"))
|
||||
)
|
||||
|
||||
# 获取内容
|
||||
result_content = result_element.text
|
||||
print(f"ID为result的内容: {result_content}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"发生错误: {e}")
|
||||
|
||||
print("执行完毕:" + result_content)
|
||||
|
||||
|
||||
driver.get("http://125.64.9.222:8022/paper/paper.php")
|
||||
|
||||
# 等待页面加载
|
||||
wait = WebDriverWait(driver, 30)
|
||||
for fillingQ_id in fillingQ_ids:
|
||||
textarea = wait.until(EC.presence_of_element_located((By.ID, fillingQ_id)))
|
||||
with open (fillingQ_path + f"/{fillingQ_id}.txt", "r", encoding="utf-8") as f:
|
||||
textarea.send_keys(f.read()) # 填写题目
|
||||
|
||||
for save in fillingQ_save_ids:
|
||||
driver.execute_script(f"{save}")
|
||||
print(f"已保存 {save} 题目")
|
||||
time.sleep(1)
|
||||
|
||||
tk.messagebox.showinfo("提示","执行成功!请手动进入网站点击调试")
|
||||
except Exception as e:
|
||||
print(f"发生错误: {e}")
|
||||
tk.messagebox.showerror("错误", f"发生错误: {e}")
|
||||
|
||||
finally:
|
||||
close_proxy()
|
||||
driver.quit()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 设置 Tesseract OCR 的路径
|
||||
pytesseract.pytesseract.tesseract_cmd = r'.\Tesseract\tesseract.exe'
|
||||
folder_path = "./20250103/"
|
||||
chrome_path = "./chrome-win64/chrome.exe" # 替换为你的路径
|
||||
chromedriver_path = "./chromedriver.exe" # 替换为你的 ChromeDriver 路径
|
||||
|
||||
exam_id = "20250103" # 填写题号
|
||||
student_id = "" # 填写学号
|
||||
password = "" # 填写密码
|
||||
|
||||
ftp_server = 'ftp.example.com' # 替换为FTP服务器地址
|
||||
ftp_username = 'your_username' # 替换为FTP用户名
|
||||
ftp_password = 'your_password' # 替换为FTP密码
|
||||
proxy_url = "http://127.0.0.1:22222" #代理地址
|
||||
local_file_path = folder_path # 替换为要上传的本地文件路径
|
||||
fillingQ_path = "./blankFillingQ"
|
||||
remote_file_path = '/' # 替换为远程服务器上保存的文件路径
|
||||
|
||||
fillingQ_ids = ["textarea_student_answer_01", "textarea_student_answer_01_2_e","textarea_student_answer_01_3_e","textarea_student_answer_02","textarea_student_answer_521_1",
|
||||
"textarea_student_answer_60_2_e"]
|
||||
fillingQ_save_ids = ["save('01')", "save('01_2_e')","save('01_3_e')","save('02')","save('521_1')"]
|
||||
|
||||
root = tk.Tk()
|
||||
root.title("一键执行")
|
||||
|
||||
# 设置窗口大小
|
||||
window_width = 300
|
||||
window_height = 200
|
||||
root.geometry(f"{window_width}x{window_height}")
|
||||
|
||||
# 获取屏幕宽度和高度
|
||||
screen_width = root.winfo_screenwidth()
|
||||
screen_height = root.winfo_screenheight()
|
||||
|
||||
# 计算主窗口的位置
|
||||
x = (screen_width // 2) - (window_width // 2)
|
||||
y = (screen_height // 2) - (window_height // 2)
|
||||
|
||||
# 设置窗口位置
|
||||
root.geometry(f"{window_width}x{window_height}+{x}+{y}")
|
||||
|
||||
# 标签
|
||||
label = tk.Label(root, text="题号")
|
||||
label.place(x=50, y=20)
|
||||
name_entry = tk.Entry(root)
|
||||
name_entry.pack(pady=10)
|
||||
name_entry.place(x=100, y=20)
|
||||
name_entry.insert(0, exam_id)
|
||||
name_entry.config(state="disabled")
|
||||
|
||||
label2 = tk.Label(root, text="学号")
|
||||
label2.place(x=50, y=60)
|
||||
id_entry = tk.Entry(root)
|
||||
id_entry.pack(pady=10)
|
||||
id_entry.place(x=100, y=60)
|
||||
label3 = tk.Label(root, text="密码")
|
||||
label3.place(x=50, y=100)
|
||||
password_entry = tk.Entry(root, show="*")
|
||||
password_entry.pack(pady=10)
|
||||
password_entry.place(x=100, y=100)
|
||||
|
||||
# 按钮
|
||||
submit_button = tk.Button(root, text="执行", command=lambda: shot(chromedriver_path, chrome_path))
|
||||
submit_button.pack(pady=10)
|
||||
submit_button.pack(side=tk.BOTTOM)
|
||||
submit_button.config(width=10, height=1)
|
||||
|
||||
|
||||
|
||||
root.mainloop()
|
Reference in New Issue
Block a user