S2OJ/web/app/controllers/judge/sync_judge_client.php

29 lines
564 B
PHP
Raw Normal View History

2016-07-18 16:39:37 +00:00
<?php
2022-11-06 02:26:21 +00:00
requirePHPLib('judger');
requirePHPLib('data');
if (!authenticateJudger()) {
UOJResponse::page404();
}
$res = DB::selectAll([
"select * from judger_info",
"where", [
["ip", "!=", ""],
"enabled" => true
]
]);
foreach ($res as $judger) {
$socket = fsockopen($judger['ip'], UOJConfig::$data['judger']['socket']['port']);
if ($socket === false) {
die("judge client {$judger['ip']} lost.");
2016-07-18 16:39:37 +00:00
}
2022-11-06 02:26:21 +00:00
fwrite($socket, json_encode([
'password' => UOJConfig::$data['judger']['socket']['password'],
'cmd' => 'update'
]));
fclose($socket);
}
die("ok");