vpanel-stack/panel/classes/Panel/Vhost/VhostsDelete.php
2023-06-19 11:53:16 -07:00

53 lines
1.2 KiB
PHP

<?php
/**
* vpanel-stack
* https://git.stack-source.com/msb/vpanel-stack
* Copyright (c) 2022 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
* GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
*/
namespace Panel\Vhost;
class VhostsDelete extends \Panel\Vhost {
function beforeRoute($f3) {
parent::beforeRoute($f3);
/* verify user exists */
}
static function get($f3) {
$f3->set('confirm', 'true');
echo \Template::instance()->render('vhost/vhosts-delete.html');
}
function post($f3) {
/* run delete command here */
$domain = $f3->get('PARAMS.vhost');
$messages = array();
$output = system("/usr/local/bin/vhost-destroy.sh -d $domain", $result_code);
if ($result_code == 0) {
$messages[] = "Website '$domain' has been deleted.";
} else {
$messages[] = "Error deleting website '$domain'.";
$messages[] = $output;
}
$f3->set('SESSION.messages', $messages);
$f3->reroute("/Websites");
// $mapping = $f3->get('NAV.mapping');
// if ($mapping == 'vmail') {
// $f3->reroute("/Users");
// } else {
// $f3->reroute("/Email/$domain/Accounts");
// }
}
}