|
|
@@ -1,11 +1,13 @@
|
|
|
<?php
|
|
|
-
|
|
|
session_start();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
|
use PHPMailer\PHPMailer\SMTP;
|
|
|
use PHPMailer\PHPMailer\Exception;
|
|
|
|
|
|
-if(!file_exists(dirname(__FILE__).'/vendor/autoload.php')){
|
|
|
+if (!file_exists(dirname(__FILE__).'/vendor/autoload.php')) {
|
|
|
trigger_error('Unable able to load required libaries. Please run v-add-sys-phpmailer in command line');
|
|
|
echo 'Unable able to load required libaries. Please run v-add-sys-phpmailer in command line';
|
|
|
exit(1);
|
|
|
@@ -14,11 +16,6 @@ if(!file_exists(dirname(__FILE__).'/vendor/autoload.php')){
|
|
|
require 'vendor/autoload.php';
|
|
|
|
|
|
define('HESTIA_CMD', '/usr/bin/sudo /usr/local/hestia/bin/');
|
|
|
-if ($_SESSION['RELEASE_BRANCH'] == 'release' && $_SESSION['DEBUG_MODE'] == 'false') {
|
|
|
- define('JS_LATEST_UPDATE', 'v=' . $_SESSION['VERSION']);
|
|
|
-} else {
|
|
|
- define('JS_LATEST_UPDATE', 'r=' . time());
|
|
|
-}
|
|
|
define('DEFAULT_PHP_VERSION', 'php-' . exec('php -r "echo substr(phpversion(),0,3);"'));
|
|
|
|
|
|
// Load Hestia Config directly
|
|
|
@@ -36,8 +33,10 @@ function destroy_sessions()
|
|
|
$i = 0;
|
|
|
|
|
|
// Saving user IPs to the session for preventing session hijacking
|
|
|
-$user_combined_ip = $_SERVER['REMOTE_ADDR'];
|
|
|
-
|
|
|
+$user_combined_ip = '';
|
|
|
+if (isset($_SERVER['REMOTE_ADDR'])) {
|
|
|
+ $user_combined_ip = $_SERVER['REMOTE_ADDR'];
|
|
|
+}
|
|
|
if (isset($_SERVER['HTTP_CLIENT_IP'])) {
|
|
|
$user_combined_ip .= '|' . $_SERVER['HTTP_CLIENT_IP'];
|
|
|
}
|
|
|
@@ -96,6 +95,12 @@ if (isset($_SESSION['user'])) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+if ($_SESSION['RELEASE_BRANCH'] == 'release' && $_SESSION['DEBUG_MODE'] == 'false') {
|
|
|
+ define('JS_LATEST_UPDATE', 'v=' . $_SESSION['VERSION']);
|
|
|
+} else {
|
|
|
+ define('JS_LATEST_UPDATE', 'r=' . time());
|
|
|
+}
|
|
|
+
|
|
|
if (!defined('NO_AUTH_REQUIRED')) {
|
|
|
if (empty($_SESSION['LAST_ACTIVITY']) || empty($_SESSION['INACTIVE_SESSION_TIMEOUT'])) {
|
|
|
destroy_sessions();
|
|
|
@@ -117,7 +122,7 @@ if (isset($_SESSION['user'])) {
|
|
|
$user_plain = htmlentities($_SESSION['user']);
|
|
|
}
|
|
|
|
|
|
-if (isset($_SESSION['look']) && ($_SESSION['userContext'] === 'admin')) {
|
|
|
+if (isset($_SESSION['look']) && $_SESSION['look'] != '' && ($_SESSION['userContext'] === 'admin')) {
|
|
|
$user = escapeshellarg($_SESSION['look']);
|
|
|
$user_plain = htmlentities($_SESSION['look']);
|
|
|
}
|
|
|
@@ -142,7 +147,8 @@ function check_return_code($return_var, $output)
|
|
|
$_SESSION['error_msg'] = $error;
|
|
|
}
|
|
|
}
|
|
|
-function check_return_code_redirect($return_var, $output, $location){
|
|
|
+function check_return_code_redirect($return_var, $output, $location)
|
|
|
+{
|
|
|
if ($return_var != 0) {
|
|
|
$error = implode('<br>', $output);
|
|
|
if (empty($error)) {
|
|
|
@@ -151,7 +157,6 @@ function check_return_code_redirect($return_var, $output, $location){
|
|
|
$_SESSION['error_msg'] = $error;
|
|
|
header("Location:".$location);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
function render_page($user, $TAB, $page)
|
|
|
@@ -163,8 +168,7 @@ function render_page($user, $TAB, $page)
|
|
|
include($__template_dir . 'header.html');
|
|
|
|
|
|
// Panel
|
|
|
- top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
|
|
-
|
|
|
+ $panel = top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
|
|
// Extract global variables
|
|
|
// I think those variables should be passed via arguments
|
|
|
extract($GLOBALS, EXTR_SKIP);
|
|
|
@@ -202,27 +206,29 @@ function verify_csrf($method, $return = false)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function show_error_panel($data){
|
|
|
+function show_error_panel($data)
|
|
|
+{
|
|
|
+ $msg_id = '';
|
|
|
+ $msg_icon = '';
|
|
|
+ $msg_text = '';
|
|
|
if (!empty($data['error_msg'])) {
|
|
|
$msg_icon = 'fa-exclamation-circle status-icon red';
|
|
|
$msg_text = htmlentities($data['error_msg']);
|
|
|
$msg_id = 'vst-error';
|
|
|
} else {
|
|
|
if (!empty($data['ok_msg'])) {
|
|
|
- $msg_icon = 'fa-check-circle status-icon green';
|
|
|
- $msg_text = $data['ok_msg'];
|
|
|
- $msg_id = 'vst-ok';
|
|
|
- }
|
|
|
- }
|
|
|
- ?>
|
|
|
- <span class="<?=$msg_id;?>"> <i class="fas <?=$msg_icon;?>"></i> <?=$msg_text;?></span>
|
|
|
- <?php
|
|
|
+ $msg_icon = 'fa-check-circle status-icon green';
|
|
|
+ $msg_text = $data['ok_msg'];
|
|
|
+ $msg_id = 'vst-ok';
|
|
|
+ }
|
|
|
+ } ?>
|
|
|
+<span class="<?=$msg_id; ?>"> <i class="fas <?=$msg_icon; ?>"></i> <?=$msg_text; ?></span>
|
|
|
+<?php
|
|
|
}
|
|
|
|
|
|
function top_panel($user, $TAB)
|
|
|
{
|
|
|
- global $panel;
|
|
|
- $command = HESTIA_CMD . 'v-list-user ' . escapeshellarg($user) . " 'json'";
|
|
|
+ $command = HESTIA_CMD . 'v-list-user ' . $user . " 'json'";
|
|
|
exec($command, $output, $return_var);
|
|
|
if ($return_var > 0) {
|
|
|
destroy_sessions();
|
|
|
@@ -235,10 +241,10 @@ function top_panel($user, $TAB)
|
|
|
|
|
|
// Log out active sessions for suspended users
|
|
|
if (($panel[$user]['SUSPENDED'] === 'yes') && ($_SESSION['POLICY_USER_VIEW_SUSPENDED'] !== 'yes')) {
|
|
|
- if(empty($_SESSION['look'])){
|
|
|
- destroy_sessions();
|
|
|
- $_SESSION['error_msg'] = _('You have been logged out. Please log in again.');
|
|
|
- header('Location: /login/');
|
|
|
+ if (empty($_SESSION['look'])) {
|
|
|
+ destroy_sessions();
|
|
|
+ $_SESSION['error_msg'] = _('You have been logged out. Please log in again.');
|
|
|
+ header('Location: /login/');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -285,12 +291,13 @@ function top_panel($user, $TAB)
|
|
|
}
|
|
|
|
|
|
include(dirname(__FILE__) . '/../templates/includes/panel.html');
|
|
|
+ return $panel;
|
|
|
}
|
|
|
|
|
|
function translate_date($date)
|
|
|
{
|
|
|
- $date = strtotime($date);
|
|
|
- return strftime('%d ', $date) . _(strftime('%b', $date)) . strftime(' %Y', $date);
|
|
|
+ $date = new DateTime($date);
|
|
|
+ return $date -> format('d').' '. _($date -> format('M')).' '.$date -> format('Y');
|
|
|
}
|
|
|
|
|
|
function humanize_time($usage)
|
|
|
@@ -302,15 +309,20 @@ function humanize_time($usage)
|
|
|
$usage = number_format($usage);
|
|
|
return sprintf(ngettext('%d day', '%d days', $usage), $usage);
|
|
|
} else {
|
|
|
+ $usage = round($usage);
|
|
|
return sprintf(ngettext('%d hour', '%d hours', $usage), $usage);
|
|
|
}
|
|
|
} else {
|
|
|
+ $usage = round($usage);
|
|
|
return sprintf(ngettext('%d minute', '%d minutes', $usage), $usage);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function humanize_usage_size($usage)
|
|
|
{
|
|
|
+ if ($usage == 'unlimited') {
|
|
|
+ return '∞';
|
|
|
+ }
|
|
|
if ($usage > 1024) {
|
|
|
$usage = $usage / 1024;
|
|
|
if ($usage > 1024) {
|
|
|
@@ -330,6 +342,10 @@ function humanize_usage_size($usage)
|
|
|
|
|
|
function humanize_usage_measure($usage)
|
|
|
{
|
|
|
+ if ($usage == 'unlimited') {
|
|
|
+ return 'mb';
|
|
|
+ }
|
|
|
+
|
|
|
$measure = 'kb';
|
|
|
if ($usage > 1024) {
|
|
|
$usage = $usage / 1024;
|
|
|
@@ -347,6 +363,10 @@ function humanize_usage_measure($usage)
|
|
|
|
|
|
function get_percentage($used, $total)
|
|
|
{
|
|
|
+ if ($total = "unlimited") {
|
|
|
+ //return 0 if unlimited
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
if (!isset($total)) {
|
|
|
$total = 0;
|
|
|
}
|
|
|
@@ -419,10 +439,11 @@ function list_timezones()
|
|
|
$offset_prefix = $offset < 0 ? '-' : '+';
|
|
|
$offset_formatted = gmdate('H:i', abs($offset));
|
|
|
$pretty_offset = "UTC${offset_prefix}${offset_formatted}";
|
|
|
- $t = new DateTimeZone($timezone);
|
|
|
- $c = new DateTime(null, $t);
|
|
|
+ $c = new DateTime(gmdate('Y-M-d H:i:s'), new DateTimeZone('UTC'));
|
|
|
+ $c->setTimezone(new DateTimeZone($timezone));
|
|
|
$current_time = $c->format('H:i:s');
|
|
|
$timezone_list[$timezone] = "$timezone [ $current_time ] ${pretty_offset}";
|
|
|
+ #$timezone_list[$timezone] = "$timezone ${pretty_offset}";
|
|
|
}
|
|
|
return $timezone_list;
|
|
|
}
|