2010-01-20 16:55:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2010-01-25 10:06:34 +00:00
|
|
|
* This file is part of the Froxlor project.
|
2010-01-20 16:55:27 +00:00
|
|
|
* Copyright (c) 2003-2009 the SysCP Team (see authors).
|
2010-01-25 10:06:34 +00:00
|
|
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
2010-01-20 16:55:27 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the COPYING
|
|
|
|
* file that was distributed with this source code. You can also view the
|
2010-01-25 10:06:34 +00:00
|
|
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
2010-01-20 16:55:27 +00:00
|
|
|
*
|
|
|
|
* @copyright (c) the authors
|
2010-01-25 10:06:34 +00:00
|
|
|
* @author Florian Lippert <flo@syscp.org> (2003-2009)
|
|
|
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
|
|
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
2010-01-20 16:55:27 +00:00
|
|
|
* @package Panel
|
2011-05-04 09:59:20 +00:00
|
|
|
*
|
2010-01-20 16:55:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
define('AREA', 'customer');
|
2013-11-18 11:53:33 +00:00
|
|
|
require './lib/init.php';
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2018-12-19 15:57:03 +00:00
|
|
|
use Froxlor\Database\Database;
|
|
|
|
use Froxlor\Settings;
|
2018-12-18 12:45:05 +00:00
|
|
|
use Froxlor\Api\Commands\SubDomains as SubDomains;
|
|
|
|
use Froxlor\Api\Commands\Certificates as Certificates;
|
|
|
|
|
2016-07-27 11:45:54 +00:00
|
|
|
// redirect if this customer page is hidden via settings
|
|
|
|
if (Settings::IsInList('panel.customer_hide_options','domains')) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo('customer_index.php');
|
2016-07-27 11:45:54 +00:00
|
|
|
}
|
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
if (isset($_POST['id'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$id = intval($_POST['id']);
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif (isset($_GET['id'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$id = intval($_GET['id']);
|
|
|
|
}
|
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
if ($page == 'overview') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_domains");
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains") . "\";");
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif ($page == 'domains') {
|
|
|
|
if ($action == '') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_domains::domains");
|
|
|
|
$fields = array(
|
2013-10-13 14:42:53 +00:00
|
|
|
'd.domain' => $lng['domains']['domainname']
|
2010-01-20 16:55:27 +00:00
|
|
|
);
|
2018-12-21 10:22:03 +00:00
|
|
|
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_DOMAINS, $fields);
|
2018-12-02 10:50:45 +00:00
|
|
|
$domains_stmt = Database::prepare("SELECT `d`.`id`, `d`.`customerid`, `d`.`domain`, `d`.`documentroot`, `d`.`isbinddomain`, `d`.`isemaildomain`, `d`.`caneditdomain`, `d`.`iswildcarddomain`, `d`.`parentdomainid`, `d`.`letsencrypt`, `d`.`registration_date`, `d`.`termination_date`, `ad`.`id` AS `aliasdomainid`, `ad`.`domain` AS `aliasdomain`, `da`.`id` AS `domainaliasid`, `da`.`domain` AS `domainalias` FROM `" . TABLE_PANEL_DOMAINS . "` `d`
|
2013-10-31 10:51:01 +00:00
|
|
|
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `ad` ON `d`.`aliasdomain`=`ad`.`id`
|
|
|
|
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `da` ON `da`.`aliasdomain`=`d`.`id`
|
2013-10-31 11:11:50 +00:00
|
|
|
WHERE `d`.`customerid`= :customerid
|
2013-10-31 10:51:01 +00:00
|
|
|
AND `d`.`email_only`='0'
|
|
|
|
AND `d`.`id` <> :standardsubdomain " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit()
|
2018-06-21 06:12:00 +00:00
|
|
|
);
|
2013-10-31 10:51:01 +00:00
|
|
|
Database::pexecute($domains_stmt, array("customerid" => $userinfo['customerid'], "standardsubdomain" => $userinfo['standardsubdomain']));
|
|
|
|
$paging->setEntries(Database::num_rows());
|
2010-01-20 16:55:27 +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);
|
|
|
|
$domains = '';
|
|
|
|
$parentdomains_count = 0;
|
|
|
|
$domains_count = 0;
|
|
|
|
$domain_array = array();
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
while ($row = $domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$row['domain'] = $idna_convert->decode($row['domain']);
|
|
|
|
$row['aliasdomain'] = $idna_convert->decode($row['aliasdomain']);
|
|
|
|
$row['domainalias'] = $idna_convert->decode($row['domainalias']);
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
if ($row['parentdomainid'] == '0' && $row['caneditdomain'] == '1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$parentdomains_count++;
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-09-27 09:03:21 +00:00
|
|
|
/**
|
2013-09-29 16:40:25 +00:00
|
|
|
* check for set ssl-certs to show different state-icons
|
2013-09-27 09:03:21 +00:00
|
|
|
*/
|
2013-09-29 16:40:25 +00:00
|
|
|
// nothing (ssl_global)
|
|
|
|
$row['domain_hascert'] = 0;
|
2013-10-31 10:51:01 +00:00
|
|
|
$ssl_stmt = Database::prepare("SELECT * FROM `".TABLE_PANEL_DOMAIN_SSL_SETTINGS."` WHERE `domainid` = :domainid");
|
|
|
|
Database::pexecute($ssl_stmt, array("domainid" => $row['id']));
|
|
|
|
$ssl_result = $ssl_stmt->fetch(PDO::FETCH_ASSOC);
|
2016-01-30 13:11:58 +00:00
|
|
|
if (is_array($ssl_result) && isset($ssl_result['ssl_cert_file']) && $ssl_result['ssl_cert_file'] != '') {
|
2013-09-29 16:40:25 +00:00
|
|
|
// own certificate (ssl_customer_green)
|
|
|
|
$row['domain_hascert'] = 1;
|
2016-01-30 13:11:58 +00:00
|
|
|
} else {
|
2013-09-29 16:40:25 +00:00
|
|
|
// check if it's parent has one set (shared)
|
|
|
|
if ($row['parentdomainid'] != 0) {
|
2013-10-31 10:51:01 +00:00
|
|
|
$ssl_stmt = Database::prepare("SELECT * FROM `".TABLE_PANEL_DOMAIN_SSL_SETTINGS."` WHERE `domainid` = :domainid");
|
|
|
|
Database::pexecute($ssl_stmt, array("domainid" => $row['parentdomainid']));
|
|
|
|
$ssl_result = $ssl_stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if (is_array($ssl_result) && isset($ssl_result['ssl_cert_file']) && $ssl_result['ssl_cert_file'] != '') {
|
2013-09-29 16:40:25 +00:00
|
|
|
// parent has a certificate (ssl_shared)
|
|
|
|
$row['domain_hascert'] = 2;
|
|
|
|
}
|
|
|
|
}
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2016-02-22 11:10:06 +00:00
|
|
|
$row['termination_date'] = str_replace("0000-00-00", "", $row['termination_date']);
|
|
|
|
if($row['termination_date'] != "") {
|
|
|
|
$cdate = strtotime($row['termination_date'] . " 23:59:59");
|
|
|
|
$today = time();
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2016-02-22 11:10:06 +00:00
|
|
|
if($cdate < $today) {
|
|
|
|
$row['termination_css'] = 'domain-expired';
|
|
|
|
} else {
|
|
|
|
$row['termination_css'] = 'domain-canceled';
|
|
|
|
}
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-09-27 09:03:21 +00:00
|
|
|
$domains_count++;
|
2010-04-12 06:15:16 +00:00
|
|
|
$domain_array[$row['domain']] = $row;
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
ksort($domain_array);
|
|
|
|
$domain_id_array = array();
|
2013-12-15 11:24:32 +00:00
|
|
|
foreach ($domain_array as $sortkey => $row) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$domain_id_array[$row['id']] = $sortkey;
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$domain_sort_array = array();
|
2013-12-15 11:24:32 +00:00
|
|
|
foreach ($domain_array as $sortkey => $row) {
|
|
|
|
if ($row['parentdomainid'] == 0) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$domain_sort_array[$sortkey][$sortkey] = $row;
|
2013-10-31 10:51:01 +00:00
|
|
|
} else {
|
2015-07-28 06:23:10 +00:00
|
|
|
// when searching and the results are subdomains only, we need to get
|
|
|
|
// the parent domain to this subdomain
|
|
|
|
if (!isset($domain_id_array[$row['parentdomainid']])) {
|
2018-06-21 06:12:00 +00:00
|
|
|
$domain_id_array[$row['parentdomainid']] = "[parent-domain]";
|
2015-07-28 06:23:10 +00:00
|
|
|
}
|
2010-01-20 16:55:27 +00:00
|
|
|
$domain_sort_array[$domain_id_array[$row['parentdomainid']]][$sortkey] = $row;
|
|
|
|
}
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$domain_array = array();
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
if ($paging->sortfield == 'd.domain' && $paging->sortorder == 'asc') {
|
2010-01-20 16:55:27 +00:00
|
|
|
ksort($domain_sort_array);
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif ($paging->sortfield == 'd.domain' && $paging->sortorder == 'desc') {
|
2010-01-20 16:55:27 +00:00
|
|
|
krsort($domain_sort_array);
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$i = 0;
|
2013-12-15 11:24:32 +00:00
|
|
|
foreach ($domain_sort_array as $sortkey => $domain_array) {
|
|
|
|
if ($paging->checkDisplay($i)) {
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2015-07-28 06:23:10 +00:00
|
|
|
if (isset($domain_array[$sortkey])) {
|
|
|
|
$row = htmlentities_array($domain_array[$sortkey]);
|
|
|
|
if (Settings::Get('system.awstats_enabled') == '1') {
|
2018-06-21 06:12:00 +00:00
|
|
|
$statsapp = 'awstats';
|
2015-07-28 06:23:10 +00:00
|
|
|
} else {
|
2018-06-21 06:12:00 +00:00
|
|
|
$statsapp = 'webalizer';
|
2015-07-28 06:23:10 +00:00
|
|
|
}
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_delimiter") . "\";");
|
2010-03-22 12:36:59 +00:00
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
if ($paging->sortfield == 'd.domain' && $paging->sortorder == 'asc') {
|
2010-01-20 16:55:27 +00:00
|
|
|
ksort($domain_array);
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif ($paging->sortfield == 'd.domain' && $paging->sortorder == 'desc') {
|
2010-01-20 16:55:27 +00:00
|
|
|
krsort($domain_array);
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
foreach ($domain_array as $row) {
|
|
|
|
if (strpos($row['documentroot'], $userinfo['documentroot']) === 0) {
|
2018-12-19 16:13:41 +00:00
|
|
|
$row['documentroot'] = \Froxlor\FileDir::makeCorrectDir(str_replace($userinfo['documentroot'], "/", $row['documentroot']));
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-05-14 15:26:30 +00:00
|
|
|
// get ssl-ips if activated
|
|
|
|
$show_ssledit = false;
|
2018-12-20 11:38:18 +00:00
|
|
|
if (Settings::Get('system.use_ssl') == '1' && \Froxlor\Domain\Domain::domainHasSslIpPort($row['id']) && $row['caneditdomain'] == '1' && $row['letsencrypt'] == 0) {
|
2013-05-14 15:26:30 +00:00
|
|
|
$show_ssledit = true;
|
|
|
|
}
|
2010-01-20 16:55:27 +00:00
|
|
|
$row = htmlentities_array($row);
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_domain") . "\";");
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$i+= count($domain_array);
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domainlist") . "\";");
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif ($action == 'delete' && $id != 0) {
|
2018-02-27 09:34:37 +00:00
|
|
|
try {
|
|
|
|
$json_result = SubDomains::getLocal($userinfo, array(
|
|
|
|
'id' => $id
|
|
|
|
))->get();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-02-27 09:34:37 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-10-31 10:51:01 +00:00
|
|
|
$alias_stmt = Database::prepare("SELECT COUNT(`id`) AS `count` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain` = :aliasdomain");
|
2018-02-27 09:34:37 +00:00
|
|
|
$alias_check = Database::pexecute_first($alias_stmt, array("aliasdomain" => $id));
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
if (isset($result['parentdomainid']) && $result['parentdomainid'] != '0' && $alias_check['count'] == 0) {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-02-27 09:34:37 +00:00
|
|
|
try {
|
|
|
|
SubDomains::getLocal($userinfo, $_POST)->delete();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array('page' => $page, 's' => $s));
|
2013-10-31 10:51:01 +00:00
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
ask_yesno('domains_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $idna_convert->decode($result['domain']));
|
|
|
|
}
|
2013-10-31 10:51:01 +00:00
|
|
|
} else {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::standard_error('domains_cantdeletemaindomain');
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif ($action == 'add') {
|
|
|
|
if ($userinfo['subdomains_used'] < $userinfo['subdomains'] || $userinfo['subdomains'] == '-1') {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-02-27 14:54:07 +00:00
|
|
|
try {
|
|
|
|
SubDomains::getLocal($userinfo, $_POST)->add();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array('page' => $page, 's' => $s));
|
2013-10-31 10:51:01 +00:00
|
|
|
} else {
|
2016-01-30 12:59:34 +00:00
|
|
|
$stmt = Database::prepare("SELECT `id`, `domain`, `documentroot`, `ssl_redirect`,`isemaildomain`,`letsencrypt` FROM `" . TABLE_PANEL_DOMAINS . "`
|
2013-10-31 10:51:01 +00:00
|
|
|
WHERE `customerid` = :customerid
|
|
|
|
AND `parentdomainid` = '0'
|
|
|
|
AND `email_only` = '0'
|
|
|
|
AND `caneditdomain` = '1'
|
|
|
|
ORDER BY `domain` ASC"
|
2018-06-21 06:12:00 +00:00
|
|
|
);
|
2013-10-31 10:51:01 +00:00
|
|
|
Database::pexecute($stmt, array("customerid" => $userinfo['customerid']));
|
2010-01-20 16:55:27 +00:00
|
|
|
$domains = '';
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
2013-10-31 10:51:01 +00:00
|
|
|
$domains .= makeoption($idna_convert->decode($row['domain']), $row['domain']);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$aliasdomains = makeoption($lng['domains']['noaliasdomain'], 0, NULL, true);
|
2013-10-31 10:51:01 +00:00
|
|
|
$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`.`id` <> `c`.`standardsubdomain`
|
2014-10-27 09:41:29 +00:00
|
|
|
AND `d`.`parentdomainid` = '0'
|
2013-10-31 10:51:01 +00:00
|
|
|
AND `d`.`customerid`=`c`.`customerid`
|
|
|
|
AND `d`.`email_only`='0'
|
|
|
|
AND `d`.`customerid`= :customerid
|
|
|
|
ORDER BY `d`.`domain` ASC"
|
2018-06-21 06:12:00 +00:00
|
|
|
);
|
2013-10-31 10:51:01 +00:00
|
|
|
Database::pexecute($domains_stmt, array("customerid" => $userinfo['customerid']));
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
while ($row_domain = $domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2013-10-31 10:51:01 +00:00
|
|
|
$aliasdomains .= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id']);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2011-03-04 10:46:40 +00:00
|
|
|
$redirectcode = '';
|
2013-12-15 11:24:32 +00:00
|
|
|
if (Settings::Get('customredirect.enabled') == '1') {
|
2010-05-11 08:50:35 +00:00
|
|
|
$codes = getRedirectCodesArray();
|
2013-12-15 11:24:32 +00:00
|
|
|
foreach ($codes as $rc) {
|
|
|
|
$redirectcode .= makeoption($rc['code']. ' ('.$lng['redirect_desc'][$rc['desc']].')', $rc['id']);
|
2010-05-11 08:50:35 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-03-27 07:34:59 +00:00
|
|
|
// check if we at least have one ssl-ip/port, #1179
|
|
|
|
$ssl_ipsandports = '';
|
2016-11-29 08:34:33 +00:00
|
|
|
$ssl_ip_stmt = Database::prepare("
|
|
|
|
SELECT COUNT(*) as countSSL
|
|
|
|
FROM `".TABLE_PANEL_IPSANDPORTS."` pip
|
|
|
|
LEFT JOIN `".TABLE_DOMAINTOIP."` dti ON dti.id_ipandports = pip.id
|
|
|
|
WHERE pip.`ssl`='1'
|
|
|
|
");
|
2013-10-31 10:51:01 +00:00
|
|
|
Database::pexecute($ssl_ip_stmt);
|
|
|
|
$resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC);
|
2013-03-27 07:34:59 +00:00
|
|
|
if (isset($resultX['countSSL']) && (int)$resultX['countSSL'] > 0) {
|
|
|
|
$ssl_ipsandports = 'notempty';
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$openbasedir = makeoption($lng['domain']['docroot'], 0, NULL, true) . makeoption($lng['domain']['homedir'], 1, NULL, true);
|
2018-12-20 11:38:18 +00:00
|
|
|
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2018-01-08 12:59:30 +00:00
|
|
|
$phpconfigs = '';
|
|
|
|
$has_phpconfigs = false;
|
|
|
|
if (isset($userinfo['allowed_phpconfigs']) && !empty($userinfo['allowed_phpconfigs']))
|
|
|
|
{
|
|
|
|
$has_phpconfigs = true;
|
|
|
|
$allowed_cfg = json_decode($userinfo['allowed_phpconfigs'], JSON_OBJECT_AS_ARRAY);
|
|
|
|
$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
|
|
|
|
WHERE c.id IN (".implode(", ", $allowed_cfg).")
|
|
|
|
");
|
|
|
|
while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
|
|
|
$phpconfigs .= makeoption($phpconfigs_row['description'] . " [".$phpconfigs_row['interpreter']."]", $phpconfigs_row['id'], Settings::Get('phpfpm.defaultini'), true, true);
|
|
|
|
} else {
|
|
|
|
$phpconfigs .= makeoption($phpconfigs_row['description'], $phpconfigs_row['id'], Settings::Get('system.mod_fcgid_defaultini'), true, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2011-02-12 16:48:54 +00:00
|
|
|
$subdomain_add_data = include_once dirname(__FILE__).'/lib/formfields/customer/domains/formfield.domains_add.php';
|
2018-12-21 10:22:03 +00:00
|
|
|
$subdomain_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($subdomain_add_data);
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2011-02-12 16:48:54 +00:00
|
|
|
$title = $subdomain_add_data['domain_add']['title'];
|
|
|
|
$image = $subdomain_add_data['domain_add']['image'];
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains_add") . "\";");
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif ($action == 'edit' && $id != 0) {
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2018-03-05 11:13:01 +00:00
|
|
|
try {
|
|
|
|
$json_result = SubDomains::getLocal($userinfo, array(
|
|
|
|
'id' => $id
|
|
|
|
))->get();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-03-05 11:13:01 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
if (isset($result['customerid']) && $result['customerid'] == $userinfo['customerid']) {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-03-05 11:13:01 +00:00
|
|
|
try {
|
|
|
|
SubDomains::getLocal($userinfo, $_POST)->update();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array('page' => $page, 's' => $s));
|
2013-10-31 10:51:01 +00:00
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['domain'] = $idna_convert->decode($result['domain']);
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$domains = makeoption($lng['domains']['noaliasdomain'], 0, $result['aliasdomain'], true);
|
2010-04-29 07:40:55 +00:00
|
|
|
// also check ip/port combination to be the same, #176
|
2013-10-31 10:51:01 +00:00
|
|
|
$domains_stmt = Database::prepare("SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d` , `" . TABLE_PANEL_CUSTOMERS . "` `c` , `".TABLE_DOMAINTOIP."` `dip`
|
|
|
|
WHERE `d`.`aliasdomain` IS NULL
|
|
|
|
AND `d`.`id` <> :id
|
|
|
|
AND `c`.`standardsubdomain` <> `d`.`id`
|
2014-10-27 09:41:29 +00:00
|
|
|
AND `d`.`parentdomainid` = '0'
|
2013-10-31 10:51:01 +00:00
|
|
|
AND `d`.`customerid` = :customerid
|
|
|
|
AND `c`.`customerid` = `d`.`customerid`
|
|
|
|
AND `d`.`id` = `dip`.`id_domain`
|
|
|
|
AND `dip`.`id_ipandports`
|
|
|
|
IN (SELECT `id_ipandports` FROM `".TABLE_DOMAINTOIP."`
|
|
|
|
WHERE `id_domain` = :id)
|
2016-04-30 15:24:11 +00:00
|
|
|
GROUP BY `d`.`id`, `d`.`domain`
|
2013-10-31 10:51:01 +00:00
|
|
|
ORDER BY `d`.`domain` ASC"
|
2018-06-21 06:12:00 +00:00
|
|
|
);
|
2013-10-31 10:51:01 +00:00
|
|
|
Database::pexecute($domains_stmt, array("id" => $result['id'], "customerid" => $userinfo['customerid']));
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
while ($row_domain = $domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2013-10-31 10:51:01 +00:00
|
|
|
$domains .= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['aliasdomain']);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2016-08-26 07:41:19 +00:00
|
|
|
if (preg_match('/^https?\:\/\//', $result['documentroot']) && validateUrl($result['documentroot'])) {
|
2013-12-15 11:24:32 +00:00
|
|
|
if (Settings::Get('panel.pathedit') == 'Dropdown') {
|
2011-03-14 06:58:32 +00:00
|
|
|
$urlvalue = $result['documentroot'];
|
2018-12-20 11:38:18 +00:00
|
|
|
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
|
2013-10-31 10:51:01 +00:00
|
|
|
} else {
|
2011-03-14 06:58:32 +00:00
|
|
|
$urlvalue = '';
|
2018-12-20 11:38:18 +00:00
|
|
|
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $result['documentroot'], true);
|
2011-03-14 06:58:32 +00:00
|
|
|
}
|
2013-10-31 10:51:01 +00:00
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
$urlvalue = '';
|
2018-12-20 11:38:18 +00:00
|
|
|
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $result['documentroot']);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2011-03-04 10:46:40 +00:00
|
|
|
$redirectcode = '';
|
2013-12-15 11:24:32 +00:00
|
|
|
if (Settings::Get('customredirect.enabled') == '1') {
|
2010-05-11 08:50:35 +00:00
|
|
|
$def_code = getDomainRedirectId($id);
|
|
|
|
$codes = getRedirectCodesArray();
|
2013-12-15 11:24:32 +00:00
|
|
|
foreach ($codes as $rc) {
|
2010-08-12 12:32:26 +00:00
|
|
|
$redirectcode .= makeoption($rc['code']. ' ('.$lng['redirect_desc'][$rc['desc']].')', $rc['id'], $def_code);
|
2010-05-11 08:50:35 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-03-27 07:34:59 +00:00
|
|
|
// check if we at least have one ssl-ip/port, #1179
|
|
|
|
$ssl_ipsandports = '';
|
2016-11-29 08:34:33 +00:00
|
|
|
$ssl_ip_stmt = Database::prepare("
|
|
|
|
SELECT COUNT(*) as countSSL
|
|
|
|
FROM `".TABLE_PANEL_IPSANDPORTS."` pip
|
|
|
|
LEFT JOIN `".TABLE_DOMAINTOIP."` dti ON dti.id_ipandports = pip.id
|
|
|
|
WHERE `dti`.`id_domain` = :id_domain AND pip.`ssl`='1'
|
|
|
|
");
|
|
|
|
Database::pexecute($ssl_ip_stmt, array("id_domain" => $result['id']));
|
2013-10-31 10:51:01 +00:00
|
|
|
$resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC);
|
2013-03-27 07:34:59 +00:00
|
|
|
if (isset($resultX['countSSL']) && (int)$resultX['countSSL'] > 0) {
|
|
|
|
$ssl_ipsandports = 'notempty';
|
|
|
|
}
|
2018-06-21 06:12:00 +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-06-21 06:12:00 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$openbasedir = makeoption($lng['domain']['docroot'], 0, $result['openbasedir_path'], true) . makeoption($lng['domain']['homedir'], 1, $result['openbasedir_path'], true);
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-10-14 08:08:15 +00:00
|
|
|
// create serveralias options
|
|
|
|
$serveraliasoptions = "";
|
|
|
|
$_value = '2';
|
|
|
|
if ($result['iswildcarddomain'] == '1') {
|
|
|
|
$_value = '0';
|
|
|
|
} elseif ($result['wwwserveralias'] == '1') {
|
|
|
|
$_value = '1';
|
|
|
|
}
|
|
|
|
$serveraliasoptions .= makeoption($lng['domains']['serveraliasoption_wildcard'], '0', $_value, true, true);
|
|
|
|
$serveraliasoptions .= makeoption($lng['domains']['serveraliasoption_www'], '1', $_value, true, true);
|
|
|
|
$serveraliasoptions .= makeoption($lng['domains']['serveraliasoption_none'], '2', $_value, true, true);
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-10-31 10:51:01 +00:00
|
|
|
$ips_stmt = Database::prepare("SELECT `p`.`ip` AS `ip` FROM `".TABLE_PANEL_IPSANDPORTS."` `p`
|
|
|
|
LEFT JOIN `".TABLE_DOMAINTOIP."` `dip`
|
|
|
|
ON ( `dip`.`id_ipandports` = `p`.`id` )
|
|
|
|
WHERE `dip`.`id_domain` = :id_domain
|
|
|
|
GROUP BY `p`.`ip`"
|
2018-06-21 06:12:00 +00:00
|
|
|
);
|
2013-10-31 10:51:01 +00:00
|
|
|
Database::pexecute($ips_stmt, array("id_domain" => $result['id']));
|
2012-12-02 14:16:22 +00:00
|
|
|
$result_ipandport['ip'] = '';
|
2013-10-31 10:51:01 +00:00
|
|
|
while ($rowip = $ips_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2013-09-20 08:58:36 +00:00
|
|
|
$result_ipandport['ip'] .= $rowip['ip'] . "<br />";
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2018-01-08 12:59:30 +00:00
|
|
|
$phpconfigs = '';
|
|
|
|
$has_phpconfigs = false;
|
|
|
|
if (isset($userinfo['allowed_phpconfigs']) && !empty($userinfo['allowed_phpconfigs']))
|
|
|
|
{
|
|
|
|
$has_phpconfigs = true;
|
|
|
|
$allowed_cfg = json_decode($userinfo['allowed_phpconfigs'], JSON_OBJECT_AS_ARRAY);
|
|
|
|
$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
|
|
|
|
WHERE c.id IN (".implode(", ", $allowed_cfg).")
|
|
|
|
");
|
|
|
|
while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
|
|
|
$phpconfigs .= makeoption($phpconfigs_row['description'] . " [".$phpconfigs_row['interpreter']."]", $phpconfigs_row['id'], $result['phpsettingid'], true, true);
|
|
|
|
} else {
|
|
|
|
$phpconfigs .= makeoption($phpconfigs_row['description'], $phpconfigs_row['id'], $result['phpsettingid'], true, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2010-04-13 11:21:25 +00:00
|
|
|
$domainip = $result_ipandport['ip'];
|
|
|
|
$result = htmlentities_array($result);
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2011-02-12 16:48:54 +00:00
|
|
|
$subdomain_edit_data = include_once dirname(__FILE__).'/lib/formfields/customer/domains/formfield.domains_edit.php';
|
2018-12-21 10:22:03 +00:00
|
|
|
$subdomain_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($subdomain_edit_data);
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2011-02-12 16:48:54 +00:00
|
|
|
$title = $subdomain_edit_data['domain_edit']['title'];
|
|
|
|
$image = $subdomain_edit_data['domain_edit']['image'];
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains_edit") . "\";");
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-10-31 10:51:01 +00:00
|
|
|
} else {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::standard_error('domains_canteditdomain');
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-31 10:51:01 +00:00
|
|
|
} elseif ($page == 'domainssleditor') {
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-10-31 10:51:01 +00:00
|
|
|
if ($action == '' || $action == 'view') {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2013-05-14 15:26:30 +00:00
|
|
|
$do_insert = isset($_POST['do_insert']) ? (($_POST['do_insert'] == 1) ? true : false) : false;
|
2018-03-05 13:21:36 +00:00
|
|
|
try {
|
|
|
|
if ($do_insert) {
|
|
|
|
Certificates::getLocal($userinfo, $_POST)->add();
|
2013-05-14 15:26:30 +00:00
|
|
|
} else {
|
2018-03-05 13:21:36 +00:00
|
|
|
Certificates::getLocal($userinfo, $_POST)->update();
|
2013-05-14 15:26:30 +00:00
|
|
|
}
|
2018-03-05 13:21:36 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2013-05-14 15:26:30 +00:00
|
|
|
}
|
|
|
|
// back to domain overview
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array('page' => 'domains', 's' => $s));
|
2013-05-14 15:26:30 +00:00
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-10-31 10:51:01 +00:00
|
|
|
$stmt = Database::prepare("SELECT * FROM `".TABLE_PANEL_DOMAIN_SSL_SETTINGS."`
|
|
|
|
WHERE `domainid`= :domainid"
|
2018-06-21 06:12:00 +00:00
|
|
|
);
|
2018-03-05 13:21:36 +00:00
|
|
|
$result = Database::pexecute_first($stmt, array("domainid" => $id));
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-05-14 15:26:30 +00:00
|
|
|
$do_insert = false;
|
|
|
|
// if no entry can be found, behave like we have empty values
|
|
|
|
if (!is_array($result) || !isset($result['ssl_cert_file'])) {
|
|
|
|
$result = array(
|
|
|
|
'ssl_cert_file' => '',
|
|
|
|
'ssl_key_file' => '',
|
|
|
|
'ssl_ca_file' => '',
|
|
|
|
'ssl_cert_chainfile' => ''
|
|
|
|
);
|
|
|
|
$do_insert = true;
|
|
|
|
}
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-05-14 15:26:30 +00:00
|
|
|
$result = htmlentities_array($result);
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-05-14 15:26:30 +00:00
|
|
|
$ssleditor_data = include_once dirname(__FILE__).'/lib/formfields/customer/domains/formfield.domain_ssleditor.php';
|
2018-12-21 10:22:03 +00:00
|
|
|
$ssleditor_form = \Froxlor\UI\HtmlForm::genHTMLForm($ssleditor_data);
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2013-05-14 15:26:30 +00:00
|
|
|
$title = $ssleditor_data['domain_ssleditor']['title'];
|
|
|
|
$image = $ssleditor_data['domain_ssleditor']['image'];
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domain_ssleditor") . "\";");
|
2013-05-14 15:26:30 +00:00
|
|
|
}
|
2016-05-18 11:54:21 +00:00
|
|
|
} elseif ($page == 'domaindnseditor' && $userinfo['dnsenabled'] == '1' && Settings::Get('system.dnsenabled') == '1') {
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2016-05-13 11:27:33 +00:00
|
|
|
require_once __DIR__.'/dns_editor.php';
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2016-09-26 09:48:36 +00:00
|
|
|
} elseif ($page == 'sslcertificates') {
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2016-09-26 09:48:36 +00:00
|
|
|
require_once __DIR__.'/ssl_certificates.php';
|
2018-06-21 06:12:00 +00:00
|
|
|
|
2018-12-01 12:33:08 +00:00
|
|
|
} elseif ($page == 'logfiles') {
|
|
|
|
|
|
|
|
require_once __DIR__.'/logfiles_viewer.php';
|
|
|
|
}
|