Server synchronisation
This commit is contained in:
parent
4b101ef4b2
commit
bbec08ac4f
6 changed files with 218 additions and 18 deletions
24
submission.php
Normal file
24
submission.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
function show($file)
|
||||
{
|
||||
if (file_exists($file))
|
||||
print file_get_contents($file);
|
||||
else
|
||||
header("Location: ".$_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
$file = __DIR__."/submission/".intval($_GET["team"])."-".intval($_GET["theme"])."-".urlencode($_GET["exercice"]);
|
||||
|
||||
if (file_exists($file))
|
||||
show(__DIR__."/teams/".intval($_GET["team"])."/alreadysubmited-".intval($_GET["theme"])."-".urlencode($_GET["exercice"]).".html");
|
||||
|
||||
else if (!empty($_POST["solution"]) && !empty($_GET["team"]) && !empty($_GET["theme"]) && !empty($_GET["exercice"]))
|
||||
{
|
||||
file_put_contents($file, $_POST['solution'], LOCK_EX);
|
||||
|
||||
show(__DIR__."/teams/".intval($_GET["team"])."/submission-".intval($_GET["theme"])."-".urlencode($_GET["exercice"]).".html");
|
||||
}
|
||||
|
||||
else
|
||||
show(__DIR__."/teams/".intval($_GET["team"])."/badsubmission-".intval($_GET["theme"])."-".urlencode($_GET["exercice"]).".html");
|
||||
Reference in a new issue