|
|
@@ -35,7 +35,8 @@ $v_tpl = $data[$v_domain]['IP'];
|
|
|
$v_cgi = $data[$v_domain]['CGI'];
|
|
|
$v_elog = $data[$v_domain]['ELOG'];
|
|
|
$v_ssl = $data[$v_domain]['SSL'];
|
|
|
-if ( $v_ssl == 'yes' ) {
|
|
|
+$v_letsencrypt = $data[$v_domain]['LETSENCRYPT'];
|
|
|
+if ( $v_ssl == 'yes' && ($v_letsencrypt == 'no' || empty($v_letsencrypt))) {
|
|
|
exec (VESTA_CMD."v-list-web-domain-ssl ".$user." '".$v_domain."' json", $output, $return_var);
|
|
|
$ssl_str = json_decode(implode('', $output), true);
|
|
|
unset($output);
|
|
|
@@ -256,139 +257,159 @@ if (!empty($_POST['save'])) {
|
|
|
$restart_proxy = 'yes';
|
|
|
}
|
|
|
|
|
|
- // Delete SSL certificate
|
|
|
- if (( $v_ssl == 'yes' ) && (empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
|
|
|
- exec (VESTA_CMD."v-delete-web-domain-ssl ".$v_username." ".$v_domain." 'no'", $output, $return_var);
|
|
|
+ // Disable Lets Encrypt support
|
|
|
+
|
|
|
+ if (( $v_letsencrypt == 'yes' ) && (empty($_POST['v_letsencrypt'])) && (!empty($_POST['v_letsencrypt'])) && (empty($_SESSION['error_msg']))) {
|
|
|
+ exec (VESTA_CMD."v-add-letsencrypt-domain ".$user." ".$v_domain." '' 'no'", $output, $return_var);
|
|
|
check_return_code($return_var,$output);
|
|
|
unset($output);
|
|
|
- $v_ssl = 'no';
|
|
|
+ $v_letsencrypt = 'no';
|
|
|
$restart_web = 'yes';
|
|
|
$restart_proxy = 'yes';
|
|
|
- }
|
|
|
-
|
|
|
- // Change SSL certificate
|
|
|
- if (($v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
|
|
|
- if (( $v_ssl_crt != str_replace("\r\n", "\n", $_POST['v_ssl_crt'])) || ( $v_ssl_key != str_replace("\r\n", "\n", $_POST['v_ssl_key'])) || ( $v_ssl_ca != str_replace("\r\n", "\n", $_POST['v_ssl_ca']))) {
|
|
|
- exec ('mktemp -d', $mktemp_output, $return_var);
|
|
|
- $tmpdir = $mktemp_output[0];
|
|
|
-
|
|
|
- // Certificate
|
|
|
- if (!empty($_POST['v_ssl_crt'])) {
|
|
|
- $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w');
|
|
|
- fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt']));
|
|
|
- fwrite($fp, "\n");
|
|
|
- fclose($fp);
|
|
|
- }
|
|
|
-
|
|
|
- // Key
|
|
|
- if (!empty($_POST['v_ssl_key'])) {
|
|
|
- $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w');
|
|
|
- fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key']));
|
|
|
- fwrite($fp, "\n");
|
|
|
- fclose($fp);
|
|
|
- }
|
|
|
-
|
|
|
- // CA
|
|
|
- if (!empty($_POST['v_ssl_ca'])) {
|
|
|
- $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w');
|
|
|
- fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca']));
|
|
|
- fwrite($fp, "\n");
|
|
|
- fclose($fp);
|
|
|
- }
|
|
|
-
|
|
|
- exec (VESTA_CMD."v-change-web-domain-sslcert ".$user." ".$v_domain." ".$tmpdir." 'no'", $output, $return_var);
|
|
|
- check_return_code($return_var,$output);
|
|
|
- unset($output);
|
|
|
- $restart_web = 'yes';
|
|
|
- $restart_proxy = 'yes';
|
|
|
- $v_ssl_crt = $_POST['v_ssl_crt'];
|
|
|
- $v_ssl_key = $_POST['v_ssl_key'];
|
|
|
- $v_ssl_ca = $_POST['v_ssl_ca'];
|
|
|
-
|
|
|
- // Cleanup certificate tempfiles
|
|
|
- if (!empty($_POST['v_ssl_crt'])) {
|
|
|
- unlink($tmpdir."/".$_POST['v_domain'].".crt");
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($_POST['v_ssl_key'])) {
|
|
|
- unlink($tmpdir."/".$_POST['v_domain'].".key");
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($_POST['v_ssl_ca'])) {
|
|
|
- unlink($tmpdir."/".$_POST['v_domain'].".ca");
|
|
|
- }
|
|
|
-
|
|
|
- rmdir($tmpdir);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Add SSL certificate
|
|
|
- if (( $v_ssl == 'no') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
|
|
|
- if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_crt']))) $errors[] = 'ssl certificate';
|
|
|
- if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_key']))) $errors[] = 'ssl key';
|
|
|
- if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_home']))) $errors[] = 'ssl home';
|
|
|
- $v_ssl_home = escapeshellarg($_POST['v_ssl_home']);
|
|
|
- if (!empty($errors[0])) {
|
|
|
- foreach ($errors as $i => $error) {
|
|
|
- if ( $i == 0 ) {
|
|
|
- $error_msg = $error;
|
|
|
- } else {
|
|
|
- $error_msg = $error_msg.", ".$error;
|
|
|
- }
|
|
|
- }
|
|
|
- $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
|
|
|
- } else {
|
|
|
- exec ('mktemp -d', $mktemp_output, $return_var);
|
|
|
- $tmpdir = $mktemp_output[0];
|
|
|
-
|
|
|
- // Certificate
|
|
|
- if (!empty($_POST['v_ssl_crt'])) {
|
|
|
- $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w');
|
|
|
- fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt']));
|
|
|
- fclose($fp);
|
|
|
- }
|
|
|
-
|
|
|
- // Key
|
|
|
- if (!empty($_POST['v_ssl_key'])) {
|
|
|
- $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w');
|
|
|
- fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key']));
|
|
|
- fclose($fp);
|
|
|
- }
|
|
|
-
|
|
|
- // CA
|
|
|
- if (!empty($_POST['v_ssl_ca'])) {
|
|
|
- $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w');
|
|
|
- fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca']));
|
|
|
- fclose($fp);
|
|
|
- }
|
|
|
- exec (VESTA_CMD."v-add-web-domain-ssl ".$user." ".$v_domain." ".$tmpdir." ".$v_ssl_home." 'no'", $output, $return_var);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // Delete SSL certificate
|
|
|
+ if (( $v_ssl == 'yes' ) && (empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
|
|
|
+ exec (VESTA_CMD."v-delete-web-domain-ssl ".$v_username." ".$v_domain." 'no'", $output, $return_var);
|
|
|
check_return_code($return_var,$output);
|
|
|
unset($output);
|
|
|
- $v_ssl = 'yes';
|
|
|
+ $v_ssl = 'no';
|
|
|
$restart_web = 'yes';
|
|
|
$restart_proxy = 'yes';
|
|
|
- $v_ssl_crt = $_POST['v_ssl_crt'];
|
|
|
- $v_ssl_key = $_POST['v_ssl_key'];
|
|
|
- $v_ssl_ca = $_POST['v_ssl_ca'];
|
|
|
- $v_ssl_home = $_POST['v_ssl_home'];
|
|
|
-
|
|
|
- // Cleanup certificate tempfiles
|
|
|
- if (!empty($_POST['v_ssl_crt'])) {
|
|
|
- unlink($tmpdir."/".$_POST['v_domain'].".crt");
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($_POST['v_ssl_key'])) {
|
|
|
- unlink($tmpdir."/".$_POST['v_domain'].".key");
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($_POST['v_ssl_ca'])) {
|
|
|
- unlink($tmpdir."/".$_POST['v_domain'].".ca");
|
|
|
- }
|
|
|
-
|
|
|
- rmdir($tmpdir);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+ if (( $v_letsencrypt == 'no' || empty( $v_letsencrypt)) && (!empty($_POST['v_letsencrypt'])) && empty($_SESSION['error_msg'])) {
|
|
|
+ exec (VESTA_CMD."v-add-letsencrypt-domain ".$user." ".$v_domain." '' 'no'", $output, $return_var);
|
|
|
+ check_return_code($return_var,$output);
|
|
|
+ unset($output);
|
|
|
+ $v_letsencrypt = 'yes';
|
|
|
+ $restart_web = 'yes';
|
|
|
+ $restart_proxy = 'yes';
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ // Change SSL certificate
|
|
|
+ if (($v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
|
|
|
+ if (( $v_ssl_crt != str_replace("\r\n", "\n", $_POST['v_ssl_crt'])) || ( $v_ssl_key != str_replace("\r\n", "\n", $_POST['v_ssl_key'])) || ( $v_ssl_ca != str_replace("\r\n", "\n", $_POST['v_ssl_ca']))) {
|
|
|
+ exec ('mktemp -d', $mktemp_output, $return_var);
|
|
|
+ $tmpdir = $mktemp_output[0];
|
|
|
+
|
|
|
+ // Certificate
|
|
|
+ if (!empty($_POST['v_ssl_crt'])) {
|
|
|
+ $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w');
|
|
|
+ fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt']));
|
|
|
+ fwrite($fp, "\n");
|
|
|
+ fclose($fp);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Key
|
|
|
+ if (!empty($_POST['v_ssl_key'])) {
|
|
|
+ $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w');
|
|
|
+ fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key']));
|
|
|
+ fwrite($fp, "\n");
|
|
|
+ fclose($fp);
|
|
|
+ }
|
|
|
+
|
|
|
+ // CA
|
|
|
+ if (!empty($_POST['v_ssl_ca'])) {
|
|
|
+ $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w');
|
|
|
+ fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca']));
|
|
|
+ fwrite($fp, "\n");
|
|
|
+ fclose($fp);
|
|
|
+ }
|
|
|
+
|
|
|
+ exec (VESTA_CMD."v-change-web-domain-sslcert ".$user." ".$v_domain." ".$tmpdir." 'no'", $output, $return_var);
|
|
|
+ check_return_code($return_var,$output);
|
|
|
+ unset($output);
|
|
|
+ $restart_web = 'yes';
|
|
|
+ $restart_proxy = 'yes';
|
|
|
+ $v_ssl_crt = $_POST['v_ssl_crt'];
|
|
|
+ $v_ssl_key = $_POST['v_ssl_key'];
|
|
|
+ $v_ssl_ca = $_POST['v_ssl_ca'];
|
|
|
+
|
|
|
+ // Cleanup certificate tempfiles
|
|
|
+ if (!empty($_POST['v_ssl_crt'])) {
|
|
|
+ unlink($tmpdir."/".$_POST['v_domain'].".crt");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($_POST['v_ssl_key'])) {
|
|
|
+ unlink($tmpdir."/".$_POST['v_domain'].".key");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($_POST['v_ssl_ca'])) {
|
|
|
+ unlink($tmpdir."/".$_POST['v_domain'].".ca");
|
|
|
+ }
|
|
|
+
|
|
|
+ rmdir($tmpdir);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Add SSL certificate
|
|
|
+ if (( $v_ssl == 'no') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
|
|
|
+ if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_crt']))) $errors[] = 'ssl certificate';
|
|
|
+ if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_key']))) $errors[] = 'ssl key';
|
|
|
+ if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_home']))) $errors[] = 'ssl home';
|
|
|
+ $v_ssl_home = escapeshellarg($_POST['v_ssl_home']);
|
|
|
+ if (!empty($errors[0])) {
|
|
|
+ foreach ($errors as $i => $error) {
|
|
|
+ if ( $i == 0 ) {
|
|
|
+ $error_msg = $error;
|
|
|
+ } else {
|
|
|
+ $error_msg = $error_msg.", ".$error;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
|
|
|
+ } else {
|
|
|
+ exec ('mktemp -d', $mktemp_output, $return_var);
|
|
|
+ $tmpdir = $mktemp_output[0];
|
|
|
+
|
|
|
+ // Certificate
|
|
|
+ if (!empty($_POST['v_ssl_crt'])) {
|
|
|
+ $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w');
|
|
|
+ fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt']));
|
|
|
+ fclose($fp);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Key
|
|
|
+ if (!empty($_POST['v_ssl_key'])) {
|
|
|
+ $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w');
|
|
|
+ fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key']));
|
|
|
+ fclose($fp);
|
|
|
+ }
|
|
|
+
|
|
|
+ // CA
|
|
|
+ if (!empty($_POST['v_ssl_ca'])) {
|
|
|
+ $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w');
|
|
|
+ fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca']));
|
|
|
+ fclose($fp);
|
|
|
+ }
|
|
|
+ exec (VESTA_CMD."v-add-web-domain-ssl ".$user." ".$v_domain." ".$tmpdir." ".$v_ssl_home." 'no'", $output, $return_var);
|
|
|
+ check_return_code($return_var,$output);
|
|
|
+ unset($output);
|
|
|
+ $v_ssl = 'yes';
|
|
|
+ $restart_web = 'yes';
|
|
|
+ $restart_proxy = 'yes';
|
|
|
+ $v_ssl_crt = $_POST['v_ssl_crt'];
|
|
|
+ $v_ssl_key = $_POST['v_ssl_key'];
|
|
|
+ $v_ssl_ca = $_POST['v_ssl_ca'];
|
|
|
+ $v_ssl_home = $_POST['v_ssl_home'];
|
|
|
+
|
|
|
+ // Cleanup certificate tempfiles
|
|
|
+ if (!empty($_POST['v_ssl_crt'])) {
|
|
|
+ unlink($tmpdir."/".$_POST['v_domain'].".crt");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($_POST['v_ssl_key'])) {
|
|
|
+ unlink($tmpdir."/".$_POST['v_domain'].".key");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($_POST['v_ssl_ca'])) {
|
|
|
+ unlink($tmpdir."/".$_POST['v_domain'].".ca");
|
|
|
+ }
|
|
|
+
|
|
|
+ rmdir($tmpdir);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// Change document root for ssl domain
|
|
|
if (( $v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
|
|
|
if ( $v_ssl_home != $_POST['v_ssl_home'] ) {
|