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
|
|
|
|
2018-12-19 15:57:03 +00:00
|
|
|
use Froxlor\Database\Database;
|
|
|
|
use Froxlor\Settings;
|
2019-11-10 17:35:32 +00:00
|
|
|
use Froxlor\Api\Commands\Customers as Customers;
|
2018-12-18 12:45:05 +00:00
|
|
|
use Froxlor\Api\Commands\Domains as Domains;
|
|
|
|
|
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
|
2019-11-10 17:35:32 +00:00
|
|
|
$json_result = Customers::getLocal($userinfo)->listingCount();
|
|
|
|
$countcustomers = json_decode($json_result, true)['data'];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($action == '') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-26 14:51:26 +00:00
|
|
|
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_domains");
|
2010-01-27 08:54:31 +00:00
|
|
|
$fields = array(
|
2018-12-22 07:15:31 +00:00
|
|
|
'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']
|
2010-01-27 08:54:31 +00:00
|
|
|
);
|
2019-11-10 17:35:32 +00:00
|
|
|
try {
|
|
|
|
// get total count
|
|
|
|
$json_result = Domains::getLocal($userinfo)->listingCount();
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
|
|
|
// initialize pagination and filtering
|
|
|
|
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
|
|
|
// get list
|
|
|
|
$json_result = Domains::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2013-11-13 14:39:20 +00:00
|
|
|
}
|
2019-11-10 17:35:32 +00:00
|
|
|
$result = json_decode($json_result, true)['data'];
|
|
|
|
|
|
|
|
$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();
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2019-11-10 17:35:32 +00:00
|
|
|
foreach ($result['list'] as $row) {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
formatDomainEntry($row, $idna_convert);
|
2018-12-19 15:57:03 +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']]);
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
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'];
|
|
|
|
}
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$count = 0;
|
2013-11-13 14:39:20 +00:00
|
|
|
foreach ($domain_array as $row) {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2019-11-10 17:35:32 +00:00
|
|
|
if (isset($row['domain']) && $row['domain'] != '') {
|
2018-12-21 18:16:49 +00:00
|
|
|
$row['customername'] = \Froxlor\User::getCorrectFullUserDetails($row);
|
2018-12-24 12:50:45 +00:00
|
|
|
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
2013-04-29 08:02:44 +00:00
|
|
|
// display a nice list of IP's
|
|
|
|
$row['ipandport'] = str_replace("\n", "<br />", $row['ipandport']);
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_domain") . "\";");
|
2016-04-11 07:19:43 +00:00
|
|
|
$count ++;
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2019-11-10 17:35:32 +00:00
|
|
|
$domainscount = $paging->getEntries();
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
// Display the list
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains") . "\";");
|
2018-02-15 13:44:48 +00:00
|
|
|
} elseif ($action == 'delete' && $id != 0) {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Domains::getLocal($userinfo, array(
|
2018-02-15 13:44:48 +00:00
|
|
|
'id' => $id,
|
|
|
|
'no_std_subdomain' => true
|
|
|
|
))->get();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$alias_check_stmt = Database::prepare("
|
|
|
|
SELECT COUNT(`id`) AS `count` FROM `" . TABLE_PANEL_DOMAINS . "`
|
|
|
|
WHERE `aliasdomain`= :id");
|
|
|
|
$alias_check = Database::pexecute_first($alias_check_stmt, array(
|
|
|
|
'id' => $id
|
|
|
|
));
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
if ($result['domain'] != '') {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send' && $alias_check['count'] == 0) {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
Domains::getLocal($userinfo, $_POST)->delete();
|
2018-02-15 13:44:48 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
2018-02-15 13:44:48 +00:00
|
|
|
'page' => $page,
|
|
|
|
's' => $s
|
|
|
|
));
|
|
|
|
} elseif ($alias_check['count'] > 0) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::standard_error('domains_cantdeletedomainwithaliases');
|
2018-02-15 13:44:48 +00:00
|
|
|
} else {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$showcheck = false;
|
2018-12-20 11:38:18 +00:00
|
|
|
if (\Froxlor\Domain\Domain::domainHasMainSubDomains($id)) {
|
2018-02-15 13:44:48 +00:00
|
|
|
$showcheck = true;
|
2016-10-31 10:18:40 +00:00
|
|
|
}
|
2018-12-24 12:50:45 +00:00
|
|
|
\Froxlor\UI\HTML::askYesNoWithCheckbox('admin_domain_reallydelete', 'remove_subbutmain_domains', $filename, array(
|
2018-02-15 13:44:48 +00:00
|
|
|
'id' => $id,
|
|
|
|
'page' => $page,
|
|
|
|
'action' => $action
|
|
|
|
), $idna_convert->decode($result['domain']), $showcheck);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} elseif ($action == 'add') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
Domains::getLocal($userinfo, $_POST)->add();
|
2018-02-15 13:44:48 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
2018-02-15 13:44:48 +00:00
|
|
|
'page' => $page,
|
|
|
|
's' => $s
|
|
|
|
));
|
|
|
|
} else {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
$customers = \Froxlor\UI\HTML::makeoption($lng['panel']['please_choose'], 0, 0, true);
|
2018-02-15 13:44:48 +00:00
|
|
|
$result_customers_stmt = Database::prepare("
|
|
|
|
SELECT `customerid`, `loginname`, `name`, `firstname`, `company`
|
2018-12-22 07:15:31 +00:00
|
|
|
FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int) $userinfo['adminid'] . "' ") . " ORDER BY COALESCE(NULLIF(`name`,''), `company`) ASC");
|
2018-02-15 13:44:48 +00:00
|
|
|
$params = array();
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
|
|
|
Database::pexecute($result_customers_stmt, $params);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-21 18:16:49 +00:00
|
|
|
$customers .= \Froxlor\UI\HTML::makeoption(\Froxlor\User::getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']);
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$admins = '';
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($userinfo['customers_see_all'] == '1') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$result_admins_stmt = Database::query("
|
|
|
|
SELECT `adminid`, `loginname`, `name`
|
|
|
|
FROM `" . TABLE_PANEL_ADMINS . "`
|
|
|
|
WHERE `domains_used` < `domains` OR `domains` = '-1' ORDER BY `name` ASC");
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
while ($row_admin = $result_admins_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-22 07:15:31 +00:00
|
|
|
$admins .= \Froxlor\UI\HTML::makeoption(\Froxlor\User::getCorrectFullUserDetails($row_admin) . ' (' . $row_admin['loginname'] . ')', $row_admin['adminid'], $userinfo['adminid']);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($userinfo['ip'] == "-1") {
|
2018-02-15 13:44:48 +00:00
|
|
|
$result_ipsandports_stmt = Database::query("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='0' ORDER BY `ip`, `port` ASC
|
2013-11-13 14:39:20 +00:00
|
|
|
");
|
2018-02-15 13:44:48 +00:00
|
|
|
$result_ssl_ipsandports_stmt = Database::query("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='1' ORDER BY `ip`, `port` ASC
|
2013-11-13 14:39:20 +00:00
|
|
|
");
|
2018-02-15 13:44:48 +00:00
|
|
|
} else {
|
|
|
|
$admin_ip_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid ORDER BY `ip`, `port` ASC
|
2013-11-13 14:39:20 +00:00
|
|
|
");
|
2018-02-15 13:44:48 +00:00
|
|
|
$admin_ip = Database::pexecute_first($admin_ip_stmt, array(
|
2018-12-22 07:15:31 +00:00
|
|
|
'ipid' => $userinfo['ip']
|
2018-02-15 13:44:48 +00:00
|
|
|
));
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +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
|
2013-11-13 14:39:20 +00:00
|
|
|
");
|
2018-02-15 13:44:48 +00:00
|
|
|
Database::pexecute($result_ipsandports_stmt, array(
|
|
|
|
'ipid' => $admin_ip['ip']
|
|
|
|
));
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +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
|
2013-11-13 14:39:20 +00:00
|
|
|
");
|
2018-02-15 13:44:48 +00:00
|
|
|
Database::pexecute($result_ssl_ipsandports_stmt, array(
|
|
|
|
'ipid' => $admin_ip['ip']
|
|
|
|
));
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
// Build array holding all IPs and Ports available to this admin
|
|
|
|
$ipsandports = array();
|
|
|
|
while ($row_ipandport = $result_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
if (filter_var($row_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
|
|
|
$row_ipandport['ip'] = '[' . $row_ipandport['ip'] . ']';
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$ipsandports[] = array(
|
|
|
|
'label' => $row_ipandport['ip'] . ':' . $row_ipandport['port'] . '<br />',
|
|
|
|
'value' => $row_ipandport['id']
|
|
|
|
);
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$ssl_ipsandports = array();
|
|
|
|
while ($row_ssl_ipandport = $result_ssl_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
if (filter_var($row_ssl_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
|
|
|
$row_ssl_ipandport['ip'] = '[' . $row_ssl_ipandport['ip'] . ']';
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$ssl_ipsandports[] = array(
|
|
|
|
'label' => $row_ssl_ipandport['ip'] . ':' . $row_ssl_ipandport['port'] . '<br />',
|
|
|
|
'value' => $row_ssl_ipandport['id']
|
|
|
|
);
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$standardsubdomains = array();
|
|
|
|
$result_standardsubdomains_stmt = Database::query("
|
|
|
|
SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` WHERE `d`.`id` = `c`.`standardsubdomain`
|
2012-12-02 14:16:22 +00:00
|
|
|
");
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
while ($row_standardsubdomain = $result_standardsubdomains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
$standardsubdomains[] = $row_standardsubdomain['id'];
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
if (count($standardsubdomains) > 0) {
|
|
|
|
$standardsubdomains = " AND `d`.`id` NOT IN (" . join(',', $standardsubdomains) . ") ";
|
|
|
|
} else {
|
|
|
|
$standardsubdomains = '';
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
$domains = \Froxlor\UI\HTML::makeoption($lng['domains']['noaliasdomain'], 0, NULL, true);
|
2018-02-15 13:44:48 +00:00
|
|
|
$result_domains_stmt = Database::prepare("
|
|
|
|
SELECT `d`.`id`, `d`.`domain`, `c`.`loginname` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
|
2018-12-22 07:15:31 +00:00
|
|
|
WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = 0" . $standardsubdomains . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . "
|
2018-02-15 13:44:48 +00:00
|
|
|
AND `d`.`customerid`=`c`.`customerid` ORDER BY `loginname`, `domain` ASC
|
2012-12-02 14:16:22 +00:00
|
|
|
");
|
2018-02-15 13:44:48 +00:00
|
|
|
$params = array();
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
|
|
|
Database::pexecute($result_domains_stmt, $params);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-21 17:31:06 +00:00
|
|
|
$domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')', $row_domain['id']);
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
$subtodomains = \Froxlor\UI\HTML::makeoption($lng['domains']['nosubtomaindomain'], 0, NULL, true);
|
2018-02-15 13:44:48 +00:00
|
|
|
$result_domains_stmt = Database::prepare("
|
|
|
|
SELECT `d`.`id`, `d`.`domain`, `c`.`loginname` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
|
2018-12-22 07:15:31 +00:00
|
|
|
WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = 0 AND `d`.`ismainbutsubto` = 0 " . $standardsubdomains . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . "
|
2018-02-15 13:44:48 +00:00
|
|
|
AND `d`.`customerid`=`c`.`customerid` ORDER BY `loginname`, `domain` ASC
|
2013-11-13 14:39:20 +00:00
|
|
|
");
|
2018-02-15 13:44:48 +00:00
|
|
|
// params from above still valid
|
|
|
|
Database::pexecute($result_domains_stmt, $params);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-21 17:31:06 +00:00
|
|
|
$subtodomains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')', $row_domain['id']);
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$phpconfigs = '';
|
|
|
|
$configs = Database::query("
|
|
|
|
SELECT c.*, fc.description as interpreter
|
|
|
|
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
|
|
|
|
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
|
2013-11-13 14:39:20 +00:00
|
|
|
");
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
2018-12-21 17:31:06 +00:00
|
|
|
$phpconfigs .= \Froxlor\UI\HTML::makeoption($row['description'] . " [" . $row['interpreter'] . "]", $row['id'], Settings::Get('phpfpm.defaultini'), true, true);
|
2018-02-15 13:44:48 +00:00
|
|
|
} else {
|
2018-12-21 17:31:06 +00:00
|
|
|
$phpconfigs .= \Froxlor\UI\HTML::makeoption($row['description'], $row['id'], Settings::Get('system.mod_fcgid_defaultini'), true, true);
|
2012-12-02 14:16:22 +00:00
|
|
|
}
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
// create serveralias options
|
|
|
|
$serveraliasoptions = "";
|
2018-12-22 07:15:31 +00:00
|
|
|
$serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_wildcard'], '0', '0', true, true);
|
|
|
|
$serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_www'], '1', '0', true, true);
|
|
|
|
$serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_none'], '2', '0', true, true);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
$subcanemaildomain = \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['never'], '0', '0', true, true);
|
|
|
|
$subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['choosableno'], '1', '0', true, true);
|
|
|
|
$subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['choosableyes'], '2', '0', true, true);
|
|
|
|
$subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['always'], '3', '0', true, true);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$add_date = date('Y-m-d');
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$domain_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_add.php';
|
2018-12-21 10:22:03 +00:00
|
|
|
$domain_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($domain_add_data);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$title = $domain_add_data['domain_add']['title'];
|
|
|
|
$image = $domain_add_data['domain_add']['image'];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains_add") . "\";");
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
|
|
|
} elseif ($action == 'edit' && $id != 0) {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Domains::getLocal($userinfo, array(
|
2018-02-15 13:44:48 +00:00
|
|
|
'id' => $id
|
|
|
|
))->get();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
if ($result['domain'] != '') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$subdomains_stmt = Database::prepare("
|
|
|
|
SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE
|
|
|
|
`parentdomainid` = :resultid
|
|
|
|
");
|
|
|
|
$subdomains = Database::pexecute_first($subdomains_stmt, array(
|
|
|
|
'resultid' => $result['id']
|
|
|
|
));
|
|
|
|
$subdomains = $subdomains['count'];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$alias_check_stmt = Database::prepare("
|
|
|
|
SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE
|
|
|
|
`aliasdomain` = :resultid
|
|
|
|
");
|
|
|
|
$alias_check = Database::pexecute_first($alias_check_stmt, array(
|
|
|
|
'resultid' => $result['id']
|
|
|
|
));
|
|
|
|
$alias_check = $alias_check['count'];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$domain_emails_result_stmt = Database::prepare("
|
|
|
|
SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders`
|
|
|
|
FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid` = :customerid AND `domainid` = :id
|
|
|
|
");
|
|
|
|
Database::pexecute($domain_emails_result_stmt, array(
|
|
|
|
'customerid' => $result['customerid'],
|
|
|
|
'id' => $result['id']
|
|
|
|
));
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$emails = Database::num_rows();
|
|
|
|
$email_forwarders = 0;
|
|
|
|
$email_accounts = 0;
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
while ($domain_emails_row = $domain_emails_result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
if ($domain_emails_row['destination'] != '') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-19 16:13:41 +00:00
|
|
|
$domain_emails_row['destination'] = explode(' ', \Froxlor\FileDir::makeCorrectDestination($domain_emails_row['destination']));
|
2018-02-15 13:44:48 +00:00
|
|
|
$email_forwarders += count($domain_emails_row['destination']);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
if (in_array($domain_emails_row['email_full'], $domain_emails_row['destination'])) {
|
|
|
|
$email_forwarders -= 1;
|
|
|
|
$email_accounts ++;
|
2012-12-02 14:16:22 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$ipsresult_stmt = Database::prepare("
|
|
|
|
SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :id
|
|
|
|
");
|
|
|
|
Database::pexecute($ipsresult_stmt, array(
|
|
|
|
'id' => $result['id']
|
|
|
|
));
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
$usedips = array();
|
|
|
|
while ($ipsresultrow = $ipsresult_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
$usedips[] = $ipsresultrow['id_ipandports'];
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
Domains::getLocal($userinfo, $_POST)->update();
|
2018-02-15 13:44:48 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2012-12-02 14:16:22 +00:00
|
|
|
}
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
2016-04-11 07:19:43 +00:00
|
|
|
'page' => $page,
|
|
|
|
's' => $s
|
|
|
|
));
|
2013-11-13 14:39:20 +00:00
|
|
|
} else {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
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' )
|
2018-12-22 07:15:31 +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']
|
|
|
|
);
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
2013-11-13 14:39:20 +00:00
|
|
|
}
|
|
|
|
Database::pexecute($result_customers_stmt, $params);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-21 18:16:49 +00:00
|
|
|
$customers .= \Froxlor\UI\HTML::makeoption(\Froxlor\User::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']
|
|
|
|
));
|
2018-12-21 18:16:49 +00:00
|
|
|
$result['customername'] = \Froxlor\User::getCorrectFullUserDetails($customer) . ' (' . $customer['loginname'] . ')';
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-22 07:15:31 +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') {
|
2018-12-19 15:57:03 +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']
|
|
|
|
));
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_admin = $result_admins_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-21 18:16:49 +00:00
|
|
|
$admins .= \Froxlor\UI\HTML::makeoption(\Froxlor\User::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']
|
|
|
|
));
|
2018-12-21 18:16:49 +00:00
|
|
|
$result['adminname'] = \Froxlor\User::getCorrectFullUserDetails($admin) . ' (' . $admin['loginname'] . ')';
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$result['domain'] = $idna_convert->decode($result['domain']);
|
2018-12-22 07:15:31 +00:00
|
|
|
$domains = \Froxlor\UI\HTML::makeoption($lng['domains']['noaliasdomain'], 0, null, true);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
$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']
|
|
|
|
));
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-21 17:31:06 +00:00
|
|
|
$domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['aliasdomain']);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
$subtodomains = \Froxlor\UI\HTML::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` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
|
|
|
|
WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = '0' AND `d`.`id` <> :id
|
2018-12-22 07:15:31 +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']
|
|
|
|
);
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
2013-11-13 14:39:20 +00:00
|
|
|
}
|
|
|
|
Database::pexecute($result_domains_stmt, $params);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-21 17:31:06 +00:00
|
|
|
$subtodomains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['ismainbutsubto']);
|
2010-08-06 05:43:28 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($userinfo['ip'] == "-1") {
|
2013-11-13 14:39:20 +00:00
|
|
|
$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(
|
2018-12-22 07:15:31 +00:00
|
|
|
'ipid' => $userinfo['ip']
|
2016-04-11 07:19:43 +00:00
|
|
|
));
|
2018-12-19 15:57:03 +00:00
|
|
|
|
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']
|
|
|
|
));
|
2018-12-19 15:57:03 +00:00
|
|
|
|
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
|
|
|
}
|
2018-12-19 15:57:03 +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
|
|
|
}
|
2018-12-19 15:57:03 +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
|
|
|
}
|
2018-12-19 15:57:03 +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
|
|
|
}
|
2018-12-19 15:57:03 +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);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
$serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_wildcard'], '0', $_value, true, true);
|
|
|
|
$serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_www'], '1', $_value, true, true);
|
|
|
|
$serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_none'], '2', $_value, true, true);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
$subcanemaildomain = \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['never'], '0', $result['subcanemaildomain'], true, true);
|
|
|
|
$subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['choosableno'], '1', $result['subcanemaildomain'], true, true);
|
|
|
|
$subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['choosableyes'], '2', $result['subcanemaildomain'], true, true);
|
|
|
|
$subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['always'], '3', $result['subcanemaildomain'], true, true);
|
|
|
|
$speciallogfile = ($result['speciallogfile'] == 1 ? $lng['panel']['yes'] : $lng['panel']['no']);
|
2010-01-27 08:54:31 +00:00
|
|
|
$result['add_date'] = date('Y-m-d', $result['add_date']);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$phpconfigs = '';
|
2018-01-08 12:59:30 +00:00
|
|
|
$phpconfigs_result_stmt = Database::query("
|
|
|
|
SELECT c.*, fc.description as interpreter
|
|
|
|
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
|
|
|
|
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
|
|
|
|
");
|
2018-12-23 18:34:32 +00:00
|
|
|
$c_allowed_configs = \Froxlor\Customer\Customer::getCustomerDetail($result['customerid'], 'allowed_phpconfigs');
|
2018-02-15 13:44:48 +00:00
|
|
|
if (! empty($c_allowed_configs)) {
|
2018-02-09 12:57:23 +00:00
|
|
|
$c_allowed_configs = json_decode($c_allowed_configs, true);
|
|
|
|
} else {
|
|
|
|
$c_allowed_configs = array();
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2013-11-13 14:39:20 +00:00
|
|
|
while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-02-15 13:44:48 +00:00
|
|
|
$disabled = ! empty($c_allowed_configs) && ! in_array($phpconfigs_row['id'], $c_allowed_configs);
|
2018-01-08 12:59:30 +00:00
|
|
|
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
2018-12-21 17:31:06 +00:00
|
|
|
$phpconfigs .= \Froxlor\UI\HTML::makeoption($phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]", $phpconfigs_row['id'], $result['phpsettingid'], true, true, null, $disabled);
|
2018-01-08 12:59:30 +00:00
|
|
|
} else {
|
2018-12-21 17:31:06 +00:00
|
|
|
$phpconfigs .= \Froxlor\UI\HTML::makeoption($phpconfigs_row['description'], $phpconfigs_row['id'], $result['phpsettingid'], true, true, null, $disabled);
|
2018-01-08 12:59:30 +00:00
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-24 12:50:45 +00:00
|
|
|
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
|
2018-12-19 15:57:03 +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';
|
2018-12-21 10:22:03 +00:00
|
|
|
$domain_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($domain_edit_data);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2011-02-08 11:53:24 +00:00
|
|
|
$title = $domain_edit_data['domain_edit']['title'];
|
|
|
|
$image = $domain_edit_data['domain_edit']['image'];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
$speciallogwarning = sprintf($lng['admin']['speciallogwarning'], $lng['admin']['delete_statistics']);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains_edit") . "\";");
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-09 12:57:23 +00:00
|
|
|
} elseif ($action == 'jqGetCustomerPHPConfigs') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-02-09 12:57:23 +00:00
|
|
|
$customerid = intval($_POST['customerid']);
|
2018-12-23 18:34:32 +00:00
|
|
|
$allowed_phpconfigs = \Froxlor\Customer\Customer::getCustomerDetail($customerid, 'allowed_phpconfigs');
|
2018-02-15 13:44:48 +00:00
|
|
|
echo ! empty($allowed_phpconfigs) ? $allowed_phpconfigs : json_encode(array());
|
|
|
|
exit();
|
2016-04-11 07:19:43 +00:00
|
|
|
} elseif ($action == 'import') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2014-12-15 13:49:34 +00:00
|
|
|
$customerid = intval($_POST['customerid']);
|
2018-12-21 15:32:44 +00:00
|
|
|
$separator = \Froxlor\Validate\Validate::validate($_POST['separator'], 'separator');
|
|
|
|
$offset = (int) \Froxlor\Validate\Validate::validate($_POST['offset'], 'offset', "/[0-9]/i");
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2014-12-15 13:49:34 +00:00
|
|
|
$file_name = $_FILES['file']['tmp_name'];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2014-12-15 13:49:34 +00:00
|
|
|
$result = array();
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2014-12-15 13:49:34 +00:00
|
|
|
try {
|
2018-12-19 18:42:50 +00:00
|
|
|
$bulk = new \Froxlor\Bulk\DomainBulkAction($file_name, $customerid);
|
2014-12-15 13:49:34 +00:00
|
|
|
$result = $bulk->doImport($separator, $offset);
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::standard_error('domain_import_error', $e->getMessage());
|
2014-12-15 13:49:34 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
|
|
|
if (! empty($bulk->getErrors())) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error(implode("<br>", $bulk->getErrors()));
|
2018-12-02 19:06:53 +00:00
|
|
|
}
|
|
|
|
|
2014-12-15 13:49:34 +00:00
|
|
|
// update customer/admin counters
|
2018-12-21 16:41:22 +00:00
|
|
|
\Froxlor\User::updateCounters(false);
|
2018-12-20 11:38:18 +00:00
|
|
|
\Froxlor\System\Cronjob::inserttask('1');
|
|
|
|
\Froxlor\System\Cronjob::inserttask('4');
|
2018-12-19 15:57:03 +00:00
|
|
|
|
|
|
|
$result_str = $result['imported'] . ' / ' . $result['all'] . (! empty($result['note']) ? ' (' . $result['note'] . ')' : '');
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::standard_success('domain_import_successfully', $result_str, array(
|
2016-04-11 07:19:43 +00:00
|
|
|
'filename' => $filename,
|
|
|
|
'action' => '',
|
|
|
|
'page' => 'domains'
|
|
|
|
));
|
2014-12-15 13:49:34 +00:00
|
|
|
} else {
|
2018-12-22 07:15:31 +00:00
|
|
|
$customers = \Froxlor\UI\HTML::makeoption($lng['panel']['please_choose'], 0, 0, true);
|
2014-12-15 13:49:34 +00:00
|
|
|
$result_customers_stmt = Database::prepare("
|
|
|
|
SELECT `customerid`, `loginname`, `name`, `firstname`, `company`
|
2018-12-22 07:15:31 +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();
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
2014-12-15 13:49:34 +00:00
|
|
|
}
|
|
|
|
Database::pexecute($result_customers_stmt, $params);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2014-12-15 13:49:34 +00:00
|
|
|
while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-21 18:16:49 +00:00
|
|
|
$customers .= \Froxlor\UI\HTML::makeoption(\Froxlor\User::getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']);
|
2014-12-15 13:49:34 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +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';
|
2018-12-21 10:22:03 +00:00
|
|
|
$domain_import_form = \Froxlor\UI\HtmlForm::genHTMLForm($domain_import_data);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2014-12-15 13:49:34 +00:00
|
|
|
$title = $domain_import_data['domain_import']['title'];
|
|
|
|
$image = $domain_import_data['domain_import']['image'];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains_import") . "\";");
|
2014-12-15 13:49:34 +00:00
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2016-05-13 11:27:33 +00:00
|
|
|
} elseif ($page == 'domaindnseditor' && Settings::Get('system.dnsenabled') == '1') {
|
2018-12-01 12:33:08 +00:00
|
|
|
|
2018-12-19 15:57:03 +00:00
|
|
|
require_once __DIR__ . '/dns_editor.php';
|
2016-09-26 09:48:36 +00:00
|
|
|
} elseif ($page == 'sslcertificates') {
|
2018-12-01 12:33:08 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
require_once __DIR__ . '/ssl_certificates.php';
|
2018-12-01 12:33:08 +00:00
|
|
|
} elseif ($page == 'logfiles') {
|
|
|
|
|
2018-12-19 15:57:03 +00:00
|
|
|
require_once __DIR__ . '/logfiles_viewer.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']);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
$row['ipandport'] = '';
|
2019-11-15 14:11:24 +00:00
|
|
|
foreach ($row['ipsandports'] as $rowip) {
|
2016-04-11 07:19:43 +00:00
|
|
|
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']);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
$row['termination_css'] = "";
|
|
|
|
if ($row['termination_date'] != "") {
|
|
|
|
$cdate = strtotime($row['termination_date'] . " 23:59:59");
|
|
|
|
$today = time();
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($cdate < $today) {
|
|
|
|
$row['termination_css'] = 'domain-expired';
|
|
|
|
} else {
|
|
|
|
$row['termination_css'] = 'domain-canceled';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|