Add a Dockerfile for frontend test container; adapt code to simplify synchronization or Docker linkage
This commit is contained in:
parent
6c69867bcc
commit
bca09af2e0
15 changed files with 329 additions and 218 deletions
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
// When running only on one machine, team/exercice.php overwrite the following function
|
||||
if (!function_exists("show_submission_result"))
|
||||
{
|
||||
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"]);
|
||||
$file = __DIR__."/submission/".$filename;
|
||||
|
||||
|
||||
if (file_exists($file))
|
||||
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"]))
|
||||
{
|
||||
$algos = array("md5", "sha1", "sha256", "sha384", "sha512", "whirlpool");
|
||||
$content = "";
|
||||
foreach($algos as $algo)
|
||||
{
|
||||
$cnt = hash($algo, $filename, true);
|
||||
// Encrypt twice on long key
|
||||
$key = hash($algo, $_POST["solution"]);
|
||||
|
||||
$kfirst = pack('H*', substr($key, 0, 64));
|
||||
$cnt = mcrypt_encrypt(MCRYPT_SERPENT, $kfirst, $cnt, MCRYPT_MODE_ECB);
|
||||
|
||||
if (strlen($key) > 64)
|
||||
{
|
||||
$ksec = pack('H*', substr($key, 64, 64));
|
||||
$cnt = mcrypt_encrypt(MCRYPT_SERPENT, $ksec, $cnt, MCRYPT_MODE_ECB);
|
||||
}
|
||||
|
||||
$content .= bin2hex($cnt)."\n";
|
||||
}
|
||||
|
||||
file_put_contents($file, $content, LOCK_EX);
|
||||
|
||||
show_submission_result(intval($_GET["team"])."/".urlencode($_GET["theme"])."/".urlencode($_GET["exercice"])."/submission");
|
||||
}
|
||||
|
||||
else
|
||||
show_submission_result(intval($_GET["team"])."/".urlencode($_GET["theme"])."/".urlencode($_GET["exercice"])."/submission/gerr");
|
||||
Reference in a new issue