diff --git a/htdocs/inc/js/webadmin.js b/htdocs/inc/js/webadmin.js index 77bb78f..4a78df5 100644 --- a/htdocs/inc/js/webadmin.js +++ b/htdocs/inc/js/webadmin.js @@ -21,6 +21,12 @@ function switch_disabled(name) { } document.observe("dom:loaded", function() { + if (document.getElementById('vhost-delete-db') != null) { + document.getElementById('vhost-delete-db').onclick = function() { + console.log("clicked box"); + switch_disabled('vhost-dbname'); + } + } document.getElementById('password_random').onclick = function() { switch_disabled('password'); } diff --git a/htdocs/index.php b/htdocs/index.php index b1010bb..a801e52 100755 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -64,6 +64,10 @@ if (!array_key_exists('auth', $_SESSION) || $_SESSION['auth']!=1) { include_once EVOADMIN_BASE . '../inc/webadmin-edit.php'; +} elseif (preg_match('#^/webadmin/(.*)/delete/$#', $uri, $params)) { + + include_once EVOADMIN_BASE . '../inc/webadmin-delete.php'; + } elseif (preg_match('#^/webadmin/suppr/(.*)/?$#', $uri, $params)) { include_once EVOADMIN_BASE . '../inc/webadmin-suppr.php'; diff --git a/inc/webadmin-delete.php b/inc/webadmin-delete.php new file mode 100644 index 0000000..85b9e03 --- /dev/null +++ b/inc/webadmin-delete.php @@ -0,0 +1,72 @@ + + * @author Thomas Martin + * @author Sebastien Palma + * @version 1.0 + */ + +require_once EVOADMIN_BASE . '../lib/bdd.php'; +require_once EVOADMIN_BASE . '../lib/domain.php'; + +global $conf; + +include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; +include_once EVOADMIN_BASE . '../tpl/menu.tpl.php'; + +if (isset($_POST['delete-vhost'])) { + $domain = $params[1]; + + while(true) { + // Errors handling + if (empty($_POST['vhost-name'])) { + print "

Veuillez entrer le nom du compte web à supprimer.

"; + printf ('

Retour

', $_SERVER['REDIRECT_URL']); + break; + } + + if ($_POST['vhost-name'] !== $domain) { + print "Le nom de compte ne correspond pas."; + printf ('

Retour

', $_SERVER['REDIRECT_URL']); + break; + } + + if (isset($_POST['vhost-delete-db']) && empty($_POST['vhost-dbname'])) { + print "Veuillez spécifier un nom de base de données."; + printf ('

Retour

', $_SERVER['REDIRECT_URL']); + break; + } + + // Shell arguments + if (!empty($_POST['vhost-dbname'])) + $exec_cmd = "web-add.sh del -y " . $domain . " " . $_POST['vhost-dbname']; + else + $exec_cmd = "web-add.sh del -y " . $domain; + + // Execute script + sudoexec($exec_cmd, $exec_output, $exec_return); + + // Deal with response code + if ($exec_return == 0) + print "

Compte supprimé.

"; + else + print "

La suppression a échouée. Veuillez contacter votre administrateur.

"; + + break; + } + + include_once EVOADMIN_BASE . '../tpl/footer.tpl.php'; + +} else { + include_once EVOADMIN_BASE . '../tpl/webadmin-delete.tpl.php'; + include_once EVOADMIN_BASE . '../tpl/footer.tpl.php'; +} + +?> diff --git a/tpl/webadmin-delete.tpl.php b/tpl/webadmin-delete.tpl.php new file mode 100644 index 0000000..58338bc --- /dev/null +++ b/tpl/webadmin-delete.tpl.php @@ -0,0 +1,36 @@ + + * @version 1.0 + */ + +?> + +

Suppression du compte web

+ +
+
+

+ + +

+

+ + +

+

+ + +

+

+ +

+
+