add api key generator

This commit is contained in:
Christopher 2020-10-23 21:59:35 +02:00
parent ba3aaaf269
commit d84cbafc53
2 changed files with 18 additions and 3 deletions

View File

@ -8,8 +8,16 @@ include_once("classen/HTML.php");
include_once("classen/GoogleAuthenticator.php");
include_once("classen/docker.php");
if(file_exists("./vendor/autoload.php"))
include_once("./vendor/autoload.php");
$RUNTIME = array();
if(!file_exists("./pages/systemkey.txt"))
{
$randomKey = md5(rand(111111111, 999999999));
file_put_contents("./pages/systemkey.txt", $randomKey);
}
$RUNTIME['SYSTEMKEY'] = file_get_contents("./pages/systemkey.txt");
$_SESSION['CONATINER'] = "System.Proxy";
$_SESSION['LOGIN'] = "true";

View File

@ -7,6 +7,13 @@ function clean($string)
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $string);
}
function calcAPIKey($container)
{
global $RUNTIME;
return md5($RUNTIME['SYSTEMKEY'].md5($container['Names'][0]));
}
if(isset($_SESSION['LOGIN']))
{
if($_SESSION['LOGIN'] == 'true')
@ -31,7 +38,7 @@ if(isset($_SESSION['LOGIN']))
$HTML->importHTML("style/default/dashboard.html");
$HTML->ReplaceLayoutInhalt("%%ContainerName%%", trim(ltrim($container['Names']['0'], '/')));
$HTML->ReplaceLayoutInhalt("%%UserAPIKey%%", trim($container['Id']));
$HTML->ReplaceLayoutInhalt("%%UserAPIKey%%", calcAPIKey($container));
$HTML->ReplaceLayoutInhalt("%%ContainerLogOutput%%", html_entity_decode(clean($logOutput)));
$HTML->build();