From cc062abfc32e952de32e1b89ce5c05a6dfcff00e Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Sun, 5 Oct 2014 14:47:55 +0300 Subject: [PATCH] Connected web interface with vesta.conf --- web/add/db/index.php | 11 +++------ web/add/mail/index.php | 5 +---- web/inc/main.php | 7 ++++++ web/list/db/index.php | 5 ----- web/list/mail/index.php | 6 ----- web/login/index.php | 32 ++++++++++----------------- web/reset/index.php | 24 +++++++------------- web/templates/admin/add_cron.html | 2 +- web/templates/admin/add_db.html | 4 ++-- web/templates/admin/add_dns.html | 2 +- web/templates/admin/add_dns_rec.html | 2 +- web/templates/admin/add_firewall.html | 2 +- web/templates/admin/add_ip.html | 2 +- web/templates/admin/add_mail.html | 2 +- web/templates/admin/add_mail_acc.html | 2 +- web/templates/admin/add_package.html | 2 +- web/templates/admin/add_user.html | 2 +- web/templates/admin/add_web.html | 6 ++--- web/templates/admin/edit_web.html | 4 ++-- web/templates/admin/list_db.html | 4 ++-- web/templates/admin/list_mail.html | 2 +- web/templates/admin/panel.html | 2 ++ web/templates/user/list_db.html | 4 ++-- web/templates/user/list_mail.html | 2 +- 24 files changed, 55 insertions(+), 81 deletions(-) diff --git a/web/add/db/index.php b/web/add/db/index.php index a9d7e8fa7..4164f290b 100644 --- a/web/add/db/index.php +++ b/web/add/db/index.php @@ -64,17 +64,14 @@ if (!empty($_POST['ok'])) { // 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); 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'] == 'mysql') && (!empty($_SESSION['DB_PMA_URL']))) $db_admin_link = $_SESSION['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']; + if (($_POST['v_type'] == 'pgsql') && (!empty($_SESSION['DB_PGA_URL']))) $db_admin_link = $_SESSION['DB_PGA_URL']; } // Email login credentials @@ -109,9 +106,7 @@ top_panel($user,$TAB); $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); +$db_types = split(",",$_SESSION['DB_SYSTEM']); // List available database servers $db_hosts = array(); diff --git a/web/add/mail/index.php b/web/add/mail/index.php index 41c0714d9..518b2e7cf 100644 --- a/web/add/mail/index.php +++ b/web/add/mail/index.php @@ -144,12 +144,9 @@ if (!empty($_POST['ok_acc'])) { // 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']; + if (!empty($_SESSION['MAIL_URL'])) $webmail = $_SESSION['MAIL_URL']; } // Flush field values on success diff --git a/web/inc/main.php b/web/inc/main.php index 2ce468130..f3aafb9bb 100644 --- a/web/inc/main.php +++ b/web/inc/main.php @@ -1,5 +1,12 @@ $value) { + $_SESSION[$key] = $value; +} + +// Set default language +if (empty($_SESSION['language'])) $_SESSION['language']=$_SESSION['LANGUAGE']; +if (empty($_SESSION['language'])) $_SESSION['language']='en'; + // Auth if (isset($_POST['user']) && isset($_POST['password'])) { $v_user = escapeshellarg($_POST['user']); @@ -33,17 +45,6 @@ if (isset($_POST['user']) && isset($_POST['password'])) { exec(VESTA_CMD ."v-check-user-password ".$v_user." ".$v_password." '".$_SERVER["REMOTE_ADDR"]."'", $output, $return_var); if ( $return_var > 0 ) { $ERROR = "".__('Invalid username or password').""; - - // Set system language - unset($output); - exec (VESTA_CMD . "v-list-sys-config json", $output, $return_var); - $data = json_decode(implode('', $output), true); - if (!empty( $data['config']['LANGUAGE'])) { - $_SESSION['language'] = $data['config']['LANGUAGE']; - } else { - $_SESSION['language'] = 'en'; - } - require_once($_SERVER['DOCUMENT_ROOT'].'/inc/i18n/'.$_SESSION['language'].'.php'); require_once('../templates/header.html'); require_once('../templates/login.html'); @@ -65,15 +66,6 @@ if (isset($_POST['user']) && isset($_POST['password'])) { } } } else { - // Set system language - exec (VESTA_CMD . "v-list-sys-config json", $output, $return_var); - $data = json_decode(implode('', $output), true); - if (!empty( $data['config']['LANGUAGE'])) { - $_SESSION['language'] = $data['config']['LANGUAGE']; - } else { - $_SESSION['language'] = 'en'; - } - require_once($_SERVER['DOCUMENT_ROOT'].'/inc/i18n/'.$_SESSION['language'].'.php'); require_once('../templates/header.html'); require_once('../templates/login.html'); diff --git a/web/reset/index.php b/web/reset/index.php index f27c396ea..bd8ccdc5e 100644 --- a/web/reset/index.php +++ b/web/reset/index.php @@ -70,27 +70,19 @@ if ((!empty($_POST['user'])) && (!empty($_POST['code'])) && (!empty($_POST['pass } } +// Set system language +exec (VESTA_CMD . "v-list-sys-config json", $output, $return_var); +$data = json_decode(implode('', $output), true); +if (!empty( $data['config']['LANGUAGE'])) { + $_SESSION['language'] = $data['config']['LANGUAGE']; +} else { + $_SESSION['language'] = 'en'; +} if (empty($_GET['action'])) { - // Set system language - exec (VESTA_CMD . "v-list-sys-config json", $output, $return_var); - $data = json_decode(implode('', $output), true); - if (!empty( $data['config']['LANGUAGE'])) { - $_SESSION['language'] = $data['config']['LANGUAGE']; - } else { - $_SESSION['language'] = 'en'; - } require_once '../templates/header.html'; require_once '../templates/reset_1.html'; } else { - // Set system language - exec (VESTA_CMD . "v-list-sys-config json", $output, $return_var); - $data = json_decode(implode('', $output), true); - if (!empty( $data['config']['LANGUAGE'])) { - $_SESSION['language'] = $data['config']['LANGUAGE']; - } else { - $_SESSION['language'] = 'en'; - } require_once '../templates/header.html'; if ($_GET['action'] == 'code' ) { require_once '../templates/reset_2.html'; diff --git a/web/templates/admin/add_cron.html b/web/templates/admin/add_cron.html index ac998b9c1..c26047114 100644 --- a/web/templates/admin/add_cron.html +++ b/web/templates/admin/add_cron.html @@ -24,7 +24,7 @@
- +
diff --git a/web/templates/admin/add_db.html b/web/templates/admin/add_db.html index b864043b4..a81415c83 100644 --- a/web/templates/admin/add_db.html +++ b/web/templates/admin/add_db.html @@ -44,7 +44,7 @@ document.v_add_db.v_password.value = randomstring; } -
+
@@ -54,7 +54,7 @@
- diff --git a/web/templates/admin/add_dns.html b/web/templates/admin/add_dns.html index c78393d3a..cbbef75be 100644 --- a/web/templates/admin/add_dns.html +++ b/web/templates/admin/add_dns.html @@ -35,7 +35,7 @@ } -
+
+
diff --git a/web/templates/admin/add_dns_rec.html b/web/templates/admin/add_dns_rec.html index f79eb0b2d..3083c9297 100644 --- a/web/templates/admin/add_dns_rec.html +++ b/web/templates/admin/add_dns_rec.html @@ -24,7 +24,7 @@ -
+
diff --git a/web/templates/admin/add_firewall.html b/web/templates/admin/add_firewall.html index 9c7bb156b..eb7b795c2 100644 --- a/web/templates/admin/add_firewall.html +++ b/web/templates/admin/add_firewall.html @@ -35,7 +35,7 @@ } -
+
diff --git a/web/templates/admin/add_ip.html b/web/templates/admin/add_ip.html index 6bb0ec5fe..94ec74230 100644 --- a/web/templates/admin/add_ip.html +++ b/web/templates/admin/add_ip.html @@ -35,7 +35,7 @@ } -
+
diff --git a/web/templates/admin/add_mail.html b/web/templates/admin/add_mail.html index 3f284b7dc..afc9ca4c2 100644 --- a/web/templates/admin/add_mail.html +++ b/web/templates/admin/add_mail.html @@ -24,7 +24,7 @@ -
+
diff --git a/web/templates/admin/add_mail_acc.html b/web/templates/admin/add_mail_acc.html index 65afefeab..12c96262a 100644 --- a/web/templates/admin/add_mail_acc.html +++ b/web/templates/admin/add_mail_acc.html @@ -45,7 +45,7 @@ } -
+
diff --git a/web/templates/admin/add_package.html b/web/templates/admin/add_package.html index 833b088e2..27cb1e19e 100644 --- a/web/templates/admin/add_package.html +++ b/web/templates/admin/add_package.html @@ -25,7 +25,7 @@ -
+
diff --git a/web/templates/admin/add_user.html b/web/templates/admin/add_user.html index 2913a9497..05e142671 100644 --- a/web/templates/admin/add_user.html +++ b/web/templates/admin/add_user.html @@ -43,7 +43,7 @@ } -
+
diff --git a/web/templates/admin/add_web.html b/web/templates/admin/add_web.html index b8522c1ab..ffbc386ed 100644 --- a/web/templates/admin/add_web.html +++ b/web/templates/admin/add_web.html @@ -63,7 +63,7 @@ } -
+
@@ -284,7 +284,7 @@
class="ftptable ftptable-nrm" name="v_add_domain_ftp"> @@ -365,7 +365,7 @@
- # () + # ()
diff --git a/web/templates/admin/edit_web.html b/web/templates/admin/edit_web.html index dd2696ce5..e70617d20 100644 --- a/web/templates/admin/edit_web.html +++ b/web/templates/admin/edit_web.html @@ -316,7 +316,7 @@
- # () + # ()
@@ -398,7 +398,7 @@
- # () + # ()
diff --git a/web/templates/admin/list_db.html b/web/templates/admin/list_db.html index 81e883868..e3de459d9 100644 --- a/web/templates/admin/list_db.html +++ b/web/templates/admin/list_db.html @@ -45,10 +45,10 @@ if ($data[$key]['HOST'] != 'localhost' ) $http_host = $data[$key]['HOST']; if ($data[$key]['TYPE'] == 'mysql') $db_admin = "phpMyAdmin"; if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/phpmyadmin/"; - if (($data[$key]['TYPE'] == 'mysql') && (!empty($sys['config']['DB_PMA_URL']))) $db_admin_link = $sys['config']['DB_PMA_URL']; + if (($data[$key]['TYPE'] == 'mysql') && (!empty($_SESSION['DB_PMA_URL']))) $db_admin_link = $_SESSION['DB_PMA_URL']; if ($data[$key]['TYPE'] == 'pgsql') $db_admin = "phpPgAdmin"; if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$http_host."/phppgadmin/"; - if (($data[$key]['TYPE'] == 'pgsql') && (!empty($sys['config']['DB_PGA_URL']))) $db_admin_link = $sys['config']['DB_PGA_URL']; + if (($data[$key]['TYPE'] == 'pgsql') && (!empty($_SESSION['DB_PGA_URL']))) $db_admin_link = $_SESSION['DB_PGA_URL']; ?>
- # () + # ()
diff --git a/web/templates/admin/list_mail.html b/web/templates/admin/list_mail.html index 6aa12afc4..7de94f246 100644 --- a/web/templates/admin/list_mail.html +++ b/web/templates/admin/list_mail.html @@ -32,7 +32,7 @@ $value) { ++$i; diff --git a/web/templates/admin/panel.html b/web/templates/admin/panel.html index 2ef51adeb..d8bcea573 100644 --- a/web/templates/admin/panel.html +++ b/web/templates/admin/panel.html @@ -8,7 +8,9 @@ + + diff --git a/web/templates/user/list_db.html b/web/templates/user/list_db.html index 008560cfa..b7f7fb99c 100644 --- a/web/templates/user/list_db.html +++ b/web/templates/user/list_db.html @@ -43,10 +43,10 @@ if ($data[$key]['HOST'] != 'localhost' ) $http_host = $data[$key]['HOST']; if ($data[$key]['TYPE'] == 'mysql') $db_admin = "phpMyAdmin"; if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/phpmyadmin/"; - if (($data[$key]['TYPE'] == 'mysql') && (!empty($sys['config']['DB_PMA_URL']))) $db_admin_link = $sys['config']['DB_PMA_URL']; + if (($data[$key]['TYPE'] == 'mysql') && (!empty($_SESSION['DB_PMA_URL']))) $db_admin_link = $_SESSION['DB_PMA_URL']; if ($data[$key]['TYPE'] == 'pgsql') $db_admin = "phpPgAdmin"; if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$http_host."/phppgadmin/"; - if (($data[$key]['TYPE'] == 'pgsql') && (!empty($sys['config']['DB_PGA_URL']))) $db_admin_link = $sys['config']['DB_PGA_URL']; + if (($data[$key]['TYPE'] == 'pgsql') && (!empty($_SESSION['DB_PGA_URL']))) $db_admin_link = $_SESSION['DB_PGA_URL']; ?>
diff --git a/web/templates/user/list_mail.html b/web/templates/user/list_mail.html index c13bd1e29..7d45a00bb 100644 --- a/web/templates/user/list_mail.html +++ b/web/templates/user/list_mail.html @@ -30,7 +30,7 @@ $value) { ++$i;