Ready to generate new certificates

This commit is contained in:
nemunaire 2014-01-21 03:07:52 +01:00
commit cc588d51f9
7 changed files with 66 additions and 208 deletions

View file

@ -8,7 +8,8 @@ function show($file)
header("HTTP/1.1 403 Forbidden");
}
$file = __DIR__."/submission/".intval($_GET["team"])."-".intval($_GET["theme"])."-".urlencode($_GET["exercice"]);
$filename = intval($_GET["team"])."-".intval($_GET["theme"])."-".urlencode($_GET["exercice"]);
$file = __DIR__."/submission/".$filename;
if (file_exists($file))
@ -16,7 +17,12 @@ if (file_exists($file))
else if (!empty($_POST["solution"]) && !empty($_GET["team"]) && !empty($_GET["theme"]) && !empty($_GET["exercice"]))
{
file_put_contents($file, $_POST['solution'], LOCK_EX);
$algos = array("md5", "sha1", "sha256", "sha384", "sha512", "whirlpool");
$content = "";
foreach($algos as $algo)
$content .= mcrypt_encrypt(MCRYPT_SERPENT_256, hash($algo, $_POST["solution"]), hash($algo, $filename), MCRYPT_MODE_ECB)."\n";
file_put_contents($file, $content, LOCK_EX);
show(__DIR__."/teams/".intval($_GET["team"])."/".urlencode($_GET["theme"])."/".urlencode($_GET["exercice"])."/submission/index.html");
}