威望0
积分7966
贡献0
在线时间763 小时
UID1
注册时间2021-4-14
最后登录2024-11-23
管理员
- UID
- 1
- 威望
- 0
- 积分
- 7966
- 贡献
- 0
- 注册时间
- 2021-4-14
- 最后登录
- 2024-11-23
- 在线时间
- 763 小时
|
<?php
//error_reporting(0);
require_once __DIR__ . '/sql.php';
$private_key = "private_key";
$host=SAE_MYSQL_HOST_M;
$port=SAE_MYSQL_PORT;
$user =SAE_MYSQL_USER;
$pass =SAE_MYSQL_PASS;
$bdname =SAE_MYSQL_DB;
//解密
function jiemi($stext) {
$key = file_get_contents("private_key");
$pi_key = openssl_pkey_get_private($key);
$decrypted = "";//解密后的密码存放在这个变量
openssl_private_decrypt(base64_decode($stext),$decrypted,$pi_key);
return $decrypted;
}
$con = mysqli_connect($host, $user, $pass, $bdname , $port); //建立连接
if(!$con)
{
die('建立连接失败:' . mysqli_connect_error());
echo 'error';
} else {
if (!empty($_GET['shenqing'])){
mysqli_query($con,'set names "utf8"');
mysqli_select_db($con,$bdname); //选择需使用的数据库
if ($_GET['shenqing'] == '1'){
if (!empty($_POST['phone']) && !empty($_POST['name']) && !empty($_POST['pass'])){
$name = $_POST['name'];
$phone = jiemi($_POST['phone']);
$passwd = md5(jiemi($_POST['pass']));
$chaxun = "SELECT phone FROM user where phone='$phone'";
$query = mysqli_query($con,$chaxun);
$rows = mysqli_num_rows($query);
if($rows > 0){
echo '10001';
} else {
$sql="INSERT INTO user (name,pass,siji,manager,phone) VALUES ('$name','$passwd','1','0','$phone')";
$result = mysqli_query($con,$sql);
if($result){
echo '00000';
} else {
die('Error: ' . mysqli_connect_error());
echo '10002';
}
}
} else {
echo '10101';
}
}
elseif ($_GET['shenqing'] == '2'){
if (!empty($_POST['xingming']))
{
$xiangmu = '';
$xianlu = '';
$beizhu = '';
if (!empty($_POST['xiangmu']))
{
$xiangmu = $_POST['xiangmu'];
}
if (!empty($_POST['xianlu']))
{
$xianlu = $_POST['xianlu'];
}
if (!empty($_POST['beizhu']))
{
$beizhu = $_POST['beizhu'];
}
if (!empty($_POST['stoptime']))
{
$stoptime = $_POST['stoptime'];
} else {
$stoptime = '2022-05-26 21:01:06';
}
if (!empty($_POST['starttime']))
{
$starttime = $_POST['starttime'];
} else {
$starttime = '2022-05-26 21:01:06';
}
$sql="INSERT INTO shenqing (xingming,xiangmu,xianlu,starttime,stoptime,beizhu) VALUES ('$_POST[xingming]','$xiangmu','$xianlu','$starttime','$stoptime','$beizhu')";
$result = mysqli_query($con,$sql);
if (!$result)
{
die('Error: ' . mysqli_connect_error());
echo 'error';
}
echo 'ok';
}
}
} elseif (!empty($_GET['caxun'])){
if ($_GET['caxun'] == '1')
{
if (!empty($_POST['xingming']))
{
$xingming = $_POST['xingming'];
$sql1 = "SELECT * FROM shenqing where xingming='$xingming' ORDER BY starttime DESC limit 10";
$result1 = mysqli_query($con,$sql1);
$data= $result1->fetch_all(PDO::FETCH_LAZY);
echo json_encode($data);//以json形式返回
} else {
http_response_code(404);
}
} elseif ($_GET['caxun'] == '2') {
if (!empty($_POST['id']))
{
$id = $_POST['id'];
$sql1 = "SELECT * FROM shenqing where id='$id' limit 1";
$result1 = mysqli_query($con,$sql1);
$data= $result1->fetch_all(PDO::FETCH_LAZY);
echo json_encode($data);//以json形式返回
} else {
http_response_code(404);
}
}
} else {
echo '123';
// http_response_code(404);
}
}
?> |
|