Possibility to generate and delete the root CA in the admin panel

This commit is contained in:
Li Chen 2013-11-12 20:24:34 +01:00
commit c5c54f3b1a
5 changed files with 110 additions and 6 deletions

View file

@ -0,0 +1,42 @@
<?php
if (!defined('ONYX')) exit;
if (isset($_GET['generate']))
{
//TODO handle if already exist
putenv("OPENSSL_CONF=".ONYX. '../misc/openssl.cnf');
putenv("TOP_DIR=".ONYX. '../misc/fic_pki');
$output = shell_exec(ONYX . '../misc/CA.sh -newca 2> toto');
$template->assign("output", $output);
}
function remove_directory($dir)
{
if (is_dir($dir))
{
$objects = scandir($dir);
foreach ($objects as $object)
{
if ($object != "." && $object != "..")
{
if (filetype($dir."/".$object) == "dir")
remove_directory($dir."/".$object);
else
unlink($dir."/".$object);
}
}
reset($objects);
rmdir($dir);
}
}
if (isset($_GET['delete']))
{
//TODO handle var path
$dir = ONYX . '../misc/fic_pki';
remove_directory($dir);
}
return "admin/home";