S2OJ/web/app/libs/uoj-data-lib.php

28 lines
762 B
PHP
Raw Normal View History

2016-07-18 16:39:37 +00:00
<?php
2022-11-06 02:26:21 +00:00
// 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");
2022-11-06 02:26:21 +00:00
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";
2016-07-18 16:39:37 +00:00
}
2022-11-06 02:26:21 +00:00
UOJLocalRun::exec(['rm', "/var/uoj_data/$id", '-r']);
UOJLocalRun::exec(['rm', "/var/uoj_data/upload/$id", '-r']);
dataNewProblem($id);
}