Server synchronisation

This commit is contained in:
nemunaire 2013-12-13 18:45:25 +01:00
commit bbec08ac4f
6 changed files with 218 additions and 18 deletions

24
submission.php Normal file
View 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");