S2OJ/web/app/libs/uoj-data-lib.php
Baoshuo fea4eea8d7
All checks were successful
continuous-integration/drone/push Build is passing
refactor: UOJProblemDataSynchronizer
2023-02-13 08:28:33 +08:00

28 lines
762 B
PHP

<?php
// Actually, these things should be done by main_judger so that the code would be much simpler.
// However, this lib exists due to some history issues.
function dataNewProblem($id) {
mkdir("/var/uoj_data/upload/$id");
mkdir("/var/uoj_data/$id");
mkdir(UOJContext::storagePath() . "/problem_resources/$id");
UOJLocalRun::execAnd([
['cd', '/var/uoj_data'],
['rm', "$id.zip"],
['zip', "$id.zip", $id, '-r', '-q']
]);
}
function dataClearProblemData($problem) {
$id = $problem['id'];
if (!validateUInt($id)) {
UOJLog::error("dataClearProblemData: hacker detected");
return "invalid problem id";
}
UOJLocalRun::exec(['rm', "/var/uoj_data/$id", '-r']);
UOJLocalRun::exec(['rm', "/var/uoj_data/upload/$id", '-r']);
dataNewProblem($id);
}