From 07e8760e608a37e82a47a8cb47642b55acf3d3ac Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 10 Aug 2025 12:55:40 +0000 Subject: [PATCH 1/4] Fix PHP 7.x compatibility issues in Vesta Control Panel Co-authored-by: peca --- web/add/favorite/index.php | 2 +- web/edit/server/index.php | 11 ++++-- web/inc/i18n.php | 6 +++- web/inc/main.php | 34 +++++++++++++++---- web/list/backup/index.php | 4 +-- web/list/cron/index.php | 2 +- web/list/db/index.php | 2 +- web/list/directory/index.php | 1 + web/list/dns/index.php | 4 +-- web/list/firewall/banlist/index.php | 2 +- web/list/firewall/banlist/ip_info.php | 4 +-- web/list/firewall/index.php | 2 +- web/list/ip/index.php | 2 +- web/list/mail/index.php | 4 +-- web/list/notifications/index.php | 4 +-- web/list/package/index.php | 1 + web/list/rrd/index.php | 1 + web/list/server/index.php | 2 ++ web/list/stats/index.php | 6 ++-- web/list/updates/index.php | 1 + web/list/user/index.php | 2 +- web/list/web/index.php | 2 +- web/login/index.php | 49 +++++++++++++++++++++++---- web/reset/index.php | 14 ++++++-- web/search/index.php | 1 + web/templates/admin/add_web.html | 2 +- web/templates/admin/list_stats.html | 2 +- web/templates/right.html | 2 +- web/templates/user/list_stats.html | 2 +- 29 files changed, 128 insertions(+), 43 deletions(-) diff --git a/web/add/favorite/index.php b/web/add/favorite/index.php index a3054d99..4159c421 100644 --- a/web/add/favorite/index.php +++ b/web/add/favorite/index.php @@ -1,4 +1,4 @@ - $value) { $v_dns_cluster = 'yes'; @@ -49,11 +51,12 @@ foreach ($dns_cluster as $key => $value) { // List Database hosts exec (VESTA_CMD."v-list-database-hosts json", $output, $return_var); $db_hosts = json_decode(implode('', $output), true); +if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($db_hosts)) { $db_hosts = array(); } unset($output); $v_mysql_hosts = array_values(array_filter($db_hosts, function($host){return $host['TYPE'] === 'mysql';})); -$v_mysql = count($v_mysql_hosts) ? 'yes' : 'no'; +$v_mysql = (version_compare(PHP_VERSION, '5.6', '==') ? count($v_mysql_hosts) : (is_array($v_mysql_hosts) ? count($v_mysql_hosts) : 0)) ? 'yes' : 'no'; $v_pgsql_hosts = array_values(array_filter($db_hosts, function($host){return $host['TYPE'] === 'pgsql';})); -$v_pgsql = count($v_pgsql_hosts) ? 'yes' : 'no'; +$v_pgsql = (version_compare(PHP_VERSION, '5.6', '==') ? count($v_pgsql_hosts) : (is_array($v_pgsql_hosts) ? count($v_pgsql_hosts) : 0)) ? 'yes' : 'no'; unset($db_hosts); // List backup settings @@ -81,12 +84,14 @@ foreach ($backup_types as $backup_type) { // List ssl web domains exec (VESTA_CMD."v-search-ssl-certificates json", $output, $return_var); $v_ssl_domains = json_decode(implode('', $output), true); +if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($v_ssl_domains)) { $v_ssl_domains = array(); } //$v_vesta_certificate unset($output); // List ssl certificate info exec (VESTA_CMD."v-list-sys-vesta-ssl json", $output, $return_var); $v_sys_ssl_str = json_decode(implode('', $output), true); +if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($v_sys_ssl_str)) { $v_sys_ssl_str = array('VESTA'=>array()); } unset($output); $v_sys_ssl_crt = $v_sys_ssl_str['VESTA']['CRT']; $v_sys_ssl_key = $v_sys_ssl_str['VESTA']['KEY']; @@ -103,6 +108,7 @@ $v_sys_ssl_issuer = $v_sys_ssl_str['VESTA']['ISSUER']; if (!empty($_SESSION['VESTA_CERTIFICATE'])); { exec (VESTA_CMD."v-list-sys-mail-ssl json", $output, $return_var); $v_mail_ssl_str = json_decode(implode('', $output), true); + if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($v_mail_ssl_str)) { $v_mail_ssl_str = array('MAIL'=>array()); } unset($output); $v_mail_ssl_crt = $v_mail_ssl_str['MAIL']['CRT']; $v_mail_ssl_key = $v_mail_ssl_str['MAIL']['KEY']; @@ -242,6 +248,7 @@ if (!empty($_POST['save'])) { // List SSL certificate info exec (VESTA_CMD."v-list-sys-mail-ssl json", $output, $return_var); $v_mail_ssl_str = json_decode(implode('', $output), true); + if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($v_mail_ssl_str)) { $v_mail_ssl_str = array('MAIL'=>array()); } unset($output); $v_mail_ssl_crt = $v_mail_ssl_str['MAIL']['CRT']; $v_mail_ssl_key = $v_mail_ssl_str['MAIL']['KEY']; diff --git a/web/inc/i18n.php b/web/inc/i18n.php index 9d6c1b7e..5a41c54a 100644 --- a/web/inc/i18n.php +++ b/web/inc/i18n.php @@ -89,7 +89,11 @@ function detect_user_language($fallback='en') { $accept_langs_sorted[$code] = (double)$q; } } - arsort($accept_langs_sorted); + if (version_compare(PHP_VERSION, '5.6', '==')) { + arsort($accept_langs_sorted); + } else { + if (!empty($accept_langs_sorted)) { arsort($accept_langs_sorted); } + } // List languages exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var); diff --git a/web/inc/main.php b/web/inc/main.php index f13e4142..8a969cb9 100644 --- a/web/inc/main.php +++ b/web/inc/main.php @@ -109,8 +109,13 @@ if (isset($_SESSION['look']) && ( $_SESSION['look'] != 'admin' )) { function get_favourites(){ exec (VESTA_CMD."v-list-user-favourites ".$_SESSION['user']." json", $output, $return_var); // $data = json_decode(implode('', $output).'}', true); - $data = json_decode(implode('', $output), true); - $data = array_reverse($data,true); + if (version_compare(PHP_VERSION, '5.6', '==')) { + $data = json_decode(implode('', $output), true); + $data = array_reverse($data, true); + } else { + $data = json_decode(implode('', $output), true); + $data = is_array($data) ? array_reverse($data, true) : array(); + } $favourites = array(); foreach($data['Favourites'] as $key => $favourite){ @@ -188,16 +193,26 @@ function top_panel($user, $TAB) { header("Location: /error/"); exit; } - $panel = json_decode(implode('', $output), true); + if (version_compare(PHP_VERSION, '5.6', '==')) { + $panel = json_decode(implode('', $output), true); + } else { + $panel = json_decode(implode('', $output), true); + if (!is_array($panel)) { $panel = array(); } + } unset($output); // getting notifications $command = VESTA_CMD."v-list-user-notifications '".$user."' 'json'"; exec ($command, $output, $return_var); - $notifications = json_decode(implode('', $output), true); + if (version_compare(PHP_VERSION, '5.6', '==')) { + $notifications = json_decode(implode('', $output), true); + } else { + $notifications = json_decode(implode('', $output), true); + if (!is_array($notifications)) { $notifications = array(); } + } foreach($notifications as $message){ - if($message['ACK'] == 'no'){ + if(isset($message['ACK']) && $message['ACK'] == 'no'){ $panel[$user]['NOTIFICATIONS'] = 'yes'; break; } @@ -214,7 +229,14 @@ function top_panel($user, $TAB) { function translate_date($date){ $date = strtotime($date); - return strftime("%d  ", $date).__(strftime("%b", $date)).strftime("  %Y", $date); + if (version_compare(PHP_VERSION, '5.6', '==')) { + return strftime("%d  ", $date).__(strftime("%b", $date)).strftime("  %Y", $date); + } else { + $day = date('d', $date); + $mon = date('M', $date); + $year = date('Y', $date); + return $day.'  '.__($mon).'  '.$year; + } } function humanize_time($usage) { diff --git a/web/list/backup/index.php b/web/list/backup/index.php index 2e29a50a..28460a70 100644 --- a/web/list/backup/index.php +++ b/web/list/backup/index.php @@ -9,14 +9,14 @@ include($_SERVER['DOCUMENT_ROOT'].'/inc/main.php'); if (empty($_GET['backup'])){ exec (VESTA_CMD."v-list-user-backups $user json", $output, $return_var); $data = json_decode(implode('', $output), true); - $data = array_reverse($data,true); + if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } unset($output); render_page($user, $TAB, 'list_backup'); } else { exec (VESTA_CMD."v-list-user-backup $user ".escapeshellarg($_GET['backup'])." json", $output, $return_var); $data = json_decode(implode('', $output), true); - $data = array_reverse($data,true); + if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } unset($output); render_page($user, $TAB, 'list_backup_detail'); diff --git a/web/list/cron/index.php b/web/list/cron/index.php index 230483cb..0014be84 100644 --- a/web/list/cron/index.php +++ b/web/list/cron/index.php @@ -8,7 +8,7 @@ include($_SERVER['DOCUMENT_ROOT'].'/inc/main.php'); // Data exec (VESTA_CMD."v-list-cron-jobs $user json", $output, $return_var); $data = json_decode(implode('', $output), true); -$data = array_reverse($data,true); +if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } unset($output); // Render page diff --git a/web/list/db/index.php b/web/list/db/index.php index 42129064..0a2560ef 100644 --- a/web/list/db/index.php +++ b/web/list/db/index.php @@ -8,7 +8,7 @@ include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); // Data exec (VESTA_CMD."v-list-databases $user json", $output, $return_var); $data = json_decode(implode('', $output), true); -$data = array_reverse($data, true); +if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } unset($output); // Render page diff --git a/web/list/directory/index.php b/web/list/directory/index.php index 7a57566c..0b845f00 100644 --- a/web/list/directory/index.php +++ b/web/list/directory/index.php @@ -22,6 +22,7 @@ if (empty($panel)) { exit; } $panel = json_decode(implode('', $output), true); +if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($panel)) { $panel = array(); } } $path_a = !empty($_REQUEST['dir_a']) ? htmlentities($_REQUEST['dir_a']) : ''; diff --git a/web/list/dns/index.php b/web/list/dns/index.php index 53d5980c..8da98594 100644 --- a/web/list/dns/index.php +++ b/web/list/dns/index.php @@ -9,14 +9,14 @@ include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); if (empty($_GET['domain'])){ exec (VESTA_CMD."v-list-dns-domains ".escapeshellarg($user)." json", $output, $return_var); $data = json_decode(implode('', $output), true); - $data = array_reverse($data, true); + if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } unset($output); render_page($user, $TAB, 'list_dns'); } else { exec (VESTA_CMD."v-list-dns-records ".escapeshellarg($user)." ".escapeshellarg($_GET['domain'])." json", $output, $return_var); $data = json_decode(implode('', $output), true); - $data = array_reverse($data, true); + if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } unset($output); render_page($user, $TAB, 'list_dns_rec'); diff --git a/web/list/firewall/banlist/index.php b/web/list/firewall/banlist/index.php index 6d8cddb4..b03a419d 100644 --- a/web/list/firewall/banlist/index.php +++ b/web/list/firewall/banlist/index.php @@ -14,7 +14,7 @@ if ($_SESSION['user'] != 'admin') { // Data exec (VESTA_CMD."v-list-firewall-ban json", $output, $return_var); $data = json_decode(implode('', $output), true); -$data = array_reverse($data, true); +if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } unset($output); // Render page diff --git a/web/list/firewall/banlist/ip_info.php b/web/list/firewall/banlist/ip_info.php index e7888a75..dd94a029 100644 --- a/web/list/firewall/banlist/ip_info.php +++ b/web/list/firewall/banlist/ip_info.php @@ -1,8 +1,8 @@ - $note){ $note['ID'] = $key; $data[$key] = $note; @@ -25,7 +25,7 @@ $TAB = 'NOTIFICATIONS'; // Data exec (VESTA_CMD."v-list-user-notifications $user json", $output, $return_var); $data = json_decode(implode('', $output), true); -$data = array_reverse($data,true); +if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } // Render page render_page($user, $TAB, 'list_notifications'); diff --git a/web/list/package/index.php b/web/list/package/index.php index 7d7f35e5..8bf029ab 100644 --- a/web/list/package/index.php +++ b/web/list/package/index.php @@ -15,6 +15,7 @@ if ($_SESSION['user'] != 'admin') { // Data exec (VESTA_CMD."v-list-user-packages json", $output, $return_var); $data = json_decode(implode('', $output), true); +if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($data)) { $data = array(); } unset($output); // Render page diff --git a/web/list/rrd/index.php b/web/list/rrd/index.php index 2c30b530..fd79e64f 100644 --- a/web/list/rrd/index.php +++ b/web/list/rrd/index.php @@ -18,6 +18,7 @@ if (!empty($_GET['period'])) { // Data exec (VESTA_CMD."v-list-sys-rrd json", $output, $return_var); $data = json_decode(implode('', $output), true); +if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($data)) { $data = array(); } unset($output); // Render page diff --git a/web/list/server/index.php b/web/list/server/index.php index b7150778..cda1fca9 100644 --- a/web/list/server/index.php +++ b/web/list/server/index.php @@ -116,9 +116,11 @@ if (isset($_GET['db'])) { // Data exec (VESTA_CMD."v-list-sys-info json", $output, $return_var); $sys = json_decode(implode('', $output), true); +if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($sys)) { $sys = array(); } unset($output); exec (VESTA_CMD."v-list-sys-services json", $output, $return_var); $data = json_decode(implode('', $output), true); +if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($data)) { $data = array(); } unset($output); // Render page diff --git a/web/list/stats/index.php b/web/list/stats/index.php index 3c730632..4db65f9b 100644 --- a/web/list/stats/index.php +++ b/web/list/stats/index.php @@ -10,13 +10,13 @@ if ($user == 'admin') { if (empty($_GET['user'])) { exec (VESTA_CMD."v-list-users-stats json", $output, $return_var); $data = json_decode(implode('', $output), true); - $data = array_reverse($data, true); + if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } unset($output); } else { $v_user = escapeshellarg($_GET['user']); exec (VESTA_CMD."v-list-user-stats $v_user json", $output, $return_var); $data = json_decode(implode('', $output), true); - $data = array_reverse($data, true); + if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } unset($output); } @@ -26,7 +26,7 @@ if ($user == 'admin') { } else { exec (VESTA_CMD."v-list-user-stats $user json", $output, $return_var); $data = json_decode(implode('', $output), true); - $data = array_reverse($data, true); + if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } unset($output); } diff --git a/web/list/updates/index.php b/web/list/updates/index.php index ef1f9b17..e27f4138 100644 --- a/web/list/updates/index.php +++ b/web/list/updates/index.php @@ -14,6 +14,7 @@ if ($_SESSION['user'] != 'admin') { // Data exec (VESTA_CMD."v-list-sys-vesta-updates json", $output, $return_var); $data = json_decode(implode('', $output), true); +if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($data)) { $data = array(); } unset($output); exec (VESTA_CMD."v-list-sys-vesta-autoupdate plain", $output, $return_var); $autoupdate = $output['0']; diff --git a/web/list/user/index.php b/web/list/user/index.php index da708edc..93a56ee1 100644 --- a/web/list/user/index.php +++ b/web/list/user/index.php @@ -12,7 +12,7 @@ if ($user == 'admin') { exec (VESTA_CMD . "v-list-user ".$user." json", $output, $return_var); } $data = json_decode(implode('', $output), true); -$data = array_reverse($data,true); +if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } // Check and get changelog if needed if ($user == 'admin') { diff --git a/web/list/web/index.php b/web/list/web/index.php index 688dfeaa..11b187dc 100644 --- a/web/list/web/index.php +++ b/web/list/web/index.php @@ -8,7 +8,7 @@ include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); // Data exec (VESTA_CMD."v-list-web-domains $user json", $output, $return_var); $data = json_decode(implode('', $output), true); -$data = array_reverse($data,true); +if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } $ips = json_decode(shell_exec(VESTA_CMD.'v-list-sys-ips json'), true); // Render page diff --git a/web/login/index.php b/web/login/index.php index 5de05451..f508c845 100644 --- a/web/login/index.php +++ b/web/login/index.php @@ -27,7 +27,12 @@ if (isset($_SESSION['user'])) { if ($_SESSION['user'] == 'admin' && !empty($_GET['loginas'])) { exec (VESTA_CMD . "v-list-user ".escapeshellarg($_GET['loginas'])." json", $output, $return_var); if ( $return_var == 0 ) { - $data = json_decode(implode('', $output), true); + if (version_compare(PHP_VERSION, '5.6', '==')) { + $data = json_decode(implode('', $output), true); + } else { + $data = json_decode(implode('', $output), true); + if (!is_array($data)) { $data = array(); } + } reset($data); $_SESSION['look'] = key($data); $_SESSION['look_alert'] = 'yes'; @@ -51,7 +56,12 @@ if (isset($_POST['user']) && isset($_POST['password'])) { // Get user's salt $output = ''; exec (VESTA_CMD."v-get-user-salt ".$v_user." ".$v_ip." json" , $output, $return_var); - $pam = json_decode(implode('', $output), true); + if (version_compare(PHP_VERSION, '5.6', '==')) { + $pam = json_decode(implode('', $output), true); + } else { + $pam = json_decode(implode('', $output), true); + if (!is_array($pam)) { $pam = array(); } + } if ( $return_var > 0 ) { $ERROR = "".__('Invalid username or password').""; } else { @@ -94,7 +104,12 @@ if (isset($_POST['user']) && isset($_POST['password'])) { // Get user speciefic parameters exec (VESTA_CMD . "v-list-user ".$v_user." json", $output, $return_var); - $data = json_decode(implode('', $output), true); + if (version_compare(PHP_VERSION, '5.6', '==')) { + $data = json_decode(implode('', $output), true); + } else { + $data = json_decode(implode('', $output), true); + if (!is_array($data)) { $data = array(); } + } // Define session user $_SESSION['user'] = key($data); @@ -106,7 +121,12 @@ if (isset($_POST['user']) && isset($_POST['password'])) { // Define language $output = ''; exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var); - $languages = json_decode(implode('', $output), true); + if (version_compare(PHP_VERSION, '5.6', '==')) { + $languages = json_decode(implode('', $output), true); + } else { + $languages = json_decode(implode('', $output), true); + if (!is_array($languages)) { $languages = array(); } + } if (in_array($data[$v_user]['LANGUAGE'], $languages)){ $_SESSION['language'] = $data[$v_user]['LANGUAGE']; } else { @@ -135,7 +155,12 @@ if (isset($_POST['user']) && isset($_POST['password'])) { // Check system configuration exec (VESTA_CMD . "v-list-sys-config json", $output, $return_var); -$data = json_decode(implode('', $output), true); +if (version_compare(PHP_VERSION, '5.6', '==')) { + $data = json_decode(implode('', $output), true); +} else { + $data = json_decode(implode('', $output), true); + if (!is_array($data)) { $data = array('config' => array()); } +} $sys_arr = $data['config']; foreach ($sys_arr as $key => $value) { $_SESSION[$key] = $value; @@ -145,12 +170,22 @@ foreach ($sys_arr as $key => $value) { if (empty($_SESSION['language'])) { $output = ''; exec (VESTA_CMD."v-list-sys-config json", $output, $return_var); - $config = json_decode(implode('', $output), true); + if (version_compare(PHP_VERSION, '5.6', '==')) { + $config = json_decode(implode('', $output), true); + } else { + $config = json_decode(implode('', $output), true); + if (!is_array($config)) { $config = array('config' => array('LANGUAGE' => 'en')); } + } $lang = $config['config']['LANGUAGE']; $output = ''; exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var); - $languages = json_decode(implode('', $output), true); + if (version_compare(PHP_VERSION, '5.6', '==')) { + $languages = json_decode(implode('', $output), true); + } else { + $languages = json_decode(implode('', $output), true); + if (!is_array($languages)) { $languages = array(); } + } if(in_array($lang, $languages)){ $_SESSION['language'] = $lang; } diff --git a/web/reset/index.php b/web/reset/index.php index 9a42b2cb..816d3155 100644 --- a/web/reset/index.php +++ b/web/reset/index.php @@ -24,7 +24,12 @@ if ((!empty($_POST['user'])) && (empty($_POST['code']))) { $cmd="/usr/bin/sudo /usr/local/vesta/bin/v-list-user"; exec ($cmd." ".$v_user." json", $output, $return_var); if ( $return_var == 0 ) { - $data = json_decode(implode('', $output), true); + if (version_compare(PHP_VERSION, '5.6', '==')) { + $data = json_decode(implode('', $output), true); + } else { + $data = json_decode(implode('', $output), true); + if (!is_array($data)) { $data = array(); } + } unset($output); exec("/usr/bin/sudo /usr/local/vesta/bin/v-get-user-value ".$v_user." RKEYEXP", $output, $return_var); $rkeyexp = trim(implode('', $output)); @@ -84,7 +89,12 @@ if ((!empty($_POST['user'])) && (!empty($_POST['code'])) && (!empty($_POST['pass $cmd="/usr/bin/sudo /usr/local/vesta/bin/v-list-user"; exec ($cmd." ".$v_user." json", $output, $return_var); if ( $return_var == 0 ) { - $data = json_decode(implode('', $output), true); + if (version_compare(PHP_VERSION, '5.6', '==')) { + $data = json_decode(implode('', $output), true); + } else { + $data = json_decode(implode('', $output), true); + if (!is_array($data)) { $data = array(); } + } unset($output); $rkey = $data[$user]['RKEY']; if (hash_equals($rkey, $_POST['code'])) { diff --git a/web/search/index.php b/web/search/index.php index 808b6f41..2b7f5c97 100644 --- a/web/search/index.php +++ b/web/search/index.php @@ -28,6 +28,7 @@ $command = $_SESSION['user'] == 'admin' exec (VESTA_CMD . $command, $output, $return_var); $data = json_decode(implode('', $output), true); +if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($data)) { $data = array(); } // Render page render_page($user, $TAB, 'list_search'); diff --git a/web/templates/admin/add_web.html b/web/templates/admin/add_web.html index 77e72239..7db3be5a 100644 --- a/web/templates/admin/add_web.html +++ b/web/templates/admin/add_web.html @@ -253,7 +253,7 @@ - + diff --git a/web/templates/admin/list_stats.html b/web/templates/admin/list_stats.html index bc3192d2..27637751 100644 --- a/web/templates/admin/list_stats.html +++ b/web/templates/admin/list_stats.html @@ -74,7 +74,7 @@
- +
diff --git a/web/templates/right.html b/web/templates/right.html index 88e1f5f0..bec69b4f 100644 --- a/web/templates/right.html +++ b/web/templates/right.html @@ -64,7 +64,7 @@ $output=''; exec (VESTA_CMD . "v-list-user ".$GLOBALS['CURRENT_USER_FINAL']." json", $output, $return_var); $data = json_decode(implode('', $output), true); - $data = array_reverse($data,true); + if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } //print_r($data); exit; $key=$GLOBALS['CURRENT_USER_FINAL']; if ($data[$key]['DISK_QUOTA']=='unlimited') echo __('unlimited'); diff --git a/web/templates/user/list_stats.html b/web/templates/user/list_stats.html index 7313060b..71e9765a 100644 --- a/web/templates/user/list_stats.html +++ b/web/templates/user/list_stats.html @@ -77,7 +77,7 @@
- +
From d944a44c7bf8b12ef289e3a1a5ad253bbcb8d9bb Mon Sep 17 00:00:00 2001 From: Peca Date: Sun, 10 Aug 2025 23:26:20 +0200 Subject: [PATCH 2/4] Refactor array initialization to remove PHP version checks in web/edit/server/index.php --- web/edit/server/index.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/web/edit/server/index.php b/web/edit/server/index.php index f2ba9637..d2aa5d40 100644 --- a/web/edit/server/index.php +++ b/web/edit/server/index.php @@ -36,13 +36,13 @@ if ($v_timezone == 'America/Halifax' ) $v_timezone = 'ADT'; // List supported languages exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var); $languages = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($languages)) { $languages = array(); } +if (!is_array($languages)) $languages = array(); unset($output); // List dns cluster hosts exec (VESTA_CMD."v-list-remote-dns-hosts json", $output, $return_var); $dns_cluster = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($dns_cluster)) { $dns_cluster = array(); } +if (!is_array($dns_cluster)) $dns_cluster = array(); unset($output); foreach ($dns_cluster as $key => $value) { $v_dns_cluster = 'yes'; @@ -51,12 +51,14 @@ foreach ($dns_cluster as $key => $value) { // List Database hosts exec (VESTA_CMD."v-list-database-hosts json", $output, $return_var); $db_hosts = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($db_hosts)) { $db_hosts = array(); } +if (!is_array($db_hosts)) $db_hosts = array(); unset($output); $v_mysql_hosts = array_values(array_filter($db_hosts, function($host){return $host['TYPE'] === 'mysql';})); -$v_mysql = (version_compare(PHP_VERSION, '5.6', '==') ? count($v_mysql_hosts) : (is_array($v_mysql_hosts) ? count($v_mysql_hosts) : 0)) ? 'yes' : 'no'; +$v_mysql = 'no'; +if (is_array($v_mysql_hosts) && count($v_mysql_hosts) > 0) $v_mysql = 'yes'; $v_pgsql_hosts = array_values(array_filter($db_hosts, function($host){return $host['TYPE'] === 'pgsql';})); -$v_pgsql = (version_compare(PHP_VERSION, '5.6', '==') ? count($v_pgsql_hosts) : (is_array($v_pgsql_hosts) ? count($v_pgsql_hosts) : 0)) ? 'yes' : 'no'; +$v_pgsql = 'no'; +if (is_array($v_pgsql_hosts) && count($v_pgsql_hosts) > 0) $v_pgsql = 'yes'; unset($db_hosts); // List backup settings @@ -84,14 +86,14 @@ foreach ($backup_types as $backup_type) { // List ssl web domains exec (VESTA_CMD."v-search-ssl-certificates json", $output, $return_var); $v_ssl_domains = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($v_ssl_domains)) { $v_ssl_domains = array(); } +if (!is_array($v_ssl_domains)) $v_ssl_domains = array(); //$v_vesta_certificate unset($output); // List ssl certificate info exec (VESTA_CMD."v-list-sys-vesta-ssl json", $output, $return_var); $v_sys_ssl_str = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($v_sys_ssl_str)) { $v_sys_ssl_str = array('VESTA'=>array()); } +if (!is_array($v_sys_ssl_str)) $v_sys_ssl_str = array('VESTA'=>array()); unset($output); $v_sys_ssl_crt = $v_sys_ssl_str['VESTA']['CRT']; $v_sys_ssl_key = $v_sys_ssl_str['VESTA']['KEY']; @@ -108,7 +110,7 @@ $v_sys_ssl_issuer = $v_sys_ssl_str['VESTA']['ISSUER']; if (!empty($_SESSION['VESTA_CERTIFICATE'])); { exec (VESTA_CMD."v-list-sys-mail-ssl json", $output, $return_var); $v_mail_ssl_str = json_decode(implode('', $output), true); - if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($v_mail_ssl_str)) { $v_mail_ssl_str = array('MAIL'=>array()); } + if (!is_array($v_mail_ssl_str)) $v_mail_ssl_str = array('MAIL'=>array()); unset($output); $v_mail_ssl_crt = $v_mail_ssl_str['MAIL']['CRT']; $v_mail_ssl_key = $v_mail_ssl_str['MAIL']['KEY']; @@ -248,7 +250,7 @@ if (!empty($_POST['save'])) { // List SSL certificate info exec (VESTA_CMD."v-list-sys-mail-ssl json", $output, $return_var); $v_mail_ssl_str = json_decode(implode('', $output), true); - if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($v_mail_ssl_str)) { $v_mail_ssl_str = array('MAIL'=>array()); } + if (!is_array($v_mail_ssl_str)) $v_mail_ssl_str = array('MAIL'=>array()); unset($output); $v_mail_ssl_crt = $v_mail_ssl_str['MAIL']['CRT']; $v_mail_ssl_key = $v_mail_ssl_str['MAIL']['KEY']; From b80bad79b27bc555fa7ec6cb08e0a9debbc7f880 Mon Sep 17 00:00:00 2001 From: Peca Date: Mon, 11 Aug 2025 15:14:08 +0200 Subject: [PATCH 3/4] Simplifying code, avoiding check for PHP version --- web/inc/i18n.php | 6 +--- web/inc/main.php | 38 ++++++-------------- web/list/backup/index.php | 4 +-- web/list/cron/index.php | 2 +- web/list/db/index.php | 2 +- web/list/directory/index.php | 2 +- web/list/dns/index.php | 4 +-- web/list/firewall/banlist/index.php | 2 +- web/list/ip/index.php | 2 +- web/list/mail/index.php | 4 +-- web/list/notifications/index.php | 4 +-- web/list/package/index.php | 2 +- web/list/rrd/index.php | 2 +- web/list/server/index.php | 4 +-- web/list/stats/index.php | 6 ++-- web/list/updates/index.php | 2 +- web/list/user/index.php | 2 +- web/list/web/index.php | 2 +- web/login/index.php | 56 ++++++++--------------------- web/reset/index.php | 16 +++------ web/search/index.php | 2 +- web/templates/admin/add_web.html | 2 +- web/templates/admin/list_stats.html | 2 +- web/templates/right.html | 2 +- web/templates/user/list_stats.html | 2 +- 25 files changed, 57 insertions(+), 115 deletions(-) diff --git a/web/inc/i18n.php b/web/inc/i18n.php index 5a41c54a..48cdf63d 100644 --- a/web/inc/i18n.php +++ b/web/inc/i18n.php @@ -89,11 +89,7 @@ function detect_user_language($fallback='en') { $accept_langs_sorted[$code] = (double)$q; } } - if (version_compare(PHP_VERSION, '5.6', '==')) { - arsort($accept_langs_sorted); - } else { - if (!empty($accept_langs_sorted)) { arsort($accept_langs_sorted); } - } + if (!empty($accept_langs_sorted)) arsort($accept_langs_sorted); // List languages exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var); diff --git a/web/inc/main.php b/web/inc/main.php index 8a969cb9..86913dd5 100644 --- a/web/inc/main.php +++ b/web/inc/main.php @@ -108,14 +108,8 @@ if (isset($_SESSION['look']) && ( $_SESSION['look'] != 'admin' )) { function get_favourites(){ exec (VESTA_CMD."v-list-user-favourites ".$_SESSION['user']." json", $output, $return_var); -// $data = json_decode(implode('', $output).'}', true); - if (version_compare(PHP_VERSION, '5.6', '==')) { - $data = json_decode(implode('', $output), true); - $data = array_reverse($data, true); - } else { - $data = json_decode(implode('', $output), true); - $data = is_array($data) ? array_reverse($data, true) : array(); - } + $data = json_decode(implode('', $output), true); + $data = is_array($data) ? array_reverse($data, true) : array(); $favourites = array(); foreach($data['Favourites'] as $key => $favourite){ @@ -193,24 +187,16 @@ function top_panel($user, $TAB) { header("Location: /error/"); exit; } - if (version_compare(PHP_VERSION, '5.6', '==')) { - $panel = json_decode(implode('', $output), true); - } else { - $panel = json_decode(implode('', $output), true); - if (!is_array($panel)) { $panel = array(); } - } + $panel = json_decode(implode('', $output), true); + if (!is_array($panel)) $panel = array(); unset($output); // getting notifications $command = VESTA_CMD."v-list-user-notifications '".$user."' 'json'"; exec ($command, $output, $return_var); - if (version_compare(PHP_VERSION, '5.6', '==')) { - $notifications = json_decode(implode('', $output), true); - } else { - $notifications = json_decode(implode('', $output), true); - if (!is_array($notifications)) { $notifications = array(); } - } + $notifications = json_decode(implode('', $output), true); + if (!is_array($notifications)) $notifications = array(); foreach($notifications as $message){ if(isset($message['ACK']) && $message['ACK'] == 'no'){ $panel[$user]['NOTIFICATIONS'] = 'yes'; @@ -229,14 +215,10 @@ function top_panel($user, $TAB) { function translate_date($date){ $date = strtotime($date); - if (version_compare(PHP_VERSION, '5.6', '==')) { - return strftime("%d  ", $date).__(strftime("%b", $date)).strftime("  %Y", $date); - } else { - $day = date('d', $date); - $mon = date('M', $date); - $year = date('Y', $date); - return $day.'  '.__($mon).'  '.$year; - } + $day = date('d', $date); + $mon = date('M', $date); + $year = date('Y', $date); + return $day.'  '.__($mon).'  '.$year; } function humanize_time($usage) { diff --git a/web/list/backup/index.php b/web/list/backup/index.php index 28460a70..c32324e9 100644 --- a/web/list/backup/index.php +++ b/web/list/backup/index.php @@ -9,14 +9,14 @@ include($_SERVER['DOCUMENT_ROOT'].'/inc/main.php'); if (empty($_GET['backup'])){ exec (VESTA_CMD."v-list-user-backups $user json", $output, $return_var); $data = json_decode(implode('', $output), true); - if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } + $data = is_array($data) ? array_reverse($data,true) : array(); unset($output); render_page($user, $TAB, 'list_backup'); } else { exec (VESTA_CMD."v-list-user-backup $user ".escapeshellarg($_GET['backup'])." json", $output, $return_var); $data = json_decode(implode('', $output), true); - if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } + $data = is_array($data) ? array_reverse($data,true) : array(); unset($output); render_page($user, $TAB, 'list_backup_detail'); diff --git a/web/list/cron/index.php b/web/list/cron/index.php index 0014be84..dc1e1121 100644 --- a/web/list/cron/index.php +++ b/web/list/cron/index.php @@ -8,7 +8,7 @@ include($_SERVER['DOCUMENT_ROOT'].'/inc/main.php'); // Data exec (VESTA_CMD."v-list-cron-jobs $user json", $output, $return_var); $data = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } +$data = is_array($data) ? array_reverse($data,true) : array(); unset($output); // Render page diff --git a/web/list/db/index.php b/web/list/db/index.php index 0a2560ef..e2610e0f 100644 --- a/web/list/db/index.php +++ b/web/list/db/index.php @@ -8,7 +8,7 @@ include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); // Data exec (VESTA_CMD."v-list-databases $user json", $output, $return_var); $data = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } +$data = is_array($data) ? array_reverse($data, true) : array(); unset($output); // Render page diff --git a/web/list/directory/index.php b/web/list/directory/index.php index 0b845f00..ef5defeb 100644 --- a/web/list/directory/index.php +++ b/web/list/directory/index.php @@ -22,7 +22,7 @@ if (empty($panel)) { exit; } $panel = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($panel)) { $panel = array(); } + if (!is_array($panel)) $panel = array(); } $path_a = !empty($_REQUEST['dir_a']) ? htmlentities($_REQUEST['dir_a']) : ''; diff --git a/web/list/dns/index.php b/web/list/dns/index.php index 8da98594..ec47d8c2 100644 --- a/web/list/dns/index.php +++ b/web/list/dns/index.php @@ -9,14 +9,14 @@ include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); if (empty($_GET['domain'])){ exec (VESTA_CMD."v-list-dns-domains ".escapeshellarg($user)." json", $output, $return_var); $data = json_decode(implode('', $output), true); - if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } + $data = is_array($data) ? array_reverse($data, true) : array(); unset($output); render_page($user, $TAB, 'list_dns'); } else { exec (VESTA_CMD."v-list-dns-records ".escapeshellarg($user)." ".escapeshellarg($_GET['domain'])." json", $output, $return_var); $data = json_decode(implode('', $output), true); - if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } + $data = is_array($data) ? array_reverse($data, true) : array(); unset($output); render_page($user, $TAB, 'list_dns_rec'); diff --git a/web/list/firewall/banlist/index.php b/web/list/firewall/banlist/index.php index b03a419d..e278defb 100644 --- a/web/list/firewall/banlist/index.php +++ b/web/list/firewall/banlist/index.php @@ -14,7 +14,7 @@ if ($_SESSION['user'] != 'admin') { // Data exec (VESTA_CMD."v-list-firewall-ban json", $output, $return_var); $data = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } +$data = is_array($data) ? array_reverse($data, true) : array(); unset($output); // Render page diff --git a/web/list/ip/index.php b/web/list/ip/index.php index deae8059..94972a7b 100644 --- a/web/list/ip/index.php +++ b/web/list/ip/index.php @@ -15,7 +15,7 @@ if ($_SESSION['user'] != 'admin') { // Data exec (VESTA_CMD."v-list-sys-ips json", $output, $return_var); $data = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } +$data = is_array($data) ? array_reverse($data, true) : array(); unset($output); // Render page diff --git a/web/list/mail/index.php b/web/list/mail/index.php index 0295d9d8..f5e2fa3a 100644 --- a/web/list/mail/index.php +++ b/web/list/mail/index.php @@ -9,14 +9,14 @@ include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); if (empty($_GET['domain'])){ exec (VESTA_CMD."v-list-mail-domains ".escapeshellarg($user)." json", $output, $return_var); $data = json_decode(implode('', $output), true); - if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } + $data = is_array($data) ? array_reverse($data, true) : array(); unset($output); render_page($user, $TAB, 'list_mail'); } else { exec (VESTA_CMD."v-list-mail-accounts ".escapeshellarg($user)." ".escapeshellarg($_GET['domain'])." json", $output, $return_var); $data = json_decode(implode('', $output), true); - if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } + $data = is_array($data) ? array_reverse($data, true) : array(); unset($output); render_page($user, $TAB, 'list_mail_acc'); diff --git a/web/list/notifications/index.php b/web/list/notifications/index.php index 5b776a72..adfcf118 100644 --- a/web/list/notifications/index.php +++ b/web/list/notifications/index.php @@ -9,7 +9,7 @@ if($_REQUEST['ajax'] == 1){ // Data exec (VESTA_CMD."v-list-user-notifications $user json", $output, $return_var); $data = json_decode(implode('', $output), true); - if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } + $data = is_array($data) ? array_reverse($data,true) : array(); foreach($data as $key => $note){ $note['ID'] = $key; $data[$key] = $note; @@ -25,7 +25,7 @@ $TAB = 'NOTIFICATIONS'; // Data exec (VESTA_CMD."v-list-user-notifications $user json", $output, $return_var); $data = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } +$data = is_array($data) ? array_reverse($data,true) : array(); // Render page render_page($user, $TAB, 'list_notifications'); diff --git a/web/list/package/index.php b/web/list/package/index.php index 8bf029ab..3feb622d 100644 --- a/web/list/package/index.php +++ b/web/list/package/index.php @@ -15,7 +15,7 @@ if ($_SESSION['user'] != 'admin') { // Data exec (VESTA_CMD."v-list-user-packages json", $output, $return_var); $data = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($data)) { $data = array(); } +if (!is_array($data)) $data = array(); unset($output); // Render page diff --git a/web/list/rrd/index.php b/web/list/rrd/index.php index fd79e64f..81fde136 100644 --- a/web/list/rrd/index.php +++ b/web/list/rrd/index.php @@ -18,7 +18,7 @@ if (!empty($_GET['period'])) { // Data exec (VESTA_CMD."v-list-sys-rrd json", $output, $return_var); $data = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($data)) { $data = array(); } +if (!is_array($data)) $data = array(); unset($output); // Render page diff --git a/web/list/server/index.php b/web/list/server/index.php index cda1fca9..15cd306f 100644 --- a/web/list/server/index.php +++ b/web/list/server/index.php @@ -116,11 +116,11 @@ if (isset($_GET['db'])) { // Data exec (VESTA_CMD."v-list-sys-info json", $output, $return_var); $sys = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($sys)) { $sys = array(); } +if (!is_array($sys)) $sys = array(); unset($output); exec (VESTA_CMD."v-list-sys-services json", $output, $return_var); $data = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($data)) { $data = array(); } +if (!is_array($data)) $data = array(); unset($output); // Render page diff --git a/web/list/stats/index.php b/web/list/stats/index.php index 4db65f9b..b9b19ded 100644 --- a/web/list/stats/index.php +++ b/web/list/stats/index.php @@ -10,13 +10,13 @@ if ($user == 'admin') { if (empty($_GET['user'])) { exec (VESTA_CMD."v-list-users-stats json", $output, $return_var); $data = json_decode(implode('', $output), true); - if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } + $data = is_array($data) ? array_reverse($data, true) : array(); unset($output); } else { $v_user = escapeshellarg($_GET['user']); exec (VESTA_CMD."v-list-user-stats $v_user json", $output, $return_var); $data = json_decode(implode('', $output), true); - if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } + $data = is_array($data) ? array_reverse($data, true) : array(); unset($output); } @@ -26,7 +26,7 @@ if ($user == 'admin') { } else { exec (VESTA_CMD."v-list-user-stats $user json", $output, $return_var); $data = json_decode(implode('', $output), true); - if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } + $data = is_array($data) ? array_reverse($data, true) : array(); unset($output); } diff --git a/web/list/updates/index.php b/web/list/updates/index.php index e27f4138..3b346fc1 100644 --- a/web/list/updates/index.php +++ b/web/list/updates/index.php @@ -14,7 +14,7 @@ if ($_SESSION['user'] != 'admin') { // Data exec (VESTA_CMD."v-list-sys-vesta-updates json", $output, $return_var); $data = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($data)) { $data = array(); } +if (!is_array($data)) $data = array(); unset($output); exec (VESTA_CMD."v-list-sys-vesta-autoupdate plain", $output, $return_var); $autoupdate = $output['0']; diff --git a/web/list/user/index.php b/web/list/user/index.php index 93a56ee1..398b7993 100644 --- a/web/list/user/index.php +++ b/web/list/user/index.php @@ -12,7 +12,7 @@ if ($user == 'admin') { exec (VESTA_CMD . "v-list-user ".$user." json", $output, $return_var); } $data = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } +$data = is_array($data) ? array_reverse($data,true) : array(); // Check and get changelog if needed if ($user == 'admin') { diff --git a/web/list/web/index.php b/web/list/web/index.php index 11b187dc..39985128 100644 --- a/web/list/web/index.php +++ b/web/list/web/index.php @@ -8,7 +8,7 @@ include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); // Data exec (VESTA_CMD."v-list-web-domains $user json", $output, $return_var); $data = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } +$data = is_array($data) ? array_reverse($data,true) : array(); $ips = json_decode(shell_exec(VESTA_CMD.'v-list-sys-ips json'), true); // Render page diff --git a/web/login/index.php b/web/login/index.php index f508c845..7ff68291 100644 --- a/web/login/index.php +++ b/web/login/index.php @@ -27,12 +27,8 @@ if (isset($_SESSION['user'])) { if ($_SESSION['user'] == 'admin' && !empty($_GET['loginas'])) { exec (VESTA_CMD . "v-list-user ".escapeshellarg($_GET['loginas'])." json", $output, $return_var); if ( $return_var == 0 ) { - if (version_compare(PHP_VERSION, '5.6', '==')) { - $data = json_decode(implode('', $output), true); - } else { - $data = json_decode(implode('', $output), true); - if (!is_array($data)) { $data = array(); } - } + $data = json_decode(implode('', $output), true); + if (!is_array($data)) { $data = array(); } reset($data); $_SESSION['look'] = key($data); $_SESSION['look_alert'] = 'yes'; @@ -56,12 +52,8 @@ if (isset($_POST['user']) && isset($_POST['password'])) { // Get user's salt $output = ''; exec (VESTA_CMD."v-get-user-salt ".$v_user." ".$v_ip." json" , $output, $return_var); - if (version_compare(PHP_VERSION, '5.6', '==')) { - $pam = json_decode(implode('', $output), true); - } else { - $pam = json_decode(implode('', $output), true); - if (!is_array($pam)) { $pam = array(); } - } + $pam = json_decode(implode('', $output), true); + if (!is_array($pam)) $pam = array(); if ( $return_var > 0 ) { $ERROR = "".__('Invalid username or password').""; } else { @@ -104,12 +96,8 @@ if (isset($_POST['user']) && isset($_POST['password'])) { // Get user speciefic parameters exec (VESTA_CMD . "v-list-user ".$v_user." json", $output, $return_var); - if (version_compare(PHP_VERSION, '5.6', '==')) { - $data = json_decode(implode('', $output), true); - } else { - $data = json_decode(implode('', $output), true); - if (!is_array($data)) { $data = array(); } - } + $data = json_decode(implode('', $output), true); + if (!is_array($data)) $data = array(); // Define session user $_SESSION['user'] = key($data); @@ -121,12 +109,8 @@ if (isset($_POST['user']) && isset($_POST['password'])) { // Define language $output = ''; exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var); - if (version_compare(PHP_VERSION, '5.6', '==')) { - $languages = json_decode(implode('', $output), true); - } else { - $languages = json_decode(implode('', $output), true); - if (!is_array($languages)) { $languages = array(); } - } + $languages = json_decode(implode('', $output), true); + if (!is_array($languages)) $languages = array(); if (in_array($data[$v_user]['LANGUAGE'], $languages)){ $_SESSION['language'] = $data[$v_user]['LANGUAGE']; } else { @@ -155,12 +139,8 @@ if (isset($_POST['user']) && isset($_POST['password'])) { // Check system configuration exec (VESTA_CMD . "v-list-sys-config json", $output, $return_var); -if (version_compare(PHP_VERSION, '5.6', '==')) { - $data = json_decode(implode('', $output), true); -} else { - $data = json_decode(implode('', $output), true); - if (!is_array($data)) { $data = array('config' => array()); } -} +$data = json_decode(implode('', $output), true); +if (!is_array($data)) $data = array('config' => array()); $sys_arr = $data['config']; foreach ($sys_arr as $key => $value) { $_SESSION[$key] = $value; @@ -170,22 +150,14 @@ foreach ($sys_arr as $key => $value) { if (empty($_SESSION['language'])) { $output = ''; exec (VESTA_CMD."v-list-sys-config json", $output, $return_var); - if (version_compare(PHP_VERSION, '5.6', '==')) { - $config = json_decode(implode('', $output), true); - } else { - $config = json_decode(implode('', $output), true); - if (!is_array($config)) { $config = array('config' => array('LANGUAGE' => 'en')); } - } + $config = json_decode(implode('', $output), true); + if (!is_array($config)) $config = array('config' => array('LANGUAGE' => 'en')); $lang = $config['config']['LANGUAGE']; $output = ''; exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var); - if (version_compare(PHP_VERSION, '5.6', '==')) { - $languages = json_decode(implode('', $output), true); - } else { - $languages = json_decode(implode('', $output), true); - if (!is_array($languages)) { $languages = array(); } - } + $languages = json_decode(implode('', $output), true); + if (!is_array($languages)) $languages = array(); if(in_array($lang, $languages)){ $_SESSION['language'] = $lang; } diff --git a/web/reset/index.php b/web/reset/index.php index 816d3155..4094815b 100644 --- a/web/reset/index.php +++ b/web/reset/index.php @@ -24,12 +24,8 @@ if ((!empty($_POST['user'])) && (empty($_POST['code']))) { $cmd="/usr/bin/sudo /usr/local/vesta/bin/v-list-user"; exec ($cmd." ".$v_user." json", $output, $return_var); if ( $return_var == 0 ) { - if (version_compare(PHP_VERSION, '5.6', '==')) { - $data = json_decode(implode('', $output), true); - } else { - $data = json_decode(implode('', $output), true); - if (!is_array($data)) { $data = array(); } - } + $data = json_decode(implode('', $output), true); + if (!is_array($data)) { $data = array(); } unset($output); exec("/usr/bin/sudo /usr/local/vesta/bin/v-get-user-value ".$v_user." RKEYEXP", $output, $return_var); $rkeyexp = trim(implode('', $output)); @@ -89,12 +85,8 @@ if ((!empty($_POST['user'])) && (!empty($_POST['code'])) && (!empty($_POST['pass $cmd="/usr/bin/sudo /usr/local/vesta/bin/v-list-user"; exec ($cmd." ".$v_user." json", $output, $return_var); if ( $return_var == 0 ) { - if (version_compare(PHP_VERSION, '5.6', '==')) { - $data = json_decode(implode('', $output), true); - } else { - $data = json_decode(implode('', $output), true); - if (!is_array($data)) { $data = array(); } - } + $data = json_decode(implode('', $output), true); + if (!is_array($data)) { $data = array(); } unset($output); $rkey = $data[$user]['RKEY']; if (hash_equals($rkey, $_POST['code'])) { diff --git a/web/search/index.php b/web/search/index.php index 2b7f5c97..022de39f 100644 --- a/web/search/index.php +++ b/web/search/index.php @@ -28,7 +28,7 @@ $command = $_SESSION['user'] == 'admin' exec (VESTA_CMD . $command, $output, $return_var); $data = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '!=') && !is_array($data)) { $data = array(); } +if (!is_array($data)) $data = array(); // Render page render_page($user, $TAB, 'list_search'); diff --git a/web/templates/admin/add_web.html b/web/templates/admin/add_web.html index 7db3be5a..910da764 100644 --- a/web/templates/admin/add_web.html +++ b/web/templates/admin/add_web.html @@ -253,7 +253,7 @@ - + diff --git a/web/templates/admin/list_stats.html b/web/templates/admin/list_stats.html index 27637751..06b29d26 100644 --- a/web/templates/admin/list_stats.html +++ b/web/templates/admin/list_stats.html @@ -74,7 +74,7 @@
- +
diff --git a/web/templates/right.html b/web/templates/right.html index bec69b4f..3079231a 100644 --- a/web/templates/right.html +++ b/web/templates/right.html @@ -64,7 +64,7 @@ $output=''; exec (VESTA_CMD . "v-list-user ".$GLOBALS['CURRENT_USER_FINAL']." json", $output, $return_var); $data = json_decode(implode('', $output), true); - if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data,true); } else { $data = is_array($data) ? array_reverse($data,true) : array(); } + $data = is_array($data) ? array_reverse($data,true) : array(); //print_r($data); exit; $key=$GLOBALS['CURRENT_USER_FINAL']; if ($data[$key]['DISK_QUOTA']=='unlimited') echo __('unlimited'); diff --git a/web/templates/user/list_stats.html b/web/templates/user/list_stats.html index 71e9765a..c069e234 100644 --- a/web/templates/user/list_stats.html +++ b/web/templates/user/list_stats.html @@ -77,7 +77,7 @@
- +
From 6660a9e975fb9ead90c3b1756fd6b471ffb0963d Mon Sep 17 00:00:00 2001 From: Peca Date: Mon, 11 Aug 2025 15:35:19 +0200 Subject: [PATCH 4/4] Refactor SSL and mail certificate handling in web/edit/server/index.php to ensure safe array access and improve error handling. Update related files to consistently check for array validity before accessing elements. --- web/edit/server/index.php | 104 ++++++++++++++++++------------------ web/inc/mail-wrapper.php | 1 + web/inc/main.php | 14 ++--- web/list/firewall/index.php | 2 +- web/login/index.php | 2 +- web/reset/index.php | 12 ++--- 6 files changed, 70 insertions(+), 65 deletions(-) diff --git a/web/edit/server/index.php b/web/edit/server/index.php index d2aa5d40..023c95ed 100644 --- a/web/edit/server/index.php +++ b/web/edit/server/index.php @@ -95,33 +95,33 @@ exec (VESTA_CMD."v-list-sys-vesta-ssl json", $output, $return_var); $v_sys_ssl_str = json_decode(implode('', $output), true); if (!is_array($v_sys_ssl_str)) $v_sys_ssl_str = array('VESTA'=>array()); unset($output); -$v_sys_ssl_crt = $v_sys_ssl_str['VESTA']['CRT']; -$v_sys_ssl_key = $v_sys_ssl_str['VESTA']['KEY']; -$v_sys_ssl_ca = $v_sys_ssl_str['VESTA']['CA']; -$v_sys_ssl_subject = $v_sys_ssl_str['VESTA']['SUBJECT']; -$v_sys_ssl_aliases = $v_sys_ssl_str['VESTA']['ALIASES']; -$v_sys_ssl_not_before = $v_sys_ssl_str['VESTA']['NOT_BEFORE']; -$v_sys_ssl_not_after = $v_sys_ssl_str['VESTA']['NOT_AFTER']; -$v_sys_ssl_signature = $v_sys_ssl_str['VESTA']['SIGNATURE']; -$v_sys_ssl_pub_key = $v_sys_ssl_str['VESTA']['PUB_KEY']; -$v_sys_ssl_issuer = $v_sys_ssl_str['VESTA']['ISSUER']; +$v_sys_ssl_crt = isset($v_sys_ssl_str['VESTA']['CRT']) ? $v_sys_ssl_str['VESTA']['CRT'] : ''; +$v_sys_ssl_key = isset($v_sys_ssl_str['VESTA']['KEY']) ? $v_sys_ssl_str['VESTA']['KEY'] : ''; +$v_sys_ssl_ca = isset($v_sys_ssl_str['VESTA']['CA']) ? $v_sys_ssl_str['VESTA']['CA'] : ''; +$v_sys_ssl_subject = isset($v_sys_ssl_str['VESTA']['SUBJECT']) ? $v_sys_ssl_str['VESTA']['SUBJECT'] : ''; +$v_sys_ssl_aliases = isset($v_sys_ssl_str['VESTA']['ALIASES']) ? $v_sys_ssl_str['VESTA']['ALIASES'] : ''; +$v_sys_ssl_not_before = isset($v_sys_ssl_str['VESTA']['NOT_BEFORE']) ? $v_sys_ssl_str['VESTA']['NOT_BEFORE'] : ''; +$v_sys_ssl_not_after = isset($v_sys_ssl_str['VESTA']['NOT_AFTER']) ? $v_sys_ssl_str['VESTA']['NOT_AFTER'] : ''; +$v_sys_ssl_signature = isset($v_sys_ssl_str['VESTA']['SIGNATURE']) ? $v_sys_ssl_str['VESTA']['SIGNATURE'] : ''; +$v_sys_ssl_pub_key = isset($v_sys_ssl_str['VESTA']['PUB_KEY']) ? $v_sys_ssl_str['VESTA']['PUB_KEY'] : ''; +$v_sys_ssl_issuer = isset($v_sys_ssl_str['VESTA']['ISSUER']) ? $v_sys_ssl_str['VESTA']['ISSUER'] : ''; // List mail ssl certificate info -if (!empty($_SESSION['VESTA_CERTIFICATE'])); { +if (!empty($_SESSION['VESTA_CERTIFICATE'])) { exec (VESTA_CMD."v-list-sys-mail-ssl json", $output, $return_var); $v_mail_ssl_str = json_decode(implode('', $output), true); if (!is_array($v_mail_ssl_str)) $v_mail_ssl_str = array('MAIL'=>array()); unset($output); - $v_mail_ssl_crt = $v_mail_ssl_str['MAIL']['CRT']; - $v_mail_ssl_key = $v_mail_ssl_str['MAIL']['KEY']; - $v_mail_ssl_ca = $v_mail_ssl_str['MAIL']['CA']; - $v_mail_ssl_subject = $v_mail_ssl_str['MAIL']['SUBJECT']; - $v_mail_ssl_aliases = $v_mail_ssl_str['MAIL']['ALIASES']; - $v_mail_ssl_not_before = $v_mail_ssl_str['MAIL']['NOT_BEFORE']; - $v_mail_ssl_not_after = $v_mail_ssl_str['MAIL']['NOT_AFTER']; - $v_mail_ssl_signature = $v_mail_ssl_str['MAIL']['SIGNATURE']; - $v_mail_ssl_pub_key = $v_mail_ssl_str['MAIL']['PUB_KEY']; - $v_mail_ssl_issuer = $v_mail_ssl_str['MAIL']['ISSUER']; + $v_mail_ssl_crt = isset($v_mail_ssl_str['MAIL']['CRT']) ? $v_mail_ssl_str['MAIL']['CRT'] : ''; + $v_mail_ssl_key = isset($v_mail_ssl_str['MAIL']['KEY']) ? $v_mail_ssl_str['MAIL']['KEY'] : ''; + $v_mail_ssl_ca = isset($v_mail_ssl_str['MAIL']['CA']) ? $v_mail_ssl_str['MAIL']['CA'] : ''; + $v_mail_ssl_subject = isset($v_mail_ssl_str['MAIL']['SUBJECT']) ? $v_mail_ssl_str['MAIL']['SUBJECT'] : ''; + $v_mail_ssl_aliases = isset($v_mail_ssl_str['MAIL']['ALIASES']) ? $v_mail_ssl_str['MAIL']['ALIASES'] : ''; + $v_mail_ssl_not_before = isset($v_mail_ssl_str['MAIL']['NOT_BEFORE']) ? $v_mail_ssl_str['MAIL']['NOT_BEFORE'] : ''; + $v_mail_ssl_not_after = isset($v_mail_ssl_str['MAIL']['NOT_AFTER']) ? $v_mail_ssl_str['MAIL']['NOT_AFTER'] : ''; + $v_mail_ssl_signature = isset($v_mail_ssl_str['MAIL']['SIGNATURE']) ? $v_mail_ssl_str['MAIL']['SIGNATURE'] : ''; + $v_mail_ssl_pub_key = isset($v_mail_ssl_str['MAIL']['PUB_KEY']) ? $v_mail_ssl_str['MAIL']['PUB_KEY'] : ''; + $v_mail_ssl_issuer = isset($v_mail_ssl_str['MAIL']['ISSUER']) ? $v_mail_ssl_str['MAIL']['ISSUER'] : ''; } // Check POST request @@ -252,16 +252,16 @@ if (!empty($_POST['save'])) { $v_mail_ssl_str = json_decode(implode('', $output), true); if (!is_array($v_mail_ssl_str)) $v_mail_ssl_str = array('MAIL'=>array()); unset($output); - $v_mail_ssl_crt = $v_mail_ssl_str['MAIL']['CRT']; - $v_mail_ssl_key = $v_mail_ssl_str['MAIL']['KEY']; - $v_mail_ssl_ca = $v_mail_ssl_str['MAIL']['CA']; - $v_mail_ssl_subject = $v_mail_ssl_str['MAIL']['SUBJECT']; - $v_mail_ssl_aliases = $v_mail_ssl_str['MAIL']['ALIASES']; - $v_mail_ssl_not_before = $v_mail_ssl_str['MAIL']['NOT_BEFORE']; - $v_mail_ssl_not_after = $v_mail_ssl_str['MAIL']['NOT_AFTER']; - $v_mail_ssl_signature = $v_mail_ssl_str['MAIL']['SIGNATURE']; - $v_mail_ssl_pub_key = $v_mail_ssl_str['MAIL']['PUB_KEY']; - $v_mail_ssl_issuer = $v_mail_ssl_str['MAIL']['ISSUER']; + $v_mail_ssl_crt = isset($v_mail_ssl_str['MAIL']['CRT']) ? $v_mail_ssl_str['MAIL']['CRT'] : ''; + $v_mail_ssl_key = isset($v_mail_ssl_str['MAIL']['KEY']) ? $v_mail_ssl_str['MAIL']['KEY'] : ''; + $v_mail_ssl_ca = isset($v_mail_ssl_str['MAIL']['CA']) ? $v_mail_ssl_str['MAIL']['CA'] : ''; + $v_mail_ssl_subject = isset($v_mail_ssl_str['MAIL']['SUBJECT']) ? $v_mail_ssl_str['MAIL']['SUBJECT'] : ''; + $v_mail_ssl_aliases = isset($v_mail_ssl_str['MAIL']['ALIASES']) ? $v_mail_ssl_str['MAIL']['ALIASES'] : ''; + $v_mail_ssl_not_before = isset($v_mail_ssl_str['MAIL']['NOT_BEFORE']) ? $v_mail_ssl_str['MAIL']['NOT_BEFORE'] : ''; + $v_mail_ssl_not_after = isset($v_mail_ssl_str['MAIL']['NOT_AFTER']) ? $v_mail_ssl_str['MAIL']['NOT_AFTER'] : ''; + $v_mail_ssl_signature = isset($v_mail_ssl_str['MAIL']['SIGNATURE']) ? $v_mail_ssl_str['MAIL']['SIGNATURE'] : ''; + $v_mail_ssl_pub_key = isset($v_mail_ssl_str['MAIL']['PUB_KEY']) ? $v_mail_ssl_str['MAIL']['PUB_KEY'] : ''; + $v_mail_ssl_issuer = isset($v_mail_ssl_str['MAIL']['ISSUER']) ? $v_mail_ssl_str['MAIL']['ISSUER'] : ''; } } } @@ -453,17 +453,18 @@ if (!empty($_POST['save'])) { // List SSL certificate info exec (VESTA_CMD."v-list-sys-vesta-ssl json", $output, $return_var); $v_sys_ssl_str = json_decode(implode('', $output), true); + if (!is_array($v_sys_ssl_str)) $v_sys_ssl_str = array('VESTA'=>array()); unset($output); - $v_sys_ssl_crt = $v_sys_ssl_str['VESTA']['CRT']; - $v_sys_ssl_key = $v_sys_ssl_str['VESTA']['KEY']; - $v_sys_ssl_ca = $v_sys_ssl_str['VESTA']['CA']; - $v_sys_ssl_subject = $v_sys_ssl_str['VESTA']['SUBJECT']; - $v_sys_ssl_aliases = $v_sys_ssl_str['VESTA']['ALIASES']; - $v_sys_ssl_not_before = $v_sys_ssl_str['VESTA']['NOT_BEFORE']; - $v_sys_ssl_not_after = $v_sys_ssl_str['VESTA']['NOT_AFTER']; - $v_sys_ssl_signature = $v_sys_ssl_str['VESTA']['SIGNATURE']; - $v_sys_ssl_pub_key = $v_sys_ssl_str['VESTA']['PUB_KEY']; - $v_sys_ssl_issuer = $v_sys_ssl_str['VESTA']['ISSUER']; + $v_sys_ssl_crt = isset($v_sys_ssl_str['VESTA']['CRT']) ? $v_sys_ssl_str['VESTA']['CRT'] : ''; + $v_sys_ssl_key = isset($v_sys_ssl_str['VESTA']['KEY']) ? $v_sys_ssl_str['VESTA']['KEY'] : ''; + $v_sys_ssl_ca = isset($v_sys_ssl_str['VESTA']['CA']) ? $v_sys_ssl_str['VESTA']['CA'] : ''; + $v_sys_ssl_subject = isset($v_sys_ssl_str['VESTA']['SUBJECT']) ? $v_sys_ssl_str['VESTA']['SUBJECT'] : ''; + $v_sys_ssl_aliases = isset($v_sys_ssl_str['VESTA']['ALIASES']) ? $v_sys_ssl_str['VESTA']['ALIASES'] : ''; + $v_sys_ssl_not_before = isset($v_sys_ssl_str['VESTA']['NOT_BEFORE']) ? $v_sys_ssl_str['VESTA']['NOT_BEFORE'] : ''; + $v_sys_ssl_not_after = isset($v_sys_ssl_str['VESTA']['NOT_AFTER']) ? $v_sys_ssl_str['VESTA']['NOT_AFTER'] : ''; + $v_sys_ssl_signature = isset($v_sys_ssl_str['VESTA']['SIGNATURE']) ? $v_sys_ssl_str['VESTA']['SIGNATURE'] : ''; + $v_sys_ssl_pub_key = isset($v_sys_ssl_str['VESTA']['PUB_KEY']) ? $v_sys_ssl_str['VESTA']['PUB_KEY'] : ''; + $v_sys_ssl_issuer = isset($v_sys_ssl_str['VESTA']['ISSUER']) ? $v_sys_ssl_str['VESTA']['ISSUER'] : ''; } } } @@ -499,17 +500,18 @@ if (!empty($_POST['save'])) { // List ssl certificate info exec (VESTA_CMD."v-list-sys-vesta-ssl json", $output, $return_var); $v_sys_ssl_str = json_decode(implode('', $output), true); + if (!is_array($v_sys_ssl_str)) $v_sys_ssl_str = array('VESTA'=>array()); unset($output); - $v_sys_ssl_crt = $v_sys_ssl_str['VESTA']['CRT']; - $v_sys_ssl_key = $v_sys_ssl_str['VESTA']['KEY']; - $v_sys_ssl_ca = $v_sys_ssl_str['VESTA']['CA']; - $v_sys_ssl_subject = $v_sys_ssl_str['VESTA']['SUBJECT']; - $v_sys_ssl_aliases = $v_sys_ssl_str['VESTA']['ALIASES']; - $v_sys_ssl_not_before = $v_sys_ssl_str['VESTA']['NOT_BEFORE']; - $v_sys_ssl_not_after = $v_sys_ssl_str['VESTA']['NOT_AFTER']; - $v_sys_ssl_signature = $v_sys_ssl_str['VESTA']['SIGNATURE']; - $v_sys_ssl_pub_key = $v_sys_ssl_str['VESTA']['PUB_KEY']; - $v_sys_ssl_issuer = $v_sys_ssl_str['VESTA']['ISSUER']; + $v_sys_ssl_crt = isset($v_sys_ssl_str['VESTA']['CRT']) ? $v_sys_ssl_str['VESTA']['CRT'] : ''; + $v_sys_ssl_key = isset($v_sys_ssl_str['VESTA']['KEY']) ? $v_sys_ssl_str['VESTA']['KEY'] : ''; + $v_sys_ssl_ca = isset($v_sys_ssl_str['VESTA']['CA']) ? $v_sys_ssl_str['VESTA']['CA'] : ''; + $v_sys_ssl_subject = isset($v_sys_ssl_str['VESTA']['SUBJECT']) ? $v_sys_ssl_str['VESTA']['SUBJECT'] : ''; + $v_sys_ssl_aliases = isset($v_sys_ssl_str['VESTA']['ALIASES']) ? $v_sys_ssl_str['VESTA']['ALIASES'] : ''; + $v_sys_ssl_not_before = isset($v_sys_ssl_str['VESTA']['NOT_BEFORE']) ? $v_sys_ssl_str['VESTA']['NOT_BEFORE'] : ''; + $v_sys_ssl_not_after = isset($v_sys_ssl_str['VESTA']['NOT_AFTER']) ? $v_sys_ssl_str['VESTA']['NOT_AFTER'] : ''; + $v_sys_ssl_signature = isset($v_sys_ssl_str['VESTA']['SIGNATURE']) ? $v_sys_ssl_str['VESTA']['SIGNATURE'] : ''; + $v_sys_ssl_pub_key = isset($v_sys_ssl_str['VESTA']['PUB_KEY']) ? $v_sys_ssl_str['VESTA']['PUB_KEY'] : ''; + $v_sys_ssl_issuer = isset($v_sys_ssl_str['VESTA']['ISSUER']) ? $v_sys_ssl_str['VESTA']['ISSUER'] : ''; } } } diff --git a/web/inc/mail-wrapper.php b/web/inc/mail-wrapper.php index 4281aaad..c5041c3a 100755 --- a/web/inc/mail-wrapper.php +++ b/web/inc/mail-wrapper.php @@ -20,6 +20,7 @@ include("/usr/local/vesta/web/inc/main.php"); // Set system language exec (VESTA_CMD . "v-list-sys-config json", $output, $return_var); $data = json_decode(implode('', $output), true); +if (!is_array($data)) $data = array('config' => array()); if (!empty( $data['config']['LANGUAGE'])) { $_SESSION['language'] = $data['config']['LANGUAGE']; } else { diff --git a/web/inc/main.php b/web/inc/main.php index 86913dd5..99e4ca90 100644 --- a/web/inc/main.php +++ b/web/inc/main.php @@ -112,13 +112,15 @@ function get_favourites(){ $data = is_array($data) ? array_reverse($data, true) : array(); $favourites = array(); - foreach($data['Favourites'] as $key => $favourite){ - $favourites[$key] = array(); + if (isset($data['Favourites']) && is_array($data['Favourites'])) { + foreach($data['Favourites'] as $key => $favourite){ + $favourites[$key] = array(); - $items = explode(',', $favourite); - foreach($items as $item){ - if($item) - $favourites[$key][trim($item)] = 1; + $items = explode(',', $favourite); + foreach($items as $item){ + if($item) + $favourites[$key][trim($item)] = 1; + } } } diff --git a/web/list/firewall/index.php b/web/list/firewall/index.php index 35799490..6750496d 100644 --- a/web/list/firewall/index.php +++ b/web/list/firewall/index.php @@ -14,7 +14,7 @@ if ($_SESSION['user'] != 'admin') { // Data exec (VESTA_CMD."v-list-firewall json", $output, $return_var); $data = json_decode(implode('', $output), true); -if (version_compare(PHP_VERSION, '5.6', '==')) { $data = array_reverse($data, true); } else { $data = is_array($data) ? array_reverse($data, true) : array(); } +$data = is_array($data) ? array_reverse($data, true) : array(); unset($output); // Render page diff --git a/web/login/index.php b/web/login/index.php index 7ff68291..8a22e204 100644 --- a/web/login/index.php +++ b/web/login/index.php @@ -111,7 +111,7 @@ if (isset($_POST['user']) && isset($_POST['password'])) { exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var); $languages = json_decode(implode('', $output), true); if (!is_array($languages)) $languages = array(); - if (in_array($data[$v_user]['LANGUAGE'], $languages)){ + if (isset($data[$v_user]['LANGUAGE']) && in_array($data[$v_user]['LANGUAGE'], $languages)){ $_SESSION['language'] = $data[$v_user]['LANGUAGE']; } else { $_SESSION['language'] = 'en'; diff --git a/web/reset/index.php b/web/reset/index.php index 4094815b..4c3629a0 100644 --- a/web/reset/index.php +++ b/web/reset/index.php @@ -32,7 +32,7 @@ if ((!empty($_POST['user'])) && (empty($_POST['code']))) { if (strlen($rkeyexp)>9) $rkeyexp=intval($rkeyexp); unset($output); if ($rkeyexp === null || $rkeyexp < time() - 900) { - if ($email == $data[$user]['CONTACT']) { + if (isset($data[$user]['CONTACT']) && $email == $data[$user]['CONTACT']) { exec("/usr/bin/sudo /usr/local/vesta/bin/v-change-user-rkey ".$v_user, $output, $return_var); unset($output); $CMD="/usr/bin/sudo /usr/local/vesta/bin/v-get-user-value ".$v_user." RKEY"; @@ -42,10 +42,10 @@ if ((!empty($_POST['user'])) && (empty($_POST['code']))) { //echo $rkey; exit; //echo $CMD."\n
"; //var_dump($rkey); exit; - $fname = $data[$user]['FNAME']; - $lname = $data[$user]['LNAME']; - $contact = $data[$user]['CONTACT']; - $to = $data[$user]['CONTACT']; + $fname = isset($data[$user]['FNAME']) ? $data[$user]['FNAME'] : ''; + $lname = isset($data[$user]['LNAME']) ? $data[$user]['LNAME'] : ''; + $contact = isset($data[$user]['CONTACT']) ? $data[$user]['CONTACT'] : ''; + $to = isset($data[$user]['CONTACT']) ? $data[$user]['CONTACT'] : ''; $subject = __('MAIL_RESET_SUBJECT',date("Y-m-d H:i:s")); $hostname = exec('hostname'); $from = __('MAIL_FROM',$hostname); @@ -88,7 +88,7 @@ if ((!empty($_POST['user'])) && (!empty($_POST['code'])) && (!empty($_POST['pass $data = json_decode(implode('', $output), true); if (!is_array($data)) { $data = array(); } unset($output); - $rkey = $data[$user]['RKEY']; + $rkey = isset($data[$user]['RKEY']) ? $data[$user]['RKEY'] : ''; if (hash_equals($rkey, $_POST['code'])) { unset($output); exec("/usr/bin/sudo /usr/local/vesta/bin/v-get-user-value ".$v_user." RKEYEXP", $output, $return_var);