2010-01-27 08:54:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file is part of the Froxlor project.
|
|
|
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
|
|
|
*
|
2022-04-28 18:48:00 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2010-01-27 08:54:31 +00:00
|
|
|
*
|
2022-04-28 18:48:00 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2011-05-04 09:59:20 +00:00
|
|
|
*
|
2022-04-28 18:48:00 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you can also view it online at
|
|
|
|
* https://files.froxlor.org/misc/COPYING.txt
|
|
|
|
*
|
|
|
|
* @copyright the authors
|
|
|
|
* @author Froxlor team <team@froxlor.org>
|
|
|
|
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
|
2010-01-27 08:54:31 +00:00
|
|
|
*/
|
|
|
|
|
2022-02-20 17:00:44 +00:00
|
|
|
const AREA = 'admin';
|
|
|
|
require __DIR__ . '/lib/init.php';
|
|
|
|
|
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;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\Bulk\DomainBulkAction;
|
|
|
|
use Froxlor\Cron\TaskId;
|
2023-09-24 15:03:15 +00:00
|
|
|
use Froxlor\CurrentUser;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\Customer\Customer;
|
2022-02-20 17:00:44 +00:00
|
|
|
use Froxlor\Database\Database;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\FileDir;
|
|
|
|
use Froxlor\FroxlorLogger;
|
2022-02-20 17:00:44 +00:00
|
|
|
use Froxlor\Settings;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\System\Cronjob;
|
|
|
|
use Froxlor\UI\Collection;
|
|
|
|
use Froxlor\UI\HTML;
|
|
|
|
use Froxlor\UI\Listing;
|
2022-02-22 16:09:36 +00:00
|
|
|
use Froxlor\UI\Panel\UI;
|
2022-02-20 17:00:44 +00:00
|
|
|
use Froxlor\UI\Request;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\UI\Response;
|
|
|
|
use Froxlor\User;
|
|
|
|
use Froxlor\Validate\Validate;
|
2018-12-18 12:45:05 +00:00
|
|
|
|
2022-12-30 20:43:27 +00:00
|
|
|
$id = (int)Request::any('id');
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2016-04-11 07:19:43 +00:00
|
|
|
if ($page == 'domains' || $page == 'overview') {
|
2013-11-13 14:39:20 +00:00
|
|
|
if ($action == '') {
|
2022-04-28 18:48:00 +00:00
|
|
|
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_domains");
|
2022-02-22 16:09:36 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
try {
|
2022-08-26 07:06:42 +00:00
|
|
|
$customerCollection = (new Collection(Customers::class, $userinfo));
|
2022-03-10 15:39:49 +00:00
|
|
|
$domain_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.domains.php';
|
2022-04-28 18:48:00 +00:00
|
|
|
$collection = (new Collection(Domains::class, $userinfo))
|
|
|
|
->has('customer', Customers::class, 'customerid', 'customerid')
|
2022-09-30 07:44:11 +00:00
|
|
|
->withPagination($domain_list_data['domain_list']['columns'], $domain_list_data['domain_list']['default_sorting']);
|
2022-03-10 15:39:49 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2022-03-10 15:39:49 +00:00
|
|
|
}
|
2022-02-22 16:09:36 +00:00
|
|
|
|
2022-02-25 19:41:06 +00:00
|
|
|
$actions_links = false;
|
2022-10-19 08:16:17 +00:00
|
|
|
if (CurrentUser::canAddResource('domains')) {
|
2022-02-25 19:41:06 +00:00
|
|
|
$actions_links = [];
|
|
|
|
$actions_links[] = [
|
|
|
|
'href' => $linker->getLink(['section' => 'domains', 'page' => $page, 'action' => 'add']),
|
2022-04-28 18:48:00 +00:00
|
|
|
'label' => lng('admin.domain_add')
|
2022-02-25 19:41:06 +00:00
|
|
|
];
|
|
|
|
$actions_links[] = [
|
|
|
|
'href' => $linker->getLink(['section' => 'domains', 'page' => $page, 'action' => 'import']),
|
2022-04-28 18:48:00 +00:00
|
|
|
'label' => lng('domains.domain_import'),
|
2022-02-25 19:41:06 +00:00
|
|
|
'icon' => 'fa-solid fa-file-import',
|
2022-09-20 06:09:53 +00:00
|
|
|
'class' => 'btn-outline-secondary'
|
2022-02-25 19:41:06 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/table.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'listing' => Listing::format($collection, $domain_list_data, 'domain_list'),
|
2022-02-25 19:41:06 +00:00
|
|
|
'actions_links' => $actions_links
|
|
|
|
]);
|
2018-02-15 13:44:48 +00:00
|
|
|
} elseif ($action == 'delete' && $id != 0) {
|
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
$json_result = Domains::getLocal($userinfo, [
|
2018-02-15 13:44:48 +00:00
|
|
|
'id' => $id,
|
|
|
|
'no_std_subdomain' => true
|
2022-04-28 18:48:00 +00:00
|
|
|
])->get();
|
2018-02-15 13:44:48 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($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");
|
2022-04-28 18:48:00 +00:00
|
|
|
$alias_check = Database::pexecute_first($alias_check_stmt, [
|
2018-02-15 13:44:48 +00:00
|
|
|
'id' => $id
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
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) {
|
|
|
|
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) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename, [
|
2022-03-14 21:51:59 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2018-02-15 13:44:48 +00:00
|
|
|
} elseif ($alias_check['count'] > 0) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::standardError('domains_cantdeletedomainwithaliases');
|
2018-02-15 13:44:48 +00:00
|
|
|
} else {
|
2023-05-23 12:36:45 +00:00
|
|
|
HTML::askYesNo('admin_domain_reallydelete', $filename, [
|
2018-02-15 13:44:48 +00:00
|
|
|
'id' => $id,
|
|
|
|
'page' => $page,
|
|
|
|
'action' => $action
|
2023-05-23 12:36:45 +00:00
|
|
|
], $idna_convert->decode($result['domain']));
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} elseif ($action == 'add') {
|
|
|
|
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) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename, [
|
2022-03-14 21:51:59 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2018-02-15 13:44:48 +00:00
|
|
|
} else {
|
2022-03-10 15:39:49 +00:00
|
|
|
$customers = [
|
2022-04-28 18:48:00 +00:00
|
|
|
0 => lng('panel.please_choose')
|
2022-03-10 15:39:49 +00:00
|
|
|
];
|
2018-02-15 13:44:48 +00:00
|
|
|
$result_customers_stmt = Database::prepare("
|
|
|
|
SELECT `customerid`, `loginname`, `name`, `firstname`, `company`
|
2022-05-25 16:54:15 +00:00
|
|
|
FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid ") . " ORDER BY COALESCE(NULLIF(`name`,''), `company`) ASC");
|
2022-04-28 18:48:00 +00:00
|
|
|
$params = [];
|
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)) {
|
2022-04-28 18:48:00 +00:00
|
|
|
$customers[$row_customer['customerid']] = User::getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')';
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
$admins = [];
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($userinfo['customers_see_all'] == '1') {
|
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)) {
|
2022-04-28 18:48:00 +00:00
|
|
|
$admins[$row_admin['adminid']] = User::getCorrectFullUserDetails($row_admin) . ' (' . $row_admin['loginname'] . ')';
|
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
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
$admin_ip = Database::pexecute_first($admin_ip_stmt, [
|
2018-12-22 07:15:31 +00:00
|
|
|
'ipid' => $userinfo['ip']
|
2022-04-28 18:48:00 +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
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
Database::pexecute($result_ipsandports_stmt, [
|
2018-02-15 13:44:48 +00:00
|
|
|
'ipid' => $admin_ip['ip']
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
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
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
Database::pexecute($result_ssl_ipsandports_stmt, [
|
2018-02-15 13:44:48 +00:00
|
|
|
'ipid' => $admin_ip['ip']
|
2022-04-28 18:48:00 +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
|
|
|
// Build array holding all IPs and Ports available to this admin
|
2022-03-10 15:39:49 +00:00
|
|
|
$ipsandports = [];
|
2018-02-15 13:44:48 +00:00
|
|
|
while ($row_ipandport = $result_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
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
|
|
|
|
2022-04-28 18:48:00 +00:00
|
|
|
$ipsandports[] = [
|
2022-03-10 15:39:49 +00:00
|
|
|
'label' => $row_ipandport['ip'] . ':' . $row_ipandport['port'],
|
2018-02-15 13:44:48 +00:00
|
|
|
'value' => $row_ipandport['id']
|
2022-04-28 18:48:00 +00:00
|
|
|
];
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
$ssl_ipsandports = [];
|
2018-02-15 13:44:48 +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)) {
|
|
|
|
$row_ssl_ipandport['ip'] = '[' . $row_ssl_ipandport['ip'] . ']';
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-04-28 18:48:00 +00:00
|
|
|
$ssl_ipsandports[] = [
|
2022-03-10 15:39:49 +00:00
|
|
|
'label' => $row_ssl_ipandport['ip'] . ':' . $row_ssl_ipandport['port'],
|
2018-02-15 13:44:48 +00:00
|
|
|
'value' => $row_ssl_ipandport['id']
|
2022-04-28 18:48:00 +00:00
|
|
|
];
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
$standardsubdomains = [];
|
2018-02-15 13:44:48 +00:00
|
|
|
$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)) {
|
2022-03-10 15:39:49 +00:00
|
|
|
$standardsubdomains[$row_standardsubdomain['id']] = $row_standardsubdomain['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
|
|
|
if (count($standardsubdomains) > 0) {
|
|
|
|
$standardsubdomains = " AND `d`.`id` NOT IN (" . join(',', $standardsubdomains) . ") ";
|
|
|
|
} else {
|
|
|
|
$standardsubdomains = '';
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
$domains = [
|
2022-04-28 18:48:00 +00:00
|
|
|
0 => lng('domains.noaliasdomain')
|
2022-03-10 15:39:49 +00:00
|
|
|
];
|
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
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
$params = [];
|
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)) {
|
2022-03-10 15:39:49 +00:00
|
|
|
$domains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')';
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
$phpconfigs = [];
|
2018-02-15 13:44:48 +00:00
|
|
|
$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)) {
|
2022-04-28 18:48:00 +00:00
|
|
|
if ((int)Settings::Get('phpfpm.enabled') == 1) {
|
2022-03-10 15:39:49 +00:00
|
|
|
$phpconfigs[$row['id']] = $row['description'] . " [" . $row['interpreter'] . "]";
|
2018-02-15 13:44:48 +00:00
|
|
|
} else {
|
2022-03-10 15:39:49 +00:00
|
|
|
$phpconfigs[$row['id']] = $row['description'];
|
2012-12-02 14:16:22 +00:00
|
|
|
}
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2023-04-25 17:42:27 +00:00
|
|
|
$openbasedir = [
|
|
|
|
0 => lng('domain.docroot'),
|
|
|
|
1 => lng('domain.homedir'),
|
|
|
|
2 => lng('domain.docparent')
|
|
|
|
];
|
2023-05-23 12:36:45 +00:00
|
|
|
|
2018-02-15 13:44:48 +00:00
|
|
|
// create serveralias options
|
2022-03-10 15:39:49 +00:00
|
|
|
$serveraliasoptions = [
|
2022-04-28 18:48:00 +00:00
|
|
|
0 => lng('domains.serveraliasoption_wildcard'),
|
|
|
|
1 => lng('domains.serveraliasoption_www'),
|
|
|
|
2 => lng('domains.serveraliasoption_none')
|
2022-03-10 15:39:49 +00:00
|
|
|
];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
$subcanemaildomain = [
|
2022-04-28 18:48:00 +00:00
|
|
|
0 => lng('admin.subcanemaildomain.never'),
|
|
|
|
1 => lng('admin.subcanemaildomain.choosableno'),
|
|
|
|
2 => lng('admin.subcanemaildomain.choosableyes'),
|
|
|
|
3 => lng('admin.subcanemaildomain.always')
|
2022-03-10 15:39:49 +00:00
|
|
|
];
|
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-19 15:57:03 +00:00
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/form.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'formaction' => $linker->getLink(['section' => 'domains']),
|
2022-03-10 15:39:49 +00:00
|
|
|
'formdata' => $domain_add_data['domain_add']
|
|
|
|
]);
|
2018-02-15 13:44:48 +00:00
|
|
|
}
|
|
|
|
} elseif ($action == 'edit' && $id != 0) {
|
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
$json_result = Domains::getLocal($userinfo, [
|
2018-02-15 13:44:48 +00:00
|
|
|
'id' => $id
|
2022-04-28 18:48:00 +00:00
|
|
|
])->get();
|
2018-02-15 13:44:48 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($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'] != '') {
|
|
|
|
$subdomains_stmt = Database::prepare("
|
|
|
|
SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE
|
|
|
|
`parentdomainid` = :resultid
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
$subdomains = Database::pexecute_first($subdomains_stmt, [
|
2018-02-15 13:44:48 +00:00
|
|
|
'resultid' => $result['id']
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2018-02-15 13:44:48 +00:00
|
|
|
$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
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
$alias_check = Database::pexecute_first($alias_check_stmt, [
|
2018-02-15 13:44:48 +00:00
|
|
|
'resultid' => $result['id']
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2018-02-15 13:44:48 +00:00
|
|
|
$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
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
Database::pexecute($domain_emails_result_stmt, [
|
2018-02-15 13:44:48 +00:00
|
|
|
'customerid' => $result['customerid'],
|
|
|
|
'id' => $result['id']
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
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)) {
|
|
|
|
if ($domain_emails_row['destination'] != '') {
|
2022-04-28 18:48:00 +00:00
|
|
|
$domain_emails_row['destination'] = explode(' ', 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;
|
2022-03-10 15:39:49 +00:00
|
|
|
$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
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
Database::pexecute($ipsresult_stmt, [
|
2018-02-15 13:44:48 +00:00
|
|
|
'id' => $result['id']
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-04-28 18:48:00 +00:00
|
|
|
$usedips = [];
|
2018-02-15 13:44:48 +00:00
|
|
|
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 {
|
2019-11-15 15:36:14 +00:00
|
|
|
// remove ssl ip/ports if set is empty
|
2019-11-27 17:32:27 +00:00
|
|
|
if (!isset($_POST['ssl_ipandport']) || empty($_POST['ssl_ipandport'])) {
|
2019-11-15 15:36:14 +00:00
|
|
|
$_POST['remove_ssl_ipandport'] = true;
|
|
|
|
}
|
2018-12-22 07:15:31 +00:00
|
|
|
Domains::getLocal($userinfo, $_POST)->update();
|
2018-02-15 13:44:48 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2012-12-02 14:16:22 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename, [
|
2022-03-14 21:51:59 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
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') {
|
2022-03-10 15:39:49 +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
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
$params = [
|
2013-11-13 14:39:20 +00:00
|
|
|
'subdomains' => $subdomains,
|
|
|
|
'emails' => $emails,
|
|
|
|
'forwarders' => $email_forwarders,
|
|
|
|
'accounts' => $email_accounts,
|
|
|
|
'customerid' => $result['customerid']
|
2022-04-28 18:48:00 +00:00
|
|
|
];
|
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)) {
|
2022-04-28 18:48:00 +00:00
|
|
|
$customers[$row_customer['customerid']] = User::getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')';
|
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
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
$customer = Database::pexecute_first($customer_stmt, [
|
2016-04-11 07:19:43 +00:00
|
|
|
'customerid' => $result['customerid']
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
|
|
|
$result['customername'] = User::getCorrectFullUserDetails($customer);
|
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') {
|
2022-03-10 15:39:49 +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
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
Database::pexecute($result_admins_stmt, [
|
2016-04-11 07:19:43 +00:00
|
|
|
'adminid' => $result['adminid']
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
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)) {
|
2022-04-28 18:48:00 +00:00
|
|
|
$admins[$row_admin['adminid']] = User::getCorrectFullUserDetails($row_admin) . ' (' . $row_admin['loginname'] . ')';
|
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
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
$admin = Database::pexecute_first($admin_stmt, [
|
2016-04-11 07:19:43 +00:00
|
|
|
'adminid' => $result['adminid']
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
|
|
|
$result['adminname'] = User::getCorrectFullUserDetails($admin) . ' (' . $admin['loginname'] . ')';
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
$domains = [
|
2022-04-28 18:48:00 +00:00
|
|
|
0 => lng('domains.noaliasdomain')
|
2022-03-10 15:39:49 +00:00
|
|
|
];
|
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
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
Database::pexecute($result_domains_stmt, [
|
2016-04-11 07:19:43 +00:00
|
|
|
'id' => $result['id'],
|
|
|
|
'customerid' => $result['customerid']
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
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)) {
|
2022-03-10 15:39:49 +00:00
|
|
|
$domains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']);
|
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['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
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
$admin_ip = Database::pexecute_first($admin_ip_stmt, [
|
2018-12-22 07:15:31 +00:00
|
|
|
'ipid' => $userinfo['ip']
|
2022-04-28 18:48:00 +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
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
Database::pexecute($result_ipsandports_stmt, [
|
2016-04-11 07:19:43 +00:00
|
|
|
'ipid' => $admin_ip['ip']
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
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
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
Database::pexecute($result_ssl_ipsandports_stmt, [
|
2016-04-11 07:19:43 +00:00
|
|
|
'ipid' => $admin_ip['ip']
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
$ipsandports = [];
|
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'] . ']';
|
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
$ipsandports[] = [
|
2022-03-10 15:39:49 +00:00
|
|
|
'label' => $row_ipandport['ip'] . ':' . $row_ipandport['port'],
|
2016-04-11 07:19:43 +00:00
|
|
|
'value' => $row_ipandport['id']
|
2022-04-28 18:48:00 +00:00
|
|
|
];
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
$ssl_ipsandports = [];
|
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'] . ']';
|
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
$ssl_ipsandports[] = [
|
2022-03-10 15:39:49 +00:00
|
|
|
'label' => $row_ssl_ipandport['ip'] . ':' . $row_ssl_ipandport['port'],
|
2016-04-11 07:19:43 +00:00
|
|
|
'value' => $row_ssl_ipandport['id']
|
2022-04-28 18:48:00 +00:00
|
|
|
];
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
// check that letsencrypt is not activated for wildcard domain
|
2013-10-14 07:50:55 +00:00
|
|
|
if ($result['iswildcarddomain'] == '1') {
|
2016-01-30 13:46:00 +00:00
|
|
|
$letsencrypt = 0;
|
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
|
|
|
|
2023-04-25 17:42:27 +00:00
|
|
|
$openbasedir = [
|
|
|
|
0 => lng('domain.docroot'),
|
|
|
|
1 => lng('domain.homedir'),
|
|
|
|
2 => lng('domain.docparent')
|
|
|
|
];
|
2023-05-23 12:36:45 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
$serveraliasoptions = [
|
2022-04-28 18:48:00 +00:00
|
|
|
0 => lng('domains.serveraliasoption_wildcard'),
|
|
|
|
1 => lng('domains.serveraliasoption_www'),
|
|
|
|
2 => lng('domains.serveraliasoption_none')
|
2022-03-10 15:39:49 +00:00
|
|
|
];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
$subcanemaildomain = [
|
2022-04-28 18:48:00 +00:00
|
|
|
0 => lng('admin.subcanemaildomain.never'),
|
|
|
|
1 => lng('admin.subcanemaildomain.choosableno'),
|
|
|
|
2 => lng('admin.subcanemaildomain.choosableyes'),
|
|
|
|
3 => lng('admin.subcanemaildomain.always')
|
2022-03-10 15:39:49 +00:00
|
|
|
];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +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
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
$c_allowed_configs = Customer::getCustomerDetail($result['customerid'], 'allowed_phpconfigs');
|
2022-03-10 15:39:49 +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 {
|
2022-04-28 18:48:00 +00:00
|
|
|
$c_allowed_configs = [];
|
2018-02-09 12:57:23 +00:00
|
|
|
}
|
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)) {
|
2022-03-10 15:39:49 +00:00
|
|
|
$disabled = !empty($c_allowed_configs) && !in_array($phpconfigs_row['id'], $c_allowed_configs);
|
|
|
|
if (!$disabled) {
|
2022-04-28 18:48:00 +00:00
|
|
|
if ((int)Settings::Get('phpfpm.enabled') == 1) {
|
2022-03-10 15:39:49 +00:00
|
|
|
$phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]";
|
|
|
|
} else {
|
|
|
|
$phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description'];
|
|
|
|
}
|
2018-01-08 12:59:30 +00:00
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2021-08-02 14:58:34 +00:00
|
|
|
if (Settings::Get('panel.allow_domain_change_customer') != '1') {
|
2022-04-28 18:48:00 +00:00
|
|
|
$result['customername'] .= ' (<a href="' . $linker->getLink([
|
|
|
|
'section' => 'customers',
|
|
|
|
'page' => 'customers',
|
|
|
|
'action' => 'su',
|
|
|
|
'id' => $customer['customerid']
|
|
|
|
]) . '" rel="external">' . $customer['loginname'] . '</a>)';
|
2021-08-02 14:58:34 +00:00
|
|
|
}
|
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-19 15:57:03 +00:00
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/form.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'formaction' => $linker->getLink(['section' => 'domains', 'id' => $id]),
|
2022-03-10 15:39:49 +00:00
|
|
|
'formdata' => $domain_edit_data['domain_edit'],
|
|
|
|
'editid' => $id
|
|
|
|
]);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-09 12:57:23 +00:00
|
|
|
} elseif ($action == 'jqGetCustomerPHPConfigs') {
|
|
|
|
$customerid = intval($_POST['customerid']);
|
2022-04-28 18:48:00 +00:00
|
|
|
$allowed_phpconfigs = Customer::getCustomerDetail($customerid, 'allowed_phpconfigs');
|
2022-03-10 15:39:49 +00:00
|
|
|
echo !empty($allowed_phpconfigs) ? $allowed_phpconfigs : json_encode([]);
|
2018-02-15 13:44:48 +00:00
|
|
|
exit();
|
2022-03-13 15:16:48 +00:00
|
|
|
} elseif ($action == 'jqSpeciallogfileNote') {
|
|
|
|
$domainid = intval($_POST['id']);
|
|
|
|
$newval = intval($_POST['newval']);
|
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
$json_result = Domains::getLocal($userinfo, [
|
2022-03-13 15:16:48 +00:00
|
|
|
'id' => $domainid
|
2022-04-28 18:48:00 +00:00
|
|
|
])->get();
|
2022-03-13 15:16:48 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2022-03-13 15:16:48 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
|
|
|
if ($newval != $result['speciallogfile']) {
|
2022-04-28 18:48:00 +00:00
|
|
|
echo json_encode(['changed' => true, 'info' => lng('admin.speciallogwarning')]);
|
2022-03-13 15:16:48 +00:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
echo 0;
|
|
|
|
exit();
|
2016-04-11 07:19:43 +00:00
|
|
|
} elseif ($action == 'import') {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2022-04-28 18:48:00 +00:00
|
|
|
$separator = Validate::validate($_POST['separator'], 'separator');
|
|
|
|
$offset = (int)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
|
|
|
|
2022-04-28 18:48:00 +00:00
|
|
|
$result = [];
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2014-12-15 13:49:34 +00:00
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
$bulk = new DomainBulkAction($file_name, $userinfo);
|
2014-12-15 13:49:34 +00:00
|
|
|
$result = $bulk->doImport($separator, $offset);
|
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::standardError('domain_import_error', $e->getMessage());
|
2014-12-15 13:49:34 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
if (!empty($bulk->getErrors())) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError(implode("<br>", $bulk->getErrors()));
|
2018-12-02 19:06:53 +00:00
|
|
|
}
|
|
|
|
|
2014-12-15 13:49:34 +00:00
|
|
|
// update customer/admin counters
|
2022-04-28 18:48:00 +00:00
|
|
|
User::updateCounters(false);
|
|
|
|
Cronjob::inserttask(TaskId::REBUILD_VHOST);
|
|
|
|
Cronjob::inserttask(TaskId::REBUILD_DNS);
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-10 15:39:49 +00:00
|
|
|
$result_str = $result['imported'] . ' / ' . $result['all'] . (!empty($result['note']) ? ' (' . $result['note'] . ')' : '');
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::standardSuccess('domain_import_successfully', $result_str, [
|
2016-04-11 07:19:43 +00:00
|
|
|
'filename' => $filename,
|
|
|
|
'action' => '',
|
|
|
|
'page' => 'domains'
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2014-12-15 13:49:34 +00:00
|
|
|
} else {
|
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-19 15:57:03 +00:00
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/form-note.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'formaction' => $linker->getLink(['section' => 'domains', 'page' => $page]),
|
2022-03-14 16:29:16 +00:00
|
|
|
'formdata' => $domain_import_data['domain_import'],
|
|
|
|
// alert-box
|
|
|
|
'type' => 'info',
|
2022-04-28 18:48:00 +00:00
|
|
|
'alert_msg' => lng('domains.import_description')
|
2022-03-14 16:29:16 +00:00
|
|
|
]);
|
2014-12-15 13:49:34 +00:00
|
|
|
}
|
2023-05-25 10:33:43 +00:00
|
|
|
} elseif ($action == 'duplicate') {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
|
|
|
try {
|
|
|
|
Domains::getLocal($userinfo, $_POST)->duplicate();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
Response::dynamicError($e->getMessage());
|
|
|
|
}
|
|
|
|
Response::redirectTo($filename, [
|
|
|
|
'page' => $page,
|
|
|
|
'searchfield' => 'd.domain_ace',
|
2023-09-24 15:03:15 +00:00
|
|
|
'searchtext' => Request::post('domain', "")
|
2023-05-25 10:33:43 +00:00
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
Response::redirectTo($filename, [
|
|
|
|
'page' => 'overview'
|
|
|
|
]);
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2022-03-16 12:54:57 +00:00
|
|
|
} elseif ($page == 'domainssleditor') {
|
|
|
|
require_once __DIR__ . '/ssl_editor.php';
|
2016-05-13 11:27:33 +00:00
|
|
|
} elseif ($page == 'domaindnseditor' && Settings::Get('system.dnsenabled') == '1') {
|
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-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
|
|
|
}
|