From c189ad759bfea245df1d94333d5ec7c8d7f04424 Mon Sep 17 00:00:00 2001 From: Florian Aders Date: Sat, 30 Jan 2016 14:34:26 +0100 Subject: [PATCH] Add Let's Encrypt to admin - GUI Signed-off-by: Florian Aders --- admin_domains.php | 34 +++++++++++++++---- .../admin/domains/formfield.domains_add.php | 10 ++++++ .../admin/domains/formfield.domains_edit.php | 10 ++++++ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/admin_domains.php b/admin_domains.php index e3c2a17f..c897ba01 100644 --- a/admin_domains.php +++ b/admin_domains.php @@ -516,6 +516,11 @@ if ($page == 'domains' $ssl_redirect = (int)$_POST['ssl_redirect']; } + $letsencrypt = 0; + if (isset($_POST['letsencrypt'])) { + $letsencrypt = (int)$_POST['letsencrypt']; + } + $ssl_ipandports = array(); if (isset($_POST['ssl_ipandport']) && !is_array($_POST['ssl_ipandport'])) { $_POST['ssl_ipandport'] = unserialize($_POST['ssl_ipandport']); @@ -547,12 +552,14 @@ if ($page == 'domains' } } else { $ssl_redirect = 0; + $letsencrypt = 0; // we need this for the serialize // if ssl is disabled or no ssl-ip/port exists $ssl_ipandports[] = -1; } } else { $ssl_redirect = 0; + $letsencrypt = 0; // we need this for the serialize // if ssl is disabled or no ssl-ip/port exists $ssl_ipandports[] = -1; @@ -702,7 +709,8 @@ if ($page == 'domains' 'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests, 'specialsettings' => $specialsettings, 'registration_date' => $registration_date, - 'issubof' => $issubof + 'issubof' => $issubof, + 'letsencrypt' => $letsencrypt ); $security_questions = array( @@ -751,7 +759,8 @@ if ($page == 'domains' 'phpsettingid' => $phpsettingid, 'mod_fcgid_starter' => $mod_fcgid_starter, 'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests, - 'ismainbutsubto' => $issubof + 'ismainbutsubto' => $issubof, + 'letsencrypt' => $letsencrypt ); $ins_stmt = Database::prepare(" @@ -782,7 +791,8 @@ if ($page == 'domains' `phpsettingid` = :phpsettingid, `mod_fcgid_starter` = :mod_fcgid_starter, `mod_fcgid_maxrequests` = :mod_fcgid_maxrequests, - `ismainbutsubto` = :ismainbutsubto + `ismainbutsubto` = :ismainbutsubto, + `letsencrypt` = :letsencrypt "); Database::pexecute($ins_stmt, $ins_data); $domainid = Database::lastInsertId(); @@ -1288,6 +1298,11 @@ if ($page == 'domains' $ssl_redirect = (int)$_POST['ssl_redirect']; } + $letsencrypt = 0; + if (isset($_POST['letsencrypt'])) { + $letsencrypt = (int)$_POST['letsencrypt']; + } + $ssl_ipandports = array(); if (isset($_POST['ssl_ipandport']) && !is_array($_POST['ssl_ipandport'])) { $_POST['ssl_ipandport'] = unserialize($_POST['ssl_ipandport']); @@ -1314,12 +1329,14 @@ if ($page == 'domains' } } else { $ssl_redirect = 0; + $letsencrypt = 0; // we need this for the serialize // if ssl is disabled or no ssl-ip/port exists $ssl_ipandports[] = -1; } } else { $ssl_redirect = 0; + $letsencrypt = 0; // we need this for the serialize // if ssl is disabled or no ssl-ip/port exists $ssl_ipandports[] = -1; @@ -1443,7 +1460,8 @@ if ($page == 'domains' 'speciallogfile' => $speciallogfile, 'speciallogverified' => $speciallogverified, 'ipandport' => serialize($ipandports), - 'ssl_ipandport' => serialize($ssl_ipandports) + 'ssl_ipandport' => serialize($ssl_ipandports), + 'letsencrypt' => $letsencrypt ); $security_questions = array( @@ -1478,6 +1496,7 @@ if ($page == 'domains' || $issubof != $result['ismainbutsubto'] || $email_only != $result['email_only'] || ($speciallogfile != $result['speciallogfile'] && $speciallogverified == '1') + || $letsencrypt != $result['letsencrypt'] ) { inserttask('1'); } @@ -1613,6 +1632,7 @@ if ($page == 'domains' $update_data['specialsettings'] = $specialsettings; $update_data['registration_date'] = $registration_date; $update_data['ismainbutsubto'] = $issubof; + $update_data['letsencrypt'] = $letsencrypt; $update_data['id'] = $id; $update_stmt = Database::prepare(" @@ -1638,7 +1658,8 @@ if ($page == 'domains' `mod_fcgid_maxrequests` = :mod_fcgid_maxrequests, `specialsettings` = :specialsettings, `registration_date` = :registration_date, - `ismainbutsubto` = :ismainbutsubto + `ismainbutsubto` = :ismainbutsubto, + `letsencrypt` = :letsencrypt WHERE `id` = :id "); Database::pexecute($update_stmt, $update_data); @@ -1653,9 +1674,10 @@ if ($page == 'domains' // if we have no more ssl-ip's for this domain, // all its subdomains must have "ssl-redirect = 0" + // and disable let's encrypt $update_sslredirect = ''; if (count($ssl_ipandports) == 1 && $ssl_ipandports[0] == -1) { - $update_sslredirect = ", `ssl_redirect` = '0' "; + $update_sslredirect = ", `ssl_redirect` = '0', `letsencrypt` = '0' "; } $_update_stmt = Database::prepare(" diff --git a/lib/formfields/admin/domains/formfield.domains_add.php b/lib/formfields/admin/domains/formfield.domains_add.php index 12dbae4a..1c21af4d 100644 --- a/lib/formfields/admin/domains/formfield.domains_add.php +++ b/lib/formfields/admin/domains/formfield.domains_add.php @@ -113,6 +113,16 @@ return array( ), 'value' => array() ), + 'letsencrypt' => array( + 'visible' => (Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports != '' ? true : false) : false), + 'label' => $lng['domains']['letsencrypt']['title'], + 'desc' => $lng['domains']['letsencrypt']['description'], + 'type' => 'checkbox', + 'values' => array( + array ('label' => $lng['panel']['yes'], 'value' => '1') + ), + 'value' => array() + ), 'no_ssl_available_info' => array( 'visible' => (Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports == '' ? true : false) : false), 'label' => 'SSL', diff --git a/lib/formfields/admin/domains/formfield.domains_edit.php b/lib/formfields/admin/domains/formfield.domains_edit.php index d4d79698..4a77d898 100644 --- a/lib/formfields/admin/domains/formfield.domains_edit.php +++ b/lib/formfields/admin/domains/formfield.domains_edit.php @@ -124,6 +124,16 @@ return array( ), 'value' => array($result['ssl_redirect']) ), + 'letsencrypt' => array( + 'visible' => (Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports != '' ? true : false) : false), + 'label' => $lng['domains']['letsencrypt']['title'], + 'desc' => $lng['domains']['letsencrypt']['description'], + 'type' => 'checkbox', + 'values' => array( + array ('label' => $lng['panel']['yes'], 'value' => '1') + ), + 'value' => array($result['letsencrypt']) + ), 'no_ssl_available_info' => array( 'visible' => (Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports == '' ? true : false) : false), 'label' => 'SSL',