From a014b5cc2b8fcc8af8d628ecfef5376ba6ab7c04 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Mon, 11 Apr 2016 09:19:43 +0200 Subject: [PATCH] minor preparations for system-hostname as 'normal' domain (to use ssl/LE/etc.) Signed-off-by: Michael Kaufmann (d00p) --- admin_domains.php | 995 +++++++++--------- .../Sparkle/admin/domains/domains_domain.tpl | 21 +- templates/Sparkle/assets/css/main.css | 20 +- 3 files changed, 547 insertions(+), 489 deletions(-) diff --git a/admin_domains.php b/admin_domains.php index 1ff3ea25..479e1bc5 100644 --- a/admin_domains.php +++ b/admin_domains.php @@ -16,29 +16,25 @@ * @package Panel * */ - define('AREA', 'admin'); require './lib/init.php'; if (isset($_POST['id'])) { $id = intval($_POST['id']); -} elseif(isset($_GET['id'])) { +} elseif (isset($_GET['id'])) { $id = intval($_GET['id']); } -if ($page == 'domains' - || $page == 'overview' -) { +if ($page == 'domains' || $page == 'overview') { // Let's see how many customers we have $stmt = Database::prepare(" - SELECT COUNT(`customerid`) as `countcustomers` FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid") - ); + SELECT COUNT(`customerid`) as `countcustomers` FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid")); $params = array(); if ($userinfo['customers_see_all'] == '0') { $params['adminid'] = $userinfo['adminid']; } $countcustomers = Database::pexecute_first($stmt, $params); - $countcustomers = (int)$countcustomers['countcustomers']; + $countcustomers = (int) $countcustomers['countcustomers']; if ($action == '') { @@ -52,16 +48,18 @@ if ($page == 'domains' 'd.aliasdomain' => $lng['domains']['aliasdomain'] ); $paging = new paging($userinfo, TABLE_PANEL_DOMAINS, $fields); - $domains = ''; + $domains = ""; + $syshostname = ""; + if (Settings::Get('system.hostname_id')) + { + $syshostname = "AND `d`.`id` <> " . Settings::Get('system.hostname_id'); + } $result_stmt = Database::prepare(" SELECT `d`.*, `c`.`loginname`, `c`.`name`, `c`.`firstname`, `c`.`company`, `c`.`standardsubdomain`, `ad`.`id` AS `aliasdomainid`, `ad`.`domain` AS `aliasdomain` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `ad` ON `d`.`aliasdomain`=`ad`.`id` - WHERE `d`.`parentdomainid`='0' " . - ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid ") . - " " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit() - ); + WHERE `d`.`parentdomainid`='0' " . $syshostname . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid ") . " " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit()); $params = array(); if ($userinfo['customers_see_all'] == '0') { $params['adminid'] = $userinfo['adminid']; @@ -77,54 +75,16 @@ if ($page == 'domains' while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { - $row['domain'] = $idna_convert->decode($row['domain']); - $row['aliasdomain'] = $idna_convert->decode($row['aliasdomain']); + formatDomainEntry($row, $idna_convert); - $resultips_stmt = Database::prepare(" - SELECT `ips`.* FROM `".TABLE_DOMAINTOIP . "` AS `dti`, `".TABLE_PANEL_IPSANDPORTS."` AS `ips` - WHERE `dti`.`id_ipandports` = `ips`.`id` AND `dti`.`id_domain` = :domainid" - ); - Database::pexecute($resultips_stmt, array('domainid' => $row['id'])); - - $row['ipandport'] = ''; - while ($rowip = $resultips_stmt->fetch(PDO::FETCH_ASSOC)) { - - if (filter_var($rowip['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { - $row['ipandport'] .= '[' . $rowip['ip'] . ']:' . $rowip['port'] . "\n"; - } else { - $row['ipandport'] .= $rowip['ip'] . ':' . $rowip['port'] . "\n"; - } - } - $row['ipandport'] = substr($row['ipandport'], 0, -1); - $row['termination_date'] = str_replace("0000-00-00", "", $row['termination_date']); - - if($row['termination_date'] != "") - { - $cdate = strtotime($row['termination_date'] . " 23:59:59"); - $today = time(); - - if($cdate < $today) - { - $row['termination_css'] = 'domain-expired'; - } - else - { - $row['termination_css'] = 'domain-canceled'; - } - } - - if (!isset($domain_array[$row['domain']])) { + if (! isset($domain_array[$row['domain']])) { $domain_array[$row['domain']] = $row; } else { $domain_array[$row['domain']] = array_merge($row, $domain_array[$row['domain']]); } - if (isset($row['aliasdomainid']) - && $row['aliasdomainid'] != null - && isset($row['aliasdomain']) - && $row['aliasdomain'] != '' - ) { - if (!isset($domain_array[$row['aliasdomain']])) { + if (isset($row['aliasdomainid']) && $row['aliasdomainid'] != null && isset($row['aliasdomain']) && $row['aliasdomain'] != '') { + if (! isset($domain_array[$row['aliasdomain']])) { $domain_array[$row['aliasdomain']] = array(); } $domain_array[$row['aliasdomain']]['domainaliasid'] = $row['id']; @@ -135,49 +95,54 @@ if ($page == 'domains' /** * We need ksort/krsort here to make sure idna-domains are also sorted correctly */ - if ($paging->sortfield == 'd.domain' - && $paging->sortorder == 'asc' - ) { + if ($paging->sortfield == 'd.domain' && $paging->sortorder == 'asc') { ksort($domain_array); - } elseif ($paging->sortfield == 'd.domain' - && $paging->sortorder == 'desc' - ) { + } elseif ($paging->sortfield == 'd.domain' && $paging->sortorder == 'desc') { krsort($domain_array); } + // show froxlor hostname as first entry + if (Settings::Get('system.hostname_id')) + { + $syshost_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `id` = :did"); + $row = Database::pexecute_first($syshost_stmt, array( + 'did' => Settings::Get('system.hostname_id') + )); + formatDomainEntry($row, $idna_convert); + $row['customername'] = 'Froxlor hostname'; + $row['loginname'] = null; + $row['termination_css'] = 'domain-hostname'; + $row['ipandport'] = str_replace("\n", "
", $row['ipandport']); + eval("\$domains.=\"" . getTemplate("domains/domains_domain") . "\";"); + } + $i = 0; $count = 0; foreach ($domain_array as $row) { - if (isset($row['domain']) - && $row['domain'] != '' - && $paging->checkDisplay($i) - ) { + if (isset($row['domain']) && $row['domain'] != '' && $paging->checkDisplay($i)) { $row['customername'] = getCorrectFullUserDetails($row); $row = htmlentities_array($row); // display a nice list of IP's $row['ipandport'] = str_replace("\n", "
", $row['ipandport']); eval("\$domains.=\"" . getTemplate("domains/domains_domain") . "\";"); - $count++; + $count ++; } - $i++; + $i ++; } $domainscount = $numrows_domains; // Display the list eval("echo \"" . getTemplate("domains/domains") . "\";"); - - } elseif($action == 'delete' - && $id != 0 - ) { + } elseif ($action == 'delete' && $id != 0) { $result_stmt = Database::prepare(" SELECT `d`.* FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` - WHERE `d`.`id` = :id AND `d`.`id` <> `c`.`standardsubdomain`" . - ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") + WHERE `d`.`id` = :id AND `d`.`id` <> `c`.`standardsubdomain`" . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid")); + $params = array( + 'id' => $id ); - $params = array('id' => $id); if ($userinfo['customers_see_all'] == '0') { $params['adminid'] = $userinfo['adminid']; } @@ -185,16 +150,13 @@ if ($page == 'domains' $alias_check_stmt = Database::prepare(" SELECT COUNT(`id`) AS `count` FROM `" . TABLE_PANEL_DOMAINS . "` - WHERE `aliasdomain`= :id" - ); - $alias_check = Database::pexecute_first($alias_check_stmt, array('id' => $id)); + WHERE `aliasdomain`= :id"); + $alias_check = Database::pexecute_first($alias_check_stmt, array( + 'id' => $id + )); - if ($result['domain'] != '' - && $alias_check['count'] == 0 - ) { - if (isset($_POST['send']) - && $_POST['send'] == 'send' - ) { + if ($result['domain'] != '' && $alias_check['count'] == 0) { + if (isset($_POST['send']) && $_POST['send'] == 'send') { // check for deletion of main-domains which are logically subdomains, #329 $rsd_sql = ''; $remove_subbutmain_domains = isset($_POST['delete_userfiles']) ? 1 : 0; @@ -204,76 +166,84 @@ if ($page == 'domains' $subresult_stmt = Database::prepare(" SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` - WHERE (`id` = :id OR `parentdomainid` = :id ".$rsd_sql.") AND `isemaildomain` = '1'" - ); - Database::pexecute($subresult_stmt, array('id' => $id)); + WHERE (`id` = :id OR `parentdomainid` = :id " . $rsd_sql . ") AND `isemaildomain` = '1'"); + Database::pexecute($subresult_stmt, array( + 'id' => $id + )); $idString = array(); $paramString = array(); while ($subRow = $subresult_stmt->fetch(PDO::FETCH_ASSOC)) { - $idString[] = "`domainid` = :domain_" . (int)$subRow['id']; - $paramString['domain_'.$subRow['id']] = $subRow['id']; + $idString[] = "`domainid` = :domain_" . (int) $subRow['id']; + $paramString['domain_' . $subRow['id']] = $subRow['id']; } $idString = implode(' OR ', $idString); if ($idString != '') { $del_stmt = Database::prepare(" - DELETE FROM `" . TABLE_MAIL_USERS . "` WHERE " . $idString - ); + DELETE FROM `" . TABLE_MAIL_USERS . "` WHERE " . $idString); Database::pexecute($del_stmt, $paramString); $del_stmt = Database::prepare(" - DELETE FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE " . $idString - ); + DELETE FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE " . $idString); Database::pexecute($del_stmt, $paramString); $log->logAction(ADM_ACTION, LOG_NOTICE, "deleted domain/s from mail-tables"); } $del_stmt = Database::prepare(" DELETE FROM `" . TABLE_PANEL_DOMAINS . "` - WHERE `id` = :id OR `parentdomainid` = :id ".$rsd_sql - ); - Database::pexecute($del_stmt, array('id' => $id)); + WHERE `id` = :id OR `parentdomainid` = :id " . $rsd_sql); + Database::pexecute($del_stmt, array( + 'id' => $id + )); $deleted_domains = $del_stmt->rowCount(); $upd_stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `subdomains_used` = `subdomains_used` - :domaincount - WHERE `customerid` = :customerid" - ); - Database::pexecute($upd_stmt, array('domaincount' => ($deleted_domains -1), 'customerid' => $result['customerid'])); + WHERE `customerid` = :customerid"); + Database::pexecute($upd_stmt, array( + 'domaincount' => ($deleted_domains - 1), + 'customerid' => $result['customerid'] + )); $upd_stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_ADMINS . "` SET `domains_used` = `domains_used` - 1 - WHERE `adminid` = :adminid" - ); - Database::pexecute($upd_stmt, array('adminid' => $userinfo['adminid'])); + WHERE `adminid` = :adminid"); + Database::pexecute($upd_stmt, array( + 'adminid' => $userinfo['adminid'] + )); $upd_stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `standardsubdomain` = '0' - WHERE `standardsubdomain` = :id AND `customerid` = :customerid" - ); - Database::pexecute($upd_stmt, array('id' => $result['id'], 'customerid' => $result['customerid'])); + WHERE `standardsubdomain` = :id AND `customerid` = :customerid"); + Database::pexecute($upd_stmt, array( + 'id' => $result['id'], + 'customerid' => $result['customerid'] + )); $del_stmt = Database::prepare(" DELETE FROM `" . TABLE_DOMAINTOIP . "` - WHERE `id_domain` = :domainid" - ); - Database::pexecute($del_stmt, array('domainid' => $id)); + WHERE `id_domain` = :domainid"); + Database::pexecute($del_stmt, array( + 'domainid' => $id + )); $del_stmt = Database::prepare(" DELETE FROM `" . TABLE_PANEL_DOMAINREDIRECTS . "` - WHERE `did` = :domainid" - ); - Database::pexecute($del_stmt, array('domainid' => $id)); + WHERE `did` = :domainid"); + Database::pexecute($del_stmt, array( + 'domainid' => $id + )); // remove certificate from domain_ssl_settings, fixes #1596 $del_stmt = Database::prepare(" DELETE FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` - WHERE `domainid` = :domainid" - ); - Database::pexecute($del_stmt, array('domainid' => $id)); + WHERE `domainid` = :domainid"); + Database::pexecute($del_stmt, array( + 'domainid' => $id + )); $log->logAction(ADM_ACTION, LOG_INFO, "deleted domain/subdomains (#" . $result['id'] . ")"); updateCounters(); @@ -282,35 +252,38 @@ if ($page == 'domains' // Using nameserver, insert a task which rebuilds the server config inserttask('4'); - redirectTo($filename, array('page' => $page, 's' => $s)); - + redirectTo($filename, array( + 'page' => $page, + 's' => $s + )); } elseif ($alias_check['count'] > 0) { standard_error('domains_cantdeletedomainwithaliases'); - } else { $showcheck = false; if (domainHasMainSubDomains($id)) { $showcheck = true; } - ask_yesno_withcheckbox('admin_domain_reallydelete', 'remove_subbutmain_domains', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $idna_convert->decode($result['domain']), $showcheck); + ask_yesno_withcheckbox('admin_domain_reallydelete', 'remove_subbutmain_domains', $filename, array( + 'id' => $id, + 'page' => $page, + 'action' => $action + ), $idna_convert->decode($result['domain']), $showcheck); } } + } elseif ($action == 'add') { - } elseif($action == 'add') { - - if ($userinfo['domains_used'] < $userinfo['domains'] - || $userinfo['domains'] == '-1' - ) { - if (isset($_POST['send']) - && $_POST['send'] == 'send' - ) { + if ($userinfo['domains_used'] < $userinfo['domains'] || $userinfo['domains'] == '-1') { + if (isset($_POST['send']) && $_POST['send'] == 'send') { if ($_POST['domain'] == Settings::Get('system.hostname')) { standard_error('admin_domain_emailsystemhostname'); } - $domain = $idna_convert->encode(preg_replace(array('/\:(\d)+$/', '/^https?\:\/\//'), '', validate($_POST['domain'], 'domain'))); + $domain = $idna_convert->encode(preg_replace(array( + '/\:(\d)+$/', + '/^https?\:\/\//' + ), '', validate($_POST['domain'], 'domain'))); $subcanemaildomain = intval($_POST['subcanemaildomain']); $isemaildomain = 0; @@ -338,18 +311,16 @@ if ($page == 'domains' $customerid = intval($_POST['customerid']); $customer_stmt = Database::prepare(" SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` - WHERE `customerid` = :customerid " . - ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid") + WHERE `customerid` = :customerid " . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid")); + $params = array( + 'customerid' => $customerid ); - $params = array('customerid' => $customerid); if ($userinfo['customers_see_all'] == '0') { $params['adminid'] = $userinfo['adminid']; } $customer = Database::pexecute_first($customer_stmt, $params); - if (empty($customer) - || $customer['customerid'] != $customerid - ) { + if (empty($customer) || $customer['customerid'] != $customerid) { standard_error('customerdoesntexist'); } @@ -358,16 +329,14 @@ if ($page == 'domains' $adminid = intval($_POST['adminid']); $admin_stmt = Database::prepare(" SELECT * FROM `" . TABLE_PANEL_ADMINS . "` - WHERE `adminid` = :adminid AND (`domains_used` < `domains` OR `domains` = '-1')" - ); - $admin = Database::pexecute_first($admin_stmt, array('adminid' => $adminid)); + WHERE `adminid` = :adminid AND (`domains_used` < `domains` OR `domains` = '-1')"); + $admin = Database::pexecute_first($admin_stmt, array( + 'adminid' => $adminid + )); - if (empty($admin) - || $admin['adminid'] != $adminid - ) { + if (empty($admin) || $admin['adminid'] != $adminid) { standard_error('admindoesntexist'); } - } else { $adminid = $userinfo['adminid']; $admin = $userinfo; @@ -377,15 +346,23 @@ if ($page == 'domains' // need to respect the documentroot_use_default_value - setting $path_suffix = ''; if (Settings::Get('system.documentroot_use_default_value') == 1) { - $path_suffix = '/'.$domain; + $path_suffix = '/' . $domain; } $documentroot = makeCorrectDir($customer['documentroot'] . $path_suffix); $registration_date = trim($_POST['registration_date']); - $registration_date = validate($registration_date, 'registration_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array('0000-00-00', '0', '')); + $registration_date = validate($registration_date, 'registration_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array( + '0000-00-00', + '0', + '' + )); - $termination_date = trim($_POST['termination_date']); - $termination_date = validate($termination_date, 'termination_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array('0000-00-00', '0', '')); + $termination_date = trim($_POST['termination_date']); + $termination_date = validate($termination_date, 'termination_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array( + '0000-00-00', + '0', + '' + )); if ($userinfo['change_serversettings'] == '1') { @@ -411,23 +388,15 @@ if ($page == 'domains' // If path is empty and 'Use domain name as default value for DocumentRoot path' is enabled in settings, // set default path to subdomain or domain name - if (isset($_POST['documentroot']) - && $_POST['documentroot'] != '' - ) { - if (substr($_POST['documentroot'], 0, 1) != '/' - && !preg_match('/^https?\:\/\//', $_POST['documentroot']) - ) { - $documentroot.= '/' . $_POST['documentroot']; + if (isset($_POST['documentroot']) && $_POST['documentroot'] != '') { + if (substr($_POST['documentroot'], 0, 1) != '/' && ! preg_match('/^https?\:\/\//', $_POST['documentroot'])) { + $documentroot .= '/' . $_POST['documentroot']; } else { $documentroot = $_POST['documentroot']; } - } elseif (isset($_POST['documentroot']) - && ($_POST['documentroot'] == '') - && (Settings::Get('system.documentroot_use_default_value') == 1) - ) { + } elseif (isset($_POST['documentroot']) && ($_POST['documentroot'] == '') && (Settings::Get('system.documentroot_use_default_value') == 1)) { $documentroot = makeCorrectDir($customer['documentroot'] . '/' . $domain); } - } else { $isbinddomain = '0'; if (Settings::Get('system.bind_enable') == '1') { @@ -439,40 +408,39 @@ if ($page == 'domains' $specialsettings = ''; } - if ($userinfo['caneditphpsettings'] == '1' - || $userinfo['change_serversettings'] == '1' - ) { + if ($userinfo['caneditphpsettings'] == '1' || $userinfo['change_serversettings'] == '1') { $openbasedir = isset($_POST['openbasedir']) ? intval($_POST['openbasedir']) : 0; - if ((int)Settings::Get('system.mod_fcgid') == 1 - || (int)Settings::Get('phpfpm.enabled') == 1 - ) { - $phpsettingid = (int)$_POST['phpsettingid']; + if ((int) Settings::Get('system.mod_fcgid') == 1 || (int) Settings::Get('phpfpm.enabled') == 1) { + $phpsettingid = (int) $_POST['phpsettingid']; $phpsettingid_check_stmt = Database::prepare(" SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` - WHERE `id` = :phpsettingid" - ); - $phpsettingid_check = Database::pexecute_first($phpsettingid_check_stmt, array('phpsettingid' => $phpsettingid)); + WHERE `id` = :phpsettingid"); + $phpsettingid_check = Database::pexecute_first($phpsettingid_check_stmt, array( + 'phpsettingid' => $phpsettingid + )); - if (!isset($phpsettingid_check['id']) - || $phpsettingid_check['id'] == '0' - || $phpsettingid_check['id'] != $phpsettingid - ) { + if (! isset($phpsettingid_check['id']) || $phpsettingid_check['id'] == '0' || $phpsettingid_check['id'] != $phpsettingid) { standard_error('phpsettingidwrong'); } - if ((int)Settings::Get('system.mod_fcgid') == 1) { - $mod_fcgid_starter = validate($_POST['mod_fcgid_starter'], 'mod_fcgid_starter', '/^[0-9]*$/', '', array('-1', '')); - $mod_fcgid_maxrequests = validate($_POST['mod_fcgid_maxrequests'], 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array('-1', '')); + if ((int) Settings::Get('system.mod_fcgid') == 1) { + $mod_fcgid_starter = validate($_POST['mod_fcgid_starter'], 'mod_fcgid_starter', '/^[0-9]*$/', '', array( + '-1', + '' + )); + $mod_fcgid_maxrequests = validate($_POST['mod_fcgid_maxrequests'], 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array( + '-1', + '' + )); } else { $mod_fcgid_starter = '-1'; $mod_fcgid_maxrequests = '-1'; } - } else { - if ((int)Settings::Get('phpfpm.enabled') == 1) { + if ((int) Settings::Get('phpfpm.enabled') == 1) { $phpsettingid = Settings::Get('phpfpm.defaultini'); } else { $phpsettingid = Settings::Get('system.mod_fcgid_defaultini'); @@ -480,11 +448,10 @@ if ($page == 'domains' $mod_fcgid_starter = '-1'; $mod_fcgid_maxrequests = '-1'; } - } else { $openbasedir = '1'; - if ((int)Settings::Get('phpfpm.enabled') == 1) { + if ((int) Settings::Get('phpfpm.enabled') == 1) { $phpsettingid = Settings::Get('phpfpm.defaultini'); } else { $phpsettingid = Settings::Get('system.mod_fcgid_defaultini'); @@ -496,36 +463,37 @@ if ($page == 'domains' if ($userinfo['ip'] != "-1") { $admin_ip_stmt = Database::prepare(" SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` - WHERE `id` = :id ORDER BY `ip`, `port` ASC" - ); - $admin_ip = Database::pexecute_first($admin_ip_stmt, array('id' => $userinfo['ip'])); + WHERE `id` = :id ORDER BY `ip`, `port` ASC"); + $admin_ip = Database::pexecute_first($admin_ip_stmt, array( + 'id' => $userinfo['ip'] + )); $additional_ip_condition = " AND `ip` = :adminip "; - $aip_param = array('adminip' => $admin_ip['ip']); + $aip_param = array( + 'adminip' => $admin_ip['ip'] + ); } else { $additional_ip_condition = ''; $aip_param = array(); } $ipandports = array(); - if (isset($_POST['ipandport']) && !is_array($_POST['ipandport'])) { + if (isset($_POST['ipandport']) && ! is_array($_POST['ipandport'])) { $_POST['ipandport'] = unserialize($_POST['ipandport']); } if (isset($_POST['ipandport']) && is_array($_POST['ipandport'])) { - foreach($_POST['ipandport'] as $ipandport) { + foreach ($_POST['ipandport'] as $ipandport) { $ipandport = intval($ipandport); $ipandport_check_stmt = Database::prepare(" SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` - WHERE `id` = :id " . $additional_ip_condition - ); + WHERE `id` = :id " . $additional_ip_condition); $ip_params = null; - $ip_params = array_merge(array('id' => $ipandport), $aip_param); + $ip_params = array_merge(array( + 'id' => $ipandport + ), $aip_param); $ipandport_check = Database::pexecute_first($ipandport_check_stmt, $ip_params); - if (!isset($ipandport_check['id']) - || $ipandport_check['id'] == '0' - || $ipandport_check['id'] != $ipandport - ) { + if (! isset($ipandport_check['id']) || $ipandport_check['id'] == '0' || $ipandport_check['id'] != $ipandport) { standard_error('ipportdoesntexist'); } else { $ipandports[] = $ipandport; @@ -533,43 +501,41 @@ if ($page == 'domains' } } - if (Settings::Get('system.use_ssl') == "1" - && isset($_POST['ssl_ipandport']) - ) { + if (Settings::Get('system.use_ssl') == "1" && isset($_POST['ssl_ipandport'])) { $ssl_redirect = 0; if (isset($_POST['ssl_redirect'])) { - $ssl_redirect = (int)$_POST['ssl_redirect']; + $ssl_redirect = (int) $_POST['ssl_redirect']; } $letsencrypt = 0; if (isset($_POST['letsencrypt'])) { - $letsencrypt = (int)$_POST['letsencrypt']; + $letsencrypt = (int) $_POST['letsencrypt']; } $ssl_ipandports = array(); - if (isset($_POST['ssl_ipandport']) && !is_array($_POST['ssl_ipandport'])) { + if (isset($_POST['ssl_ipandport']) && ! is_array($_POST['ssl_ipandport'])) { $_POST['ssl_ipandport'] = unserialize($_POST['ssl_ipandport']); } // Verify SSL-Ports if (isset($_POST['ssl_ipandport']) && is_array($_POST['ssl_ipandport'])) { foreach ($_POST['ssl_ipandport'] as $ssl_ipandport) { - if (trim($ssl_ipandport) == "") continue; - // fix if no ssl-ip/port is checked - if (trim($ssl_ipandport) < 1) continue; + if (trim($ssl_ipandport) == "") + continue; + // fix if no ssl-ip/port is checked + if (trim($ssl_ipandport) < 1) + continue; $ssl_ipandport = intval($ssl_ipandport); $ssl_ipandport_check_stmt = Database::prepare(" SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` - WHERE `id` = :id " . $additional_ip_condition - ); + WHERE `id` = :id " . $additional_ip_condition); $ip_params = null; - $ip_params = array_merge(array('id' => $ssl_ipandport), $aip_param); + $ip_params = array_merge(array( + 'id' => $ssl_ipandport + ), $aip_param); $ssl_ipandport_check = Database::pexecute_first($ssl_ipandport_check_stmt, $ip_params); - if (!isset($ssl_ipandport_check['id']) - || $ssl_ipandport_check['id'] == '0' - || $ssl_ipandport_check['id'] != $ssl_ipandport - ) { + if (! isset($ssl_ipandport_check['id']) || $ssl_ipandport_check['id'] == '0' || $ssl_ipandport_check['id'] != $ssl_ipandport) { standard_error('ipportdoesntexist'); } else { $ssl_ipandports[] = $ssl_ipandport; @@ -580,19 +546,19 @@ if ($page == 'domains' $letsencrypt = 0; // we need this for the serialize // if ssl is disabled or no ssl-ip/port exists - $ssl_ipandports[] = -1; + $ssl_ipandports[] = - 1; } } else { $ssl_redirect = 0; $letsencrypt = 0; // we need this for the serialize // if ssl is disabled or no ssl-ip/port exists - $ssl_ipandports[] = -1; + $ssl_ipandports[] = - 1; } // We can't enable let's encrypt for wildcard - domains if ($serveraliasoption == '0' && $letsencrypt == '1') { - standard_error('nowildcardwithletsencrypt'); + standard_error('nowildcardwithletsencrypt'); } // Temporarily deactivate ssl_redirect until Let's Encrypt certificate was generated @@ -600,7 +566,7 @@ if ($page == 'domains' $ssl_redirect = 2; } - if (!preg_match('/^https?\:\/\//', $documentroot)) { + if (! preg_match('/^https?\:\/\//', $documentroot)) { if (strstr($documentroot, ":") !== false) { standard_error('pathmaynotcontaincolon'); } else { @@ -610,9 +576,10 @@ if ($page == 'domains' $domain_check_stmt = Database::prepare(" SELECT `id`, `domain` FROM `" . TABLE_PANEL_DOMAINS . "` - WHERE `domain` = :domain" - ); - $domain_check = Database::pexecute_first($domain_check_stmt, array('domain' => strtolower($domain))); + WHERE `domain` = :domain"); + $domain_check = Database::pexecute_first($domain_check_stmt, array( + 'domain' => strtolower($domain) + )); $aliasdomain_check = array( 'id' => 0 @@ -623,13 +590,16 @@ if ($page == 'domains' $ipandports = array(); $ssl_ipandports = array(); $origipresult_stmt = Database::prepare(" - SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP ."` - WHERE `id_domain` = :id" - ); - Database::pexecute($origipresult_stmt, array('id' => $aliasdomain)); - $ipdata_stmt = Database::prepare("SELECT * FROM `".TABLE_PANEL_IPSANDPORTS."` WHERE `id` = :ipid"); + SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "` + WHERE `id_domain` = :id"); + Database::pexecute($origipresult_stmt, array( + 'id' => $aliasdomain + )); + $ipdata_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid"); while ($origip = $origipresult_stmt->fetch(PDO::FETCH_ASSOC)) { - $_origip_tmp = Database::pexecute_first($ipdata_stmt, array('ipid' => $origip['id_ipandports'])); + $_origip_tmp = Database::pexecute_first($ipdata_stmt, array( + 'ipid' => $origip['id_ipandports'] + )); if ($_origip_tmp['ssl'] == 0) { $ipandports[] = $origip['id_ipandports']; } else { @@ -640,7 +610,7 @@ if ($page == 'domains' if (count($ssl_ipandports) == 0) { // we need this for the serialize // if ssl is disabled or no ssl-ip/port exists - $ssl_ipandports[] = -1; + $ssl_ipandports[] = - 1; } $aliasdomain_check_stmt = Database::prepare(" @@ -648,9 +618,11 @@ if ($page == 'domains' WHERE `d`.`customerid` = :customerid AND `d`.`aliasdomain` IS NULL AND `d`.`id` <> `c`.`standardsubdomain` AND `c`.`customerid` = :customerid - AND `d`.`id` = :aliasdomainid" + AND `d`.`id` = :aliasdomainid"); + $alias_params = array( + 'customerid' => $customerid, + 'aliasdomainid' => $aliasdomain ); - $alias_params = array('customerid' => $customerid, 'aliasdomainid' => $aliasdomain); $aliasdomain_check = Database::pexecute_first($aliasdomain_check_stmt, $alias_params); } @@ -680,10 +652,7 @@ if ($page == 'domains' $email_only = '0'; } - if ($subcanemaildomain != '1' - && $subcanemaildomain != '2' - && $subcanemaildomain != '3' - ) { + if ($subcanemaildomain != '1' && $subcanemaildomain != '2' && $subcanemaildomain != '3') { $subcanemaildomain = '0'; } @@ -703,24 +672,31 @@ if ($page == 'domains' $issubof = '0'; } - if ($aliasdomain != 0 && $letsencrypt != 0) - { + if ($aliasdomain != 0 && $letsencrypt != 0) { standard_error('letsencryptdoesnotworkwithaliasdomains'); } if ($domain == '') { - standard_error(array('stringisempty', 'mydomain')); - } - // Check whether domain validation is enabled and if, validate the domain - elseif (Settings::Get('system.validate_domain') && !validateDomain($domain)) { - standard_error(array('stringiswrong', 'mydomain')); - } elseif($documentroot == '') { - standard_error(array('stringisempty', 'mydocumentroot')); - } elseif($customerid == 0) { + standard_error(array( + 'stringisempty', + 'mydomain' + )); + } // Check whether domain validation is enabled and if, validate the domain +elseif (Settings::Get('system.validate_domain') && ! validateDomain($domain)) { + standard_error(array( + 'stringiswrong', + 'mydomain' + )); + } elseif ($documentroot == '') { + standard_error(array( + 'stringisempty', + 'mydocumentroot' + )); + } elseif ($customerid == 0) { standard_error('adduserfirst'); - } elseif(strtolower($domain_check['domain']) == strtolower($domain)) { + } elseif (strtolower($domain_check['domain']) == strtolower($domain)) { standard_error('domainalreadyexists', $idna_convert->decode($domain)); - } elseif($aliasdomain_check['id'] != $aliasdomain) { + } elseif ($aliasdomain_check['id'] != $aliasdomain) { standard_error('domainisaliasorothercustomer'); } else { $params = array( @@ -756,20 +732,18 @@ if ($page == 'domains' $security_questions = array( 'reallydisablesecuritysetting' => ($openbasedir == '0' && $userinfo['change_serversettings'] == '1'), - 'reallydocrootoutofcustomerroot' => (substr($documentroot, 0, strlen($customer['documentroot'])) != $customer['documentroot'] && !preg_match('/^https?\:\/\//', $documentroot)) + 'reallydocrootoutofcustomerroot' => (substr($documentroot, 0, strlen($customer['documentroot'])) != $customer['documentroot'] && ! preg_match('/^https?\:\/\//', $documentroot)) ); $question_nr = 1; foreach ($security_questions as $question_name => $question_launch) { if ($question_launch !== false) { $params[$question_name] = $question_name; - if (!isset($_POST[$question_name]) - || $_POST[$question_name] != $question_name - ) { + if (! isset($_POST[$question_name]) || $_POST[$question_name] != $question_name) { ask_yesno('admin_domain_' . $question_name, $filename, $params, $question_nr); } } - $question_nr++; + $question_nr ++; } $wwwserveralias = ($serveraliasoption == '1') ? '1' : '0'; @@ -796,7 +770,7 @@ if ($page == 'domains' 'ssl_redirect' => $ssl_redirect, 'add_date' => time(), 'registration_date' => $registration_date, - 'termination_date' => $termination_date, + 'termination_date' => $termination_date, 'phpsettingid' => $phpsettingid, 'mod_fcgid_starter' => $mod_fcgid_starter, 'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests, @@ -841,9 +815,10 @@ if ($page == 'domains' $upd_stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_ADMINS . "` SET `domains_used` = `domains_used` + 1 - WHERE `adminid` = :adminid" - ); - Database::pexecute($upd_stmt, array('adminid' => $adminid)); + WHERE `adminid` = :adminid"); + Database::pexecute($upd_stmt, array( + 'adminid' => $adminid + )); $ins_stmt = Database::prepare(" INSERT INTO `" . TABLE_DOMAINTOIP . "` SET @@ -874,18 +849,17 @@ if ($page == 'domains' // Using nameserver, insert a task which rebuilds the server config inserttask('4'); - redirectTo($filename, array('page' => $page, 's' => $s)); + redirectTo($filename, array( + 'page' => $page, + 's' => $s + )); } - } else { $customers = makeoption($lng['panel']['please_choose'], 0, 0, true); $result_customers_stmt = Database::prepare(" SELECT `customerid`, `loginname`, `name`, `firstname`, `company` - FROM `" . TABLE_PANEL_CUSTOMERS . "` " . - ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int)$userinfo['adminid'] . "' ") . - " ORDER BY COALESCE(NULLIF(`name`,''), `company`) ASC" - ); + FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int) $userinfo['adminid'] . "' ") . " ORDER BY COALESCE(NULLIF(`name`,''), `company`) ASC"); $params = array(); if ($userinfo['customers_see_all'] == '0') { $params['adminid'] = $userinfo['adminid']; @@ -893,7 +867,7 @@ if ($page == 'domains' Database::pexecute($result_customers_stmt, $params); while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) { - $customers.= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']); + $customers .= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']); } $admins = ''; @@ -902,11 +876,10 @@ if ($page == 'domains' $result_admins_stmt = Database::query(" SELECT `adminid`, `loginname`, `name` FROM `" . TABLE_PANEL_ADMINS . "` - WHERE `domains_used` < `domains` OR `domains` = '-1' ORDER BY `name` ASC" - ); + WHERE `domains_used` < `domains` OR `domains` = '-1' ORDER BY `name` ASC"); while ($row_admin = $result_admins_stmt->fetch(PDO::FETCH_ASSOC)) { - $admins.= makeoption(getCorrectFullUserDetails($row_admin) . ' (' . $row_admin['loginname'] . ')', $row_admin['adminid'], $userinfo['adminid']); + $admins .= makeoption(getCorrectFullUserDetails($row_admin) . ' (' . $row_admin['loginname'] . ')', $row_admin['adminid'], $userinfo['adminid']); } } @@ -921,17 +894,23 @@ if ($page == 'domains' $admin_ip_stmt = Database::prepare(" SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid ORDER BY `ip`, `port` ASC "); - $admin_ip = Database::pexecute_first($admin_ip_stmt, array('ipid' => $userinfo['ip'])); + $admin_ip = Database::pexecute_first($admin_ip_stmt, array( + 'ipid' => $userinfo['ip'] + )); $result_ipsandports_stmt = Database::prepare(" SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='0' AND `ip` = :ipid ORDER BY `ip`, `port` ASC "); - Database::pexecute($result_ipsandports_stmt, array('ipid' => $admin_ip['ip'])); + Database::pexecute($result_ipsandports_stmt, array( + 'ipid' => $admin_ip['ip'] + )); $result_ssl_ipsandports_stmt = Database::prepare(" SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='1' AND `ip` = :ipid ORDER BY `ip`, `port` ASC "); - Database::pexecute($result_ssl_ipsandports_stmt, array('ipid' => $admin_ip['ip'])); + Database::pexecute($result_ssl_ipsandports_stmt, array( + 'ipid' => $admin_ip['ip'] + )); } // Build array holding all IPs and Ports available to this admin @@ -942,7 +921,10 @@ if ($page == 'domains' $row_ipandport['ip'] = '[' . $row_ipandport['ip'] . ']'; } - $ipsandports[] = array('label' => $row_ipandport['ip'] . ':' . $row_ipandport['port'] . '
', 'value' => $row_ipandport['id']); + $ipsandports[] = array( + 'label' => $row_ipandport['ip'] . ':' . $row_ipandport['port'] . '
', + 'value' => $row_ipandport['id'] + ); } $ssl_ipsandports = array(); @@ -952,7 +934,10 @@ if ($page == 'domains' $row_ssl_ipandport['ip'] = '[' . $row_ssl_ipandport['ip'] . ']'; } - $ssl_ipsandports[] = array('label' => $row_ssl_ipandport['ip'] . ':' . $row_ssl_ipandport['port'] . '
', 'value' => $row_ssl_ipandport['id']); + $ssl_ipsandports[] = array( + 'label' => $row_ssl_ipandport['ip'] . ':' . $row_ssl_ipandport['port'] . '
', + 'value' => $row_ssl_ipandport['id'] + ); } $standardsubdomains = array(); @@ -973,8 +958,7 @@ if ($page == 'domains' $domains = makeoption($lng['domains']['noaliasdomain'], 0, NULL, true); $result_domains_stmt = Database::prepare(" SELECT `d`.`id`, `d`.`domain`, `c`.`loginname` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` - WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = 0" . $standardsubdomains . - ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . " + WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = 0" . $standardsubdomains . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . " AND `d`.`customerid`=`c`.`customerid` ORDER BY `loginname`, `domain` ASC "); $params = array(); @@ -984,31 +968,30 @@ if ($page == 'domains' Database::pexecute($result_domains_stmt, $params); while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { - $domains.= makeoption($idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')', $row_domain['id']); + $domains .= makeoption($idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')', $row_domain['id']); } $subtodomains = makeoption($lng['domains']['nosubtomaindomain'], 0, NULL, true); $result_domains_stmt = Database::prepare(" SELECT `d`.`id`, `d`.`domain`, `c`.`loginname` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` - WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = 0 AND `d`.`ismainbutsubto` = 0 " . $standardsubdomains . - ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . " + WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = 0 AND `d`.`ismainbutsubto` = 0 " . $standardsubdomains . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . " AND `d`.`customerid`=`c`.`customerid` ORDER BY `loginname`, `domain` ASC "); // params from above still valid Database::pexecute($result_domains_stmt, $params); while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { - $subtodomains.= makeoption($idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')', $row_domain['id']); + $subtodomains .= makeoption($idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')', $row_domain['id']); } $phpconfigs = ''; $configs = Database::query("SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "`"); while ($row = $configs->fetch(PDO::FETCH_ASSOC)) { - if ((int)Settings::Get('phpfpm.enabled') == 1) { - $phpconfigs.= makeoption($row['description'], $row['id'], Settings::Get('phpfpm.defaultini'), true, true); + if ((int) Settings::Get('phpfpm.enabled') == 1) { + $phpconfigs .= makeoption($row['description'], $row['id'], Settings::Get('phpfpm.defaultini'), true, true); } else { - $phpconfigs.= makeoption($row['description'], $row['id'], Settings::Get('system.mod_fcgid_defaultini'), true, true); + $phpconfigs .= makeoption($row['description'], $row['id'], Settings::Get('system.mod_fcgid_defaultini'), true, true); } } @@ -1019,13 +1002,13 @@ if ($page == 'domains' $serveraliasoptions .= makeoption($lng['domains']['serveraliasoption_none'], '2', '0', true, true); $subcanemaildomain = makeoption($lng['admin']['subcanemaildomain']['never'], '0', '0', true, true); - $subcanemaildomain.= makeoption($lng['admin']['subcanemaildomain']['choosableno'], '1', '0', true, true); - $subcanemaildomain.= makeoption($lng['admin']['subcanemaildomain']['choosableyes'], '2', '0', true, true); - $subcanemaildomain.= makeoption($lng['admin']['subcanemaildomain']['always'], '3', '0', true, true); + $subcanemaildomain .= makeoption($lng['admin']['subcanemaildomain']['choosableno'], '1', '0', true, true); + $subcanemaildomain .= makeoption($lng['admin']['subcanemaildomain']['choosableyes'], '2', '0', true, true); + $subcanemaildomain .= makeoption($lng['admin']['subcanemaildomain']['always'], '3', '0', true, true); $add_date = date('Y-m-d'); - $domain_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/domains/formfield.domains_add.php'; + $domain_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_add.php'; $domain_add_form = htmlform::genHTMLForm($domain_add_data); $title = $domain_add_data['domain_add']['title']; @@ -1034,17 +1017,14 @@ if ($page == 'domains' eval("echo \"" . getTemplate("domains/domains_add") . "\";"); } } - - } elseif($action == 'edit' - && $id != 0 - ) { + } elseif ($action == 'edit' && $id != 0) { $result_stmt = Database::prepare(" SELECT `d`.*, `c`.`customerid` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) - WHERE `d`.`parentdomainid` = '0' AND `d`.`id` = :id" . - ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") + WHERE `d`.`parentdomainid` = '0' AND `d`.`id` = :id" . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid")); + $params = array( + 'id' => $id ); - $params = array('id' => $id); if ($userinfo['customers_see_all'] == '0') { $params['adminid'] = $userinfo['adminid']; } @@ -1056,21 +1036,28 @@ if ($page == 'domains' SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `parentdomainid` = :resultid "); - $subdomains = Database::pexecute_first($subdomains_stmt, array('resultid' => $result['id'])); + $subdomains = Database::pexecute_first($subdomains_stmt, array( + 'resultid' => $result['id'] + )); $subdomains = $subdomains['count']; $alias_check_stmt = Database::prepare(" SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain` = :resultid "); - $alias_check = Database::pexecute_first($alias_check_stmt, array('resultid' => $result['id'])); + $alias_check = Database::pexecute_first($alias_check_stmt, array( + 'resultid' => $result['id'] + )); $alias_check = $alias_check['count']; $domain_emails_result_stmt = Database::prepare(" SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders` FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid` = :customerid AND `domainid` = :id "); - Database::pexecute($domain_emails_result_stmt, array('customerid' => $result['customerid'], 'id' => $result['id'])); + Database::pexecute($domain_emails_result_stmt, array( + 'customerid' => $result['customerid'], + 'id' => $result['id'] + )); $emails = Database::num_rows(); $email_forwarders = 0; @@ -1081,11 +1068,11 @@ if ($page == 'domains' if ($domain_emails_row['destination'] != '') { $domain_emails_row['destination'] = explode(' ', makeCorrectDestination($domain_emails_row['destination'])); - $email_forwarders+= count($domain_emails_row['destination']); + $email_forwarders += count($domain_emails_row['destination']); if (in_array($domain_emails_row['email_full'], $domain_emails_row['destination'])) { - $email_forwarders-= 1; - $email_accounts++; + $email_forwarders -= 1; + $email_accounts ++; } } } @@ -1093,31 +1080,30 @@ if ($page == 'domains' $ipsresult_stmt = Database::prepare(" SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :id "); - Database::pexecute($ipsresult_stmt, array('id' => $result['id'])); + Database::pexecute($ipsresult_stmt, array( + 'id' => $result['id'] + )); $usedips = array(); while ($ipsresultrow = $ipsresult_stmt->fetch(PDO::FETCH_ASSOC)) { $usedips[] = $ipsresultrow['id_ipandports']; } - if (isset($_POST['send']) - && $_POST['send'] == 'send' - ) { + if (isset($_POST['send']) && $_POST['send'] == 'send') { $customer_stmt = Database::prepare(" SELECT * FROM " . TABLE_PANEL_CUSTOMERS . " WHERE `customerid` = :customerid "); - $customer = Database::pexecute_first($customer_stmt, array('customerid' => $result['customerid'])); + $customer = Database::pexecute_first($customer_stmt, array( + 'customerid' => $result['customerid'] + )); - $customerid = -1; + $customerid = - 1; if (isset($_POST['customerid'])) { $customerid = intval($_POST['customerid']); } - if ($customerid > 0 - && $customerid != $result['customerid'] - && Settings::Get('panel.allow_domain_change_customer') == '1' - ) { + if ($customerid > 0 && $customerid != $result['customerid'] && Settings::Get('panel.allow_domain_change_customer') == '1') { $customer_stmt = Database::prepare(" SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` @@ -1125,9 +1111,7 @@ if ($page == 'domains' AND (`subdomains_used` + :subdomains <= `subdomains` OR `subdomains` = '-1' ) AND (`emails_used` + :emails <= `emails` OR `emails` = '-1' ) AND (`email_forwarders_used` + :forwarders <= `email_forwarders` OR `email_forwarders` = '-1' ) - AND (`email_accounts_used` + :accounts <= `email_accounts` OR `email_accounts` = '-1' ) " . - ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid") - ); + AND (`email_accounts_used` + :accounts <= `email_accounts` OR `email_accounts` = '-1' ) " . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid")); $params = array( 'customerid' => $customerid, @@ -1141,9 +1125,7 @@ if ($page == 'domains' } $customer = Database::pexecute_first($customer_stmt, $params); - if (empty($customer) - || $customer['customerid'] != $customerid - ) { + if (empty($customer) || $customer['customerid'] != $customerid) { standard_error('customerdoesntexist'); } } else { @@ -1153,29 +1135,28 @@ if ($page == 'domains' $customer_stmt = Database::prepare(" SELECT * FROM " . TABLE_PANEL_ADMINS . " WHERE `adminid` = :adminid "); - $admin = Database::pexecute_first($customer_stmt, array('adminid' => $result['adminid'])); + $admin = Database::pexecute_first($customer_stmt, array( + 'adminid' => $result['adminid'] + )); if ($userinfo['customers_see_all'] == '1') { - $adminid = -1; + $adminid = - 1; if (isset($_POST['adminid'])) { $adminid = intval($_POST['adminid']); } - if ($adminid > 0 - && $adminid != $result['adminid'] - && Settings::Get('panel.allow_domain_change_admin') == '1' - ) { + if ($adminid > 0 && $adminid != $result['adminid'] && Settings::Get('panel.allow_domain_change_admin') == '1') { $admin_stmt = Database::prepare(" SELECT * FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :adminid AND ( `domains_used` < `domains` OR `domains` = '-1' ) "); - $admin = Database::pexecute_first($admin_stmt, array('adminid' => $adminid)); + $admin = Database::pexecute_first($admin_stmt, array( + 'adminid' => $adminid + )); - if (empty($admin) - || $admin['adminid'] != $adminid - ) { + if (empty($admin) || $admin['adminid'] != $adminid) { standard_error('admindoesntexist'); } } else { @@ -1190,9 +1171,17 @@ if ($page == 'domains' $subcanemaildomain = intval($_POST['subcanemaildomain']); $caneditdomain = isset($_POST['caneditdomain']) ? intval($_POST['caneditdomain']) : 0; $registration_date = trim($_POST['registration_date']); - $registration_date = validate($registration_date, 'registration_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array('0000-00-00', '0', '')); + $registration_date = validate($registration_date, 'registration_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array( + '0000-00-00', + '0', + '' + )); $termination_date = trim($_POST['termination_date']); - $termination_date = validate($termination_date, 'termination_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array('0000-00-00', '0', '')); + $termination_date = validate($termination_date, 'termination_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array( + '0000-00-00', + '0', + '' + )); $isemaildomain = 0; if (isset($_POST['isemaildomain'])) { @@ -1215,16 +1204,15 @@ if ($page == 'domains' } $speciallogfile = 0; - if(isset($_POST['speciallogfile'])) + if (isset($_POST['speciallogfile'])) $speciallogfile = intval($_POST['speciallogfile']); - if ($userinfo['change_serversettings'] == '1') { $isbinddomain = $result['isbinddomain']; $zonefile = $result['zonefile']; if (Settings::Get('system.bind_enable') == '1') { if (isset($_POST['isbinddomain'])) { - $isbinddomain = (int)$_POST['isbinddomain']; + $isbinddomain = (int) $_POST['isbinddomain']; } else { $isbinddomain = 0; } @@ -1251,12 +1239,9 @@ if ($page == 'domains' } } - if (!preg_match('/^https?\:\/\//', $documentroot) - && strstr($documentroot, ":") !== false - ) { + if (! preg_match('/^https?\:\/\//', $documentroot) && strstr($documentroot, ":") !== false) { standard_error('pathmaynotcontaincolon'); } - } else { $isbinddomain = $result['isbinddomain']; $zonefile = $result['zonefile']; @@ -1266,44 +1251,43 @@ if ($page == 'domains' $documentroot = $result['documentroot']; } - $speciallogverified = (isset($_POST['speciallogverified']) ? (int)$_POST['speciallogverified'] : 0); + $speciallogverified = (isset($_POST['speciallogverified']) ? (int) $_POST['speciallogverified'] : 0); - if ($userinfo['caneditphpsettings'] == '1' - || $userinfo['change_serversettings'] == '1' - ) { + if ($userinfo['caneditphpsettings'] == '1' || $userinfo['change_serversettings'] == '1') { $openbasedir = isset($_POST['openbasedir']) ? intval($_POST['openbasedir']) : 0; - if ((int)Settings::Get('system.mod_fcgid') == 1 - || (int)Settings::Get('phpfpm.enabled') == 1 - ) { - $phpsettingid = (int)$_POST['phpsettingid']; + if ((int) Settings::Get('system.mod_fcgid') == 1 || (int) Settings::Get('phpfpm.enabled') == 1) { + $phpsettingid = (int) $_POST['phpsettingid']; $phpsettingid_check_stmt = Database::prepare(" SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :phpid "); - $phpsettingid_check = Database::pexecute_first($phpsettingid_check_stmt, array('phpid' => $phpsettingid)); + $phpsettingid_check = Database::pexecute_first($phpsettingid_check_stmt, array( + 'phpid' => $phpsettingid + )); - if (!isset($phpsettingid_check['id']) - || $phpsettingid_check['id'] == '0' - || $phpsettingid_check['id'] != $phpsettingid - ) { + if (! isset($phpsettingid_check['id']) || $phpsettingid_check['id'] == '0' || $phpsettingid_check['id'] != $phpsettingid) { standard_error('phpsettingidwrong'); } - if ((int)Settings::Get('system.mod_fcgid') == 1) { - $mod_fcgid_starter = validate($_POST['mod_fcgid_starter'], 'mod_fcgid_starter', '/^[0-9]*$/', '', array('-1', '')); - $mod_fcgid_maxrequests = validate($_POST['mod_fcgid_maxrequests'], 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array('-1', '')); + if ((int) Settings::Get('system.mod_fcgid') == 1) { + $mod_fcgid_starter = validate($_POST['mod_fcgid_starter'], 'mod_fcgid_starter', '/^[0-9]*$/', '', array( + '-1', + '' + )); + $mod_fcgid_maxrequests = validate($_POST['mod_fcgid_maxrequests'], 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array( + '-1', + '' + )); } else { $mod_fcgid_starter = $result['mod_fcgid_starter']; $mod_fcgid_maxrequests = $result['mod_fcgid_maxrequests']; } - } else { $phpsettingid = $result['phpsettingid']; $mod_fcgid_starter = $result['mod_fcgid_starter']; $mod_fcgid_maxrequests = $result['mod_fcgid_maxrequests']; } - } else { $openbasedir = $result['openbasedir']; $phpsettingid = $result['phpsettingid']; @@ -1312,7 +1296,7 @@ if ($page == 'domains' } $ipandports = array(); - if (isset($_POST['ipandport']) && !is_array($_POST['ipandport'])) { + if (isset($_POST['ipandport']) && ! is_array($_POST['ipandport'])) { $_POST['ipandport'] = unserialize($_POST['ipandport']); } if (isset($_POST['ipandport']) && is_array($_POST['ipandport'])) { @@ -1321,13 +1305,13 @@ if ($page == 'domains' SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipandport "); foreach ($_POST['ipandport'] as $ipandport) { - if (trim($ipandport) == "") continue; + if (trim($ipandport) == "") + continue; $ipandport = intval($ipandport); - $ipandport_check = Database::pexecute_first($ipandport_check_stmt, array('ipandport' => $ipandport)); - if (!isset($ipandport_check['id']) - || $ipandport_check['id'] == '0' - || $ipandport_check['id'] != $ipandport - ) { + $ipandport_check = Database::pexecute_first($ipandport_check_stmt, array( + 'ipandport' => $ipandport + )); + if (! isset($ipandport_check['id']) || $ipandport_check['id'] == '0' || $ipandport_check['id'] != $ipandport) { standard_error('ipportdoesntexist'); } else { $ipandports[] = $ipandport; @@ -1335,22 +1319,20 @@ if ($page == 'domains' } } - if (Settings::Get('system.use_ssl') == '1' - && isset($_POST['ssl_ipandport']) - ) { + if (Settings::Get('system.use_ssl') == '1' && isset($_POST['ssl_ipandport'])) { $ssl = 1; // if ssl is set and != 0, it can only be 1 $ssl_redirect = 0; if (isset($_POST['ssl_redirect'])) { - $ssl_redirect = (int)$_POST['ssl_redirect']; + $ssl_redirect = (int) $_POST['ssl_redirect']; } $letsencrypt = 0; if (isset($_POST['letsencrypt'])) { - $letsencrypt = (int)$_POST['letsencrypt']; + $letsencrypt = (int) $_POST['letsencrypt']; } $ssl_ipandports = array(); - if (isset($_POST['ssl_ipandport']) && !is_array($_POST['ssl_ipandport'])) { + if (isset($_POST['ssl_ipandport']) && ! is_array($_POST['ssl_ipandport'])) { $_POST['ssl_ipandport'] = unserialize($_POST['ssl_ipandport']); } if (isset($_POST['ssl_ipandport']) && is_array($_POST['ssl_ipandport'])) { @@ -1359,15 +1341,16 @@ if ($page == 'domains' SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipandport "); foreach ($_POST['ssl_ipandport'] as $ssl_ipandport) { - if (trim($ssl_ipandport) == "") continue; - // fix if ip/port got de-checked and it was the last one - if (trim($ssl_ipandport) < 1) continue; + if (trim($ssl_ipandport) == "") + continue; + // fix if ip/port got de-checked and it was the last one + if (trim($ssl_ipandport) < 1) + continue; $ssl_ipandport = intval($ssl_ipandport); - $ssl_ipandport_check = Database::pexecute_first($ssl_ipandport_check_stmt, array('ipandport' => $ssl_ipandport)); - if (!isset($ssl_ipandport_check['id']) - || $ssl_ipandport_check['id'] == '0' - || $ssl_ipandport_check['id'] != $ssl_ipandport - ) { + $ssl_ipandport_check = Database::pexecute_first($ssl_ipandport_check_stmt, array( + 'ipandport' => $ssl_ipandport + )); + if (! isset($ssl_ipandport_check['id']) || $ssl_ipandport_check['id'] == '0' || $ssl_ipandport_check['id'] != $ssl_ipandport) { standard_error('ipportdoesntexist'); } else { $ssl_ipandports[] = $ssl_ipandport; @@ -1378,14 +1361,14 @@ if ($page == 'domains' $letsencrypt = 0; // we need this for the serialize // if ssl is disabled or no ssl-ip/port exists - $ssl_ipandports[] = -1; + $ssl_ipandports[] = - 1; } } else { $ssl_redirect = 0; $letsencrypt = 0; // we need this for the serialize // if ssl is disabled or no ssl-ip/port exists - $ssl_ipandports[] = -1; + $ssl_ipandports[] = - 1; } // We can't enable let's encrypt for wildcard domains @@ -1398,7 +1381,7 @@ if ($page == 'domains' $ssl_redirect = 2; } - if (!preg_match('/^https?\:\/\//', $documentroot)) { + if (! preg_match('/^https?\:\/\//', $documentroot)) { $documentroot = makeCorrectDir($documentroot); } @@ -1420,14 +1403,11 @@ if ($page == 'domains' $email_only = '0'; } - if ($subcanemaildomain != '1' - && $subcanemaildomain != '2' - && $subcanemaildomain != '3' - ) { + if ($subcanemaildomain != '1' && $subcanemaildomain != '2' && $subcanemaildomain != '3') { $subcanemaildomain = '0'; } - if ($dkim != '1') { + if ($dkim != '1') { $dkim = '0'; } @@ -1444,12 +1424,16 @@ if ($page == 'domains' $ipandports = array(); $ssl_ipandports = array(); $origipresult_stmt = Database::prepare(" - SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP ."` WHERE `id_domain` = :aliasdomain + SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :aliasdomain "); - Database::pexecute($origipresult_stmt, array('aliasdomain' => $aliasdomain)); - $ipdata_stmt = Database::prepare("SELECT * FROM `".TABLE_PANEL_IPSANDPORTS."` WHERE `id` = :ipid"); + Database::pexecute($origipresult_stmt, array( + 'aliasdomain' => $aliasdomain + )); + $ipdata_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid"); while ($origip = $origipresult_stmt->fetch(PDO::FETCH_ASSOC)) { - $_origip_tmp = Database::pexecute_first($ipdata_stmt, array('ipid' => $origip['id_ipandports'])); + $_origip_tmp = Database::pexecute_first($ipdata_stmt, array( + 'ipid' => $origip['id_ipandports'] + )); if ($_origip_tmp['ssl'] == 0) { $ipandports[] = $origip['id_ipandports']; } else { @@ -1460,7 +1444,7 @@ if ($page == 'domains' if (count($ssl_ipandports) == 0) { // we need this for the serialize // if ssl is disabled or no ssl-ip/port exists - $ssl_ipandports[] = -1; + $ssl_ipandports[] = - 1; } $aliasdomain_check_stmt = Database::prepare(" @@ -1470,7 +1454,10 @@ if ($page == 'domains' AND `c`.`customerid` = :customerid AND `d`.`id` = :aliasdomain "); - $aliasdomain_check = Database::pexecute_first($aliasdomain_check_stmt, array('customerid' => $customerid, 'aliasdomain' => $aliasdomain)); + $aliasdomain_check = Database::pexecute_first($aliasdomain_check_stmt, array( + 'customerid' => $customerid, + 'aliasdomain' => $aliasdomain + )); } if (count($ipandports) == 0) { @@ -1485,8 +1472,7 @@ if ($page == 'domains' $issubof = '0'; } - if ($aliasdomain != 0 && $letsencrypt != 0) - { + if ($aliasdomain != 0 && $letsencrypt != 0) { standard_error('letsencryptdoesnotworkwithaliasdomains'); } @@ -1529,14 +1515,12 @@ if ($page == 'domains' $security_questions = array( 'reallydisablesecuritysetting' => ($openbasedir == '0' && $userinfo['change_serversettings'] == '1'), - 'reallydocrootoutofcustomerroot' => (substr($documentroot, 0, strlen($customer['documentroot'])) != $customer['documentroot'] && !preg_match('/^https?\:\/\//', $documentroot)) + 'reallydocrootoutofcustomerroot' => (substr($documentroot, 0, strlen($customer['documentroot'])) != $customer['documentroot'] && ! preg_match('/^https?\:\/\//', $documentroot)) ); foreach ($security_questions as $question_name => $question_launch) { if ($question_launch !== false) { $params[$question_name] = $question_name; - if (!isset($_POST[$question_name]) - || $_POST[$question_name] != $question_name - ) { + if (! isset($_POST[$question_name]) || $_POST[$question_name] != $question_name) { ask_yesno('admin_domain_' . $question_name, $filename, $params); } } @@ -1545,21 +1529,7 @@ if ($page == 'domains' $wwwserveralias = ($serveraliasoption == '1') ? '1' : '0'; $iswildcarddomain = ($serveraliasoption == '0') ? '1' : '0'; - if ($documentroot != $result['documentroot'] - || $ssl_redirect != $result['ssl_redirect'] - || $wwwserveralias != $result['wwwserveralias'] - || $iswildcarddomain != $result['iswildcarddomain'] - || $openbasedir != $result['openbasedir'] - || $phpsettingid != $result['phpsettingid'] - || $mod_fcgid_starter != $result['mod_fcgid_starter'] - || $mod_fcgid_maxrequests != $result['mod_fcgid_maxrequests'] - || $specialsettings != $result['specialsettings'] - || $aliasdomain != $result['aliasdomain'] - || $issubof != $result['ismainbutsubto'] - || $email_only != $result['email_only'] - || ($speciallogfile != $result['speciallogfile'] && $speciallogverified == '1') - || $letsencrypt != $result['letsencrypt'] - ) { + if ($documentroot != $result['documentroot'] || $ssl_redirect != $result['ssl_redirect'] || $wwwserveralias != $result['wwwserveralias'] || $iswildcarddomain != $result['iswildcarddomain'] || $openbasedir != $result['openbasedir'] || $phpsettingid != $result['phpsettingid'] || $mod_fcgid_starter != $result['mod_fcgid_starter'] || $mod_fcgid_maxrequests != $result['mod_fcgid_maxrequests'] || $specialsettings != $result['specialsettings'] || $aliasdomain != $result['aliasdomain'] || $issubof != $result['ismainbutsubto'] || $email_only != $result['email_only'] || ($speciallogfile != $result['speciallogfile'] && $speciallogverified == '1') || $letsencrypt != $result['letsencrypt']) { inserttask('1'); } @@ -1567,45 +1537,40 @@ if ($page == 'domains' $speciallogfile = $result['speciallogfile']; } - if ($isbinddomain != $result['isbinddomain'] - || $zonefile != $result['zonefile'] - || $dkim != $result['dkim'] - ) { + if ($isbinddomain != $result['isbinddomain'] || $zonefile != $result['zonefile'] || $dkim != $result['dkim']) { inserttask('4'); } - if ($isemaildomain == '0' - && $result['isemaildomain'] == '1' - ) { + if ($isemaildomain == '0' && $result['isemaildomain'] == '1') { $del_stmt = Database::prepare(" DELETE FROM `" . TABLE_MAIL_USERS . "` WHERE `domainid` = :id "); - Database::pexecute($del_stmt, array('id' => $id)); + Database::pexecute($del_stmt, array( + 'id' => $id + )); $del_stmt = Database::prepare(" DELETE FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `domainid` = :id "); - Database::pexecute($del_stmt, array('id' => $id)); + Database::pexecute($del_stmt, array( + 'id' => $id + )); $log->logAction(ADM_ACTION, LOG_NOTICE, "deleted domain #" . $id . " from mail-tables"); } $updatechildren = ''; - if ($subcanemaildomain == '0' - && $result['subcanemaildomain'] != '0' - ) { + if ($subcanemaildomain == '0' && $result['subcanemaildomain'] != '0') { $updatechildren = ", `isemaildomain` = '0' "; - - } elseif($subcanemaildomain == '3' - && $result['subcanemaildomain'] != '3' - ) { + } elseif ($subcanemaildomain == '3' && $result['subcanemaildomain'] != '3') { $updatechildren = ", `isemaildomain` = '1' "; } - if ($customerid != $result['customerid'] - && Settings::Get('panel.allow_domain_change_customer') == '1' - ) { - $upd_data = array('customerid' => $customerid, 'domainid' => $result['id']); + if ($customerid != $result['customerid'] && Settings::Get('panel.allow_domain_change_customer') == '1') { + $upd_data = array( + 'customerid' => $customerid, + 'domainid' => $result['id'] + ); $upd_stmt = Database::prepare(" UPDATE `" . TABLE_MAIL_USERS . "` SET `customerid` = :customerid WHERE `domainid` = :domainid "); @@ -1614,7 +1579,12 @@ if ($page == 'domains' UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `customerid` = :customerid WHERE `domainid` = :domainid "); Database::pexecute($upd_stmt, $upd_data); - $upd_data = array('subdomains' => $subdomains, 'emails' => $emails, 'forwarders' => $email_forwarders, 'accounts' => $email_accounts); + $upd_data = array( + 'subdomains' => $subdomains, + 'emails' => $emails, + 'forwarders' => $email_forwarders, + 'accounts' => $email_accounts + ); $upd_data['customerid'] = $customerid; $upd_stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET @@ -1638,18 +1608,20 @@ if ($page == 'domains' Database::pexecute($upd_stmt, $upd_data); } - if ($adminid != $result['adminid'] - && Settings::Get('panel.allow_domain_change_admin') == '1' - ) { + if ($adminid != $result['adminid'] && Settings::Get('panel.allow_domain_change_admin') == '1') { $upd_stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_ADMINS . "` SET `domains_used` = `domains_used` + 1 WHERE `adminid` = :adminid "); - Database::pexecute($upd_stmt, array('adminid' => $adminid)); + Database::pexecute($upd_stmt, array( + 'adminid' => $adminid + )); $upd_stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_ADMINS . "` SET `domains_used` = `domains_used` - 1 WHERE `adminid` = :adminid "); - Database::pexecute($upd_stmt, array('adminid' => $result['adminid'])); + Database::pexecute($upd_stmt, array( + 'adminid' => $result['adminid'] + )); } $_update_data = array(); @@ -1664,7 +1636,9 @@ if ($page == 'domains' $upd_stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `specialsettings`='' WHERE `parentdomainid` = :id "); - Database::pexecute($upd_stmt, array('id' => $id)); + Database::pexecute($upd_stmt, array( + 'id' => $id + )); $log->logAction(ADM_ACTION, LOG_INFO, "removed specialsettings on all subdomains of domain #" . $id); } @@ -1740,7 +1714,7 @@ if ($page == 'domains' // all its subdomains must have "ssl-redirect = 0" // and disable let's encrypt $update_sslredirect = ''; - if (count($ssl_ipandports) == 1 && $ssl_ipandports[0] == -1) { + if (count($ssl_ipandports) == 1 && $ssl_ipandports[0] == - 1) { $update_sslredirect = ", `ssl_redirect` = '0', `letsencrypt` = '0' "; } @@ -1767,18 +1741,26 @@ if ($page == 'domains' $del_stmt = Database::prepare(" DELETE FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :id "); - Database::pexecute($del_stmt, array('id' => $id)); + Database::pexecute($del_stmt, array( + 'id' => $id + )); $ins_stmt = Database::prepare(" INSERT INTO `" . TABLE_DOMAINTOIP . "` SET `id_domain` = :domainid, `id_ipandports` = :ipportid "); foreach ($ipandports as $ipportid) { - Database::pexecute($ins_stmt, array('domainid' => $id, 'ipportid' => $ipportid)); + Database::pexecute($ins_stmt, array( + 'domainid' => $id, + 'ipportid' => $ipportid + )); } foreach ($ssl_ipandports as $ssl_ipportid) { if ($ssl_ipportid > 0) { - Database::pexecute($ins_stmt, array('domainid' => $id, 'ipportid' => $ssl_ipportid)); + Database::pexecute($ins_stmt, array( + 'domainid' => $id, + 'ipportid' => $ssl_ipportid + )); } } @@ -1786,14 +1768,18 @@ if ($page == 'domains' $domainidsresult_stmt = Database::prepare(" SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `parentdomainid` = :id "); - Database::pexecute($domainidsresult_stmt, array('id' => $id)); + Database::pexecute($domainidsresult_stmt, array( + 'id' => $id + )); while ($row = $domainidsresult_stmt->fetch(PDO::FETCH_ASSOC)) { $del_stmt = Database::prepare(" DELETE FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :rowid "); - Database::pexecute($del_stmt, array('rowid' => $row['id'])); + Database::pexecute($del_stmt, array( + 'rowid' => $row['id'] + )); $ins_stmt = Database::prepare(" INSERT INTO `" . TABLE_DOMAINTOIP . "` SET @@ -1802,21 +1788,28 @@ if ($page == 'domains' "); foreach ($ipandports as $ipportid) { - Database::pexecute($ins_stmt, array('rowid' => $row['id'], 'ipportid' => $ipportid)); + Database::pexecute($ins_stmt, array( + 'rowid' => $row['id'], + 'ipportid' => $ipportid + )); } foreach ($ssl_ipandports as $ssl_ipportid) { if ($ssl_ipportid > 0) { - Database::pexecute($ins_stmt, array('rowid' => $row['id'], 'ipportid' => $ssl_ipportid)); + Database::pexecute($ins_stmt, array( + 'rowid' => $row['id'], + 'ipportid' => $ssl_ipportid + )); } } } $log->logAction(ADM_ACTION, LOG_INFO, "edited domain #" . $id); - redirectTo($filename, array('page' => $page, 's' => $s)); - + redirectTo($filename, array( + 'page' => $page, + 's' => $s + )); } else { - if (Settings::Get('panel.allow_domain_change_customer') == '1') { $customers = ''; $result_customers_stmt = Database::prepare(" @@ -1824,8 +1817,7 @@ if ($page == 'domains' WHERE ( (`subdomains_used` + :subdomains <= `subdomains` OR `subdomains` = '-1' ) AND (`emails_used` + :emails <= `emails` OR `emails` = '-1' ) AND (`email_forwarders_used` + :forwarders <= `email_forwarders` OR `email_forwarders` = '-1' ) - AND (`email_accounts_used` + :accounts <= `email_accounts` OR `email_accounts` = '-1' ) " . - ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid ") . ") + AND (`email_accounts_used` + :accounts <= `email_accounts` OR `email_accounts` = '-1' ) " . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid ") . ") OR `customerid` = :customerid ORDER BY `name` ASC "); $params = array( @@ -1841,15 +1833,16 @@ if ($page == 'domains' Database::pexecute($result_customers_stmt, $params); while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) { - $customers.= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid'], $result['customerid']); + $customers .= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid'], $result['customerid']); } - } else { $customer_stmt = Database::prepare(" SELECT `customerid`, `loginname`, `name`, `firstname`, `company` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid` = :customerid "); - $customer = Database::pexecute_first($customer_stmt, array('customerid' => $result['customerid'])); + $customer = Database::pexecute_first($customer_stmt, array( + 'customerid' => $result['customerid'] + )); $result['customername'] = getCorrectFullUserDetails($customer) . ' (' . $customer['loginname'] . ')'; } @@ -1861,16 +1854,20 @@ if ($page == 'domains' SELECT `adminid`, `loginname`, `name` FROM `" . TABLE_PANEL_ADMINS . "` WHERE (`domains_used` < `domains` OR `domains` = '-1') OR `adminid` = :adminid ORDER BY `name` ASC "); - Database::pexecute($result_admins_stmt, array('adminid' => $result['adminid'])); + Database::pexecute($result_admins_stmt, array( + 'adminid' => $result['adminid'] + )); while ($row_admin = $result_admins_stmt->fetch(PDO::FETCH_ASSOC)) { - $admins.= makeoption(getCorrectFullUserDetails($row_admin) . ' (' . $row_admin['loginname'] . ')', $row_admin['adminid'], $result['adminid']); + $admins .= makeoption(getCorrectFullUserDetails($row_admin) . ' (' . $row_admin['loginname'] . ')', $row_admin['adminid'], $result['adminid']); } } else { $admin_stmt = Database::prepare(" SELECT `adminid`, `loginname`, `name` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :adminid "); - $admin = Database::pexecute_first($admin_stmt, array('adminid' => $result['adminid'])); + $admin = Database::pexecute_first($admin_stmt, array( + 'adminid' => $result['adminid'] + )); $result['adminname'] = getCorrectFullUserDetails($admin) . ' (' . $admin['loginname'] . ')'; } } @@ -1884,28 +1881,32 @@ if ($page == 'domains' AND `c`.`standardsubdomain`<>`d`.`id` AND `d`.`customerid` = :customerid AND `c`.`customerid`=`d`.`customerid` ORDER BY `d`.`domain` ASC "); - Database::pexecute($result_domains_stmt, array('id' => $result['id'], 'customerid' => $result['customerid'])); + Database::pexecute($result_domains_stmt, array( + 'id' => $result['id'], + 'customerid' => $result['customerid'] + )); while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { - $domains.= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['aliasdomain']); + $domains .= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['aliasdomain']); } $subtodomains = makeoption($lng['domains']['nosubtomaindomain'], 0, null, true); $result_domains_stmt = Database::prepare(" SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = '0' AND `d`.`id` <> :id - AND `c`.`standardsubdomain`<>`d`.`id` AND `c`.`customerid`=`d`.`customerid`". - ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . " + AND `c`.`standardsubdomain`<>`d`.`id` AND `c`.`customerid`=`d`.`customerid`" . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . " ORDER BY `d`.`domain` ASC "); - $params = array('id' => $result['id']); + $params = array( + 'id' => $result['id'] + ); if ($userinfo['customers_see_all'] == '0') { $params['adminid'] = $userinfo['adminid']; } Database::pexecute($result_domains_stmt, $params); while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { - $subtodomains.= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['ismainbutsubto']); + $subtodomains .= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['ismainbutsubto']); } if ($userinfo['ip'] == "-1") { @@ -1919,17 +1920,23 @@ if ($page == 'domains' $admin_ip_stmt = Database::prepare(" SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid ORDER BY `ip`, `port` ASC "); - $admin_ip = Database::pexecute_first($admin_ip_stmt, array('ipid' => $userinfo['ip'])); + $admin_ip = Database::pexecute_first($admin_ip_stmt, array( + 'ipid' => $userinfo['ip'] + )); $result_ipsandports_stmt = Database::prepare(" SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='0' AND `ip` = :ipid ORDER BY `ip`, `port` ASC "); - Database::pexecute($result_ipsandports_stmt, array('ipid' => $admin_ip['ip'])); + Database::pexecute($result_ipsandports_stmt, array( + 'ipid' => $admin_ip['ip'] + )); $result_ssl_ipsandports_stmt = Database::prepare(" SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='1' AND `ip` = :ipid ORDER BY `ip`, `port` ASC "); - Database::pexecute($result_ssl_ipsandports_stmt, array('ipid' => $admin_ip['ip'])); + Database::pexecute($result_ssl_ipsandports_stmt, array( + 'ipid' => $admin_ip['ip'] + )); } $ipsandports = array(); @@ -1937,7 +1944,10 @@ if ($page == 'domains' if (filter_var($row_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { $row_ipandport['ip'] = '[' . $row_ipandport['ip'] . ']'; } - $ipsandports[] = array('label' => $row_ipandport['ip'] . ':' . $row_ipandport['port'] . '
', 'value' => $row_ipandport['id']); + $ipsandports[] = array( + 'label' => $row_ipandport['ip'] . ':' . $row_ipandport['port'] . '
', + 'value' => $row_ipandport['id'] + ); } $ssl_ipsandports = array(); @@ -1945,7 +1955,10 @@ if ($page == 'domains' if (filter_var($row_ssl_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { $row_ssl_ipandport['ip'] = '[' . $row_ssl_ipandport['ip'] . ']'; } - $ssl_ipsandports[] = array('label' => $row_ssl_ipandport['ip'] . ':' . $row_ssl_ipandport['port'] . '
', 'value' => $row_ssl_ipandport['id']); + $ssl_ipsandports[] = array( + 'label' => $row_ssl_ipandport['ip'] . ':' . $row_ssl_ipandport['port'] . '
', + 'value' => $row_ssl_ipandport['id'] + ); } // create serveralias options @@ -1961,15 +1974,15 @@ if ($page == 'domains' // Fudge the result for ssl_redirect to hide the Let's Encrypt steps $result['temporary_ssl_redirect'] = $result['ssl_redirect']; $result['ssl_redirect'] = ($result['ssl_redirect'] == 0 ? 0 : 1); - + $serveraliasoptions .= makeoption($lng['domains']['serveraliasoption_wildcard'], '0', $_value, true, true); $serveraliasoptions .= makeoption($lng['domains']['serveraliasoption_www'], '1', $_value, true, true); $serveraliasoptions .= makeoption($lng['domains']['serveraliasoption_none'], '2', $_value, true, true); $subcanemaildomain = makeoption($lng['admin']['subcanemaildomain']['never'], '0', $result['subcanemaildomain'], true, true); - $subcanemaildomain.= makeoption($lng['admin']['subcanemaildomain']['choosableno'], '1', $result['subcanemaildomain'], true, true); - $subcanemaildomain.= makeoption($lng['admin']['subcanemaildomain']['choosableyes'], '2', $result['subcanemaildomain'], true, true); - $subcanemaildomain.= makeoption($lng['admin']['subcanemaildomain']['always'], '3', $result['subcanemaildomain'], true, true); + $subcanemaildomain .= makeoption($lng['admin']['subcanemaildomain']['choosableno'], '1', $result['subcanemaildomain'], true, true); + $subcanemaildomain .= makeoption($lng['admin']['subcanemaildomain']['choosableyes'], '2', $result['subcanemaildomain'], true, true); + $subcanemaildomain .= makeoption($lng['admin']['subcanemaildomain']['always'], '3', $result['subcanemaildomain'], true, true); $speciallogfile = ($result['speciallogfile'] == 1 ? $lng['panel']['yes'] : $lng['panel']['no']); $result['add_date'] = date('Y-m-d', $result['add_date']); @@ -1977,12 +1990,12 @@ if ($page == 'domains' $phpconfigs_result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "`"); while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) { - $phpconfigs.= makeoption($phpconfigs_row['description'], $phpconfigs_row['id'], $result['phpsettingid'], true, true); + $phpconfigs .= makeoption($phpconfigs_row['description'], $phpconfigs_row['id'], $result['phpsettingid'], true, true); } $result = htmlentities_array($result); - $domain_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/domains/formfield.domains_edit.php'; + $domain_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_edit.php'; $domain_edit_form = htmlform::genHTMLForm($domain_edit_data); $title = $domain_edit_data['domain_edit']['title']; @@ -1993,15 +2006,13 @@ if ($page == 'domains' eval("echo \"" . getTemplate("domains/domains_edit") . "\";"); } } - } elseif($action == 'import') { + } elseif ($action == 'import') { - if (isset($_POST['send']) - && $_POST['send'] == 'send' - ) { + if (isset($_POST['send']) && $_POST['send'] == 'send') { $customerid = intval($_POST['customerid']); $separator = validate($_POST['separator'], 'separator'); - $offset = (int)validate($_POST['offset'], 'offset', "/[0-9]/i"); + $offset = (int) validate($_POST['offset'], 'offset', "/[0-9]/i"); $file_name = $_FILES['file']['tmp_name']; @@ -2015,21 +2026,22 @@ if ($page == 'domains' } // @FIXME find a way to display $result['notice'] here somehow, - // as it might be important if you've reached your maximum allocation of domains + // as it might be important if you've reached your maximum allocation of domains // update customer/admin counters updateCounters(false); $result_str = $result['imported'] . ' / ' . $result['all']; - standard_success('domain_import_successfully', $result_str, array('filename' => $filename, 'action' => '', 'page' => 'domains')); + standard_success('domain_import_successfully', $result_str, array( + 'filename' => $filename, + 'action' => '', + 'page' => 'domains' + )); } else { $customers = makeoption($lng['panel']['please_choose'], 0, 0, true); $result_customers_stmt = Database::prepare(" SELECT `customerid`, `loginname`, `name`, `firstname`, `company` - FROM `" . TABLE_PANEL_CUSTOMERS . "` " . - ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int)$userinfo['adminid'] . "' ") . - " ORDER BY `name` ASC" - ); + FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int) $userinfo['adminid'] . "' ") . " ORDER BY `name` ASC"); $params = array(); if ($userinfo['customers_see_all'] == '0') { $params['adminid'] = $userinfo['adminid']; @@ -2037,10 +2049,10 @@ if ($page == 'domains' Database::pexecute($result_customers_stmt, $params); while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) { - $customers.= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']); + $customers .= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']); } - $domain_import_data = include_once dirname(__FILE__).'/lib/formfields/admin/domains/formfield.domains_import.php'; + $domain_import_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_import.php'; $domain_import_form = htmlform::genHTMLForm($domain_import_data); $title = $domain_import_data['domain_import']['title']; @@ -2050,3 +2062,42 @@ if ($page == 'domains' } } } + +function formatDomainEntry(&$row, &$idna_convert) +{ + $row['domain'] = $idna_convert->decode($row['domain']); + $row['aliasdomain'] = $idna_convert->decode($row['aliasdomain']); + + $resultips_stmt = Database::prepare(" + SELECT `ips`.* FROM `" . TABLE_DOMAINTOIP . "` AS `dti`, `" . TABLE_PANEL_IPSANDPORTS . "` AS `ips` + WHERE `dti`.`id_ipandports` = `ips`.`id` AND `dti`.`id_domain` = :domainid + "); + + Database::pexecute($resultips_stmt, array( + 'domainid' => $row['id'] + )); + + $row['ipandport'] = ''; + while ($rowip = $resultips_stmt->fetch(PDO::FETCH_ASSOC)) { + + if (filter_var($rowip['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + $row['ipandport'] .= '[' . $rowip['ip'] . ']:' . $rowip['port'] . "\n"; + } else { + $row['ipandport'] .= $rowip['ip'] . ':' . $rowip['port'] . "\n"; + } + } + $row['ipandport'] = substr($row['ipandport'], 0, - 1); + $row['termination_date'] = str_replace("0000-00-00", "", $row['termination_date']); + + $row['termination_css'] = ""; + if ($row['termination_date'] != "") { + $cdate = strtotime($row['termination_date'] . " 23:59:59"); + $today = time(); + + if ($cdate < $today) { + $row['termination_css'] = 'domain-expired'; + } else { + $row['termination_css'] = 'domain-canceled'; + } + } +} diff --git a/templates/Sparkle/admin/domains/domains_domain.tpl b/templates/Sparkle/admin/domains/domains_domain.tpl index fe0dcf4f..4d268100 100644 --- a/templates/Sparkle/admin/domains/domains_domain.tpl +++ b/templates/Sparkle/admin/domains/domains_domain.tpl @@ -1,23 +1,20 @@ - - + + - - + + - - {$row['domain']}  ({$lng['admin']['stdsubdomain']}) - -
({$lng['domains']['termination_date_overview']} {$row['termination_date']})
-
- + +
({$lng['domains']['termination_date_overview']} {$row['termination_date']})
+
{$row['ipandport']} {$row['customername']}  - ({$row['loginname']}) + ({$row['loginname']}) @@ -26,7 +23,7 @@ {$lng['panel']['letsencrypt']} - +   {$lng['panel']['delete']} diff --git a/templates/Sparkle/assets/css/main.css b/templates/Sparkle/assets/css/main.css index 7e532474..38e07046 100644 --- a/templates/Sparkle/assets/css/main.css +++ b/templates/Sparkle/assets/css/main.css @@ -1495,11 +1495,21 @@ fieldset.file { } .domain-canceled { - /* Color copied from .warningcontainer */ - background-color: #fffecc; + /* Color copied from .warningcontainer */ + background-color: #fffecc; } .domain-expired { - /* Color copied from .errorcontainer */ - background-color: rgb(242, 222, 222); -} \ No newline at end of file + /* Color copied from .errorcontainer */ + background-color: rgb(242, 222, 222); +} + +.domain-hostname { + background-color: rgb(53, 106, 160); + color: #ddd; + font-weight: bold; +} + +table.hl tbody tr.domain-hostname:hover { + background-color: rgb(64, 150, 238); +}