From 01262ce4b51e2b081e9e1a466d9f70a38cfcf401 Mon Sep 17 00:00:00 2001 From: Dustin Dauncey Date: Tue, 29 Jul 2014 14:03:16 -0700 Subject: [PATCH 01/19] Update v-add-cron-job Just fixed a typo in the description. --- bin/v-add-cron-job | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/v-add-cron-job b/bin/v-add-cron-job index b6b2dd575..75a396a09 100755 --- a/bin/v-add-cron-job +++ b/bin/v-add-cron-job @@ -55,7 +55,7 @@ str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" # Adding to crontab echo "$str" >> $VESTA/data/users/$user/cron.conf -# Chaning permissions +# Changing permissions chmod 660 $VESTA/data/users/$user/cron.conf # Sort jobs by id number From d580ce6f998182c22c27dc19fa896d03d14a60aa Mon Sep 17 00:00:00 2001 From: Dustin Dauncey Date: Tue, 29 Jul 2014 15:04:05 -0700 Subject: [PATCH 02/19] Update en.php Updated for more consistency (i.e.: all sentences should end in a period.), and improved the flow of words in some sentences for clarity. Minor changes. --- web/inc/i18n/en.php | 72 ++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/web/inc/i18n/en.php b/web/inc/i18n/en.php index f4a8613f2..d9c56d45b 100644 --- a/web/inc/i18n/en.php +++ b/web/inc/i18n/en.php @@ -265,7 +265,7 @@ $LANG['en'] = array( 'Message' => 'Message', 'use local-part' => 'use local-part', 'one or more email addresses' => 'one or more email addresses', - 'Prefix will be automaticaly added to database name and database user' => 'Prefix %s will be automaticaly added to database name and database user', + 'Prefix will be automaticaly added to database name and database user' => 'Prefix %s will be automaticaly added to database name and database user.', 'Database' => 'Database', 'Type' => 'Type', 'Minute' => 'Minute', @@ -355,50 +355,50 @@ $LANG['en'] = array( '%s objects' => '%s objects', 'no exclusions' => 'no exclusions', - 'USER_CREATED_OK' => 'User %s has been created successfully', + 'USER_CREATED_OK' => 'User %s has been created successfully.', 'WEB_DOMAIN_CREATED_OK' => 'Domain %s has been created successfully.', 'DNS_DOMAIN_CREATED_OK' => 'DNS domain %s has been created successfully.', 'DNS_RECORD_CREATED_OK' => 'Record %s.%s has been created successfully.', 'MAIL_DOMAIN_CREATED_OK' => 'Mail domain %s has been created successfully.', - 'MAIL_ACCOUNT_CREATED_OK' => 'Mail account %s@%s has been created successfully', - 'DATABASE_CREATED_OK' => 'Database %s has been created successfully', + 'MAIL_ACCOUNT_CREATED_OK' => 'Mail account %s@%s has been created successfully.', + 'DATABASE_CREATED_OK' => 'Database %s has been created successfully.', 'CRON_CREATED_OK' => 'Cron job has been created successfully.', 'IP_CREATED_OK' => 'IP address %s has been created successfully.', 'PACKAGE_CREATED_OK' => 'Package %s has been created successfully.', 'SSL_GENERATED_OK' => 'Certificate has been generated successfully.', - 'Autoupdate has been successfully enabled' => 'Autoupdate has been successfully enabled', - 'Autoupdate has been successfully disabled' => 'Autoupdate has been successfully disabled', - 'Changes has been saved.' => 'Changes has been saved.', + 'Autoupdate has been successfully enabled' => 'Autoupdate has been successfully enabled.', + 'Autoupdate has been successfully disabled' => 'Autoupdate has been successfully disabled.', + 'Changes has been saved.' => 'Changes have been saved.', 'Confirmation' => 'Confirmation', - 'DELETE_USER_CONFIRMATION' => 'Are you sure to delete user %s?', - 'SUSPEND_USER_CONFIRMATION' => 'Are you sure to suspend user %s?', - 'UNSUSPEND_USER_CONFIRMATION' => 'Are you sure to unsuspend user %s?', - 'DELETE_DOMAIN_CONFIRMATION' => 'Are you sure to delete domain %s?', - 'SUSPEND_DOMAIN_CONFIRMATION' => 'Are you sure to suspend domain %s?', - 'UNSUSPEND_DOMAIN_CONFIRMATION' => 'Are you sure to unsuspend domain %s?', - 'DELETE_RECORD_CONFIRMATION' => 'Are you sure to delete record %s?', - 'SUSPEND_RECORD_CONFIRMATION' => 'Are you sure to suspend record %s?', - 'UNSUSPEND_RECORD_CONFIRMATION' => 'Are you sure to unsuspend record %s?', - 'DELETE_MAIL_ACCOUNT_CONFIRMATION' => 'Are you sure to delete %s?', - 'SUSPEND_MAIL_ACCOUNT_CONFIRMATION' => 'Are you sure to suspend %s?', - 'UNSUSPEND_MAIL_ACCOUNT_CONFIRMATION' => 'Are you sure to unsuspend %s?', - 'DELETE_DATABASE_CONFIRMATION' => 'Are you sure to delete database %s?', - 'SUSPEND_DATABASE_CONFIRMATION' => 'Are you sure to suspend database %s?', - 'UNSUSPEND_DATABASE_CONFIRMATION' => 'Are you sure to unsuspend database %s?', - 'DELETE_CRON_CONFIRMATION' => 'Are you sure to delete cron job?', - 'SUSPEND_CRON_CONFIRMATION' => 'Are you sure to suspend cron job?', - 'UNSUSPEND_CRON_CONFIRMATION' => 'Are you sure to unsuspend cron job?', - 'DELETE_BACKUP_CONFIRMATION' => 'Are you sure to delete %s backup?', - 'DELETE_EXCLUSION_CONFIRMATION' => 'Are you sure to delete %s exclusion?', - 'DELETE_PACKAGE_CONFIRMATION' => 'Are you sure to delete package %s?', - 'DELETE_IP_CONFIRMATION' => 'Are you sure to delere IP address %s?', + 'DELETE_USER_CONFIRMATION' => 'Are you sure you want to delete user %s?', + 'SUSPEND_USER_CONFIRMATION' => 'Are you sure you want to suspend user %s?', + 'UNSUSPEND_USER_CONFIRMATION' => 'Are you sure you want to unsuspend user %s?', + 'DELETE_DOMAIN_CONFIRMATION' => 'Are you sure you want to delete domain %s?', + 'SUSPEND_DOMAIN_CONFIRMATION' => 'Are you sure you want to suspend domain %s?', + 'UNSUSPEND_DOMAIN_CONFIRMATION' => 'Are you sure you want to unsuspend domain %s?', + 'DELETE_RECORD_CONFIRMATION' => 'Are you sure you want to delete record %s?', + 'SUSPEND_RECORD_CONFIRMATION' => 'Are you sure you want to suspend record %s?', + 'UNSUSPEND_RECORD_CONFIRMATION' => 'Are you sure you want to unsuspend record %s?', + 'DELETE_MAIL_ACCOUNT_CONFIRMATION' => 'Are you sure you want to delete %s?', + 'SUSPEND_MAIL_ACCOUNT_CONFIRMATION' => 'Are you sure you want to suspend %s?', + 'UNSUSPEND_MAIL_ACCOUNT_CONFIRMATION' => 'Are you sure you want to unsuspend %s?', + 'DELETE_DATABASE_CONFIRMATION' => 'Are you sure you want to delete database %s?', + 'SUSPEND_DATABASE_CONFIRMATION' => 'Are you sure you want to suspend database %s?', + 'UNSUSPEND_DATABASE_CONFIRMATION' => 'Are you sure you want to unsuspend database %s?', + 'DELETE_CRON_CONFIRMATION' => 'Are you sure you want to delete cron job?', + 'SUSPEND_CRON_CONFIRMATION' => 'Are you sure you want to suspend cron job?', + 'UNSUSPEND_CRON_CONFIRMATION' => 'Are you sure you want to unsuspend cron job?', + 'DELETE_BACKUP_CONFIRMATION' => 'Are you sure you want to delete %s backup?', + 'DELETE_EXCLUSION_CONFIRMATION' => 'Are you sure you want to delete %s exclusion?', + 'DELETE_PACKAGE_CONFIRMATION' => 'Are you sure you want to delete package %s?', + 'DELETE_IP_CONFIRMATION' => 'Are you sure you want to delete IP address %s?', 'Welcome' => 'Welcome', 'LOGGED_IN_AS' => 'Logged in as user %s', 'Error' => 'Error', - 'Invalid username or password' => 'Invalid username or password', - 'Invalid username or code' => 'Invalid username or code', - 'Passwords not match' => 'Passwords not match', - 'Please enter valid email address.' => 'Please enter valid email address.', + 'Invalid username or password' => 'Invalid username or password.', + 'Invalid username or code' => 'Invalid username or code.', + 'Passwords not match' => 'Passwords do not match.', + 'Please enter valid email address.' => 'Please enter a valid email address.', 'Field "%s" can not be blank.' => 'Field "%s" can not be blank.', 'Password is too short.' => 'Password is too short (minimum is 6 characters)', 'Error code:' => 'Error code: %s', @@ -406,7 +406,7 @@ $LANG['en'] = array( 'IP address is in use' => 'IP address is in use', 'BACKUP_SCHEDULED' => 'Task has been added to the queue. You will receive an email notification when your backup is ready for download.', 'BACKUP_EXISTS' => 'An existing backup is already running. Please wait for that backup to finish.', - 'RESTORE_SCHEDULED' => 'Task has been added to the queue. You will receive an email notification when your backup is ready for download.', + 'RESTORE_SCHEDULED' => 'Task has been added to the queue. You will receive an email notification when your restore has been completed.', 'RESTORE_EXISTS' => 'An existing restoration task is already running. Please wait for it to finish before launching it again.', 'WEB_EXCLUSIONS' => "Type domain name, one per line. To exclude all domains use *. To exclude specific dirs use following format: domain.com:public_html/cache:public_html/tmp", @@ -420,10 +420,10 @@ $LANG['en'] = array( 'MAIL_FROM' => 'Vesta Control Panel ', 'GREETINGS_GORDON_FREEMAN' => "Hello, %s %s,\n", 'GREETINGS' => "Hello,\n", - 'ACCOUNT_READY' => "Your account has been created and ready for use.\n\nhttps://%s/login/\nUsername: %s\nPassword: %s\n\n--\nVesta Control Panel\n", + 'ACCOUNT_READY' => "Your account has been created and is ready for use.\n\nhttps://%s/login/\nUsername: %s\nPassword: %s\n\n--\nVesta Control Panel\n", 'FTP login credentials' => 'FTP login credentials', - 'FTP_ACCOUNT_READY' => "FTP account has been created and ready for use.\n\nHostname: %s\nUsername: %s_%s\nPassword: %s\n\n--\nVesta Control Panel\n", + 'FTP_ACCOUNT_READY' => "FTP account has been created and is ready for use.\n\nHostname: %s\nUsername: %s_%s\nPassword: %s\n\n--\nVesta Control Panel\n", 'Database Credentials' => 'Database Credentials', 'DATABASE_READY' => "Database has been created successfully.\n\nDatabase: %s\nUser: %s\nPassword: %s\n%s\n\n--\nVesta Control Panel\n", From 2f300aab696e0f45eae9835330bfe1227c06ebaa Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 30 Jul 2014 15:29:50 +0300 Subject: [PATCH 03/19] Fix for Ubuntu 14.04 --- bin/v-list-user-ns | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/v-list-user-ns b/bin/v-list-user-ns index d296191b3..1da0fe5f1 100755 --- a/bin/v-list-user-ns +++ b/bin/v-list-user-ns @@ -21,7 +21,7 @@ json_list_ns() { ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \') echo '[' i=1 - nslistc=$(echo -e "${ns//,/\n}"|wc -l) + nslistc=$(echo -e "${ns//,/\\n}"|wc -l) for nameserver in ${ns//,/ };do if [ "$i" -ne "$nslistc" ]; then echo -e "\t\"$nameserver\"," From 2558fa550d14ce56656667c8b319c2559454f3e0 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 30 Jul 2014 15:34:34 +0300 Subject: [PATCH 04/19] Improved code formating --- web/add/cron/index.php | 71 ++-- web/add/db/index.php | 111 +++--- web/add/dns/index.php | 146 ++++---- web/add/ip/index.php | 139 +++---- web/add/mail/index.php | 234 ++++++------ web/add/package/index.php | 312 ++++++++-------- web/add/user/index.php | 196 +++++----- web/edit/backup/exclusions/index.php | 213 ++++++----- web/edit/cron/index.php | 120 +++--- web/edit/db/index.php | 101 +++-- web/edit/dns/index.php | 319 ++++++++-------- web/edit/ip/index.php | 189 +++++----- web/edit/mail/index.php | 527 ++++++++++++++------------- web/edit/package/index.php | 363 +++++++++--------- web/edit/user/index.php | 337 +++++++---------- 15 files changed, 1723 insertions(+), 1655 deletions(-) diff --git a/web/add/cron/index.php b/web/add/cron/index.php index 047d89b20..d7f1a2ce0 100644 --- a/web/add/cron/index.php +++ b/web/add/cron/index.php @@ -4,32 +4,19 @@ error_reporting(NULL); ob_start(); session_start(); $TAB = 'CRON'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); -// Header -include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); - -// Panel -top_panel($user,$TAB); - +// Check POST request if (!empty($_POST['ok'])) { - // Check input + + // Check empty fields if ((!isset($_POST['v_min'])) || ($_POST['v_min'] == '')) $errors[] = __('minute'); if ((!isset($_POST['v_hour'])) || ($_POST['v_hour'] == '')) $errors[] = __('hour'); if ((!isset($_POST['v_day'])) || ($_POST['v_day'] == '')) $errors[] = __('day'); if ((!isset($_POST['v_month'])) || ($_POST['v_month'] == '')) $errors[] = __('month'); if ((!isset($_POST['v_wday'])) || ($_POST['v_wday'] == '')) $errors[] = __('day of week'); if ((!isset($_POST['v_cmd'])) || ($_POST['v_cmd'] == '')) $errors[] = __('cmd'); - - // Protect input - $v_min = escapeshellarg($_POST['v_min']); - $v_hour = escapeshellarg($_POST['v_hour']); - $v_day = escapeshellarg($_POST['v_day']); - $v_month = escapeshellarg($_POST['v_month']); - $v_wday = escapeshellarg($_POST['v_wday']); - $v_cmd = escapeshellarg($_POST['v_cmd']); - - // Check for errors if (!empty($errors[0])) { foreach ($errors as $i => $error) { if ( $i == 0 ) { @@ -39,32 +26,46 @@ if (!empty($_POST['ok'])) { } } $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg); - } else { - // Add Cron Job + } + + // Protect input + $v_min = escapeshellarg($_POST['v_min']); + $v_hour = escapeshellarg($_POST['v_hour']); + $v_day = escapeshellarg($_POST['v_day']); + $v_month = escapeshellarg($_POST['v_month']); + $v_wday = escapeshellarg($_POST['v_wday']); + $v_cmd = escapeshellarg($_POST['v_cmd']); + + // Add cron job + if (empty($_SESSION['error_msg'])) { exec (VESTA_CMD."v-add-cron-job ".$user." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var); - $v_type = $_POST['v_type']; - $v_charset = $_POST['v_charset']; check_return_code($return_var,$output); - unset($v_password); unset($output); - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('CRON_CREATED_OK'); - unset($v_min); - unset($v_hour); - unset($v_day); - unset($v_month); - unset($v_wday); - unset($v_cmd); - unset($output); - } + } + + // Flush field values on success + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('CRON_CREATED_OK'); + unset($v_min); + unset($v_hour); + unset($v_day); + unset($v_month); + unset($v_wday); + unset($v_cmd); + unset($output); } } -exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var); -$db_types = json_decode(implode('', $output), true); -unset($output); +// Header +include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); +// Panel +top_panel($user,$TAB); + +// Display body include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_cron.html'); + +// Flush session messages unset($_SESSION['error_msg']); unset($_SESSION['ok_msg']); diff --git a/web/add/db/index.php b/web/add/db/index.php index a4c1e543e..a9d7e8fa7 100644 --- a/web/add/db/index.php +++ b/web/add/db/index.php @@ -6,24 +6,16 @@ session_start(); $TAB = 'DB'; include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); -// Header -include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); - -// Panel -top_panel($user,$TAB); - -$v_db_email = $panel[$user]['CONTACT']; - +// Check POST request if (!empty($_POST['ok'])) { - // Check input + + // Check empty fields if (empty($_POST['v_database'])) $errors[] = __('database'); if (empty($_POST['v_dbuser'])) $errors[] = __('username'); if (empty($_POST['v_password'])) $errors[] = __('password'); if (empty($_POST['v_type'])) $errors[] = __('type'); if (empty($_POST['v_host'])) $errors[] = __('host'); if (empty($_POST['v_charset'])) $errors[] = __('charset'); - - // Check for errors if (!empty($errors[0])) { foreach ($errors as $i => $error) { if ( $i == 0 ) { @@ -36,12 +28,18 @@ if (!empty($_POST['ok'])) { } // Validate email - if (!empty($_POST['v_db_email'])) { + if ((!empty($_POST['v_db_email'])) && (empty($_SESSION['error_msg']))) { if (!filter_var($_POST['v_db_email'], FILTER_VALIDATE_EMAIL)) { $_SESSION['error_msg'] = __('Please enter valid email address.'); } } + // Check password length + if (empty($_SESSION['error_msg'])) { + $pw_len = strlen($_POST['v_password']); + if ($pw_len < 6 ) $_SESSION['error_msg'] = __('Password is too short.',$error_msg); + } + // Protect input $v_database = escapeshellarg($_POST['v_database']); $v_dbuser = escapeshellarg($_POST['v_dbuser']); @@ -51,63 +49,71 @@ if (!empty($_POST['ok'])) { $v_host = $_POST['v_host']; $v_db_email = $_POST['v_db_email']; - // Check password length + // Add database if (empty($_SESSION['error_msg'])) { - $pw_len = strlen($_POST['v_password']); - if ($pw_len < 6 ) $_SESSION['error_msg'] = __('Password is too short.',$error_msg); - } - - if (empty($_SESSION['error_msg'])) { - // Add Database $v_type = escapeshellarg($_POST['v_type']); $v_charset = escapeshellarg($_POST['v_charset']); $v_host = escapeshellarg($_POST['v_host']); exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." ".$v_host." ".$v_charset, $output, $return_var); + check_return_code($return_var,$output); + unset($output); $v_type = $_POST['v_type']; $v_host = $_POST['v_host']; $v_charset = $_POST['v_charset']; - check_return_code($return_var,$output); + } + + // Get database manager url + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-list-sys-config json", $output, $return_var); + $sys = json_decode(implode('', $output), true); unset($output); - if ((!empty($v_db_email)) && (empty($_SESSION['error_msg']))) { - list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"]); - if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpmyadmin/"; - if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phppgadmin/"; - $to = $v_db_email; - $subject = __("Database Credentials"); - $hostname = exec('hostname'); - $from = __('MAIL_FROM',$hostname); - $mailtext = __('DATABASE_READY',$user."_".$_POST['v_database'],$user."_".$_POST['v_dbuser'],$_POST['v_password'],$db_admin_link); - send_email($to, $subject, $mailtext, $from); - } - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-list-sys-config json", $output, $return_var); - $sys = json_decode(implode('', $output), true); - unset($output); + list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"] . ":"); + if ($_POST['v_host'] != 'localhost' ) $http_host = $_POST['v_host']; + if ($_POST['v_type'] == 'mysql') $db_admin = "phpMyAdmin"; + if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpmyadmin/"; + if (($_POST['v_type'] == 'mysql') && (!empty($sys['config']['DB_PMA_URL']))) $db_admin_link = $sys['config']['DB_PMA_URL']; + if ($_POST['v_type'] == 'pgsql') $db_admin = "phpPgAdmin"; + if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phppgadmin/"; + if (($_POST['v_type'] == 'pgsql') && (!empty($sys['config']['DB_PGA_URL']))) $db_admin_link = $sys['config']['DB_PGA_URL']; + } - list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"] . ":"); - if ($_POST['v_host'] != 'localhost' ) $http_host = $_POST['v_host']; - if ($_POST['v_type'] == 'mysql') $db_admin = "phpMyAdmin"; - if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpmyadmin/"; - if (($_POST['v_type'] == 'mysql') && (!empty($sys['config']['DB_PMA_URL']))) $db_admin_link = $sys['config']['DB_PMA_URL']; - if ($_POST['v_type'] == 'pgsql') $db_admin = "phpPgAdmin"; - if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phppgadmin/"; - if (($_POST['v_type'] == 'pgsql') && (!empty($sys['config']['DB_PGA_URL']))) $db_admin_link = $sys['config']['DB_PGA_URL']; + // Email login credentials + if ((!empty($v_db_email)) && (empty($_SESSION['error_msg']))) { + $to = $v_db_email; + $subject = __("Database Credentials"); + $hostname = exec('hostname'); + $from = __('MAIL_FROM',$hostname); + $mailtext = __('DATABASE_READY',$user."_".$_POST['v_database'],$user."_".$_POST['v_dbuser'],$_POST['v_password'],$db_admin_link); + send_email($to, $subject, $mailtext, $from); + } - $_SESSION['ok_msg'] = __('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']); - $_SESSION['ok_msg'] .= " / " . __('open %s',$db_admin) . ""; - unset($v_database); - unset($v_dbuser); - unset($v_password); - unset($v_type); - unset($v_charset); - } + // Flush field values on success + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']); + $_SESSION['ok_msg'] .= " / " . __('open %s',$db_admin) . ""; + unset($v_database); + unset($v_dbuser); + unset($v_password); + unset($v_type); + unset($v_charset); } } +// Header +include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); + +// Panel +top_panel($user,$TAB); + +// Get user email +$v_db_email = $panel[$user]['CONTACT']; + +// List avaiable database types exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var); $db_types = json_decode(implode('', $output), true); unset($output); +// List available database servers $db_hosts = array(); foreach ($db_types as $db_type ) { exec (VESTA_CMD."v-list-database-hosts ".$db_type." 'json'", $output, $return_var); @@ -117,7 +123,10 @@ foreach ($db_types as $db_type ) { unset($output); } +// Display body include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html'); + +// Flush session messages unset($_SESSION['error_msg']); unset($_SESSION['ok_msg']); diff --git a/web/add/dns/index.php b/web/add/dns/index.php index 8f6ec6c8e..f5a1b8a68 100644 --- a/web/add/dns/index.php +++ b/web/add/dns/index.php @@ -4,31 +4,15 @@ error_reporting(NULL); ob_start(); session_start(); $TAB = 'DNS'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); -// Header -include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); - -// Panel -top_panel($user,$TAB); - +// Check POST request for dns domain if (!empty($_POST['ok'])) { - // Check input + + // Check empty fields if (empty($_POST['v_domain'])) $errors[] = __('domain'); if (empty($_POST['v_ip'])) $errors[] = __('ip'); - - // Protect input - $v_domain = preg_replace("/^www./i", "", $_POST['v_domain']); - $v_domain = escapeshellarg($v_domain); - $v_domain = strtolower($v_domain); - $v_ip = escapeshellarg($_POST['v_ip']); - - if (!empty($_POST['v_ns1'])) $v_ns1 = escapeshellarg($_POST['v_ns1']); - if (!empty($_POST['v_ns2'])) $v_ns2 = escapeshellarg($_POST['v_ns2']); - if (!empty($_POST['v_ns3'])) $v_ns3 = escapeshellarg($_POST['v_ns3']); - if (!empty($_POST['v_ns4'])) $v_ns4 = escapeshellarg($_POST['v_ns4']); - - // Check for errors if (!empty($errors[0])) { foreach ($errors as $i => $error) { if ( $i == 0 ) { @@ -38,49 +22,78 @@ if (!empty($_POST['ok'])) { } } $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg); - } else { - // Add DNS + } + + // Protect input + $v_domain = preg_replace("/^www./i", "", $_POST['v_domain']); + $v_domain = escapeshellarg($v_domain); + $v_domain = strtolower($v_domain); + $v_ip = escapeshellarg($_POST['v_ip']); + if (!empty($_POST['v_ns1'])) $v_ns1 = escapeshellarg($_POST['v_ns1']); + if (!empty($_POST['v_ns2'])) $v_ns2 = escapeshellarg($_POST['v_ns2']); + if (!empty($_POST['v_ns3'])) $v_ns3 = escapeshellarg($_POST['v_ns3']); + if (!empty($_POST['v_ns4'])) $v_ns4 = escapeshellarg($_POST['v_ns4']); + + // Add dns domain + if (empty($_SESSION['error_msg'])) { exec (VESTA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_ip." ".$v_ns1." ".$v_ns2." ".$v_ns3." ".$v_ns4." no", $output, $return_var); check_return_code($return_var,$output); unset($output); + } - // Change Expiriation date + // Set expiriation date + if (empty($_SESSION['error_msg'])) { if ((!empty($_POST['v_exp'])) && ($_POST['v_exp'] != date('Y-m-d', strtotime('+1 year')))) { $v_exp = escapeshellarg($_POST['v_exp']); exec (VESTA_CMD."v-change-dns-domain-exp ".$user." ".$v_domain." ".$v_exp." no", $output, $return_var); check_return_code($return_var,$output); unset($output); } + } - // Change TTL + // Set ttl + if (empty($_SESSION['error_msg'])) { if ((!empty($_POST['v_ttl'])) && ($_POST['v_ttl'] != '14400') && (empty($_SESSION['error_msg']))) { $v_ttl = escapeshellarg($_POST['v_ttl']); exec (VESTA_CMD."v-change-dns-domain-ttl ".$user." ".$v_domain." ".$v_ttl." no", $output, $return_var); check_return_code($return_var,$output); unset($output); } + } - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('DNS_DOMAIN_CREATED_OK',$_POST[v_domain],$_POST[v_domain]); - unset($v_domain); - } - - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-restart-dns", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } + // Restart dns server + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-restart-dns", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + // Flush field values on success + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('DNS_DOMAIN_CREATED_OK',$_POST[v_domain],$_POST[v_domain]); + unset($v_domain); } } -// DNS Record + +// Check POST request for dns record if (!empty($_POST['ok_rec'])) { - // Check input + + // Check empty fields if (empty($_POST['v_domain'])) $errors[] = 'domain'; if (empty($_POST['v_rec'])) $errors[] = 'record'; if (empty($_POST['v_type'])) $errors[] = 'type'; if (empty($_POST['v_val'])) $errors[] = 'value'; + 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); + } // Protect input $v_domain = escapeshellarg($_POST['v_domain']); @@ -89,34 +102,36 @@ if (!empty($_POST['ok_rec'])) { $v_val = escapeshellarg($_POST['v_val']); $v_priority = escapeshellarg($_POST['v_priority']); - // Check for errors - 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 { - // Add DNS Record + // Add dns record + if (empty($_SESSION['error_msg'])) { exec (VESTA_CMD."v-add-dns-record ".$user." ".$v_domain." ".$v_rec." ".$v_type." ".$v_val." ".$v_priority, $output, $return_var); - $v_type = $_POST['v_type']; check_return_code($return_var,$output); unset($output); - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('DNS_RECORD_CREATED_OK',$_POST[v_rec],$_POST[v_domain]); - unset($v_domain); - unset($v_rec); - unset($v_val); - unset($v_priority); - } + $v_type = $_POST['v_type']; + } + + // Flush field values on success + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('DNS_RECORD_CREATED_OK',$_POST[v_rec],$_POST[v_domain]); + unset($v_domain); + unset($v_rec); + unset($v_val); + unset($v_priority); } } -if ((empty($_GET['domain'])) && (empty($_POST['domain']))) { - if ((empty($v_ns1)) && (empty($v_ns2))) { + +// Header +include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); + +// Panel +top_panel($user,$TAB); + +// Display body for dns domain +if (empty($_GET['domain'])) { + if (empty($v_ttl)) $v_ttl = 14400; + if (empty($v_exp)) $v_exp = date('Y-m-d', strtotime('+1 year')); + if (empty($v_ns1)) { exec (VESTA_CMD."v-list-user-ns ".$user." json", $output, $return_var); $nameservers = json_decode(implode('', $output), true); $v_ns1 = $nameservers[0]; @@ -125,17 +140,18 @@ if ((empty($_GET['domain'])) && (empty($_POST['domain']))) { $v_ns4 = $nameservers[3]; unset($output); } - if (empty($v_ttl)) $v_ttl = 14400; - if (empty($v_exp)) $v_exp = date('Y-m-d', strtotime('+1 year')); include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} else { +} + +// Display body for dns record +if (!empty($_GET['domain'])) { $v_domain = $_GET['domain']; include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns_rec.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); } +// Flush session messages +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); + // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/add/ip/index.php b/web/add/ip/index.php index 23eeb2434..dfb595ca1 100644 --- a/web/add/ip/index.php +++ b/web/add/ip/index.php @@ -4,80 +4,93 @@ error_reporting(NULL); ob_start(); session_start(); $TAB = 'IP'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); +// Check user +if ($_SESSION['user'] != 'admin') { + header("Location: /list/user"); + exit; +} + +// Check POST request +if (!empty($_POST['ok'])) { + + // Check empty fields + if (empty($_POST['v_ip'])) $errors[] = __('ip address'); + if (empty($_POST['v_netmask'])) $errors[] = __('netmask'); + if (empty($_POST['v_interface'])) $errors[] = __('interface'); + if (empty($_POST['v_owner'])) $errors[] = __('assigned user'); + 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); + } + + // Protect input + $v_ip = escapeshellarg($_POST['v_ip']); + $v_netmask = escapeshellarg($_POST['v_netmask']); + $v_name = escapeshellarg($_POST['v_name']); + $v_nat = escapeshellarg($_POST['v_nat']); + $v_interface = escapeshellarg($_POST['v_interface']); + $v_owner = escapeshellarg($_POST['v_owner']); + $v_shared = $_POST['v_shared']; + + // Check shared checkmark + if ($v_shared == 'on') { + $ip_status = 'shared'; + } else { + $ip_status = 'dedicated'; + $v_dedicated = 'yes'; + + } + + // Add IP + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-sys-ip ".$v_ip." ".$v_netmask." ".$v_interface." ".$v_owner." '".$ip_status."' ".$v_name." ".$v_nat, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + $v_owner = $_POST['v_owner']; + $v_interface = $_POST['v_interface']; + } + + // Flush field values on success + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('IP_CREATED_OK',$_POST['v_ip'],$_POST['v_ip']); + unset($v_ip); + unset($v_netmask); + unset($v_name); + unset($v_nat); + } +} + // Header include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); // Panel top_panel($user,$TAB); -// Are you admin? -if ($_SESSION['user'] == 'admin') { - if (!empty($_POST['ok'])) { - // Check input - if (empty($_POST['v_ip'])) $errors[] = __('ip address'); - if (empty($_POST['v_netmask'])) $errors[] = __('netmask'); - if (empty($_POST['v_interface'])) $errors[] = __('interface'); - if (empty($_POST['v_owner'])) $errors[] = __('assigned user'); +// List network interfaces +exec (VESTA_CMD."v-list-sys-interfaces 'json'", $output, $return_var); +$interfaces = json_decode(implode('', $output), true); +unset($output); - // Protect input - $v_ip = escapeshellarg($_POST['v_ip']); - $v_netmask = escapeshellarg($_POST['v_netmask']); - $v_name = escapeshellarg($_POST['v_name']); - $v_nat = escapeshellarg($_POST['v_nat']); +// List users +exec (VESTA_CMD."v-list-sys-users 'json'", $output, $return_var); +$users = json_decode(implode('', $output), true); +unset($output); - $v_interface = $_POST['v_interface']; - $v_shared = $_POST['v_shared']; - if ($v_shared == 'on') { - $ip_status = 'shared'; - } else { - $ip_status = 'dedicated'; - $v_dedicated = 'yes'; - } +// Display body +include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_ip.html'); - $v_owner = $_POST['v_owner']; - - // Check for errors - 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 { - // Add IP - $v_interface = escapeshellarg($_POST['v_interface']); - $v_owner = $_POST['v_owner']; - exec (VESTA_CMD."v-add-sys-ip ".$v_ip." ".$v_netmask." ".$v_interface." ".$v_owner." '".$ip_status."' ".$v_name." ".$v_nat, $output, $return_var); - $v_owner = $_POST['v_owner']; - $v_interface = $_POST['v_interface']; - check_return_code($return_var,$output); - unset($output); - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('IP_CREATED_OK',$_POST['v_ip'],$_POST['v_ip']); - unset($v_ip); - unset($v_netmask); - unset($v_name); - unset($v_nat); - } - } - } - exec (VESTA_CMD."v-list-sys-interfaces 'json'", $output, $return_var); - $interfaces = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-sys-users 'json'", $output, $return_var); - $users = json_decode(implode('', $output), true); - unset($output); - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_ip.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} +// Flush session messages +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/add/mail/index.php b/web/add/mail/index.php index 492d16739..41c0714d9 100644 --- a/web/add/mail/index.php +++ b/web/add/mail/index.php @@ -4,41 +4,15 @@ error_reporting(NULL); ob_start(); session_start(); $TAB = 'MAIL'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); -// Header -include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); -// Panel -top_panel($user,$TAB); - -// Mail Domain +// Check POST request for mail domain if (!empty($_POST['ok'])) { + + // Check empty fields if (empty($_POST['v_domain'])) $errors[] = __('domain'); - if (!empty($_POST['v_antispam'])) { - $v_antispam = 'yes'; - } else { - $v_antispam = 'no'; - } - - if (!empty($_POST['v_antivirus'])) { - $v_antivirus = 'yes'; - } else { - $v_antivirus = 'no'; - } - - if (!empty($_POST['v_dkim'])) { - $v_dkim = 'yes'; - } else { - $v_dkim = 'no'; - } - - // Protect input - $v_domain = preg_replace("/^www./i", "", $_POST['v_domain']); - $v_domain = escapeshellarg($v_domain); - $v_domain = strtolower($v_domain); - - // Check for errors if (!empty($errors[0])) { foreach ($errors as $i => $error) { if ( $i == 0 ) { @@ -48,27 +22,66 @@ if (!empty($_POST['ok'])) { } } $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg); - } else { + } - // Add mail domain + // Check antispam option + if (!empty($_POST['v_antispam'])) { + $v_antispam = 'yes'; + } else { + $v_antispam = 'no'; + } + + // Check antivirus option + if (!empty($_POST['v_antivirus'])) { + $v_antivirus = 'yes'; + } else { + $v_antivirus = 'no'; + } + + // Check dkim option + if (!empty($_POST['v_dkim'])) { + $v_dkim = 'yes'; + } else { + $v_dkim = 'no'; + } + + // Set domain name to lowercase and remove www prefix + $v_domain = preg_replace("/^www./i", "", $_POST['v_domain']); + $v_domain = escapeshellarg($v_domain); + $v_domain = strtolower($v_domain); + + // Add mail domain + if (empty($_SESSION['error_msg'])) { exec (VESTA_CMD."v-add-mail-domain ".$user." ".$v_domain." ".$v_antispam." ".$v_antivirus." ".$v_dkim, $output, $return_var); check_return_code($return_var,$output); unset($output); + } - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('MAIL_DOMAIN_CREATED_OK',$_POST['v_domain'],$_POST['v_domain']); - unset($v_domain); - } + // Flush field values on success + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('MAIL_DOMAIN_CREATED_OK',$_POST['v_domain'],$_POST['v_domain']); + unset($v_domain); } } -// Mail Account +// Check POST request for mail account if (!empty($_POST['ok_acc'])) { - // Check input + + // Check empty fields if (empty($_POST['v_domain'])) $errors[] = __('domain'); if (empty($_POST['v_account'])) $errors[] = __('account'); if (empty($_POST['v_password'])) $errors[] = __('password'); + 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); + } // Protect input $v_domain = escapeshellarg($_POST['v_domain']); @@ -78,99 +91,100 @@ if (!empty($_POST['ok_acc'])) { $v_quota = escapeshellarg($_POST['v_quota']); $v_aliases = $_POST['v_aliases']; $v_fwd = $_POST['v_fwd']; - if (empty($_POST['v_quota'])) $v_quota = 0; if ((!empty($_POST['v_quota'])) || (!empty($_POST['v_aliases'])) || (!empty($_POST['v_fwd'])) ) $v_adv = 'yes'; - // Check for errors - 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 { - // Add Mail Account + // Add Mail Account + if (empty($_SESSION['error_msg'])) { exec (VESTA_CMD."v-add-mail-account ".$user." ".$v_domain." ".$v_account." ".$v_password." ".$v_quota, $output, $return_var); check_return_code($return_var,$output); unset($output); + } - // Add Aliases - if ((!empty($_POST['v_aliases'])) && (empty($_SESSION['error_msg']))) { - $valiases = preg_replace("/\n/", " ", $_POST['v_aliases']); - $valiases = preg_replace("/,/", " ", $valiases); - $valiases = preg_replace('/\s+/', ' ',$valiases); - $valiases = trim($valiases); - $aliases = explode(" ", $valiases); - foreach ($aliases as $alias) { - $alias = escapeshellarg($alias); - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-mail-account-alias ".$user." ".$v_domain." ".$v_account." ".$alias, $output, $return_var); - check_return_code($return_var,$output); - } - unset($output); - } - } - - // Add Forwads - if ((!empty($_POST['v_fwd'])) && (empty($_SESSION['error_msg']))) { - $vfwd = preg_replace("/\n/", " ", $_POST['v_fwd']); - $vfwd = preg_replace("/,/", " ", $vfwd); - $vfwd = preg_replace('/\s+/', ' ',$vfwd); - $vfwd = trim($vfwd); - $fwd = explode(" ", $vfwd); - foreach ($fwd as $forward) { - $forward = escapeshellarg($forward); - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-mail-account-forward ".$user." ".$v_domain." ".$v_account." ".$forward, $output, $return_var); - check_return_code($return_var,$output); - } - unset($output); - } - // Add fwd_only flag - if ((!empty($_POST['v_fwd_only'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-mail-account-fwd-only ".$user." ".$v_domain." ".$v_account, $output, $return_var); + // Add Aliases + if ((!empty($_POST['v_aliases'])) && (empty($_SESSION['error_msg']))) { + $valiases = preg_replace("/\n/", " ", $_POST['v_aliases']); + $valiases = preg_replace("/,/", " ", $valiases); + $valiases = preg_replace('/\s+/', ' ',$valiases); + $valiases = trim($valiases); + $aliases = explode(" ", $valiases); + foreach ($aliases as $alias) { + $alias = escapeshellarg($alias); + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-mail-account-alias ".$user." ".$v_domain." ".$v_account." ".$alias, $output, $return_var); check_return_code($return_var,$output); unset($output); } } + } - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-list-sys-config json", $output, $return_var); - $sys = json_decode(implode('', $output), true); - unset($output); - - list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"].":"); - $webmail = "http://".$http_host."/webmail/"; - if (!empty($sys['config']['MAIL_URL'])) $webmail = $sys['config']['MAIL_URL']; - - $_SESSION['ok_msg'] = __('MAIL_ACCOUNT_CREATED_OK',strtolower($_POST['v_account']),$_POST[v_domain],strtolower($_POST['v_account']),$_POST[v_domain]); - $_SESSION['ok_msg'] .= " / " . __('open webmail') . ""; - unset($v_account); - unset($v_password); - unset($v_password); - unset($v_aliases); - unset($v_fwd); - unset($v_quota); + // Add Forwarders + if ((!empty($_POST['v_fwd'])) && (empty($_SESSION['error_msg']))) { + $vfwd = preg_replace("/\n/", " ", $_POST['v_fwd']); + $vfwd = preg_replace("/,/", " ", $vfwd); + $vfwd = preg_replace('/\s+/', ' ',$vfwd); + $vfwd = trim($vfwd); + $fwd = explode(" ", $vfwd); + foreach ($fwd as $forward) { + $forward = escapeshellarg($forward); + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-mail-account-forward ".$user." ".$v_domain." ".$v_account." ".$forward, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } } } + + // Add fwd_only flag + if ((!empty($_POST['v_fwd_only'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-mail-account-fwd-only ".$user." ".$v_domain." ".$v_account, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Get webmail url + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-list-sys-config json", $output, $return_var); + $sys = json_decode(implode('', $output), true); + unset($output); + list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"].":"); + $webmail = "http://".$http_host."/webmail/"; + if (!empty($sys['config']['MAIL_URL'])) $webmail = $sys['config']['MAIL_URL']; + } + + // Flush field values on success + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('MAIL_ACCOUNT_CREATED_OK',strtolower($_POST['v_account']),$_POST[v_domain],strtolower($_POST['v_account']),$_POST[v_domain]); + $_SESSION['ok_msg'] .= " / " . __('open webmail') . ""; + unset($v_account); + unset($v_password); + unset($v_password); + unset($v_aliases); + unset($v_fwd); + unset($v_quota); + } } +// Header +include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); -if ((empty($_GET['domain'])) && (empty($_POST['domain']))) { - $v_domain = (isset($_GET['domain'])?$_GET['domain']:''); +// Panel +top_panel($user,$TAB); + +// Display body for mail domain +if (empty($_GET['domain'])) { include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_mail.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} else { +} + +// Display body for mail account +if (!empty($_GET['domain'])) { $v_domain = $_GET['domain']; include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_mail_acc.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); } +// Flush session messages +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); + // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/add/package/index.php b/web/add/package/index.php index 594d3529d..7feb8218b 100644 --- a/web/add/package/index.php +++ b/web/add/package/index.php @@ -4,175 +4,181 @@ error_reporting(NULL); ob_start(); session_start(); $TAB = 'PACKAGE'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); -if (empty($_SESSION['user'])) { - header("Location: /login/"); +// Check user +if ($_SESSION['user'] != 'admin') { + header("Location: /list/user"); + exit; } +// Check POST request +if (!empty($_POST['ok'])) { + + // Check empty fields + if (empty($_POST['v_package'])) $errors[] = __('package'); + 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'); + if (!isset($_POST['v_dns_domains'])) $errors[] = __('dns domains'); + if (!isset($_POST['v_dns_records'])) $errors[] = __('dns records'); + if (!isset($_POST['v_mail_domains'])) $errors[] = __('mail domains'); + if (!isset($_POST['v_mail_accounts'])) $errors[] = __('mail accounts'); + if (!isset($_POST['v_databases'])) $errors[] = __('databases'); + if (!isset($_POST['v_cron_jobs'])) $errors[] = __('cron jobs'); + if (!isset($_POST['v_backups'])) $errors[] = __('backups'); + if (!isset($_POST['v_disk_quota'])) $errors[] = __('quota'); + if (!isset($_POST['v_bandwidth'])) $errors[] = __('bandwidth'); + if (empty($_POST['v_ns1'])) $errors[] = __('ns1'); + if (empty($_POST['v_ns2'])) $errors[] = __('ns2'); + 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); + } + + // Protect input + $v_package = escapeshellarg($_POST['v_package']); + $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']); + $v_dns_domains = escapeshellarg($_POST['v_dns_domains']); + $v_dns_records = escapeshellarg($_POST['v_dns_records']); + $v_mail_domains = escapeshellarg($_POST['v_mail_domains']); + $v_mail_accounts = escapeshellarg($_POST['v_mail_accounts']); + $v_databases = escapeshellarg($_POST['v_databases']); + $v_cron_jobs = escapeshellarg($_POST['v_cron_jobs']); + $v_backups = escapeshellarg($_POST['v_backups']); + $v_disk_quota = escapeshellarg($_POST['v_disk_quota']); + $v_bandwidth = escapeshellarg($_POST['v_bandwidth']); + $v_ns1 = trim($_POST['v_ns1'], '.'); + $v_ns2 = trim($_POST['v_ns2'], '.'); + $v_ns3 = trim($_POST['v_ns3'], '.'); + $v_ns4 = trim($_POST['v_ns4'], '.'); + $v_ns = $v_ns1.",".$v_ns2; + if (!empty($v_ns3)) $v_ns .= ",".$v_ns3; + if (!empty($v_ns4)) $v_ns .= ",".$v_ns4; + $v_ns = escapeshellarg($v_ns); + $v_time = escapeshellarg(date('H:i:s')); + $v_date = escapeshellarg(date('Y-m-d')); + + // Create temporary dir + if (empty($_SESSION['error_msg'])) { + exec ('mktemp -d', $output, $return_var); + $tmpdir = $output[0]; + check_return_code($return_var,$output); + unset($output); + } + + // Create package file + if (empty($_SESSION['error_msg'])) { + $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"; + $pkg .= "DNS_RECORDS=".$v_dns_records."\n"; + $pkg .= "MAIL_DOMAINS=".$v_mail_domains."\n"; + $pkg .= "MAIL_ACCOUNTS=".$v_mail_accounts."\n"; + $pkg .= "DATABASES=".$v_databases."\n"; + $pkg .= "CRON_JOBS=".$v_cron_jobs."\n"; + $pkg .= "DISK_QUOTA=".$v_disk_quota."\n"; + $pkg .= "BANDWIDTH=".$v_bandwidth."\n"; + $pkg .= "NS=".$v_ns."\n"; + $pkg .= "SHELL=".$v_shell."\n"; + $pkg .= "BACKUPS=".$v_backups."\n"; + $pkg .= "TIME=".$v_time."\n"; + $pkg .= "DATE=".$v_date."\n"; + + $fp = fopen($tmpdir."/".$_POST['v_package'].".pkg", 'w'); + fwrite($fp, $pkg); + fclose($fp); + } + + // Add new package + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-user-package ".$tmpdir." ".$v_package, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Remove tmpdir + exec ('rm -rf '.$tmpdir, $output, $return_var); + unset($output); + + // Flush field values on success + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('PACKAGE_CREATED_OK',$_POST['v_package'],$_POST['v_package']); + unset($v_package); + } + +} + + // Header include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); // Panel top_panel($user,$TAB); -// Are you admin? -if ($_SESSION['user'] == 'admin') { - if (!empty($_POST['ok'])) { - // Check input - if (empty($_POST['v_package'])) $errors[] = __('package'); - 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'); - if (!isset($_POST['v_dns_domains'])) $errors[] = __('dns domains'); - if (!isset($_POST['v_dns_records'])) $errors[] = __('dns records'); - if (!isset($_POST['v_mail_domains'])) $errors[] = __('mail domains'); - if (!isset($_POST['v_mail_accounts'])) $errors[] = __('mail accounts'); - if (!isset($_POST['v_databases'])) $errors[] = __('databases'); - if (!isset($_POST['v_cron_jobs'])) $errors[] = __('cron jobs'); - if (!isset($_POST['v_backups'])) $errors[] = __('backups'); - if (!isset($_POST['v_disk_quota'])) $errors[] = __('quota'); - if (!isset($_POST['v_bandwidth'])) $errors[] = __('bandwidth'); - if (empty($_POST['v_ns1'])) $errors[] = __('ns1'); - if (empty($_POST['v_ns2'])) $errors[] = __('ns2'); +// List web temmplates +exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); +$web_templates = json_decode(implode('', $output), true); +unset($output); +// List web templates for proxy +exec (VESTA_CMD."v-list-web-templates-proxy json", $output, $return_var); +$proxy_templates = json_decode(implode('', $output), true); +unset($output); - // Protect input - $v_package = escapeshellarg($_POST['v_package']); - $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']); - $v_dns_domains = escapeshellarg($_POST['v_dns_domains']); - $v_dns_records = escapeshellarg($_POST['v_dns_records']); - $v_mail_domains = escapeshellarg($_POST['v_mail_domains']); - $v_mail_accounts = escapeshellarg($_POST['v_mail_accounts']); - $v_databases = escapeshellarg($_POST['v_databases']); - $v_cron_jobs = escapeshellarg($_POST['v_cron_jobs']); - $v_backups = escapeshellarg($_POST['v_backups']); - $v_disk_quota = escapeshellarg($_POST['v_disk_quota']); - $v_bandwidth = escapeshellarg($_POST['v_bandwidth']); - $v_ns1 = trim($_POST['v_ns1'], '.'); - $v_ns2 = trim($_POST['v_ns2'], '.'); - $v_ns3 = trim($_POST['v_ns3'], '.'); - $v_ns4 = trim($_POST['v_ns4'], '.'); - $v_ns = $v_ns1.",".$v_ns2; - if (!empty($v_ns3)) $v_ns .= ",".$v_ns3; - if (!empty($v_ns4)) $v_ns .= ",".$v_ns4; - $v_ns = escapeshellarg($v_ns); - $v_time = escapeshellarg(date('H:i:s')); - $v_date = escapeshellarg(date('Y-m-d')); +// List DNS templates +exec (VESTA_CMD."v-list-dns-templates json", $output, $return_var); +$dns_templates = json_decode(implode('', $output), true); +unset($output); - // Check for errors - 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', $output, $return_var); - $tmpdir = $output[0]; - unset($output); +// List system shells +exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var); +$shells = json_decode(implode('', $output), true); +unset($output); - // Create package - $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"; - $pkg .= "DNS_RECORDS=".$v_dns_records."\n"; - $pkg .= "MAIL_DOMAINS=".$v_mail_domains."\n"; - $pkg .= "MAIL_ACCOUNTS=".$v_mail_accounts."\n"; - $pkg .= "DATABASES=".$v_databases."\n"; - $pkg .= "CRON_JOBS=".$v_cron_jobs."\n"; - $pkg .= "DISK_QUOTA=".$v_disk_quota."\n"; - $pkg .= "BANDWIDTH=".$v_bandwidth."\n"; - $pkg .= "NS=".$v_ns."\n"; - $pkg .= "SHELL=".$v_shell."\n"; - $pkg .= "BACKUPS=".$v_backups."\n"; - $pkg .= "TIME=".$v_time."\n"; - $pkg .= "DATE=".$v_date."\n"; +// Set default values +if (empty($v_web_template)) $v_web_template = 'default'; +if (empty($v_proxy_template)) $v_proxy_template = 'default'; +if (empty($v_dns_template)) $v_dns_template = 'default'; +if (empty($v_shell)) $v_shell = 'nologin'; +if (empty($v_web_domains)) $v_web_domains = "'0'"; +if (empty($v_web_aliases)) $v_web_aliases = "'0'"; +if (empty($v_dns_domains)) $v_dns_domains = "'0'"; +if (empty($v_dns_records)) $v_dns_records = "'0'"; +if (empty($v_mail_domains)) $v_mail_domains = "'0'"; +if (empty($v_mail_accounts)) $v_mail_accounts = "'0'"; +if (empty($v_databases)) $v_databases = "'0'"; +if (empty($v_cron_jobs)) $v_cron_jobs = "'0'"; +if (empty($v_backups)) $v_backups = "'0'"; +if (empty($v_disk_quota)) $v_disk_quota = "'0'"; +if (empty($v_bandwidth)) $v_bandwidth = "'0'"; +if (empty($v_ns1)) $v_ns1 = 'ns1.example.ltd'; +if (empty($v_ns2)) $v_ns2 = 'ns2.example.ltd'; - // Write package - $fp = fopen($tmpdir."/".$_POST['v_package'].".pkg", 'w'); - fwrite($fp, $pkg); - fclose($fp); +// Display body +include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_package.html'); - // Add new package - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-user-package ".$tmpdir." ".$v_package, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - // Remove tmpdir - exec ('rm -rf '.$tmpdir, $output, $return_var); - unset($output); - - // Check output - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('PACKAGE_CREATED_OK',$_POST['v_package'],$_POST['v_package']); - unset($v_package); - } - - } - } - - - exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); - check_error($return_var); - $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); - check_error($return_var); - $shells = json_decode(implode('', $output), true); - unset($output); - - // Set default values - if (empty($v_web_template)) $v_web_template = 'default'; - if (empty($v_proxy_template)) $v_proxy_template = 'default'; - if (empty($v_dns_template)) $v_dns_template = 'default'; - if (empty($v_shell)) $v_shell = 'nologin'; - if (empty($v_web_domains)) $v_web_domains = "'0'"; - if (empty($v_web_aliases)) $v_web_aliases = "'0'"; - if (empty($v_dns_domains)) $v_dns_domains = "'0'"; - if (empty($v_dns_records)) $v_dns_records = "'0'"; - if (empty($v_mail_domains)) $v_mail_domains = "'0'"; - if (empty($v_mail_accounts)) $v_mail_accounts = "'0'"; - if (empty($v_databases)) $v_databases = "'0'"; - if (empty($v_cron_jobs)) $v_cron_jobs = "'0'"; - if (empty($v_backups)) $v_backups = "'0'"; - if (empty($v_disk_quota)) $v_disk_quota = "'0'"; - if (empty($v_bandwidth)) $v_bandwidth = "'0'"; - if (empty($v_ns1)) $v_ns1 = 'ns1.example.ltd'; - if (empty($v_ns2)) $v_ns2 = 'ns2.example.ltd'; - - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_package.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} +// Flush session messages +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/add/user/index.php b/web/add/user/index.php index 59e9181ea..3324c0464 100644 --- a/web/add/user/index.php +++ b/web/add/user/index.php @@ -1,110 +1,128 @@ $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg); + } + + // Validate email + if ((empty($_SESSION['error_msg'])) && (!filter_var($_POST['v_email'], FILTER_VALIDATE_EMAIL))) { + $_SESSION['error_msg'] = __('Please enter valid email address.'); + } + + // Check password length + if (empty($_SESSION['error_msg'])) { + $pw_len = strlen($_POST['v_password']); + if ($pw_len < 6 ) $_SESSION['error_msg'] = __('Password is too short.',$error_msg); + } + + // Protect input + $v_username = escapeshellarg($_POST['v_username']); + $v_password = escapeshellarg($_POST['v_password']); + $v_email = escapeshellarg($_POST['v_email']); + $v_package = escapeshellarg($_POST['v_package']); + $v_language = escapeshellarg($_POST['v_language']); + $v_fname = escapeshellarg($_POST['v_fname']); + $v_lname = escapeshellarg($_POST['v_lname']); + $v_notify = $_POST['v_notify']; + + + // Add user + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-user ".$v_username." ".$v_password." ".$v_email." ".$v_package." ".$v_fname." ".$v_lname, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Set language + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-change-user-language ".$v_username." ".$v_language, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Send email to the new user + if ((empty($_SESSION['error_msg'])) && (!empty($v_notify))) { + $to = $_POST['v_notify']; + $subject = _translate($_POST['v_language'],"Welcome to Vesta Control Panel"); + $hostname = exec('hostname'); + unset($output); + $from = _translate($_POST['v_language'],'MAIL_FROM',$hostname); + if (!empty($_POST['v_fname'])) { + $mailtext = _translate($_POST['v_language'],'GREETINGS_GORDON_FREEMAN',$_POST['v_fname'],$_POST['v_lname']); + } else { + $mailtext = _translate($_POST['v_language'],'GREETINGS'); + } + $mailtext .= _translate($_POST['v_language'],'ACCOUNT_READY',$_SERVER['HTTP_HOST'],$_POST['v_username'],$_POST['v_password']); + send_email($to, $subject, $mailtext, $from); + } + + // Flush field values on success + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('USER_CREATED_OK',$_POST['v_username'],$_POST['v_username']); + $_SESSION['ok_msg'] .= " / " . __('login as') ." ".$_POST['v_username']. ""; + unset($v_username); + unset($v_password); + unset($v_email); + unset($v_fname); + unset($v_lname); + unset($v_notify); + } +} + + // Header include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); // Panel top_panel($user,$TAB); -// Are you admin? -if ($_SESSION['user'] == 'admin') { - if (!empty($_POST['ok'])) { - // Check input - if (empty($_POST['v_username'])) $errors[] = __('user'); - if (empty($_POST['v_password'])) $errors[] = __('password'); - if (empty($_POST['v_package'])) $errrors[] = __('package'); - if (empty($_POST['v_email'])) $errors[] = __('email'); - if (empty($_POST['v_fname'])) $errors[] = __('first name'); - if (empty($_POST['v_lname'])) $errors[] = __('last name'); +// List hosting packages +exec (VESTA_CMD."v-list-user-packages json", $output, $return_var); +check_error($return_var); +$data = json_decode(implode('', $output), true); +unset($output); - // Protect input - $v_username = escapeshellarg($_POST['v_username']); - $v_password = escapeshellarg($_POST['v_password']); - $v_email = escapeshellarg($_POST['v_email']); - $v_package = escapeshellarg($_POST['v_package']); - $v_language = escapeshellarg($_POST['v_language']); - $v_fname = escapeshellarg($_POST['v_fname']); - $v_lname = escapeshellarg($_POST['v_lname']); - $v_notify = $_POST['v_notify']; +// List languages +exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var); +$languages = json_decode(implode('', $output), true); +unset($output); - // Validate email - if (!filter_var($_POST['v_email'], FILTER_VALIDATE_EMAIL)) { - $_SESSION['error_msg'] = __('Please enter valid email address.'); - } +// Display body +include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_user.html'); - // Check for errors - 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); - } - - // Check password length - if (empty($_SESSION['error_msg'])) { - $pw_len = strlen($_POST['v_password']); - if ($pw_len < 6 ) $_SESSION['error_msg'] = __('Password is too short.',$error_msg); - } - - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-user ".$v_username." ".$v_password." ".$v_email." ".$v_package." ".$v_fname." ".$v_lname, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-change-user-language ".$v_username." ".$v_language, $output, $return_var); - if (!empty($v_notify)) { - $to = $_POST['v_notify']; - $subject = _translate($_POST['v_language'],"Welcome to Vesta Control Panel"); - $hostname = exec('hostname'); - $from = _translate($_POST['v_language'],'MAIL_FROM',$hostname); - if (!empty($_POST['v_fname'])) { - $mailtext = _translate($_POST['v_language'],'GREETINGS_GORDON_FREEMAN',$_POST['v_fname'],$_POST['v_lname']); - } else { - $mailtext = _translate($_POST['v_language'],'GREETINGS'); - } - $mailtext .= _translate($_POST['v_language'],'ACCOUNT_READY',$_SERVER['HTTP_HOST'],$_POST['v_username'],$_POST['v_password']); - send_email($to, $subject, $mailtext, $from); - } - - $_SESSION['ok_msg'] = __('USER_CREATED_OK',$_POST[v_username],$_POST[v_username]); - $_SESSION['ok_msg'] .= " / " . __('login as') ." ".$_POST[v_username]. ""; - unset($v_username); - unset($v_password); - unset($v_email); - unset($v_fname); - unset($v_lname); - unset($v_notify); - } - unset($output); - } - } - - exec (VESTA_CMD."v-list-user-packages json", $output, $return_var); - check_error($return_var); - $data = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var); - $languages = json_decode(implode('', $output), true); - unset($output); - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_user.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} +// Flush session messages +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/backup/exclusions/index.php b/web/edit/backup/exclusions/index.php index a9c09929e..3f0e81130 100644 --- a/web/edit/backup/exclusions/index.php +++ b/web/edit/backup/exclusions/index.php @@ -3,116 +3,129 @@ error_reporting(NULL); ob_start(); session_start(); - $TAB = 'BACKUP EXCLUSIONS'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); +// Edit as someone else? +if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) { + $user=escapeshellarg($_GET['user']); +} + +// List backup exclustions +exec (VESTA_CMD."v-list-user-backup-exclusions ".$user." 'json'", $output, $return_var); +check_return_code($return_var,$output); +$data = json_decode(implode('', $output), true); +unset($output); + +// Parse web +$v_username = $user; +foreach ($data['WEB'] as $key => $value) { + if (!empty($value)){ + $v_web .= $key . ":" . $value. "\n"; + } else { + $v_web .= $key . "\n"; + } +} + +// Parse dns +foreach ($data['DNS'] as $key => $value) { + if (!empty($value)){ + $v_dns .= $key . ":" . $value. "\n"; + } else { + $v_dns .= $key . "\n"; + } +} + +// Parse mail +foreach ($data['MAIL'] as $key => $value) { + if (!empty($value)){ + $v_mail .= $key . ":" . $value. "\n"; + } else { + $v_mail .= $key . "\n"; + } +} + +// Parse databases +foreach ($data['DB'] as $key => $value) { + if (!empty($value)){ + $v_db .= $key . ":" . $value. "\n"; + } else { + $v_db .= $key . "\n"; + } +} + +// Parse user directories +foreach ($data['USER'] as $key => $value) { + if (!empty($value)){ + $v_userdir .= $key . ":" . $value. "\n"; + } else { + $v_userdir .= $key . "\n"; + } +} + +// Check POST request +if (!empty($_POST['save'])) { + $v_web = $_POST['v_web']; + $v_web_tmp = str_replace("\r\n", ",", $_POST['v_web']); + $v_web_tmp = rtrim($v_web_tmp, ","); + $v_web_tmp = "WEB=" . escapeshellarg($v_web_tmp); + + $v_dns = $_POST['v_dns']; + $v_dns_tmp = str_replace("\r\n", ",", $_POST['v_dns']); + $v_dns_tmp = rtrim($v_dns_tmp, ","); + $v_dns_tmp = "DNS=" . escapeshellarg($v_dns_tmp); + + $v_mail = $_POST['v_mail']; + $v_mail_tmp = str_replace("\r\n", ",", $_POST['v_mail']); + $v_mail_tmp = rtrim($v_mail_tmp, ","); + $v_mail_tmp = "MAIL=" . escapeshellarg($v_mail_tmp); + + $v_db = $_POST['v_db']; + $v_db_tmp = str_replace("\r\n", ",", $_POST['v_db']); + $v_db_tmp = rtrim($v_db_tmp, ","); + $v_db_tmp = "DB=" . escapeshellarg($v_db_tmp); + + $v_cron = $_POST['v_cron']; + $v_cron_tmp = str_replace("\r\n", ",", $_POST['v_cron']); + $v_cron_tmp = rtrim($v_cron_tmp, ","); + $v_cron_tmp = "CRON=" . escapeshellarg($v_cron_tmp); + + $v_userdir = $_POST['v_userdir']; + $v_userdir_tmp = str_replace("\r\n", ",", $_POST['v_userdir']); + $v_userdir_tmp = rtrim($v_userdir_tmp, ","); + $v_userdir_tmp = "USER=" . escapeshellarg($v_userdir_tmp); + + // Create temporary exeption list on a filesystem + exec ('mktemp', $mktemp_output, $return_var); + $tmp = $mktemp_output[0]; + $fp = fopen($tmp, 'w'); + fwrite($fp, $v_web_tmp . "\n" . $v_dns_tmp . "\n" . $v_mail_tmp . "\n" . $v_db_tmp . "\n" . $v_userdir_tmp . "\n"); + fclose($fp); + unset($mktemp_output); + + // Save changes + exec (VESTA_CMD."v-update-user-backup-exclusions ".$user." ".$tmp, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + + // Set success message + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __("Changes has been saved."); + } +} + + // Header include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); // Panel top_panel($user,$TAB); -// Edit as someone else? -if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) { - $user=escapeshellarg($_GET['user']); -} - -exec (VESTA_CMD."v-list-user-backup-exclusions ".$user." 'json'", $output, $return_var); -check_return_code($return_var,$output); -if (empty($_SESSION['error_msg'])) { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - - foreach ($data['WEB'] as $key => $value) { - if (!empty($value)){ - $v_web .= $key . ":" . $value. "\n"; - } else { - $v_web .= $key . "\n"; - } - } - - foreach ($data['DNS'] as $key => $value) { - if (!empty($value)){ - $v_dns .= $key . ":" . $value. "\n"; - } else { - $v_dns .= $key . "\n"; - } - } - - foreach ($data['MAIL'] as $key => $value) { - if (!empty($value)){ - $v_mail .= $key . ":" . $value. "\n"; - } else { - $v_mail .= $key . "\n"; - } - } - - foreach ($data['DB'] as $key => $value) { - if (!empty($value)){ - $v_db .= $key . ":" . $value. "\n"; - } else { - $v_db .= $key . "\n"; - } - } - - foreach ($data['USER'] as $key => $value) { - if (!empty($value)){ - $v_userdir .= $key . ":" . $value. "\n"; - } else { - $v_userdir .= $key . "\n"; - } - } - - - // Action - if (!empty($_POST['save'])) { - - $v_web = $_POST['v_web']; - $v_web_tmp = str_replace("\r\n", ",", $_POST['v_web']); - $v_web_tmp = rtrim($v_web_tmp, ","); - $v_web_tmp = "WEB=" . escapeshellarg($v_web_tmp); - - $v_dns = $_POST['v_dns']; - $v_dns_tmp = str_replace("\r\n", ",", $_POST['v_dns']); - $v_dns_tmp = rtrim($v_dns_tmp, ","); - $v_dns_tmp = "DNS=" . escapeshellarg($v_dns_tmp); - - $v_mail = $_POST['v_mail']; - $v_mail_tmp = str_replace("\r\n", ",", $_POST['v_mail']); - $v_mail_tmp = rtrim($v_mail_tmp, ","); - $v_mail_tmp = "MAIL=" . escapeshellarg($v_mail_tmp); - - $v_db = $_POST['v_db']; - $v_db_tmp = str_replace("\r\n", ",", $_POST['v_db']); - $v_db_tmp = rtrim($v_db_tmp, ","); - $v_db_tmp = "DB=" . escapeshellarg($v_db_tmp); - - $v_cron = $_POST['v_cron']; - $v_cron_tmp = str_replace("\r\n", ",", $_POST['v_cron']); - $v_cron_tmp = rtrim($v_cron_tmp, ","); - $v_cron_tmp = "CRON=" . escapeshellarg($v_cron_tmp); - - $v_userdir = $_POST['v_userdir']; - $v_userdir_tmp = str_replace("\r\n", ",", $_POST['v_userdir']); - $v_userdir_tmp = rtrim($v_userdir_tmp, ","); - $v_userdir_tmp = "USER=" . escapeshellarg($v_userdir_tmp); - - exec ('mktemp', $mktemp_output, $return_var); - $tmp = $mktemp_output[0]; - $fp = fopen($tmp, 'w'); - fwrite($fp, $v_web_tmp . "\n" . $v_dns_tmp . "\n" . $v_mail_tmp . "\n" . $v_db_tmp . "\n" . $v_userdir_tmp . "\n"); - fclose($fp); - exec (VESTA_CMD."v-update-user-backup-exclusions ".$user." ".$tmp, $output, $return_var); - check_return_code($return_var,$output); - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __("Changes has been saved."); - } - } -} - +// Display body include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_backup_exclusions.html'); + +// Flush session messages unset($_SESSION['error_msg']); unset($_SESSION['ok_msg']); diff --git a/web/edit/cron/index.php b/web/edit/cron/index.php index c5929b405..09d63cb5e 100644 --- a/web/edit/cron/index.php +++ b/web/edit/cron/index.php @@ -3,73 +3,79 @@ error_reporting(NULL); ob_start(); session_start(); - $TAB = 'CRON'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); +// Edit as someone else? +if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) { + $user=escapeshellarg($_GET['user']); +} + +// Check job id +if (empty($_GET['job'])) { + header("Location: /list/cron/"); + exit; +} + +// List cron job +$v_job = escapeshellarg($_GET['job']); +exec (VESTA_CMD."v-list-cron-job ".$user." ".$v_job." 'json'", $output, $return_var); +check_return_code($return_var,$output); +$data = json_decode(implode('', $output), true); +unset($output); + +// Parse cron job +$v_username = $user; +$v_job = $_GET['job']; +$v_min = $data[$v_job]['MIN']; +$v_hour = $data[$v_job]['HOUR']; +$v_day = $data[$v_job]['DAY']; +$v_month = $data[$v_job]['MONTH']; +$v_wday = $data[$v_job]['WDAY']; +$v_cmd = $data[$v_job]['CMD']; +$v_date = $data[$v_job]['DATE']; +$v_time = $data[$v_job]['TIME']; +$v_suspended = $data[$v_job]['SUSPENDED']; +if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; +} else { + $v_status = 'active'; +} + +// Check POST request +if (!empty($_POST['save'])) { + $v_username = $user; + $v_min = escapeshellarg($_POST['v_min']); + $v_hour = escapeshellarg($_POST['v_hour']); + $v_day = escapeshellarg($_POST['v_day']); + $v_month = escapeshellarg($_POST['v_month']); + $v_wday = escapeshellarg($_POST['v_wday']); + $v_cmd = escapeshellarg($_POST['v_cmd']); + + // Save changes + exec (VESTA_CMD."v-change-cron-job ".$v_username." ".$v_job." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + + $v_cmd = $_POST['v_cmd']; + + // Set success message + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __("Changes has been saved."); + } +} + // Header include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); // Panel top_panel($user,$TAB); -// Edit as someone else? -if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) { - $user=escapeshellarg($_GET['user']); -} - -// Check user argument? -if (empty($_GET['job'])) { - header("Location: /list/cron/"); - exit; -} - -$v_job = escapeshellarg($_GET['job']); -exec (VESTA_CMD."v-list-cron-job ".$user." ".$v_job." 'json'", $output, $return_var); -check_return_code($return_var,$output); -if (empty($_SESSION['error_msg'])) { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_job = $_GET['job']; - $v_min = $data[$v_job]['MIN']; - $v_hour = $data[$v_job]['HOUR']; - $v_day = $data[$v_job]['DAY']; - $v_month = $data[$v_job]['MONTH']; - $v_wday = $data[$v_job]['WDAY']; - $v_cmd = $data[$v_job]['CMD']; - $v_date = $data[$v_job]['DATE']; - $v_time = $data[$v_job]['TIME']; - $v_suspended = $data[$v_job]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - - // Action - if (!empty($_POST['save'])) { - $v_username = $user; - // Change job - if (($v_min != $_POST['v_min']) || ($v_hour != $_POST['v_hour']) || ($v_day != $_POST['v_day']) || ($v_month != $_POST['v_month']) || ($v_wday != $_POST['v_wday']) || ($v_cmd != $_POST['v_cmd']) &&(empty($_SESSION['error_msg']))) { - $v_min = escapeshellarg($_POST['v_min']); - $v_hour = escapeshellarg($_POST['v_hour']); - $v_day = escapeshellarg($_POST['v_day']); - $v_month = escapeshellarg($_POST['v_month']); - $v_wday = escapeshellarg($_POST['v_wday']); - $v_cmd = escapeshellarg($_POST['v_cmd']); - exec (VESTA_CMD."v-change-cron-job ".$v_username." ".$v_job." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $v_cmd = $_POST['v_cmd']; - } - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __("Changes has been saved."); - } - } -} - +// Display body include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_cron.html'); + +// Flush session messages unset($_SESSION['error_msg']); unset($_SESSION['ok_msg']); diff --git a/web/edit/db/index.php b/web/edit/db/index.php index 435bbb17f..c64e53046 100644 --- a/web/edit/db/index.php +++ b/web/edit/db/index.php @@ -3,8 +3,8 @@ error_reporting(NULL); ob_start(); session_start(); - $TAB = 'DB'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); // Header @@ -13,6 +13,7 @@ include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); // Panel top_panel($user,$TAB); +// Check database id if (empty($_GET['database'])) { header("Location: /list/db/"); exit; @@ -23,69 +24,63 @@ if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) { $user=escapeshellarg($_GET['user']); } +// List datbase $v_database = escapeshellarg($_GET['database']); exec (VESTA_CMD."v-list-database ".$user." ".$v_database." 'json'", $output, $return_var); check_return_code($return_var,$output); -if (empty($_SESSION['error_msg'])) { - $data = json_decode(implode('', $output), true); - unset($output); +$data = json_decode(implode('', $output), true); +unset($output); + +// Parse database +$v_username = $user; +$v_database = $_GET['database']; +$v_dbuser = $data[$v_database]['DBUSER']; +$v_password = "••••••••"; +$v_host = $data[$v_database]['HOST']; +$v_type = $data[$v_database]['TYPE']; +$v_charset = $data[$v_database]['CHARSET']; +$v_date = $data[$v_database]['DATE']; +$v_time = $data[$v_database]['TIME']; +$v_suspended = $data[$v_database]['SUSPENDED']; +if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; +} else { + $v_status = 'active'; +} + +// Check POST request +if (!empty($_POST['save'])) { $v_username = $user; - $v_database = $_GET['database']; - $v_dbuser = $data[$v_database]['DBUSER']; - $v_password = "••••••••"; - $v_host = $data[$v_database]['HOST']; - $v_type = $data[$v_database]['TYPE']; - $v_charset = $data[$v_database]['CHARSET']; - $v_date = $data[$v_database]['DATE']; - $v_time = $data[$v_database]['TIME']; - $v_suspended = $data[$v_database]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; + + // Change database user + if (($v_dbuser != $_POST['v_dbuser']) && (empty($_SESSION['error_msg']))) { + $v_dbuser = preg_replace("/^".$user."_/", "", $_POST['v_dbuser']); + $v_dbuser = escapeshellarg($v_dbuser); + exec (VESTA_CMD."v-change-database-user ".$v_username." ".$v_database." ".$v_dbuser, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + $v_dbuser = $user."_".preg_replace("/^".$user."_/", "", $_POST['v_dbuser']); } - // Action - if (!empty($_POST['save'])) { - $v_username = $user; + // Change database password + if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { + $v_password = escapeshellarg($_POST['v_password']); + exec (VESTA_CMD."v-change-database-password ".$v_username." ".$v_database." ".$v_password, $output, $return_var); + check_return_code($return_var,$output); + $v_password = "••••••••"; + unset($output); + } - // Change database username - if (($v_dbuser != $_POST['v_dbuser']) && (empty($_SESSION['error_msg']))) { - $v_dbuser = preg_replace("/^".$user."_/", "", $_POST['v_dbuser']); - $v_dbuser = escapeshellarg($v_dbuser); - if ($v_password != $_POST['v_password']) { - // Change username and password - $v_password = escapeshellarg($_POST['v_password']); - exec (VESTA_CMD."v-change-database-user ".$v_username." ".$v_database." ".$v_dbuser." ".$v_password, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $v_dbuser = $user."_".preg_replace("/^".$user."_/", "", $_POST['v_dbuser']); - $v_password = "••••••••"; - $v_pw_changed = 'yes'; - } else { - // Change only username - exec (VESTA_CMD."v-change-database-user ".$v_username." ".$v_database." ".$v_dbuser, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $v_dbuser = $user."_".preg_replace("/^".$user."_/", "", $_POST['v_dbuser']); - } - } - - // Change only database password - if (($v_password != $_POST['v_password']) && (!isset($v_pw_changed)) && (empty($_SESSION['error_msg']))) { - $v_password = escapeshellarg($_POST['v_password']); - exec (VESTA_CMD."v-change-database-password ".$v_username." ".$v_database." ".$v_password, $output, $return_var); - check_return_code($return_var,$output); - $v_password = "••••••••"; - unset($output); - } - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('Changes has been saved.'); - } + // Set success message + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('Changes has been saved.'); } } +// Display body include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_db.html'); + +// Flush session messages unset($_SESSION['error_msg']); unset($_SESSION['ok_msg']); diff --git a/web/edit/dns/index.php b/web/edit/dns/index.php index cd6a1c179..d07d1a6dd 100644 --- a/web/edit/dns/index.php +++ b/web/edit/dns/index.php @@ -3,17 +3,11 @@ error_reporting(NULL); ob_start(); session_start(); - $TAB = 'DNS'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); -// Header -include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); - -// Panel -top_panel($user,$TAB); - -// Check user argument? +// Check domain name if (empty($_GET['domain'])) { header("Location: /list/dns/"); exit; @@ -24,163 +18,194 @@ if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) { $user=escapeshellarg($_GET['user']); } -// Check domain +// List dns domain if ((!empty($_GET['domain'])) && (empty($_GET['record_id']))) { $v_domain = escapeshellarg($_GET['domain']); exec (VESTA_CMD."v-list-dns-domain ".$user." ".$v_domain." json", $output, $return_var); check_return_code($return_var,$output); + $data = json_decode(implode('', $output), true); + unset($output); + + // Parse dns domain + $v_username = $user; + $v_domain = $_GET['domain']; + $v_ip = $data[$v_domain]['IP']; + $v_template = $data[$v_domain]['TPL']; + $v_ttl = $data[$v_domain]['TTL']; + $v_exp = $data[$v_domain]['EXP']; + $v_soa = $data[$v_domain]['SOA']; + $v_date = $data[$v_domain]['DATE']; + $v_time = $data[$v_domain]['TIME']; + $v_suspended = $data[$v_domain]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + + // List dns templates + exec (VESTA_CMD."v-list-dns-templates json", $output, $return_var); + $templates = json_decode(implode('', $output), true); + unset($output); +} + +// List dns record +if ((!empty($_GET['domain'])) && (!empty($_GET['record_id']))) { + $v_domain = escapeshellarg($_GET['domain']); + $v_record_id = escapeshellarg($_GET['record_id']); + exec (VESTA_CMD."v-list-dns-records ".$user." ".$v_domain." 'json'", $output, $return_var); + check_return_code($return_var,$output); + $data = json_decode(implode('', $output), true); + unset($output); + + // Parse dns record + $v_username = $user; + $v_domain = $_GET['domain']; + $v_record_id = $_GET['record_id']; + $v_rec = $data[$v_record_id]['RECORD']; + $v_type = $data[$v_record_id]['TYPE']; + $v_val = $data[$v_record_id]['VALUE']; + $v_priority = $data[$v_record_id]['PRIORITY']; + $v_suspended = $data[$v_record_id]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + $v_date = $data[$v_record_id]['DATE']; + $v_time = $data[$v_record_id]['TIME']; +} + +// Check POST request for dns domain +if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (empty($_GET['record_id']))) { + $v_domain = escapeshellarg($_POST['v_domain']); + + // Change domain IP + if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) { + $v_ip = escapeshellarg($_POST['v_ip']); + exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); + check_return_code($return_var,$output); + $restart_dns = 'yes'; + unset($output); + } + + // Change domain template + if (($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { + $v_template = escapeshellarg($_POST['v_template']); + exec (VESTA_CMD."v-change-dns-domain-tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + $restart_dns = 'yes'; + } + + // Change SOA record + if (($v_soa != $_POST['v_soa']) && (empty($_SESSION['error_msg']))) { + $v_soa = escapeshellarg($_POST['v_soa']); + exec (VESTA_CMD."v-change-dns-domain-soa ".$v_username." ".$v_domain." ".$v_soa." 'no'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + $restart_dns = 'yes'; + } + + // Change expiriation date + if (($v_exp != $_POST['v_exp']) && (empty($_SESSION['error_msg']))) { + $v_exp = escapeshellarg($_POST['v_exp']); + exec (VESTA_CMD."v-change-dns-domain-exp ".$v_username." ".$v_domain." ".$v_exp." 'no'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Change domain ttl + if (($v_ttl != $_POST['v_ttl']) && (empty($_SESSION['error_msg']))) { + $v_ttl = escapeshellarg($_POST['v_ttl']); + exec (VESTA_CMD."v-change-dns-domain-ttl ".$v_username." ".$v_domain." ".$v_ttl." 'no'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + $restart_dns = 'yes'; + } + + // Restart dns server + if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-restart-dns", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Set success message if (empty($_SESSION['error_msg'])) { - $data = json_decode(implode('', $output), true); + $_SESSION['ok_msg'] = __('Changes has been saved.'); + } +} + +// Check POST request for dns record +if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (!empty($_GET['record_id']))) { + // Protect input + $v_domain = escapeshellarg($_POST['v_domain']); + $v_record_id = escapeshellarg($_POST['v_record_id']); + + // Change dns record + if (($v_val != $_POST['v_val']) || ($v_priority != $_POST['v_priority']) && (empty($_SESSION['error_msg']))) { + $v_val = escapeshellarg($_POST['v_val']); + $v_priority = escapeshellarg($_POST['v_priority']); + exec (VESTA_CMD."v-change-dns-record ".$v_username." ".$v_domain." ".$v_record_id." ".$v_val." ".$v_priority, $output, $return_var); + check_return_code($return_var,$output); + $v_val = $_POST['v_val']; unset($output); - $v_username = $user; - $v_domain = $_GET['domain']; - $v_ip = $data[$v_domain]['IP']; - $v_template = $data[$v_domain]['TPL']; - $v_ttl = $data[$v_domain]['TTL']; - $v_exp = $data[$v_domain]['EXP']; - $v_soa = $data[$v_domain]['SOA']; - $v_date = $data[$v_domain]['DATE']; - $v_time = $data[$v_domain]['TIME']; - $v_suspended = $data[$v_domain]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - exec (VESTA_CMD."v-list-dns-templates json", $output, $return_var); - $templates = json_decode(implode('', $output), true); + $restart_dns = 'yes'; + } + + // Change dns record id + if (($_GET['record_id'] != $_POST['v_record_id']) && (empty($_SESSION['error_msg']))) { + $v_old_record_id = escapeshellarg($_GET['record_id']); + exec (VESTA_CMD."v-change-dns-record-id ".$v_username." ".$v_domain." ".$v_old_record_id." ".$v_record_id, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + $restart_dns = 'yes'; + } + + // Restart dns server + if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-restart-dns", $output, $return_var); + check_return_code($return_var,$output); unset($output); } - // Action - if (!empty($_POST['save'])) { - $v_domain = escapeshellarg($_POST['v_domain']); - - // IP - if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) { - $v_ip = escapeshellarg($_POST['v_ip']); - exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); - check_return_code($return_var,$output); - $restart_dns = 'yes'; - unset($output); - } - - // Template - if (( $_SESSION['user'] == 'admin') && ($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { - $v_template = escapeshellarg($_POST['v_template']); - exec (VESTA_CMD."v-change-dns-domain-tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $restart_dns = 'yes'; - } - - // SOA - if (($v_soa != $_POST['v_soa']) && (empty($_SESSION['error_msg']))) { - $v_soa = escapeshellarg($_POST['v_soa']); - exec (VESTA_CMD."v-change-dns-domain-soa ".$v_username." ".$v_domain." ".$v_soa." 'no'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $restart_dns = 'yes'; - } - - // EXP - if (($v_exp != $_POST['v_exp']) && (empty($_SESSION['error_msg']))) { - $v_exp = escapeshellarg($_POST['v_exp']); - exec (VESTA_CMD."v-change-dns-domain-exp ".$v_username." ".$v_domain." ".$v_exp." 'no'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $restart_dns = 'yes'; - } - - // TTL - if (($v_ttl != $_POST['v_ttl']) && (empty($_SESSION['error_msg']))) { - $v_ttl = escapeshellarg($_POST['v_ttl']); - exec (VESTA_CMD."v-change-dns-domain-ttl ".$v_username." ".$v_domain." ".$v_ttl." 'no'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $restart_dns = 'yes'; - } - - // Restart dns - if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-restart-dns", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('Changes has been saved.'); - } + // Set success message + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('Changes has been saved.'); } + // Change url if record id was changed + if ((empty($_SESSION['error_msg'])) && ($_GET['record_id'] != $_POST['v_record_id'])) { + header("Location: /edit/dns/?domain=".$_GET['domain']."&record_id=".$_POST['v_record_id']); + exit; + } +} + +// Header +include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); + +// Panel +top_panel($user,$TAB); + +// Display body for dns domain +if ((!empty($_GET['domain'])) && (empty($_GET['record_id']))) { if ($_SESSION['user'] == 'admin') { include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns.html'); } else { include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_dns.html'); } - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} else { - $v_domain = escapeshellarg($_GET['domain']); - $v_record_id = escapeshellarg($_GET['record_id']); - exec (VESTA_CMD."v-list-dns-records ".$user." ".$v_domain." 'json'", $output, $return_var); - check_return_code($return_var,$output); - if (empty($_SESSION['error_msg'])) { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_domain = $_GET['domain']; - $v_record_id = $_GET['record_id']; - $v_rec = $data[$v_record_id]['RECORD']; - $v_type = $data[$v_record_id]['TYPE']; - $v_val = $data[$v_record_id]['VALUE']; - $v_priority = $data[$v_record_id]['PRIORITY']; - $v_suspended = $data[$v_record_id]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - $v_date = $data[$v_record_id]['DATE']; - $v_time = $data[$v_record_id]['TIME']; - } - - // Action - if (!empty($_POST['save'])) { - $v_domain = escapeshellarg($_POST['v_domain']); - $v_record_id = escapeshellarg($_POST['v_record_id']); - if (($v_val != $_POST['v_val']) || ($v_priority != $_POST['v_priority']) && (empty($_SESSION['error_msg']))) { - $v_val = escapeshellarg($_POST['v_val']); - $v_priority = escapeshellarg($_POST['v_priority']); - exec (VESTA_CMD."v-change-dns-record ".$v_username." ".$v_domain." ".$v_record_id." ".$v_val." ".$v_priority, $output, $return_var); - check_return_code($return_var,$output); - $v_val = $_POST['v_val']; - $restart_dns = 'yes'; - unset($output); - } - - if (($_GET['record_id'] != $_POST['v_record_id']) && (empty($_SESSION['error_msg']))) { - $v_old_record_id = escapeshellarg($_GET['record_id']); - exec (VESTA_CMD."v-change-dns-record-id ".$v_username." ".$v_domain." ".$v_old_record_id." ".$v_record_id, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('Changes has been saved.'); - } - - if ((empty($_SESSION['error_msg'])) && ($_GET['record_id'] != $_POST['v_record_id'])) { - header("Location: /edit/dns/?domain=".$_GET['domain']."&record_id=".$_POST['v_record_id']); - exit; - } - } - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns_rec.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); } +// List dns record +if ((!empty($_GET['domain'])) && (!empty($_GET['record_id']))) { + // Display body for dns record + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns_rec.html'); +} + +// Flush session messages +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/ip/index.php b/web/edit/ip/index.php index c6cdf2de9..bec1ae58f 100644 --- a/web/edit/ip/index.php +++ b/web/edit/ip/index.php @@ -3,107 +3,114 @@ error_reporting(NULL); ob_start(); session_start(); - $TAB = 'IP'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); +// Check user +if ($_SESSION['user'] != 'admin') { + header("Location: /list/user"); + exit; +} + +// Check ip argument +if (empty($_GET['ip'])) { + header("Location: /list/ip/"); + exit; +} + +// List ip +$v_ip = escapeshellarg($_GET['ip']); +exec (VESTA_CMD."v-list-sys-ip ".$v_ip." 'json'", $output, $return_var); +check_return_code($return_var,$output); +$data = json_decode(implode('', $output), true); +unset($output); + +// Parse ip +$v_username = $user; +$v_ip = $_GET['ip']; +$v_netmask = $data[$v_ip]['NETMASK']; +$v_interace = $data[$v_ip]['INTERFACE']; +$v_name = $data[$v_ip]['NAME']; +$v_nat = $data[$v_ip]['NAT']; +$v_ipstatus = $data[$v_ip]['STATUS']; +if ($v_ipstatus == 'dedicated') $v_dedicated = 'yes'; +$v_owner = $data[$v_ip]['OWNER']; +$v_date = $data[$v_ip]['DATE']; +$v_time = $data[$v_ip]['TIME']; +$v_suspended = $data[$v_ip]['SUSPENDED']; +if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; +} else { + $v_status = 'active'; +} + +// List users +exec (VESTA_CMD."v-list-sys-users 'json'", $output, $return_var); +$users = json_decode(implode('', $output), true); +unset($output); + +// Check POST request +if (!empty($_POST['save'])) { + $v_ip = escapeshellarg($_POST['v_ip']); + + // Change Status + if (($v_ipstatus == 'shared') && (empty($_POST['v_shared'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-change-sys-ip-status ".$v_ip." 'dedicated'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + $v_dedicated = 'yes'; + } + if (($v_ipstatus == 'dedicated') && (!empty($_POST['v_shared'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-change-sys-ip-status ".$v_ip." 'shared'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + unset($v_dedicated); + } + + // Change owner + if (($v_owner != $_POST['v_owner']) && (empty($_SESSION['error_msg']))) { + $v_owner = escapeshellarg($_POST['v_owner']); + exec (VESTA_CMD."v-change-sys-ip-owner ".$v_ip." ".$v_owner, $output, $return_var); + check_return_code($return_var,$output); + $v_owner = $_POST['v_owner']; + unset($output); + } + + // Change associated domain + if (($v_name != $_POST['v_name']) && (empty($_SESSION['error_msg']))) { + $v_name = escapeshellarg($_POST['v_name']); + exec (VESTA_CMD."v-change-sys-ip-name ".$v_ip." ".$v_name, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Change NAT address + if (($v_nat != $_POST['v_nat']) && (empty($_SESSION['error_msg']))) { + $v_nat = escapeshellarg($_POST['v_nat']); + exec (VESTA_CMD."v-change-sys-ip-nat ".$v_ip." ".$v_nat, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Set success message + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('Changes has been saved.'); + } +} + // Header include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); // Panel top_panel($user,$TAB); -// Are you admin? -if ($_SESSION['user'] == 'admin') { +// Display body +include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_ip.html'); - // Check user argument? - if (empty($_GET['ip'])) { - header("Location: /list/ip/"); - exit; - } - - $v_ip = escapeshellarg($_GET['ip']); - exec (VESTA_CMD."v-list-sys-ip ".$v_ip." 'json'", $output, $return_var); - check_return_code($return_var,$output); - if (empty($_SESSION['error_msg'])) { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_ip = $_GET['ip']; - $v_netmask = $data[$v_ip]['NETMASK']; - $v_interace = $data[$v_ip]['INTERFACE']; - $v_name = $data[$v_ip]['NAME']; - $v_nat = $data[$v_ip]['NAT']; - $v_ipstatus = $data[$v_ip]['STATUS']; - if ($v_ipstatus == 'dedicated') $v_dedicated = 'yes'; - $v_owner = $data[$v_ip]['OWNER']; - $v_date = $data[$v_ip]['DATE']; - $v_time = $data[$v_ip]['TIME']; - $v_suspended = $data[$v_ip]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - - exec (VESTA_CMD."v-list-sys-users 'json'", $output, $return_var); - $users = json_decode(implode('', $output), true); - unset($output); - - // Action - if (!empty($_POST['save'])) { - $v_username = $user; - $v_ip = escapeshellarg($_POST['v_ip']); - - // Change Status - if (($v_ipstatus == 'shared') && (empty($_POST['v_shared'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-change-sys-ip-status ".$v_ip." 'dedicated'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $v_dedicated = 'yes'; - } - if (($v_ipstatus == 'dedicated') && (!empty($_POST['v_shared'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-change-sys-ip-status ".$v_ip." 'shared'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - unset($v_dedicated); - } - - // Change owner - if (($v_owner != $_POST['v_owner']) && (empty($_SESSION['error_msg']))) { - $v_owner = escapeshellarg($_POST['v_owner']); - exec (VESTA_CMD."v-change-sys-ip-owner ".$v_ip." ".$v_owner, $output, $return_var); - check_return_code($return_var,$output); - $v_owner = $_POST['v_owner']; - unset($output); - } - - // Change Name - if (($v_name != $_POST['v_name']) && (empty($_SESSION['error_msg']))) { - $v_name = escapeshellarg($_POST['v_name']); - exec (VESTA_CMD."v-change-sys-ip-name ".$v_ip." ".$v_name, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - // Change Nat - if (($v_nat != $_POST['v_nat']) && (empty($_SESSION['error_msg']))) { - $v_nat = escapeshellarg($_POST['v_nat']); - exec (VESTA_CMD."v-change-sys-ip-nat ".$v_ip." ".$v_nat, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('Changes has been saved.'); - } - } - } - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_ip.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} +// Flush session messages +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/mail/index.php b/web/edit/mail/index.php index c70c6c896..6ff029351 100644 --- a/web/edit/mail/index.php +++ b/web/edit/mail/index.php @@ -3,8 +3,8 @@ error_reporting(NULL); ob_start(); session_start(); - $TAB = 'MAIL'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); // Header @@ -13,7 +13,7 @@ include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); // Panel top_panel($user,$TAB); -// Check user argument? +// Check domain argument if (empty($_GET['domain'])) { header("Location: /list/mail/"); exit; @@ -23,272 +23,289 @@ if (empty($_GET['domain'])) { if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) { $user=escapeshellarg($_GET['user']); } +$v_username = $user; -// Check domain +// List mail domain if ((!empty($_GET['domain'])) && (empty($_GET['account']))) { $v_domain = escapeshellarg($_GET['domain']); exec (VESTA_CMD."v-list-mail-domain ".$user." ".$v_domain." json", $output, $return_var); - check_return_code($return_var,$output); - if (empty($_SESSION['error_msg'])) { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_domain = $_GET['domain']; - $v_antispam = $data[$v_domain]['ANTISPAM']; - $v_antivirus = $data[$v_domain]['ANTIVIRUS']; - $v_dkim = $data[$v_domain]['DKIM']; - $v_catchall = $data[$v_domain]['CATCHALL']; - $v_date = $data[$v_domain]['DATE']; - $v_time = $data[$v_domain]['TIME']; - $v_suspended = $data[$v_domain]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } + $data = json_decode(implode('', $output), true); + unset($output); + + // Parse domain + $v_domain = $_GET['domain']; + $v_antispam = $data[$v_domain]['ANTISPAM']; + $v_antivirus = $data[$v_domain]['ANTIVIRUS']; + $v_dkim = $data[$v_domain]['DKIM']; + $v_catchall = $data[$v_domain]['CATCHALL']; + $v_date = $data[$v_domain]['DATE']; + $v_time = $data[$v_domain]['TIME']; + $v_suspended = $data[$v_domain]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; } +} - // Action - if (!empty($_POST['save'])) { - $v_domain = escapeshellarg($_POST['v_domain']); - // Antispam - if (($v_antispam == 'yes') && (empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-mail-domain-antispam ".$v_username." ".$v_domain, $output, $return_var); - check_return_code($return_var,$output); - $v_antispam = 'no'; - unset($output); - } - if (($v_antispam == 'no') && (!empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-mail-domain-antispam ".$v_username." ".$v_domain, $output, $return_var); - check_return_code($return_var,$output); - $v_antispam = 'yes'; - unset($output); - } - // Antivirus - if (($v_antivirus == 'yes') && (empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-mail-domain-antivirus ".$v_username." ".$v_domain, $output, $return_var); - check_return_code($return_var,$output); - $v_antivirus = 'no'; - unset($output); - } - if (($v_antivirus == 'no') && (!empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-mail-domain-antivirus ".$v_username." ".$v_domain, $output, $return_var); - check_return_code($return_var,$output); - $v_antivirus = 'yes'; - unset($output); - } - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('Changes has been saved.'); - } - - // DKIM - if (($v_dkim == 'yes') && (empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-mail-domain-dkim ".$v_username." ".$v_domain, $output, $return_var); - check_return_code($return_var,$output); - $v_dkim = 'no'; - unset($output); - } - if (($v_dkim == 'no') && (!empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-mail-domain-dkim ".$v_username." ".$v_domain, $output, $return_var); - check_return_code($return_var,$output); - $v_dkim = 'yes'; - unset($output); - } - - // Catchall - if ((!empty($v_catchall)) && (empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-mail-domain-catchall ".$v_username." ".$v_domain, $output, $return_var); - check_return_code($return_var,$output); - $v_catchall = ''; - unset($output); - } - if ((!empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { - if ($v_catchall != $_POST['v_catchall']) { - $v_catchall = escapeshellarg($_POST['v_catchall']); - exec (VESTA_CMD."v-change-mail-domain-catchall ".$v_username." ".$v_domain." ".$v_catchall, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - } - if ((empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { - $v_catchall = escapeshellarg($_POST['v_catchall']); - exec (VESTA_CMD."v-add-mail-domain-catchall ".$v_username." ".$v_domain." ".$v_catchall, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('Changes has been saved.'); - } - } - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_mail.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} else { - $v_username = $user; +// List mail account +if ((!empty($_GET['domain'])) && (!empty($_GET['account']))) { $v_domain = escapeshellarg($_GET['domain']); $v_account = escapeshellarg($_GET['account']); exec (VESTA_CMD."v-list-mail-account ".$user." ".$v_domain." ".$v_account." 'json'", $output, $return_var); - check_return_code($return_var,$output); - if (empty($_SESSION['error_msg'])) { - $data = json_decode(implode('', $output), true); + $data = json_decode(implode('', $output), true); + unset($output); + + // Parse mail account + $v_username = $user; + $v_domain = $_GET['domain']; + $v_account = $_GET['account']; + $v_password = "••••••••"; + $v_aliases = str_replace(',', "\n", $data[$v_account]['ALIAS']); + $valiases = explode(",", $data[$v_account]['ALIAS']); + $v_fwd = str_replace(',', "\n", $data[$v_account]['FWD']); + $vfwd = explode(",", $data[$v_account]['FWD']); + $v_fwd_only = $data[$v_account]['FWD_ONLY']; + $v_quota = $data[$v_account]['QUOTA']; + $v_autoreply = $data[$v_account]['AUTOREPLY']; + $v_suspended = $data[$v_account]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + $v_date = $data[$v_account]['DATE']; + $v_time = $data[$v_account]['TIME']; + + // Parse autoreply + if ( $v_autoreply == 'yes' ) { + exec (VESTA_CMD."v-list-mail-account-autoreply ".$user." '".$v_domain."' '".$v_account."' json", $output, $return_var); + $autoreply_str = json_decode(implode('', $output), true); unset($output); - $v_username = $user; - $v_domain = $_GET['domain']; - $v_account = $_GET['account']; - $v_password = "••••••••"; - $v_aliases = str_replace(',', "\n", $data[$v_account]['ALIAS']); - $valiases = explode(",", $data[$v_account]['ALIAS']); - $v_fwd = str_replace(',', "\n", $data[$v_account]['FWD']); - $vfwd = explode(",", $data[$v_account]['FWD']); - $v_fwd_only = $data[$v_account]['FWD_ONLY']; - $v_quota = $data[$v_account]['QUOTA']; - $v_autoreply = $data[$v_account]['AUTOREPLY']; - if ( $v_autoreply == 'yes' ) { - exec (VESTA_CMD."v-list-mail-account-autoreply ".$user." '".$v_domain."' '".$v_account."' json", $output, $return_var); - $autoreply_str = json_decode(implode('', $output), true); - unset($output); - $v_autoreply_message = $autoreply_str[$v_account]['MSG']; - } - $v_suspended = $data[$v_account]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - $v_date = $data[$v_account]['DATE']; - $v_time = $data[$v_account]['TIME']; + $v_autoreply_message = $autoreply_str[$v_account]['MSG']; } - - // Action - if (!empty($_POST['save'])) { - $v_domain = escapeshellarg($_POST['v_domain']); - $v_account = escapeshellarg($_POST['v_account']); - // Password - if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { - $v_password = escapeshellarg($_POST['v_password']); - exec (VESTA_CMD."v-change-mail-account-password ".$v_username." ".$v_domain." ".$v_account." ".$v_password, $output, $return_var); - check_return_code($return_var,$output); - $v_password = "••••••••"; - unset($output); - } - - // Quota - if (($v_quota != $_POST['v_quota']) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_quota'])) { - $v_quota = 0; - } else { - $v_quota = escapeshellarg($_POST['v_quota']); - } - exec (VESTA_CMD."v-change-mail-account-quota ".$v_username." ".$v_domain." ".$v_account." ".$v_quota, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - // Aliases - if (empty($_SESSION['error_msg'])) { - $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']); - $waliases = preg_replace("/,/", " ", $waliases); - $waliases = preg_replace('/\s+/', ' ',$waliases); - $waliases = trim($waliases); - $aliases = explode(" ", $waliases); - $v_aliases = str_replace(' ', "\n", $waliases); - $result = array_diff($valiases, $aliases); - foreach ($result as $alias) { - if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { - exec (VESTA_CMD."v-delete-mail-account-alias ".$v_username." ".$v_domain." ".$v_account." '".$alias."'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - } - $result = array_diff($aliases, $valiases); - foreach ($result as $alias) { - if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { - exec (VESTA_CMD."v-add-mail-account-alias ".$v_username." ".$v_domain." ".$v_account." '".$alias."'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - } - } - // Forwarders - if (empty($_SESSION['error_msg'])) { - $wfwd = preg_replace("/\n/", " ", $_POST['v_fwd']); - $wfwd = preg_replace("/,/", " ", $wfwd); - $wfwd = preg_replace('/\s+/', ' ',$wfwd); - $wfwd = trim($wfwd); - $fwd = explode(" ", $wfwd); - $v_fwd = str_replace(' ', "\n", $wfwd); - $result = array_diff($vfwd, $fwd); - foreach ($result as $forward) { - if ((empty($_SESSION['error_msg'])) && (!empty($forward))) { - exec (VESTA_CMD."v-delete-mail-account-forward ".$v_username." ".$v_domain." ".$v_account." '".$forward."'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - } - $result = array_diff($fwd, $vfwd); - foreach ($result as $forward) { - if ((empty($_SESSION['error_msg'])) && (!empty($forward))) { - exec (VESTA_CMD."v-add-mail-account-forward ".$v_username." ".$v_domain." ".$v_account." '".$forward."'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - } - } - - // FWD_ONLY flag - if (($v_fwd_only == 'yes') && (empty($_POST['v_fwd_only'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-mail-account-fwd-only ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $v_fwd_only = ''; - } - if (($v_fwd_only != 'yes') && (!empty($_POST['v_fwd_only'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-mail-account-fwd-only ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $v_fwd_only = 'yes'; - } - - // Autoreply - if (($v_autoreply == 'yes') && (empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $v_autoreply = 'no'; - $v_autoreply_message = ''; - } - if (($v_autoreply == 'yes') && (!empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { - if ( $v_autoreply_message != str_replace("\r\n", "\n", $_POST['v_autoreply_message'])) { - $v_autoreply_message = str_replace("\r\n", "\n", $_POST['v_autoreply_message']); - $v_autoreply_message = escapeshellarg($v_autoreply_message); - exec (VESTA_CMD."v-add-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account." ".$v_autoreply_message, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $v_autoreply_message = $_POST['v_autoreply_message']; - } - } - if (($v_autoreply == 'no') && (!empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_autoreply_message'])) $_SESSION['error_msg'] = $_SESSION['error_msg'] = __('Field "%s" can not be blank.','atoreply'); - if (empty($_SESSION['error_msg'])) { - $v_autoreply_message = str_replace("\r\n", "\n", $_POST['v_autoreply_message']); - $v_autoreply_message = escapeshellarg($v_autoreply_message); - exec (VESTA_CMD."v-add-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account." ".$v_autoreply_message, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $v_autoreply = 'yes'; - $v_autoreply_message = $_POST['v_autoreply_message']; - } - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('Changes has been saved.'); - } - } - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_mail_acc.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); } +// Check POST request for mail domain +if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (empty($_GET['account']))) { + $v_domain = escapeshellarg($_POST['v_domain']); + + // Delete antispam + if (($v_antispam == 'yes') && (empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-mail-domain-antispam ".$v_username." ".$v_domain, $output, $return_var); + check_return_code($return_var,$output); + $v_antispam = 'no'; + unset($output); + } + + // Add antispam + if (($v_antispam == 'no') && (!empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-mail-domain-antispam ".$v_username." ".$v_domain, $output, $return_var); + check_return_code($return_var,$output); + $v_antispam = 'yes'; + unset($output); + } + + // Delete antivirus + if (($v_antivirus == 'yes') && (empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-mail-domain-antivirus ".$v_username." ".$v_domain, $output, $return_var); + check_return_code($return_var,$output); + $v_antivirus = 'no'; + unset($output); + } + + // Add antivirs + if (($v_antivirus == 'no') && (!empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-mail-domain-antivirus ".$v_username." ".$v_domain, $output, $return_var); + check_return_code($return_var,$output); + $v_antivirus = 'yes'; + unset($output); + } + + // Delete DKIM + if (($v_dkim == 'yes') && (empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-mail-domain-dkim ".$v_username." ".$v_domain, $output, $return_var); + check_return_code($return_var,$output); + $v_dkim = 'no'; + unset($output); + } + + // Add DKIM + if (($v_dkim == 'no') && (!empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-mail-domain-dkim ".$v_username." ".$v_domain, $output, $return_var); + check_return_code($return_var,$output); + $v_dkim = 'yes'; + unset($output); + } + + // Delete catchall + if ((!empty($v_catchall)) && (empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-mail-domain-catchall ".$v_username." ".$v_domain, $output, $return_var); + check_return_code($return_var,$output); + $v_catchall = ''; + unset($output); + } + + // Change catchall address + if ((!empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { + if ($v_catchall != $_POST['v_catchall']) { + $v_catchall = escapeshellarg($_POST['v_catchall']); + exec (VESTA_CMD."v-change-mail-domain-catchall ".$v_username." ".$v_domain." ".$v_catchall, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + } + + // Add catchall + if ((empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { + $v_catchall = escapeshellarg($_POST['v_catchall']); + exec (VESTA_CMD."v-add-mail-domain-catchall ".$v_username." ".$v_domain." ".$v_catchall, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Set success message + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('Changes has been saved.'); + } +} + +// Check POST request for mail account +if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (!empty($_GET['account']))) { + $v_domain = escapeshellarg($_POST['v_domain']); + $v_account = escapeshellarg($_POST['v_account']); + + // Change password + if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { + $v_password = escapeshellarg($_POST['v_password']); + exec (VESTA_CMD."v-change-mail-account-password ".$v_username." ".$v_domain." ".$v_account." ".$v_password, $output, $return_var); + check_return_code($return_var,$output); + $v_password = "••••••••"; + unset($output); + } + + // Change quota + if (($v_quota != $_POST['v_quota']) && (empty($_SESSION['error_msg']))) { + if (empty($_POST['v_quota'])) { + $v_quota = 0; + } else { + $v_quota = escapeshellarg($_POST['v_quota']); + } + exec (VESTA_CMD."v-change-mail-account-quota ".$v_username." ".$v_domain." ".$v_account." ".$v_quota, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Change account aliases + if (empty($_SESSION['error_msg'])) { + $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']); + $waliases = preg_replace("/,/", " ", $waliases); + $waliases = preg_replace('/\s+/', ' ',$waliases); + $waliases = trim($waliases); + $aliases = explode(" ", $waliases); + $v_aliases = str_replace(' ', "\n", $waliases); + $result = array_diff($valiases, $aliases); + foreach ($result as $alias) { + if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { + exec (VESTA_CMD."v-delete-mail-account-alias ".$v_username." ".$v_domain." ".$v_account." '".$alias."'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + } + $result = array_diff($aliases, $valiases); + foreach ($result as $alias) { + if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { + exec (VESTA_CMD."v-add-mail-account-alias ".$v_username." ".$v_domain." ".$v_account." '".$alias."'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + } + } + + // Change forwarders + if (empty($_SESSION['error_msg'])) { + $wfwd = preg_replace("/\n/", " ", $_POST['v_fwd']); + $wfwd = preg_replace("/,/", " ", $wfwd); + $wfwd = preg_replace('/\s+/', ' ',$wfwd); + $wfwd = trim($wfwd); + $fwd = explode(" ", $wfwd); + $v_fwd = str_replace(' ', "\n", $wfwd); + $result = array_diff($vfwd, $fwd); + foreach ($result as $forward) { + if ((empty($_SESSION['error_msg'])) && (!empty($forward))) { + exec (VESTA_CMD."v-delete-mail-account-forward ".$v_username." ".$v_domain." ".$v_account." '".$forward."'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + } + $result = array_diff($fwd, $vfwd); + foreach ($result as $forward) { + if ((empty($_SESSION['error_msg'])) && (!empty($forward))) { + exec (VESTA_CMD."v-add-mail-account-forward ".$v_username." ".$v_domain." ".$v_account." '".$forward."'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + } + } + + // Delete FWD_ONLY flag + if (($v_fwd_only == 'yes') && (empty($_POST['v_fwd_only'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-mail-account-fwd-only ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + $v_fwd_only = ''; + } + + // Add FWD_ONLY flag + if (($v_fwd_only != 'yes') && (!empty($_POST['v_fwd_only'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-mail-account-fwd-only ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + $v_fwd_only = 'yes'; + } + + // Delete autoreply + if (($v_autoreply == 'yes') && (empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + $v_autoreply = 'no'; + $v_autoreply_message = ''; + } + + // Add autoreply + if ((!empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { + if ( $v_autoreply_message != str_replace("\r\n", "\n", $_POST['v_autoreply_message'])) { + $v_autoreply_message = str_replace("\r\n", "\n", $_POST['v_autoreply_message']); + $v_autoreply_message = escapeshellarg($v_autoreply_message); + exec (VESTA_CMD."v-add-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account." ".$v_autoreply_message, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + $v_autoreply = 'yes'; + $v_autoreply_message = $_POST['v_autoreply_message']; + } + } + + // Set success message + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('Changes has been saved.'); + } +} + +// Display body for mail domain +if ((!empty($_GET['domain'])) && (empty($_GET['account']))) { + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_mail.html'); +} + +// Display body for mail account +if ((!empty($_GET['domain'])) && (!empty($_GET['account']))) { + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_mail_acc.html'); +} + +// Flush session messages +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); + // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/package/index.php b/web/edit/package/index.php index 2347aa261..41b3640b6 100644 --- a/web/edit/package/index.php +++ b/web/edit/package/index.php @@ -3,196 +3,199 @@ error_reporting(NULL); ob_start(); session_start(); - $TAB = 'PACKAGE'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); + +// Check user +if ($_SESSION['user'] != 'admin') { + header("Location: /list/user"); + exit; +} + +// Check package argument +if (empty($_GET['package'])) { + header("Location: /list/package/"); + exit; +} + + +// List package +$v_package = escapeshellarg($_GET['package']); +exec (VESTA_CMD."v-list-user-package ".$v_package." 'json'", $output, $return_var); +$data = json_decode(implode('', $output), true); +unset($output); + +// Parse package +$v_package = $_GET['package']; +$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']; +$v_dns_records = $data[$v_package]['DNS_RECORDS']; +$v_mail_domains = $data[$v_package]['MAIL_DOMAINS']; +$v_mail_accounts = $data[$v_package]['MAIL_ACCOUNTS']; +$v_databases = $data[$v_package]['DATABASES']; +$v_cron_jobs = $data[$v_package]['CRON_JOBS']; +$v_disk_quota = $data[$v_package]['DISK_QUOTA']; +$v_bandwidth = $data[$v_package]['BANDWIDTH']; +$v_shell = $data[$v_package]['SHELL']; +$v_ns = $data[$v_package]['NS']; +$nameservers = explode(", ", $v_ns); +$v_ns1 = $nameservers[0]; +$v_ns2 = $nameservers[1]; +$v_ns3 = $nameservers[2]; +$v_ns4 = $nameservers[3]; +$v_backups = $data[$v_package]['BACKUPS']; +$v_date = $data[$v_package]['DATE']; +$v_time = $data[$v_package]['TIME']; +$v_status = 'active'; + +// List web templates +exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); +$web_templates = json_decode(implode('', $output), true); +unset($output); + +// List proxy templates +exec (VESTA_CMD."v-list-web-templates-proxy json", $output, $return_var); +$proxy_templates = json_decode(implode('', $output), true); +unset($output); + +// List dns templates +exec (VESTA_CMD."v-list-dns-templates json", $output, $return_var); +$dns_templates = json_decode(implode('', $output), true); +unset($output); + +// List shels +exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var); +$shells = json_decode(implode('', $output), true); +unset($output); + +// Check POST request +if (!empty($_POST['save'])) { + + // Check empty fields + if (empty($_POST['v_package'])) $errors[] = __('package'); + 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'); + if (!isset($_POST['v_dns_domains'])) $errors[] = __('dns domains'); + if (!isset($_POST['v_dns_records'])) $errors[] = __('dns records'); + if (!isset($_POST['v_mail_domains'])) $errors[] = __('mail domains'); + if (!isset($_POST['v_mail_accounts'])) $errors[] = __('mail accounts'); + if (!isset($_POST['v_databases'])) $errors[] = __('databases'); + if (!isset($_POST['v_cron_jobs'])) $errors[] = __('cron jobs'); + if (!isset($_POST['v_backups'])) $errors[] = __('backups'); + if (!isset($_POST['v_disk_quota'])) $errors[] = __('quota'); + if (!isset($_POST['v_bandwidth'])) $errors[] = __('bandwidth'); + if (empty($_POST['v_ns1'])) $errors[] = __('ns1'); + if (empty($_POST['v_ns2'])) $errors[] = __('ns2'); + 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); + } + + // Protect input + $v_package = escapeshellarg($_POST['v_package']); + $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']); + $v_dns_domains = escapeshellarg($_POST['v_dns_domains']); + $v_dns_records = escapeshellarg($_POST['v_dns_records']); + $v_mail_domains = escapeshellarg($_POST['v_mail_domains']); + $v_mail_accounts = escapeshellarg($_POST['v_mail_accounts']); + $v_databases = escapeshellarg($_POST['v_databases']); + $v_cron_jobs = escapeshellarg($_POST['v_cron_jobs']); + $v_backups = escapeshellarg($_POST['v_backups']); + $v_disk_quota = escapeshellarg($_POST['v_disk_quota']); + $v_bandwidth = escapeshellarg($_POST['v_bandwidth']); + $v_ns1 = trim($_POST['v_ns1'], '.'); + $v_ns2 = trim($_POST['v_ns2'], '.'); + $v_ns3 = trim($_POST['v_ns3'], '.'); + $v_ns4 = trim($_POST['v_ns4'], '.'); + $v_ns = $v_ns1.",".$v_ns2; + if (!empty($v_ns3)) $v_ns .= ",".$v_ns3; + if (!empty($v_ns4)) $v_ns .= ",".$v_ns4; + $v_ns = escapeshellarg($v_ns); + $v_time = escapeshellarg(date('H:i:s')); + $v_date = escapeshellarg(date('Y-m-d')); + + // Create temprorary directory + exec ('mktemp -d', $output, $return_var); + $tmpdir = $output[0]; + unset($output); + + // Save package file on a fs + $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"; + $pkg .= "DNS_RECORDS=".$v_dns_records."\n"; + $pkg .= "MAIL_DOMAINS=".$v_mail_domains."\n"; + $pkg .= "MAIL_ACCOUNTS=".$v_mail_accounts."\n"; + $pkg .= "DATABASES=".$v_databases."\n"; + $pkg .= "CRON_JOBS=".$v_cron_jobs."\n"; + $pkg .= "DISK_QUOTA=".$v_disk_quota."\n"; + $pkg .= "BANDWIDTH=".$v_bandwidth."\n"; + $pkg .= "NS=".$v_ns."\n"; + $pkg .= "SHELL=".$v_shell."\n"; + $pkg .= "BACKUPS=".$v_backups."\n"; + $pkg .= "TIME=".$v_time."\n"; + $pkg .= "DATE=".$v_date."\n"; + $fp = fopen($tmpdir."/".$_POST['v_package'].".pkg", 'w'); + fwrite($fp, $pkg); + fclose($fp); + + // Save changes + exec (VESTA_CMD."v-add-user-package ".$tmpdir." ".$v_package." 'yes'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + + // Remove temporary dir + exec ('rm -rf '.$tmpdir, $output, $return_var); + unset($output); + + // Propogate new package + exec (VESTA_CMD."v-update-user-package ".$v_package." 'json'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + + // Set success message + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('Changes has been saved.'); + } +} + + // Header include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); // Panel top_panel($user,$TAB); -// Are you admin? -if ($_SESSION['user'] == 'admin') { +// Display body +include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_package.html'); - // Check user argument? - if (empty($_GET['package'])) { - header("Location: /list/package/"); - exit; - } - - $v_package = escapeshellarg($_GET['package']); - exec (VESTA_CMD."v-list-user-package ".$v_package." 'json'", $output, $return_var); - check_return_code($return_var,$output); - if (empty($_SESSION['error_msg'])) { - $data = json_decode(implode('', $output), true); - unset($output); - - $v_package = $_GET['package']; - $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']; - $v_dns_records = $data[$v_package]['DNS_RECORDS']; - $v_mail_domains = $data[$v_package]['MAIL_DOMAINS']; - $v_mail_accounts = $data[$v_package]['MAIL_ACCOUNTS']; - $v_databases = $data[$v_package]['DATABASES']; - $v_cron_jobs = $data[$v_package]['CRON_JOBS']; - $v_disk_quota = $data[$v_package]['DISK_QUOTA']; - $v_bandwidth = $data[$v_package]['BANDWIDTH']; - $v_shell = $data[$v_package]['SHELL']; - $v_ns = $data[$v_package]['NS']; - $nameservers = explode(", ", $v_ns); - $v_ns1 = $nameservers[0]; - $v_ns2 = $nameservers[1]; - $v_ns3 = $nameservers[2]; - $v_ns4 = $nameservers[3]; - $v_backups = $data[$v_package]['BACKUPS']; - $v_date = $data[$v_package]['DATE']; - $v_time = $data[$v_package]['TIME']; - $v_status = 'active'; - - - exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); - check_error($return_var); - $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); - check_error($return_var); - $shells = json_decode(implode('', $output), true); - unset($output); - - // Action - if (!empty($_POST['save'])) { - // Check input - if (empty($_POST['v_package'])) $errors[] = __('package'); - 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'); - if (!isset($_POST['v_dns_domains'])) $errors[] = __('dns domains'); - if (!isset($_POST['v_dns_records'])) $errors[] = __('dns records'); - if (!isset($_POST['v_mail_domains'])) $errors[] = __('mail domains'); - if (!isset($_POST['v_mail_accounts'])) $errors[] = __('mail accounts'); - if (!isset($_POST['v_databases'])) $errors[] = __('databases'); - if (!isset($_POST['v_cron_jobs'])) $errors[] = __('cron jobs'); - if (!isset($_POST['v_backups'])) $errors[] = __('backups'); - if (!isset($_POST['v_disk_quota'])) $errors[] = __('quota'); - if (!isset($_POST['v_bandwidth'])) $errors[] = __('bandwidth'); - if (empty($_POST['v_ns1'])) $errors[] = __('ns1'); - if (empty($_POST['v_ns2'])) $errors[] = __('ns2'); - - // Protect input - $v_package = escapeshellarg($_POST['v_package']); - $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']); - $v_dns_domains = escapeshellarg($_POST['v_dns_domains']); - $v_dns_records = escapeshellarg($_POST['v_dns_records']); - $v_mail_domains = escapeshellarg($_POST['v_mail_domains']); - $v_mail_accounts = escapeshellarg($_POST['v_mail_accounts']); - $v_databases = escapeshellarg($_POST['v_databases']); - $v_cron_jobs = escapeshellarg($_POST['v_cron_jobs']); - $v_backups = escapeshellarg($_POST['v_backups']); - $v_disk_quota = escapeshellarg($_POST['v_disk_quota']); - $v_bandwidth = escapeshellarg($_POST['v_bandwidth']); - $v_ns1 = trim($_POST['v_ns1'], '.'); - $v_ns2 = trim($_POST['v_ns2'], '.'); - $v_ns3 = trim($_POST['v_ns3'], '.'); - $v_ns4 = trim($_POST['v_ns4'], '.'); - $v_ns = $v_ns1.",".$v_ns2; - if (!empty($v_ns3)) $v_ns .= ",".$v_ns3; - if (!empty($v_ns4)) $v_ns .= ",".$v_ns4; - $v_ns = escapeshellarg($v_ns); - $v_time = escapeshellarg(date('H:i:s')); - $v_date = escapeshellarg(date('Y-m-d')); - - // Check for errors - 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', $output, $return_var); - $tmpdir = $output[0]; - unset($output); - - // Create package - $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"; - $pkg .= "DNS_RECORDS=".$v_dns_records."\n"; - $pkg .= "MAIL_DOMAINS=".$v_mail_domains."\n"; - $pkg .= "MAIL_ACCOUNTS=".$v_mail_accounts."\n"; - $pkg .= "DATABASES=".$v_databases."\n"; - $pkg .= "CRON_JOBS=".$v_cron_jobs."\n"; - $pkg .= "DISK_QUOTA=".$v_disk_quota."\n"; - $pkg .= "BANDWIDTH=".$v_bandwidth."\n"; - $pkg .= "NS=".$v_ns."\n"; - $pkg .= "SHELL=".$v_shell."\n"; - $pkg .= "BACKUPS=".$v_backups."\n"; - $pkg .= "TIME=".$v_time."\n"; - $pkg .= "DATE=".$v_date."\n"; - - // Write package - $fp = fopen($tmpdir."/".$_POST['v_package'].".pkg", 'w'); - fwrite($fp, $pkg); - fclose($fp); - - // Rewrite package - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-user-package ".$tmpdir." ".$v_package." 'yes'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - // Remove tmpdir - exec ('rm -rf '.$tmpdir, $output, $return_var); - unset($output); - - // Propogate new package - exec (VESTA_CMD."v-update-user-package ".$v_package." 'json'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('Changes has been saved.'); - } - } - } - } - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_package.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} +// Flush session messages +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/user/index.php b/web/edit/user/index.php index bc1aa8889..50f36c3ad 100644 --- a/web/edit/user/index.php +++ b/web/edit/user/index.php @@ -3,118 +3,126 @@ error_reporting(NULL); ob_start(); session_start(); - $TAB = 'USER'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); // Header include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); +// Check user argument +if (empty($_GET['user'])) { + header("Location: /list/user/"); + exit; +} + +// Edit as someone else? +if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) { + $user=$_GET['user']; + $v_username=$_GET['user']; +} else { + $user=$_SESSION['user']; + $v_username=$_SESSION['user']; +} + +// List user +exec (VESTA_CMD."v-list-user ".$v_username." json", $output, $return_var); +check_return_code($return_var,$output); +$data = json_decode(implode('', $output), true); +unset($output); + +// Parse user +$v_password = "••••••••"; +$v_email = $data[$v_username]['CONTACT']; +$v_package = $data[$v_username]['PACKAGE']; +$v_language = $data[$v_username]['LANGUAGE']; +$v_fname = $data[$v_username]['FNAME']; +$v_lname = $data[$v_username]['LNAME']; +$v_shell = $data[$v_username]['SHELL']; +$v_ns = $data[$v_username]['NS']; +$nameservers = explode(", ", $v_ns); +$v_ns1 = $nameservers[0]; +$v_ns2 = $nameservers[1]; +$v_ns3 = $nameservers[2]; +$v_ns4 = $nameservers[3]; +$v_suspended = $data[$v_username]['SUSPENDED']; +if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; +} else { + $v_status = 'active'; +} +$v_time = $data[$v_username]['TIME']; +$v_date = $data[$v_username]['DATE']; + +// List packages +exec (VESTA_CMD."v-list-user-packages json", $output, $return_var); +$packages = json_decode(implode('', $output), true); +unset($output); + +// List lanugages +exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var); +$languages = json_decode(implode('', $output), true); +unset($output); + +// List shells +exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var); +$shells = json_decode(implode('', $output), true); +unset($output); + // Are you admin? -if ($_SESSION['user'] == 'admin') { - // Check user argument? - if (empty($_GET['user'])) { - header("Location: /list/user/"); - exit; - } +// Check POST request +if (!empty($_POST['save'])) { - // Check user - $v_username = escapeshellarg($_GET['user']); - exec (VESTA_CMD."v-list-user ".$v_username." json", $output, $return_var); - check_return_code($return_var,$output); - if (empty($_SESSION['error_msg'])) { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $_GET['user']; + // Change password + if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { + $v_password = escapeshellarg($_POST['v_password']); + exec (VESTA_CMD."v-change-user-password ".$v_username." ".$v_password, $output, $return_var); + check_return_code($return_var,$output); $v_password = "••••••••"; - $v_email = $data[$v_username]['CONTACT']; - $v_package = $data[$v_username]['PACKAGE']; - $v_language = $data[$v_username]['LANGUAGE']; - $v_fname = $data[$v_username]['FNAME']; - $v_lname = $data[$v_username]['LNAME']; - $v_shell = $data[$v_username]['SHELL']; - $v_ns = $data[$v_username]['NS']; - $nameservers = explode(", ", $v_ns); - $v_ns1 = $nameservers[0]; - $v_ns2 = $nameservers[1]; - $v_ns3 = $nameservers[2]; - $v_ns4 = $nameservers[3]; - $v_suspended = $data[$v_username]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - $v_time = $data[$v_username]['TIME']; - $v_date = $data[$v_username]['DATE']; - - exec (VESTA_CMD."v-list-user-packages json", $output, $return_var); - $packages = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var); - $languages = 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); } - // Action - if (!empty($_POST['save'])) { - $v_username = escapeshellarg($_POST['v_username']); + // Change package (admin only) + if (($v_package != $_POST['v_package']) && ($_SESSION['user'] == 'admin') && (empty($_SESSION['error_msg']))) { + $v_package = escapeshellarg($_POST['v_package']); + exec (VESTA_CMD."v-change-user-package ".$v_username." ".$v_package, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } - // Change password - if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { - $v_password = escapeshellarg($_POST['v_password']); - exec (VESTA_CMD."v-change-user-password ".$v_username." ".$v_password, $output, $return_var); - check_return_code($return_var,$output); - $v_password = "••••••••"; - unset($output); - } + // Change language + if (($v_language != $_POST['v_language']) && (empty($_SESSION['error_msg']))) { + $v_language = escapeshellarg($_POST['v_language']); + exec (VESTA_CMD."v-change-user-language ".$v_username." ".$v_language, $output, $return_var); + check_return_code($return_var,$output); + if (($_GET['user'] == 'admin') && (empty($_SESSION['error_msg']))) $_SESSION['language'] = $_POST['v_language']; + unset($output); + } - // Change package - if (($v_package != $_POST['v_package']) && (empty($_SESSION['error_msg']))) { - $v_package = escapeshellarg($_POST['v_package']); - exec (VESTA_CMD."v-change-user-package ".$v_username." ".$v_package, $output, $return_var); + // Change shell (admin only) + if (($v_shell != $_POST['v_shell']) && ($_SESSION['user'] == 'admin') && (empty($_SESSION['error_msg']))) { + $v_shell = escapeshellarg($_POST['v_shell']); + exec (VESTA_CMD."v-change-user-shell ".$v_username." ".$v_shell, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Change contact email + if (($v_email != $_POST['v_email']) && (empty($_SESSION['error_msg']))) { + if (!filter_var($_POST['v_email'], FILTER_VALIDATE_EMAIL)) { + $_SESSION['error_msg'] = __('Please enter valid email address.'); + } else { + $v_email = escapeshellarg($_POST['v_email']); + exec (VESTA_CMD."v-change-user-contact ".$v_username." ".$v_email, $output, $return_var); check_return_code($return_var,$output); unset($output); } + } - // Change language - if (($v_language != $_POST['v_language']) && (empty($_SESSION['error_msg']))) { - $v_language = escapeshellarg($_POST['v_language']); - exec (VESTA_CMD."v-change-user-language ".$v_username." ".$v_language, $output, $return_var); - check_return_code($return_var,$output); - if (($_GET['user'] == 'admin') && (empty($_SESSION['error_msg']))) $_SESSION['language'] = $_POST['v_language']; - unset($output); - } - - // Change shell - if (($v_shell != $_POST['v_shell']) && (empty($_SESSION['error_msg']))) { - $v_shell = escapeshellarg($_POST['v_shell']); - exec (VESTA_CMD."v-change-user-shell ".$v_username." ".$v_shell, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - // Change contact email - if (($v_email != $_POST['v_email']) && (empty($_SESSION['error_msg']))) { - // Validate email - if (!filter_var($_POST['v_email'], FILTER_VALIDATE_EMAIL)) { - $_SESSION['error_msg'] = __('Please enter valid email address.'); - } else { - $v_email = escapeshellarg($_POST['v_email']); - exec (VESTA_CMD."v-change-user-contact ".$v_username." ".$v_email, $output, $return_var); - check_return_code($return_var,$output); - } - unset($output); - } - - // Change Name - if (($v_fname != $_POST['v_fname']) || ($v_lname != $_POST['v_lname']) && (empty($_SESSION['error_msg']))) { + // Change full name (admin only) + if (($v_fname != $_POST['v_fname']) || ($v_lname != $_POST['v_lname'])) { + if (($_SESSION['user'] == 'admin') && (empty($_SESSION['error_msg']))) { $v_fname = escapeshellarg($_POST['v_fname']); $v_lname = escapeshellarg($_POST['v_lname']); exec (VESTA_CMD."v-change-user-name ".$v_username." ".$v_fname." ".$v_lname, $output, $return_var); @@ -123,124 +131,41 @@ if ($_SESSION['user'] == 'admin') { $v_fname = $_POST['v_fname']; $v_lname = $_POST['v_lname']; } - - // Change NameServers - if (($v_ns1 != $_POST['v_ns1']) || ($v_ns2 != $_POST['v_ns2']) || ($v_ns3 != $_POST['v_ns3']) || ($v_ns4 != $_POST['v_ns4']) && (empty($_SESSION['error_msg']))) { - $v_ns1 = escapeshellarg($_POST['v_ns1']); - $v_ns2 = escapeshellarg($_POST['v_ns2']); - $v_ns3 = escapeshellarg($_POST['v_ns3']); - $v_ns4 = escapeshellarg($_POST['v_ns4']); - $ns_cmd = VESTA_CMD."v-change-user-ns ".$v_username." ".$v_ns1." ".$v_ns2; - if (!empty($_POST['v_ns3'])) $ns_cmd = $ns_cmd." ".$v_ns3; - if (!empty($_POST['v_ns4'])) $ns_cmd = $ns_cmd." ".$v_ns4; - exec ($ns_cmd, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('Changes has been saved.'); - } - } - // Panel - top_panel($user,$TAB); - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_user.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} else { - // Check user argument? - if (empty($_GET['user'])) { - header("Location: /list/user/"); - exit; } - // Check user - $v_username = $user; - exec (VESTA_CMD."v-list-user ".$v_username." json", $output, $return_var); - check_return_code($return_var,$output); + // Change NameServers + if (($v_ns1 != $_POST['v_ns1']) || ($v_ns2 != $_POST['v_ns2']) || ($v_ns3 != $_POST['v_ns3']) || ($v_ns4 != $_POST['v_ns4']) && (empty($_SESSION['error_msg']))) { + $v_ns1 = escapeshellarg($_POST['v_ns1']); + $v_ns2 = escapeshellarg($_POST['v_ns2']); + $v_ns3 = escapeshellarg($_POST['v_ns3']); + $v_ns4 = escapeshellarg($_POST['v_ns4']); + $ns_cmd = VESTA_CMD."v-change-user-ns ".$v_username." ".$v_ns1." ".$v_ns2; + if (!empty($_POST['v_ns3'])) $ns_cmd = $ns_cmd." ".$v_ns3; + if (!empty($_POST['v_ns4'])) $ns_cmd = $ns_cmd." ".$v_ns4; + exec ($ns_cmd, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Set success message if (empty($_SESSION['error_msg'])) { - $data = json_decode(implode('', $output), true); - unset($output); - $v_password = "••••••••"; - $v_email = $data[$v_username]['CONTACT']; - $v_fname = $data[$v_username]['FNAME']; - $v_lname = $data[$v_username]['LNAME']; - $v_language = $data[$v_username]['LANGUAGE']; - $v_ns = $data[$v_username]['NS']; - $nameservers = explode(", ", $v_ns); - $v_ns1 = $nameservers[0]; - $v_ns2 = $nameservers[1]; - $v_ns3 = $nameservers[2]; - $v_ns4 = $nameservers[3]; - $v_suspended = $data[$v_username]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - $v_time = $data[$v_username]['TIME']; - $v_date = $data[$v_username]['DATE']; - - exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var); - $languages = json_decode(implode('', $output), true); - unset($output); - + $_SESSION['ok_msg'] = __('Changes has been saved.'); } - - // Action - if (!empty($_POST['save'])) { - // Change password - if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { - $v_password = escapeshellarg($_POST['v_password']); - exec (VESTA_CMD."v-change-user-password ".$v_username." ".$v_password, $output, $return_var); - check_return_code($return_var,$output); - $v_password = "••••••••"; - unset($output); - } - - // Change language - if (($v_language != $_POST['v_language']) && (empty($_SESSION['error_msg']))) { - $v_language = escapeshellarg($_POST['v_language']); - exec (VESTA_CMD."v-change-user-language ".$v_username." ".$v_language, $output, $return_var); - check_return_code($return_var,$output); - if (empty($_SESSION['error_msg'])) $_SESSION['language'] = $_POST['v_language']; - unset($output); - } - - // Change contact email - if (($v_email != $_POST['v_email']) && (empty($_SESSION['error_msg']))) { - $v_email = escapeshellarg($_POST['v_email']); - exec (VESTA_CMD."v-change-user-contact ".$v_username." ".$v_email, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - // Change NameServers - if (($v_ns1 != $_POST['v_ns1']) || ($v_ns2 != $_POST['v_ns2']) || ($v_ns3 != $_POST['v_ns3']) || ($v_ns4 != $_POST['v_ns4']) && (empty($_SESSION['error_msg']))) { - $v_ns1 = escapeshellarg($_POST['v_ns1']); - $v_ns2 = escapeshellarg($_POST['v_ns2']); - $v_ns3 = escapeshellarg($_POST['v_ns3']); - $v_ns4 = escapeshellarg($_POST['v_ns4']); - $ns_cmd = VESTA_CMD."v-change-user-ns ".$v_username." ".$v_ns1." ".$v_ns2; - if (!empty($_POST['v_ns3'])) $ns_cmd = $ns_cmd." ".$v_ns3; - if (!empty($_POST['v_ns4'])) $ns_cmd = $ns_cmd." ".$v_ns4; - exec ($ns_cmd, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = __('Changes has been saved.'); - } - } - // Panel - top_panel($user,$TAB); - - include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_user.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); } +// Panel +top_panel($user,$TAB); + +// Display body +if ($_SESSION['user'] == 'admin') { + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_user.html'); +} else { + include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_user.html'); +} + +// Flush session messages +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); + // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); From d0e3002288bc37af7ec6b4f4de37f445bec6d555 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 30 Jul 2014 15:37:52 +0300 Subject: [PATCH 05/19] new icons --- web/images/db.png | Bin 0 -> 181 bytes web/images/edit.png | Bin 225 -> 222 bytes web/images/folder.png | Bin 0 -> 183 bytes web/images/login-as.png | Bin 2864 -> 233 bytes web/images/more.png | Bin 165 -> 176 bytes web/images/stats.png | Bin 0 -> 170 bytes 6 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 web/images/db.png create mode 100644 web/images/folder.png create mode 100644 web/images/stats.png diff --git a/web/images/db.png b/web/images/db.png new file mode 100644 index 0000000000000000000000000000000000000000..7317de69ee5bd11dc3ef436ffe93d9baa7d41301 GIT binary patch literal 181 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqoCO|{#S9GG!XV7ZFl&wkP*5S+ zBgmJ5p-Pp3p`n?9;R}#%xyZnf8_&S-B8P#&2B=XwqWL*{1yHTEr;B4q#jT{0va)#x z4;(0HXlzuR)Y#bA$tb!frHQL3X<|wO5F{lgBzQCzJxdNeaNy8^0|qbFGVn0WUdi=l TRzN#9&=>|!S3j3^P6QcVB=dL;k=fP(-4`Tqa_faw4Lbua(`>RI+y?e z7jKeZ#YO-C0Axu-K~#9!e9Ey2gFpZU(C6VAwjq05C+;COVwnMKGlSTN;1;eBQoDc~ zq)`aRCBOQg_lp>#OnOupLk2I{am6h?w76r#1Fw)^bMyf#=8!>HCh&$59qKQ9Vme3o ehv(rZ!e;>DI}oWLu-<$T`Y!+g0AWc)K~xyiZO$zYgFp}l(8s0%$ua6$$qkTjJdROh9TM5z1c}5< z$Yz&Ole}+!8g&imqhFf>N4&A4gLH!*%n`Z*IsWmC4O_aw7bg7hO@T*DV8Uz7rUvptckPy+arh(OSQe$J|LC&tk2eQJE~|)z4*}Q$iB}r(ra# literal 0 HcmV?d00001 diff --git a/web/images/login-as.png b/web/images/login-as.png index 1d7e049c7f6642e67351c9cf84c45e0ee72c211a..06a5b712291ceceba6d85d47a2f9c2f261549831 100644 GIT binary patch delta 188 zcmV;t07L(<7U=06Lfe z02gnPU&TfM003`EL_t(|+FZ@S3Bo`CMA7HEhk!K%)Ec}75jG{*hgEp=WE-}ihd@$A zEF=fX!2~w>Ffi~LW|LBah#O95@x(9qbHN!q)Tm&VTT4PN-{_|PK`}Fb!GQZ}EuzE~ q2kh}hk5|M4MK(B2slrO+6ypFT!VSG-)pFAS0000f59&ghTmgWD z0l;*TI7e|ZE3OddDgXd@nX){&BsoQaTL>+22Uk}v9w^R9 z7b_GtVFF>AKrX_0nHe&HG!NkO%m4tOkrff(gY*4(&VLTB&dxTDwhmt{>c0m6B4T3W z{^ifBa6kY6;dFk{{wy!E8h|?nfNlPwCGG@hUJIag_lst-4?wj5py}FI^KkfnJUm6A zkh$5}<>chpO2k52Vaiv1{%68pz*qfj`F=e7_x0eu;v|7GU4cgg_~63K^h~83&yop* zV%+ABM}Pdc3;+Bb(;~!4V!2o<6ys46agIcqjPo+3B8fthDa9qy|77CdEc*jK-!%ZR zYCZvbku9iQV*~a}ClFY4z~c7+0P?$U!PF=S1Au6Q;m>#f??3%Vpd|o+W=WE9003S@ zBra6Svp>fO002awfhw>;8}z{#EWidF!3EsG3xE7zHiSYX#KJ-lLJDMn9CBbOtb#%) zhRv`YDqt_vKpix|QD}yfa1JiQRk#j4a1Z)n2%fLC6RbVIkUx0b+_+BaR3c znT7Zv!AJxWizFb)h!jyGOOZ85F;a?DAXP{m@;!0_Ifqlp|(=5QHQ7#Gr)$3XMd?XsE4X&sBct1q<&fbi3VB2Ov6t@q*0);U*o*S zAPZv|vv@2aYYnT0b%8a+Cb7-ge0D0knEf5Qi#@8Tp*ce{N;6lpQuCB%KL_KOarm5c zP6_8IrP_yNQcbz0DW*G2J50yT%*~?B)|oY%Ju%lZ z=bPu7*PGwBU|M)uEVih&xMfMQuC{HqePL%}7iYJ{uEXw=y_0>qeSeMpJqHbk*$%56 zS{;6Kv~mM9! zg3B(KJ}#RZ#@)!hR=4N)wtYw9={>5&Kw=W)*2gz%*kgNq+ zEef_mrsz~!DAy_nvS(#iX1~pe$~l&+o-57m%(KedkbgIv@1Ote62cPUlD4IWOIIx& zSmwQ~YB{nzae3Pc;}r!fhE@iwJh+OsDs9zItL;~pu715HdQEGAUct(O!LkCy1 z<%NCg+}G`0PgpNm-?d@-hMgNe6^V+j6x$b<6@S<$+<4_1hi}TincS4LsjI}fWY1>O zX6feMEq|U{4wkBy=9dm`4cXeX4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC- zq*U}&`cyXV(%rRT*Z6MH?i+i&_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-N zmiuj8txj!m?Z*Ss1N{dh4z}01)YTo*JycSU)_*JOM-ImyzW$x>cP$Mz4ONYt#^NJz zM0w=t_X*$k9t}F$c8q(h;Rn+nb{%IOFKR-X@|s4QQ=0o*Vq3aT%s$c9>fU<%N829{ zoHRUHc}nwC$!Xf@g42^{^3RN&m7RTlF8SPG+oHC6=VQ*_Y7cMkx)5~X(nbG^=R3SR z&VO9;xODQe+vO8ixL2C5I$v$-bm~0*lhaSfyPUh4uDM)mx$b(swR>jw=^LIm&fWCA zdGQwi*43UlJ>9+YdT;l|_x0Zv-F|W>{m#p~*>@-It-MdXU-UrjLD@syht)q@{@mE_ z+<$7occAmp+(-8Yg@e!jk@b%cLj{kSkAKUC4TkHUI6gT!;y-fz>HMcd&t%Ugo)`Y2 z{>!cx7B7DI)$7;J(U{Spm-3gBzioV_{p!H$8L!*M!p0uH$#^p{Ui4P`?ZJ24cOCDe z-w#jZd?0@)|7iKK^;6KN`;!@ylm7$*nDhK&GcDTy000JJOGiWi{{a60|De66laV19 ze+P6)O+^RY1rrZ4JHH<&H~;_uVo5|nR0!9F%|Q(UK@ddIH@hfl1zZRM+6XETfdg(B zX$9+HN5G1J%Mb_&@Gq6rPpX+=Ds=M(Y577kqi3jhEBNkvXXu0mjfxzJZa diff --git a/web/images/more.png b/web/images/more.png index a2d6aa7c91fa1a0eeb589b3d6d54f4c016ca2f71..ce30922674e008540b835e17cfeb4a53a921cdca 100644 GIT binary patch delta 129 zcmZ3=xPftk%0y?;a)o4%AYTTCDpdxChGqtapZ|gMO9qBg0|tgy2@DKYGZ+}e^C!h0 zbz@*)F!OYA45_%4R8m%U?@WVqO=@C7!iS@a8yZ_18ymN&83d#>=`#btGZx^prw85kJYlDyqr82*Fcg1yTpPgIofWiRpcb!ET9BE)W{ zn{P5@DNvQFr;B5V#O36agoKQw1uO=S3>Nk!2?vO17zA+5l8}&KxsYMOz_7lG`TSW4 RV>zG(22WQ%mvv4FO#p(tBoY7s diff --git a/web/images/stats.png b/web/images/stats.png new file mode 100644 index 0000000000000000000000000000000000000000..c464fe6e4b68ba4d73cb5d309a505bdfbedebe76 GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqoCO|{#S9GG!XV7ZFl&wkP*5S+ zBgmJ5p-Pp3p`n?9;R}#%xyZnf8_&S-B8P#&2B=XwqWL*{1yHSlr;B4q#jT{0va&P> zrr8U(==(HuHZmj}RNg*QLwLplE%V304i{KXi2&6y{Qu9)@HL3}%Zp>1?t%E8u6{1- HoD!M Date: Wed, 30 Jul 2014 15:38:07 +0300 Subject: [PATCH 06/19] compact logo --- web/images/logo.png | Bin 5014 -> 2407 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/web/images/logo.png b/web/images/logo.png index 19acb5a434eb45303ede3cb50d287a499a734b54..9a902492d51f5e1603652e24b67852bc08d7a353 100644 GIT binary patch literal 2407 zcmV-t37GbYP)F00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru-Uka59v-xyh5i5l2=qxr zK~#9!?VDj}9LE*Me;XMWgFwBM1Q!<@U#1vbC@vRLYFtw8PUT91OCWNKO+t)=M4={S zLu&<_m;{T;H5y`EYAj-68X|BcVq#)?)VhPvQd5(oCIy4(R3-vbgF#2YU=WDuhkIL( zSG#+=x>MT^`{2-NXLe?H-h2P|e{bd>mt1nmC6`=s$)(TY^Y00e6|Qoo(EQ> z?a%qr_nBZ=t^OiV2e9P%=4*0&7Q?d4UBJh{ zX5g6Tn~7WxBN;7uc z9FxEid8eoA&Bnr-mF4;7l-26Cz}Ho$Da_~j`2&Dg8v5E+%f1$pL^ znUrOSUjs&DgR|RIXDC@8&X$UxGwb}*Tlk0~h*}b$zLh}Uhj<868CE!b^eL&*gDrME1 zjaIE(S#Th&8ljA8=$_dg$X6?D4E1JX3>fQ`)rnD6V<0xYvZM@j&}y|wg6B?QcDp^_ zobB;B2OLEqkT?U}lzA3Im5(Uz8cm2>)h-a2MM~XZsRyYhK=^p7q}Xb;*J{WY z5mXvB2@&Wmsq@VpVTOoDUGjW$ANUUNI-Mf$Qj)dD#HM~JYaxMw_EX{rQc+TdWMx^c z2E_%-z+0l6J5JxeY;$YdfR?jy9-xn5m%k#}#Kc3QRH30m^YW1QRL&Zt31Gf2k%wo1{ z#H*eq!l+tegl=v)o#@T5ayb^X`)J)F7QI{{9eQX{E@wqO7nK=YbK>b~W_*X8=DEqsD~sxgIvU z4)LljY_XNbvmOgUl=gh%0SACZ*}s~Sdfp4b&-?JOx1E$As5u^!Ie(mjZOw7ZM6>`6?mE#V9_z|5A%JaaC z)#|9E1y3Z^2c5hooJ@xEqojB>EpfvAj78A&^-|a>qmsE6x_MVPW+?|w1|@zRkgCQ_ zhspI4vtE=^)&b8qUs|nRkn$El*=lt&*m~(gG)5fwD}?f+q=INtq8gRk4GUBj9EG*l zlEaC|#2J;FmPD4G!uwf^AqKc8<(~Nw)UW?qq5NFc(_}<5|KD}O;|(BY9yss zWtJEZo9u&EErh(e6)rs`dY0##2Ue>e(%Cd@2}BJ5zn6*zboQ}cO{tt667x1m@po4Q zA-E#N;hKDJrWkrY6l=Pbn0i)Nty~FMVvrAwtiijgp`6Ng={uX`S$Mv=37iIg0{lT} zwOb1u%J6V!=p0cii#J_#Jn6dC>N(&~Qq|bz`Q~|HrD?2vA*OAXb&v?wR?G;21(FNU zT@&ZH{j4dmbb$ASp`DS1J}cY(dw};n-<(dE@DU|@zL~RHeM6LY8Tc0u58#}jb8aK8 zxES9z2n?85OrF+D>8YCHS=}6LRq1I%%0<2u2D27gyTIdG6g2{TDBn-kn~m|15~~TNsVtt-sy7?M5%X6=P+N4# zQk=5h7Wmr;T((+$EVTyhf7^_2OPC8jhBTNDKhCqP_qSZ6xrTXa%=E(qtJSYV4CR{wgUQ(S zTD`=>-QeS%Z#22|MK)yYf5Z8{A~7mBKQU^xG7`TYmutTiSj?pllIe#Da=h#pz*#BA z-jAp)x^ABTQlyX4(~s%oJmE*e7K3BcOLPjq1Hc702g~LEK&)0ujs@hBOD?(Ol1nbR Z@Ndx!Xeh;$CPx4O002ovPDHLkV1mcBl=A=p literal 5014 zcmV;H6KU*;P)R5e300009a7bBm000XU z000XU0RWnu7ytkYPiaF#P*7-ZbZ>KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z000QVNkl^<{}vT$HAkmP&(? zQ0by5HWfus6cdX|p|m8lSS*S*Wd(6j>}%QLq9A<`D9Q$FioplLN*={vpb)Zu%y;m5 zd*|ny*Ra2aS(`CDKc@QyV&p3Nb-HUMuE$QOV)0XT2?;z|8hfjgz~-x?Zw0rlZaRUNtnoMf;aD5N3dr)^pC~a9kT2 zzRU2%D}h1aAHdhz`b5q?6Nn!Gn{@qd;CA`ymvwBLH2)Cr2=EXvrE(jvS1#c+a3t#G zc09V(bSaetZ7*p6Pv7Vue|oB%NW(9NoO?;+?HS;6fxq53-y&1p6JWkS0-hAhzXTlC z;Mu1A4KdztSk~vP!)mysRc`4d@V$Wd2f!S#6k|K?sB>6#n%A9_f|znV<}=J~IH2AB z`H?J5`aWqO0_A9k-|cmD`UL@No9|BG8{k*qN4big05TY*spfun#P$6G$bLrAIv!Pr zdH-2;ddcx_V>;jJxHpM4ash7cx7GuAvts8pB4U36?gsuS0E@cjjCJ3P%>7ZB*Jow+ zKLnnT&mREx15X(McK|N{CsO$JN(dNnIxme$pD;B0c#J_-G!$VX#q-LJ`dVWQida6p z1^7aMBR~3tn0TLFxFF!~*M6Tm{*c120Y|+@ET25*h}mBe`|mV3L7dJQPGA*E0pQ`V zR^^Dg1}(5_z^LvkS*EtAV_O{cELrX8O`-9nID=_Lz-U}+ly?G83y5coP^?S7_C;+; z<%kGjhnW2_4HmzXdVtprf_E_l@LEihX=_HA`o#9FTZ}p@dap5SKx85PF$X~`z-I(N zvlVJZ5xAr>tC+n9xJ5pEgWN=$tW2A(eON9fOw0SN#+PGsO1*%$TCT;eZ(JaE>wG1H zerpY|V%^%Nllt(geD9(Fe#JwtC*NF;T#`HZr^2>>tGwC(8*zz30zY1gsTt)A z2XHOK-;ZYatWrYFk44({OZ)#I;&cl5uSV9bz&#pG=QC))21ogv<>N0BKHWMIqf>0n zn9fM!NWte zX!nFQpvION@WdK^mty1ZfS*)uwitXz#tqnqH|bIlkvpX0lfe7(_3MC}6NWCOh|!;g zc8@zcypf>W1Gy5@x&;Eh+lYSFBLTBr+mM*@Vgnko2KYf4sUKunx)S=Qazr-F){LkS$xf5{ z+xM2Q-s{lxMuG0KQssI8-)|7HdBw(y(&|kjZU-$hpM~r)Sb4j$a7nXnHLLL^Ny{=E z>vnYf&{YDx-_hPm4E_=b_$*!;)o0;;>hv()tX8|g*_3fZY|FAJ4cn@Y98yR~LM<-^ zXhuDN2eJD`gC0gYV{5sKr5B`OXYppjIvpB)OU8h|#g!8@1rfE=DlgOlcz=i`2$Ei) z$+6uQ;tm=KdKl@9;xD0q@4{P+(y1iK%QE%8T;|G2lX~T%EX$wqCTJ!#;NDSK_({xq zY~NgJKz1!kfX0y{fYdZ{fs29Y1fq z!)0x0053Km9E%IO4MHg+?e2C&4^d%gAmHak+J^8J9{OZyr=ev9#mPzKDZGyqe$jp* zAj3BgJcc&~TUDGspAzt}j9jB-)B#l1*|kLX1g&YCl6id-ZyD1GhZ%24_yPsh=M%s; z<+o?V7Z5>vNLpWz85~c^qKgR!Ln9=s>Cm)*x7zOzw#3QLp%>+6D|o9{d=2#1puY#a z!EXy4gQVF}Zjm*467NHX0X=t}k}n5Im&z@t(EcJv1Amd(y&wkvu5rE-_vb@B^3O9Oe}je&$%8R8@IKfUmZ$_a|EV)Yy*%-j@c5d!)(jI&Y_G zFX2s?>@dQ$H0#wT0y-m!iR};3(29c#_=_3G1^%Gp`Dr4A{)B+1*6IZn20QCfbC`j%9cuL5Bk z6_B-v_vnp?4r(Dpua+>R3~guJZ_DgO3RU@Af2C>FxNfs?-2sJpkINP8S*DOEN;60p z4OFcACJYzQZ9H!}CP=-8HL|bYVrcAm%y!p;Tu;;Q{?sS@A0T!s7N5fVKI|oF@d9w4 zD(?`pZUg=$^R`m{eufMdLFWGekzCUL1H=J^P}?=)eBXStNS6QI*{uBgh#0#0A!2Xd z{mUz9zYm{s_~tR-QG@W@i?_Vk%+Bp1-p2*GG)U6^$ICtgxJhaM8ta<%4iny-clq@R z_?#Ge6W+3?szY=APk<*?_Oo-jT!$vzC3_SzuM=VWSjX>{FRzl_(&k)JN>l#Vo4HBP gB?mm08%6#%0ARIQq4zv3*8l(j07*qoM6N<$g3+{p(*OVf From 9b7948b4871b6cbe6f251e59d63d9ace9ba63fff Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 30 Jul 2014 15:38:32 +0300 Subject: [PATCH 07/19] background for suspended objects --- web/images/disabled_bg.png | Bin 0 -> 194 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 web/images/disabled_bg.png diff --git a/web/images/disabled_bg.png b/web/images/disabled_bg.png new file mode 100644 index 0000000000000000000000000000000000000000..2eff4f4299b7d151a615c0809000cfecad6319dd GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^tRT$61|)m))t&+=#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*b3=G`DAk4@xYmNj^kiEpy*OmPqyAYoVixg*{JWxoo#5JPCIX^cy zHLrxhxhOTUBsE2$JhLQ2!QIn0AiR-J9H>av)5S4_<9c$61FH-V50BIfCN?0IbA;O< a0cgHu8>3QPnzas4A%mx@pUXO@geCxDaxDb_ literal 0 HcmV?d00001 From 2a02e5629cddbfacc2a2d0a2e48a516f058ae573 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 30 Jul 2014 15:38:47 +0300 Subject: [PATCH 08/19] pause icon --- web/images/pause.png | Bin 0 -> 157 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 web/images/pause.png diff --git a/web/images/pause.png b/web/images/pause.png new file mode 100644 index 0000000000000000000000000000000000000000..4120a61cb814eb14872bd2fb782d68a2c9663961 GIT binary patch literal 157 zcmeAS@N?(olHy`uVBq!ia0vp^Y(UJx0U~c5>$3n-jKx9jP7LeL$-D%~CV9KNF#HF> z1$&oI28wVNctjR6FmMZlFeAgPITAoY_7YEDSN41C{5%>AQBQozfkLvLE{-7_*OOBc r5>_NOG>B=$9zFmBM;e%U{5Top)ERryd75Sb6*73b`njxgN@xNAC}Sw6 literal 0 HcmV?d00001 From d160b441c7f99e9437273f5302024597412cc2db Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 30 Jul 2014 15:41:06 +0300 Subject: [PATCH 09/19] file manager api commands --- bin/v-copy-fs-file | 58 +++++++++++++++++++++++++++++++++++++++++ bin/v-list-fs-directory | 39 +++++++++++++++++++++++++++ bin/v-open-fs-file | 36 +++++++++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100755 bin/v-copy-fs-file create mode 100755 bin/v-list-fs-directory create mode 100755 bin/v-open-fs-file diff --git a/bin/v-copy-fs-file b/bin/v-copy-fs-file new file mode 100755 index 000000000..a3004654b --- /dev/null +++ b/bin/v-copy-fs-file @@ -0,0 +1,58 @@ +#!/bin/bash +# File copier + +user=$1 +file_src=$2 +file_dst=$3 + +# Checking arguments +if [ -z "$file_dst" ]; then + echo "Usage: USER SRC_FILE DST_FILE" + exit 1 +fi + +# Checking users +if [ ! -e "$VESTA/data/users/$user" ]; then + exit 1 +fi + +# Checking homedir +homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) +if [ -z $homedir ]; then + exit 1 +fi + +# Checking source file +if [ ! -e "$file_src" ]; then + exit 1 +fi + +# Checking source path +rpath=$(readlink -f "$file_src") +if [ -z "$(echo $rpath |grep ^/tmp)" ]; then + exit 1 +fi + +# Checking destination path +rpath=$(readlink -f "$file_dst") +if [ -z "$(echo $rpath |grep ^$homedir)" ]; then + exit 1 +fi + +# Checking dst file permission +if [ -e "$file_dst" ]; then + perms=$(stat --format '%a' $file_dst) +fi + +# Copying file +cp $file_src $file_dst + +# Changing ownership +chown $user:$user $file_dst + +# Changin permissions +if [ ! -z "$perms" ]; then + chmod $perms $file_dst +fi + +exit diff --git a/bin/v-list-fs-directory b/bin/v-list-fs-directory new file mode 100755 index 000000000..a06b4168d --- /dev/null +++ b/bin/v-list-fs-directory @@ -0,0 +1,39 @@ +#!/bin/bash +# File list wrapper + +user=$1 +path=$2 + +# Checking arguments +if [ -z "$user" ]; then + echo "Usage: USER [PATH]" + exit 1 +fi + +# Checking users +if [ ! -e "$VESTA/data/users/$user" ]; then + exit 1 +fi + +# Checking homedir +homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) +if [ -z $homedir ]; then + exit 1 +fi + +# Checking path +if [ ! -z "$path" ]; then + # Validating absolute path + rpath=$(readlink -f "$path") + if [ -z "$(echo $rpath |grep $homedir)" ]; then + exit 1 + fi +else + path=$homedir +fi + +# Listing files +find "$path" -maxdepth 1 -printf "%y/%m/%TY-%Tm-%Td/%TH:%TM:%TS/%u/%g/%s/%P\n" + + +exit diff --git a/bin/v-open-fs-file b/bin/v-open-fs-file new file mode 100755 index 000000000..d5c8ea3a6 --- /dev/null +++ b/bin/v-open-fs-file @@ -0,0 +1,36 @@ +#!/bin/bash +# File reader + +user=$1 +path=$2 + +# Checking arguments +if [ -z "$path" ]; then + echo "Usage: USER PATH" + exit 1 +fi + +# Checking users +if [ ! -e "$VESTA/data/users/$user" ]; then + exit 1 +fi + +# Checking homedir +homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :) +if [ -z $homedir ]; then + exit 1 +fi + +# Checking path +if [ ! -z "$path" ]; then + # Validating absolute path + rpath=$(readlink -f "$path") + if [ -z "$(echo $rpath |grep $homedir)" ]; then + exit 1 + fi +fi + +cat "$path" + +exit + From a34da7e2432b8477348995e16d117ba99739bc41 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 30 Jul 2014 15:41:21 +0300 Subject: [PATCH 10/19] new icon for webmail --- web/images/mail.png | Bin 0 -> 236 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 web/images/mail.png diff --git a/web/images/mail.png b/web/images/mail.png new file mode 100644 index 0000000000000000000000000000000000000000..1281299b94a8d479d84a346d2b84b43086d3088b GIT binary patch literal 236 zcmeAS@N?(olHy`uVBq!ia0vp^oIuRM!3HF?&tBaM5-9M9EM{Qf76xHPhFNnYfPxCi z9znhg3{|QO3=Pc;3}1kB%S8r;+;|3t7dZ?JHr)&i(h<$i*(-o*i#%N%Ln>~yTrlK1 zmdKI;Vst06V%(?f?J) literal 0 HcmV?d00001 From 0797ddfddb1ec695f69c074a666a2b0fcb704c88 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 30 Jul 2014 15:44:06 +0300 Subject: [PATCH 11/19] Improved css style --- web/css/jquery-custom-dialogs.css | 12 +- web/css/main.css | 411 ++++++++++++++++++++++++------ 2 files changed, 337 insertions(+), 86 deletions(-) diff --git a/web/css/jquery-custom-dialogs.css b/web/css/jquery-custom-dialogs.css index f1a4fa752..f0cb265ab 100644 --- a/web/css/jquery-custom-dialogs.css +++ b/web/css/jquery-custom-dialogs.css @@ -35,7 +35,7 @@ ----------------------------------*/ /* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #e6e6e6;} +.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #999;} /*! @@ -58,7 +58,7 @@ .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Arial, Helvetica, sans-serif; font-size: 10pt; } .ui-widget-content { border: 1px solid #aaaaaa; color: #222222; } .ui-widget-content a { color: #222222; } -.ui-widget-header { background: #505050; color: #444; font-size: 10pt; font-weight: bold;} +.ui-widget-header { background: #777; color: #444; font-size: 10pt; font-weight: bold;} .ui-widget-header a { color: #222222; } /* Interaction Cues @@ -75,14 +75,14 @@ /* Icons ----------------------------------*/ -/* states and images */ +/* states and images .ui-icon { width: 16px; height: 16px; } .ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png); } .ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); } .ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); } .ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); } .ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); } - +*/ /* positioning */ .ui-icon-carat-1-n { background-position: 0 0; } @@ -376,8 +376,8 @@ * http://docs.jquery.com/UI/Button#theming */ .ui-button { display: inline-block; position: relative; padding: 0; margin-right: .10pt; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */ -.ui-button { filter:chroma(color=#000000); cursor: pointer; color: #555; background-color: #ececec; border: 1px solid #e0e0e0; border-radius: 3px 3px 3px 3px; font-weight: bold; font-size: 14px; padding: 2px 16px; width: 108px; height: 34px; } -.ui-button:hover { border: 1px solid #f79b44; background-color: #f79b44; color: #fff;} +.ui-button { filter:chroma(color=#000000); cursor: pointer; color: #fff; background-color: #f79b44; border: 1px solid #f79b44; border-radius: 3px 3px 3px 3px; font-weight: bold; font-size: 14px; padding: 2px 16px; width: 108px; height: 34px; } +.ui-button:hover { border: 1px solid #9e9e9e; background-color: #9e9e9e; color: #fff;} .ui-button:active { background-color: #ccc; color: #fff; border: 1px solid #ccc; } .ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */ button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */ diff --git a/web/css/main.css b/web/css/main.css index b2a114e83..4e2c6ecfb 100644 --- a/web/css/main.css +++ b/web/css/main.css @@ -1,6 +1,6 @@ body { font-family: Arial, Helvetica, sans-serif; - background-color: #e1e8e8; + background-color: #75b0c5; margin: 0; padding: 0; border: 0; @@ -19,6 +19,9 @@ td { padding: 0; } +label { + cursor: pointer; +} .hidden { display: none; @@ -26,13 +29,33 @@ td { .top { width: 1000px; - position: fixed; background: #fff; - border-bottom: 1px solid #e1e8e8; } +.top.small .submenu{ + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.10); +} + + +.top .nav-logo .logo-container{ + background-color: #fff; + width: 167px; +} + +.top.small-logo .nav-logo .logo-container{ + position: fixed; +} +.top.small-logo .nav-logo img{ + margin: 29px 0 -4px 10px; + padding: 0 0 10px; +} + + .top-menu { height: 24px; background-color: #505050; + width: 1000px; + position: fixed; + z-index: 10; } .top-link { @@ -51,9 +74,9 @@ td { background-color: #f79b44; } -.top-link:active{ +.top-link:active { color: #333; - background-color: #f1f1f1; + background-color: #eee; } .top-selected-link { @@ -65,7 +88,7 @@ td { line-height: 22px; padding: 0 20px 2px; color: #333; - background-color: #f0f0f0; + background-color: #eee; } .top-selected-link:hover { @@ -75,7 +98,7 @@ td { .top-selected-link:active { color: #2361a1; - background-color: #f1f1f1; + background-color: #eee; } .top-user { @@ -93,7 +116,7 @@ td { color: #fff; } -.top-user:active{ +.top-user:active { color: #fff; background-color: #f79b44; } @@ -120,12 +143,21 @@ td { background-color: #999; } +.main-menu{ + display: block; + float: left; + margin-bottom: 1px; +} + .nav-logo { float: left; - height: 111px; + height: 139px; width: 167px; - margin: 0; - border-bottom: 1px solid #e1e8e8; + margin: 0 0 0px; +} + +.nav-logo img{ + margin: 56px 0 0 10px; } .nav-lnk { @@ -145,59 +177,96 @@ td { width: 119px; float:left; cursor: pointer; - border-bottom: 1px solid #e1e8e8; + padding-bottom: 2px; } .nav-block:hover { height:108px; - border-bottom: 4px solid #f79b44; + padding-bottom: 0; } .nav-selected-block { + padding-bottom: 0; font-family: Arial, Helvetica, sans-serif; margin: 0; - color: #2361a1; + color: #4a82be; height: 108px; width: 119px; float: left; - border-bottom: 4px solid #777777; cursor: pointer; } .nav-selected-block:hover { height:108px; - border-bottom: 4px solid #f79b44; } .nav-selected-block:active { color: #f79b44; } -.nav-header { - padding: 14px 0 0 6px; - margin: 0; - letter-spacing: -1.0px; - font-size: 16pt; - font-weight: bold; +.top .nav-block .marker, +.top .nav-selected-block .marker { + -webkit-transition: background .1s ease-in-out; + -moz-transition: background .1s ease-in-out; + -o-transition: background .1s ease-in-out; + transition: background .1s ease-in-out; + padding: 0; + height: 4px; + margin: 12px 0 0 0; + width: 100%; + background-color: #fff; } -.nav-selected-header { - padding: 14px 0 0 6px; - margin: 0; - letter-spacing: -1.0px; +.top .nav-selected-block .marker { + background-color: #777; + border-bottom: 1px solid #777; +} + +.top.small .marker{ + position: fixed; + top: 66px; + width: 119px; +} + +.nav-block:hover .marker{ + background-color: #f79b44; + border-bottom: 1px solid #f79b44; +} + +.nav-selected-block:hover .marker{ + background-color: #f79b44; + border-bottom: 1px solid #f79b44; +} + +.nav-header, .nav-selected-header { + background-color: #FFF; font-size: 16pt; font-weight: bold; + height: 27px; + letter-spacing: -1px; + margin: 0; + padding: 16px 0 0 6px; + position: fixed; + top: 24px; + width: 113px; + z-index: 10; +} + +.top.small .nav-header, .top.small .nav-selected-header{ + height: 38px; } .nav-counters { padding: 1px 0 0 6px; - margin: 0; + margin: 65px 0 0 0; height: 58px; line-height: 1.4em; font-size: 9pt; font-family: Arial, Helvetica, sans-serif; color: #333; decoration: none; + overflow: hidden; + opacity: 0.8; } .submenu { @@ -205,6 +274,19 @@ td { vertical-align: middle; float: left; width: 1000px; + border-bottom: 1px solid #e1e8e8; + border-top: 1px solid #e1e8e8; + background-color: #fff; + margin-bottom: -1px; +} + +.top.small .submenu{ + position: fixed; + top: 82px; +} + +.submenu .wrapper{ + padding: 11px 10px 14px 10px; } .submenu-button-block { @@ -226,7 +308,7 @@ td { } .submenu-button-select { - width: 20px; + width: 28px; height: 28px; cursor: pointer; color: #555; @@ -273,16 +355,26 @@ td { } .submenu-button-main:hover { - border: 1px solid #999; - background-color: #999; + border: 1px solid #aaa; + background-color: #adaeae; + + -webkit-transition: background .1s ease-in-out; + -moz-transition: background .1s ease-in-out; + -o-transition: background .1s ease-in-out; + transition: background .1s ease-in-out; } .submenu-button-select:hover { - border: 1px solid #f79b44; + border: 1px solid #adaeae; + background-color: #adaeae; + color: #fff; } .submenu-button-search:hover { - border: 1px solid #f79b44; + border: 1px solid #adaeae; + background-color: #adaeae; + color: #fff; + } .submenu-button-main:active { @@ -308,7 +400,7 @@ td { } .submenu-select-link { - color: #6A6A6A; + color: #6a6a6a; display: block; float: left; font-size: 8pt; @@ -331,21 +423,34 @@ td { .submenu-select-dropdown { font-family:Arial, Helvetica, sans-serif; font-size: 9pt; - color: #333333; + color: #333; display: block; float: left; height: 28px; margin: 0 4px 0 0; min-width: 138px; - background-color: #FFFFFF; - border: 1px solid #CCCCCC; + background-color: #fff; + border: 1px solid #ccc; border-radius: 3px 3px 3px 3px; padding: 4px 5px; } + +.submenu-select-dropdown:hover { + border: 1px solid #909090; +} + +.submenu-select-dropdown:focus { + border: 1px solid #f79b44; + background-color: #fffcd2; + color: #333; +} + + .submenu-select-dropdown option { padding: 5px 5px 5px 8px; } + .submenu-search-block { display: block; text-align: right; @@ -366,11 +471,13 @@ td { } .submenu-search-field:hover { - border: 1px solid #f79b44; + border: 1px solid #909090; } .submenu-search-field:focus { border: 1px solid #f79b44; + background-color: #FFFCD2; + color: #333; } .bottom { @@ -404,11 +511,11 @@ td { } .vst { - padding: 4px 4px 0 4px; + padding: 5px 7px 0 7px; margin: 0; text-decoration: none; color: #999; - font-size: 12pt; + font-size: 11pt; float: left; } @@ -422,11 +529,11 @@ td { } .vst-selected { - padding: 4px 4px 0 4px; + padding: 5px 7px 0 7px; margin: 0; text-decoration: none; color: #2361a1; - font-size: 12pt; + font-size: 11pt; float: left; } @@ -449,21 +556,18 @@ td { font-size: 12pt; text-align: left; vertical-align:top; - margin: 0; + margin: 1px 0 0 0; behavior:url("/css/csshover3.htc"); + background-color: #fff } .data a { text-decoration: none; } -.data-row:hover { - margin: 0; - background-color: #f0f0f0; -} -.data-row:active { - background-color: #f7f7d8; +.data-row.selected, .data-row.selected.suspended{ + background-color: #e4e9e9; } .datarowhover { @@ -530,7 +634,7 @@ td { .data-date { letter-spacing: 0.3em; font-size: 8pt; - color: #6A6A6A + color: #6a6a6a } .data-active { @@ -550,26 +654,36 @@ td { height: 16px; border-left: 1px solid #d3d3d3; font-size: 8pt; - padding: 2px 12px 1px 6px; + padding: 6px 11px 2px; letter-spacing: 0.1em; - color: #2361a1; + color: #3e7c91; text-decoration: none; cursor: pointer; } +.data-controls.edit{ + font-weight: bold; + letter-spacing: 0; +} + .data-controls:hover { color: #fff; background-color: #f79b44; } .data-controls:active { - background-color: #999 + background-color: #999; } + .data-controls img { border: 0px; } +.ch-toggle { + cursor: pointer; +} + .data-count { font-family: Arial, Helvetica, sans-serif; color: #505050; @@ -599,6 +713,14 @@ td { padding: 1px 0 2px 0; } +.suspended .domain { + color: #777; +} + +.domain.hostname { + font-size: 16pt; +} + .cron { color: #222; font-size: 18px; @@ -675,17 +797,17 @@ td { .vst-ok { font-size: 12pt; - color: #62a358; + color: #33691e; padding: 4px; } -.vst-ok a{ - color: #58934f; - text-decoration: none; +.vst-ok a { + color: #33691e; } -.vst-ok a:hover{ - text-decoration: underline; +.vst-ok a:hover { + background: #f79b44; + color: #fff; } .vst-error { @@ -713,11 +835,13 @@ td { } .vst-textinput:hover { - border: 1px solid #f79b44; + border: 1px solid #909090; } .vst-textinput:focus { border: 1px solid #f79b44; + background-color: #fffcd2; + color: #333; } .vst-textinput:disabled { @@ -737,17 +861,23 @@ td { } .vst-input:hover { - border: 1px solid #f79b44; + border: 1px solid #909090; } .vst-input:focus { border: 1px solid #f79b44; + background-color: #fffcd2; + color: #333; } .vst-input:disabled { background-color: #f1f1f1; } +.vst-input.long{ + width: 580px; +} + .vst-list { font-family:Arial, Helvetica, sans-serif; font-size: 12pt; @@ -767,7 +897,7 @@ td { padding: 5px; font-size: 12pt; border: 1px solid #f7f6ed; - margin: 2px 6px 0 0; + margin: 2px 6px 0 3px; } .vst-checkbox:hover { @@ -775,23 +905,23 @@ td { } .button { - filter:chroma(color=#000000); + filter:chroma(color=#000); cursor: pointer; border-radius: 3px 3px 3px 3px; - font-size: 14px; + font-size: 13px; font-weight: bold; - padding: 2px 16px; + padding: 1px 16px 3px 16px; width: 108px; height: 34px; - color: #555; - background-color: #fff; - border: 1px solid #ccc; + color: #fafafa; + border: 1px solid #f79b44; + background-color: #f79b44; } .button:hover { color: #fff; - border: 1px solid #f79b44; - background-color: #f79b44; + border: 1px solid #999; + background-color: #999; } .button:active { @@ -800,7 +930,7 @@ td { } .login-button { - filter:chroma(color=#000000); + filter:chroma(color=#000); cursor: pointer; border-radius: 3px 3px 3px 3px; font-size: 14px; @@ -809,14 +939,13 @@ td { width: 108px; height: 34px; color: #fff; - background-color: #999; - border: 1px solid #999; + background-color: #f79b44; + border: 1px solid #f79b44; } .login-button:hover { - color: #fff; - border: 1px solid #f79b44; - background-color: #f79b44; + border: 1px solid #adaeae; + background-color: #adaeae; } .login-button:active { @@ -864,7 +993,7 @@ td { background-color: #777; } -.fixed{ +.fixed { position: fixed; border: none; top: -3px; @@ -872,7 +1001,7 @@ td { background-color: #fff; } -*html .fixed{ +*html .fixed { position:absolute; position:fixed; _position:absolute; @@ -880,7 +1009,7 @@ td { _top:expression( eval(document.body.scrollTop) + 'px' ); } -#vstobjects{ +#vstobjects { padding-top: 193px; min-height: 372px; } @@ -911,7 +1040,7 @@ td { padding: 0 26px 0 0; } -.vestacp{ +.vestacp { font-size: 8pt; color: #505050; text-align: right; @@ -919,10 +1048,132 @@ td { .error { font-size: 10pt; - color: #dE6c5d; + color: #de6c5d; } .hint { font-size: 14pt; color: #7fa1cb; } + +.step-top { + padding-top: 42px; +} + +.step-bottom { + padding-bottom: 20px; +} + +.step-left { + padding-left: 50px; +} + +.input-label { + padding-top: 20px; +} + +.additional-control { + margin-left: 20px; + color: #2361a1; + border-bottom: 1px solid #f79b44; + font-size: 10pt; + letter-spacing: 0.1em; + cursor: pointer; +} + +.additional-control:hover { + color: #7fa1cb; +} + +.additional-control:active { + color: #fff; + background-color: #f79b44; +} + +.ftp-path-prefix { + color: #848483; + font-size: 13px; +} + +.ftp-path-value { + color: #333; + font-size: 13px; + font-weight: bold; +} + +.data .suspended { + background: url(/images/disabled_bg.png); +} + +.timer-container .refresh-timer { + border: 2px solid #c0d4a6; + border-radius: 14px; + height: 14px; + width: 14px; + margin: 10px; + float: left; + margin: 7px 10px 0 0; +} + +.timer-container .refresh-timer.paused{ + border: 2px solid #9f9f9f; +} + +.timer-container .refresh-timer.paused .loader-half.right, +.timer-container .refresh-timer.paused .loader-half.dark{ + background-color: #9F9F9F; +} + +.timer-container .loader-half { + border-radius: 0 14px 14px 0; + height: 14px; + width: 7px; + float: left; +} + +.timer-container .loader-half.left { + border-radius: 14px 0 0 14px; + background-color: #fff; +} + +.timer-container .loader-half.right { + margin-left: 7px; + background-color: #c0d4a6; +} + +.timer-container .loader-half.dark{ + background-color: #c0d4a6; +} + +.timer-container .movement{ + float: left; + width: 14px; + height: 14px; + position: absolute; +} + +.timer-container .movement.left { + z-index: 10; +} + +.timer-container .movement.right{ + transform: rotate(180deg); + -webkit-transform: rotate(180deg); +} + +.timer-container .timer-button{ + cursor: pointer; + text-decotation: underline; + margin: 11px 0 0 38px; + width: 15px; + float: left; + height: 10px; +} + +.timer-container .timer-button.pause{ + background: url(/images/pause.png) no-repeat ; +} + +.timer-container .timer-button.play{ + background: url(/images/start.png) no-repeat; +} From 393d97fdfc49ce7d7eb350c7ac7de6bfecf9ccdc Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 30 Jul 2014 15:48:20 +0300 Subject: [PATCH 12/19] Multiple FTP Account Support --- web/js/pages/add.web.js | 157 ++++++++++++++++++++++++++++++++++----- web/js/pages/edit.web.js | 131 +++++++++++++++++++++++++++++--- web/js/templates.js | 6 +- 3 files changed, 262 insertions(+), 32 deletions(-) diff --git a/web/js/pages/add.web.js b/web/js/pages/add.web.js index 8b06b14a0..d350a4375 100644 --- a/web/js/pages/add.web.js +++ b/web/js/pages/add.web.js @@ -1,37 +1,158 @@ -// -// -// Updates ftp username dynamically, showing its prefix App.Actions.WEB.update_ftp_username_hint = function(elm, hint) { if (hint.trim() == '') { $(elm).parent().find('.hint').html(''); - } - // remove prefix from value in order to eliminate duplicates + } + + hint = hint.replace(/[^\w\d]/gi, ''); + if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) { hint = hint.slice(GLOBAL.FTP_USER_PREFIX.length, hint.length); } - + $(elm).parent().find('.v-ftp-user').val(hint); $(elm).parent().find('.hint').text(GLOBAL.FTP_USER_PREFIX + hint); } -// -// listener that triggers ftp user hint updating App.Listeners.WEB.keypress_ftp_username = function() { - var ref = $('input[name="v_ftp_user"]'); - var current_val = ref.val(); - if (current_val.trim() != '') { - App.Actions.DB.update_ftp_username_hint(ref, current_val); - } - - ref.bind('keypress input', function(evt) { + var ftp_user_inputs = $('.v-ftp-user'); + $.each(ftp_user_inputs, function(i, ref) { + var ref = $(ref); + var current_val = ref.val(); + if (current_val.trim() != '') { + App.Actions.WEB.update_ftp_username_hint(ref, current_val); + } + + ref.bind('keypress', function(evt) { + clearTimeout(window.frp_usr_tmt); + window.frp_usr_tmt = setTimeout(function() { + var elm = $(evt.target); + App.Actions.WEB.update_ftp_username_hint(elm, $(elm).val()); + }, 100); + }); + }); +} + +App.Listeners.WEB.keypress_domain_name = function() { + $('#v_domain').bind('keypress', function(evt) { clearTimeout(window.frp_usr_tmt); window.frp_usr_tmt = setTimeout(function() { - var elm = $(evt.target); - App.Actions.WEB.update_ftp_username_hint(elm, $(elm).val()); + //var elm = $(evt.target); + //App.Actions.WEB.update_ftp_username_hint(elm, $(elm).val()); + var domain = $('.ftp-path-prefix').text(GLOBAL.FTP_USER_PREPATH + '/' + $('#v_domain').val()); }, 100); }); } +// +// + +App.Actions.WEB.update_ftp_path_hint = function(elm, hint) { + if (hint.trim() == '') { + $(elm).parent().find('.v-ftp-path-hint').html(''); + } + + if (hint[0] != '/') { + hint = '/' + hint; + } + hint = hint.replace(/\/(\/+)/g, '/'); + + $(elm).parent().find('.v-ftp-path-hint').text(hint); +} + +App.Listeners.WEB.keypress_ftp_path = function() { + var ftp_path_inputs = $('.v-ftp-path'); + $.each(ftp_path_inputs, function(i, ref) { + var ref = $(ref); + var current_val = ref.val(); + if (current_val.trim() != '') { + App.Actions.WEB.update_ftp_path_hint(ref, current_val); + } + + ref.bind('keypress', function(evt) { + clearTimeout(window.frp_usr_tmt); + window.frp_usr_tmt = setTimeout(function() { + var elm = $(evt.target); + App.Actions.WEB.update_ftp_path_hint(elm, $(elm).val()); + }, 100); + }); + }); +} + +// +// +App.Actions.WEB.add_ftp_user_form = function() { + var ref = $('#templates').find('.ftptable').clone(true); + var index = $('.data-col2 .ftptable').length + 1; + + ref.find('input').each(function(i, elm) { + var attr_value = $(elm).attr('name').replace('%INDEX%', index); + $(elm).attr('name', attr_value); + }); + + ref.find('.ftp-user-number').text(index); + + $('.data-col2 .ftptable:last').after(ref); + + var index = 1; + $('.data-col2 .ftp-user-number:visible').each(function(i, o) { + $(o).text(index); + index += 1; + }); +} + +App.Actions.WEB.remove_ftp_user = function(elm) { + var ref = $(elm).parents('.ftptable'); + ref.remove(); + + var index = 1; + $('.data-col2 .ftp-user-number:visible').each(function(i, o) { + $(o).text(index); + index += 1; + }); + + if ($('.ftptable-nrm:visible').length == 0) { + $('.v-add-new-user').hide(); + $('input[name="v_ftp"]').attr('checked', false); + } +} + + +App.Actions.WEB.toggle_additional_ftp_accounts = function(elm) { + if ($(elm).attr('checked')) { + $('.ftptable-nrm, .v-add-new-user, .add-new-ftp-user-button').show(); + $('.ftptable-nrm').each(function(i, elm) { + var login = $(elm).find('.v-ftp-user'); + if (login.val().trim() != '') { + $(elm).find('.v-ftp-user-deleted').val(0); + } + }); + } + else { + $('.ftptable-nrm, .v-add-new-user, .add-new-ftp-user-button').hide(); + $('.ftptable-nrm').each(function(i, elm) { + var login = $(elm).find('.v-ftp-user'); + if (login.val().trim() != '') { + $(elm).find('.v-ftp-user-deleted').val(1); + } + }); + } + + if ($('.ftptable-nrm:visible').length == 0) { + var ref = $('#templates').find('.ftptable').clone(true); + var index = $('.data-col2 .ftptable').length + 1; + + ref.find('input').each(function(i, elm) { + var attr_value = $(elm).attr('name').replace('%INDEX%', index); + $(elm).attr('name', attr_value); + }); + + ref.find('.ftp-user-number').text(index); + + $('.v-add-new-user').parent('tr').prev().find('td').html(ref); + } +} + // // Page entry point -// Trigger listeners App.Listeners.WEB.keypress_ftp_username(); +App.Listeners.WEB.keypress_ftp_path(); +App.Listeners.WEB.keypress_domain_name(); diff --git a/web/js/pages/edit.web.js b/web/js/pages/edit.web.js index fc9be3fcf..5d8ede2f2 100644 --- a/web/js/pages/edit.web.js +++ b/web/js/pages/edit.web.js @@ -1,29 +1,138 @@ App.Actions.WEB.update_ftp_username_hint = function(elm, hint) { if (hint.trim() == '') { $(elm).parent().find('.hint').html(''); - } + } + + hint = hint.replace(/[^\w\d]/gi, ''); + if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) { hint = hint.slice(GLOBAL.FTP_USER_PREFIX.length, hint.length); } + $(elm).parent().find('.v-ftp-user').val(hint); $(elm).parent().find('.hint').text(GLOBAL.FTP_USER_PREFIX + hint); } App.Listeners.WEB.keypress_ftp_username = function() { - var ref = $('input[name="v_ftp_user"]'); - var current_val = ref.val(); - if (current_val.trim() != '') { - App.Actions.DB.update_ftp_username_hint(ref, current_val); + var ftp_user_inputs = $('.v-ftp-user'); + $.each(ftp_user_inputs, function(i, ref) { + var ref = $(ref); + var current_val = ref.val(); + if (current_val.trim() != '') { + App.Actions.WEB.update_ftp_username_hint(ref, current_val); + } + + ref.bind('keypress', function(evt) { + clearTimeout(window.frp_usr_tmt); + window.frp_usr_tmt = setTimeout(function() { + var elm = $(evt.target); + App.Actions.WEB.update_ftp_username_hint(elm, $(elm).val()); + }, 100); + }); + }); +} + +// +// + +App.Actions.WEB.update_ftp_path_hint = function(elm, hint) { + if (hint.trim() == '') { + $(elm).parent().find('.v-ftp-path-hint').html(''); + } + + if (hint[0] != '/') { + hint = '/' + hint; } - ref.bind('keypress', function(evt) { - clearTimeout(window.frp_usr_tmt); - window.frp_usr_tmt = setTimeout(function() { - var elm = $(evt.target); - App.Actions.WEB.update_ftp_username_hint(elm, $(elm).val()); - }, 100); + hint = hint.replace(/\/(\/+)/g, '/'); + + $(elm).parent().find('.v-ftp-path-hint').text(hint); +} + +App.Listeners.WEB.keypress_ftp_path = function() { + var ftp_path_inputs = $('.v-ftp-path'); + $.each(ftp_path_inputs, function(i, ref) { + var ref = $(ref); + var current_val = ref.val(); + if (current_val.trim() != '') { + App.Actions.WEB.update_ftp_path_hint(ref, current_val); + } + + ref.bind('keypress', function(evt) { + clearTimeout(window.frp_usr_tmt); + window.frp_usr_tmt = setTimeout(function() { + var elm = $(evt.target); + App.Actions.WEB.update_ftp_path_hint(elm, $(elm).val()); + }, 100); + }); }); } +// +// +App.Actions.WEB.add_ftp_user_form = function() { + var ref = $('#templates').find('.ftptable').clone(true); + var index = $('.data-col2 .ftptable').length + 1; + + ref.find('input').each(function(i, elm) { + var attr_value = $(elm).attr('name').replace('%INDEX%', index); + $(elm).attr('name', attr_value); + }); + + ref.find('.ftp-user-number').text(index); + + $('.data-col2 .ftptable:last').after(ref); + + var index = 1; + $('.data-col2 .ftp-user-number:visible').each(function(i, o) { + $(o).text(index); + index += 1; + }); +} + +App.Actions.WEB.remove_ftp_user = function(elm) { + var ref = $(elm).parents('.ftptable'); + ref.find('.v-ftp-user-deleted').val('1'); + if (ref.find('.v-ftp-user-is-new').val() == 1) { + ref.remove(); + return true; + } + ref.removeClass('ftptable-nrm'); + ref.hide(); + + var index = 1; + $('.data-col2 .ftp-user-number:visible').each(function(i, o) { + $(o).text(index); + index += 1; + }); + + if ($('.ftptable-nrm:visible').length == 0) { + $('.add-new-ftp-user-button').hide(); + $('input[name="v_ftp"]').attr('checked', false); + } +} + +App.Actions.WEB.toggle_additional_ftp_accounts = function(elm) { + if ($(elm).attr('checked')) { + $('.ftptable-nrm, .v-add-new-user, .add-new-ftp-user-button').show(); + $('.ftptable-nrm').each(function(i, elm) { + var login = $(elm).find('.v-ftp-user'); + if (login.val().trim() != '') { + $(elm).find('.v-ftp-user-deleted').val(0); + } + }); + } + else { + $('.ftptable-nrm, .v-add-new-user, .add-new-ftp-user-button').hide(); + $('.ftptable-nrm').each(function(i, elm) { + var login = $(elm).find('.v-ftp-user'); + if (login.val().trim() != '') { + $(elm).find('.v-ftp-user-deleted').val(1); + } + }); + } +} + // // Page entry point App.Listeners.WEB.keypress_ftp_username(); +App.Listeners.WEB.keypress_ftp_path(); diff --git a/web/js/templates.js b/web/js/templates.js index ee5aeda60..e91f2f799 100644 --- a/web/js/templates.js +++ b/web/js/templates.js @@ -66,7 +66,7 @@ var Templator = function() { 'undefined' == typeof App.Templates._indexes[key] ? App.Templates._indexes[key] = {} : false; 'undefined' == typeof App.Templates._indexes[key][ref_key] ? - App.Templates._indexes[key][ref_key] = {} : false; + App.Templates._indexes[key][ref_key] = {} : false; jQuery(tpl).each(function(index, o) { if (':' == o.charAt(0)) { @@ -84,8 +84,8 @@ var Templator = function() Templator.getTemplate = function(ns, key){ return [ - App.Templates._indexes[ns][key], - App.Templates.html[ns][key].slice(0) + App.Templates._indexes[ns][key], + App.Templates.html[ns][key].slice(0) ]; } // init templator From 6718bdd926aae04b13b01944844a10ed188fb19c Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 30 Jul 2014 15:49:14 +0300 Subject: [PATCH 13/19] Renamed dialog button --- web/js/events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/js/events.js b/web/js/events.js index f183ba831..881eadcfa 100644 --- a/web/js/events.js +++ b/web/js/events.js @@ -102,7 +102,7 @@ VE.helpers.createConfirmationDialog = function(elm, dialog_title, confirmed_loca $(this).dialog("destroy"); }, buttons: { - "Ok": function(event, ui) { + "OK": function(event, ui) { location.href = confirmed_location_url; }, "Cancel": function() { From ff9cb08425ce44254c96537e6bac04a06a250229 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 30 Jul 2014 15:51:22 +0300 Subject: [PATCH 14/19] scrollable top panel --- web/templates/admin/panel.html | 15 ++++- web/templates/header.html | 114 ++++++++++++++++++++++++++++++++- web/templates/user/panel.html | 15 ++++- 3 files changed, 137 insertions(+), 7 deletions(-) diff --git a/web/templates/admin/panel.html b/web/templates/admin/panel.html index ee9ffef3f..968b5fc0f 100644 --- a/web/templates/admin/panel.html +++ b/web/templates/admin/panel.html @@ -15,9 +15,11 @@ -
+ diff --git a/web/templates/header.html b/web/templates/header.html index 56580bd2a..70fe7ee45 100644 --- a/web/templates/header.html +++ b/web/templates/header.html @@ -41,8 +41,10 @@ var valus= document.getElementById(frmname); if (checked==false) { checked=true; + $('.data-row').addClass("selected"); } else { checked = false; + $('.data-row').removeClass("selected"); } for (var i =0; i < valus.elements.length; i++) { valus.elements[i].checked=checked; @@ -51,8 +53,40 @@ - + \ No newline at end of file diff --git a/web/templates/user/panel.html b/web/templates/user/panel.html index 80d4e8c92..fb6af499d 100644 --- a/web/templates/user/panel.html +++ b/web/templates/user/panel.html @@ -10,9 +10,11 @@
-
+ +
\ No newline at end of file From f42face68d91ea12e8528bdfb454ebe0c8cc6ca4 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 30 Jul 2014 15:54:18 +0300 Subject: [PATCH 15/19] Multiftp support --- web/add/web/index.php | 591 +++++++++++++++++------------- web/edit/web/index.php | 440 ++++++++++++++-------- web/templates/admin/add_web.html | 274 ++++++++------ web/templates/admin/edit_web.html | 232 ++++++++---- web/templates/user/edit_web.html | 227 ++++++++---- 5 files changed, 1094 insertions(+), 670 deletions(-) diff --git a/web/add/web/index.php b/web/add/web/index.php index 0c13cf58e..63d8d792b 100644 --- a/web/add/web/index.php +++ b/web/add/web/index.php @@ -4,277 +4,350 @@ error_reporting(NULL); ob_start(); session_start(); $TAB = 'WEB'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); +// Check POST request +if (!empty($_POST['ok'])) { + + // Check for empty fields + if (empty($_POST['v_domain'])) $errors[] = __('domain'); + if (empty($_POST['v_ip'])) $errors[] = __('ip'); + 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($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); + } + + // Check stats password length + if ((!empty($v_stats)) && (empty($_SESSION['error_msg']))) { + if (!empty($_POST['v_stats_user'])) { + $pw_len = strlen($_POST['v_stats_password']); + if ($pw_len < 6 ) $_SESSION['error_msg'] = __('Password is too short.',$error_msg); + } + } + + // Default proxy extention list + $v_proxy_ext = 'jpeg, jpg, png, gif, bmp, ico, svg, tif, tiff, css, js, htm, html, ttf, '; + $v_proxy_ext .= 'otf, webp, woff, txt, csv, rtf, doc, docx, xls, xlsx, ppt, pptx, odf, '; + $v_proxy_ext .= 'odp, ods, odt, pdf, psd, ai, eot, eps, ps, zip, tar, tgz, gz, rar, '; + $v_proxy_ext .= 'bz2, 7z, aac, m4a, mp3, mp4, ogg, wav, wma, 3gp, avi, flv, m4v, mkv, '; + $v_proxy_ext .= 'mov, mp4, mpeg, mpg, wmv, exe, iso, dmg, swf'; + + // Set advanced option checkmark + if (empty($_POST['v_proxy'])) $v_adv = 'yes'; + if (!empty($_POST['v_ftp'])) $v_adv = 'yes'; + if ($_POST['v_proxy_ext'] != $v_proxy_ext) $v_adv = 'yes'; + + // Set domain name to lowercase and remove www prefix + $v_domain = preg_replace("/^www\./i", "", $_POST['v_domain']); + $v_domain = escapeshellarg($v_domain); + $v_domain = strtolower($v_domain); + + // Prepare domain values + $v_ip = escapeshellarg($_POST['v_ip']); + if ((!empty($_POST['v_aliases'])) && ($_POST['v_aliases'] != 'www.'.$_POST['v_domain'])) $v_adv = 'yes'; + if ((!empty($_POST['v_ssl'])) || (!empty($_POST['v_elog']))) $v_adv = 'yes'; + if ((!empty($_POST['v_ssl_crt'])) || (!empty($_POST['v_ssl_key']))) $v_adv = 'yes'; + if ((!empty($_POST['v_ssl_ca'])) || ($_POST['v_stats'] != 'none')) $v_adv = 'yes'; + if (!empty($v_domain)) $v_ftp_user_prepath .= $v_domain; + if (empty($_POST['v_dns'])) $v_dns = 'off'; + if (empty($_POST['v_mail'])) $v_mail = 'off'; + if (empty($_POST['v_proxy'])) $v_proxy = 'off'; + $v_aliases = $_POST['v_aliases']; + $v_elog = $_POST['v_elog']; + $v_ssl = $_POST['v_ssl']; + $v_ssl_crt = $_POST['v_ssl_crt']; + $v_ssl_key = $_POST['v_ssl_key']; + $v_ssl_ca = $_POST['v_ssl_ca']; + $v_ssl_home = $data[$v_domain]['SSL_HOME']; + $v_stats = escapeshellarg($_POST['v_stats']); + $v_stats_user = $data[$v_domain]['STATS_USER']; + $v_stats_password = $data[$v_domain]['STATS_PASSWORD']; + $v_proxy_ext = preg_replace("/\n/", " ", $_POST['v_proxy_ext']); + $v_proxy_ext = preg_replace("/,/", " ", $v_proxy_ext); + $v_proxy_ext = preg_replace('/\s+/', ' ',$v_proxy_ext); + $v_proxy_ext = trim($v_proxy_ext); + $v_proxy_ext = str_replace(' ', ", ", $v_proxy_ext); + $v_ftp = $_POST['v_ftp']; + $v_ftp_user = $_POST['v_ftp_user']; + $v_ftp_password = $_POST['v_ftp_password']; + $v_ftp_email = $_POST['v_ftp_email']; + + + // Add web domain + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-web-domain ".$user." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + $domain_added = empty($_SESSION['error_msg']); + } + + // Add DNS domain + if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_ip, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Add mail domain + if (($_POST['v_mail'] == 'on') && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-mail-domain ".$user." ".$v_domain, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Add domain aliases + if ((!empty($_POST['v_aliases'])) && (empty($_SESSION['error_msg']))) { + $valiases = preg_replace("/\n/", " ", $_POST['v_aliases']); + $valiases = preg_replace("/,/", " ", $valiases); + $valiases = preg_replace('/\s+/', ' ',$valiases); + $valiases = trim($valiases); + $aliases = explode(" ", $valiases); + foreach ($aliases as $alias) { + if ($alias == 'www.'.$_POST['v_domain']) { + $www_alias = 'yes'; + } else { + $alias = escapeshellarg($alias); + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-web-domain-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-dns-on-web-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + } + } + } + + // Delete www. alias if it wasn't found + if ((empty($www_alias)) && (empty($_SESSION['error_msg']))) { + $alias = preg_replace("/^www./i", "", $_POST['v_domain']); + $alias = 'www.'.$alias; + $alias = escapeshellarg($alias); + exec (VESTA_CMD."v-delete-web-domain-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Add proxy support + if (($_POST['v_proxy'] == 'on') && (empty($_SESSION['error_msg']))) { + $ext = str_replace(' ', '', $v_proxy_ext); + $ext = escapeshellarg($ext); + exec (VESTA_CMD."v-add-web-domain-proxy ".$user." ".$v_domain." '' ".$ext." 'no'", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Add SSL certificates + if ((!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { + exec ('mktemp -d', $output, $return_var); + $tmpdir = $output[0]; + unset($output); + + // Save 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); + } + + // Save private 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); + } + + // Save CA bundle + 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); + } + + $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); + 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); + } + + // Add web stats + if ((!empty($_POST['v_stats'])) && ($_POST['v_stats'] != 'none' ) && (empty($_SESSION['error_msg']))) { + $v_stats = escapeshellarg($_POST['v_stats']); + exec (VESTA_CMD."v-add-web-domain-stats ".$user." ".$v_domain." ".$v_stats, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Add web stats password + if ((!empty($_POST['v_stats_user'])) && (empty($_SESSION['error_msg']))) { + $v_stats_user = escapeshellarg($_POST['v_stats_user']); + $v_stats_password = escapeshellarg($_POST['v_stats_password']); + exec (VESTA_CMD."v-add-web-domain-stats-user ".$user." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Restart DNS server + if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-restart-dns", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Restart web server + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-restart-web", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Restart proxy server + if (($_POST['v_proxy'] == 'on') && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-restart-proxy", $output, $return_var); + check_return_code($return_var,$output); + unset($output); + } + + // Add FTP + if ((!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { + $v_ftp_users_updated = array(); + foreach ($_POST['v_ftp_user'] as $i => $v_ftp_user_data) { + if ($v_ftp_user_data['is_new'] == 1) { + if ((!empty($v_ftp_user_data['v_ftp_email'])) && (!filter_var($v_ftp_user_data['v_ftp_email'], FILTER_VALIDATE_EMAIL))) $_SESSION['error_msg'] = __('Please enter valid email address.'); + if (empty($v_ftp_user_data['v_ftp_user'])) $errors[] = 'ftp user'; + if (empty($v_ftp_user_data['v_ftp_password'])) $errors[] = 'ftp user password'; + 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); + } + + // Validate email + if ((!empty($v_ftp_user_data['v_ftp_email'])) && (!filter_var($v_ftp_user_data['v_ftp_email'], FILTER_VALIDATE_EMAIL))) { + $_SESSION['error_msg'] = __('Please enter valid email address.'); + } + + // Check ftp password length + if ((!empty($v_ftp_user_data['v_ftp']))) { + if (!empty($v_ftp_user_data['v_ftp_user'])) { + $pw_len = strlen($v_ftp_user_data['v_ftp_password']); + if ($pw_len < 6 ) $_SESSION['error_msg'] = __('Password is too short.',$error_msg); + } + } + + $v_ftp_user_data['v_ftp_user'] = preg_replace("/^".$user."_/i", "", $v_ftp_user_data['v_ftp_user']); + $v_ftp_username = $v_ftp_user_data['v_ftp_user']; + $v_ftp_username_full = $user . '_' . $v_ftp_user_data['v_ftp_user']; + $v_ftp_user = escapeshellarg($v_ftp_user_data['v_ftp_user']); + $v_ftp_password = escapeshellarg($v_ftp_user_data['v_ftp_password']); + + if ($domain_added) { + exec (VESTA_CMD."v-add-web-domain-ftp ".$user." ".$v_domain." ".$v_ftp_username." ".$v_ftp_password . " " . $v_ftp_user_data['v_ftp_path'], $output, $return_var); + check_return_code($return_var,$output); + unset($output); + if ((!empty($v_ftp_user_data['v_ftp_email'])) && (empty($_SESSION['error_msg']))) { + $to = $v_ftp_user_data['v_ftp_email']; + $subject = __("FTP login credentials"); + $from = __('MAIL_FROM',$_POST['v_domain']); + $mailtext = __('FTP_ACCOUNT_READY',$_POST['v_domain'],$user,$v_ftp_user_data['v_ftp_user'],$v_ftp_user_data['v_ftp_password']); + send_email($to, $subject, $mailtext, $from); + unset($v_ftp_email); + } + } else { + $return_var = -1; + } + + if ($return_var == 0) { + $v_ftp_password = "••••••••"; + $v_ftp_user_data['is_new'] = 0; + } else { + $v_ftp_user_data['is_new'] = 1; + } + + $v_ftp_username = preg_replace("/^".$user."_/", "", $v_ftp_user_data['v_ftp_user']); + $v_ftp_users_updated[] = array( + 'is_new' => $v_ftp_user_data['is_new'], + 'v_ftp_user' => $return_var == 0 ? $v_ftp_username_full : $v_ftp_username, + 'v_ftp_password' => $v_ftp_password, + 'v_ftp_path' => $v_ftp_user_data['v_ftp_path'], + 'v_ftp_email' => $v_ftp_user_data['v_ftp_email'], + 'v_ftp_pre_path' => $v_ftp_user_prepath + ); + continue; + } + } + + if (!empty($_SESSION['error_msg']) && $domain_added) { + $_SESSION['ok_msg'] = __('WEB_DOMAIN_CREATED_OK',$_POST[v_domain],$_POST[v_domain]); + $_SESSION['flash_error_msg'] = $_SESSION['error_msg']; + $url = '/edit/web/?domain='.strtolower(preg_replace("/^www\./i", "", $_POST['v_domain'])); + header('Location: ' . $url); + exit; + } + } + + // Flush field values on success + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __('WEB_DOMAIN_CREATED_OK',$_POST[v_domain],$_POST[v_domain]); + unset($v_domain); + unset($v_aliases); + unset($v_ssl); + unset($v_ssl_crt); + unset($v_ssl_key); + unset($v_ssl_ca); + unset($v_stats_user); + unset($v_stats_password); + unset($v_ftp); + } +} + + // Header include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); // Panel top_panel($user,$TAB); + +// Define user variables +$v_ftp_user_prepath = $panel[$user]['HOME'] . "/web"; $v_ftp_email = $panel[$user]['CONTACT']; - if (!empty($_POST['ok'])) { - // Check input - if (empty($_POST['v_domain'])) $errors[] = __('domain'); - if (empty($_POST['v_ip'])) $errors[] = __('ip'); - 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_aliases'])) && ($_POST['v_aliases'] != 'www.'.$_POST['v_domain'])) $v_adv = 'yes'; - if ((!empty($_POST['v_ssl'])) || (!empty($_POST['v_elog']))) $v_adv = 'yes'; - if ((!empty($_POST['v_ssl_crt'])) || (!empty($_POST['v_ssl_key']))) $v_adv = 'yes'; - if ((!empty($_POST['v_ssl_ca'])) || ($_POST['v_stats'] != 'none')) $v_adv = 'yes'; - if (empty($_POST['v_proxy'])) $v_adv = 'yes'; - if (!empty($_POST['v_ftp'])) $v_adv = 'yes'; - $v_proxy_ext = 'jpeg, jpg, png, gif, bmp, ico, svg, tif, tiff, css, js, htm, html, ttf,'; - $v_proxy_ext .= 'otf, webp, woff, txt, csv, rtf, doc, docx, xls, xlsx, ppt, pptx, odf, '; - $v_proxy_ext .= 'odp, ods, odt, pdf, psd, ai, eot, eps, ps, zip, tar, tgz, gz, rar, '; - $v_proxy_ext .= 'bz2, 7z, aac, m4a, mp3, mp4, ogg, wav, wma, 3gp, avi, flv, m4v, mkv, '; - $v_proxy_ext .= 'mov, mp4, mpeg, mpg, wmv, exe, iso, dmg, swf'; - if ($_POST['v_proxy_ext'] != $v_proxy_ext) $v_adv = 'yes'; +// List IP addresses +exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var); +$ips = json_decode(implode('', $output), true); +unset($output); - // Protect input - $v_domain = preg_replace("/^www\./i", "", $_POST['v_domain']); - $v_domain = escapeshellarg($v_domain); - $v_domain = strtolower($v_domain); - $v_ip = escapeshellarg($_POST['v_ip']); - if (empty($_POST['v_dns'])) $v_dns = 'off'; - if (empty($_POST['v_mail'])) $v_mail = 'off'; - if (empty($_POST['v_proxy'])) $v_proxy = 'off'; - $v_aliases = $_POST['v_aliases']; - $v_elog = $_POST['v_elog']; - $v_ssl = $_POST['v_ssl']; - $v_ssl_crt = $_POST['v_ssl_crt']; - $v_ssl_key = $_POST['v_ssl_key']; - $v_ssl_ca = $_POST['v_ssl_ca']; - $v_ssl_home = $data[$v_domain]['SSL_HOME']; - $v_stats = escapeshellarg($_POST['v_stats']); - $v_stats_user = $data[$v_domain]['STATS_USER']; - $v_stats_password = $data[$v_domain]['STATS_PASSWORD']; - $v_proxy_ext = preg_replace("/\n/", " ", $_POST['v_proxy_ext']); - $v_proxy_ext = preg_replace("/,/", " ", $v_proxy_ext); - $v_proxy_ext = preg_replace('/\s+/', ' ',$v_proxy_ext); - $v_proxy_ext = trim($v_proxy_ext); - $v_proxy_ext = str_replace(' ', ", ", $v_proxy_ext); - $v_ftp = $_POST['v_ftp']; - $v_ftp_user = $_POST['v_ftp_user']; - $v_ftp_password = $_POST['v_ftp_password']; - $v_ftp_email = $_POST['v_ftp_email']; +// List web stat engines +exec (VESTA_CMD."v-list-web-stats json", $output, $return_var); +$stats = json_decode(implode('', $output), true); +unset($output); - // Validate email - if ((!empty($_POST['v_ftp_email'])) && (!filter_var($_POST['v_ftp_email'], FILTER_VALIDATE_EMAIL))) { - $_SESSION['error_msg'] = __('Please enter valid email address.'); - } +// Display body +include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_web.html'); - // Check ftp password length - if ((!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - if (!empty($_POST['v_ftp_user'])) { - $pw_len = strlen($_POST['v_ftp_password']); - if ($pw_len < 6 ) $_SESSION['error_msg'] = __('Password is too short.',$error_msg); - } - } - - // Check stats password length - if ((!empty($v_stats)) && (empty($_SESSION['error_msg']))) { - if (!empty($_POST['v_stats_user'])) { - $pw_len = strlen($_POST['v_stats_password']); - if ($pw_len < 6 ) $_SESSION['error_msg'] = __('Password is too short.',$error_msg); - } - } - - // Check for errors - 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); - } - - if (empty($_SESSION['error_msg'])) { - // Add WEB - exec (VESTA_CMD."v-add-web-domain ".$user." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - - // Add DNS - if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_ip, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - // Add Mail - if (($_POST['v_mail'] == 'on') && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-mail-domain ".$user." ".$v_domain, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - // Add Aliases - if ((!empty($_POST['v_aliases'])) && (empty($_SESSION['error_msg']))) { - $valiases = preg_replace("/\n/", " ", $_POST['v_aliases']); - $valiases = preg_replace("/,/", " ", $valiases); - $valiases = preg_replace('/\s+/', ' ',$valiases); - $valiases = trim($valiases); - $aliases = explode(" ", $valiases); - foreach ($aliases as $alias) { - if ($alias == 'www.'.$_POST['v_domain']) { - $www_alias = 'yes'; - } else { - $alias = escapeshellarg($alias); - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-web-domain-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var); - check_return_code($return_var,$output); - } - unset($output); - if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-dns-on-web-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - } - } - } - if ((empty($www_alias)) && (empty($_SESSION['error_msg']))) { - $alias = preg_replace("/^www./i", "", $_POST['v_domain']); - $alias = 'www.'.$alias; - $alias = escapeshellarg($alias); - exec (VESTA_CMD."v-delete-web-domain-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var); - check_return_code($return_var,$output); - } - - - // Add proxy - if (($_POST['v_proxy'] == 'on') && (empty($_SESSION['error_msg']))) { - $ext = str_replace(' ', '', $v_proxy_ext); - $ext = escapeshellarg($ext); - exec (VESTA_CMD."v-add-web-domain-proxy ".$user." ".$v_domain." '' ".$ext." 'no'", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - // Add SSL - if (!empty($_POST['v_ssl'])) { - exec ('mktemp -d', $output, $return_var); - $tmpdir = $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); - } - - $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); - 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); - } - - // Add WebStats - if ((!empty($_POST['v_stats'])) && ($_POST['v_stats'] != 'none' ) && (empty($_SESSION['error_msg']))) { - $v_stats = escapeshellarg($_POST['v_stats']); - exec (VESTA_CMD."v-add-web-domain-stats ".$user." ".$v_domain." ".$v_stats, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - - if ((!empty($_POST['v_stats_user'])) && (empty($_SESSION['error_msg']))) { - $v_stats_user = escapeshellarg($_POST['v_stats_user']); - $v_stats_password = escapeshellarg($_POST['v_stats_password']); - exec (VESTA_CMD."v-add-web-domain-stats-user ".$user." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); - check_return_code($return_var,$output); - unset($v_stats_user); - unset($v_stats_password); - unset($output); - } - } - - - // Add FTP - if ((!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - $v_ftp_user = escapeshellarg($_POST['v_ftp_user']); - $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); - exec (VESTA_CMD."v-add-web-domain-ftp ".$user." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); - check_return_code($return_var,$output); - if (empty($_SESSION['error_msg'])) { - if (!empty($v_ftp_email)) { - $to = $_POST['v_ftp_email']; - $subject = __("FTP login credentials"); - $hostname = exec('hostname'); - $from = __('MAIL_FROM',$hostname); - $mailtext .= __('FTP_ACCOUNT_READY',$_POST['v_domain'],$user,$_POST['v_ftp_user'],$_POST['v_ftp_password']); - send_email($to, $subject, $mailtext, $from); - } - } - unset($v_ftp); - unset($v_ftp_user); - unset($v_ftp_password); - unset($output); - } - - if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-restart-dns", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-restart-web", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-restart-proxy", $output, $return_var); - check_return_code($return_var,$output); - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - unset($output); - $_SESSION['ok_msg'] = __('WEB_DOMAIN_CREATED_OK',$_POST[v_domain],$_POST[v_domain]); - unset($v_domain); - unset($v_aliases); - unset($v_ssl); - unset($v_ssl_crt); - unset($v_ssl_key); - unset($v_ssl_ca); - } - } - } - - exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var); - $ips = 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); - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_web.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -//} +// Flush session messages +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/web/index.php b/web/edit/web/index.php index a607e5465..fad416202 100644 --- a/web/edit/web/index.php +++ b/web/edit/web/index.php @@ -4,17 +4,11 @@ error_reporting(NULL); ob_start(); session_start(); unset($_SESSION['error_msg']); - $TAB = 'WEB'; + include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); -// Header -include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); - -// Panel -top_panel($user,$TAB); - -// Check user argument? +// Check domain argument if (empty($_GET['domain'])) { header("Location: /list/web/"); exit; @@ -25,73 +19,77 @@ if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) { $user=escapeshellarg($_GET['user']); } -// Check domain +// List domain $v_domain = escapeshellarg($_GET['domain']); exec (VESTA_CMD."v-list-web-domain ".$user." ".$v_domain." json", $output, $return_var); -check_return_code($return_var,$output); -if (empty($_SESSION['error_msg'])) { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_domain = $_GET['domain']; - $v_ip = $data[$v_domain]['IP']; - $v_template = $data[$v_domain]['TPL']; - $v_aliases = str_replace(',', "\n", $data[$v_domain]['ALIAS']); - $valiases = explode(",", $data[$v_domain]['ALIAS']); - $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' ) { - 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_home = $data[$v_domain]['SSL_HOME']; - $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 = "••••••••"; - $v_ftp_user = $data[$v_domain]['FTP_USER']; - if (!empty($v_ftp_user)) $v_ftp_password = "••••••••"; - $v_suspended = $data[$v_domain]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - $v_time = $data[$v_domain]['TIME']; - $v_date = $data[$v_domain]['DATE']; +$data = json_decode(implode('', $output), true); +unset($output); - exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var); - $ips = 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-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); +// Parse domain +$v_username = $user; +$v_domain = $_GET['domain']; +$v_ip = $data[$v_domain]['IP']; +$v_template = $data[$v_domain]['TPL']; +$v_aliases = str_replace(',', "\n", $data[$v_domain]['ALIAS']); +$valiases = explode(",", $data[$v_domain]['ALIAS']); +$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' ) { + 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']; } - - -// Action +$v_ssl_home = $data[$v_domain]['SSL_HOME']; +$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 = "••••••••"; +$v_ftp_user = $data[$v_domain]['FTP_USER']; +if (!empty($v_ftp_user)) $v_ftp_password = "••••••••"; +$v_ftp_user_prepath = $data[$v_domain]['DOCUMENT_ROOT']; +$v_ftp_user_prepath = str_replace('/public_html', '', $v_ftp_user_prepath, $occurance = 1); $v_ftp_email = $panel[$user]['CONTACT']; +$v_suspended = $data[$v_domain]['SUSPENDED']; +if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; +} else { + $v_status = 'active'; +} +$v_time = $data[$v_domain]['TIME']; +$v_date = $data[$v_domain]['DATE']; + +// List ip addresses +exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var); +$ips = json_decode(implode('', $output), true); +unset($output); + +// List web templates +exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); +$templates = json_decode(implode('', $output), true); +unset($output); + +// List proxy templates +exec (VESTA_CMD."v-list-web-templates-proxy json", $output, $return_var); +$proxy_templates = json_decode(implode('', $output), true); +unset($output); + +// List web stat engines +exec (VESTA_CMD."v-list-web-stats json", $output, $return_var); +$stats = json_decode(implode('', $output), true); +unset($output); + +// Check POST request if (!empty($_POST['save'])) { $v_domain = escapeshellarg($_POST['v_domain']); - // IP + // Change web domain IP if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) { $v_ip = escapeshellarg($_POST['v_ip']); exec (VESTA_CMD."v-change-web-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); @@ -99,27 +97,36 @@ if (!empty($_POST['save'])) { $restart_web = 'yes'; $restart_proxy = 'yes'; unset($output); + } + + // Chane dns domain IP + if (empty($_SESSION['error_msg'])) { exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain." json", $output, $return_var); - if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { - unset($output); + unset($output); + if ($return_var == 0 ) { exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); check_return_code($return_var,$output); - $restart_dns = 'yes'; - } - unset($output); - foreach($valiases as $v_alias ){ - exec (VESTA_CMD."v-list-dns-domain ".$v_username." '".$v_alias."' json", $output, $return_var); - if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { - exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." '".$v_alias."' ".$v_ip, $output, $return_var); - check_return_code($return_var,$output); - $restart_dns = 'yes'; - } unset($output); + $restart_dns = 'yes'; } } - // Template - if (( $_SESSION['user'] == 'admin') && ($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { + // Change dns ip for each alias + if (empty($_SESSION['error_msg'])) { + foreach($valiases as $v_alias ){ + exec (VESTA_CMD."v-list-dns-domain ".$v_username." '".$v_alias."' json", $output, $return_var); + unset($output); + if ($return_var == 0 ) { + exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." '".$v_alias."' ".$v_ip, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + $restart_dns = 'yes'; + } + } + } + + // Change template (admin only) + if (($v_template != $_POST['v_template']) && ( $_SESSION['user'] == 'admin') && (empty($_SESSION['error_msg']))) { $v_template = escapeshellarg($_POST['v_template']); exec (VESTA_CMD."v-change-web-domain-tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var); check_return_code($return_var,$output); @@ -127,7 +134,7 @@ if (!empty($_POST['save'])) { $restart_web = 'yes'; } - // Aliases + // Change aliases if (empty($_SESSION['error_msg'])) { $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']); $waliases = preg_replace("/,/", " ", $waliases); @@ -151,9 +158,9 @@ if (!empty($_POST['save'])) { if ($return_var == 0) { exec (VESTA_CMD."v-delete-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); check_return_code($return_var,$output); + unset($output); $restart_dns = 'yes'; } - unset($output); } } } @@ -173,15 +180,15 @@ if (!empty($_POST['save'])) { if ($return_var == 0) { exec (VESTA_CMD."v-add-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); check_return_code($return_var,$output); + unset($output); $restart_dns = 'yes'; } } - unset($output); } } } - // Proxy + // Delete proxy support 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); check_return_code($return_var,$output); @@ -189,6 +196,8 @@ if (!empty($_POST['save'])) { unset($v_proxy); $restart_proxy = 'yes'; } + + // Change proxy template / Update extention list if ((!empty($v_proxy)) && (!empty($_POST['v_proxy'])) && (empty($_SESSION['error_msg']))) { $ext = preg_replace("/\n/", " ", $_POST['v_proxy_ext']); $ext = preg_replace("/,/", " ", $ext); @@ -205,6 +214,8 @@ if (!empty($_POST['save'])) { $restart_proxy = 'yes'; } } + + // Add proxy support 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'])) { @@ -221,7 +232,7 @@ if (!empty($_POST['save'])) { $restart_proxy = 'yes'; } - // SSL + // 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); @@ -230,6 +241,8 @@ if (!empty($_POST['save'])) { $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); @@ -269,15 +282,8 @@ if (!empty($_POST['save'])) { $v_ssl_ca = $_POST['v_ssl_ca']; } } - 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']; - unset($output); - } - } + + // 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'; @@ -329,19 +335,34 @@ if (!empty($_POST['save'])) { } } - // Web Stats + // 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']; + unset($output); + } + } + + // Delete web stats if ((!empty($v_stats)) && ($_POST['v_stats'] == 'none') && (empty($_SESSION['error_msg']))) { exec (VESTA_CMD."v-delete-web-domain-stats ".$v_username." ".$v_domain, $output, $return_var); check_return_code($return_var,$output); unset($output); $v_stats = ''; } + + // Change web stats engine if ((!empty($v_stats)) && ($_POST['v_stats'] != $v_stats) && (empty($_SESSION['error_msg']))) { $v_stats = escapeshellarg($_POST['v_stats']); exec (VESTA_CMD."v-change-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); check_return_code($return_var,$output); unset($output); } + + // Add web stats if ((empty($v_stats)) && ($_POST['v_stats'] != 'none') && (empty($_SESSION['error_msg']))) { $v_stats = escapeshellarg($_POST['v_stats']); exec (VESTA_CMD."v-add-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); @@ -349,7 +370,7 @@ if (!empty($_POST['save'])) { unset($output); } - // Web Stats Auth + // Delete web stats authorization if ((!empty($v_stats_user)) && (empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { exec (VESTA_CMD."v-delete-web-domain-stats-user ".$v_username." ".$v_domain, $output, $return_var); check_return_code($return_var,$output); @@ -357,6 +378,8 @@ if (!empty($_POST['save'])) { $v_stats_user = ''; $v_stats_password = ''; } + + // Change web stats user or password if ((empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { if (empty($_POST['v_stats_user'])) $errors[] = __('stats username'); if (empty($_POST['v_stats_password'])) $errors[] = __('stats password'); @@ -378,6 +401,8 @@ if (!empty($_POST['save'])) { $v_stats_password = "••••••••"; } } + + // Add web stats authorization if ((!empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { if (empty($_POST['v_stats_user'])) $errors[] = __('stats user'); if (empty($_POST['v_stats_password'])) $errors[] = __('stats password'); @@ -401,112 +426,203 @@ if (!empty($_POST['save'])) { } } - // Delete FTP Account - if ((!empty($v_ftp_user)) && (empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-ftp ".$v_username." ".$v_domain, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $v_ftp= ''; - $v_ftp_user = ''; - $v_ftp_password = ''; - } - - // Change FTP Account - if ((!empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_ftp_user'])) $errors[] = __('ftp user'); - if (empty($_POST['v_ftp_password'])) $errors[] = __('ftp user password'); - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; + // Change ftp accounts + if (!empty($_POST['v_ftp_user'])) { + $v_ftp_users_updated = array(); + foreach ($_POST['v_ftp_user'] as $i => $v_ftp_user_data) { + $v_ftp_user_data['v_ftp_user'] = preg_replace("/^".$user."_/i", "", $v_ftp_user_data['v_ftp_user']); + if ($v_ftp_user_data['is_new'] == 1) { + if ((!empty($v_ftp_user_data['v_ftp_email'])) && (!filter_var($v_ftp_user_data['v_ftp_email'], FILTER_VALIDATE_EMAIL))) $_SESSION['error_msg'] = __('Please enter valid email address.'); + if (empty($v_ftp_user_data['v_ftp_user'])) $errors[] = 'ftp user'; + if (empty($v_ftp_user_data['v_ftp_password'])) $errors[] = 'ftp user password'; + 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); } - } - $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg); - } - if (($v_ftp_user != $_POST['v_ftp_user']) || ($_POST['v_ftp_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { - $v_ftp_user = preg_replace("/^".$user."_/", "", $_POST['v_ftp_user']); - $v_ftp_user = escapeshellarg($v_ftp_user); - $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); - exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); - check_return_code($return_var,$output); - unset($output); - $v_ftp= ''; - $v_ftp_user = $user."_".preg_replace("/^".$user."_/", "", $_POST['v_ftp_user']); - $v_ftp_password = "••••••••"; - } - } - // Add FTP Account - if ((empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - if ((!empty($_POST['v_ftp_email'])) && (!filter_var($_POST['v_ftp_email'], FILTER_VALIDATE_EMAIL))) $_SESSION['error_msg'] = __('Please enter valid email address.'); - if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp user'; - if (empty($_POST['v_ftp_password'])) $errors[] = 'ftp user password'; - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; + $v_ftp_username = $v_ftp_user_data['v_ftp_user']; + $v_ftp_username_full = $user . '_' . $v_ftp_user_data['v_ftp_user']; + $v_ftp_user = escapeshellarg($v_ftp_username); + $v_ftp_password = escapeshellarg($v_ftp_user_data['v_ftp_password']); + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_username." ".$v_ftp_password . " " . $v_ftp_user_data['v_ftp_path'], $output, $return_var); + check_return_code($return_var,$output); + if ((!empty($v_ftp_user_data['v_ftp_email'])) && (empty($_SESSION['error_msg']))) { + $to = $v_ftp_user_data['v_ftp_email']; + $subject = __("FTP login credentials"); + $hostname = exec('hostname'); + $from = __('MAIL_FROM',$hostname); + $mailtext = __('FTP_ACCOUNT_READY',$_GET['domain'],$user,$v_ftp_username,$v_ftp_user_data['v_ftp_password']); + send_email($to, $subject, $mailtext, $from); + unset($v_ftp_email); + } + unset($output); } + + if ($return_var == 0) { + $v_ftp_password = "••••••••"; + $v_ftp_user_data['is_new'] = 0; + } + else { + $v_ftp_user_data['is_new'] = 1; + } + + $v_ftp_users_updated[] = array( + 'is_new' => empty($_SESSION['error_msg']) ? 0 : 1, + 'v_ftp_user' => $v_ftp_username_full, + 'v_ftp_password' => $v_ftp_password, + 'v_ftp_path' => $v_ftp_user_data['v_ftp_path'], + 'v_ftp_email' => $v_ftp_user_data['v_ftp_email'], + 'v_ftp_pre_path' => $v_ftp_user_prepath + ); + + continue; } - $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg); - } - if (empty($_SESSION['error_msg'])) { - $v_ftp_user = escapeshellarg($_POST['v_ftp_user']); - $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); - exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); - check_return_code($return_var,$output); - if ((!empty($_POST['v_ftp_email'])) && (empty($_SESSION['error_msg']))) { - $to = $_POST['v_ftp_email']; - $subject = __("FTP login credentials"); - $hostname = exec('hostname'); - $from = __('MAIL_FROM',$hostname); - $mailtext .= __('FTP_ACCOUNT_READY',$_GET['domain'],$user,$_POST['v_ftp_user'],$_POST['v_ftp_password']); - send_email($to, $subject, $mailtext, $from); - unset($v_ftp_email); + + + if ($v_ftp_user_data['delete'] == 1) { + $v_ftp_username = $user . '_' . $v_ftp_user_data['v_ftp_user']; + exec (VESTA_CMD."v-delete-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_username, $output, $return_var); + check_return_code($return_var,$output); + unset($output); + + continue; } + + // Change FTP Account + if (empty($v_ftp_user_data['v_ftp_user'])) $errors[] = __('ftp user'); + if (empty($v_ftp_user_data['v_ftp_password'])) $errors[] = __('ftp user password'); + 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); + } + + $v_ftp_username = $user . '_' . $v_ftp_user_data['v_ftp_user']; //preg_replace("/^".$user."_/", "", $v_ftp_user_data['v_ftp_user']); + $v_ftp_username = escapeshellarg($v_ftp_username); + $v_ftp_user_data['v_ftp_password'] = escapeshellarg(trim($v_ftp_user_data['v_ftp_password'])); + exec (VESTA_CMD."v-change-web-domain-ftp-path ".$v_username." ".$v_domain." ".$v_ftp_username." ".$v_ftp_user_data['v_ftp_path'], $output, $return_var); + if ($v_ftp_user_data['v_ftp_password'] != "••••••••" && !empty($v_ftp_user_data['v_ftp_password'])) { + exec (VESTA_CMD."v-change-web-domain-ftp-password ".$v_username." ".$v_domain." ".$v_ftp_username." ".$v_ftp_user_data['v_ftp_password'], $output, $return_var); + } + check_return_code($return_var, $output); unset($output); - $v_ftp_user = $user."_".$_POST['v_ftp_user']; + $v_ftp_password = "••••••••"; + + $v_ftp_users_updated[] = array( + 'is_new' => 0, + 'v_ftp_user' => $v_ftp_username, + 'v_ftp_password' => $v_ftp_password, + 'v_ftp_path' => $v_ftp_user_data['v_ftp_path'], + 'v_ftp_email' => $v_ftp_user_data['v_ftp_email'], + 'v_ftp_pre_path' => $v_ftp_user_prepath + ); } } - // Restart web + // Restart web server if (!empty($restart_web) && (empty($_SESSION['error_msg']))) { exec (VESTA_CMD."v-restart-web", $output, $return_var); check_return_code($return_var,$output); unset($output); } - // Restart proxy + // Restart proxy server if (!empty($restart_proxy) && (empty($_SESSION['error_msg']))) { exec (VESTA_CMD."v-restart-proxy", $output, $return_var); check_return_code($return_var,$output); unset($output); } - // Restart dns + // Restart dns server if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { exec (VESTA_CMD."v-restart-dns", $output, $return_var); check_return_code($return_var,$output); unset($output); } + // Set success message if (empty($_SESSION['error_msg'])) { $_SESSION['ok_msg'] = __('Changes has been saved.'); } } + + +$v_ftp_users_raw = explode(':', $v_ftp_user); +$v_ftp_users_paths_raw = explode(':', $data[$v_domain]['FTP_PATH']); +$v_ftp_users = array(); +foreach ($v_ftp_users_raw as $v_ftp_user_index => $v_ftp_user_val) { + if (empty($v_ftp_user_val)) { + continue; + } + $v_ftp_users[] = array( + 'is_new' => 0, + 'v_ftp_user' => $v_ftp_user_val, + 'v_ftp_password' => $v_ftp_password, + 'v_ftp_path' => (isset($v_ftp_users_paths_raw[$v_ftp_user_index]) ? $v_ftp_users_paths_raw[$v_ftp_user_index] : ''), + 'v_ftp_email' => $v_ftp_email, + 'v_ftp_pre_path' => $v_ftp_user_prepath + ); +} + +if (empty($v_ftp_users)) { + $v_ftp_user = null; + $v_ftp_users[] = array( + 'is_new' => 1, + 'v_ftp_user' => '', + 'v_ftp_password' => '', + 'v_ftp_path' => (isset($v_ftp_users_paths_raw[$v_ftp_user_index]) ? $v_ftp_users_paths_raw[$v_ftp_user_index] : ''), + 'v_ftp_email' => '', + 'v_ftp_pre_path' => $v_ftp_user_prepath + ); +} + +// set default pre path for newly created users +$v_ftp_pre_path_new_user = $v_ftp_user_prepath; +if (isset($v_ftp_users_updated)) { + $v_ftp_users = $v_ftp_users_updated; + if (empty($v_ftp_users_updated)) { + $v_ftp_user = null; + $v_ftp_users[] = array( + 'is_new' => 1, + 'v_ftp_user' => '', + 'v_ftp_password' => '', + 'v_ftp_path' => (isset($v_ftp_users_paths_raw[$v_ftp_user_index]) ? $v_ftp_users_paths_raw[$v_ftp_user_index] : ''), + 'v_ftp_email' => '', + 'v_ftp_pre_path' => $v_ftp_user_prepath + ); + } +} + +// Header +include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); + +// Panel +top_panel($user,$TAB); + +// Display body if ($_SESSION['user'] == 'admin') { include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_web.html'); } else { include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_web.html'); } + +// Flush session messages unset($_SESSION['error_msg']); unset($_SESSION['ok_msg']); - // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/templates/admin/add_web.html b/web/templates/admin/add_web.html index 6f50d67a5..b8522c1ab 100644 --- a/web/templates/admin/add_web.html +++ b/web/templates/admin/add_web.html @@ -42,7 +42,7 @@ document.v_add_web.v_stats_password.value = webrandom; } - function FTPrandom() { + function FTPrandom(elm) { var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; var string_length = 10; var ftprandomstring = ''; @@ -50,7 +50,7 @@ var rnum = Math.floor(Math.random() * chars.length); ftprandomstring += chars.substring(rnum,rnum+1); } - document.v_add_web.v_ftp_password.value = ftprandomstring; + $(elm).parents('.ftptable').find('.v-ftp-user-psw').val(ftprandomstring); } function elementHideShow(elementToHideOrShow){ @@ -75,7 +75,7 @@ - @@ -85,7 +85,7 @@ - @@ -107,34 +107,24 @@ - - - - - - - - -
+
+
- + +
- > + +
- -
- > -
+
- @@ -144,25 +134,20 @@ - - - -
+
- -
- onclick="javascript:elementHideShow('proxytable');"> + +
- - @@ -170,26 +155,21 @@ - - - -
+
+
- / + + /
- onclick="javascript:elementHideShow('ssltable');"> -
- - - - - - - - @@ -234,7 +214,7 @@ - @@ -256,20 +236,15 @@ - - - - - - - - - @@ -36,7 +39,7 @@ document.v_edit_web.v_stats_password.value = webrandom; } - function FTPrandom() { + function FTPrandom(elm) { var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; var string_length = 10; var ftprandomstring = ''; @@ -44,7 +47,8 @@ var rnum = Math.floor(Math.random() * chars.length); ftprandomstring += chars.substring(rnum,rnum+1); } - document.v_edit_web.v_ftp_password.value = ftprandomstring; + + $(elm).parents('.ftptable').find('.v-ftp-user-psw').val(ftprandomstring); } function elementHideShow(elementToHideOrShow){ @@ -72,7 +76,7 @@
+
+
+
+
+
+
+ ()
+
+
- + +
- onclick="javascript:elementHideShow('statstable');"> -
+ - @@ -279,73 +254,104 @@ -
+
+ /
- +
- + +
- onclick="javascript:elementHideShow('ftptable');"> -
- - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + +
-
- -
- -
- / -
- - -
- class="ftptable ftptable-nrm" name="v_add_domain_ftp"> +
+ # () + + +
+
+ +
+ name="v_ftp_user[][v_ftp_user]" > + +
+ / +
+ + +
+ + +
+ +
+ + +
+ - - @@ -354,7 +360,71 @@
+ +
+ + + diff --git a/web/templates/admin/edit_web.html b/web/templates/admin/edit_web.html index 3ef861501..dd2696ce5 100644 --- a/web/templates/admin/edit_web.html +++ b/web/templates/admin/edit_web.html @@ -10,12 +10,15 @@
→ ".$_SESSION['ok_msg'].""; + } if (!empty($_SESSION['error_msg'])) { echo " → ".$_SESSION['error_msg'].""; - } else { - if (!empty($_SESSION['ok_msg'])) { - echo " → ".$_SESSION['ok_msg'].""; - } + } + if (!empty($_SESSION['flash_error_msg'])) { + echo " / FTP USER ".$_SESSION['flash_error_msg'].""; + unset($_SESSION['flash_error_msg']); } ?> - @@ -82,7 +86,7 @@ - @@ -105,7 +109,7 @@ - @@ -115,7 +119,7 @@ - @@ -136,20 +140,15 @@ - - - - -
+
+
+
+
- + +
- onclick="javascript:elementHideShow('proxytable');"> -
+ - @@ -173,7 +172,7 @@ - @@ -186,21 +185,16 @@ - - - - - @@ -36,7 +39,7 @@ document.v_edit_web.v_stats_password.value = webrandom; } - function FTPrandom() { + function FTPrandom(elm) { var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; var string_length = 10; var ftprandomstring = ''; @@ -44,7 +47,8 @@ var rnum = Math.floor(Math.random() * chars.length); ftprandomstring += chars.substring(rnum,rnum+1); } - document.v_edit_web.v_ftp_password.value = ftprandomstring; + + $(elm).parents('.ftptable').find('.v-ftp-user-psw').val(ftprandomstring); } function elementHideShow(elementToHideOrShow){ @@ -72,7 +76,7 @@
+
+
- / + + /
- onclick="javascript:elementHideShow('ssltable');"> -
+ - @@ -218,7 +212,7 @@ - @@ -228,7 +222,7 @@ - @@ -238,7 +232,7 @@ - @@ -251,7 +245,7 @@ - @@ -273,20 +267,15 @@ - - - - - - - - - + + + +
+
+
+
+ ()
+
- + +
- onclick="javascript:elementHideShow('statstable');"> -
+ - @@ -296,80 +285,106 @@ -
+
+ /
- +
- + +
- onclick="javascript:elementHideShow('ftptable');"> -
- + + $ftp_user): ?> + +
- - + + + - - - - -
- - ' . __('Prefix will be automaticaly added to username',$user."_") . '' ?> + + # () + +
- +
+ +
+ name="v_ftp_user[][v_ftp_user]" >
- / + + /
- + - + +
- + +
+ +
+ +
+ + +
- - @@ -378,7 +393,74 @@
+ +
+ + + + diff --git a/web/templates/user/edit_web.html b/web/templates/user/edit_web.html index 1b0998feb..80e67bb47 100644 --- a/web/templates/user/edit_web.html +++ b/web/templates/user/edit_web.html @@ -10,12 +10,15 @@
→ ".$_SESSION['ok_msg'].""; + } if (!empty($_SESSION['error_msg'])) { echo " → ".$_SESSION['error_msg'].""; - } else { - if (!empty($_SESSION['ok_msg'])) { - echo " → ".$_SESSION['ok_msg'].""; - } + } + if (!empty($_SESSION['flash_error_msg'])) { + echo "
→ ".$_SESSION['flash_error_msg'].""; + unset($_SESSION['flash_error_msg']); } ?>
- @@ -82,7 +86,7 @@ - @@ -105,7 +109,7 @@ - @@ -115,17 +119,12 @@ - - - - -
+
+
+
- + +
- onclick="javascript:elementHideShow('proxytable');"> -
+ - - - - -
@@ -141,21 +140,16 @@
- / + + /
- onclick="javascript:elementHideShow('ssltable');"> -
+ - @@ -164,7 +158,7 @@ - @@ -183,7 +177,7 @@ - @@ -193,7 +187,7 @@ - @@ -206,7 +200,7 @@ - @@ -228,20 +222,15 @@ - - - - -
+
+
+
+ ()
+
- + +
- onclick="javascript:elementHideShow('statstable');"> -
+ - @@ -251,7 +240,7 @@ - @@ -264,67 +253,95 @@ - - - - + + + +
+
+ /
- + +
- onclick="javascript:elementHideShow('ftptable');"> -
- + + + + $ftp_user): ?> + +
- - + + + - - - - -
- - ' . __('Prefix will be automaticaly added to username',$user."_") . '' ?> + + # () + +
- +
+ +
+ name="v_ftp_user[][v_ftp_user]" >
- / + + /
- + - + +
- + +
+ +
+ +
+ + +
- - @@ -333,7 +350,73 @@
+ +
+ + + From bf7058f8b6fb1181d6e44a9f99e8c9894f228fbd Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 30 Jul 2014 15:56:19 +0300 Subject: [PATCH 16/19] Fixed syntax errors --- web/inc/i18n/hu.php | 6 +- web/templates/admin/add_cron.html | 18 +++--- web/templates/admin/add_db.html | 22 +++---- web/templates/admin/add_dns.html | 20 +++--- web/templates/admin/add_dns_rec.html | 14 ++--- web/templates/admin/add_ip.html | 29 ++++----- web/templates/admin/add_mail.html | 33 +++------- web/templates/admin/add_mail_acc.html | 32 ++++------ web/templates/admin/add_package.html | 38 ++++++------ web/templates/admin/add_user.html | 22 +++---- .../admin/edit_backup_exclusions.html | 16 ++--- web/templates/admin/edit_cron.html | 20 +++--- web/templates/admin/edit_db.html | 18 +++--- web/templates/admin/edit_dns.html | 16 ++--- web/templates/admin/edit_dns_rec.html | 16 ++--- web/templates/admin/edit_ip.html | 61 ++++++++++--------- web/templates/admin/edit_mail.html | 35 +++-------- web/templates/admin/edit_mail_acc.html | 36 ++++------- web/templates/admin/edit_package.html | 38 ++++++------ web/templates/admin/edit_user.html | 24 ++++---- web/templates/admin/list_backup.html | 4 +- web/templates/admin/list_backup_detail.html | 2 +- .../admin/list_backup_exclusions.html | 2 +- web/templates/admin/list_cron.html | 6 +- web/templates/admin/list_db.html | 8 +-- web/templates/admin/list_dns.html | 4 +- web/templates/admin/list_dns_rec.html | 2 +- web/templates/admin/list_ip.html | 2 +- web/templates/admin/list_log.html | 2 +- web/templates/admin/list_mail.html | 8 +-- web/templates/admin/list_mail_acc.html | 4 +- web/templates/admin/list_packages.html | 6 +- web/templates/admin/list_rrd.html | 17 +++++- web/templates/admin/list_search.html | 4 +- web/templates/admin/list_services.html | 22 ++++--- web/templates/admin/list_stats.html | 6 +- web/templates/admin/list_updates.html | 2 +- web/templates/admin/list_user.html | 8 +-- web/templates/admin/list_web.html | 21 +++++-- web/templates/user/edit_dns.html | 16 ++--- web/templates/user/edit_user.html | 14 ++--- web/templates/user/list_cron.html | 4 +- web/templates/user/list_db.html | 8 +-- web/templates/user/list_dns.html | 4 +- web/templates/user/list_dns_rec.html | 2 +- web/templates/user/list_mail.html | 8 +-- web/templates/user/list_mail_acc.html | 4 +- web/templates/user/list_search.html | 4 +- web/templates/user/list_stats.html | 6 +- web/templates/user/list_user.html | 8 +-- web/templates/user/list_web.html | 10 +-- 51 files changed, 356 insertions(+), 376 deletions(-) diff --git a/web/inc/i18n/hu.php b/web/inc/i18n/hu.php index 25b52d700..f8ae15d40 100644 --- a/web/inc/i18n/hu.php +++ b/web/inc/i18n/hu.php @@ -17,7 +17,7 @@ $LANG['hu'] = array( 'Log in' => 'Belépés', 'Log out' => 'Kilépés', - 'USER' => 'FELHASZNÁLÓ', + 'USER' => 'USER', 'WEB' => 'WEB', 'DNS' => 'DNS', 'MAIL' => 'MAIL', @@ -142,7 +142,7 @@ $LANG['hu'] = array( 'Databases' => 'Adatbázis', 'User Directories' => 'Felhasználói könyvtárak', 'Template' => 'Sablon', - 'Web Template' => 'Apache sablon, + 'Web Template' => 'Apache sablon', 'Proxy Template' => 'Nginx sablon', 'DNS Template' => 'DNS sablon', 'Web Domains' => 'Web Domainek', @@ -398,7 +398,7 @@ $LANG['hu'] = array( 'LOGGED_IN_AS' => 'Belépve, mint %s', 'Error' => 'Hiba', 'Invalid username or password' => 'Hibás felhasználónév vagy jelszó', - 'Invalid username or code' => 'Hibás felhasználónév vagy kód + 'Invalid username or code' => 'Hibás felhasználónév vagy kód', 'Passwords not match' => 'A jelszavak nem egyeznek meg', 'Please enter valid email address.' => 'Kérlek valós e-mail címet adj meg!', 'Field "%s" can not be blank.' => 'A(z) "%s" mező nem lehet üres.', diff --git a/web/templates/admin/add_cron.html b/web/templates/admin/add_cron.html index c988cba9b..ac998b9c1 100644 --- a/web/templates/admin/add_cron.html +++ b/web/templates/admin/add_cron.html @@ -34,7 +34,7 @@
- @@ -44,7 +44,7 @@ - @@ -54,7 +54,7 @@ - @@ -64,7 +64,7 @@ - @@ -74,7 +74,7 @@ - @@ -84,22 +84,22 @@ -
+
+
+
+
+
+
- > + >
- - diff --git a/web/templates/admin/add_db.html b/web/templates/admin/add_db.html index 438824ab3..b864043b4 100644 --- a/web/templates/admin/add_db.html +++ b/web/templates/admin/add_db.html @@ -54,12 +54,12 @@
+ +
- - @@ -70,7 +70,7 @@ - @@ -81,17 +81,17 @@ - - @@ -109,7 +109,7 @@ - @@ -128,7 +128,7 @@ - @@ -174,7 +174,7 @@ - @@ -186,10 +186,10 @@
+
+
+
+ /
- +
+
+
+
+
- - diff --git a/web/templates/admin/add_dns.html b/web/templates/admin/add_dns.html index c7d042594..c78393d3a 100644 --- a/web/templates/admin/add_dns.html +++ b/web/templates/admin/add_dns.html @@ -45,7 +45,7 @@
+ +
- @@ -55,7 +55,7 @@ - @@ -65,15 +65,15 @@ - -
+
+
+
- +
+ - @@ -83,7 +83,7 @@ - @@ -93,7 +93,7 @@ - @@ -123,10 +123,10 @@
+ ()
+ TTL
+
- - diff --git a/web/templates/admin/add_dns_rec.html b/web/templates/admin/add_dns_rec.html index 4fb6ad71b..f79eb0b2d 100644 --- a/web/templates/admin/add_dns_rec.html +++ b/web/templates/admin/add_dns_rec.html @@ -34,7 +34,7 @@
+ +
- @@ -44,7 +44,7 @@ - @@ -55,7 +55,7 @@ - @@ -78,7 +78,7 @@ - @@ -88,7 +88,7 @@ - @@ -100,10 +100,10 @@
+
+
+
+
+ ()
- - diff --git a/web/templates/admin/add_ip.html b/web/templates/admin/add_ip.html index 2957bd6c4..6bb0ec5fe 100644 --- a/web/templates/admin/add_ip.html +++ b/web/templates/admin/add_ip.html @@ -45,7 +45,7 @@
+ +
- @@ -55,7 +55,7 @@ - @@ -65,7 +65,7 @@ - @@ -83,25 +83,20 @@ - - - - -
+
+
+
- + +
- onclick="javascript:elementHideShow('usrtable');"> -
+ - - - @@ -127,7 +122,7 @@ - @@ -141,10 +136,10 @@
+
+
+ ()
+ ()
- - diff --git a/web/templates/admin/add_mail.html b/web/templates/admin/add_mail.html index 3c839b482..3f284b7dc 100644 --- a/web/templates/admin/add_mail.html +++ b/web/templates/admin/add_mail.html @@ -34,7 +34,7 @@
+ +
- @@ -44,42 +44,27 @@ - - - - - - - - - - - -
+
- + +
- > + +
- -
- > -
- -
- > + +
- - diff --git a/web/templates/admin/add_mail_acc.html b/web/templates/admin/add_mail_acc.html index bbf943e62..65afefeab 100644 --- a/web/templates/admin/add_mail_acc.html +++ b/web/templates/admin/add_mail_acc.html @@ -55,7 +55,7 @@
+ +
- @@ -65,7 +65,7 @@ - @@ -75,25 +75,25 @@ - - -
+
+
+ /
- +
+
+ - @@ -103,7 +103,7 @@ - @@ -113,7 +113,7 @@ - @@ -123,26 +123,20 @@ - - - - -
+ ()
+ ()
+ ()
- + +
- > -
- - diff --git a/web/templates/admin/add_package.html b/web/templates/admin/add_package.html index 56777f656..833b088e2 100644 --- a/web/templates/admin/add_package.html +++ b/web/templates/admin/add_package.html @@ -35,7 +35,7 @@
+ +
- @@ -45,7 +45,7 @@ - @@ -68,7 +68,7 @@ - @@ -91,7 +91,7 @@ - @@ -114,7 +114,7 @@ - @@ -137,7 +137,7 @@ - @@ -147,7 +147,7 @@ - @@ -157,7 +157,7 @@ - @@ -167,7 +167,7 @@ - @@ -177,7 +177,7 @@ - @@ -187,7 +187,7 @@ - @@ -197,7 +197,7 @@ - @@ -207,7 +207,7 @@ - @@ -217,7 +217,7 @@ - @@ -227,7 +227,7 @@ - @@ -237,7 +237,7 @@ - @@ -247,7 +247,7 @@ - @@ -274,10 +274,10 @@
+
+
+
+
+
+
+ ()
+
+ ()
+
+ ()
+
+
+
+ ()
+ ()
+
- - diff --git a/web/templates/admin/add_user.html b/web/templates/admin/add_user.html index b645e7ac9..2913a9497 100644 --- a/web/templates/admin/add_user.html +++ b/web/templates/admin/add_user.html @@ -53,7 +53,7 @@
+ +
- @@ -63,17 +63,17 @@ - @@ -83,7 +83,7 @@ - @@ -107,7 +107,7 @@ - @@ -133,7 +133,7 @@ - @@ -143,7 +143,7 @@ - @@ -153,7 +153,7 @@ - @@ -166,10 +166,10 @@
+
+ /
- +
+
+
+
+
+
- - diff --git a/web/templates/admin/edit_backup_exclusions.html b/web/templates/admin/edit_backup_exclusions.html index 770966eb5..e2f974d78 100644 --- a/web/templates/admin/edit_backup_exclusions.html +++ b/web/templates/admin/edit_backup_exclusions.html @@ -38,7 +38,7 @@
+ +
- @@ -48,7 +48,7 @@ - @@ -58,7 +58,7 @@ - @@ -68,7 +68,7 @@ - @@ -78,7 +78,7 @@ - @@ -88,7 +88,7 @@ - @@ -100,10 +100,10 @@
+
+
+
+
+
+
- - diff --git a/web/templates/admin/edit_cron.html b/web/templates/admin/edit_cron.html index 9a6cd1bcb..786180a0b 100644 --- a/web/templates/admin/edit_cron.html +++ b/web/templates/admin/edit_cron.html @@ -40,7 +40,7 @@
+ +
- @@ -50,7 +50,7 @@ - @@ -60,7 +60,7 @@ - @@ -70,7 +70,7 @@ - @@ -80,7 +80,7 @@ - @@ -90,22 +90,22 @@ -
+
+
+
+
+
+
- > + >
- - @@ -113,4 +113,4 @@
+ +
- + \ No newline at end of file diff --git a/web/templates/admin/edit_db.html b/web/templates/admin/edit_db.html index 8a7af352d..96111abdd 100644 --- a/web/templates/admin/edit_db.html +++ b/web/templates/admin/edit_db.html @@ -61,7 +61,7 @@
- @@ -72,7 +72,7 @@ - @@ -83,17 +83,17 @@ - @@ -103,7 +103,7 @@ - @@ -113,7 +113,7 @@ - @@ -125,10 +125,10 @@
+
+
+ /
- +
+
+
- - diff --git a/web/templates/admin/edit_dns.html b/web/templates/admin/edit_dns.html index 017ffca65..ff28fc8e5 100644 --- a/web/templates/admin/edit_dns.html +++ b/web/templates/admin/edit_dns.html @@ -40,7 +40,7 @@
+ +
- @@ -50,7 +50,7 @@ - @@ -60,7 +60,7 @@ - @@ -81,7 +81,7 @@ - @@ -91,7 +91,7 @@ - @@ -101,7 +101,7 @@ - @@ -113,10 +113,10 @@
+
+
+
+ ()
+ SOA
+ TTL
- - diff --git a/web/templates/admin/edit_dns_rec.html b/web/templates/admin/edit_dns_rec.html index ad900fa75..b9e5f97c8 100644 --- a/web/templates/admin/edit_dns_rec.html +++ b/web/templates/admin/edit_dns_rec.html @@ -40,7 +40,7 @@
+ +
- @@ -51,7 +51,7 @@ - @@ -61,7 +61,7 @@ - @@ -71,7 +71,7 @@ - @@ -81,7 +81,7 @@ - @@ -91,7 +91,7 @@ - @@ -104,10 +104,10 @@
+
+
+
+
+ ()
+ ()
- - diff --git a/web/templates/admin/edit_ip.html b/web/templates/admin/edit_ip.html index 49e97b1c5..a166a2d14 100644 --- a/web/templates/admin/edit_ip.html +++ b/web/templates/admin/edit_ip.html @@ -52,7 +52,7 @@
+ +
- @@ -62,7 +62,7 @@ - @@ -72,7 +72,7 @@ - @@ -82,35 +82,36 @@ - - - - - - - - - @@ -120,7 +121,7 @@ - @@ -133,10 +134,10 @@
+
+
+
- + +
- + + + + + + + + +
+ +
+ +
- -
- -
+ ()
+ ()
- - @@ -144,4 +145,4 @@
+ +
- + \ No newline at end of file diff --git a/web/templates/admin/edit_mail.html b/web/templates/admin/edit_mail.html index 4f4e82006..e9317d1c2 100644 --- a/web/templates/admin/edit_mail.html +++ b/web/templates/admin/edit_mail.html @@ -40,7 +40,7 @@
- @@ -50,37 +50,22 @@ - - - - - - - - - - - - - @@ -92,10 +77,10 @@
+
- + +
- > + +
- + +
- > -
- -
- > -
+
- - diff --git a/web/templates/admin/edit_mail_acc.html b/web/templates/admin/edit_mail_acc.html index c427685b1..1ca35090a 100644 --- a/web/templates/admin/edit_mail_acc.html +++ b/web/templates/admin/edit_mail_acc.html @@ -62,7 +62,7 @@
+ +
- @@ -74,17 +74,17 @@ - @@ -94,7 +94,7 @@ - @@ -104,7 +104,7 @@ - @@ -114,27 +114,17 @@ - - - - - - - - -
+
+ /
- + ()
+ ()
+ ()
- + +
- > + +
- -
- onclick="javascript:elementHideShow('autoreplytable');"> -
+
@@ -152,10 +142,10 @@
- - diff --git a/web/templates/admin/edit_package.html b/web/templates/admin/edit_package.html index 079d637b5..e7248659e 100644 --- a/web/templates/admin/edit_package.html +++ b/web/templates/admin/edit_package.html @@ -40,7 +40,7 @@
+ +
- @@ -51,7 +51,7 @@ - @@ -74,7 +74,7 @@ - @@ -97,7 +97,7 @@ - @@ -120,7 +120,7 @@ - @@ -143,7 +143,7 @@ - @@ -153,7 +153,7 @@ - @@ -163,7 +163,7 @@ - @@ -173,7 +173,7 @@ - @@ -183,7 +183,7 @@ - @@ -193,7 +193,7 @@ - @@ -203,7 +203,7 @@ - @@ -213,7 +213,7 @@ - @@ -223,7 +223,7 @@ - @@ -233,7 +233,7 @@ - @@ -243,7 +243,7 @@ - @@ -253,7 +253,7 @@ - @@ -280,10 +280,10 @@
+
+
+
+
+
+
+ ()
+
+ ()
+
+ ()
+
+
+
+ ()
+ ()
+
- - diff --git a/web/templates/admin/edit_user.html b/web/templates/admin/edit_user.html index c1b93a3c5..bec90e90d 100644 --- a/web/templates/admin/edit_user.html +++ b/web/templates/admin/edit_user.html @@ -52,7 +52,7 @@
+ +
- @@ -62,17 +62,17 @@ - @@ -82,7 +82,7 @@ - @@ -103,7 +103,7 @@ - @@ -127,7 +127,7 @@ - @@ -137,7 +137,7 @@ - @@ -147,7 +147,7 @@ - @@ -168,7 +168,7 @@ - @@ -195,10 +195,10 @@
+
+ /
- +
+
+
+
+
+
+
- - diff --git a/web/templates/admin/list_backup.html b/web/templates/admin/list_backup.html index 3fb26ed11..b532f6b4e 100644 --- a/web/templates/admin/list_backup.html +++ b/web/templates/admin/list_backup.html @@ -1,6 +1,6 @@
+ +
-