new improved template scheme

This commit is contained in:
Serghey Rodin 2013-05-10 11:04:40 +03:00
commit fd4e68bb8c
96 changed files with 1395 additions and 1425 deletions

View file

@ -33,7 +33,9 @@ if ($_SESSION['user'] == 'admin') {
unset($output);
$v_package = $_GET['package'];
$v_template = $data[$v_package]['TEMPLATE'];
$v_web_template = $data[$v_package]['WEB_TEMPLATE'];
$v_proxy_template = $data[$v_package]['PROXY_TEMPLATE'];
$v_dns_template = $data[$v_package]['DNS_TEMPLATE'];
$v_web_domains = $data[$v_package]['WEB_DOMAINS'];
$v_web_aliases = $data[$v_package]['WEB_ALIASES'];
$v_dns_domains = $data[$v_package]['DNS_DOMAINS'];
@ -59,7 +61,17 @@ if ($_SESSION['user'] == 'admin') {
exec (VESTA_CMD."v-list-web-templates json", $output, $return_var);
check_error($return_var);
$templates = json_decode(implode('', $output), true);
$web_templates = json_decode(implode('', $output), true);
unset($output);
exec (VESTA_CMD."v-list-web-templates-proxy json", $output, $return_var);
check_error($return_var);
$proxy_templates = json_decode(implode('', $output), true);
unset($output);
exec (VESTA_CMD."v-list-dns-templates json", $output, $return_var);
check_error($return_var);
$dns_templates = json_decode(implode('', $output), true);
unset($output);
exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var);
@ -71,7 +83,9 @@ if ($_SESSION['user'] == 'admin') {
if (!empty($_POST['save'])) {
// Check input
if (empty($_POST['v_package'])) $errors[] = __('package');
if (empty($_POST['v_template'])) $errors[] = __('template');
if (empty($_POST['v_web_template'])) $errors[] = __('web template');
if (empty($_POST['v_proxy_template'])) $errors[] = __('proxy template');
if (empty($_POST['v_dns_template'])) $errors[] = __('dns template');
if (empty($_POST['v_shell'])) $errrors[] = __('shell');
if (!isset($_POST['v_web_domains'])) $errors[] = __('web domains');
if (!isset($_POST['v_web_aliases'])) $errors[] = __('web aliases');
@ -89,7 +103,9 @@ if ($_SESSION['user'] == 'admin') {
// Protect input
$v_package = escapeshellarg($_POST['v_package']);
$v_template = escapeshellarg($_POST['v_template']);
$v_web_template = escapeshellarg($_POST['v_web_template']);
$v_proxy_template = escapeshellarg($_POST['v_proxy_template']);
$v_dns_template = escapeshellarg($_POST['v_dns_template']);
$v_shell = escapeshellarg($_POST['v_shell']);
$v_web_domains = escapeshellarg($_POST['v_web_domains']);
$v_web_aliases = escapeshellarg($_POST['v_web_aliases']);
@ -129,7 +145,9 @@ if ($_SESSION['user'] == 'admin') {
unset($output);
// Create package
$pkg = "TEMPLATE=".$v_template."\n";
$pkg = "WEB_TEMPLATE=".$v_web_template."\n";
$pkg .= "PROXY_TEMPLATE=".$v_proxy_template."\n";
$pkg .= "DNS_TEMPLATE=".$v_dns_template."\n";
$pkg .= "WEB_DOMAINS=".$v_web_domains."\n";
$pkg .= "WEB_ALIASES=".$v_web_aliases."\n";
$pkg .= "DNS_DOMAINS=".$v_dns_domains."\n";

View file

@ -32,7 +32,6 @@ if ($_SESSION['user'] == 'admin') {
$v_username = $_GET['user'];
$v_password = "••••••••";
$v_email = $data[$v_username]['CONTACT'];
$v_template = $data[$v_username]['TEMPLATE'];
$v_package = $data[$v_username]['PACKAGE'];
$v_language = $data[$v_username]['LANGUAGE'];
$v_fname = $data[$v_username]['FNAME'];
@ -61,10 +60,6 @@ if ($_SESSION['user'] == 'admin') {
$languages = json_decode(implode('', $output), true);
unset($output);
exec (VESTA_CMD."v-list-web-templates json", $output, $return_var);
$templates = json_decode(implode('', $output), true);
unset($output);
exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var);
$shells = json_decode(implode('', $output), true);
unset($output);
@ -113,18 +108,6 @@ if ($_SESSION['user'] == 'admin') {
unset($output);
}
// Change template
if (($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) {
$v_template = escapeshellarg($_POST['v_template']);
exec (VESTA_CMD."v-change-user-template ".$v_username." ".$v_template, $output, $return_var);
if ($return_var != 0) {
$error = implode('<br>', $output);
if (empty($error)) $error = __('Error code:',$return_var);
$_SESSION['error_msg'] = $error;
}
unset($output);
}
// Change shell
if (($v_shell != $_POST['v_shell']) && (empty($_SESSION['error_msg']))) {
$v_shell = escapeshellarg($_POST['v_shell']);

View file

@ -54,8 +54,9 @@ if ($return_var != 0) {
$v_ssl_ca = $ssl_str[$v_domain]['CA'];
}
$v_ssl_home = $data[$v_domain]['SSL_HOME'];
$v_nginx = $data[$v_domain]['NGINX'];
$v_nginx_ext = str_replace(',', ', ', $data[$v_domain]['NGINX_EXT']);
$v_proxy = $data[$v_domain]['PROXY'];
$v_proxy_template = $data[$v_domain]['PROXY'];
$v_proxy_ext = str_replace(',', ', ', $data[$v_domain]['PROXY_EXT']);
$v_stats = $data[$v_domain]['STATS'];
$v_stats_user = $data[$v_domain]['STATS_USER'];
if (!empty($v_stats_user)) $v_stats_password = "••••••••";
@ -78,6 +79,10 @@ if ($return_var != 0) {
$templates = json_decode(implode('', $output), true);
unset($output);
exec (VESTA_CMD."v-list-web-templates-proxy json", $output, $return_var);
$proxy_templates = json_decode(implode('', $output), true);
unset($output);
exec (VESTA_CMD."v-list-web-stats json", $output, $return_var);
$stats = json_decode(implode('', $output), true);
unset($output);
@ -200,56 +205,56 @@ if (!empty($_POST['save'])) {
}
}
// Nginx
if ((!empty($v_nginx)) && (empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) {
exec (VESTA_CMD."v-delete-web-domain-nginx ".$v_username." ".$v_domain." 'no'", $output, $return_var);
// Proxy
if ((!empty($v_proxy)) && (empty($_POST['v_proxy'])) && (empty($_SESSION['error_msg']))) {
exec (VESTA_CMD."v-delete-web-domain-proxy ".$v_username." ".$v_domain." 'no'", $output, $return_var);
if ($return_var != 0) {
$error = implode('<br>', $output);
if (empty($error)) $error = __('Error code:',$return_var);
$_SESSION['error_msg'] = $error;
}
unset($output);
unset($v_nginx);
$restart_web = 'yes';
unset($v_proxy);
$restart_proxy = 'yes';
}
if ((!empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) {
$ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']);
if ((!empty($v_proxy)) && (!empty($_POST['v_proxy'])) && (empty($_SESSION['error_msg']))) {
$ext = preg_replace("/\n/", " ", $_POST['v_proxy_ext']);
$ext = preg_replace("/,/", " ", $ext);
$ext = preg_replace('/\s+/', ' ',$ext);
$ext = trim($ext);
$ext = str_replace(' ', ", ", $ext);
if ( $v_nginx_ext != $ext ) {
if (( $v_proxy_template != $_POST['v_proxy_template']) || ($v_proxy_ext != $ext)) {
$ext = str_replace(', ', ",", $ext);
exec (VESTA_CMD."v-change-web-domain-nginx-tpl ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var);
exec (VESTA_CMD."v-change-web-domain-proxy-tpl ".$v_username." ".$v_domain." ".escapeshellarg($_POST['v_proxy_template'])." ".escapeshellarg($ext)." 'no'", $output, $return_var);
if ($return_var != 0) {
$error = implode('<br>', $output);
if (empty($error)) $error = __('Error code:',$return_var);
$_SESSION['error_msg'] = $error;
}
$v_nginx_ext = str_replace(',', ', ', $ext);
$v_proxy_template = $_POST['v_proxy_template'];
$v_proxy_ext = str_replace(',', ', ', $ext);
unset($output);
$restart_web = 'yes';
$restart_proxy = 'yes';
}
}
if ((empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) {
$nginx_ext = "'jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm'";
if (!empty($_POST['v_nginx_ext'])) {
$ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']);
if ((empty($v_proxy)) && (!empty($_POST['v_proxy'])) && (empty($_SESSION['error_msg']))) {
$v_proxy_template = $_POST['v_proxy_template'];
if (!empty($_POST['v_proxy_ext'])) {
$ext = preg_replace("/\n/", " ", $_POST['v_proxy_ext']);
$ext = preg_replace("/,/", " ", $ext);
$ext = preg_replace('/\s+/', ' ',$ext);
$ext = trim($ext);
$ext = str_replace(' ', ",", $ext);
$v_nginx_ext = str_replace(',', ', ', $ext);
$v_proxy_ext = str_replace(',', ', ', $ext);
}
exec (VESTA_CMD."v-add-web-domain-nginx ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var);
exec (VESTA_CMD."v-add-web-domain-proxy ".$v_username." ".$v_domain." ".escapeshellarg($v_proxy_template)." ".escapeshellarg($ext)." 'no'", $output, $return_var);
if ($return_var != 0) {
$error = implode('<br>', $output);
if (empty($error)) $error = __('Error code:',$return_var);
$_SESSION['error_msg'] = $error;
}
unset($output);
$v_nginx = 'default';
$restart_web = 'yes';
$restart_proxy = 'yes';
}
// SSL