|
发表于 2022-11-9 09:12:37
|
显示全部楼层
湖南省湘潭市
不太懂 压缩包里面只有一个名为execute.php的文件
文件内容如下:
<?php
//by豚君
$updatesql = @file_get_contents("php://input");//读取post过来的内容
echo sqldo($updatesql);
function sqldo ($updatesql,$task=""){
if(empty($updatesql)){echo json_encode(array("code"=>"400","msg"=>"sqlcode"));die;}
if(empty($task) and substr ($updatesql, 0,6) == "select"){$task="select";}//确定cha询还是其他执行
define("HOST", "localhost");//MYSQL服务器地址 本地直接用->localhost
define("dbuser", "eroot");//MYSQL账号
define("dbpsd", "eroot");//MYSQL密码
define("dbtableName", "dispatchsystem");//MYSQL密码
$mysqli = new mysqli(HOST, dbuser, dbpsd, dbtableName);
$myArray = array();
$result = $mysqli->query($updatesql);
if ($result != false){
if ($task == 'select') {
$tempArray = array();
while ($row = $result->fetch_object())
{
$tempArray = $row;
array_push($myArray, $tempArray);
}
$results= json_encode(["code"=>"200","count"=>count($myArray),"msg"=>"success","data"=>$myArray]);
}else{
$row_affected = mysqli_affected_rows($mysqli);
$results= json_encode(["code"=>"200","count"=>count($myArray),"msg"=>"success","data"=>$row_affected]);
}
}else{
$results= json_encode(["code"=>$mysqli->errno,"taskname"=>$taskname,"page"=>$page,"msg"=>$mysqli->error]);
}
$mysqli->close();
return $results;
}//sqlcha询统一接口
?> |
|