get rid of more functions

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-20 12:38:18 +01:00
parent f263175802
commit 5888927239
53 changed files with 639 additions and 858 deletions

View File

@@ -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',
),

View File

@@ -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(

View File

@@ -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'

View File

@@ -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;

View File

@@ -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 = '';

View File

@@ -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');
}
}

View File

@@ -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 = '';

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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;
}
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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');

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 {

View File

@@ -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

View File

@@ -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']

View File

@@ -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);

View File

@@ -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

View File

@@ -0,0 +1,75 @@
<?php
namespace Froxlor\Customer;
use Froxlor\Database\Database;
class Customer
{
public static 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;
}
}
/**
* 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;
}
}

View File

@@ -0,0 +1,123 @@
<?php
namespace Froxlor\Domain;
use Froxlor\Database\Database;
class Domain
{
/**
* check whether a domain has subdomains added as full-domains
* #329
*
* @param int $id
* domain-id
*
* @return boolean
*/
public static 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
*/
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
));
}
}
}

View File

@@ -0,0 +1,83 @@
<?php
namespace Froxlor\Domain;
use Froxlor\Database\Database;
class IpAddr
{
public static 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;
}
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);
}
}

View File

@@ -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 <martin.burchert@syscp.de>
* @author Manuel Bernhardt <manuel.bernhardt@syscp.de>
*/
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 = '<input type="hidden" name="path" value="/" />';
$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);

View File

@@ -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')
{

View File

@@ -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 <flo@syscp.org>
* @author Froxlor team <team@froxlor.org>
*/
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;

View File

@@ -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'],

View File

@@ -1,106 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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 <martin.burchert@syscp.de>
* @author Manuel Bernhardt <manuel.bernhardt@syscp.de>
*/
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 = '<input type="hidden" name="path" value="/" />';
$field = array(
'type' => 'hidden',
'value' => '/',
'note' => $lng['panel']['dirsmissing']
);
}
}
return $field;
}

View File

@@ -1,72 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,44 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,64 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,43 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2013 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,32 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}
}

View File

@@ -1,41 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,68 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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);
}

View File

@@ -1,23 +0,0 @@
<?php
/**
* returns the loginname of a customer by given uid
*
* @param int $uid uid of customer
*
* @return string customers loginname
*/
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;
}

View File

@@ -1,117 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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 <flo@syscp.org>
* @author Froxlor team <team@froxlor.org>
*/
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
));
}
}

View File

@@ -1,43 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,34 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Daniel Reichelt <hacking@nachtgeist.net> (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
));
}
}

View File

@@ -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;
}
}