Update index.php

This commit is contained in:
Namhyeon Go 2024-02-29 17:54:36 +09:00 committed by GitHub
parent 61851cd1b1
commit 4c9a7f42d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -217,7 +217,7 @@ function relay_mysql_query($params, $mysqli) {
if ($pos !== false) { if ($pos !== false) {
$query_type = strtolower(substr($query, 0, $pos)); $query_type = strtolower(substr($query, 0, $pos));
} }
$result = $mysqli->query($query); $query_result = $mysqli->query($query);
if (!$mysqli->error) { if (!$mysqli->error) {
return array( return array(
@ -230,27 +230,28 @@ function relay_mysql_query($params, $mysqli) {
); );
} }
$data = array(); $success = false;
$result = array(
"status" => 200
);
switch($query_type) { switch($query_type) {
case "select": case "select":
$data = mysqli_fetch_all($result, MYSQLI_ASSOC); $success = true;
$result['data'] = mysqli_fetch_all($query_result, MYSQLI_ASSOC);
break; break;
case "insert": case "insert":
$data[] = $result; $success = $query_result;
$data[] = @$mysqli->insert_id(); $result['insert_id'] = @$mysqli->insert_id();
break; break;
default: default:
$data[] = $result; $success = $query_result;
} }
return array( return array(
"success" => true, "success" => $success,
"result" => array( "result" => $result
"status" => 200,
"data" => $data
)
); );
} }
@ -450,12 +451,15 @@ if ($context['jsonrpc'] == "2.0") {
} }
// check is it XML-RPC (stateless) // check is it XML-RPC (stateless)
// Use the target server as a simple CMS // Use the target server as a simple CMS API
if ($xmlrpc_method) { if ($xmlrpc_method) {
$method = $xmlrpc_method; $method = $xmlrpc_method;
switch ($method) { switch ($method) {
case "metaWeblog.newPost": case "metaWeblog.newPost":
// todo list($blogid, $username, $password, $content, $publish) = $params;
break; break;
case "metaWeblog.getRecentPosts": case "metaWeblog.getRecentPosts":