add debug info for ojfeeder.php

This commit is contained in:
2026-02-07 15:45:07 +08:00
parent 660a8cb025
commit f21c33d69c

View File

@@ -8,6 +8,13 @@ require_once('lib.php');
@session_unset();
@session_destroy();
function ojfeeder_log($message) {
global $CFG;
if (!empty($CFG->debug)) {
error_log('[ojfeeder] ' . $message);
}
}
function get_judge_id($xmlrpcmsg) {
$ip = explode('.', getremoteaddr());
$id = ($ip[0] << 24) | ($ip[1] << 16) | ($ip[2] << 8) | $ip[3];
@@ -188,11 +195,24 @@ function get_tests($xmlrpcmsg)
$tests = array();
$rs = $DB->get_records('programming_tests', array('programmingid'=> $id));
ojfeeder_log("get_tests problem_id={$id} full=" . ($full ? 1 : 0) . " count=" . (is_array($rs) ? count($rs) : 0));
if (!empty($rs)) {
foreach ($rs as $rid => $r) {
if ($full) {
if (!empty($r->gzinput)) $r->input = bzdecompress($r->gzinput);
if (!empty($r->gzoutput)) $r->output = bzdecompress($r->gzoutput);
if (!empty($r->gzinput)) {
$input = bzdecompress($r->gzinput);
if ($input === false) {
ojfeeder_log("get_tests bzdecompress gzinput failed test_id={$r->id}");
}
$r->input = $input;
}
if (!empty($r->gzoutput)) {
$output = bzdecompress($r->gzoutput);
if ($output === false) {
ojfeeder_log("get_tests bzdecompress gzoutput failed test_id={$r->id}");
}
$r->output = $output;
}
}
$r = new xmlrpcval(array(
'id' => new xmlrpcval(sprintf('%d', $r->id), 'string'),
@@ -313,6 +333,17 @@ function get_gztest($xmlrpcmsg)
$id = $xmlrpcmsg->getParam(0)->scalarVal();
$r = $DB->get_record('programming_tests', array('id'=> $id));
if (empty($r)) {
ojfeeder_log("get_gztest missing test_id={$id}");
$ret = new xmlrpcval(array(), 'struct');
return new xmlrpcresp($ret);
}
$inlen = isset($r->input) ? strlen($r->input) : 0;
$outlen = isset($r->output) ? strlen($r->output) : 0;
$gzinin = isset($r->gzinput) ? strlen($r->gzinput) : 0;
$gzoutlen = isset($r->gzoutput) ? strlen($r->gzoutput) : 0;
ojfeeder_log("get_gztest test_id={$id} input={$inlen} output={$outlen} gzinput={$gzinin} gzoutput={$gzoutlen}");
if (empty($r->gzinput)) $r->gzinput = bzcompress($r->input);
if (empty($r->gzoutput)) $r->gzoutput = bzcompress($r->output);
$ret = new xmlrpcval(array(