From 59e8e5a6dccf95ce8a627dc5f31381862d33b3d1 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Mon, 15 Apr 2024 10:41:09 -0700 Subject: [PATCH] add new VHOSTLIMIT config option --- panel/classes/Panel/Vhost/VhostsAdd.php | 18 +++++++++++++++++- panel/classes/Panel/Vmail/DomainsAdd.php | 17 ++++++++++++++++- panel/config/config.ini | 2 ++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/panel/classes/Panel/Vhost/VhostsAdd.php b/panel/classes/Panel/Vhost/VhostsAdd.php index e213c00..37b0e92 100644 --- a/panel/classes/Panel/Vhost/VhostsAdd.php +++ b/panel/classes/Panel/Vhost/VhostsAdd.php @@ -34,13 +34,29 @@ class VhostsAdd extends \Panel\Vhost { } else { $deploy['showwriteinfo'] = 0; } + $f3->set('deploy', $deploy); + /* check if VHOSTLIMIT is set */ + if (is_numeric($f3->get('VHOSTLIMIT'))) { + if ($f3->get('VHOSTLIMIT') > 0) { + $f3->set('vhostlimited', TRUE); + if ($vhosts_array = $f3->call('\Panel::vGet', array("vhost-get.sh -c", FALSE))) { + $f3->set('vhostscount', count($vhosts_array)); + } + } + } + } static function get($f3) { - echo \Template::instance()->render('vhost/vhosts-add.html'); + /* check VHOSTLIMIT */ + if ($f3->get('vhostlimited') && ($f3->get('vhostscount') >= $f3->get('VHOSTLIMIT'))) { + echo \Template::instance()->render('vhost/vhosts-add-max.html'); + } else { + echo \Template::instance()->render('vhost/vhosts-add.html'); + } } diff --git a/panel/classes/Panel/Vmail/DomainsAdd.php b/panel/classes/Panel/Vmail/DomainsAdd.php index 64fac1d..8605b48 100644 --- a/panel/classes/Panel/Vmail/DomainsAdd.php +++ b/panel/classes/Panel/Vmail/DomainsAdd.php @@ -19,11 +19,26 @@ class DomainsAdd extends \Panel\Vmail { $vm_domains_defaults = $f3->call('\Panel::vGet', array("vmail-defaults-get.sh -c", FALSE)); $f3->set('vm_domains_defaults', $vm_domains_defaults[0]); + /* check if VHOSTLIMIT is set */ + if (is_numeric($f3->get('VHOSTLIMIT'))) { + if ($f3->get('VHOSTLIMIT') > 0) { + $f3->set('vhostlimited', TRUE); + if ($domains_array = $f3->call('\Panel::vGet', array("vmail-domains-get.sh -c", FALSE))) { + $f3->set('vhostscount', count($domains_array)); + } + } + } + } static function get($f3) { - echo \Template::instance()->render('vmail/domains-add.html'); + /* check VHOSTLIMIT */ + if ($f3->get('vhostlimited') && ($f3->get('vhostscount') >= $f3->get('VHOSTLIMIT'))) { + echo \Template::instance()->render('vmail/domains-add-max.html'); + } else { + echo \Template::instance()->render('vmail/domains-add.html'); + } } diff --git a/panel/config/config.ini b/panel/config/config.ini index 9f1f339..ba67f57 100644 --- a/panel/config/config.ini +++ b/panel/config/config.ini @@ -28,6 +28,8 @@ FPMMAX=4 WRITEUSERINFO=1 ; Show "Write User Info" & "Write DB Info" options. If no then just use defaults above without giving users the option to change. 1 = Yes, blank or 0 = No SHOWWRITEINFO=0 +; Maximum number of websites that can be installed. Blank or 0 = unlimited. +VHOSTLIMIT=0 ; DNS admin. 1 = Yes, blank or 0 = No VDNSADMIN=0 ; Maximum number of results returned for DNS listings. Defaults to 100 if unspecified.