Can send solutions on the backend (using the same file as frontend)
This commit is contained in:
parent
dbc97fda8a
commit
4a67552a29
@ -41,18 +41,22 @@ if (isset($VAR['submission_dir']))
|
||||
{
|
||||
if (is_writable("$submission_dir/"))
|
||||
{
|
||||
$file = $submission_dir.'/'.$p[1].'-'.$p[2].'-'.$p[3];
|
||||
function show_submission_result($path)
|
||||
{
|
||||
header("Location: /".SALT_USER."/".$path);
|
||||
exit;
|
||||
}
|
||||
|
||||
file_put_contents($file, $_POST['solution'], LOCK_EX);
|
||||
$_GET["team"] = $p[1];
|
||||
$_GET["theme"] = $p[2];
|
||||
$_GET["exercice"] = $p[3];
|
||||
|
||||
header("Location: /".implode("/", $p));
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
header("Location: /".implode("/", $p)."/werr");
|
||||
exit;
|
||||
require("../submission.php");
|
||||
}
|
||||
|
||||
// Fallback error
|
||||
header("Location: /".implode("/", $p)."/werr");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
function show($file)
|
||||
// When running only on one machine, team/exercice.php overwrite the following function
|
||||
if (!function_exists("show_submission_result"))
|
||||
{
|
||||
if (file_exists($file))
|
||||
print file_get_contents($file);
|
||||
else
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
function show_submission_result($path)
|
||||
{
|
||||
if (file_exists(__DIR__."/teams/".$path."/index.html"))
|
||||
print file_get_contents(__DIR__."/teams/".$path."/index.html");
|
||||
else
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
}
|
||||
}
|
||||
|
||||
$filename = intval($_GET["team"])."-".intval($_GET["theme"])."-".urlencode($_GET["exercice"]);
|
||||
@ -13,7 +17,7 @@ $file = __DIR__."/submission/".$filename;
|
||||
|
||||
|
||||
if (file_exists($file))
|
||||
show(__DIR__."/teams/".intval($_GET["team"])."/".urlencode($_GET["theme"])."/".urlencode($_GET["exercice"])."/submission/serr/index.html");
|
||||
show_submission_result(intval($_GET["team"])."/".urlencode($_GET["theme"])."/".urlencode($_GET["exercice"])."/submission/serr");
|
||||
|
||||
else if (!empty($_POST["solution"]) && !empty($_GET["team"]) && !empty($_GET["theme"]) && !empty($_GET["exercice"]))
|
||||
{
|
||||
@ -39,8 +43,8 @@ else if (!empty($_POST["solution"]) && !empty($_GET["team"]) && !empty($_GET["th
|
||||
|
||||
file_put_contents($file, $content, LOCK_EX);
|
||||
|
||||
show(__DIR__."/teams/".intval($_GET["team"])."/".urlencode($_GET["theme"])."/".urlencode($_GET["exercice"])."/submission/index.html");
|
||||
show_submission_result(intval($_GET["team"])."/".urlencode($_GET["theme"])."/".urlencode($_GET["exercice"])."/submission");
|
||||
}
|
||||
|
||||
else
|
||||
show(__DIR__."/teams/".intval($_GET["team"])."/".urlencode($_GET["theme"])."/".urlencode($_GET["exercice"])."/submission/gerr/index.html");
|
||||
show_submission_result(intval($_GET["team"])."/".urlencode($_GET["theme"])."/".urlencode($_GET["exercice"])."/submission/gerr");
|
||||
|
Loading…
Reference in New Issue
Block a user