vpanel-stack/panel/classes/Panel/Vhost/Vhosts.php
Matthew Saunders Brown fd94a4e3c4 initial commit
2022-07-01 15:24:26 -07:00

76 lines
2.0 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 Vhosts extends \Panel\Vhost {
/* use this to make query */
function beforeRoute($f3) {
parent::beforeRoute($f3);
if ($f3->exists('PARAMS.vhost')) {
$vhost = $f3->get('PARAMS.vhost');
if ($vhost_array = $f3->call('\Panel::vGet', array("vhost-get.sh -d $vhost -c", FALSE))) {
$f3->set('vhost_array', $vhost_array[0]);
}
} else {
if ($vhosts_array = $f3->call('\Panel::vGet', array("vhost-get.sh -c", FALSE))) {
$f3->set('vhosts_array', $vhosts_array);
}
}
}
static function get($f3) {
if ($f3->exists('PARAMS.vhost')) {
$vhost_array = $f3->get('vhost_array');
/* convert data for frontend display */
if ($vhost_array['status'] == 1) {
$vhost_array['status'] = 'Enabled';
} else {
$vhost_array['status'] = 'Disabled';
}
if ($vhost_array['mbox_limit'] == "NULL") {
$vhost_array['mbox_limit'] = 'Unlimited';
}
if ($vhost_array['mbox_quota_default'] == "NULL") {
$vhost_array['mbox_quota_default'] = 'Unlimited';
} else {
$vhost_array['mbox_quota_default'] .= ' GB';
}
if ($vhost_array['mbox_ratelimit_default'] == "NULL") {
$vhost_array['mbox_ratelimit_default'] = 'Unlimited';
} else {
$vhost_array['mbox_ratelimit_default'] .= ' emails per hour';
}
$f3->set('vhost_array', $vhost_array);
$vhost = $f3->get('PARAMS.vhost');
$f3->set('page_header', "Website Hosting for $vhost");
echo \Template::instance()->render('vhost/vhosts-vhost.html');
} else {
$f3->set('page_header', "Websites");
echo \Template::instance()->render('vhost/vhosts.html');
}
}
}