From 58889272399fb342478043d976bcb8bdfe8426ff Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Thu, 20 Dec 2018 12:38:18 +0100 Subject: [PATCH] get rid of more functions Signed-off-by: Michael Kaufmann --- actions/admin/settings/120.system.php | 6 +- admin_domains.php | 6 +- admin_settings.php | 12 +- admin_updates.php | 2 +- customer_domains.php | 10 +- customer_extras.php | 34 ++--- customer_ftp.php | 4 +- index.php | 6 +- .../updates/froxlor/0.9/update_0.9.inc.php | 6 +- lib/Froxlor/Api/Commands/Certificates.php | 2 +- lib/Froxlor/Api/Commands/Cronjobs.php | 2 +- lib/Froxlor/Api/Commands/CustomerBackups.php | 2 +- lib/Froxlor/Api/Commands/Customers.php | 26 ++-- lib/Froxlor/Api/Commands/DirOptions.php | 6 +- lib/Froxlor/Api/Commands/DirProtections.php | 6 +- lib/Froxlor/Api/Commands/DomainZones.php | 4 +- lib/Froxlor/Api/Commands/Domains.php | 30 ++--- lib/Froxlor/Api/Commands/EmailAccounts.php | 2 +- lib/Froxlor/Api/Commands/Emails.php | 2 +- lib/Froxlor/Api/Commands/FpmDaemons.php | 6 +- lib/Froxlor/Api/Commands/Froxlor.php | 8 +- lib/Froxlor/Api/Commands/Ftps.php | 8 +- lib/Froxlor/Api/Commands/IpsAndPorts.php | 12 +- lib/Froxlor/Api/Commands/PhpSettings.php | 6 +- lib/Froxlor/Api/Commands/SubDomains.php | 34 ++--- lib/Froxlor/Cron/Http/Apache.php | 4 +- .../Cron/Http/LetsEncrypt/LetsEncrypt.php | 2 +- .../Cron/Http/LetsEncrypt/LetsEncrypt_v2.php | 2 +- lib/Froxlor/Cron/Http/Lighttpd.php | 4 +- lib/Froxlor/Cron/Http/Nginx.php | 4 +- lib/Froxlor/Cron/Http/WebserverBase.php | 2 +- lib/Froxlor/Cron/MasterCron.php | 10 +- lib/Froxlor/Cron/System/TasksCron.php | 2 +- lib/Froxlor/Customer/Customer.php | 75 +++++++++++ lib/Froxlor/Domain/Domain.php | 123 ++++++++++++++++++ lib/Froxlor/Domain/IpAddr.php | 83 ++++++++++++ lib/Froxlor/FileDir.php | 96 +++++++++++++- lib/Froxlor/PhpHelper.php | 33 ++++- lib/Froxlor/System/Cronjob.php | 99 ++++++++++++++ .../domains/formfield.domains_edit.php | 2 +- .../filedir/function.makePathfield.php | 106 --------------- .../filedir/function.storeDefaultIndex.php | 72 ---------- .../function.customerHasPerlEnabled.php | 44 ------- .../function.domainHasMainSubDomains.php | 64 --------- .../froxlor/function.domainHasSslIpPort.php | 43 ------ .../froxlor/function.getCustomerDetail.php | 32 ----- .../froxlor/function.getIpAddresses.php | 41 ------ .../function.getIpPortCombinations.php | 68 ---------- .../froxlor/function.getLoginNameByUid.php | 23 ---- lib/functions/froxlor/function.inserttask.php | 117 ----------------- .../function.isCustomerStdSubdomain.php | 43 ------ ...etsEncryptCSRForAliasDestinationDomain.php | 34 ----- lib/functions/system/function.randomStr.php | 27 ---- 53 files changed, 639 insertions(+), 858 deletions(-) create mode 100644 lib/Froxlor/Customer/Customer.php create mode 100644 lib/Froxlor/Domain/Domain.php create mode 100644 lib/Froxlor/Domain/IpAddr.php delete mode 100644 lib/functions/filedir/function.makePathfield.php delete mode 100644 lib/functions/filedir/function.storeDefaultIndex.php delete mode 100644 lib/functions/froxlor/function.customerHasPerlEnabled.php delete mode 100644 lib/functions/froxlor/function.domainHasMainSubDomains.php delete mode 100644 lib/functions/froxlor/function.domainHasSslIpPort.php delete mode 100644 lib/functions/froxlor/function.getCustomerDetail.php delete mode 100644 lib/functions/froxlor/function.getIpAddresses.php delete mode 100644 lib/functions/froxlor/function.getIpPortCombinations.php delete mode 100644 lib/functions/froxlor/function.getLoginNameByUid.php delete mode 100644 lib/functions/froxlor/function.inserttask.php delete mode 100644 lib/functions/froxlor/function.isCustomerStdSubdomain.php delete mode 100644 lib/functions/froxlor/function.triggerLetsEncryptCSRForAliasDestinationDomain.php diff --git a/actions/admin/settings/120.system.php b/actions/admin/settings/120.system.php index 7d643c2e..2b8698e7 100644 --- a/actions/admin/settings/120.system.php +++ b/actions/admin/settings/120.system.php @@ -46,7 +46,7 @@ return array( 'varname' => 'ipaddress', 'type' => 'option', 'option_mode' => 'one', - 'option_options_method' => 'getIpAddresses', + 'option_options_method' => array('\\Froxlor\\Domain\\IpAddr', 'getIpAddresses'), 'default' => '', 'save_method' => 'storeSettingIpAddress', ), @@ -56,7 +56,7 @@ return array( 'varname' => 'defaultip', 'type' => 'option', 'option_mode' => 'multiple', - 'option_options_method' => 'getIpPortCombinations', + 'option_options_method' => array('\\Froxlor\\Domain\\IpAddr', 'getIpPortCombinations'), 'default' => '', 'save_method' => 'storeSettingDefaultIp', ), @@ -66,7 +66,7 @@ return array( 'varname' => 'defaultsslip', 'type' => 'option', 'option_mode' => 'multiple', - 'option_options_method' => 'getSslIpPortCombinations', + 'option_options_method' => array('\\Froxlor\\Domain\\IpAddr', 'getSslIpPortCombinations'), 'default' => '', 'save_method' => 'storeSettingDefaultSslIp', ), diff --git a/admin_domains.php b/admin_domains.php index 9e959532..4e02b308 100644 --- a/admin_domains.php +++ b/admin_domains.php @@ -156,7 +156,7 @@ if ($page == 'domains' || $page == 'overview') { } else { $showcheck = false; - if (domainHasMainSubDomains($id)) { + if (\Froxlor\Domain\Domain::domainHasMainSubDomains($id)) { $showcheck = true; } ask_yesno_withcheckbox('admin_domain_reallydelete', 'remove_subbutmain_domains', $filename, array( @@ -668,8 +668,8 @@ if ($page == 'domains' || $page == 'overview') { // update customer/admin counters updateCounters(false); - inserttask('1'); - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('1'); + \Froxlor\System\Cronjob::inserttask('4'); $result_str = $result['imported'] . ' / ' . $result['all'] . (! empty($result['note']) ? ' (' . $result['note'] . ')' : ''); standard_success('domain_import_successfully', $result_str, array( diff --git a/admin_settings.php b/admin_settings.php index d94e1f35..690307cc 100644 --- a/admin_settings.php +++ b/admin_settings.php @@ -65,9 +65,9 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') { 'page' => $page ), $_part, $settings_all, $settings_part, $only_enabledisable)) { $log->logAction(ADM_ACTION, LOG_INFO, "rebuild configfiles due to changed setting"); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); // Using nameserver, insert a task which rebuilds the server config - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); standard_success('settingssaved', '', array( 'filename' => $filename, @@ -143,12 +143,12 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') { if (isset($_POST['send']) && $_POST['send'] == 'send') { $log->logAction(ADM_ACTION, LOG_INFO, "rebuild configfiles"); - inserttask('1'); - inserttask('10'); + \Froxlor\System\Cronjob::inserttask('1'); + \Froxlor\System\Cronjob::inserttask('10'); // Using nameserver, insert a task which rebuilds the server config - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); // cron.d file - inserttask('99'); + \Froxlor\System\Cronjob::inserttask('99'); standard_success('rebuildingconfigs', '', array( 'filename' => 'admin_index.php' diff --git a/admin_updates.php b/admin_updates.php index 97508130..efb6d11a 100644 --- a/admin_updates.php +++ b/admin_updates.php @@ -77,7 +77,7 @@ if ($page == 'overview') { eval("echo \"" . getTemplate('update/update_end') . "\";"); updateCounters(); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); @chmod('./lib/userdata.inc.php', 0440); $successful_update = true; diff --git a/customer_domains.php b/customer_domains.php index b124af59..9a6f7296 100644 --- a/customer_domains.php +++ b/customer_domains.php @@ -168,7 +168,7 @@ if ($page == 'overview') { // get ssl-ips if activated $show_ssledit = false; - if (Settings::Get('system.use_ssl') == '1' && domainHasSslIpPort($row['id']) && $row['caneditdomain'] == '1' && $row['letsencrypt'] == 0) { + if (Settings::Get('system.use_ssl') == '1' && \Froxlor\Domain\Domain::domainHasSslIpPort($row['id']) && $row['caneditdomain'] == '1' && $row['letsencrypt'] == 0) { $show_ssledit = true; } $row = htmlentities_array($row); @@ -270,7 +270,7 @@ if ($page == 'overview') { } $openbasedir = makeoption($lng['domain']['docroot'], 0, NULL, true) . makeoption($lng['domain']['homedir'], 1, NULL, true); - $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); + $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $phpconfigs = ''; $has_phpconfigs = false; @@ -349,14 +349,14 @@ if ($page == 'overview') { if (preg_match('/^https?\:\/\//', $result['documentroot']) && validateUrl($result['documentroot'])) { if (Settings::Get('panel.pathedit') == 'Dropdown') { $urlvalue = $result['documentroot']; - $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); + $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); } else { $urlvalue = ''; - $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $result['documentroot'], true); + $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $result['documentroot'], true); } } else { $urlvalue = ''; - $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $result['documentroot']); + $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $result['documentroot']); } $redirectcode = ''; diff --git a/customer_extras.php b/customer_extras.php index 831b1564..865503b8 100644 --- a/customer_extras.php +++ b/customer_extras.php @@ -26,7 +26,7 @@ use Froxlor\Api\Commands\DirProtections as DirProtections; use Froxlor\Api\Commands\CustomerBackups as CustomerBackups; // redirect if this customer page is hidden via settings -if (Settings::IsInList('panel.customer_hide_options','extras')) { +if (Settings::IsInList('panel.customer_hide_options', 'extras')) { redirectTo('customer_index.php'); } @@ -42,7 +42,7 @@ if ($page == 'overview') { } elseif ($page == 'htpasswds') { // redirect if this customer sub-page is hidden via settings - if (Settings::IsInList('panel.customer_hide_options','extras.directoryprotection')) { + if (Settings::IsInList('panel.customer_hide_options', 'extras.directoryprotection')) { redirectTo('customer_index.php'); } @@ -127,7 +127,7 @@ if ($page == 'overview') { 's' => $s )); } else { - $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); + $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $htpasswd_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_add.php'; $htpasswd_add_form = htmlform::genHTMLForm($htpasswd_add_data); @@ -178,7 +178,7 @@ if ($page == 'overview') { } elseif ($page == 'htaccess') { // redirect if this customer sub-page is hidden via settings - if (Settings::IsInList('panel.customer_hide_options','extras.pathoptions')) { + if (Settings::IsInList('panel.customer_hide_options', 'extras.pathoptions')) { redirectTo('customer_index.php'); } @@ -269,7 +269,7 @@ if ($page == 'overview') { 's' => $s )); } else { - $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); + $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $cperlenabled = customerHasPerlEnabled($userinfo['customerid']); $htaccess_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_add.php'; @@ -329,12 +329,11 @@ if ($page == 'overview') { } elseif ($page == 'backup') { // redirect if this customer sub-page is hidden via settings - if (Settings::IsInList('panel.customer_hide_options','extras.backup')) { + if (Settings::IsInList('panel.customer_hide_options', 'extras.backup')) { redirectTo('customer_index.php'); } - if (Settings::Get('system.backupenabled') == 1) - { + if (Settings::Get('system.backupenabled') == 1) { if ($action == 'abort' && isset($_POST['send']) && $_POST['send'] == 'send') { $log->logAction(USR_ACTION, LOG_NOTICE, "customer_extras::backup - aborted scheduled backupjob"); try { @@ -343,7 +342,11 @@ if ($page == 'overview') { dynamic_error($e->getMessage()); } standard_success('backupaborted'); - redirectTo($filename, array('page' => $page, 'action' => '', 's' => $s)); + redirectTo($filename, array( + 'page' => $page, + 'action' => '', + 's' => $s + )); } if ($action == '') { $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras::backup"); @@ -356,8 +359,7 @@ if ($page == 'overview') { } $result = json_decode($json_result, true)['data']; $existing_backupJob = null; - if ($result['count'] > 0) - { + if ($result['count'] > 0) { $existing_backupJob = array_shift($result['list']); } @@ -370,7 +372,7 @@ if ($page == 'overview') { standard_success('backupscheduled'); } else { - if (!empty($existing_backupJob)) { + if (! empty($existing_backupJob)) { $action = "abort"; $row = $existing_backupJob['data']; @@ -379,22 +381,20 @@ if ($page == 'overview') { $row['backup_mail'] = ($row['backup_mail'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no']; $row['backup_dbs'] = ($row['backup_dbs'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no']; } - $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); + $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $backup_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.backup.php'; $backup_form = htmlform::genHTMLForm($backup_data); $title = $backup_data['backup']['title']; $image = $backup_data['backup']['image']; - if (!empty($existing_backupJob)) { + if (! empty($existing_backupJob)) { // overwrite backup_form after we took everything from it we needed eval("\$backup_form = \"" . getTemplate("extras/backup_listexisting") . "\";"); } eval("echo \"" . getTemplate("extras/backup") . "\";"); } } - } - else - { + } else { standard_error('backupfunctionnotenabled'); } } diff --git a/customer_ftp.php b/customer_ftp.php index c93fdfbd..4d2d7024 100644 --- a/customer_ftp.php +++ b/customer_ftp.php @@ -116,7 +116,7 @@ if ($page == 'overview') { } redirectTo($filename, array('page' => $page, 's' => $s)); } else { - $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], '/'); + $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], '/'); if (Settings::Get('customer.ftpatdomain') == '1') { $domainlist = array(); @@ -189,7 +189,7 @@ if ($page == 'overview') { } $homedir = \Froxlor\FileDir::makeCorrectDir($homedir); - $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $homedir); + $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $homedir); if (Settings::Get('customer.ftpatdomain') == '1') { $domains = ''; diff --git a/index.php b/index.php index 47a50c42..4d0ab92c 100644 --- a/index.php +++ b/index.php @@ -432,8 +432,8 @@ if ($action == 'forgotpwd') { if ($user !== false) { // build a activation code $timestamp = time(); - $first = substr(md5($user['loginname'] . $timestamp . randomStr(16)), 0, 15); - $third = substr(md5($user['email'] . $timestamp . randomStr(16)), - 15); + $first = substr(md5($user['loginname'] . $timestamp . \Froxlor\PhpHelper::randomStr(16)), 0, 15); + $third = substr(md5($user['email'] . $timestamp . \Froxlor\PhpHelper::randomStr(16)), - 15); $activationcode = $first . $timestamp . $third . substr(md5($third . $timestamp), 0, 10); // Drop all existing activation codes for this user @@ -761,4 +761,4 @@ function finishLogin($userinfo) } } return false; -} \ No newline at end of file +} diff --git a/install/updates/froxlor/0.9/update_0.9.inc.php b/install/updates/froxlor/0.9/update_0.9.inc.php index 2e2979ee..ac1701de 100644 --- a/install/updates/froxlor/0.9/update_0.9.inc.php +++ b/install/updates/froxlor/0.9/update_0.9.inc.php @@ -2810,7 +2810,7 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.9.32-dev4')) { $crondfile = \Froxlor\FileDir::makeCorrectFile($crondfile); Settings::AddNew("system.cronconfig", $crondfile); // add task to generate cron.d-file - inserttask('99'); + \Froxlor\System\Cronjob::inserttask('99'); lastStepStatus(0); \Froxlor\Froxlor::updateToVersion('0.9.32-dev5'); @@ -2825,7 +2825,7 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.9.32-dev5')) { $crondreload = isset($_POST['crondreload']) ? $_POST['crondreload'] : "/etc/init.d/cron reload"; Settings::AddNew("system.crondreload", $crondreload); // add task to generate cron.d-file - inserttask('99'); + \Froxlor\System\Cronjob::inserttask('99'); lastStepStatus(0); \Froxlor\Froxlor::updateToVersion('0.9.32-dev6'); @@ -2855,7 +2855,7 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.9.32-rc1')) { $croncmdline = isset($_POST['croncmdline']) ? $_POST['croncmdline'] : "/usr/bin/nice -n 5 /usr/bin/php5 -q"; Settings::AddNew("system.croncmdline", $croncmdline); // add task to generate cron.d-file - inserttask('99'); + \Froxlor\System\Cronjob::inserttask('99'); // silenty add the auto-update setting - we do not want everybody to know and use this // as it is a very dangerous setting Settings::AddNew("system.cron_allowautoupdate", 0); diff --git a/lib/Froxlor/Api/Commands/Certificates.php b/lib/Froxlor/Api/Commands/Certificates.php index 73873153..9d6ad840 100644 --- a/lib/Froxlor/Api/Commands/Certificates.php +++ b/lib/Froxlor/Api/Commands/Certificates.php @@ -341,7 +341,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou ); Database::pexecute($stmt, $params, true, true); // insert task to re-generate webserver-configs (#1260) - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); return true; } } diff --git a/lib/Froxlor/Api/Commands/Cronjobs.php b/lib/Froxlor/Api/Commands/Cronjobs.php index b4e95517..4fe82f61 100644 --- a/lib/Froxlor/Api/Commands/Cronjobs.php +++ b/lib/Froxlor/Api/Commands/Cronjobs.php @@ -114,7 +114,7 @@ class Cronjobs extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceE ), true, true); // insert task to re-generate the cron.d-file - inserttask('99'); + \Froxlor\System\Cronjob::inserttask('99'); $this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] cronjob with description '" . $result['module'] . '/' . $result['cronfile'] . "' has been updated by '" . $this->getUserDetail('loginname') . "'"); $result = $this->apiCall('Cronjobs.get', array( 'id' => $id diff --git a/lib/Froxlor/Api/Commands/CustomerBackups.php b/lib/Froxlor/Api/Commands/CustomerBackups.php index 840a187d..3be044f0 100644 --- a/lib/Froxlor/Api/Commands/CustomerBackups.php +++ b/lib/Froxlor/Api/Commands/CustomerBackups.php @@ -106,7 +106,7 @@ class CustomerBackups extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re 'backup_web' => $backup_web ); // schedule backup job - inserttask('20', $task_data); + \Froxlor\System\Cronjob::inserttask('20', $task_data); $this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_NOTICE, "[API] added customer-backup job for '" . $customer['loginname'] . "'. Target directory: " . $userpath); return $this->response(200, "successfull", $task_data); diff --git a/lib/Froxlor/Api/Commands/Customers.php b/lib/Froxlor/Api/Commands/Customers.php index 540fa194..d26fa2ab 100644 --- a/lib/Froxlor/Api/Commands/Customers.php +++ b/lib/Froxlor/Api/Commands/Customers.php @@ -517,10 +517,10 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource unset($ins_data); // insert task to create homedir etc. - inserttask('2', $loginname, $guid, $guid, $store_defaultindex); + \Froxlor\System\Cronjob::inserttask('2', $loginname, $guid, $guid, $store_defaultindex); // Using filesystem - quota, insert a task which cleans the filesystem - quota - inserttask('10'); + \Froxlor\System\Cronjob::inserttask('10'); // Add htpasswd for the stats-pages if (CRYPT_STD_DES == 1) { @@ -551,7 +551,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource $this->logger()->logAction(ADM_ACTION, LOG_NOTICE, "[API] automatically added " . $stats_folder . " htpasswd for user '" . $loginname . "'"); Database::pexecute($ins_stmt, $ins_data, true, true); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); $cryptPassword = \Froxlor\System\Crypt::makeCryptPassword($password); // add FTP-User // @fixme use Ftp-ApiCommand later @@ -641,7 +641,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource 'customerid' => $customerid ), true, true); $this->logger()->logAction(ADM_ACTION, LOG_NOTICE, "[API] automatically added standardsubdomain for user '" . $loginname . "'"); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); } } @@ -984,7 +984,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource 'customerid' => $result['customerid'] ), true, true); $this->logger()->logAction(ADM_ACTION, LOG_NOTICE, "[API] automatically added standardsubdomain for user '" . $result['loginname'] . "'"); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); } } @@ -998,7 +998,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource $this->logger()->logAction(ADM_ACTION, LOG_ERR, "[API] Unable to delete standard-subdomain: " . $e->getMessage()); } $this->logger()->logAction(ADM_ACTION, LOG_NOTICE, "[API] automatically deleted standardsubdomain for user '" . $result['loginname'] . "'"); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); } if ($deactivated != '1') { @@ -1018,7 +1018,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource } if ($phpenabled != $result['phpenabled'] || $perlenabled != $result['perlenabled']) { - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); } if ($logviewenabled != '0') { @@ -1104,7 +1104,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource ), true, true); $this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] " . ($deactivated ? 'deactivated' : 'reactivated') . " user '" . $result['loginname'] . "'"); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); } // Disable or enable POP3 Login for customers Mail Accounts @@ -1214,7 +1214,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource if ($this->isAdmin()) { // Using filesystem - quota, insert a task which cleans the filesystem - quota - inserttask('10'); + \Froxlor\System\Cronjob::inserttask('10'); $admin_update_query = "UPDATE `" . TABLE_PANEL_ADMINS . "` SET `customers_used` = `customers_used` "; @@ -1543,18 +1543,18 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource Database::query($admin_update_query); // rebuild configs - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); // Using nameserver, insert a task which rebuilds the server config - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); if ($delete_userfiles == 1) { // insert task to remove the customers files from the filesystem - inserttask('6', $result['loginname']); + \Froxlor\System\Cronjob::inserttask('6', $result['loginname']); } // Using filesystem - quota, insert a task which cleans the filesystem - quota - inserttask('10'); + \Froxlor\System\Cronjob::inserttask('10'); $this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] deleted customer '" . $result['loginname'] . "'"); return $this->response(200, "successfull", $result); diff --git a/lib/Froxlor/Api/Commands/DirOptions.php b/lib/Froxlor/Api/Commands/DirOptions.php index 2721ce41..0c5f44e5 100644 --- a/lib/Froxlor/Api/Commands/DirOptions.php +++ b/lib/Froxlor/Api/Commands/DirOptions.php @@ -123,7 +123,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc Database::pexecute($stmt, $params, true, true); $id = Database::lastInsertId(); $this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_INFO, "[API] added directory-option for '" . $userpath . "'"); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); $result = $this->apiCall('DirOptions.get', array( 'id' => $id @@ -248,7 +248,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc } if (($options_indexes != $result['options_indexes']) || ($error404path != $result['error404path']) || ($error403path != $result['error403path']) || ($error500path != $result['error500path']) || ($options_cgi != $result['options_cgi'])) { - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); $stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_HTACCESS . "` SET `options_indexes` = :options_indexes, @@ -375,7 +375,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc "id" => $id )); $this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_INFO, "[API] deleted directory-option for '" . str_replace($customer_data['documentroot'], '/', $result['path']) . "'"); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); return $this->response(200, "successfull", $result); } } diff --git a/lib/Froxlor/Api/Commands/DirProtections.php b/lib/Froxlor/Api/Commands/DirProtections.php index b1f61fae..97be648f 100644 --- a/lib/Froxlor/Api/Commands/DirProtections.php +++ b/lib/Froxlor/Api/Commands/DirProtections.php @@ -112,7 +112,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res Database::pexecute($stmt, $params, true, true); $id = Database::lastInsertId(); $this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_INFO, "[API] added directory-protection for '" . $username . " (" . $path . ")'"); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); $result = $this->apiCall('DirProtections.get', array( 'id' => $id @@ -261,7 +261,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res UPDATE `" . TABLE_PANEL_HTPASSWDS . "` SET " . $upd_query . " WHERE `id` = :id AND `customerid`= :cid "); Database::pexecute($upd_stmt, $upd_params, true, true); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); } $this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_INFO, "[API] updated directory-protection '" . $result['username'] . " (" . $result['path'] . ")'"); @@ -357,7 +357,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res )); $this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_INFO, "[API] deleted htpasswd for '" . $result['username'] . " (" . $result['path'] . ")'"); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); return $this->response(200, "successfull", $result); } } diff --git a/lib/Froxlor/Api/Commands/DomainZones.php b/lib/Froxlor/Api/Commands/DomainZones.php index db4ae09a..b2ed2f72 100644 --- a/lib/Froxlor/Api/Commands/DomainZones.php +++ b/lib/Froxlor/Api/Commands/DomainZones.php @@ -281,7 +281,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour $dom_entries[] = $new_entry; // re-generate bind configs - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); $result = $this->apiCall('DomainZones.get', array( 'id' => $id @@ -392,7 +392,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour ), true, true); if ($del_stmt->rowCount() > 0) { // re-generate bind configs - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); return $this->response(200, "successfull", true); } return $this->response(304, "successfull", true); diff --git a/lib/Froxlor/Api/Commands/Domains.php b/lib/Froxlor/Api/Commands/Domains.php index fd96a6eb..2b32482b 100644 --- a/lib/Froxlor/Api/Commands/Domains.php +++ b/lib/Froxlor/Api/Commands/Domains.php @@ -638,11 +638,11 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn } } - triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); + \Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); // Using nameserver, insert a task which rebuilds the server config - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); $this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] added domain '" . $domain . "'"); @@ -1140,7 +1140,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn $iswildcarddomain = ($serveraliasoption == '0') ? '1' : '0'; if ($documentroot != $result['documentroot'] || $ssl_redirect != $result['ssl_redirect'] || $wwwserveralias != $result['wwwserveralias'] || $iswildcarddomain != $result['iswildcarddomain'] || $phpenabled != $result['phpenabled'] || $openbasedir != $result['openbasedir'] || $phpsettingid != $result['phpsettingid'] || $mod_fcgid_starter != $result['mod_fcgid_starter'] || $mod_fcgid_maxrequests != $result['mod_fcgid_maxrequests'] || $specialsettings != $result['specialsettings'] || $notryfiles != $result['notryfiles'] || $writeaccesslog != $result['writeaccesslog'] || $writeerrorlog != $result['writeerrorlog'] || $aliasdomain != $result['aliasdomain'] || $issubof != $result['ismainbutsubto'] || $email_only != $result['email_only'] || ($speciallogfile != $result['speciallogfile'] && $speciallogverified == '1') || $letsencrypt != $result['letsencrypt'] || $http2 != $result['http2'] || $hsts_maxage != $result['hsts'] || $hsts_sub != $result['hsts_sub'] || $hsts_preload != $result['hsts_preload'] || $ocsp_stapling != $result['ocsp_stapling']) { - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); } if ($speciallogfile != $result['speciallogfile'] && $speciallogverified != '1') { @@ -1148,11 +1148,11 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn } if ($isbinddomain != $result['isbinddomain'] || $zonefile != $result['zonefile'] || $dkim != $result['dkim'] || $isemaildomain != $result['isemaildomain']) { - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); } // check whether nameserver has been disabled, #581 if ($isbinddomain != $result['isbinddomain'] && $isbinddomain == 0) { - inserttask('11', $result['domain']); + \Froxlor\System\Cronjob::inserttask('11', $result['domain']); } if ($isemaildomain == '0' && $result['isemaildomain'] == '1') { @@ -1380,7 +1380,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn Database::pexecute($_update_stmt, $_update_data, true, true); // insert a rebuild-task - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); // Cleanup domain <-> ip mapping $del_stmt = Database::prepare(" @@ -1449,16 +1449,16 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn } if ($result['aliasdomain'] != $aliasdomain) { // trigger when domain id for alias destination has changed: both for old and new destination - triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $this->logger()); - triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); + \Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $this->logger()); + \Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); } elseif ($result['wwwserveralias'] != $wwwserveralias || $result['letsencrypt'] != $letsencrypt) { // or when wwwserveralias or letsencrypt was changed - triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); + \Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); if ($aliasdomain === 0) { // in case the wwwserveralias is set on a main domain, $aliasdomain is 0 // --> the call just above to triggerLetsEncryptCSRForAliasDestinationDomain // is a noop...let's repeat it with the domain id of the main domain - triggerLetsEncryptCSRForAliasDestinationDomain($id, $this->logger()); + \Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($id, $this->logger()); } } @@ -1611,16 +1611,16 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn 'domainid' => $id ), true, true); - triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $this->logger()); + \Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $this->logger()); // remove domains DNS from powerDNS if used, #581 - inserttask('11', $result['domain']); + \Froxlor\System\Cronjob::inserttask('11', $result['domain']); $this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] deleted domain/subdomains (#" . $result['id'] . ")"); updateCounters(); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); // Using nameserver, insert a task which rebuilds the server config - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); return $this->response(200, "successfull", $result); } throw new \Exception("Not allowed to execute given command.", 403); diff --git a/lib/Froxlor/Api/Commands/EmailAccounts.php b/lib/Froxlor/Api/Commands/EmailAccounts.php index 89535007..32071eb9 100644 --- a/lib/Froxlor/Api/Commands/EmailAccounts.php +++ b/lib/Froxlor/Api/Commands/EmailAccounts.php @@ -474,7 +474,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso } if ($delete_userfiles) { - inserttask('7', $customer['loginname'], $result['email_full']); + \Froxlor\System\Cronjob::inserttask('7', $customer['loginname'], $result['email_full']); } // decrease usage for customer diff --git a/lib/Froxlor/Api/Commands/Emails.php b/lib/Froxlor/Api/Commands/Emails.php index c2a1e2ca..07691acb 100644 --- a/lib/Froxlor/Api/Commands/Emails.php +++ b/lib/Froxlor/Api/Commands/Emails.php @@ -371,7 +371,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt Admins::decreaseUsage($customer['customerid'], 'email_forwarders_used', '', $number_forwarders); if ($delete_userfiles) { - inserttask('7', $customer['loginname'], $result['email_full']); + \Froxlor\System\Cronjob::inserttask('7', $customer['loginname'], $result['email_full']); } // delete address diff --git a/lib/Froxlor/Api/Commands/FpmDaemons.php b/lib/Froxlor/Api/Commands/FpmDaemons.php index 75faa021..009b77de 100644 --- a/lib/Froxlor/Api/Commands/FpmDaemons.php +++ b/lib/Froxlor/Api/Commands/FpmDaemons.php @@ -198,7 +198,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc Database::pexecute($ins_stmt, $ins_data); $id = Database::lastInsertId(); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); $this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] fpm-daemon with description '" . $description . "' has been created by '" . $this->getUserDetail('loginname') . "'"); $result = $this->apiCall('FpmDaemons.get', array( 'id' => $id @@ -315,7 +315,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc ); Database::pexecute($upd_stmt, $upd_data, true, true); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); $this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] fpm-daemon with description '" . $description . "' has been updated by '" . $this->getUserDetail('loginname') . "'"); $result = $this->apiCall('FpmDaemons.get', array( 'id' => $id @@ -364,7 +364,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc 'id' => $id ), true, true); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); $this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] fpm-daemon setting '" . $result['description'] . "' has been deleted by '" . $this->getUserDetail('loginname') . "'"); return $this->response(200, "successfull", $result); } diff --git a/lib/Froxlor/Api/Commands/Froxlor.php b/lib/Froxlor/Api/Commands/Froxlor.php index 7160c51b..91519b03 100644 --- a/lib/Froxlor/Api/Commands/Froxlor.php +++ b/lib/Froxlor/Api/Commands/Froxlor.php @@ -119,12 +119,12 @@ class Froxlor extends \Froxlor\Api\ApiCommand $this->logger()->logAction(ADM_ACTION, LOG_NOTICE, "User " . $this->getUserDetail('loginname') . " imported settings"); try { \Froxlor\SImExporter::import($json_str); - inserttask('1'); - inserttask('10'); + \Froxlor\System\Cronjob::inserttask('1'); + \Froxlor\System\Cronjob::inserttask('10'); // Using nameserver, insert a task which rebuilds the server config - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); // cron.d file - inserttask('99'); + \Froxlor\System\Cronjob::inserttask('99'); return $this->response(200, "successfull", true); } catch (\Exception $e) { throw new \Exception($e->getMessage(), 406); diff --git a/lib/Froxlor/Api/Commands/Ftps.php b/lib/Froxlor/Api/Commands/Ftps.php index 67262314..9a4ca781 100644 --- a/lib/Froxlor/Api/Commands/Ftps.php +++ b/lib/Froxlor/Api/Commands/Ftps.php @@ -183,7 +183,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit Admins::increaseUsage($customer['adminid'], 'ftps_used'); $this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_INFO, "[API] added ftp-account '" . $username . " (" . $path . ")'"); - inserttask(5); + \Froxlor\System\Cronjob::inserttask(5); if ($sendinfomail == 1) { $replace_arr = array( @@ -393,7 +393,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit } // it's the task for "new ftp" but that will // create all directories and correct their permissions - inserttask(5); + \Froxlor\System\Cronjob::inserttask(5); $stmt = Database::prepare(" UPDATE `" . TABLE_FTP_USERS . "` @@ -534,11 +534,11 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit // refs #293 if ($delete_userfiles == 1) { - inserttask('8', $customer_data['loginname'], $result['homedir']); + \Froxlor\System\Cronjob::inserttask('8', $customer_data['loginname'], $result['homedir']); } else { if (Settings::Get('system.nssextrausers') == 1) { // this is used so that the libnss-extrausers cron is fired - inserttask(5); + \Froxlor\System\Cronjob::inserttask(5); } } diff --git a/lib/Froxlor/Api/Commands/IpsAndPorts.php b/lib/Froxlor/Api/Commands/IpsAndPorts.php index c25d7820..169e9296 100644 --- a/lib/Froxlor/Api/Commands/IpsAndPorts.php +++ b/lib/Froxlor/Api/Commands/IpsAndPorts.php @@ -238,9 +238,9 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour Database::pexecute($ins_stmt, $ins_data); $ins_data['id'] = Database::lastInsertId(); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); // Using nameserver, insert a task which rebuilds the server config - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { $ip = '[' . $ip . ']'; @@ -426,9 +426,9 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour ); Database::pexecute($upd_stmt, $upd_data); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); // Using nameserver, insert a task which rebuilds the server config - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); $this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] changed IP/port from '" . $result['ip'] . ":" . $result['port'] . "' to '" . $ip . ":" . $port . "'"); @@ -499,9 +499,9 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour 'id' => $id ), true, true); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); // Using nameserver, insert a task which rebuilds the server config - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); $this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] deleted IP/port '" . $result['ip'] . ":" . $result['port'] . "'"); return $this->response(200, "successfull", $result); diff --git a/lib/Froxlor/Api/Commands/PhpSettings.php b/lib/Froxlor/Api/Commands/PhpSettings.php index 840b5eef..1070123c 100644 --- a/lib/Froxlor/Api/Commands/PhpSettings.php +++ b/lib/Froxlor/Api/Commands/PhpSettings.php @@ -333,7 +333,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour Database::pexecute($ins_stmt, $ins_data, true, true); $ins_data['id'] = Database::lastInsertId(); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); $this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] php setting with description '" . $description . "' has been created by '" . $this->getUserDetail('loginname') . "'"); $result = $this->apiCall('PhpSettings.get', array( @@ -529,7 +529,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour ); Database::pexecute($upd_stmt, $upd_data, true, true); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); $this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] php setting with description '" . $description . "' has been updated by '" . $this->getUserDetail('loginname') . "'"); $result = $this->apiCall('PhpSettings.get', array( @@ -584,7 +584,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour 'id' => $id ), true, true); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); $this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] php setting '" . $result['description'] . "' has been deleted by '" . $this->getUserDetail('loginname') . "'"); return $this->response(200, "successfull", $result); } diff --git a/lib/Froxlor/Api/Commands/SubDomains.php b/lib/Froxlor/Api/Commands/SubDomains.php index b21a53fc..c455080d 100644 --- a/lib/Froxlor/Api/Commands/SubDomains.php +++ b/lib/Froxlor/Api/Commands/SubDomains.php @@ -154,7 +154,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc if ($aliasdomain_check['id'] != $aliasdomain) { standard_error('domainisaliasorothercustomer', '', true); } - triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); + \Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); } // validate / correct path/url of domain @@ -200,7 +200,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc if ($ssl_redirect != 0) { // a ssl-redirect only works if there actually is a // ssl ip/port assigned to the domain - if (domainHasSslIpPort($domain_check['id']) == true) { + if (\Froxlor\Domain\Domain::domainHasSslIpPort($domain_check['id']) == true) { $ssl_redirect = '1'; $_doredirect = true; } else { @@ -211,7 +211,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc if ($letsencrypt != 0) { // let's encrypt only works if there actually is a // ssl ip/port assigned to the domain - if (domainHasSslIpPort($domain_check['id']) == true) { + if (\Froxlor\Domain\Domain::domainHasSslIpPort($domain_check['id']) == true) { $letsencrypt = '1'; } else { standard_error('letsencryptonlypossiblewithsslipport', '', true); @@ -304,9 +304,9 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc addRedirectToDomain($subdomain_id, $redirectcode); } - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); // Using nameserver, insert a task which rebuilds the server config - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); Customers::increaseUsage($customer['customerid'], 'subdomains_used'); Admins::increaseUsage(($this->isAdmin() ? $customer['adminid'] : $this->getUserDetail('adminid')), 'subdomains_used'); @@ -510,7 +510,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc if ($aliasdomain_check['id'] != $aliasdomain) { standard_error('domainisaliasorothercustomer', '', true); } - triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); + \Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); } // validate / correct path/url of domain @@ -536,7 +536,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc if ($ssl_redirect != 0) { // a ssl-redirect only works if there actually is a // ssl ip/port assigned to the domain - if (domainHasSslIpPort($result['id']) == true) { + if (\Froxlor\Domain\Domain::domainHasSslIpPort($result['id']) == true) { $ssl_redirect = '1'; $_doredirect = true; } else { @@ -547,7 +547,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc if ($letsencrypt != 0) { // let's encrypt only works if there actually is a // ssl ip/port assigned to the domain - if (domainHasSslIpPort($result['id']) == true) { + if (\Froxlor\Domain\Domain::domainHasSslIpPort($result['id']) == true) { $letsencrypt = '1'; } else { standard_error('letsencryptonlypossiblewithsslipport', '', true); @@ -625,11 +625,11 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc if ($result['aliasdomain'] != $aliasdomain) { // trigger when domain id for alias destination has changed: both for old and new destination - triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $this->logger()); - triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); + \Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $this->logger()); + \Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); } elseif ($result['wwwserveralias'] != $wwwserveralias || $result['letsencrypt'] != $letsencrypt) { // or when wwwserveralias or letsencrypt was changed - triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); + \Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); } // check whether LE has been disabled, so we remove the certificate @@ -642,8 +642,8 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc ), true, true); } - inserttask('1'); - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('1'); + \Froxlor\System\Cronjob::inserttask('4'); $idna_convert = new \Froxlor\Idna\IdnaWrapper(); $this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_INFO, "[API] edited domain '" . $idna_convert->decode($result['domain']) . "'"); } @@ -776,7 +776,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc } } - triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $this->logger()); + \Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $this->logger()); // delete domain from table $stmt = Database::prepare(" @@ -823,11 +823,11 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc 'domainid' => $id ), true, true); - inserttask('1'); + \Froxlor\System\Cronjob::inserttask('1'); // Using nameserver, insert a task which rebuilds the server config - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('4'); // remove domains DNS from powerDNS if used, #581 - inserttask('11', $result['domain']); + \Froxlor\System\Cronjob::inserttask('11', $result['domain']); // reduce subdomain-usage-counter Customers::decreaseUsage($customer['customerid'], 'subdomains_used'); diff --git a/lib/Froxlor/Cron/Http/Apache.php b/lib/Froxlor/Cron/Http/Apache.php index ab063416..38601742 100644 --- a/lib/Froxlor/Cron/Http/Apache.php +++ b/lib/Froxlor/Cron/Http/Apache.php @@ -833,9 +833,9 @@ class Apache extends HttpConfigBase */ protected function getVhostFilename($domain, $ssl_vhost = false) { - if ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && ((int) $domain['ismainbutsubto'] == 0 || domainMainToSubExists($domain['ismainbutsubto']) == false)) { + if ((int) $domain['parentdomainid'] == 0 && \Froxlor\Domain\Domain::isCustomerStdSubdomain((int) $domain['id']) == false && ((int) $domain['ismainbutsubto'] == 0 || \Froxlor\Domain\Domain::domainMainToSubExists($domain['ismainbutsubto']) == false)) { $vhost_no = '35'; - } elseif ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) { + } elseif ((int) $domain['parentdomainid'] == 0 && \Froxlor\Domain\Domain::isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) { $vhost_no = '30'; } else { // number of dots in a domain specifies it's position (and depth of subdomain) starting at 29 going downwards on higher depth diff --git a/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt.php b/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt.php index 8d628e2b..96e913e7 100644 --- a/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt.php +++ b/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt.php @@ -291,7 +291,7 @@ class LetsEncrypt extends \Froxlor\Cron\FroxlorCron // If we have a change in a certificate, we need to update the webserver - configs // This is easiest done by just creating a new task ;) if ($changedetected) { - inserttask(1); + \Froxlor\System\Cronjob::inserttask(1); } // reset logger diff --git a/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt_v2.php b/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt_v2.php index a62b658c..d8af907a 100644 --- a/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt_v2.php +++ b/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt_v2.php @@ -295,7 +295,7 @@ class LetsEncrypt_v2 extends \Froxlor\Cron\FroxlorCron // If we have a change in a certificate, we need to update the webserver - configs // This is easiest done by just creating a new task ;) if ($changedetected) { - inserttask(1); + \Froxlor\System\Cronjob::inserttask(1); } // reset logger diff --git a/lib/Froxlor/Cron/Http/Lighttpd.php b/lib/Froxlor/Cron/Http/Lighttpd.php index f898fac1..ea933792 100644 --- a/lib/Froxlor/Cron/Http/Lighttpd.php +++ b/lib/Froxlor/Cron/Http/Lighttpd.php @@ -401,10 +401,10 @@ class Lighttpd extends HttpConfigBase $_inc_path = substr($_tmp_path, $_pos + 1); // maindomain - if ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && ((int) $domain['ismainbutsubto'] == 0 || domainMainToSubExists($domain['ismainbutsubto']) == false)) { + if ((int) $domain['parentdomainid'] == 0 && \Froxlor\Domain\Domain::isCustomerStdSubdomain((int) $domain['id']) == false && ((int) $domain['ismainbutsubto'] == 0 || \Froxlor\Domain\Domain::domainMainToSubExists($domain['ismainbutsubto']) == false)) { $vhost_no = '50'; } // sub-but-main-domain - elseif ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) { + elseif ((int) $domain['parentdomainid'] == 0 && \Froxlor\Domain\Domain::isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) { $vhost_no = '51'; } // subdomains else { diff --git a/lib/Froxlor/Cron/Http/Nginx.php b/lib/Froxlor/Cron/Http/Nginx.php index 2580b36a..c6483096 100644 --- a/lib/Froxlor/Cron/Http/Nginx.php +++ b/lib/Froxlor/Cron/Http/Nginx.php @@ -367,9 +367,9 @@ class Nginx extends HttpConfigBase protected function getVhostFilename($domain, $ssl_vhost = false) { - if ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && ((int) $domain['ismainbutsubto'] == 0 || domainMainToSubExists($domain['ismainbutsubto']) == false)) { + if ((int) $domain['parentdomainid'] == 0 && \Froxlor\Domain\Domain::isCustomerStdSubdomain((int) $domain['id']) == false && ((int) $domain['ismainbutsubto'] == 0 || \Froxlor\Domain\Domain::domainMainToSubExists($domain['ismainbutsubto']) == false)) { $vhost_no = '35'; - } elseif ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) { + } elseif ((int) $domain['parentdomainid'] == 0 && \Froxlor\Domain\Domain::isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) { $vhost_no = '30'; } else { // number of dots in a domain specifies it's position (and depth of subdomain) starting at 29 going downwards on higher depth diff --git a/lib/Froxlor/Cron/Http/WebserverBase.php b/lib/Froxlor/Cron/Http/WebserverBase.php index 79732f67..fa958c05 100644 --- a/lib/Froxlor/Cron/Http/WebserverBase.php +++ b/lib/Froxlor/Cron/Http/WebserverBase.php @@ -80,7 +80,7 @@ class WebserverBase // now, if the domain has an ssl ip/port assigned, get // the corresponding information from the db - if (domainHasSslIpPort($domain['id'])) { + if (\Froxlor\Domain\Domain::domainHasSslIpPort($domain['id'])) { $ssl_ip = Database::pexecute_first($ip_stmt, array( 'domainid' => $domain['id'] diff --git a/lib/Froxlor/Cron/MasterCron.php b/lib/Froxlor/Cron/MasterCron.php index 630747b0..f22f6e96 100644 --- a/lib/Froxlor/Cron/MasterCron.php +++ b/lib/Froxlor/Cron/MasterCron.php @@ -54,13 +54,13 @@ class MasterCron extends \Froxlor\Cron\FroxlorCron if (strtolower($argv[$x]) == '--force') { // really force re-generating of config-files by // inserting task 1 - inserttask('1'); - // bind (if enabled, inserttask() checks this) - inserttask('4'); + \Froxlor\System\Cronjob::inserttask('1'); + // bind (if enabled, \Froxlor\System\Cronjob::inserttask() checks this) + \Froxlor\System\Cronjob::inserttask('4'); // set quotas (if enabled) - inserttask('10'); + \Froxlor\System\Cronjob::inserttask('10'); // also regenerate cron.d-file - inserttask('99'); + \Froxlor\System\Cronjob::inserttask('99'); addToQueue($jobs_to_run, 'tasks'); } elseif (strtolower($argv[$x]) == '--debug') { define('CRON_DEBUG_FLAG', 1); diff --git a/lib/Froxlor/Cron/System/TasksCron.php b/lib/Froxlor/Cron/System/TasksCron.php index 75b8daab..e333e07f 100644 --- a/lib/Froxlor/Cron/System/TasksCron.php +++ b/lib/Froxlor/Cron/System/TasksCron.php @@ -205,7 +205,7 @@ class TasksCron extends \Froxlor\Cron\FroxlorCron // check if admin of customer has added template for new customer directories if ((int) $row['data']['store_defaultindex'] == 1) { - storeDefaultIndex($row['data']['loginname'], $userhomedir, \Froxlor\FroxlorLogger::getInstanceOf(), true); + \Froxlor\FileDir::storeDefaultIndex($row['data']['loginname'], $userhomedir, \Froxlor\FroxlorLogger::getInstanceOf(), true); } // strip of last slash of paths to have correct chown results diff --git a/lib/Froxlor/Customer/Customer.php b/lib/Froxlor/Customer/Customer.php new file mode 100644 index 00000000..26531196 --- /dev/null +++ b/lib/Froxlor/Customer/Customer.php @@ -0,0 +1,75 @@ + $customerid + )); + + if (isset($customer[$varname])) { + return $customer[$varname]; + } else { + return false; + } + } + + /** + * returns the loginname of a customer by given uid + * + * @param int $uid + * uid of customer + * + * @return string customers loginname + */ + public function getLoginNameByUid($uid = null) + { + $result_stmt = Database::prepare(" + SELECT `loginname` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `guid` = :guid + "); + $result = Database::pexecute_first($result_stmt, array( + 'guid' => $uid + )); + + if (is_array($result) && isset($result['loginname'])) { + return $result['loginname']; + } + return false; + } + + /** + * Function customerHasPerlEnabled + * + * returns true or false whether perl is + * enabled for the given customer + * + * @param + * int customer-id + * + * @return boolean + */ + public static function customerHasPerlEnabled($cid = 0) + { + if ($cid > 0) { + $result_stmt = Database::prepare(" + SELECT `perlenabled` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid` = :cid"); + Database::pexecute($result_stmt, array( + 'cid' => $cid + )); + $result = $result_stmt->fetch(\PDO::FETCH_ASSOC); + + if (is_array($result) && isset($result['perlenabled'])) { + return ($result['perlenabled'] == '1') ? true : false; + } + } + return false; + } +} diff --git a/lib/Froxlor/Domain/Domain.php b/lib/Froxlor/Domain/Domain.php new file mode 100644 index 00000000..d57495be --- /dev/null +++ b/lib/Froxlor/Domain/Domain.php @@ -0,0 +1,123 @@ + $id + )); + + if (isset($result['mainsubs']) && $result['mainsubs'] > 0) { + return true; + } + return false; + } + + /** + * check whether a subof-domain exists + * #329 + * + * @param int $id + * subof-domain-id + * + * @return boolean + */ + public static function domainMainToSubExists($id = 0) + { + $result_stmt = Database::prepare(" + SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `id` = :id"); + Database::pexecute($result_stmt, array( + 'id' => $id + )); + $result = $result_stmt->fetch(\PDO::FETCH_ASSOC); + + if (isset($result['id']) && $result['id'] > 0) { + return true; + } + return false; + } + + /** + * Check whether a given domain has an ssl-ip/port assigned + * + * @param int $domainid + * + * @return boolean + */ + public static function domainHasSslIpPort($domainid = 0) + { + $result_stmt = Database::prepare(" + SELECT `dt`.* FROM `" . TABLE_DOMAINTOIP . "` `dt`, `" . TABLE_PANEL_IPSANDPORTS . "` `iap` + WHERE `dt`.`id_ipandports` = `iap`.`id` AND `iap`.`ssl` = '1' AND `dt`.`id_domain` = :domainid;"); + Database::pexecute($result_stmt, array( + 'domainid' => $domainid + )); + $result = $result_stmt->fetch(\PDO::FETCH_ASSOC); + + if (is_array($result) && isset($result['id_ipandports'])) { + return true; + } + return false; + } + + /** + * returns true or false whether a given domain id + * is the std-subdomain of a customer + * + * @param + * int domain-id + * + * @return boolean + */ + public static function isCustomerStdSubdomain($did = 0) + { + if ($did > 0) { + $result_stmt = Database::prepare(" + SELECT `customerid` FROM `" . TABLE_PANEL_CUSTOMERS . "` + WHERE `standardsubdomain` = :did + "); + $result = Database::pexecute_first($result_stmt, array( + 'did' => $did + )); + + if (is_array($result) && isset($result['customerid']) && $result['customerid'] > 0) { + return true; + } + } + return false; + } + + public static function triggerLetsEncryptCSRForAliasDestinationDomain($aliasDestinationDomainID, $log) + { + if (isset($aliasDestinationDomainID) && $aliasDestinationDomainID > 0) { + $log->logAction(ADM_ACTION, LOG_INFO, "LetsEncrypt CSR triggered for domain ID " . $aliasDestinationDomainID); + $upd_stmt = Database::prepare("UPDATE + `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` + SET + `expirationdate` = null + WHERE + domainid = :domainid + "); + Database::pexecute($upd_stmt, array( + 'domainid' => $aliasDestinationDomainID + )); + } + } +} \ No newline at end of file diff --git a/lib/Froxlor/Domain/IpAddr.php b/lib/Froxlor/Domain/IpAddr.php new file mode 100644 index 00000000..2037970f --- /dev/null +++ b/lib/Froxlor/Domain/IpAddr.php @@ -0,0 +1,83 @@ +fetch(\PDO::FETCH_ASSOC)) { + + if (! isset($system_ipaddress_array[$row['ip']]) && ! in_array($row['ip'], $system_ipaddress_array)) { + if (filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + $row['ip'] = '[' . $row['ip'] . ']'; + } + $system_ipaddress_array[$row['ip']] = $row['ip']; + } + } + + return $system_ipaddress_array; + } + + public static function getIpPortCombinations($ssl = false) + { + global $userinfo; + + $additional_conditions_params = array(); + $additional_conditions_array = array(); + + if ($userinfo['ip'] != '-1') { + $admin_ip_stmt = Database::prepare(" + SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = IN (:ipid) + "); + $myips = implode(",", json_decode($userinfo['ip'], true)); + Database::pexecute($admin_ip_stmt, array( + 'ipid' => $myips + )); + $additional_conditions_array[] = "`ip` IN (:adminips)"; + $additional_conditions_params['adminips'] = $myips; + } + + if ($ssl !== null) { + $additional_conditions_array[] = "`ssl` = :ssl"; + $additional_conditions_params['ssl'] = ($ssl === true ? '1' : '0'); + } + + $additional_conditions = ''; + if (count($additional_conditions_array) > 0) { + $additional_conditions = " WHERE " . implode(" AND ", $additional_conditions_array) . " "; + } + + $result_stmt = Database::prepare(" + SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . $additional_conditions . " ORDER BY `ip` ASC, `port` ASC + "); + + Database::pexecute($result_stmt, $additional_conditions_params); + $system_ipaddress_array = array(); + + while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { + if (filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + $row['ip'] = '[' . $row['ip'] . ']'; + } + $system_ipaddress_array[$row['id']] = $row['ip'] . ':' . $row['port']; + } + + return $system_ipaddress_array; + } + + public static function getSslIpPortCombinations() + { + global $lng; + return array( + '' => $lng['panel']['none_value'] + ) + self::getIpPortCombinations(true); + } +} \ No newline at end of file diff --git a/lib/Froxlor/FileDir.php b/lib/Froxlor/FileDir.php index 87ed4eb0..82da6459 100644 --- a/lib/Froxlor/FileDir.php +++ b/lib/Froxlor/FileDir.php @@ -118,11 +118,9 @@ class FileDir self::safe_exec('mkdir -p ' . escapeshellarg($sdir)); // place index if ($placeindex) { - // @fixme - $loginname = getLoginNameByUid($uid); + $loginname = \Froxlor\Customer\Customer::getLoginNameByUid($uid); if ($loginname !== false) { - // @fixme - storeDefaultIndex($loginname, $sdir, null); + self::storeDefaultIndex($loginname, $sdir, null); } } self::safe_exec('chown -R ' . (int) $uid . ':' . (int) $gid . ' ' . escapeshellarg($sdir)); @@ -318,6 +316,94 @@ class FileDir return $destination; } + /** + * Returns a valid html tag for the chosen $fieldType for paths + * + * @param + * string path The path to start searching in + * @param + * integer uid The uid which must match the found directories + * @param + * integer gid The gid which must match the found direcotries + * @param + * string value the value for the input-field + * + * @return string The html tag for the chosen $fieldType + * + * @author Martin Burchert + * @author Manuel Bernhardt + */ + public static function makePathfield($path, $uid, $gid, $value = '', $dom = false) + { + global $lng; + + $value = str_replace($path, '', $value); + $field = array(); + + // path is given without starting slash + // but dirList holds the paths with starting slash + // so we just add one here to get the correct + // default path selected, #225 + if (substr($value, 0, 1) != '/' && ! $dom) { + $value = '/' . $value; + } + + $fieldType = \Froxlor\Settings::Get('panel.pathedit'); + + if ($fieldType == 'Manual') { + + $field = array( + 'type' => 'text', + 'value' => htmlspecialchars($value) + ); + } elseif ($fieldType == 'Dropdown') { + + $dirList = self::findDirs($path, $uid, $gid); + natcasesort($dirList); + + if (sizeof($dirList) > 0) { + if (sizeof($dirList) <= 100) { + $_field = ''; + foreach ($dirList as $dir) { + if (strpos($dir, $path) === 0) { + $dir = substr($dir, strlen($path)); + // docroot cut off of current directory == empty -> directory is the docroot + if (empty($dir)) { + $dir = '/'; + } + $dir = self::makeCorrectDir($dir); + } + $_field .= makeoption($dir, $dir, $value); + } + $field = array( + 'type' => 'select', + 'value' => $_field + ); + } else { + // remove starting slash we added + // for the Dropdown, #225 + $value = substr($value, 1); + // $field = $lng['panel']['toomanydirs']; + $field = array( + 'type' => 'text', + 'value' => htmlspecialchars($value), + 'note' => $lng['panel']['toomanydirs'] + ); + } + } else { + // $field = $lng['panel']['dirsmissing']; + // $field = ''; + $field = array( + 'type' => 'hidden', + 'value' => '/', + 'note' => $lng['panel']['dirsmissing'] + ); + } + } + + return $field; + } + /** * Returns an array of found directories * @@ -333,7 +419,7 @@ class FileDir * * @return array Array of found valid paths */ - public static function findDirs($path, $uid, $gid) + private static function findDirs($path, $uid, $gid) { $_fileList = array(); $path = self::makeCorrectDir($path); diff --git a/lib/Froxlor/PhpHelper.php b/lib/Froxlor/PhpHelper.php index 3ff055d7..6c8b73b8 100644 --- a/lib/Froxlor/PhpHelper.php +++ b/lib/Froxlor/PhpHelper.php @@ -37,6 +37,34 @@ class PhpHelper } } + /** + * Function randomStr + * + * generate a pseudo-random string of bytes + * + * @param int $length + * + * @return string + */ + public static function randomStr($length) + { + if (version_compare(PHP_VERSION, '7.0.0') >= 0) { + return random_bytes($length); + } elseif (function_exists('openssl_random_pseudo_bytes')) { + return openssl_random_pseudo_bytes($length); + } else { + $pr_bits = ''; + $fp = @fopen('/dev/urandom', 'rb'); + if ($fp !== false) { + $pr_bits .= @fread($fp, $length); + @fclose($fp); + } else { + $pr_bits = substr(rand(time(), getrandmax()) . rand(time(), getrandmax()), 0, $length); + } + return $pr_bits; + } + } + /** * Return human readable sizes * @@ -46,8 +74,9 @@ class PhpHelper * maximum unit * @param string $system * 'si' for SI, 'bi' for binary prefixes - * - * @param string + * + * @param + * string */ public static function size_readable($size, $max = null, $system = 'si', $retstring = '%01.2f %s') { diff --git a/lib/Froxlor/System/Cronjob.php b/lib/Froxlor/System/Cronjob.php index 2e7d73f1..609da028 100644 --- a/lib/Froxlor/System/Cronjob.php +++ b/lib/Froxlor/System/Cronjob.php @@ -7,6 +7,105 @@ use Froxlor\Database\Database; class Cronjob { + /** + * Inserts a task into the PANEL_TASKS-Table + * + * @param + * int Type of task + * @param + * string Parameter 1 + * @param + * string Parameter 2 + * @param + * string Parameter 3 + * @author Florian Lippert + * @author Froxlor team + */ + public static function inserttask($type, $param1 = '', $param2 = '', $param3 = '', $param4 = '') + { + + // prepare the insert-statement + $ins_stmt = Database::prepare(" + INSERT INTO `" . TABLE_PANEL_TASKS . "` SET `type` = :type, `data` = :data + "); + + if ($type == '1' || $type == '3' || $type == '4' || $type == '5' || $type == '10' || $type == '99') { + // 4 = bind -> if bind disabled -> no task + if ($type == '4' && Settings::Get('system.bind_enable') == '0') { + return; + } + // 10 = quota -> if quota disabled -> no task + if ($type == '10' && Settings::Get('system.diskquota_enabled') == '0') { + return; + } + + // delete previously inserted tasks if they are the same as we only need ONE + $del_stmt = Database::prepare(" + DELETE FROM `" . TABLE_PANEL_TASKS . "` WHERE `type` = :type + "); + Database::pexecute($del_stmt, array( + 'type' => $type + )); + + // insert the new task + Database::pexecute($ins_stmt, array( + 'type' => $type, + 'data' => '' + )); + } elseif ($type == '2' && $param1 != '' && $param2 != '' && $param3 != '' && ($param4 == 0 || $param4 == 1)) { + $data = array(); + $data['loginname'] = $param1; + $data['uid'] = $param2; + $data['gid'] = $param3; + $data['store_defaultindex'] = $param4; + $data = json_encode($data); + Database::pexecute($ins_stmt, array( + 'type' => '2', + 'data' => $data + )); + } elseif ($type == '6' && $param1 != '') { + $data = array(); + $data['loginname'] = $param1; + $data = json_encode($data); + Database::pexecute($ins_stmt, array( + 'type' => '6', + 'data' => $data + )); + } elseif ($type == '7' && $param1 != '' && $param2 != '') { + $data = array(); + $data['loginname'] = $param1; + $data['email'] = $param2; + $data = json_encode($data); + Database::pexecute($ins_stmt, array( + 'type' => '7', + 'data' => $data + )); + } elseif ($type == '8' && $param1 != '' && $param2 != '') { + $data = array(); + $data['loginname'] = $param1; + $data['homedir'] = $param2; + $data = json_encode($data); + Database::pexecute($ins_stmt, array( + 'type' => '8', + 'data' => $data + )); + } elseif ($type == '11' && $param1 != '') { + $data = array(); + $data['domain'] = $param1; + $data = json_encode($data); + Database::pexecute($ins_stmt, array( + 'type' => '11', + 'data' => $data + )); + } elseif ($type == '20' && is_array($param1)) { + $data = json_encode($param1); + Database::pexecute($ins_stmt, array( + 'type' => '20', + 'data' => $data + )); + } + } + public static function getCronjobsLastRun() { global $lng; diff --git a/lib/formfields/customer/domains/formfield.domains_edit.php b/lib/formfields/customer/domains/formfield.domains_edit.php index 85e4b4b2..ef8e496a 100644 --- a/lib/formfields/customer/domains/formfield.domains_edit.php +++ b/lib/formfields/customer/domains/formfield.domains_edit.php @@ -93,7 +93,7 @@ return array( 'section_bssl' => array( 'title' => $lng['admin']['webserversettings_ssl'], 'image' => 'icons/domain_edit.png', - 'visible' => \Froxlor\Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports != '' ? (domainHasSslIpPort($result['id']) ? true : false) : false) : false, + 'visible' => \Froxlor\Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports != '' ? (\Froxlor\Domain\Domain::domainHasSslIpPort($result['id']) ? true : false) : false) : false, 'fields' => array( 'ssl_redirect' => array( 'label' => $lng['domains']['ssl_redirect']['title'], diff --git a/lib/functions/filedir/function.makePathfield.php b/lib/functions/filedir/function.makePathfield.php deleted file mode 100644 index b07a08fd..00000000 --- a/lib/functions/filedir/function.makePathfield.php +++ /dev/null @@ -1,106 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -/** - * Returns a valid html tag for the chosen $fieldType for paths - * - * @param - * string path The path to start searching in - * @param - * integer uid The uid which must match the found directories - * @param - * integer gid The gid which must match the found direcotries - * @param - * string value the value for the input-field - * - * @return string The html tag for the chosen $fieldType - * - * @author Martin Burchert - * @author Manuel Bernhardt - */ -function makePathfield($path, $uid, $gid, $value = '', $dom = false) -{ - global $lng; - - $value = str_replace($path, '', $value); - $field = array(); - - // path is given without starting slash - // but dirList holds the paths with starting slash - // so we just add one here to get the correct - // default path selected, #225 - if (substr($value, 0, 1) != '/' && ! $dom) { - $value = '/' . $value; - } - - $fieldType = \Froxlor\Settings::Get('panel.pathedit'); - - if ($fieldType == 'Manual') { - - $field = array( - 'type' => 'text', - 'value' => htmlspecialchars($value) - ); - } elseif ($fieldType == 'Dropdown') { - - $dirList = \Froxlor\FileDir::findDirs($path, $uid, $gid); - natcasesort($dirList); - - if (sizeof($dirList) > 0) { - if (sizeof($dirList) <= 100) { - $_field = ''; - foreach ($dirList as $dir) { - if (strpos($dir, $path) === 0) { - $dir = substr($dir, strlen($path)); - // docroot cut off of current directory == empty -> directory is the docroot - if (empty($dir)) { - $dir = '/'; - } - $dir = \Froxlor\FileDir::makeCorrectDir($dir); - } - $_field .= makeoption($dir, $dir, $value); - } - $field = array( - 'type' => 'select', - 'value' => $_field - ); - } else { - // remove starting slash we added - // for the Dropdown, #225 - $value = substr($value, 1); - // $field = $lng['panel']['toomanydirs']; - $field = array( - 'type' => 'text', - 'value' => htmlspecialchars($value), - 'note' => $lng['panel']['toomanydirs'] - ); - } - } else { - // $field = $lng['panel']['dirsmissing']; - // $field = ''; - $field = array( - 'type' => 'hidden', - 'value' => '/', - 'note' => $lng['panel']['dirsmissing'] - ); - } - } - - return $field; -} diff --git a/lib/functions/filedir/function.storeDefaultIndex.php b/lib/functions/filedir/function.storeDefaultIndex.php deleted file mode 100644 index 56ec8115..00000000 --- a/lib/functions/filedir/function.storeDefaultIndex.php +++ /dev/null @@ -1,72 +0,0 @@ - (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -/** - * store the default index-file in a given destination folder - * - * @param string $loginname customers loginname - * @param string $destination path where to create the file - * @param object $logger FroxlorLogger object - * @param boolean $force force creation whatever the settings say (needed for task #2, create new user) - * - * @return null - */ -function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false) { - - if ($force - || (int)\Froxlor\Settings::Get('system.store_index_file_subs') == 1 - ) { - $result_stmt = \Froxlor\Database\Database::prepare(" - SELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login` - FROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c` INNER JOIN `" . TABLE_PANEL_ADMINS . "` AS `a` - ON `c`.`adminid` = `a`.`adminid` - INNER JOIN `" . TABLE_PANEL_TEMPLATES . "` AS `t` - ON `a`.`adminid` = `t`.`adminid` - WHERE `varname` = 'index_html' AND `c`.`loginname` = :loginname"); - \Froxlor\Database\Database::pexecute($result_stmt, array('loginname' => $loginname)); - - if (\Froxlor\Database\Database::num_rows() > 0) { - - $template = $result_stmt->fetch(PDO::FETCH_ASSOC); - - $replace_arr = array( - 'SERVERNAME' => \Froxlor\Settings::Get('system.hostname'), - 'CUSTOMER' => $template['customer_login'], - 'ADMIN' => $template['admin_login'], - 'CUSTOMER_EMAIL' => $template['customer_email'], - 'ADMIN_EMAIL' => $template['admin_email'] - ); - - $htmlcontent = \Froxlor\PhpHelper::replace_variables($template['value'], $replace_arr); - $indexhtmlpath = \Froxlor\FileDir::makeCorrectFile($destination . '/index.' . \Froxlor\Settings::Get('system.index_file_extension')); - $index_html_handler = fopen($indexhtmlpath, 'w'); - fwrite($index_html_handler, $htmlcontent); - fclose($index_html_handler); - if ($logger !== null) { - $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Creating \'index.' . \Froxlor\Settings::Get('system.index_file_extension') . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath)); - } - - } else { - $destination = \Froxlor\FileDir::makeCorrectDir($destination); - if ($logger !== null) { - $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Running: cp -a ' . \Froxlor\Froxlor::getInstallDir() . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination)); - } - \Froxlor\FileDir::safe_exec('cp -a ' . \Froxlor\Froxlor::getInstallDir() . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination)); - } - } - return; -} diff --git a/lib/functions/froxlor/function.customerHasPerlEnabled.php b/lib/functions/froxlor/function.customerHasPerlEnabled.php deleted file mode 100644 index 67dec86d..00000000 --- a/lib/functions/froxlor/function.customerHasPerlEnabled.php +++ /dev/null @@ -1,44 +0,0 @@ - (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -/** - * Function customerHasPerlEnabled - * - * returns true or false whether perl is - * enabled for the given customer - * - * @param int customer-id - * - * @return boolean - */ -function customerHasPerlEnabled($cid = 0) { - - if ($cid > 0) { - $result_stmt = Database::prepare(" - SELECT `perlenabled` FROM `".TABLE_PANEL_CUSTOMERS."` WHERE `customerid` = :cid" - ); - Database::pexecute($result_stmt, array('cid' => $cid)); - $result = $result_stmt->fetch(PDO::FETCH_ASSOC); - - if (is_array($result) - && isset($result['perlenabled']) - ) { - return ($result['perlenabled'] == '1') ? true : false; - } - } - return false; -} diff --git a/lib/functions/froxlor/function.domainHasMainSubDomains.php b/lib/functions/froxlor/function.domainHasMainSubDomains.php deleted file mode 100644 index d6d162ae..00000000 --- a/lib/functions/froxlor/function.domainHasMainSubDomains.php +++ /dev/null @@ -1,64 +0,0 @@ - (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -/** - * check whether a domain has subdomains added as full-domains - * #329 - * - * @param int $id domain-id - * - * @return boolean - */ -function domainHasMainSubDomains($id = 0) { - - $result_stmt = Database::prepare(" - SELECT COUNT(`id`) as `mainsubs` FROM `".TABLE_PANEL_DOMAINS."` - WHERE `ismainbutsubto` = :id" - ); - $result = Database::pexecute_first($result_stmt, array('id' => $id)); - - if (isset($result['mainsubs']) - && $result['mainsubs'] > 0 - ) { - return true; - } - return false; -} - -/** - * check whether a subof-domain exists - * #329 - * - * @param int $id subof-domain-id - * - * @return boolean - */ -function domainMainToSubExists($id = 0) { - - $result_stmt = Database::prepare(" - SELECT `id` FROM `".TABLE_PANEL_DOMAINS."` WHERE `id` = :id" - ); - Database::pexecute($result_stmt, array('id' => $id)); - $result = $result_stmt->fetch(PDO::FETCH_ASSOC); - - if (isset($result['id']) - && $result['id'] > 0 - ) { - return true; - } - return false; -} diff --git a/lib/functions/froxlor/function.domainHasSslIpPort.php b/lib/functions/froxlor/function.domainHasSslIpPort.php deleted file mode 100644 index 790af7cd..00000000 --- a/lib/functions/froxlor/function.domainHasSslIpPort.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Cron - * - * @since 0.9.29.1-dev1 - * - */ - -/** - * Check whether a given domain has an ssl-ip/port assigned - * - * @param int $domainid - * - * @return boolean - */ -function domainHasSslIpPort($domainid = 0) { - - $result_stmt = Database::prepare(" - SELECT `dt`.* FROM `".TABLE_DOMAINTOIP."` `dt`, `".TABLE_PANEL_IPSANDPORTS."` `iap` - WHERE `dt`.`id_ipandports` = `iap`.`id` AND `iap`.`ssl` = '1' AND `dt`.`id_domain` = :domainid;" - ); - Database::pexecute($result_stmt, array('domainid' => $domainid)); - $result = $result_stmt->fetch(PDO::FETCH_ASSOC); - - if (is_array($result) - && isset($result['id_ipandports']) - ) { - return true; - } - return false; -} diff --git a/lib/functions/froxlor/function.getCustomerDetail.php b/lib/functions/froxlor/function.getCustomerDetail.php deleted file mode 100644 index a07163e4..00000000 --- a/lib/functions/froxlor/function.getCustomerDetail.php +++ /dev/null @@ -1,32 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -function getCustomerDetail($customerid, $varname) { - - $customer_stmt = Database::prepare(" - SELECT `" . $varname . "` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid` = :customerid - "); - $customer = Database::pexecute_first($customer_stmt, array('customerid' => $customerid)); - - if (isset($customer[$varname])) { - return $customer[$varname]; - } else { - return false; - } -} diff --git a/lib/functions/froxlor/function.getIpAddresses.php b/lib/functions/froxlor/function.getIpAddresses.php deleted file mode 100644 index 5148fe0f..00000000 --- a/lib/functions/froxlor/function.getIpAddresses.php +++ /dev/null @@ -1,41 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -function getIpAddresses() { - - $result_stmt = Database::query(" - SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` ORDER BY `ip` ASC, `port` ASC - "); - - $system_ipaddress_array = array(); - - while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { - - if (!isset($system_ipaddress_array[$row['ip']]) - && !in_array($row['ip'], $system_ipaddress_array) - ) { - if (filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { - $row['ip'] = '[' . $row['ip'] . ']'; - } - $system_ipaddress_array[$row['ip']] = $row['ip']; - } - } - - return $system_ipaddress_array; -} diff --git a/lib/functions/froxlor/function.getIpPortCombinations.php b/lib/functions/froxlor/function.getIpPortCombinations.php deleted file mode 100644 index b0a2346f..00000000 --- a/lib/functions/froxlor/function.getIpPortCombinations.php +++ /dev/null @@ -1,68 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -function getIpPortCombinations($ssl = false) { - - global $userinfo; - - $additional_conditions_params = array(); - $additional_conditions_array = array(); - - if ($userinfo['ip'] != '-1') { - $admin_ip_stmt = Database::prepare(" - SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = IN (:ipid) - "); - $myips = implode(",", json_decode($userinfo['ip'], true)); - Database::pexecute($admin_ip_stmt, array('ipid' => $myips)); - $additional_conditions_array[] = "`ip` IN (:adminips)"; - $additional_conditions_params['adminips'] = $myips; - } - - if ($ssl !== null) { - $additional_conditions_array[] = "`ssl` = :ssl"; - $additional_conditions_params['ssl'] = ($ssl === true ? '1' : '0' ); - } - - $additional_conditions = ''; - if (count($additional_conditions_array) > 0) { - $additional_conditions = " WHERE " . implode(" AND ", $additional_conditions_array) . " "; - } - - $result_stmt = Database::prepare(" - SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . - $additional_conditions . " ORDER BY `ip` ASC, `port` ASC - "); - - Database::pexecute($result_stmt, $additional_conditions_params); - $system_ipaddress_array = array(); - - while($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { - if (filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { - $row['ip'] = '[' . $row['ip'] . ']'; - } - $system_ipaddress_array[$row['id']] = $row['ip'] . ':' . $row['port']; - } - - return $system_ipaddress_array; -} - -function getSslIpPortCombinations() { - global $lng; - return array('' => $lng['panel']['none_value']) + getIpPortCombinations(true); -} diff --git a/lib/functions/froxlor/function.getLoginNameByUid.php b/lib/functions/froxlor/function.getLoginNameByUid.php deleted file mode 100644 index 3292064f..00000000 --- a/lib/functions/froxlor/function.getLoginNameByUid.php +++ /dev/null @@ -1,23 +0,0 @@ - $uid)); - - if (is_array($result) - && isset($result['loginname']) - ) { - return $result['loginname']; - } - return false; -} diff --git a/lib/functions/froxlor/function.inserttask.php b/lib/functions/froxlor/function.inserttask.php deleted file mode 100644 index 06b06e6d..00000000 --- a/lib/functions/froxlor/function.inserttask.php +++ /dev/null @@ -1,117 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -/** - * Inserts a task into the PANEL_TASKS-Table - * - * @param - * int Type of task - * @param - * string Parameter 1 - * @param - * string Parameter 2 - * @param - * string Parameter 3 - * @author Florian Lippert - * @author Froxlor team - */ -function inserttask($type, $param1 = '', $param2 = '', $param3 = '', $param4 = '') -{ - - // prepare the insert-statement - $ins_stmt = Database::prepare(" - INSERT INTO `" . TABLE_PANEL_TASKS . "` SET `type` = :type, `data` = :data - "); - - if ($type == '1' || $type == '3' || $type == '4' || $type == '5' || $type == '10' || $type == '99') { - // 4 = bind -> if bind disabled -> no task - if ($type == '4' && Settings::Get('system.bind_enable') == '0') { - return; - } - // 10 = quota -> if quota disabled -> no task - if ($type == '10' && Settings::Get('system.diskquota_enabled') == '0') { - return; - } - - // delete previously inserted tasks if they are the same as we only need ONE - $del_stmt = Database::prepare(" - DELETE FROM `" . TABLE_PANEL_TASKS . "` WHERE `type` = :type - "); - Database::pexecute($del_stmt, array( - 'type' => $type - )); - - // insert the new task - Database::pexecute($ins_stmt, array( - 'type' => $type, - 'data' => '' - )); - } elseif ($type == '2' && $param1 != '' && $param2 != '' && $param3 != '' && ($param4 == 0 || $param4 == 1)) { - $data = array(); - $data['loginname'] = $param1; - $data['uid'] = $param2; - $data['gid'] = $param3; - $data['store_defaultindex'] = $param4; - $data = json_encode($data); - Database::pexecute($ins_stmt, array( - 'type' => '2', - 'data' => $data - )); - } elseif ($type == '6' && $param1 != '') { - $data = array(); - $data['loginname'] = $param1; - $data = json_encode($data); - Database::pexecute($ins_stmt, array( - 'type' => '6', - 'data' => $data - )); - } elseif ($type == '7' && $param1 != '' && $param2 != '') { - $data = array(); - $data['loginname'] = $param1; - $data['email'] = $param2; - $data = json_encode($data); - Database::pexecute($ins_stmt, array( - 'type' => '7', - 'data' => $data - )); - } elseif ($type == '8' && $param1 != '' && $param2 != '') { - $data = array(); - $data['loginname'] = $param1; - $data['homedir'] = $param2; - $data = json_encode($data); - Database::pexecute($ins_stmt, array( - 'type' => '8', - 'data' => $data - )); - } elseif ($type == '11' && $param1 != '') { - $data = array(); - $data['domain'] = $param1; - $data = json_encode($data); - Database::pexecute($ins_stmt, array( - 'type' => '11', - 'data' => $data - )); - } elseif ($type == '20' && is_array($param1)) { - $data = json_encode($param1); - Database::pexecute($ins_stmt, array( - 'type' => '20', - 'data' => $data - )); - } -} diff --git a/lib/functions/froxlor/function.isCustomerStdSubdomain.php b/lib/functions/froxlor/function.isCustomerStdSubdomain.php deleted file mode 100644 index 9791d715..00000000 --- a/lib/functions/froxlor/function.isCustomerStdSubdomain.php +++ /dev/null @@ -1,43 +0,0 @@ - (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -/** - * returns true or false whether a given domain id - * is the std-subdomain of a customer - * - * @param int domain-id - * - * @return boolean - */ -function isCustomerStdSubdomain($did = 0) { - - if ($did > 0) { - $result_stmt = Database::prepare(" - SELECT `customerid` FROM `".TABLE_PANEL_CUSTOMERS."` - WHERE `standardsubdomain` = :did - "); - $result = Database::pexecute_first($result_stmt, array('did' => $did)); - - if (is_array($result) - && isset($result['customerid']) - && $result['customerid'] > 0 - ) { - return true; - } - } - return false; -} diff --git a/lib/functions/froxlor/function.triggerLetsEncryptCSRForAliasDestinationDomain.php b/lib/functions/froxlor/function.triggerLetsEncryptCSRForAliasDestinationDomain.php deleted file mode 100644 index cda8ac98..00000000 --- a/lib/functions/froxlor/function.triggerLetsEncryptCSRForAliasDestinationDomain.php +++ /dev/null @@ -1,34 +0,0 @@ - (2016-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -function triggerLetsEncryptCSRForAliasDestinationDomain($aliasDestinationDomainID, $log) -{ - if (isset($aliasDestinationDomainID) && $aliasDestinationDomainID > 0) { - $log->logAction(ADM_ACTION, LOG_INFO, "LetsEncrypt CSR triggered for domain ID " . $aliasDestinationDomainID); - $upd_stmt = Database::prepare( - "UPDATE - `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` - SET - `expirationdate` = null - WHERE - domainid = :domainid - "); - Database::pexecute($upd_stmt, array( - 'domainid' => $aliasDestinationDomainID - )); - } -} diff --git a/lib/functions/system/function.randomStr.php b/lib/functions/system/function.randomStr.php index 1278a378..ef256201 100644 --- a/lib/functions/system/function.randomStr.php +++ b/lib/functions/system/function.randomStr.php @@ -15,30 +15,3 @@ * */ -/** - * Function randomStr - * - * generate a pseudo-random string of bytes - * - * @param int $length - * - * @return string - */ -function randomStr($length) -{ - if (version_compare(PHP_VERSION, '7.0.0') >= 0) { - return random_bytes($length); - } elseif (function_exists('openssl_random_pseudo_bytes')) { - return openssl_random_pseudo_bytes($length); - } else { - $pr_bits = ''; - $fp = @fopen('/dev/urandom', 'rb'); - if ($fp !== false) { - $pr_bits .= @fread($fp, $length); - @fclose($fp); - } else { - $pr_bits = substr(rand(time(), getrandmax()).rand(time(), getrandmax()), 0, $length); - } - return $pr_bits; - } -}