vpanel-stack/panel/classes/Panel/Vhost/UsersDelete.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 UsersDelete 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/users-delete.html');
}
function post($f3) {
/* run delete command here */
$username = $f3->get('PARAMS.username');
$messages = array();
$output = system("/usr/local/bin/vhost-user-del.sh -u $username", $result_code);
if ($result_code == 0) {
$messages[] = "User '$username' has been deleted.";
} else {
$messages[] = "Error deleting user '$username'.";
$messages[] = $output;
}
$f3->set('SESSION.messages', $messages);
$f3->reroute("/Users");
// $mapping = $f3->get('NAV.mapping');
// if ($mapping == 'vmail') {
// $f3->reroute("/Users");
// } else {
// $f3->reroute("/Email/$domain/Accounts");
// }
}
}