|
|
@@ -265,11 +265,85 @@ if (!empty($_POST['save'])) {
|
|
|
$restart_proxy = 'yes';
|
|
|
}
|
|
|
|
|
|
+ // 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'] ) {
|
|
|
+ $v_ssl_home = escapeshellarg($_POST['v_ssl_home']);
|
|
|
+ exec (VESTA_CMD."v-change-web-domain-sslhome ".$user." ".$v_domain." ".$v_ssl_home." 'no'", $output, $return_var);
|
|
|
+ check_return_code($return_var,$output);
|
|
|
+ $v_ssl_home = $_POST['v_ssl_home'];
|
|
|
+ $restart_web = 'yes';
|
|
|
+ $restart_proxy = 'yes';
|
|
|
+ unset($output);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Change SSL certificate
|
|
|
+ if (( $v_letsencrypt == 'no' ) && ( $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';
|
|
|
+
|
|
|
+ exec (VESTA_CMD."v-list-web-domain-ssl ".$user." '".$v_domain."' json", $output, $return_var);
|
|
|
+ $ssl_str = json_decode(implode('', $output), true);
|
|
|
+ unset($output);
|
|
|
+ $v_ssl_crt = $ssl_str[$v_domain]['CRT'];
|
|
|
+ $v_ssl_key = $ssl_str[$v_domain]['KEY'];
|
|
|
+ $v_ssl_ca = $ssl_str[$v_domain]['CA'];
|
|
|
+ $v_ssl_subject = $ssl_str[$v_domain]['SUBJECT'];
|
|
|
+ $v_ssl_aliases = $ssl_str[$v_domain]['ALIASES'];
|
|
|
+ $v_ssl_not_before = $ssl_str[$v_domain]['NOT_BEFORE'];
|
|
|
+ $v_ssl_not_after = $ssl_str[$v_domain]['NOT_AFTER'];
|
|
|
+ $v_ssl_signature = $ssl_str[$v_domain]['SIGNATURE'];
|
|
|
+ $v_ssl_pub_key = $ssl_str[$v_domain]['PUB_KEY'];
|
|
|
+ $v_ssl_issuer = $ssl_str[$v_domain]['ISSUER'];
|
|
|
+
|
|
|
+ // 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// Delete Lets Encrypt support
|
|
|
if (( $v_letsencrypt == 'yes' ) && (empty($_POST['v_letsencrypt'])) && (empty($_SESSION['error_msg']))) {
|
|
|
exec (VESTA_CMD."v-delete-letsencrypt-domain ".$user." ".$v_domain." 'no'", $output, $return_var);
|
|
|
check_return_code($return_var,$output);
|
|
|
unset($output);
|
|
|
+ $v_ssl_crt = '';
|
|
|
+ $v_ssl_key = '';
|
|
|
+ $v_ssl_ca = '';
|
|
|
$v_letsencrypt = 'no';
|
|
|
$v_letsencrypt_deleted = 'yes';
|
|
|
$v_ssl = 'no';
|
|
|
@@ -282,6 +356,9 @@ if (!empty($_POST['save'])) {
|
|
|
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_crt = '';
|
|
|
+ $v_ssl_key = '';
|
|
|
+ $v_ssl_ca = '';
|
|
|
$v_ssl = 'no';
|
|
|
$restart_web = 'yes';
|
|
|
$restart_proxy = 'yes';
|
|
|
@@ -348,16 +425,16 @@ if (!empty($_POST['save'])) {
|
|
|
exec (VESTA_CMD."v-list-web-domain-ssl ".$user." '".$v_domain."' json", $output, $return_var);
|
|
|
$ssl_str = json_decode(implode('', $output), true);
|
|
|
unset($output);
|
|
|
- $v_ssl_crt = $ssl_str[$v_domain]['CRT'];
|
|
|
- $v_ssl_key = $ssl_str[$v_domain]['KEY'];
|
|
|
- $v_ssl_ca = $ssl_str[$v_domain]['CA'];
|
|
|
- $v_ssl_subject = $ssl_str[$v_domain]['SUBJECT'];
|
|
|
- $v_ssl_aliases = $ssl_str[$v_domain]['ALIASES'];
|
|
|
- $v_ssl_not_before = $ssl_str[$v_domain]['NOT_BEFORE'];
|
|
|
- $v_ssl_not_after = $ssl_str[$v_domain]['NOT_AFTER'];
|
|
|
- $v_ssl_signature = $ssl_str[$v_domain]['SIGNATURE'];
|
|
|
- $v_ssl_pub_key = $ssl_str[$v_domain]['PUB_KEY'];
|
|
|
- $v_ssl_issuer = $ssl_str[$v_domain]['ISSUER'];
|
|
|
+ $v_ssl_crt = $ssl_str[$_POST['v_domain']]['CRT'];
|
|
|
+ $v_ssl_key = $ssl_str[$_POST['v_domain']]['KEY'];
|
|
|
+ $v_ssl_ca = $ssl_str[$_POST['v_domain']]['CA'];
|
|
|
+ $v_ssl_subject = $ssl_str[$_POST['v_domain']]['SUBJECT'];
|
|
|
+ $v_ssl_aliases = $ssl_str[$_POST['v_domain']]['ALIASES'];
|
|
|
+ $v_ssl_not_before = $ssl_str[$_POST['v_domain']]['NOT_BEFORE'];
|
|
|
+ $v_ssl_not_after = $ssl_str[$_POST['v_domain']]['NOT_AFTER'];
|
|
|
+ $v_ssl_signature = $ssl_str[$_POST['v_domain']]['SIGNATURE'];
|
|
|
+ $v_ssl_pub_key = $ssl_str[$_POST['v_domain']]['PUB_KEY'];
|
|
|
+ $v_ssl_issuer = $ssl_str[$_POST['v_domain']]['ISSUER'];
|
|
|
|
|
|
// Cleanup certificate tempfiles
|
|
|
if (!empty($_POST['v_ssl_crt'])) unlink($tmpdir."/".$_POST['v_domain'].".crt");
|
|
|
@@ -367,76 +444,7 @@ if (!empty($_POST['save'])) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Change SSL certificate
|
|
|
- if (( $v_letsencrypt == 'no' ) && ( $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';
|
|
|
-
|
|
|
- exec (VESTA_CMD."v-list-web-domain-ssl ".$user." '".$v_domain."' json", $output, $return_var);
|
|
|
- $ssl_str = json_decode(implode('', $output), true);
|
|
|
- unset($output);
|
|
|
- $v_ssl_crt = $ssl_str[$v_domain]['CRT'];
|
|
|
- $v_ssl_key = $ssl_str[$v_domain]['KEY'];
|
|
|
- $v_ssl_ca = $ssl_str[$v_domain]['CA'];
|
|
|
- $v_ssl_subject = $ssl_str[$v_domain]['SUBJECT'];
|
|
|
- $v_ssl_aliases = $ssl_str[$v_domain]['ALIASES'];
|
|
|
- $v_ssl_not_before = $ssl_str[$v_domain]['NOT_BEFORE'];
|
|
|
- $v_ssl_not_after = $ssl_str[$v_domain]['NOT_AFTER'];
|
|
|
- $v_ssl_signature = $ssl_str[$v_domain]['SIGNATURE'];
|
|
|
- $v_ssl_pub_key = $ssl_str[$v_domain]['PUB_KEY'];
|
|
|
- $v_ssl_issuer = $ssl_str[$v_domain]['ISSUER'];
|
|
|
-
|
|
|
- // 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'] ) {
|
|
|
- $v_ssl_home = escapeshellarg($_POST['v_ssl_home']);
|
|
|
- exec (VESTA_CMD."v-change-web-domain-sslhome ".$user." ".$v_domain." ".$v_ssl_home." 'no'", $output, $return_var);
|
|
|
- check_return_code($return_var,$output);
|
|
|
- $v_ssl_home = $_POST['v_ssl_home'];
|
|
|
- $restart_web = 'yes';
|
|
|
- $restart_proxy = 'yes';
|
|
|
- unset($output);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
// Delete web stats
|
|
|
if ((!empty($v_stats)) && ($_POST['v_stats'] == 'none') && (empty($_SESSION['error_msg']))) {
|