diff --git a/admin_domains.php b/admin_domains.php index 16e92549..3fa595d6 100644 --- a/admin_domains.php +++ b/admin_domains.php @@ -665,6 +665,9 @@ if ($page == 'domains' || $page == 'overview') { UI::twigOutputBuffer(); } } +} elseif ($page == 'domainssleditor') { + + require_once __DIR__ . '/ssl_editor.php'; } elseif ($page == 'domaindnseditor' && Settings::Get('system.dnsenabled') == '1') { require_once __DIR__ . '/dns_editor.php'; diff --git a/customer_domains.php b/customer_domains.php index b6d4ef18..1c98c44f 100644 --- a/customer_domains.php +++ b/customer_domains.php @@ -19,7 +19,6 @@ const AREA = 'customer'; require __DIR__ . '/lib/init.php'; -use Froxlor\Api\Commands\Certificates as Certificates; use Froxlor\Api\Commands\SubDomains as SubDomains; use Froxlor\Database\Database; use Froxlor\Settings; @@ -357,63 +356,7 @@ if ($page == 'overview' || $page == 'domains') { } } elseif ($page == 'domainssleditor') { - if ($action == '' || $action == 'view') { - - // get domain - try { - $json_result = SubDomains::getLocal($userinfo, array( - 'id' => $id - ))->get(); - } catch (Exception $e) { - \Froxlor\UI\Response::dynamic_error($e->getMessage()); - } - $result_domain = json_decode($json_result, true)['data']; - - if (isset($_POST['send']) && $_POST['send'] == 'send') { - $do_insert = isset($_POST['do_insert']) ? (($_POST['do_insert'] == 1) ? true : false) : false; - try { - if ($do_insert) { - Certificates::getLocal($userinfo, $_POST)->add(); - } else { - Certificates::getLocal($userinfo, $_POST)->update(); - } - } catch (Exception $e) { - \Froxlor\UI\Response::dynamic_error($e->getMessage()); - } - // back to domain overview - \Froxlor\UI\Response::redirectTo($filename, array( - 'page' => 'domains' - )); - } - - $stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` - WHERE `domainid`= :domainid"); - $result = Database::pexecute_first($stmt, array( - "domainid" => $id - )); - - $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; - } - - $result = \Froxlor\PhpHelper::htmlentitiesArray($result); - - $ssleditor_data = include_once dirname(__FILE__) . '/lib/formfields/customer/domains/formfield.domain_ssleditor.php'; - $ssleditor_form = \Froxlor\UI\HtmlForm::genHTMLForm($ssleditor_data); - - $title = $ssleditor_data['domain_ssleditor']['title']; - $image = $ssleditor_data['domain_ssleditor']['image']; - - eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domain_ssleditor") . "\";"); - } + require_once __DIR__ . '/ssl_editor.php'; } elseif ($page == 'domaindnseditor' && $userinfo['dnsenabled'] == '1' && Settings::Get('system.dnsenabled') == '1') { require_once __DIR__ . '/dns_editor.php'; @@ -424,52 +367,3 @@ if ($page == 'overview' || $page == 'domains') { require_once __DIR__ . '/logfiles_viewer.php'; } - -function formatDomainEntry(&$row, &$idna_convert) -{ - $row['domain'] = $idna_convert->decode($row['domain']); - $row['aliasdomain'] = $idna_convert->decode($row['aliasdomain']); - $row['domainalias'] = $idna_convert->decode($row['domainalias']); - - /** - * check for set ssl-certs to show different state-icons - */ - // nothing (ssl_global) - $row['domain_hascert'] = 0; - $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); - if (is_array($ssl_result) && isset($ssl_result['ssl_cert_file']) && $ssl_result['ssl_cert_file'] != '') { - // own certificate (ssl_customer_green) - $row['domain_hascert'] = 1; - } else { - // check if it's parent has one set (shared) - if ($row['parentdomainid'] != 0) { - $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'] != '') { - // parent has a certificate (ssl_shared) - $row['domain_hascert'] = 2; - } - } - } - - $row['termination_date'] = str_replace("0000-00-00", "", $row['termination_date']); - - $row['termination_css'] = ""; - if ($row['termination_date'] != "") { - $cdate = strtotime($row['termination_date'] . " 23:59:59"); - $today = time(); - - if ($cdate < $today) { - $row['termination_css'] = 'domain-expired'; - } else { - $row['termination_css'] = 'domain-canceled'; - } - } -} diff --git a/lib/formfields/admin/domains/formfield.domains_add.php b/lib/formfields/admin/domains/formfield.domains_add.php index fd3e0bbd..c38b8dd8 100644 --- a/lib/formfields/admin/domains/formfield.domains_add.php +++ b/lib/formfields/admin/domains/formfield.domains_add.php @@ -182,14 +182,14 @@ return array( 'visible' => \Froxlor\Settings::Get('system.use_ssl') == '1' ? true : false, 'fields' => array( 'sslenabled' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false), + 'visible' => (!empty($ssl_ipsandports) ? true : false), 'label' => $lng['admin']['domain_sslenabled'], 'type' => 'checkbox', 'value' => '1', 'checked' => true ), 'no_ssl_available_info' => array( - 'visible' => ($ssl_ipsandports == '' ? true : false), + 'visible' => (!empty($ssl_ipsandports) ? true : false), 'label' => 'SSL', 'type' => 'label', 'value' => $lng['panel']['nosslipsavailable'] @@ -203,7 +203,7 @@ return array( 'is_array' => 1 ), 'ssl_redirect' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false), + 'visible' => (!empty($ssl_ipsandports) ? true : false), 'label' => $lng['domains']['ssl_redirect']['title'], 'desc' => $lng['domains']['ssl_redirect']['description'], 'type' => 'checkbox', @@ -211,7 +211,7 @@ return array( 'checked' => false ), 'letsencrypt' => array( - 'visible' => (\Froxlor\Settings::Get('system.leenabled') == '1' ? ($ssl_ipsandports != '' ? true : false) : false), + 'visible' => (\Froxlor\Settings::Get('system.leenabled') == '1' ? (!empty($ssl_ipsandports) ? true : false) : false), 'label' => $lng['admin']['letsencrypt']['title'], 'desc' => $lng['admin']['letsencrypt']['description'], 'type' => 'checkbox', @@ -219,7 +219,7 @@ return array( 'checked' => false ), 'http2' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' && \Froxlor\Settings::Get('system.http2_support') == '1', + 'visible' => (!empty($ssl_ipsandports) ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' && \Froxlor\Settings::Get('system.http2_support') == '1', 'label' => $lng['admin']['domain_http2']['title'], 'desc' => $lng['admin']['domain_http2']['description'], 'type' => 'checkbox', @@ -227,14 +227,14 @@ return array( 'checked' => false ), 'override_tls' => array( - 'visible' => (($ssl_ipsandports != '' ? true : false) && $userinfo['change_serversettings'] == '1' ? true : false), + 'visible' => ((!empty($ssl_ipsandports) ? true : false) && $userinfo['change_serversettings'] == '1' ? true : false), 'label' => $lng['admin']['domain_override_tls'], 'type' => 'checkbox', 'value' => '1', 'checked' => false ), 'ssl_protocols' => array( - 'visible' => (($ssl_ipsandports != '' ? true : false) && $userinfo['change_serversettings'] == '1' && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' ? true : false), + 'visible' => ((!empty($ssl_ipsandports) ? true : false) && $userinfo['change_serversettings'] == '1' && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' ? true : false), 'label' => $lng['serversettings']['ssl']['ssl_protocols']['title'], 'desc' => $lng['serversettings']['ssl']['ssl_protocols']['description'], 'type' => 'checkbox', @@ -262,21 +262,21 @@ return array( 'is_array' => 1 ), 'ssl_cipher_list' => array( - 'visible' => (($ssl_ipsandports != '' ? true : false) && $userinfo['change_serversettings'] == '1' ? true : false), + 'visible' => ((!empty($ssl_ipsandports) ? true : false) && $userinfo['change_serversettings'] == '1' ? true : false), 'label' => $lng['serversettings']['ssl']['ssl_cipher_list']['title'], 'desc' => $lng['serversettings']['ssl']['ssl_cipher_list']['description'], 'type' => 'text', 'value' => \Froxlor\Settings::Get('system.ssl_cipher_list') ), 'tlsv13_cipher_list' => array( - 'visible' => (($ssl_ipsandports != '' ? true : false) && $userinfo['change_serversettings'] == '1' && \Froxlor\Settings::Get('system.webserver') == "apache2" && \Froxlor\Settings::Get('system.apache24') == 1 ? true : false), + 'visible' => ((!empty($ssl_ipsandports) ? true : false) && $userinfo['change_serversettings'] == '1' && \Froxlor\Settings::Get('system.webserver') == "apache2" && \Froxlor\Settings::Get('system.apache24') == 1 ? true : false), 'label' => $lng['serversettings']['ssl']['tlsv13_cipher_list']['title'], 'desc' => $lng['serversettings']['ssl']['tlsv13_cipher_list']['description'], 'type' => 'text', 'value' => \Froxlor\Settings::Get('system.tlsv13_cipher_list') ), 'ssl_specialsettings' => array( - 'visible' => (($ssl_ipsandports != '' ? true : false) && $userinfo['change_serversettings'] == '1' ? true : false), + 'visible' => ((!empty($ssl_ipsandports) ? true : false) && $userinfo['change_serversettings'] == '1' ? true : false), 'label' => $lng['admin']['ownsslvhostsettings'], 'desc' => $lng['serversettings']['default_vhostconf']['description'], 'type' => 'textarea', @@ -284,7 +284,7 @@ return array( 'rows' => 12 ), 'include_specialsettings' => array( - 'visible' => (($ssl_ipsandports != '' ? true : false) && $userinfo['change_serversettings'] == '1' ? true : false), + 'visible' => ((!empty($ssl_ipsandports) ? true : false) && $userinfo['change_serversettings'] == '1' ? true : false), 'label' => $lng['admin']['include_ownvhostsettings'], 'type' => 'checkbox', 'value' => '1', @@ -300,7 +300,7 @@ return array( 'value' => 0 ), 'hsts_sub' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false), + 'visible' => (!empty($ssl_ipsandports) ? true : false), 'label' => $lng['admin']['domain_hsts_incsub']['title'], 'desc' => $lng['admin']['domain_hsts_incsub']['description'], 'type' => 'checkbox', @@ -308,7 +308,7 @@ return array( 'checked' => false ), 'hsts_preload' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false), + 'visible' => (!empty($ssl_ipsandports) ? true : false), 'label' => $lng['admin']['domain_hsts_preload']['title'], 'desc' => $lng['admin']['domain_hsts_preload']['description'], 'type' => 'checkbox', @@ -316,7 +316,7 @@ return array( 'checked' => false ), 'ocsp_stapling' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd', + 'visible' => (!empty($ssl_ipsandports) ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd', 'label' => $lng['admin']['domain_ocsp_stapling']['title'], 'desc' => $lng['admin']['domain_ocsp_stapling']['description'] . (\Froxlor\Settings::Get('system.webserver') == 'nginx' ? $lng['admin']['domain_ocsp_stapling']['nginx_version_warning'] : ""), 'type' => 'checkbox', @@ -324,14 +324,14 @@ return array( 'checked' => false ), 'honorcipherorder' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false), + 'visible' => (!empty($ssl_ipsandports) ? true : false), 'label' => $lng['admin']['domain_honorcipherorder'], 'type' => 'checkbox', 'value' => '1', 'checked' => false ), 'sessiontickets' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' && \Froxlor\Settings::Get('system.sessionticketsenabled' != '1'), + 'visible' => (!empty($ssl_ipsandports) ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' && \Froxlor\Settings::Get('system.sessionticketsenabled' != '1'), 'label' => $lng['admin']['domain_sessiontickets'], 'type' => 'checkbox', 'value' => '1', diff --git a/lib/formfields/admin/domains/formfield.domains_edit.php b/lib/formfields/admin/domains/formfield.domains_edit.php index 01aa20ff..f8a4f9b6 100644 --- a/lib/formfields/admin/domains/formfield.domains_edit.php +++ b/lib/formfields/admin/domains/formfield.domains_edit.php @@ -209,14 +209,14 @@ return array( 'visible' => \Froxlor\Settings::Get('system.use_ssl') == '1' ? true : false, 'fields' => array( 'sslenabled' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false), + 'visible' => (!empty($ssl_ipsandports) ? true : false), 'label' => $lng['admin']['domain_sslenabled'], 'type' => 'checkbox', 'value' => '1', 'checked' => $result['ssl_enabled'] ), 'no_ssl_available_info' => array( - 'visible' => ($ssl_ipsandports == '' ? true : false), + 'visible' => (empty($ssl_ipsandports) ? true : false), 'label' => 'SSL', 'type' => 'label', 'value' => $lng['panel']['nosslipsavailable'] @@ -230,7 +230,7 @@ return array( 'is_array' => 1 ), 'ssl_redirect' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false), + 'visible' => (!empty($ssl_ipsandports) ? true : false), 'label' => $lng['domains']['ssl_redirect']['title'], 'desc' => $lng['domains']['ssl_redirect']['description'] . ($result['temporary_ssl_redirect'] > 1 ? $lng['domains']['ssl_redirect_temporarilydisabled'] : ''), 'type' => 'checkbox', @@ -238,7 +238,7 @@ return array( 'checked' => $result['ssl_redirect'] ), 'letsencrypt' => array( - 'visible' => (\Froxlor\Settings::Get('system.leenabled') == '1' ? ($ssl_ipsandports != '' ? true : false) : false), + 'visible' => (\Froxlor\Settings::Get('system.leenabled') == '1' ? (!empty($ssl_ipsandports) ? true : false) : false), 'label' => $lng['admin']['letsencrypt']['title'], 'desc' => $lng['admin']['letsencrypt']['description'], 'type' => 'checkbox', @@ -246,7 +246,7 @@ return array( 'checked' => $result['letsencrypt'] ), 'http2' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' && \Froxlor\Settings::Get('system.http2_support') == '1', + 'visible' => (!empty($ssl_ipsandports) ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' && \Froxlor\Settings::Get('system.http2_support') == '1', 'label' => $lng['admin']['domain_http2']['title'], 'desc' => $lng['admin']['domain_http2']['description'], 'type' => 'checkbox', @@ -254,14 +254,14 @@ return array( 'checked' => $result['http2'] ), 'override_tls' => array( - 'visible' => (($ssl_ipsandports != '' ? true : false) && $userinfo['change_serversettings'] == '1' ? true : false), + 'visible' => ((!empty($ssl_ipsandports) ? true : false) && $userinfo['change_serversettings'] == '1' ? true : false), 'label' => $lng['admin']['domain_override_tls'], 'type' => 'checkbox', 'value' => '1', 'checked' => $result['override_tls'] ), 'ssl_protocols' => array( - 'visible' => (($ssl_ipsandports != '' ? true : false) && $userinfo['change_serversettings'] == '1' && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' ? true : false), + 'visible' => ((!empty($ssl_ipsandports) ? true : false) && $userinfo['change_serversettings'] == '1' && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' ? true : false), 'label' => $lng['serversettings']['ssl']['ssl_protocols']['title'], 'desc' => $lng['serversettings']['ssl']['ssl_protocols']['description'], 'type' => 'checkbox', @@ -287,14 +287,14 @@ return array( 'is_array' => 1 ), 'ssl_cipher_list' => array( - 'visible' => (($ssl_ipsandports != '' ? true : false) && $userinfo['change_serversettings'] == '1' ? true : false), + 'visible' => ((!empty($ssl_ipsandports) ? true : false) && $userinfo['change_serversettings'] == '1' ? true : false), 'label' => $lng['serversettings']['ssl']['ssl_cipher_list']['title'], 'desc' => $lng['serversettings']['ssl']['ssl_cipher_list']['description'], 'type' => 'text', 'value' => !empty($result['ssl_cipher_list']) ? $result['ssl_cipher_list'] : \Froxlor\Settings::Get('system.ssl_cipher_list') ), 'tlsv13_cipher_list' => array( - 'visible' => (($ssl_ipsandports != '' ? true : false) && $userinfo['change_serversettings'] == '1' && \Froxlor\Settings::Get('system.webserver') == "apache2" && \Froxlor\Settings::Get('system.apache24') == 1 ? true : false), + 'visible' => ((!empty($ssl_ipsandports) ? true : false) && $userinfo['change_serversettings'] == '1' && \Froxlor\Settings::Get('system.webserver') == "apache2" && \Froxlor\Settings::Get('system.apache24') == 1 ? true : false), 'label' => $lng['serversettings']['ssl']['tlsv13_cipher_list']['title'], 'desc' => $lng['serversettings']['ssl']['tlsv13_cipher_list']['description'], 'type' => 'text', @@ -316,7 +316,7 @@ return array( 'checked' => $result['include_specialsettings'] ), 'hsts_maxage' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false), + 'visible' => (!empty($ssl_ipsandports) ? true : false), 'label' => $lng['admin']['domain_hsts_maxage']['title'], 'desc' => $lng['admin']['domain_hsts_maxage']['description'], 'type' => 'number', @@ -325,7 +325,7 @@ return array( 'value' => $result['hsts'] ), 'hsts_sub' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false), + 'visible' => (!empty($ssl_ipsandports) ? true : false), 'label' => $lng['admin']['domain_hsts_incsub']['title'], 'desc' => $lng['admin']['domain_hsts_incsub']['description'], 'type' => 'checkbox', @@ -333,7 +333,7 @@ return array( 'checked' => $result['hsts_sub'] ), 'hsts_preload' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false), + 'visible' => (!empty($ssl_ipsandports) ? true : false), 'label' => $lng['admin']['domain_hsts_preload']['title'], 'desc' => $lng['admin']['domain_hsts_preload']['description'], 'type' => 'checkbox', @@ -341,7 +341,7 @@ return array( 'checked' => $result['hsts_preload'] ), 'ocsp_stapling' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd', + 'visible' => (!empty($ssl_ipsandports) ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd', 'label' => $lng['admin']['domain_ocsp_stapling']['title'], 'desc' => $lng['admin']['domain_ocsp_stapling']['description'] . (\Froxlor\Settings::Get('system.webserver') == 'nginx' ? $lng['admin']['domain_ocsp_stapling']['nginx_version_warning'] : ""), 'type' => 'checkbox', @@ -349,14 +349,14 @@ return array( 'checked' => $result['ocsp_stapling'] ), 'honorcipherorder' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false), + 'visible' => (!empty($ssl_ipsandports) ? true : false), 'label' => $lng['admin']['domain_honorcipherorder'], 'type' => 'checkbox', 'value' => '1', 'checked' => $result['ssl_honorcipherorder'] ), 'sessiontickets' => array( - 'visible' => ($ssl_ipsandports != '' ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' && \Froxlor\Settings::Get('system.sessionticketsenabled' != '1'), + 'visible' => (!empty($ssl_ipsandports) ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' && \Froxlor\Settings::Get('system.sessionticketsenabled' != '1'), 'label' => $lng['admin']['domain_sessiontickets'], 'type' => 'checkbox', 'value' => '1', diff --git a/lib/formfields/customer/domains/formfield.domain_ssleditor.php b/lib/formfields/formfield.domain_ssleditor.php similarity index 95% rename from lib/formfields/customer/domains/formfield.domain_ssleditor.php rename to lib/formfields/formfield.domain_ssleditor.php index d2f0a42d..44c3856c 100644 --- a/lib/formfields/customer/domains/formfield.domain_ssleditor.php +++ b/lib/formfields/formfield.domain_ssleditor.php @@ -25,9 +25,8 @@ return array( 'fields' => array( 'domainname' => array( 'label' => $lng['domains']['domainname'], - 'type' => 'hidden', - 'value' => $result_domain['domain'], - 'display' => $result_domain['domain'] + 'type' => 'label', + 'value' => $result_domain['domain'] ), 'ssl_cert_file' => array( 'label' => $lng['admin']['ipsandports']['ssl_cert_file_content'], diff --git a/ssl_editor.php b/ssl_editor.php new file mode 100644 index 00000000..c4069b9d --- /dev/null +++ b/ssl_editor.php @@ -0,0 +1,96 @@ + (2016-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Panel + * + */ + +use Froxlor\Database\Database; +use Froxlor\Api\Commands\Certificates; +use Froxlor\Api\Commands\SubDomains; +use Froxlor\UI\Panel\UI; + +// This file is being included in admin_domains and customer_domains +// and therefore does not need to require lib/init.php + +if ($action == '' || $action == 'view') { + + // get domain + try { + $json_result = SubDomains::getLocal($userinfo, array( + 'id' => $id + ))->get(); + } catch (Exception $e) { + \Froxlor\UI\Response::dynamic_error($e->getMessage()); + } + $result_domain = json_decode($json_result, true)['data']; + + if (isset($_POST['send']) && $_POST['send'] == 'send') { + $do_insert = isset($_POST['do_insert']) ? (($_POST['do_insert'] == 1) ? true : false) : false; + try { + if ($do_insert) { + Certificates::getLocal($userinfo, $_POST)->add(); + } else { + Certificates::getLocal($userinfo, $_POST)->update(); + } + } catch (Exception $e) { + \Froxlor\UI\Response::dynamic_error($e->getMessage()); + } + // back to domain overview + \Froxlor\UI\Response::redirectTo($filename, array( + 'page' => 'domains' + )); + } + + $stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` + WHERE `domainid`= :domainid"); + $result = Database::pexecute_first($stmt, array( + "domainid" => $id + )); + + $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; + } + + $result = \Froxlor\PhpHelper::htmlentitiesArray($result); + + $ssleditor_data = include_once dirname(__FILE__) . '/lib/formfields/formfield.domain_ssleditor.php'; + + $title = ['title']; + $image = $ssleditor_data['domain_ssleditor']['image']; + + UI::twigBuffer('user/form.html.twig', [ + 'formaction' => $linker->getLink(array('section' => 'domains', 'page' => 'domainssleditor', 'id' => $id)), + 'formdata' => $ssleditor_data['domain_ssleditor'], + 'editid' => $id, + 'actions_links' => [[ + 'class' => 'btn-outline-primary', + 'href' => $linker->getLink(['section' => 'domains', 'page' => 'overview']), + 'label' => $lng['admin']['domains'], + 'icon' => 'fa fa-globe' + ]] + ]); + UI::twigOutputBuffer(); +}