2010-01-27 08:54:31 +00:00
|
|
|
<?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 Panel
|
2011-05-04 09:59:20 +00:00
|
|
|
*
|
2010-01-27 08:54:31 +00:00
|
|
|
*/
|
|
|
|
define('AREA', 'admin');
|
2013-11-18 11:53:33 +00:00
|
|
|
require './lib/init.php';
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if (isset($_POST['id'])) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$id = intval($_POST['id']);
|
2016-04-11 07:19:43 +00:00
|
|
|
} elseif (isset($_GET['id'])) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$id = intval($_GET['id']);
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($page == 'domains' || $page == 'overview') {
|
2010-01-27 08:54:31 +00:00
|
|
|
// Let's see how many customers we have
|
2013-11-13 14:39:20 +00:00
|
|
|
$stmt = Database::prepare("
|
2016-04-11 07:19:43 +00:00
|
|
|
SELECT COUNT(`customerid`) as `countcustomers` FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid"));
|
2013-11-13 14:39:20 +00:00
|
|
|
$params = array();
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
$countcustomers = Database::pexecute_first($stmt, $params);
|
2016-04-11 07:19:43 +00:00
|
|
|
$countcustomers = (int) $countcustomers['countcustomers'];
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($action == '') {
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_domains");
|
|
|
|
$fields = array(
|
|
|
|
'd.domain' => $lng['domains']['domainname'],
|
|
|
|
'c.name' => $lng['customer']['name'],
|
|
|
|
'c.firstname' => $lng['customer']['firstname'],
|
|
|
|
'c.company' => $lng['customer']['company'],
|
|
|
|
'c.loginname' => $lng['login']['username'],
|
|
|
|
'd.aliasdomain' => $lng['domains']['aliasdomain']
|
|
|
|
);
|
2013-12-15 10:47:23 +00:00
|
|
|
$paging = new paging($userinfo, TABLE_PANEL_DOMAINS, $fields);
|
2016-04-11 07:19:43 +00:00
|
|
|
$domains = "";
|
|
|
|
$syshostname = "";
|
|
|
|
if (Settings::Get('system.hostname_id'))
|
|
|
|
{
|
|
|
|
$syshostname = "AND `d`.`id` <> " . Settings::Get('system.hostname_id');
|
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
$result_stmt = Database::prepare("
|
2016-03-16 21:17:30 +00:00
|
|
|
SELECT `d`.*, `c`.`loginname`, `c`.`name`, `c`.`firstname`, `c`.`company`, `c`.`standardsubdomain`, `ad`.`id` AS `aliasdomainid`, `ad`.`domain` AS `aliasdomain`
|
2013-11-13 14:39:20 +00:00
|
|
|
FROM `" . TABLE_PANEL_DOMAINS . "` `d`
|
|
|
|
LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`)
|
|
|
|
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `ad` ON `d`.`aliasdomain`=`ad`.`id`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `d`.`parentdomainid`='0' " . $syshostname . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid ") . " " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
2013-11-13 14:39:20 +00:00
|
|
|
$params = array();
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
Database::pexecute($result_stmt, $params);
|
|
|
|
$numrows_domains = Database::num_rows();
|
|
|
|
$paging->setEntries($numrows_domains);
|
2010-01-27 08:54:31 +00:00
|
|
|
$sortcode = $paging->getHtmlSortCode($lng);
|
|
|
|
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
|
|
|
$searchcode = $paging->getHtmlSearchCode($lng);
|
|
|
|
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
|
|
|
$domain_array = array();
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
formatDomainEntry($row, $idna_convert);
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (! isset($domain_array[$row['domain']])) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$domain_array[$row['domain']] = $row;
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$domain_array[$row['domain']] = array_merge($row, $domain_array[$row['domain']]);
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (isset($row['aliasdomainid']) && $row['aliasdomainid'] != null && isset($row['aliasdomain']) && $row['aliasdomain'] != '') {
|
|
|
|
if (! isset($domain_array[$row['aliasdomain']])) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$domain_array[$row['aliasdomain']] = array();
|
|
|
|
}
|
|
|
|
$domain_array[$row['aliasdomain']]['domainaliasid'] = $row['id'];
|
|
|
|
$domain_array[$row['aliasdomain']]['domainalias'] = $row['domain'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We need ksort/krsort here to make sure idna-domains are also sorted correctly
|
|
|
|
*/
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($paging->sortfield == 'd.domain' && $paging->sortorder == 'asc') {
|
2010-01-27 08:54:31 +00:00
|
|
|
ksort($domain_array);
|
2016-04-11 07:19:43 +00:00
|
|
|
} elseif ($paging->sortfield == 'd.domain' && $paging->sortorder == 'desc') {
|
2010-01-27 08:54:31 +00:00
|
|
|
krsort($domain_array);
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
// 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", "<br />", $row['ipandport']);
|
|
|
|
eval("\$domains.=\"" . getTemplate("domains/domains_domain") . "\";");
|
|
|
|
}
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$i = 0;
|
|
|
|
$count = 0;
|
2013-11-13 14:39:20 +00:00
|
|
|
foreach ($domain_array as $row) {
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (isset($row['domain']) && $row['domain'] != '' && $paging->checkDisplay($i)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$row['customername'] = getCorrectFullUserDetails($row);
|
|
|
|
$row = htmlentities_array($row);
|
2013-04-29 08:02:44 +00:00
|
|
|
// display a nice list of IP's
|
|
|
|
$row['ipandport'] = str_replace("\n", "<br />", $row['ipandport']);
|
2010-01-27 08:54:31 +00:00
|
|
|
eval("\$domains.=\"" . getTemplate("domains/domains_domain") . "\";");
|
2016-04-11 07:19:43 +00:00
|
|
|
$count ++;
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2016-04-11 07:19:43 +00:00
|
|
|
$i ++;
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$domainscount = $numrows_domains;
|
2010-05-04 06:43:23 +00:00
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
// Display the list
|
|
|
|
eval("echo \"" . getTemplate("domains/domains") . "\";");
|
2016-04-11 07:19:43 +00:00
|
|
|
} elseif ($action == 'delete' && $id != 0) {
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `d`.* FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `d`.`id` = :id AND `d`.`id` <> `c`.`standardsubdomain`" . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid"));
|
|
|
|
$params = array(
|
|
|
|
'id' => $id
|
2013-11-13 14:39:20 +00:00
|
|
|
);
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
$result = Database::pexecute_first($result_stmt, $params);
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$alias_check_stmt = Database::prepare("
|
|
|
|
SELECT COUNT(`id`) AS `count` FROM `" . TABLE_PANEL_DOMAINS . "`
|
2016-04-11 07:19:43 +00:00
|
|
|
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') {
|
2010-08-06 05:43:28 +00:00
|
|
|
// check for deletion of main-domains which are logically subdomains, #329
|
|
|
|
$rsd_sql = '';
|
|
|
|
$remove_subbutmain_domains = isset($_POST['delete_userfiles']) ? 1 : 0;
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($remove_subbutmain_domains == 1) {
|
|
|
|
$rsd_sql .= " OR `ismainbutsubto` = :id";
|
2010-08-06 05:43:28 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$subresult_stmt = Database::prepare("
|
|
|
|
SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "`
|
2016-09-17 05:33:48 +00:00
|
|
|
WHERE (`id` = :id OR `parentdomainid` = :id " . $rsd_sql . ")");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($subresult_stmt, array(
|
|
|
|
'id' => $id
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
$idString = array();
|
2013-11-13 14:39:20 +00:00
|
|
|
$paramString = array();
|
|
|
|
while ($subRow = $subresult_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$idString[] = "`domainid` = :domain_" . (int) $subRow['id'];
|
|
|
|
$paramString['domain_' . $subRow['id']] = $subRow['id'];
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$idString = implode(' OR ', $idString);
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($idString != '') {
|
|
|
|
$del_stmt = Database::prepare("
|
2016-04-11 07:19:43 +00:00
|
|
|
DELETE FROM `" . TABLE_MAIL_USERS . "` WHERE " . $idString);
|
2013-11-13 14:39:20 +00:00
|
|
|
Database::pexecute($del_stmt, $paramString);
|
|
|
|
$del_stmt = Database::prepare("
|
2016-04-11 07:19:43 +00:00
|
|
|
DELETE FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE " . $idString);
|
2013-11-13 14:39:20 +00:00
|
|
|
Database::pexecute($del_stmt, $paramString);
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "deleted domain/s from mail-tables");
|
|
|
|
}
|
|
|
|
|
2016-09-17 06:13:10 +00:00
|
|
|
// if mainbutsubto-domains are not to be deleted, re-assign the (ismainbutsubto value of the main
|
|
|
|
// domain which is being deleted) as their new ismainbutsubto value
|
|
|
|
if ($remove_subbutmain_domains !== 1) {
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET
|
|
|
|
`ismainbutsubto` = :newIsMainButSubtoValue
|
|
|
|
WHERE `ismainbutsubto` = :deletedMainDomainId
|
|
|
|
");
|
|
|
|
Database::pexecute($upd_stmt, array(
|
|
|
|
'newIsMainButSubtoValue' => $result['ismainbutsubto'],
|
|
|
|
'deletedMainDomainId' => $id,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$del_stmt = Database::prepare("
|
|
|
|
DELETE FROM `" . TABLE_PANEL_DOMAINS . "`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `id` = :id OR `parentdomainid` = :id " . $rsd_sql);
|
|
|
|
Database::pexecute($del_stmt, array(
|
|
|
|
'id' => $id
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2016-11-24 09:40:28 +00:00
|
|
|
$deleted_domains = $del_stmt->rowCount();
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
|
|
|
|
`subdomains_used` = `subdomains_used` - :domaincount
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `customerid` = :customerid");
|
|
|
|
Database::pexecute($upd_stmt, array(
|
|
|
|
'domaincount' => ($deleted_domains - 1),
|
|
|
|
'customerid' => $result['customerid']
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_ADMINS . "` SET
|
|
|
|
`domains_used` = `domains_used` - 1
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `adminid` = :adminid");
|
|
|
|
Database::pexecute($upd_stmt, array(
|
|
|
|
'adminid' => $userinfo['adminid']
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
|
|
|
|
`standardsubdomain` = '0'
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `standardsubdomain` = :id AND `customerid` = :customerid");
|
|
|
|
Database::pexecute($upd_stmt, array(
|
|
|
|
'id' => $result['id'],
|
|
|
|
'customerid' => $result['customerid']
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$del_stmt = Database::prepare("
|
|
|
|
DELETE FROM `" . TABLE_DOMAINTOIP . "`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `id_domain` = :domainid");
|
|
|
|
Database::pexecute($del_stmt, array(
|
|
|
|
'domainid' => $id
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$del_stmt = Database::prepare("
|
|
|
|
DELETE FROM `" . TABLE_PANEL_DOMAINREDIRECTS . "`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `did` = :domainid");
|
|
|
|
Database::pexecute($del_stmt, array(
|
|
|
|
'domainid' => $id
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2016-03-06 17:40:48 +00:00
|
|
|
// remove certificate from domain_ssl_settings, fixes #1596
|
|
|
|
$del_stmt = Database::prepare("
|
|
|
|
DELETE FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `domainid` = :domainid");
|
|
|
|
Database::pexecute($del_stmt, array(
|
|
|
|
'domainid' => $id
|
|
|
|
));
|
2016-03-06 17:40:48 +00:00
|
|
|
|
2016-05-18 11:25:31 +00:00
|
|
|
// remove possible existing DNS entries
|
|
|
|
$del_stmt = Database::prepare("
|
|
|
|
DELETE FROM `" . TABLE_DOMAIN_DNS . "`
|
|
|
|
WHERE `domain_id` = :domainid
|
|
|
|
");
|
|
|
|
Database::pexecute($del_stmt, array(
|
|
|
|
'domainid' => $id
|
|
|
|
));
|
|
|
|
|
2016-05-16 14:32:07 +00:00
|
|
|
triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $log);
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "deleted domain/subdomains (#" . $result['id'] . ")");
|
|
|
|
updateCounters();
|
|
|
|
inserttask('1');
|
2011-12-06 14:43:34 +00:00
|
|
|
|
2013-02-25 10:18:12 +00:00
|
|
|
// Using nameserver, insert a task which rebuilds the server config
|
2013-03-29 19:10:37 +00:00
|
|
|
inserttask('4');
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
redirectTo($filename, array(
|
|
|
|
'page' => $page,
|
|
|
|
's' => $s
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
} elseif ($alias_check['count'] > 0) {
|
2011-02-06 09:57:31 +00:00
|
|
|
standard_error('domains_cantdeletedomainwithaliases');
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
|
|
|
|
2010-08-06 05:43:28 +00:00
|
|
|
$showcheck = false;
|
2013-11-13 14:39:20 +00:00
|
|
|
if (domainHasMainSubDomains($id)) {
|
2010-08-06 05:43:28 +00:00
|
|
|
$showcheck = true;
|
|
|
|
}
|
2016-04-11 07:19:43 +00:00
|
|
|
ask_yesno_withcheckbox('admin_domain_reallydelete', 'remove_subbutmain_domains', $filename, array(
|
|
|
|
'id' => $id,
|
|
|
|
'page' => $page,
|
|
|
|
'action' => $action
|
|
|
|
), $idna_convert->decode($result['domain']), $showcheck);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
2016-04-11 07:19:43 +00:00
|
|
|
} elseif ($action == 'add') {
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($userinfo['domains_used'] < $userinfo['domains'] || $userinfo['domains'] == '-1') {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
if ($_POST['domain'] == Settings::Get('system.hostname')) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('admin_domain_emailsystemhostname');
|
|
|
|
}
|
|
|
|
|
2017-06-04 07:17:31 +00:00
|
|
|
if (substr($_POST['domain'], 0, 4) == 'xn--') {
|
2016-05-18 07:03:14 +00:00
|
|
|
standard_error('domain_nopunycode');
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
$domain = $idna_convert->encode(preg_replace(array(
|
|
|
|
'/\:(\d)+$/',
|
|
|
|
'/^https?\:\/\//'
|
|
|
|
), '', validate($_POST['domain'], 'domain')));
|
2016-05-18 07:03:14 +00:00
|
|
|
|
|
|
|
// Check whether domain validation is enabled and if, validate the domain
|
|
|
|
if (Settings::Get('system.validate_domain') && ! validateDomain($domain)) {
|
|
|
|
standard_error(array(
|
|
|
|
'stringiswrong',
|
|
|
|
'mydomain'
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$subcanemaildomain = intval($_POST['subcanemaildomain']);
|
2011-06-16 18:54:54 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$isemaildomain = 0;
|
2013-11-13 14:39:20 +00:00
|
|
|
if (isset($_POST['isemaildomain'])) {
|
|
|
|
$isemaildomain = intval($_POST['isemaildomain']);
|
|
|
|
}
|
2011-06-16 18:54:54 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$email_only = 0;
|
2013-11-13 14:39:20 +00:00
|
|
|
if (isset($_POST['email_only'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$email_only = intval($_POST['email_only']);
|
2013-11-13 14:39:20 +00:00
|
|
|
}
|
2011-06-16 18:54:54 +00:00
|
|
|
|
2013-10-14 07:50:55 +00:00
|
|
|
$serveraliasoption = 0;
|
2013-11-13 14:39:20 +00:00
|
|
|
if (isset($_POST['selectserveralias'])) {
|
2013-10-14 07:50:55 +00:00
|
|
|
$serveraliasoption = intval($_POST['selectserveralias']);
|
2013-11-13 14:39:20 +00:00
|
|
|
}
|
2011-06-16 18:54:54 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$speciallogfile = 0;
|
2013-11-13 14:39:20 +00:00
|
|
|
if (isset($_POST['speciallogfile'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$speciallogfile = intval($_POST['speciallogfile']);
|
2013-11-13 14:39:20 +00:00
|
|
|
}
|
2011-06-16 18:54:54 +00:00
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$aliasdomain = intval($_POST['alias']);
|
2010-08-06 05:43:28 +00:00
|
|
|
$issubof = intval($_POST['issubof']);
|
2010-01-27 08:54:31 +00:00
|
|
|
$customerid = intval($_POST['customerid']);
|
2013-11-13 14:39:20 +00:00
|
|
|
$customer_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `customerid` = :customerid " . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid"));
|
|
|
|
$params = array(
|
|
|
|
'customerid' => $customerid
|
2013-11-13 14:39:20 +00:00
|
|
|
);
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
$customer = Database::pexecute_first($customer_stmt, $params);
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (empty($customer) || $customer['customerid'] != $customerid) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('customerdoesntexist');
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($userinfo['customers_see_all'] == '1') {
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$adminid = intval($_POST['adminid']);
|
2013-11-13 14:39:20 +00:00
|
|
|
$admin_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_ADMINS . "`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `adminid` = :adminid AND (`domains_used` < `domains` OR `domains` = '-1')");
|
|
|
|
$admin = Database::pexecute_first($admin_stmt, array(
|
|
|
|
'adminid' => $adminid
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (empty($admin) || $admin['adminid'] != $adminid) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('admindoesntexist');
|
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$adminid = $userinfo['adminid'];
|
|
|
|
$admin = $userinfo;
|
|
|
|
}
|
|
|
|
|
2014-04-12 07:37:51 +00:00
|
|
|
// set default path if admin/reseller has "change_serversettings == false" but we still
|
|
|
|
// need to respect the documentroot_use_default_value - setting
|
|
|
|
$path_suffix = '';
|
|
|
|
if (Settings::Get('system.documentroot_use_default_value') == 1) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$path_suffix = '/' . $domain;
|
2014-04-12 07:37:51 +00:00
|
|
|
}
|
|
|
|
$documentroot = makeCorrectDir($customer['documentroot'] . $path_suffix);
|
|
|
|
|
2011-05-01 11:27:24 +00:00
|
|
|
$registration_date = trim($_POST['registration_date']);
|
2016-04-11 07:19:43 +00:00
|
|
|
$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',
|
|
|
|
''
|
|
|
|
));
|
2016-05-01 16:01:05 +00:00
|
|
|
if ($registration_date == '0000-00-00') {
|
|
|
|
$registration_date = null;
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
$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',
|
|
|
|
''
|
|
|
|
));
|
2016-05-01 16:01:05 +00:00
|
|
|
if ($termination_date == '0000-00-00') {
|
|
|
|
$termination_date = null;
|
|
|
|
}
|
2016-02-10 20:22:52 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($userinfo['change_serversettings'] == '1') {
|
|
|
|
|
2013-02-28 08:31:33 +00:00
|
|
|
$caneditdomain = isset($_POST['caneditdomain']) ? intval($_POST['caneditdomain']) : 0;
|
2013-02-25 10:18:12 +00:00
|
|
|
|
|
|
|
$isbinddomain = '0';
|
|
|
|
$zonefile = '';
|
2013-12-15 10:47:23 +00:00
|
|
|
if (Settings::Get('system.bind_enable') == '1') {
|
2013-02-25 10:18:12 +00:00
|
|
|
if (isset($_POST['isbinddomain'])) {
|
|
|
|
$isbinddomain = intval($_POST['isbinddomain']);
|
|
|
|
}
|
|
|
|
$zonefile = validate($_POST['zonefile'], 'zonefile');
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if (isset($_POST['dkim'])) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$dkim = intval($_POST['dkim']);
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$dkim = '1';
|
|
|
|
}
|
|
|
|
|
|
|
|
$specialsettings = validate(str_replace("\r\n", "\n", $_POST['specialsettings']), 'specialsettings', '/^[^\0]*$/');
|
|
|
|
validate($_POST['documentroot'], 'documentroot');
|
|
|
|
|
2013-03-20 19:37:37 +00:00
|
|
|
// 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
|
2016-04-11 07:19:43 +00:00
|
|
|
if (isset($_POST['documentroot']) && $_POST['documentroot'] != '') {
|
|
|
|
if (substr($_POST['documentroot'], 0, 1) != '/' && ! preg_match('/^https?\:\/\//', $_POST['documentroot'])) {
|
|
|
|
$documentroot .= '/' . $_POST['documentroot'];
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$documentroot = $_POST['documentroot'];
|
|
|
|
}
|
2016-04-11 07:19:43 +00:00
|
|
|
} elseif (isset($_POST['documentroot']) && ($_POST['documentroot'] == '') && (Settings::Get('system.documentroot_use_default_value') == 1)) {
|
2013-03-20 19:37:37 +00:00
|
|
|
$documentroot = makeCorrectDir($customer['documentroot'] . '/' . $domain);
|
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2013-02-25 10:18:12 +00:00
|
|
|
$isbinddomain = '0';
|
2013-12-15 10:47:23 +00:00
|
|
|
if (Settings::Get('system.bind_enable') == '1') {
|
2013-02-25 10:18:12 +00:00
|
|
|
$isbinddomain = '1';
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
$caneditdomain = '1';
|
|
|
|
$zonefile = '';
|
|
|
|
$dkim = '1';
|
|
|
|
$specialsettings = '';
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($userinfo['caneditphpsettings'] == '1' || $userinfo['change_serversettings'] == '1') {
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2017-01-16 07:43:54 +00:00
|
|
|
$phpenabled = isset($_POST['phpenabled']) ? intval($_POST['phpenabled']) : 0;
|
2013-02-25 10:18:12 +00:00
|
|
|
$openbasedir = isset($_POST['openbasedir']) ? intval($_POST['openbasedir']) : 0;
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ((int) Settings::Get('system.mod_fcgid') == 1 || (int) Settings::Get('phpfpm.enabled') == 1) {
|
|
|
|
$phpsettingid = (int) $_POST['phpsettingid'];
|
2013-11-13 14:39:20 +00:00
|
|
|
$phpsettingid_check_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `id` = :phpsettingid");
|
|
|
|
$phpsettingid_check = Database::pexecute_first($phpsettingid_check_stmt, array(
|
|
|
|
'phpsettingid' => $phpsettingid
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (! isset($phpsettingid_check['id']) || $phpsettingid_check['id'] == '0' || $phpsettingid_check['id'] != $phpsettingid) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('phpsettingidwrong');
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
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',
|
|
|
|
''
|
|
|
|
));
|
2013-07-14 09:23:52 +00:00
|
|
|
} else {
|
|
|
|
$mod_fcgid_starter = '-1';
|
|
|
|
$mod_fcgid_maxrequests = '-1';
|
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
2013-12-15 10:47:23 +00:00
|
|
|
$phpsettingid = Settings::Get('phpfpm.defaultini');
|
2013-07-05 08:54:52 +00:00
|
|
|
} else {
|
2013-12-15 10:47:23 +00:00
|
|
|
$phpsettingid = Settings::Get('system.mod_fcgid_defaultini');
|
2013-07-05 08:54:52 +00:00
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
$mod_fcgid_starter = '-1';
|
|
|
|
$mod_fcgid_maxrequests = '-1';
|
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
|
|
|
|
2017-01-16 07:43:54 +00:00
|
|
|
$phpenabled = '1';
|
2010-01-27 08:54:31 +00:00
|
|
|
$openbasedir = '1';
|
2016-11-13 13:41:39 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
2013-12-15 10:47:23 +00:00
|
|
|
$phpsettingid = Settings::Get('phpfpm.defaultini');
|
2013-07-05 08:54:52 +00:00
|
|
|
} else {
|
2013-12-15 10:47:23 +00:00
|
|
|
$phpsettingid = Settings::Get('system.mod_fcgid_defaultini');
|
2013-07-05 08:54:52 +00:00
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
$mod_fcgid_starter = '-1';
|
|
|
|
$mod_fcgid_maxrequests = '-1';
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($userinfo['ip'] != "-1") {
|
|
|
|
$admin_ip_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `id` = :id ORDER BY `ip`, `port` ASC");
|
|
|
|
$admin_ip = Database::pexecute_first($admin_ip_stmt, array(
|
|
|
|
'id' => $userinfo['ip']
|
|
|
|
));
|
2013-12-30 14:00:36 +00:00
|
|
|
$additional_ip_condition = " AND `ip` = :adminip ";
|
2016-04-11 07:19:43 +00:00
|
|
|
$aip_param = array(
|
|
|
|
'adminip' => $admin_ip['ip']
|
|
|
|
);
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$additional_ip_condition = '';
|
2013-11-13 14:39:20 +00:00
|
|
|
$aip_param = array();
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2012-12-02 14:16:22 +00:00
|
|
|
$ipandports = array();
|
2016-04-11 07:19:43 +00:00
|
|
|
if (isset($_POST['ipandport']) && ! is_array($_POST['ipandport'])) {
|
2012-12-02 14:16:22 +00:00
|
|
|
$_POST['ipandport'] = unserialize($_POST['ipandport']);
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-05-08 14:34:04 +00:00
|
|
|
if (isset($_POST['ipandport']) && is_array($_POST['ipandport'])) {
|
2016-04-11 07:19:43 +00:00
|
|
|
foreach ($_POST['ipandport'] as $ipandport) {
|
2013-05-08 14:34:04 +00:00
|
|
|
$ipandport = intval($ipandport);
|
2013-11-13 14:39:20 +00:00
|
|
|
$ipandport_check_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `id` = :id " . $additional_ip_condition);
|
2013-11-13 14:39:20 +00:00
|
|
|
$ip_params = null;
|
2016-04-11 07:19:43 +00:00
|
|
|
$ip_params = array_merge(array(
|
|
|
|
'id' => $ipandport
|
|
|
|
), $aip_param);
|
2013-11-13 14:39:20 +00:00
|
|
|
$ipandport_check = Database::pexecute_first($ipandport_check_stmt, $ip_params);
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (! isset($ipandport_check['id']) || $ipandport_check['id'] == '0' || $ipandport_check['id'] != $ipandport) {
|
2012-12-02 14:16:22 +00:00
|
|
|
standard_error('ipportdoesntexist');
|
2013-05-08 14:34:04 +00:00
|
|
|
} else {
|
2012-12-02 14:16:22 +00:00
|
|
|
$ipandports[] = $ipandport;
|
|
|
|
}
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (Settings::Get('system.use_ssl') == "1" && isset($_POST['ssl_ipandport'])) {
|
2011-05-18 11:18:41 +00:00
|
|
|
$ssl_redirect = 0;
|
|
|
|
if (isset($_POST['ssl_redirect'])) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$ssl_redirect = (int) $_POST['ssl_redirect'];
|
2011-05-18 11:18:41 +00:00
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2016-01-30 13:34:26 +00:00
|
|
|
$letsencrypt = 0;
|
|
|
|
if (isset($_POST['letsencrypt'])) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$letsencrypt = (int) $_POST['letsencrypt'];
|
2016-01-30 13:34:26 +00:00
|
|
|
}
|
|
|
|
|
2012-12-02 14:16:22 +00:00
|
|
|
$ssl_ipandports = array();
|
2016-04-11 07:19:43 +00:00
|
|
|
if (isset($_POST['ssl_ipandport']) && ! is_array($_POST['ssl_ipandport'])) {
|
2012-12-02 14:16:22 +00:00
|
|
|
$_POST['ssl_ipandport'] = unserialize($_POST['ssl_ipandport']);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2012-12-02 14:16:22 +00:00
|
|
|
|
|
|
|
// Verify SSL-Ports
|
2013-09-30 10:12:04 +00:00
|
|
|
if (isset($_POST['ssl_ipandport']) && is_array($_POST['ssl_ipandport'])) {
|
|
|
|
foreach ($_POST['ssl_ipandport'] as $ssl_ipandport) {
|
2016-04-11 07:19:43 +00:00
|
|
|
if (trim($ssl_ipandport) == "")
|
|
|
|
continue;
|
|
|
|
// fix if no ssl-ip/port is checked
|
|
|
|
if (trim($ssl_ipandport) < 1)
|
|
|
|
continue;
|
2012-12-02 14:16:22 +00:00
|
|
|
$ssl_ipandport = intval($ssl_ipandport);
|
2013-11-13 14:39:20 +00:00
|
|
|
$ssl_ipandport_check_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `id` = :id " . $additional_ip_condition);
|
2013-11-13 14:39:20 +00:00
|
|
|
$ip_params = null;
|
2016-04-11 07:19:43 +00:00
|
|
|
$ip_params = array_merge(array(
|
|
|
|
'id' => $ssl_ipandport
|
|
|
|
), $aip_param);
|
2013-11-13 14:39:20 +00:00
|
|
|
$ssl_ipandport_check = Database::pexecute_first($ssl_ipandport_check_stmt, $ip_params);
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (! isset($ssl_ipandport_check['id']) || $ssl_ipandport_check['id'] == '0' || $ssl_ipandport_check['id'] != $ssl_ipandport) {
|
2012-12-02 14:16:22 +00:00
|
|
|
standard_error('ipportdoesntexist');
|
2013-09-30 10:12:04 +00:00
|
|
|
} else {
|
2012-12-02 14:16:22 +00:00
|
|
|
$ssl_ipandports[] = $ssl_ipandport;
|
|
|
|
}
|
|
|
|
}
|
2016-10-07 09:48:13 +00:00
|
|
|
|
2017-08-24 11:21:21 +00:00
|
|
|
$http2 = isset($_POST['http2']) && (int)$_POST['http2'] == 1 ? 1 : 0;
|
|
|
|
|
2016-10-07 09:48:13 +00:00
|
|
|
// HSTS
|
|
|
|
$hsts_maxage = isset($_POST['hsts_maxage']) ? (int)$_POST['hsts_maxage'] : 0;
|
|
|
|
$hsts_sub = isset($_POST['hsts_sub']) && (int)$_POST['hsts_sub'] == 1 ? 1 : 0;
|
|
|
|
$hsts_preload = isset($_POST['hsts_preload']) && (int)$_POST['hsts_preload'] == 1 ? 1 : 0;
|
|
|
|
|
2017-04-11 15:09:34 +00:00
|
|
|
// OCSP stapling
|
|
|
|
$ocsp_stapling = isset($_POST['ocsp_stapling']) && (int)$_POST['ocsp_stapling'] == 1 ? 1 : 0;
|
|
|
|
|
2013-09-30 10:12:04 +00:00
|
|
|
} else {
|
2013-11-21 07:01:43 +00:00
|
|
|
$ssl_redirect = 0;
|
2016-01-30 13:34:26 +00:00
|
|
|
$letsencrypt = 0;
|
2017-08-24 11:21:21 +00:00
|
|
|
$http2 = 0;
|
2013-09-30 10:12:04 +00:00
|
|
|
// we need this for the serialize
|
|
|
|
// if ssl is disabled or no ssl-ip/port exists
|
2016-04-11 07:19:43 +00:00
|
|
|
$ssl_ipandports[] = - 1;
|
2016-10-07 09:48:13 +00:00
|
|
|
|
|
|
|
// HSTS
|
|
|
|
$hsts_maxage = 0;
|
|
|
|
$hsts_sub = 0;
|
|
|
|
$hsts_preload = 0;
|
2017-04-11 15:09:34 +00:00
|
|
|
|
|
|
|
// OCSP stapling
|
|
|
|
$ocsp_stapling = 0;
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2013-09-30 10:12:04 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$ssl_redirect = 0;
|
2016-01-30 13:34:26 +00:00
|
|
|
$letsencrypt = 0;
|
2017-08-24 11:21:21 +00:00
|
|
|
$http2 = 0;
|
2013-09-30 10:12:04 +00:00
|
|
|
// we need this for the serialize
|
|
|
|
// if ssl is disabled or no ssl-ip/port exists
|
2016-04-11 07:19:43 +00:00
|
|
|
$ssl_ipandports[] = - 1;
|
2016-10-07 09:48:13 +00:00
|
|
|
|
|
|
|
// HSTS
|
|
|
|
$hsts_maxage = 0;
|
|
|
|
$hsts_sub = 0;
|
|
|
|
$hsts_preload = 0;
|
2017-04-11 15:09:34 +00:00
|
|
|
|
|
|
|
// OCSP stapling
|
|
|
|
$ocsp_stapling = 0;
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2016-01-30 13:46:00 +00:00
|
|
|
// We can't enable let's encrypt for wildcard - domains
|
2016-02-16 07:51:36 +00:00
|
|
|
if ($serveraliasoption == '0' && $letsencrypt == '1') {
|
2016-04-11 07:19:43 +00:00
|
|
|
standard_error('nowildcardwithletsencrypt');
|
2016-01-30 13:46:00 +00:00
|
|
|
}
|
|
|
|
|
2016-02-16 13:31:07 +00:00
|
|
|
// Temporarily deactivate ssl_redirect until Let's Encrypt certificate was generated
|
|
|
|
if ($ssl_redirect > 0 && $letsencrypt == 1) {
|
|
|
|
$ssl_redirect = 2;
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (! preg_match('/^https?\:\/\//', $documentroot)) {
|
2013-11-13 14:39:20 +00:00
|
|
|
if (strstr($documentroot, ":") !== false) {
|
2010-05-31 08:28:12 +00:00
|
|
|
standard_error('pathmaynotcontaincolon');
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-05-31 08:28:12 +00:00
|
|
|
$documentroot = makeCorrectDir($documentroot);
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$domain_check_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `domain` FROM `" . TABLE_PANEL_DOMAINS . "`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `domain` = :domain");
|
|
|
|
$domain_check = Database::pexecute_first($domain_check_stmt, array(
|
|
|
|
'domain' => strtolower($domain)
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$aliasdomain_check = array(
|
|
|
|
'id' => 0
|
|
|
|
);
|
|
|
|
|
2013-09-29 13:08:45 +00:00
|
|
|
if ($aliasdomain != 0) {
|
2012-12-02 14:16:22 +00:00
|
|
|
// Overwrite given ipandports with these of the "main" domain
|
|
|
|
$ipandports = array();
|
2014-12-22 12:37:35 +00:00
|
|
|
$ssl_ipandports = array();
|
2013-11-13 14:39:20 +00:00
|
|
|
$origipresult_stmt = Database::prepare("
|
2016-04-11 07:19:43 +00:00
|
|
|
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");
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($origip = $origipresult_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$_origip_tmp = Database::pexecute_first($ipdata_stmt, array(
|
|
|
|
'ipid' => $origip['id_ipandports']
|
|
|
|
));
|
2014-12-22 12:37:35 +00:00
|
|
|
if ($_origip_tmp['ssl'] == 0) {
|
|
|
|
$ipandports[] = $origip['id_ipandports'];
|
|
|
|
} else {
|
|
|
|
$ssl_ipandports[] = $origip['id_ipandports'];
|
|
|
|
}
|
2012-12-02 14:16:22 +00:00
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2014-12-22 13:14:53 +00:00
|
|
|
if (count($ssl_ipandports) == 0) {
|
|
|
|
// we need this for the serialize
|
|
|
|
// if ssl is disabled or no ssl-ip/port exists
|
2016-04-11 07:19:43 +00:00
|
|
|
$ssl_ipandports[] = - 1;
|
2014-12-22 13:14:53 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$aliasdomain_check_stmt = Database::prepare("
|
|
|
|
SELECT `d`.`id` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
|
|
|
|
WHERE `d`.`customerid` = :customerid
|
|
|
|
AND `d`.`aliasdomain` IS NULL AND `d`.`id` <> `c`.`standardsubdomain`
|
|
|
|
AND `c`.`customerid` = :customerid
|
2016-04-11 07:19:43 +00:00
|
|
|
AND `d`.`id` = :aliasdomainid");
|
|
|
|
$alias_params = array(
|
|
|
|
'customerid' => $customerid,
|
|
|
|
'aliasdomainid' => $aliasdomain
|
2013-11-13 14:39:20 +00:00
|
|
|
);
|
|
|
|
$aliasdomain_check = Database::pexecute_first($aliasdomain_check_stmt, $alias_params);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if (count($ipandports) == 0) {
|
2012-12-02 14:16:22 +00:00
|
|
|
standard_error('noipportgiven');
|
|
|
|
}
|
2017-01-16 07:43:54 +00:00
|
|
|
|
|
|
|
if ($phpenabled != '1') {
|
2016-11-13 13:41:39 +00:00
|
|
|
$phpenabled = '0';
|
|
|
|
}
|
2012-12-02 14:16:22 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($openbasedir != '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$openbasedir = '0';
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($speciallogfile != '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$speciallogfile = '0';
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($isbinddomain != '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$isbinddomain = '0';
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($isemaildomain != '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$isemaildomain = '0';
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($email_only == '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$isemaildomain = '1';
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$email_only = '0';
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($subcanemaildomain != '1' && $subcanemaildomain != '2' && $subcanemaildomain != '3') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$subcanemaildomain = '0';
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($dkim != '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$dkim = '0';
|
|
|
|
}
|
|
|
|
|
2013-10-14 07:50:55 +00:00
|
|
|
if ($serveraliasoption != '1' && $serveraliasoption != '2') {
|
|
|
|
$serveraliasoption = '0';
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($caneditdomain != '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$caneditdomain = '0';
|
|
|
|
}
|
2011-06-16 18:54:54 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($issubof <= '0') {
|
2010-08-06 05:43:28 +00:00
|
|
|
$issubof = '0';
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($domain == '') {
|
2016-04-11 07:19:43 +00:00
|
|
|
standard_error(array(
|
|
|
|
'stringisempty',
|
|
|
|
'mydomain'
|
|
|
|
));
|
|
|
|
} elseif ($documentroot == '') {
|
|
|
|
standard_error(array(
|
|
|
|
'stringisempty',
|
|
|
|
'mydocumentroot'
|
|
|
|
));
|
|
|
|
} elseif ($customerid == 0) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('adduserfirst');
|
2016-04-11 07:19:43 +00:00
|
|
|
} elseif (strtolower($domain_check['domain']) == strtolower($domain)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('domainalreadyexists', $idna_convert->decode($domain));
|
2016-04-11 07:19:43 +00:00
|
|
|
} elseif ($aliasdomain_check['id'] != $aliasdomain) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('domainisaliasorothercustomer');
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$params = array(
|
|
|
|
'page' => $page,
|
|
|
|
'action' => $action,
|
|
|
|
'domain' => $domain,
|
|
|
|
'customerid' => $customerid,
|
|
|
|
'adminid' => $adminid,
|
|
|
|
'documentroot' => $documentroot,
|
|
|
|
'alias' => $aliasdomain,
|
|
|
|
'isbinddomain' => $isbinddomain,
|
|
|
|
'isemaildomain' => $isemaildomain,
|
|
|
|
'email_only' => $email_only,
|
|
|
|
'subcanemaildomain' => $subcanemaildomain,
|
|
|
|
'caneditdomain' => $caneditdomain,
|
|
|
|
'zonefile' => $zonefile,
|
|
|
|
'dkim' => $dkim,
|
|
|
|
'speciallogfile' => $speciallogfile,
|
2013-10-14 07:50:55 +00:00
|
|
|
'selectserveralias' => $serveraliasoption,
|
2013-05-08 14:34:04 +00:00
|
|
|
'ipandport' => serialize($ipandports),
|
2010-01-27 08:54:31 +00:00
|
|
|
'ssl_redirect' => $ssl_redirect,
|
2013-05-08 14:34:04 +00:00
|
|
|
'ssl_ipandport' => serialize($ssl_ipandports),
|
2016-11-13 13:41:39 +00:00
|
|
|
'phpenabled' => $phpenabled,
|
2010-01-27 08:54:31 +00:00
|
|
|
'openbasedir' => $openbasedir,
|
|
|
|
'phpsettingid' => $phpsettingid,
|
|
|
|
'mod_fcgid_starter' => $mod_fcgid_starter,
|
|
|
|
'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests,
|
|
|
|
'specialsettings' => $specialsettings,
|
2010-08-06 05:43:28 +00:00
|
|
|
'registration_date' => $registration_date,
|
2016-03-10 11:12:19 +00:00
|
|
|
'termination_date' => $termination_date,
|
2016-01-30 13:34:26 +00:00
|
|
|
'issubof' => $issubof,
|
2016-10-07 09:48:13 +00:00
|
|
|
'letsencrypt' => $letsencrypt,
|
2017-08-24 11:21:21 +00:00
|
|
|
'http2' => $http2,
|
2016-11-03 09:52:33 +00:00
|
|
|
'hsts_maxage' => $hsts_maxage,
|
2016-10-07 09:48:13 +00:00
|
|
|
'hsts_sub' => $hsts_sub,
|
2017-04-11 15:09:34 +00:00
|
|
|
'hsts_preload' => $hsts_preload,
|
2017-08-24 11:21:21 +00:00
|
|
|
'ocsp_stapling' => $ocsp_stapling
|
2010-01-27 08:54:31 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$security_questions = array(
|
2011-06-16 18:54:54 +00:00
|
|
|
'reallydisablesecuritysetting' => ($openbasedir == '0' && $userinfo['change_serversettings'] == '1'),
|
2016-04-11 07:19:43 +00:00
|
|
|
'reallydocrootoutofcustomerroot' => (substr($documentroot, 0, strlen($customer['documentroot'])) != $customer['documentroot'] && ! preg_match('/^https?\:\/\//', $documentroot))
|
2010-01-27 08:54:31 +00:00
|
|
|
);
|
2010-09-20 06:07:54 +00:00
|
|
|
$question_nr = 1;
|
2013-11-13 14:39:20 +00:00
|
|
|
foreach ($security_questions as $question_name => $question_launch) {
|
|
|
|
if ($question_launch !== false) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$params[$question_name] = $question_name;
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (! isset($_POST[$question_name]) || $_POST[$question_name] != $question_name) {
|
2010-09-20 06:07:54 +00:00
|
|
|
ask_yesno('admin_domain_' . $question_name, $filename, $params, $question_nr);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
2016-04-11 07:19:43 +00:00
|
|
|
$question_nr ++;
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2013-10-14 07:50:55 +00:00
|
|
|
$wwwserveralias = ($serveraliasoption == '1') ? '1' : '0';
|
|
|
|
$iswildcarddomain = ($serveraliasoption == '0') ? '1' : '0';
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$ins_data = array(
|
|
|
|
'domain' => $domain,
|
|
|
|
'customerid' => $customerid,
|
|
|
|
'adminid' => $adminid,
|
|
|
|
'documentroot' => $documentroot,
|
|
|
|
'aliasdomain' => ($aliasdomain != 0 ? $aliasdomain : null),
|
|
|
|
'zonefile' => $zonefile,
|
|
|
|
'dkim' => $dkim,
|
|
|
|
'wwwserveralias' => $wwwserveralias,
|
|
|
|
'iswildcarddomain' => $iswildcarddomain,
|
|
|
|
'isbinddomain' => $isbinddomain,
|
|
|
|
'isemaildomain' => $isemaildomain,
|
|
|
|
'email_only' => $email_only,
|
|
|
|
'subcanemaildomain' => $subcanemaildomain,
|
|
|
|
'caneditdomain' => $caneditdomain,
|
2016-11-13 13:41:39 +00:00
|
|
|
'phpenabled' => $phpenabled,
|
2013-11-13 14:39:20 +00:00
|
|
|
'openbasedir' => $openbasedir,
|
|
|
|
'speciallogfile' => $speciallogfile,
|
|
|
|
'specialsettings' => $specialsettings,
|
|
|
|
'ssl_redirect' => $ssl_redirect,
|
|
|
|
'add_date' => time(),
|
|
|
|
'registration_date' => $registration_date,
|
2016-04-11 07:19:43 +00:00
|
|
|
'termination_date' => $termination_date,
|
2013-11-13 14:39:20 +00:00
|
|
|
'phpsettingid' => $phpsettingid,
|
|
|
|
'mod_fcgid_starter' => $mod_fcgid_starter,
|
|
|
|
'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests,
|
2016-01-30 13:34:26 +00:00
|
|
|
'ismainbutsubto' => $issubof,
|
2016-10-07 09:48:13 +00:00
|
|
|
'letsencrypt' => $letsencrypt,
|
2017-08-24 11:21:21 +00:00
|
|
|
'http2' => $http2,
|
2016-10-07 09:48:13 +00:00
|
|
|
'hsts' => $hsts_maxage,
|
|
|
|
'hsts_sub' => $hsts_sub,
|
2017-04-11 15:09:34 +00:00
|
|
|
'hsts_preload' => $hsts_preload,
|
2017-08-24 11:21:21 +00:00
|
|
|
'ocsp_stapling' => $ocsp_stapling
|
2013-11-13 14:39:20 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$ins_stmt = Database::prepare("
|
|
|
|
INSERT INTO `" . TABLE_PANEL_DOMAINS . "` SET
|
|
|
|
`domain` = :domain,
|
|
|
|
`customerid` = :customerid,
|
|
|
|
`adminid` = :adminid,
|
|
|
|
`documentroot` = :documentroot,
|
|
|
|
`aliasdomain` = :aliasdomain,
|
|
|
|
`zonefile` = :zonefile,
|
|
|
|
`dkim` = :dkim,
|
2014-03-05 07:11:56 +00:00
|
|
|
`dkim_id` = '0',
|
|
|
|
`dkim_privkey` = '',
|
|
|
|
`dkim_pubkey` = '',
|
2013-11-13 14:39:20 +00:00
|
|
|
`wwwserveralias` = :wwwserveralias,
|
|
|
|
`iswildcarddomain` = :iswildcarddomain,
|
|
|
|
`isbinddomain` = :isbinddomain,
|
|
|
|
`isemaildomain` = :isemaildomain,
|
|
|
|
`email_only` = :email_only,
|
|
|
|
`subcanemaildomain` = :subcanemaildomain,
|
|
|
|
`caneditdomain` = :caneditdomain,
|
2016-11-13 13:41:39 +00:00
|
|
|
`phpenabled` = :phpenabled,
|
2013-11-13 14:39:20 +00:00
|
|
|
`openbasedir` = :openbasedir,
|
|
|
|
`speciallogfile` = :speciallogfile,
|
|
|
|
`specialsettings` = :specialsettings,
|
|
|
|
`ssl_redirect` = :ssl_redirect,
|
|
|
|
`add_date` = :add_date,
|
2013-11-13 16:41:39 +00:00
|
|
|
`registration_date` = :registration_date,
|
2016-10-07 09:48:13 +00:00
|
|
|
`termination_date` = :termination_date,
|
2013-11-13 14:39:20 +00:00
|
|
|
`phpsettingid` = :phpsettingid,
|
|
|
|
`mod_fcgid_starter` = :mod_fcgid_starter,
|
2013-11-13 16:41:39 +00:00
|
|
|
`mod_fcgid_maxrequests` = :mod_fcgid_maxrequests,
|
2016-01-30 13:34:26 +00:00
|
|
|
`ismainbutsubto` = :ismainbutsubto,
|
2016-10-07 09:48:13 +00:00
|
|
|
`letsencrypt` = :letsencrypt,
|
2017-08-24 11:21:21 +00:00
|
|
|
`http2` = :http2,
|
2016-10-07 09:48:13 +00:00
|
|
|
`hsts` = :hsts,
|
|
|
|
`hsts_sub` = :hsts_sub,
|
2017-04-11 15:09:34 +00:00
|
|
|
`hsts_preload` = :hsts_preload,
|
|
|
|
`ocsp_stapling` = :ocsp_stapling
|
2012-12-02 14:16:22 +00:00
|
|
|
");
|
2013-11-13 14:39:20 +00:00
|
|
|
Database::pexecute($ins_stmt, $ins_data);
|
|
|
|
$domainid = Database::lastInsertId();
|
|
|
|
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_ADMINS . "` SET `domains_used` = `domains_used` + 1
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `adminid` = :adminid");
|
|
|
|
Database::pexecute($upd_stmt, array(
|
|
|
|
'adminid' => $adminid
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2014-12-22 13:14:53 +00:00
|
|
|
$ins_stmt = Database::prepare("
|
|
|
|
INSERT INTO `" . TABLE_DOMAINTOIP . "` SET
|
|
|
|
`id_domain` = :domainid,
|
|
|
|
`id_ipandports` = :ipandportsid
|
|
|
|
");
|
|
|
|
|
2012-12-02 14:16:22 +00:00
|
|
|
foreach ($ipandports as $ipportid) {
|
2013-11-13 14:39:20 +00:00
|
|
|
$ins_data = array(
|
|
|
|
'domainid' => $domainid,
|
|
|
|
'ipandportsid' => $ipportid
|
|
|
|
);
|
|
|
|
Database::pexecute($ins_stmt, $ins_data);
|
2012-12-02 14:16:22 +00:00
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2012-12-02 14:16:22 +00:00
|
|
|
foreach ($ssl_ipandports as $ssl_ipportid) {
|
2013-09-30 10:12:04 +00:00
|
|
|
if ($ssl_ipportid > 0) {
|
2013-11-13 14:39:20 +00:00
|
|
|
$ins_data = array(
|
|
|
|
'domainid' => $domainid,
|
|
|
|
'ipandportsid' => $ssl_ipportid
|
|
|
|
);
|
|
|
|
Database::pexecute($ins_stmt, $ins_data);
|
2013-09-30 10:12:04 +00:00
|
|
|
}
|
2012-12-02 14:16:22 +00:00
|
|
|
}
|
2016-05-16 14:32:07 +00:00
|
|
|
|
|
|
|
triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $log);
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "added domain '" . $domain . "'");
|
|
|
|
inserttask('1');
|
2011-12-06 14:43:34 +00:00
|
|
|
|
2013-03-29 19:10:37 +00:00
|
|
|
// Using nameserver, insert a task which rebuilds the server config
|
|
|
|
inserttask('4');
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
redirectTo($filename, array(
|
|
|
|
'page' => $page,
|
|
|
|
's' => $s
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$customers = makeoption($lng['panel']['please_choose'], 0, 0, true);
|
2013-11-13 14:39:20 +00:00
|
|
|
$result_customers_stmt = Database::prepare("
|
|
|
|
SELECT `customerid`, `loginname`, `name`, `firstname`, `company`
|
2016-04-11 07:19:43 +00:00
|
|
|
FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int) $userinfo['adminid'] . "' ") . " ORDER BY COALESCE(NULLIF(`name`,''), `company`) ASC");
|
2013-11-13 14:39:20 +00:00
|
|
|
$params = array();
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
Database::pexecute($result_customers_stmt, $params);
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$customers .= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$admins = '';
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($userinfo['customers_see_all'] == '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$result_admins_stmt = Database::query("
|
|
|
|
SELECT `adminid`, `loginname`, `name`
|
|
|
|
FROM `" . TABLE_PANEL_ADMINS . "`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `domains_used` < `domains` OR `domains` = '-1' ORDER BY `name` ASC");
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_admin = $result_admins_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$admins .= makeoption(getCorrectFullUserDetails($row_admin) . ' (' . $row_admin['loginname'] . ')', $row_admin['adminid'], $userinfo['adminid']);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($userinfo['ip'] == "-1") {
|
|
|
|
$result_ipsandports_stmt = Database::query("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='0' ORDER BY `ip`, `port` ASC
|
|
|
|
");
|
|
|
|
$result_ssl_ipsandports_stmt = Database::query("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='1' ORDER BY `ip`, `port` ASC
|
|
|
|
");
|
|
|
|
} else {
|
|
|
|
$admin_ip_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid ORDER BY `ip`, `port` ASC
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
$admin_ip = Database::pexecute_first($admin_ip_stmt, array(
|
|
|
|
'ipid' => $userinfo['ip']
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$result_ipsandports_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='0' AND `ip` = :ipid ORDER BY `ip`, `port` ASC
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($result_ipsandports_stmt, array(
|
|
|
|
'ipid' => $admin_ip['ip']
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$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
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($result_ssl_ipsandports_stmt, array(
|
|
|
|
'ipid' => $admin_ip['ip']
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2012-12-02 14:16:22 +00:00
|
|
|
// Build array holding all IPs and Ports available to this admin
|
|
|
|
$ipsandports = array();
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_ipandport = $result_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
|
|
|
|
if (filter_var($row_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$row_ipandport['ip'] = '[' . $row_ipandport['ip'] . ']';
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
$ipsandports[] = array(
|
|
|
|
'label' => $row_ipandport['ip'] . ':' . $row_ipandport['port'] . '<br />',
|
|
|
|
'value' => $row_ipandport['id']
|
|
|
|
);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2012-12-02 14:16:22 +00:00
|
|
|
$ssl_ipsandports = array();
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_ssl_ipandport = $result_ssl_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
|
|
|
|
if (filter_var($row_ssl_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$row_ssl_ipandport['ip'] = '[' . $row_ssl_ipandport['ip'] . ']';
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
$ssl_ipsandports[] = array(
|
|
|
|
'label' => $row_ssl_ipandport['ip'] . ':' . $row_ssl_ipandport['port'] . '<br />',
|
|
|
|
'value' => $row_ssl_ipandport['id']
|
|
|
|
);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$standardsubdomains = array();
|
2013-11-13 14:39:20 +00:00
|
|
|
$result_standardsubdomains_stmt = Database::query("
|
|
|
|
SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` WHERE `d`.`id` = `c`.`standardsubdomain`
|
|
|
|
");
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_standardsubdomain = $result_standardsubdomains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
$standardsubdomains[] = $row_standardsubdomain['id'];
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if (count($standardsubdomains) > 0) {
|
|
|
|
$standardsubdomains = " AND `d`.`id` NOT IN (" . join(',', $standardsubdomains) . ") ";
|
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$standardsubdomains = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$domains = makeoption($lng['domains']['noaliasdomain'], 0, NULL, true);
|
2013-11-13 14:39:20 +00:00
|
|
|
$result_domains_stmt = Database::prepare("
|
|
|
|
SELECT `d`.`id`, `d`.`domain`, `c`.`loginname` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = 0" . $standardsubdomains . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . "
|
2013-11-13 14:39:20 +00:00
|
|
|
AND `d`.`customerid`=`c`.`customerid` ORDER BY `loginname`, `domain` ASC
|
|
|
|
");
|
|
|
|
$params = array();
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
Database::pexecute($result_domains_stmt, $params);
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$domains .= makeoption($idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')', $row_domain['id']);
|
2010-08-06 08:46:55 +00:00
|
|
|
}
|
2011-06-16 18:54:54 +00:00
|
|
|
|
2010-08-06 08:46:55 +00:00
|
|
|
$subtodomains = makeoption($lng['domains']['nosubtomaindomain'], 0, NULL, true);
|
2013-11-13 14:39:20 +00:00
|
|
|
$result_domains_stmt = Database::prepare("
|
|
|
|
SELECT `d`.`id`, `d`.`domain`, `c`.`loginname` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
|
2016-04-11 07:19:43 +00:00
|
|
|
WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = 0 AND `d`.`ismainbutsubto` = 0 " . $standardsubdomains . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . "
|
2013-11-13 14:39:20 +00:00
|
|
|
AND `d`.`customerid`=`c`.`customerid` ORDER BY `loginname`, `domain` ASC
|
|
|
|
");
|
|
|
|
// params from above still valid
|
|
|
|
Database::pexecute($result_domains_stmt, $params);
|
2010-08-06 08:46:55 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$subtodomains .= makeoption($idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')', $row_domain['id']);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$phpconfigs = '';
|
2013-11-13 14:39:20 +00:00
|
|
|
$configs = Database::query("SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "`");
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
|
|
|
$phpconfigs .= makeoption($row['description'], $row['id'], Settings::Get('phpfpm.defaultini'), true, true);
|
2013-07-05 08:54:52 +00:00
|
|
|
} else {
|
2016-04-11 07:19:43 +00:00
|
|
|
$phpconfigs .= makeoption($row['description'], $row['id'], Settings::Get('system.mod_fcgid_defaultini'), true, true);
|
2013-07-05 08:54:52 +00:00
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2013-10-14 07:50:55 +00:00
|
|
|
// create serveralias options
|
|
|
|
$serveraliasoptions = "";
|
|
|
|
$serveraliasoptions .= makeoption($lng['domains']['serveraliasoption_wildcard'], '0', '0', true, true);
|
|
|
|
$serveraliasoptions .= makeoption($lng['domains']['serveraliasoption_www'], '1', '0', true, true);
|
|
|
|
$serveraliasoptions .= makeoption($lng['domains']['serveraliasoption_none'], '2', '0', true, true);
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$subcanemaildomain = makeoption($lng['admin']['subcanemaildomain']['never'], '0', '0', true, true);
|
2016-04-11 07:19:43 +00:00
|
|
|
$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);
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$add_date = date('Y-m-d');
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
$domain_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_add.php';
|
2011-02-08 11:53:24 +00:00
|
|
|
$domain_add_form = htmlform::genHTMLForm($domain_add_data);
|
|
|
|
|
|
|
|
$title = $domain_add_data['domain_add']['title'];
|
|
|
|
$image = $domain_add_data['domain_add']['image'];
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
eval("echo \"" . getTemplate("domains/domains_add") . "\";");
|
|
|
|
}
|
|
|
|
}
|
2016-04-11 07:19:43 +00:00
|
|
|
} elseif ($action == 'edit' && $id != 0) {
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$result_stmt = Database::prepare("
|
2016-10-31 10:18:40 +00:00
|
|
|
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")
|
|
|
|
);
|
2016-04-11 07:19:43 +00:00
|
|
|
$params = array(
|
|
|
|
'id' => $id
|
2013-11-13 14:39:20 +00:00
|
|
|
);
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
$result = Database::pexecute_first($result_stmt, $params);
|
|
|
|
|
|
|
|
if ($result['domain'] != '') {
|
|
|
|
|
2013-11-13 15:27:27 +00:00
|
|
|
$subdomains_stmt = Database::prepare("
|
2013-11-13 14:39:20 +00:00
|
|
|
SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE
|
|
|
|
`parentdomainid` = :resultid
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
$subdomains = Database::pexecute_first($subdomains_stmt, array(
|
|
|
|
'resultid' => $result['id']
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
$subdomains = $subdomains['count'];
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$alias_check_stmt = Database::prepare("
|
|
|
|
SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE
|
|
|
|
`aliasdomain` = :resultid
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
$alias_check = Database::pexecute_first($alias_check_stmt, array(
|
|
|
|
'resultid' => $result['id']
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
$alias_check = $alias_check['count'];
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$domain_emails_result_stmt = Database::prepare("
|
|
|
|
SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders`
|
2013-11-13 15:55:54 +00:00
|
|
|
FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid` = :customerid AND `domainid` = :id
|
2013-11-13 14:39:20 +00:00
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($domain_emails_result_stmt, array(
|
|
|
|
'customerid' => $result['customerid'],
|
|
|
|
'id' => $result['id']
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$emails = Database::num_rows();
|
2010-01-27 08:54:31 +00:00
|
|
|
$email_forwarders = 0;
|
|
|
|
$email_accounts = 0;
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($domain_emails_row = $domain_emails_result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
|
|
|
|
if ($domain_emails_row['destination'] != '') {
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$domain_emails_row['destination'] = explode(' ', makeCorrectDestination($domain_emails_row['destination']));
|
2016-04-11 07:19:43 +00:00
|
|
|
$email_forwarders += count($domain_emails_row['destination']);
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if (in_array($domain_emails_row['email_full'], $domain_emails_row['destination'])) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$email_forwarders -= 1;
|
|
|
|
$email_accounts ++;
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$ipsresult_stmt = Database::prepare("
|
|
|
|
SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :id
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($ipsresult_stmt, array(
|
|
|
|
'id' => $result['id']
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2012-12-02 14:16:22 +00:00
|
|
|
$usedips = array();
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($ipsresultrow = $ipsresult_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2012-12-02 14:16:22 +00:00
|
|
|
$usedips[] = $ipsresultrow['id_ipandports'];
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$customer_stmt = Database::prepare("
|
|
|
|
SELECT * FROM " . TABLE_PANEL_CUSTOMERS . " WHERE `customerid` = :customerid
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
$customer = Database::pexecute_first($customer_stmt, array(
|
|
|
|
'customerid' => $result['customerid']
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
$customerid = - 1;
|
2013-11-13 16:52:00 +00:00
|
|
|
if (isset($_POST['customerid'])) {
|
|
|
|
$customerid = intval($_POST['customerid']);
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($customerid > 0 && $customerid != $result['customerid'] && Settings::Get('panel.allow_domain_change_customer') == '1') {
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$customer_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`
|
|
|
|
WHERE `customerid` = :customerid
|
|
|
|
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' )
|
2016-04-11 07:19:43 +00:00
|
|
|
AND (`email_accounts_used` + :accounts <= `email_accounts` OR `email_accounts` = '-1' ) " . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid"));
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$params = array(
|
|
|
|
'customerid' => $customerid,
|
|
|
|
'subdomains' => $subdomains,
|
|
|
|
'emails' => $emails,
|
|
|
|
'forwarders' => $email_forwarders,
|
|
|
|
'accounts' => $email_accounts
|
|
|
|
);
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$customer = Database::pexecute_first($customer_stmt, $params);
|
2016-04-11 07:19:43 +00:00
|
|
|
if (empty($customer) || $customer['customerid'] != $customerid) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('customerdoesntexist');
|
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$customerid = $result['customerid'];
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$customer_stmt = Database::prepare("
|
|
|
|
SELECT * FROM " . TABLE_PANEL_ADMINS . " WHERE `adminid` = :adminid
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
$admin = Database::pexecute_first($customer_stmt, array(
|
|
|
|
'adminid' => $result['adminid']
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($userinfo['customers_see_all'] == '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
$adminid = - 1;
|
2013-11-13 16:52:00 +00:00
|
|
|
if (isset($_POST['adminid'])) {
|
|
|
|
$adminid = intval($_POST['adminid']);
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($adminid > 0 && $adminid != $result['adminid'] && Settings::Get('panel.allow_domain_change_admin') == '1') {
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$admin_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_ADMINS . "`
|
|
|
|
WHERE `adminid` = :adminid AND ( `domains_used` < `domains` OR `domains` = '-1' )
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
$admin = Database::pexecute_first($admin_stmt, array(
|
|
|
|
'adminid' => $adminid
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (empty($admin) || $admin['adminid'] != $adminid) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('admindoesntexist');
|
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$adminid = $result['adminid'];
|
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$adminid = $result['adminid'];
|
|
|
|
}
|
|
|
|
|
2016-10-25 10:24:57 +00:00
|
|
|
$aliasdomain = isset($_POST['alias']) ? intval($_POST['alias']) : 0;
|
2010-08-06 05:43:28 +00:00
|
|
|
$issubof = intval($_POST['issubof']);
|
2010-01-27 08:54:31 +00:00
|
|
|
$subcanemaildomain = intval($_POST['subcanemaildomain']);
|
2013-02-28 08:31:33 +00:00
|
|
|
$caneditdomain = isset($_POST['caneditdomain']) ? intval($_POST['caneditdomain']) : 0;
|
2011-05-01 11:27:24 +00:00
|
|
|
$registration_date = trim($_POST['registration_date']);
|
2016-04-11 07:19:43 +00:00
|
|
|
$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',
|
|
|
|
''
|
|
|
|
));
|
2016-05-01 16:01:05 +00:00
|
|
|
if ($registration_date == '0000-00-00') {
|
|
|
|
$registration_date = null;
|
|
|
|
}
|
2016-02-16 13:31:07 +00:00
|
|
|
$termination_date = trim($_POST['termination_date']);
|
2016-04-11 07:19:43 +00:00
|
|
|
$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',
|
|
|
|
''
|
|
|
|
));
|
2016-05-01 16:01:05 +00:00
|
|
|
if ($termination_date == '0000-00-00') {
|
|
|
|
$termination_date = null;
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$isemaildomain = 0;
|
2013-11-13 14:39:20 +00:00
|
|
|
if (isset($_POST['isemaildomain'])) {
|
|
|
|
$isemaildomain = intval($_POST['isemaildomain']);
|
|
|
|
}
|
2011-06-16 18:54:54 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$email_only = 0;
|
2013-11-13 14:39:20 +00:00
|
|
|
if (isset($_POST['email_only'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$email_only = intval($_POST['email_only']);
|
2013-11-13 14:39:20 +00:00
|
|
|
}
|
2011-06-16 18:54:54 +00:00
|
|
|
|
2013-10-14 07:50:55 +00:00
|
|
|
$serveraliasoption = '2';
|
|
|
|
if ($result['iswildcarddomain'] == '1') {
|
|
|
|
$serveraliasoption = '0';
|
|
|
|
} elseif ($result['wwwserveralias'] == '1') {
|
|
|
|
$serveraliasoption = '1';
|
|
|
|
}
|
|
|
|
if (isset($_POST['selectserveralias'])) {
|
|
|
|
$serveraliasoption = intval($_POST['selectserveralias']);
|
|
|
|
}
|
2011-06-16 18:54:54 +00:00
|
|
|
|
2012-03-08 14:11:25 +00:00
|
|
|
$speciallogfile = 0;
|
2016-04-11 07:19:43 +00:00
|
|
|
if (isset($_POST['speciallogfile']))
|
2012-03-08 14:11:25 +00:00
|
|
|
$speciallogfile = intval($_POST['speciallogfile']);
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($userinfo['change_serversettings'] == '1') {
|
2013-02-25 10:18:12 +00:00
|
|
|
$isbinddomain = $result['isbinddomain'];
|
|
|
|
$zonefile = $result['zonefile'];
|
2013-12-15 10:47:23 +00:00
|
|
|
if (Settings::Get('system.bind_enable') == '1') {
|
2013-02-25 10:18:12 +00:00
|
|
|
if (isset($_POST['isbinddomain'])) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$isbinddomain = (int) $_POST['isbinddomain'];
|
2013-09-18 21:29:41 +00:00
|
|
|
} else {
|
2013-09-19 06:04:25 +00:00
|
|
|
$isbinddomain = 0;
|
2013-02-25 10:18:12 +00:00
|
|
|
}
|
|
|
|
$zonefile = validate($_POST['zonefile'], 'zonefile');
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
if (Settings::Get('dkim.use_dkim') == '1') {
|
2012-06-25 07:27:39 +00:00
|
|
|
$dkim = isset($_POST['dkim']) ? 1 : 0;
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$dkim = $result['dkim'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$specialsettings = validate(str_replace("\r\n", "\n", $_POST['specialsettings']), 'specialsettings', '/^[^\0]*$/');
|
2016-02-27 18:57:29 +00:00
|
|
|
$ssfs = (isset($_POST['specialsettingsforsubdomains']) && intval($_POST['specialsettingsforsubdomains']) == 1) ? 1 : 0;
|
2010-01-27 08:54:31 +00:00
|
|
|
$documentroot = validate($_POST['documentroot'], 'documentroot');
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($documentroot == '') {
|
2013-03-20 19:37:37 +00:00
|
|
|
// 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
|
2013-12-15 10:47:23 +00:00
|
|
|
if (Settings::Get('system.documentroot_use_default_value') == 1) {
|
2013-03-20 19:37:37 +00:00
|
|
|
$documentroot = makeCorrectDir($customer['documentroot'] . '/' . $result['domain']);
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2013-03-20 19:37:37 +00:00
|
|
|
$documentroot = $customer['documentroot'];
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2010-05-12 06:52:11 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (! preg_match('/^https?\:\/\//', $documentroot) && strstr($documentroot, ":") !== false) {
|
2010-05-12 06:52:11 +00:00
|
|
|
standard_error('pathmaynotcontaincolon');
|
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$isbinddomain = $result['isbinddomain'];
|
|
|
|
$zonefile = $result['zonefile'];
|
|
|
|
$dkim = $result['dkim'];
|
|
|
|
$specialsettings = $result['specialsettings'];
|
2016-02-27 18:57:29 +00:00
|
|
|
$ssfs = (empty($specialsettings) ? 0 : 1);
|
2010-01-27 08:54:31 +00:00
|
|
|
$documentroot = $result['documentroot'];
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
$speciallogverified = (isset($_POST['speciallogverified']) ? (int) $_POST['speciallogverified'] : 0);
|
2013-09-23 07:35:33 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($userinfo['caneditphpsettings'] == '1' || $userinfo['change_serversettings'] == '1') {
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2016-11-13 13:41:39 +00:00
|
|
|
$phpenabled = isset($_POST['phpenabled']) ? intval($_POST['phpenabled']) : 0;
|
2013-02-25 10:18:12 +00:00
|
|
|
$openbasedir = isset($_POST['openbasedir']) ? intval($_POST['openbasedir']) : 0;
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ((int) Settings::Get('system.mod_fcgid') == 1 || (int) Settings::Get('phpfpm.enabled') == 1) {
|
|
|
|
$phpsettingid = (int) $_POST['phpsettingid'];
|
2013-11-13 14:39:20 +00:00
|
|
|
$phpsettingid_check_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :phpid
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
$phpsettingid_check = Database::pexecute_first($phpsettingid_check_stmt, array(
|
|
|
|
'phpid' => $phpsettingid
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (! isset($phpsettingid_check['id']) || $phpsettingid_check['id'] == '0' || $phpsettingid_check['id'] != $phpsettingid) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('phpsettingidwrong');
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
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',
|
|
|
|
''
|
|
|
|
));
|
2013-07-14 09:23:52 +00:00
|
|
|
} else {
|
|
|
|
$mod_fcgid_starter = $result['mod_fcgid_starter'];
|
|
|
|
$mod_fcgid_maxrequests = $result['mod_fcgid_maxrequests'];
|
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$phpsettingid = $result['phpsettingid'];
|
|
|
|
$mod_fcgid_starter = $result['mod_fcgid_starter'];
|
|
|
|
$mod_fcgid_maxrequests = $result['mod_fcgid_maxrequests'];
|
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2016-11-13 13:41:39 +00:00
|
|
|
$phpenabled = $result['phpenabled'];
|
2010-01-27 08:54:31 +00:00
|
|
|
$openbasedir = $result['openbasedir'];
|
|
|
|
$phpsettingid = $result['phpsettingid'];
|
|
|
|
$mod_fcgid_starter = $result['mod_fcgid_starter'];
|
|
|
|
$mod_fcgid_maxrequests = $result['mod_fcgid_maxrequests'];
|
|
|
|
}
|
|
|
|
|
2013-04-29 08:02:44 +00:00
|
|
|
$ipandports = array();
|
2016-04-11 07:19:43 +00:00
|
|
|
if (isset($_POST['ipandport']) && ! is_array($_POST['ipandport'])) {
|
2012-12-02 14:16:22 +00:00
|
|
|
$_POST['ipandport'] = unserialize($_POST['ipandport']);
|
|
|
|
}
|
2013-04-29 08:02:44 +00:00
|
|
|
if (isset($_POST['ipandport']) && is_array($_POST['ipandport'])) {
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$ipandport_check_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipandport
|
|
|
|
");
|
|
|
|
foreach ($_POST['ipandport'] as $ipandport) {
|
2016-04-11 07:19:43 +00:00
|
|
|
if (trim($ipandport) == "")
|
|
|
|
continue;
|
2013-04-29 08:02:44 +00:00
|
|
|
$ipandport = intval($ipandport);
|
2016-04-11 07:19:43 +00:00
|
|
|
$ipandport_check = Database::pexecute_first($ipandport_check_stmt, array(
|
|
|
|
'ipandport' => $ipandport
|
|
|
|
));
|
|
|
|
if (! isset($ipandport_check['id']) || $ipandport_check['id'] == '0' || $ipandport_check['id'] != $ipandport) {
|
2013-04-29 08:02:44 +00:00
|
|
|
standard_error('ipportdoesntexist');
|
|
|
|
} else {
|
|
|
|
$ipandports[] = $ipandport;
|
|
|
|
}
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (Settings::Get('system.use_ssl') == '1' && isset($_POST['ssl_ipandport'])) {
|
2012-06-25 07:27:39 +00:00
|
|
|
$ssl = 1; // if ssl is set and != 0, it can only be 1
|
2011-05-18 11:18:41 +00:00
|
|
|
$ssl_redirect = 0;
|
|
|
|
if (isset($_POST['ssl_redirect'])) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$ssl_redirect = (int) $_POST['ssl_redirect'];
|
2011-05-18 11:18:41 +00:00
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2016-01-30 13:34:26 +00:00
|
|
|
$letsencrypt = 0;
|
|
|
|
if (isset($_POST['letsencrypt'])) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$letsencrypt = (int) $_POST['letsencrypt'];
|
2016-01-30 13:34:26 +00:00
|
|
|
}
|
|
|
|
|
2017-08-24 11:21:21 +00:00
|
|
|
$http2 = isset($_POST['http2']) && (int)$_POST['http2'] == 1 ? 1 : 0;
|
|
|
|
|
2016-11-03 09:52:33 +00:00
|
|
|
// HSTS
|
|
|
|
$hsts_maxage = isset($_POST['hsts_maxage']) ? (int)$_POST['hsts_maxage'] : 0;
|
|
|
|
$hsts_sub = isset($_POST['hsts_sub']) && (int)$_POST['hsts_sub'] == 1 ? 1 : 0;
|
|
|
|
$hsts_preload = isset($_POST['hsts_preload']) && (int)$_POST['hsts_preload'] == 1 ? 1 : 0;
|
|
|
|
|
2017-04-11 15:09:34 +00:00
|
|
|
// OCSP stapling
|
|
|
|
$ocsp_stapling = isset($_POST['ocsp_stapling']) && (int)$_POST['ocsp_stapling'] == 1 ? 1 : 0;
|
|
|
|
|
2012-12-02 14:16:22 +00:00
|
|
|
$ssl_ipandports = array();
|
2016-04-11 07:19:43 +00:00
|
|
|
if (isset($_POST['ssl_ipandport']) && ! is_array($_POST['ssl_ipandport'])) {
|
2012-12-02 14:16:22 +00:00
|
|
|
$_POST['ssl_ipandport'] = unserialize($_POST['ssl_ipandport']);
|
|
|
|
}
|
2013-04-29 08:02:44 +00:00
|
|
|
if (isset($_POST['ssl_ipandport']) && is_array($_POST['ssl_ipandport'])) {
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$ssl_ipandport_check_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipandport
|
|
|
|
");
|
2013-04-29 08:02:44 +00:00
|
|
|
foreach ($_POST['ssl_ipandport'] as $ssl_ipandport) {
|
2016-04-11 07:19:43 +00:00
|
|
|
if (trim($ssl_ipandport) == "")
|
|
|
|
continue;
|
|
|
|
// fix if ip/port got de-checked and it was the last one
|
|
|
|
if (trim($ssl_ipandport) < 1)
|
|
|
|
continue;
|
2012-12-02 14:16:22 +00:00
|
|
|
$ssl_ipandport = intval($ssl_ipandport);
|
2016-04-11 07:19:43 +00:00
|
|
|
$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) {
|
2012-12-02 14:16:22 +00:00
|
|
|
standard_error('ipportdoesntexist');
|
2013-04-29 08:02:44 +00:00
|
|
|
} else {
|
2012-12-02 14:16:22 +00:00
|
|
|
$ssl_ipandports[] = $ssl_ipandport;
|
|
|
|
}
|
|
|
|
}
|
2016-10-07 09:48:13 +00:00
|
|
|
|
2013-09-30 10:12:04 +00:00
|
|
|
} else {
|
2013-11-21 07:01:43 +00:00
|
|
|
$ssl_redirect = 0;
|
2016-01-30 13:34:26 +00:00
|
|
|
$letsencrypt = 0;
|
2017-08-24 11:21:21 +00:00
|
|
|
$http2 = 0;
|
2013-09-30 10:12:04 +00:00
|
|
|
// we need this for the serialize
|
|
|
|
// if ssl is disabled or no ssl-ip/port exists
|
2016-04-11 07:19:43 +00:00
|
|
|
$ssl_ipandports[] = - 1;
|
2016-10-07 09:48:13 +00:00
|
|
|
|
|
|
|
// HSTS
|
|
|
|
$hsts_maxage = 0;
|
|
|
|
$hsts_sub = 0;
|
|
|
|
$hsts_preload = 0;
|
2017-04-11 15:09:34 +00:00
|
|
|
|
|
|
|
// OCSP stapling
|
|
|
|
$ocsp_stapling = 0;
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$ssl_redirect = 0;
|
2016-01-30 13:34:26 +00:00
|
|
|
$letsencrypt = 0;
|
2017-08-24 11:21:21 +00:00
|
|
|
$http2 = 0;
|
2013-09-30 10:12:04 +00:00
|
|
|
// we need this for the serialize
|
|
|
|
// if ssl is disabled or no ssl-ip/port exists
|
2016-04-11 07:19:43 +00:00
|
|
|
$ssl_ipandports[] = - 1;
|
2016-10-07 09:48:13 +00:00
|
|
|
|
|
|
|
// HSTS
|
|
|
|
$hsts_maxage = 0;
|
|
|
|
$hsts_sub = 0;
|
|
|
|
$hsts_preload = 0;
|
2017-04-11 15:09:34 +00:00
|
|
|
|
|
|
|
// OCSP stapling
|
|
|
|
$ocsp_stapling = 0;
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2016-01-30 13:46:00 +00:00
|
|
|
// We can't enable let's encrypt for wildcard domains
|
2016-02-16 07:51:36 +00:00
|
|
|
if ($serveraliasoption == '0' && $letsencrypt == '1') {
|
|
|
|
standard_error('nowildcardwithletsencrypt');
|
2016-01-30 13:46:00 +00:00
|
|
|
}
|
|
|
|
|
2016-02-16 13:31:07 +00:00
|
|
|
// Temporarily deactivate ssl_redirect until Let's Encrypt certificate was generated
|
|
|
|
if ($ssl_redirect > 0 && $letsencrypt == 1 && $result['letsencrypt'] != $letsencrypt) {
|
|
|
|
$ssl_redirect = 2;
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (! preg_match('/^https?\:\/\//', $documentroot)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$documentroot = makeCorrectDir($documentroot);
|
|
|
|
}
|
2017-01-16 07:43:54 +00:00
|
|
|
|
2016-11-13 13:41:39 +00:00
|
|
|
if ($phpenabled != '1') {
|
|
|
|
$phpenabled = '0';
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($openbasedir != '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$openbasedir = '0';
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($isbinddomain != '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$isbinddomain = '0';
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($isemaildomain != '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$isemaildomain = '0';
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($email_only == '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$isemaildomain = '1';
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$email_only = '0';
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($subcanemaildomain != '1' && $subcanemaildomain != '2' && $subcanemaildomain != '3') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$subcanemaildomain = '0';
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($dkim != '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$dkim = '0';
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($caneditdomain != '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$caneditdomain = '0';
|
|
|
|
}
|
|
|
|
|
|
|
|
$aliasdomain_check = array(
|
|
|
|
'id' => 0
|
|
|
|
);
|
|
|
|
|
2013-05-02 08:38:44 +00:00
|
|
|
if ($aliasdomain != 0) {
|
|
|
|
// Overwrite given ipandports with these of the "main" domain
|
|
|
|
$ipandports = array();
|
2014-12-22 12:32:37 +00:00
|
|
|
$ssl_ipandports = array();
|
2013-11-13 14:39:20 +00:00
|
|
|
$origipresult_stmt = Database::prepare("
|
2016-04-11 07:19:43 +00:00
|
|
|
SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :aliasdomain
|
2013-11-13 14:39:20 +00:00
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($origipresult_stmt, array(
|
|
|
|
'aliasdomain' => $aliasdomain
|
|
|
|
));
|
|
|
|
$ipdata_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid");
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($origip = $origipresult_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$_origip_tmp = Database::pexecute_first($ipdata_stmt, array(
|
|
|
|
'ipid' => $origip['id_ipandports']
|
|
|
|
));
|
2014-12-22 12:32:37 +00:00
|
|
|
if ($_origip_tmp['ssl'] == 0) {
|
|
|
|
$ipandports[] = $origip['id_ipandports'];
|
|
|
|
} else {
|
|
|
|
$ssl_ipandports[] = $origip['id_ipandports'];
|
|
|
|
}
|
2013-05-02 08:38:44 +00:00
|
|
|
}
|
2014-12-22 13:14:53 +00:00
|
|
|
|
|
|
|
if (count($ssl_ipandports) == 0) {
|
|
|
|
// we need this for the serialize
|
|
|
|
// if ssl is disabled or no ssl-ip/port exists
|
2016-04-11 07:19:43 +00:00
|
|
|
$ssl_ipandports[] = - 1;
|
2014-12-22 13:14:53 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$aliasdomain_check_stmt = Database::prepare("
|
|
|
|
SELECT `d`.`id` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
|
|
|
|
WHERE `d`.`customerid` = :customerid
|
|
|
|
AND `d`.`aliasdomain` IS NULL AND `d`.`id` <> `c`.`standardsubdomain`
|
|
|
|
AND `c`.`customerid` = :customerid
|
|
|
|
AND `d`.`id` = :aliasdomain
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
$aliasdomain_check = Database::pexecute_first($aliasdomain_check_stmt, array(
|
|
|
|
'customerid' => $customerid,
|
|
|
|
'aliasdomain' => $aliasdomain
|
|
|
|
));
|
2013-05-02 08:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (count($ipandports) == 0) {
|
|
|
|
standard_error('noipportgiven');
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($aliasdomain_check['id'] != $aliasdomain) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('domainisaliasorothercustomer');
|
|
|
|
}
|
2011-06-16 18:54:54 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($issubof <= '0') {
|
2010-08-06 05:43:28 +00:00
|
|
|
$issubof = '0';
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-10-14 07:50:55 +00:00
|
|
|
if ($serveraliasoption != '1' && $serveraliasoption != '2') {
|
|
|
|
$serveraliasoption = '0';
|
|
|
|
}
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$params = array(
|
|
|
|
'id' => $id,
|
|
|
|
'page' => $page,
|
|
|
|
'action' => $action,
|
|
|
|
'customerid' => $customerid,
|
|
|
|
'adminid' => $adminid,
|
|
|
|
'documentroot' => $documentroot,
|
|
|
|
'alias' => $aliasdomain,
|
|
|
|
'isbinddomain' => $isbinddomain,
|
|
|
|
'isemaildomain' => $isemaildomain,
|
|
|
|
'email_only' => $email_only,
|
|
|
|
'subcanemaildomain' => $subcanemaildomain,
|
|
|
|
'caneditdomain' => $caneditdomain,
|
|
|
|
'zonefile' => $zonefile,
|
|
|
|
'dkim' => $dkim,
|
2013-10-14 07:50:55 +00:00
|
|
|
'selectserveralias' => $serveraliasoption,
|
2010-01-27 08:54:31 +00:00
|
|
|
'ssl_redirect' => $ssl_redirect,
|
2016-11-13 13:41:39 +00:00
|
|
|
'phpenabled' => $phpenabled,
|
2010-01-27 08:54:31 +00:00
|
|
|
'openbasedir' => $openbasedir,
|
|
|
|
'phpsettingid' => $phpsettingid,
|
|
|
|
'mod_fcgid_starter' => $mod_fcgid_starter,
|
|
|
|
'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests,
|
|
|
|
'specialsettings' => $specialsettings,
|
2016-02-27 18:57:29 +00:00
|
|
|
'specialsettingsforsubdomains' => $ssfs,
|
2010-08-06 05:43:28 +00:00
|
|
|
'registration_date' => $registration_date,
|
2016-02-16 13:31:07 +00:00
|
|
|
'termination_date' => $termination_date,
|
|
|
|
'issubof' => $issubof,
|
2012-12-02 14:16:22 +00:00
|
|
|
'speciallogfile' => $speciallogfile,
|
2013-09-23 07:35:33 +00:00
|
|
|
'speciallogverified' => $speciallogverified,
|
2012-12-02 14:16:22 +00:00
|
|
|
'ipandport' => serialize($ipandports),
|
2016-01-30 13:34:26 +00:00
|
|
|
'ssl_ipandport' => serialize($ssl_ipandports),
|
2016-10-07 09:48:13 +00:00
|
|
|
'letsencrypt' => $letsencrypt,
|
2017-08-24 11:21:21 +00:00
|
|
|
'http2' => $http2,
|
2016-11-03 09:52:33 +00:00
|
|
|
'hsts_maxage' => $hsts_maxage,
|
2016-10-07 09:48:13 +00:00
|
|
|
'hsts_sub' => $hsts_sub,
|
2017-04-11 15:09:34 +00:00
|
|
|
'hsts_preload' => $hsts_preload,
|
2017-08-24 11:21:21 +00:00
|
|
|
'ocsp_stapling' => $ocsp_stapling
|
2010-01-27 08:54:31 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$security_questions = array(
|
2011-06-16 18:54:54 +00:00
|
|
|
'reallydisablesecuritysetting' => ($openbasedir == '0' && $userinfo['change_serversettings'] == '1'),
|
2016-04-11 07:19:43 +00:00
|
|
|
'reallydocrootoutofcustomerroot' => (substr($documentroot, 0, strlen($customer['documentroot'])) != $customer['documentroot'] && ! preg_match('/^https?\:\/\//', $documentroot))
|
2010-01-27 08:54:31 +00:00
|
|
|
);
|
2013-11-13 14:39:20 +00:00
|
|
|
foreach ($security_questions as $question_name => $question_launch) {
|
|
|
|
if ($question_launch !== false) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$params[$question_name] = $question_name;
|
2016-04-11 07:19:43 +00:00
|
|
|
if (! isset($_POST[$question_name]) || $_POST[$question_name] != $question_name) {
|
2010-01-27 08:54:31 +00:00
|
|
|
ask_yesno('admin_domain_' . $question_name, $filename, $params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-14 07:50:55 +00:00
|
|
|
$wwwserveralias = ($serveraliasoption == '1') ? '1' : '0';
|
|
|
|
$iswildcarddomain = ($serveraliasoption == '0') ? '1' : '0';
|
|
|
|
|
2017-04-11 15:09:34 +00:00
|
|
|
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'] ||
|
|
|
|
$aliasdomain != $result['aliasdomain'] ||
|
|
|
|
$issubof != $result['ismainbutsubto'] ||
|
|
|
|
$email_only != $result['email_only'] ||
|
|
|
|
($speciallogfile != $result['speciallogfile'] && $speciallogverified == '1') ||
|
|
|
|
$letsencrypt != $result['letsencrypt'] ||
|
2017-08-24 11:21:21 +00:00
|
|
|
$http2 != $result['http2'] ||
|
2017-04-11 15:09:34 +00:00
|
|
|
$hsts_maxage != $result['hsts'] ||
|
|
|
|
$hsts_sub != $result['hsts_sub'] ||
|
|
|
|
$hsts_preload != $result['hsts_preload'] ||
|
|
|
|
$ocsp_stapling != $result['ocsp_stapling']
|
|
|
|
) {
|
2010-01-27 08:54:31 +00:00
|
|
|
inserttask('1');
|
|
|
|
}
|
|
|
|
|
2013-09-23 07:35:33 +00:00
|
|
|
if ($speciallogfile != $result['speciallogfile'] && $speciallogverified != '1') {
|
|
|
|
$speciallogfile = $result['speciallogfile'];
|
|
|
|
}
|
2012-03-08 14:11:25 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($isbinddomain != $result['isbinddomain'] || $zonefile != $result['zonefile'] || $dkim != $result['dkim']) {
|
2013-03-29 19:10:37 +00:00
|
|
|
inserttask('4');
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($isemaildomain == '0' && $result['isemaildomain'] == '1') {
|
2013-11-13 14:39:20 +00:00
|
|
|
$del_stmt = Database::prepare("
|
|
|
|
DELETE FROM `" . TABLE_MAIL_USERS . "` WHERE `domainid` = :id
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($del_stmt, array(
|
|
|
|
'id' => $id
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$del_stmt = Database::prepare("
|
|
|
|
DELETE FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `domainid` = :id
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($del_stmt, array(
|
|
|
|
'id' => $id
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "deleted domain #" . $id . " from mail-tables");
|
|
|
|
}
|
|
|
|
|
2016-10-31 10:18:40 +00:00
|
|
|
// check whether LE has been disabled, so we remove the certificate
|
|
|
|
if ($letsencrypt == '0' && $result['letsencrypt'] == '1') {
|
|
|
|
$del_stmt = Database::prepare("
|
|
|
|
DELETE FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = :id
|
|
|
|
");
|
|
|
|
Database::pexecute($del_stmt, array(
|
|
|
|
'id' => $id
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$updatechildren = '';
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($subcanemaildomain == '0' && $result['subcanemaildomain'] != '0') {
|
2013-11-13 14:39:20 +00:00
|
|
|
$updatechildren = ", `isemaildomain` = '0' ";
|
2016-04-11 07:19:43 +00:00
|
|
|
} elseif ($subcanemaildomain == '3' && $result['subcanemaildomain'] != '3') {
|
2013-11-13 14:39:20 +00:00
|
|
|
$updatechildren = ", `isemaildomain` = '1' ";
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($customerid != $result['customerid'] && Settings::Get('panel.allow_domain_change_customer') == '1') {
|
|
|
|
$upd_data = array(
|
|
|
|
'customerid' => $customerid,
|
|
|
|
'domainid' => $result['id']
|
|
|
|
);
|
2013-11-13 14:39:20 +00:00
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_MAIL_USERS . "` SET `customerid` = :customerid WHERE `domainid` = :domainid
|
|
|
|
");
|
|
|
|
Database::pexecute($upd_stmt, $upd_data);
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `customerid` = :customerid WHERE `domainid` = :domainid
|
|
|
|
");
|
|
|
|
Database::pexecute($upd_stmt, $upd_data);
|
2016-04-11 07:19:43 +00:00
|
|
|
$upd_data = array(
|
|
|
|
'subdomains' => $subdomains,
|
|
|
|
'emails' => $emails,
|
|
|
|
'forwarders' => $email_forwarders,
|
|
|
|
'accounts' => $email_accounts
|
|
|
|
);
|
2013-11-13 14:39:20 +00:00
|
|
|
$upd_data['customerid'] = $customerid;
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
|
|
|
|
`subdomains_used` = `subdomains_used` + :subdomains,
|
|
|
|
`emails_used` = `emails_used` + :emails,
|
|
|
|
`email_forwarders_used` = `email_forwarders_used` + :forwarders,
|
|
|
|
`email_accounts_used` = `email_accounts_used` + :accounts
|
|
|
|
WHERE `customerid` = :customerid
|
|
|
|
");
|
|
|
|
Database::pexecute($upd_stmt, $upd_data);
|
|
|
|
|
|
|
|
$upd_data['customerid'] = $result['customerid'];
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
|
|
|
|
`subdomains_used` = `subdomains_used` - :subdomains,
|
|
|
|
`emails_used` = `emails_used` - :emails,
|
|
|
|
`email_forwarders_used` = `email_forwarders_used` - :forwarders,
|
|
|
|
`email_accounts_used` = `email_accounts_used` - :accounts
|
|
|
|
WHERE `customerid` = :customerid
|
|
|
|
");
|
|
|
|
Database::pexecute($upd_stmt, $upd_data);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($adminid != $result['adminid'] && Settings::Get('panel.allow_domain_change_admin') == '1') {
|
2013-11-13 14:39:20 +00:00
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_ADMINS . "` SET `domains_used` = `domains_used` + 1 WHERE `adminid` = :adminid
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($upd_stmt, array(
|
|
|
|
'adminid' => $adminid
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_ADMINS . "` SET `domains_used` = `domains_used` - 1 WHERE `adminid` = :adminid
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($upd_stmt, array(
|
|
|
|
'adminid' => $result['adminid']
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$_update_data = array();
|
|
|
|
|
2012-07-23 23:06:45 +00:00
|
|
|
$ssfs = isset($_POST['specialsettingsforsubdomains']) ? 1 : 0;
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($ssfs == 1) {
|
|
|
|
$_update_data['specialsettings'] = $specialsettings;
|
|
|
|
$upd_specialsettings = ", `specialsettings` = :specialsettings ";
|
|
|
|
} else {
|
2010-01-29 09:30:55 +00:00
|
|
|
$upd_specialsettings = '';
|
2013-11-13 14:39:20 +00:00
|
|
|
unset($_update_data['specialsettings']);
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `specialsettings`='' WHERE `parentdomainid` = :id
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($upd_stmt, array(
|
|
|
|
'id' => $id
|
|
|
|
));
|
2010-01-29 09:30:55 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "removed specialsettings on all subdomains of domain #" . $id);
|
|
|
|
}
|
2011-06-16 18:54:54 +00:00
|
|
|
|
2013-10-14 07:50:55 +00:00
|
|
|
$wwwserveralias = ($serveraliasoption == '1') ? '1' : '0';
|
|
|
|
$iswildcarddomain = ($serveraliasoption == '0') ? '1' : '0';
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$update_data = array();
|
|
|
|
$update_data['customerid'] = $customerid;
|
|
|
|
$update_data['adminid'] = $adminid;
|
|
|
|
$update_data['documentroot'] = $documentroot;
|
|
|
|
$update_data['ssl_redirect'] = $ssl_redirect;
|
|
|
|
$update_data['aliasdomain'] = ($aliasdomain != 0 && $alias_check == 0) ? $aliasdomain : null;
|
|
|
|
$update_data['isbinddomain'] = $isbinddomain;
|
|
|
|
$update_data['isemaildomain'] = $isemaildomain;
|
|
|
|
$update_data['email_only'] = $email_only;
|
|
|
|
$update_data['subcanemaildomain'] = $subcanemaildomain;
|
|
|
|
$update_data['dkim'] = $dkim;
|
|
|
|
$update_data['caneditdomain'] = $caneditdomain;
|
|
|
|
$update_data['zonefile'] = $zonefile;
|
|
|
|
$update_data['wwwserveralias'] = $wwwserveralias;
|
|
|
|
$update_data['iswildcarddomain'] = $iswildcarddomain;
|
2016-11-13 13:41:39 +00:00
|
|
|
$update_data['phpenabled'] = $phpenabled;
|
2013-11-13 14:39:20 +00:00
|
|
|
$update_data['openbasedir'] = $openbasedir;
|
|
|
|
$update_data['speciallogfile'] = $speciallogfile;
|
|
|
|
$update_data['phpsettingid'] = $phpsettingid;
|
|
|
|
$update_data['mod_fcgid_starter'] = $mod_fcgid_starter;
|
|
|
|
$update_data['mod_fcgid_maxrequests'] = $mod_fcgid_maxrequests;
|
|
|
|
$update_data['specialsettings'] = $specialsettings;
|
|
|
|
$update_data['registration_date'] = $registration_date;
|
2016-02-16 13:31:07 +00:00
|
|
|
$update_data['termination_date'] = $termination_date;
|
2013-11-13 14:39:20 +00:00
|
|
|
$update_data['ismainbutsubto'] = $issubof;
|
2016-01-30 13:34:26 +00:00
|
|
|
$update_data['letsencrypt'] = $letsencrypt;
|
2017-08-24 11:21:21 +00:00
|
|
|
$update_data['http2'] = $http2;
|
2016-10-07 09:48:13 +00:00
|
|
|
$update_data['hsts'] = $hsts_maxage;
|
|
|
|
$update_data['hsts_sub'] = $hsts_sub;
|
|
|
|
$update_data['hsts_preload'] = $hsts_preload;
|
2017-04-11 15:09:34 +00:00
|
|
|
$update_data['ocsp_stapling'] = $ocsp_stapling;
|
2013-11-13 14:39:20 +00:00
|
|
|
$update_data['id'] = $id;
|
|
|
|
|
|
|
|
$update_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET
|
|
|
|
`customerid` = :customerid,
|
|
|
|
`adminid` = :adminid,
|
|
|
|
`documentroot` = :documentroot,
|
|
|
|
`ssl_redirect` = :ssl_redirect,
|
|
|
|
`aliasdomain` = :aliasdomain,
|
|
|
|
`isbinddomain` = :isbinddomain,
|
|
|
|
`isemaildomain` = :isemaildomain,
|
|
|
|
`email_only` = :email_only,
|
|
|
|
`subcanemaildomain` = :subcanemaildomain,
|
|
|
|
`dkim` = :dkim,
|
|
|
|
`caneditdomain` = :caneditdomain,
|
|
|
|
`zonefile` = :zonefile,
|
|
|
|
`wwwserveralias` = :wwwserveralias,
|
|
|
|
`iswildcarddomain` = :iswildcarddomain,
|
2016-11-13 13:41:39 +00:00
|
|
|
`phpenabled` = :phpenabled,
|
2013-11-13 14:39:20 +00:00
|
|
|
`openbasedir` = :openbasedir,
|
|
|
|
`speciallogfile` = :speciallogfile,
|
|
|
|
`phpsettingid` = :phpsettingid,
|
|
|
|
`mod_fcgid_starter` = :mod_fcgid_starter,
|
|
|
|
`mod_fcgid_maxrequests` = :mod_fcgid_maxrequests,
|
|
|
|
`specialsettings` = :specialsettings,
|
|
|
|
`registration_date` = :registration_date,
|
2016-02-16 13:31:07 +00:00
|
|
|
`termination_date` = :termination_date,
|
2016-01-30 13:34:26 +00:00
|
|
|
`ismainbutsubto` = :ismainbutsubto,
|
2016-10-07 09:48:13 +00:00
|
|
|
`letsencrypt` = :letsencrypt,
|
2017-08-24 11:21:21 +00:00
|
|
|
`http2` = :http2,
|
2016-10-07 09:48:13 +00:00
|
|
|
`hsts` = :hsts,
|
|
|
|
`hsts_sub` = :hsts_sub,
|
2017-04-11 15:09:34 +00:00
|
|
|
`hsts_preload` = :hsts_preload,
|
|
|
|
`ocsp_stapling` = :ocsp_stapling
|
2013-11-13 14:39:20 +00:00
|
|
|
WHERE `id` = :id
|
2012-12-02 14:16:22 +00:00
|
|
|
");
|
2013-11-13 14:39:20 +00:00
|
|
|
Database::pexecute($update_stmt, $update_data);
|
|
|
|
|
|
|
|
$_update_data['customerid'] = $customerid;
|
|
|
|
$_update_data['adminid'] = $adminid;
|
2016-11-13 13:41:39 +00:00
|
|
|
$_update_data['phpenabled'] = $phpenabled;
|
2013-11-13 14:39:20 +00:00
|
|
|
$_update_data['openbasedir'] = $openbasedir;
|
|
|
|
$_update_data['phpsettingid'] = $phpsettingid;
|
|
|
|
$_update_data['mod_fcgid_starter'] = $mod_fcgid_starter;
|
|
|
|
$_update_data['mod_fcgid_maxrequests'] = $mod_fcgid_maxrequests;
|
|
|
|
$_update_data['parentdomainid'] = $id;
|
|
|
|
|
2014-02-11 14:39:24 +00:00
|
|
|
// if we have no more ssl-ip's for this domain,
|
|
|
|
// all its subdomains must have "ssl-redirect = 0"
|
2016-01-30 13:34:26 +00:00
|
|
|
// and disable let's encrypt
|
2014-02-11 14:39:24 +00:00
|
|
|
$update_sslredirect = '';
|
2016-04-11 07:19:43 +00:00
|
|
|
if (count($ssl_ipandports) == 1 && $ssl_ipandports[0] == - 1) {
|
2016-01-30 13:34:26 +00:00
|
|
|
$update_sslredirect = ", `ssl_redirect` = '0', `letsencrypt` = '0' ";
|
2014-02-11 14:39:24 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$_update_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET
|
2013-11-13 16:22:37 +00:00
|
|
|
`customerid` = :customerid,
|
2013-11-13 14:39:20 +00:00
|
|
|
`adminid` = :adminid,
|
2016-11-13 13:41:39 +00:00
|
|
|
`phpenabled` = :phpenabled,
|
2013-11-13 14:39:20 +00:00
|
|
|
`openbasedir` = :openbasedir,
|
|
|
|
`phpsettingid` = :phpsettingid,
|
|
|
|
`mod_fcgid_starter` = :mod_fcgid_starter,
|
|
|
|
`mod_fcgid_maxrequests` = :mod_fcgid_maxrequests
|
2014-02-11 14:39:24 +00:00
|
|
|
" . $upd_specialsettings . $updatechildren . $update_sslredirect . "
|
2013-11-13 16:22:37 +00:00
|
|
|
WHERE `parentdomainid` = :parentdomainid
|
2012-12-02 14:16:22 +00:00
|
|
|
");
|
2013-11-13 14:39:20 +00:00
|
|
|
Database::pexecute($_update_stmt, $_update_data);
|
2012-12-02 14:16:22 +00:00
|
|
|
|
2013-05-02 08:38:44 +00:00
|
|
|
// FIXME check how many we got and if the amount of assigned IP's
|
|
|
|
// has changed so we can insert a config-rebuild task if only
|
|
|
|
// the ip's of this domain were changed
|
2014-07-09 15:52:16 +00:00
|
|
|
// -> for now, always insert a rebuild-task
|
|
|
|
inserttask('1');
|
2013-05-02 08:38:44 +00:00
|
|
|
|
2012-12-02 14:16:22 +00:00
|
|
|
// Cleanup domain <-> ip mapping
|
2013-11-13 14:39:20 +00:00
|
|
|
$del_stmt = Database::prepare("
|
|
|
|
DELETE FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :id
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($del_stmt, array(
|
|
|
|
'id' => $id
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$ins_stmt = Database::prepare("
|
|
|
|
INSERT INTO `" . TABLE_DOMAINTOIP . "` SET `id_domain` = :domainid, `id_ipandports` = :ipportid
|
|
|
|
");
|
2012-12-02 14:16:22 +00:00
|
|
|
|
|
|
|
foreach ($ipandports as $ipportid) {
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($ins_stmt, array(
|
|
|
|
'domainid' => $id,
|
|
|
|
'ipportid' => $ipportid
|
|
|
|
));
|
2012-12-02 14:16:22 +00:00
|
|
|
}
|
|
|
|
foreach ($ssl_ipandports as $ssl_ipportid) {
|
2013-09-30 10:12:04 +00:00
|
|
|
if ($ssl_ipportid > 0) {
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($ins_stmt, array(
|
|
|
|
'domainid' => $id,
|
|
|
|
'ipportid' => $ssl_ipportid
|
|
|
|
));
|
2013-09-30 10:12:04 +00:00
|
|
|
}
|
2012-12-02 14:16:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Cleanup domain <-> ip mapping for subdomains
|
2013-11-13 14:39:20 +00:00
|
|
|
$domainidsresult_stmt = Database::prepare("
|
|
|
|
SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `parentdomainid` = :id
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($domainidsresult_stmt, array(
|
|
|
|
'id' => $id
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
while ($row = $domainidsresult_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
|
|
|
|
$del_stmt = Database::prepare("
|
|
|
|
DELETE FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :rowid
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($del_stmt, array(
|
|
|
|
'rowid' => $row['id']
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$ins_stmt = Database::prepare("
|
|
|
|
INSERT INTO `" . TABLE_DOMAINTOIP . "` SET
|
|
|
|
`id_domain` = :rowid,
|
|
|
|
`id_ipandports` = :ipportid
|
|
|
|
");
|
|
|
|
|
2012-12-02 14:16:22 +00:00
|
|
|
foreach ($ipandports as $ipportid) {
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($ins_stmt, array(
|
|
|
|
'rowid' => $row['id'],
|
|
|
|
'ipportid' => $ipportid
|
|
|
|
));
|
2012-12-02 14:16:22 +00:00
|
|
|
}
|
|
|
|
foreach ($ssl_ipandports as $ssl_ipportid) {
|
2014-10-27 09:41:29 +00:00
|
|
|
if ($ssl_ipportid > 0) {
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($ins_stmt, array(
|
|
|
|
'rowid' => $row['id'],
|
|
|
|
'ipportid' => $ssl_ipportid
|
|
|
|
));
|
2014-10-27 09:41:29 +00:00
|
|
|
}
|
2012-12-02 14:16:22 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:32:07 +00:00
|
|
|
if ($result['aliasdomain'] != $aliasdomain) {
|
|
|
|
// trigger when domain id for alias destination has changed: both for old and new destination
|
|
|
|
triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $log);
|
|
|
|
triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $log);
|
|
|
|
} else
|
|
|
|
if ($result['wwwserveralias'] != $wwwserveralias || $result['letsencrypt'] != $letsencrypt) {
|
|
|
|
// or when wwwserveralias or letsencrypt was changed
|
|
|
|
triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $log);
|
|
|
|
}
|
2012-12-02 14:16:22 +00:00
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "edited domain #" . $id);
|
2016-04-11 07:19:43 +00:00
|
|
|
redirectTo($filename, array(
|
|
|
|
'page' => $page,
|
|
|
|
's' => $s
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
if (Settings::Get('panel.allow_domain_change_customer') == '1') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$customers = '';
|
2013-11-13 14:39:20 +00:00
|
|
|
$result_customers_stmt = Database::prepare("
|
|
|
|
SELECT `customerid`, `loginname`, `name`, `firstname`, `company` FROM `" . TABLE_PANEL_CUSTOMERS . "`
|
|
|
|
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' )
|
2016-04-11 07:19:43 +00:00
|
|
|
AND (`email_accounts_used` + :accounts <= `email_accounts` OR `email_accounts` = '-1' ) " . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid ") . ")
|
2013-11-13 14:39:20 +00:00
|
|
|
OR `customerid` = :customerid ORDER BY `name` ASC
|
|
|
|
");
|
|
|
|
$params = array(
|
|
|
|
'subdomains' => $subdomains,
|
|
|
|
'emails' => $emails,
|
|
|
|
'forwarders' => $email_forwarders,
|
|
|
|
'accounts' => $email_accounts,
|
|
|
|
'customerid' => $result['customerid']
|
|
|
|
);
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
Database::pexecute($result_customers_stmt, $params);
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$customers .= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid'], $result['customerid']);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
|
|
|
$customer_stmt = Database::prepare("
|
|
|
|
SELECT `customerid`, `loginname`, `name`, `firstname`, `company` FROM `" . TABLE_PANEL_CUSTOMERS . "`
|
|
|
|
WHERE `customerid` = :customerid
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
$customer = Database::pexecute_first($customer_stmt, array(
|
|
|
|
'customerid' => $result['customerid']
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
$result['customername'] = getCorrectFullUserDetails($customer) . ' (' . $customer['loginname'] . ')';
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($userinfo['customers_see_all'] == '1') {
|
2013-12-15 10:47:23 +00:00
|
|
|
if (Settings::Get('panel.allow_domain_change_admin') == '1') {
|
2013-11-13 14:39:20 +00:00
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$admins = '';
|
2013-11-13 14:39:20 +00:00
|
|
|
$result_admins_stmt = Database::prepare("
|
|
|
|
SELECT `adminid`, `loginname`, `name` FROM `" . TABLE_PANEL_ADMINS . "`
|
|
|
|
WHERE (`domains_used` < `domains` OR `domains` = '-1') OR `adminid` = :adminid ORDER BY `name` ASC
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($result_admins_stmt, array(
|
|
|
|
'adminid' => $result['adminid']
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_admin = $result_admins_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$admins .= makeoption(getCorrectFullUserDetails($row_admin) . ' (' . $row_admin['loginname'] . ')', $row_admin['adminid'], $result['adminid']);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
|
|
|
$admin_stmt = Database::prepare("
|
|
|
|
SELECT `adminid`, `loginname`, `name` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :adminid
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
$admin = Database::pexecute_first($admin_stmt, array(
|
|
|
|
'adminid' => $result['adminid']
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
$result['adminname'] = getCorrectFullUserDetails($admin) . ' (' . $admin['loginname'] . ')';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$result['domain'] = $idna_convert->decode($result['domain']);
|
2013-11-13 14:39:20 +00:00
|
|
|
$domains = makeoption($lng['domains']['noaliasdomain'], 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 `d`.`customerid` = :customerid AND `c`.`customerid`=`d`.`customerid`
|
|
|
|
ORDER BY `d`.`domain` ASC
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($result_domains_stmt, array(
|
|
|
|
'id' => $result['id'],
|
|
|
|
'customerid' => $result['customerid']
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$domains .= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['aliasdomain']);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2010-08-27 05:53:25 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$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
|
2016-04-11 07:19:43 +00:00
|
|
|
AND `c`.`standardsubdomain`<>`d`.`id` AND `c`.`customerid`=`d`.`customerid`" . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . "
|
2013-11-13 14:39:20 +00:00
|
|
|
ORDER BY `d`.`domain` ASC
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
$params = array(
|
|
|
|
'id' => $result['id']
|
|
|
|
);
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
Database::pexecute($result_domains_stmt, $params);
|
2010-08-06 05:43:28 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$subtodomains .= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['ismainbutsubto']);
|
2010-08-06 05:43:28 +00:00
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($userinfo['ip'] == "-1") {
|
|
|
|
$result_ipsandports_stmt = Database::query("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='0' ORDER BY `ip`, `port` ASC
|
|
|
|
");
|
|
|
|
$result_ssl_ipsandports_stmt = Database::query("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='1' ORDER BY `ip`, `port` ASC
|
|
|
|
");
|
|
|
|
} else {
|
|
|
|
$admin_ip_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid ORDER BY `ip`, `port` ASC
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
$admin_ip = Database::pexecute_first($admin_ip_stmt, array(
|
|
|
|
'ipid' => $userinfo['ip']
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$result_ipsandports_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='0' AND `ip` = :ipid ORDER BY `ip`, `port` ASC
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($result_ipsandports_stmt, array(
|
|
|
|
'ipid' => $admin_ip['ip']
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
|
|
|
|
$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
|
|
|
|
");
|
2016-04-11 07:19:43 +00:00
|
|
|
Database::pexecute($result_ssl_ipsandports_stmt, array(
|
|
|
|
'ipid' => $admin_ip['ip']
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2012-12-02 14:16:22 +00:00
|
|
|
$ipsandports = array();
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_ipandport = $result_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
if (filter_var($row_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$row_ipandport['ip'] = '[' . $row_ipandport['ip'] . ']';
|
|
|
|
}
|
2016-04-11 07:19:43 +00:00
|
|
|
$ipsandports[] = array(
|
|
|
|
'label' => $row_ipandport['ip'] . ':' . $row_ipandport['port'] . '<br />',
|
|
|
|
'value' => $row_ipandport['id']
|
|
|
|
);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2012-12-02 14:16:22 +00:00
|
|
|
$ssl_ipsandports = array();
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_ssl_ipandport = $result_ssl_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
if (filter_var($row_ssl_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$row_ssl_ipandport['ip'] = '[' . $row_ssl_ipandport['ip'] . ']';
|
|
|
|
}
|
2016-04-11 07:19:43 +00:00
|
|
|
$ssl_ipsandports[] = array(
|
|
|
|
'label' => $row_ssl_ipandport['ip'] . ':' . $row_ssl_ipandport['port'] . '<br />',
|
|
|
|
'value' => $row_ssl_ipandport['id']
|
|
|
|
);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2013-10-14 07:50:55 +00:00
|
|
|
// create serveralias options
|
|
|
|
$serveraliasoptions = "";
|
2013-10-14 08:08:15 +00:00
|
|
|
$_value = '2';
|
2013-10-14 07:50:55 +00:00
|
|
|
if ($result['iswildcarddomain'] == '1') {
|
2013-10-14 08:08:15 +00:00
|
|
|
$_value = '0';
|
2016-01-30 13:46:00 +00:00
|
|
|
$letsencrypt = 0;
|
2013-10-14 07:50:55 +00:00
|
|
|
} elseif ($result['wwwserveralias'] == '1') {
|
2013-10-14 08:08:15 +00:00
|
|
|
$_value = '1';
|
2013-10-14 07:50:55 +00:00
|
|
|
}
|
2016-02-16 13:31:07 +00:00
|
|
|
|
|
|
|
// 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);
|
2016-04-11 07:19:43 +00:00
|
|
|
|
2013-10-14 08:08:15 +00:00
|
|
|
$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);
|
2013-10-14 07:50:55 +00:00
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$subcanemaildomain = makeoption($lng['admin']['subcanemaildomain']['never'], '0', $result['subcanemaildomain'], true, true);
|
2016-04-11 07:19:43 +00:00
|
|
|
$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);
|
2010-01-27 08:54:31 +00:00
|
|
|
$speciallogfile = ($result['speciallogfile'] == 1 ? $lng['panel']['yes'] : $lng['panel']['no']);
|
|
|
|
$result['add_date'] = date('Y-m-d', $result['add_date']);
|
|
|
|
|
|
|
|
$phpconfigs = '';
|
2013-11-13 14:39:20 +00:00
|
|
|
$phpconfigs_result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "`");
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$phpconfigs .= makeoption($phpconfigs_row['description'], $phpconfigs_row['id'], $result['phpsettingid'], true, true);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$result = htmlentities_array($result);
|
2011-02-08 11:53:24 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
$domain_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_edit.php';
|
2011-02-08 11:53:24 +00:00
|
|
|
$domain_edit_form = htmlform::genHTMLForm($domain_edit_data);
|
|
|
|
|
|
|
|
$title = $domain_edit_data['domain_edit']['title'];
|
|
|
|
$image = $domain_edit_data['domain_edit']['image'];
|
|
|
|
|
2013-03-27 11:30:37 +00:00
|
|
|
$speciallogwarning = sprintf($lng['admin']['speciallogwarning'], $lng['admin']['delete_statistics']);
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
eval("echo \"" . getTemplate("domains/domains_edit") . "\";");
|
|
|
|
}
|
|
|
|
}
|
2016-04-11 07:19:43 +00:00
|
|
|
} elseif ($action == 'import') {
|
2014-12-15 13:49:34 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2014-12-15 13:49:34 +00:00
|
|
|
|
|
|
|
$customerid = intval($_POST['customerid']);
|
|
|
|
$separator = validate($_POST['separator'], 'separator');
|
2016-04-11 07:19:43 +00:00
|
|
|
$offset = (int) validate($_POST['offset'], 'offset', "/[0-9]/i");
|
2014-12-15 13:49:34 +00:00
|
|
|
|
|
|
|
$file_name = $_FILES['file']['tmp_name'];
|
|
|
|
|
|
|
|
$result = array();
|
|
|
|
|
|
|
|
try {
|
|
|
|
$bulk = new DomainBulkAction($file_name, $customerid);
|
|
|
|
$result = $bulk->doImport($separator, $offset);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
standard_error('domain_import_error', $e->getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
// @FIXME find a way to display $result['notice'] here somehow,
|
2016-04-11 07:19:43 +00:00
|
|
|
// as it might be important if you've reached your maximum allocation of domains
|
2014-12-15 13:49:34 +00:00
|
|
|
|
|
|
|
// update customer/admin counters
|
|
|
|
updateCounters(false);
|
2017-10-06 07:29:49 +00:00
|
|
|
inserttask('1');
|
|
|
|
inserttask('4');
|
2014-12-15 13:49:34 +00:00
|
|
|
|
|
|
|
$result_str = $result['imported'] . ' / ' . $result['all'];
|
2016-04-11 07:19:43 +00:00
|
|
|
standard_success('domain_import_successfully', $result_str, array(
|
|
|
|
'filename' => $filename,
|
|
|
|
'action' => '',
|
|
|
|
'page' => 'domains'
|
|
|
|
));
|
2014-12-15 13:49:34 +00:00
|
|
|
} else {
|
|
|
|
$customers = makeoption($lng['panel']['please_choose'], 0, 0, true);
|
|
|
|
$result_customers_stmt = Database::prepare("
|
|
|
|
SELECT `customerid`, `loginname`, `name`, `firstname`, `company`
|
2016-04-11 07:19:43 +00:00
|
|
|
FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int) $userinfo['adminid'] . "' ") . " ORDER BY `name` ASC");
|
2014-12-15 13:49:34 +00:00
|
|
|
$params = array();
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
Database::pexecute($result_customers_stmt, $params);
|
|
|
|
|
|
|
|
while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2016-04-11 07:19:43 +00:00
|
|
|
$customers .= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']);
|
2014-12-15 13:49:34 +00:00
|
|
|
}
|
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
$domain_import_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_import.php';
|
2014-12-15 13:49:34 +00:00
|
|
|
$domain_import_form = htmlform::genHTMLForm($domain_import_data);
|
|
|
|
|
|
|
|
$title = $domain_import_data['domain_import']['title'];
|
|
|
|
$image = $domain_import_data['domain_import']['image'];
|
|
|
|
|
|
|
|
eval("echo \"" . getTemplate("domains/domains_import") . "\";");
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2016-05-13 11:27:33 +00:00
|
|
|
} elseif ($page == 'domaindnseditor' && Settings::Get('system.dnsenabled') == '1') {
|
2016-05-09 13:09:09 +00:00
|
|
|
|
|
|
|
require_once __DIR__.'/dns_editor.php';
|
2016-09-26 09:48:36 +00:00
|
|
|
|
|
|
|
} elseif ($page == 'sslcertificates') {
|
|
|
|
|
|
|
|
require_once __DIR__.'/ssl_certificates.php';
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2016-04-11 07:19:43 +00:00
|
|
|
|
|
|
|
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';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|