mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 19:28:41 +00:00
96d4a3ecf7
Due to historical reasons, the code is in subfolder "1". With SVN removal, we place the code back and remove the annoying "1" folder.
47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
requirePHPLib('judger');
|
|
switch ($_GET['type']) {
|
|
case 'problem':
|
|
if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) {
|
|
become404Page();
|
|
}
|
|
|
|
$visible = isProblemVisibleToUser($problem, $myUser);
|
|
if (!$visible && $myUser != null) {
|
|
$result = DB::query("select contest_id from contests_problems where problem_id = {$_GET['id']}");
|
|
while (list($contest_id) = DB::fetch($result, MYSQLI_NUM)) {
|
|
$contest = queryContest($contest_id);
|
|
genMoreContestInfo($contest);
|
|
if ($contest['cur_progress'] != CONTEST_NOT_STARTED && hasRegistered($myUser, $contest) && queryContestProblemRank($contest, $problem)) {
|
|
$visible = true;
|
|
}
|
|
}
|
|
}
|
|
if (!$visible) {
|
|
become404Page();
|
|
}
|
|
|
|
$id = $_GET['id'];
|
|
|
|
$file_name = "/var/uoj_data/$id/download.zip";
|
|
$download_name = "problem_$id.zip";
|
|
break;
|
|
case 'testlib.h':
|
|
$file_name = "/home/local_main_judger/judge_client/uoj_judger/include/testlib.h";
|
|
$download_name = "testlib.h";
|
|
break;
|
|
default:
|
|
become404Page();
|
|
}
|
|
|
|
$finfo = finfo_open(FILEINFO_MIME);
|
|
$mimetype = finfo_file($finfo, $file_name);
|
|
if ($mimetype === false) {
|
|
become404Page();
|
|
}
|
|
finfo_close($finfo);
|
|
|
|
header("X-Sendfile: $file_name");
|
|
header("Content-type: $mimetype");
|
|
header("Content-Disposition: attachment; filename=$download_name");
|
|
?>
|