mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 10:37:42 -07:00
New, simpler WEB UI
This commit is contained in:
parent
2de99900ce
commit
d352cb9385
439 changed files with 3920 additions and 45184 deletions
97
web/inc/main.php
Normal file
97
web/inc/main.php
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
// Set timezone
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Check user
|
||||
if (!isset($_SESSION['user'])) {
|
||||
header("Location: /login/");
|
||||
}
|
||||
|
||||
if (!empty($_SESSION['look'])&& $_SESSION['look'] != 'admin') {
|
||||
$user = $_SESSION['look'];
|
||||
} else {
|
||||
$user = $_SESSION['user'];
|
||||
}
|
||||
|
||||
|
||||
define('VESTA_CMD', '/usr/bin/sudo /usr/local/vesta/bin/');
|
||||
|
||||
|
||||
// Define functions
|
||||
function check_error($return_var){
|
||||
if ( $return_var > 0 ) {
|
||||
header("Location: /error/");
|
||||
}
|
||||
}
|
||||
|
||||
function top_panel($user, $TAB) {
|
||||
global $panel;
|
||||
$command = VESTA_CMD."v_list_user '".$user."' 'json'";
|
||||
exec ($command, $output, $return_var);
|
||||
if ( $return_var > 0 ) {
|
||||
header("Location: /error/");
|
||||
}
|
||||
$panel = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
if ( $user == 'admin' ) {
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/panel.html');
|
||||
} else {
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/panel.html');
|
||||
}
|
||||
}
|
||||
|
||||
function humanize_time($usage) {
|
||||
if ( $usage > 60 ) {
|
||||
$usage = $usage / 60;
|
||||
$usage = number_format($usage, 2);
|
||||
$usage = $usage." Hour.";
|
||||
} else {
|
||||
$usage = $usage." Min.";
|
||||
}
|
||||
return $usage;
|
||||
}
|
||||
|
||||
function humanize_usage($usage) {
|
||||
if ( $usage > 1000 ) {
|
||||
$usage = $usage / 1000;
|
||||
if ( $usage > 1000 ) {
|
||||
$usage = $usage / 1000 ;
|
||||
if ( $usage > 1000 ) {
|
||||
$usage = $usage / 1000 ;
|
||||
$usage = number_format($usage, 2);
|
||||
$usage = $usage." PB";
|
||||
} else {
|
||||
$usage = number_format($usage, 2);
|
||||
$usage = $usage." TB";
|
||||
}
|
||||
} else {
|
||||
$usage = number_format($usage, 2);
|
||||
$usage = $usage." GB";
|
||||
}
|
||||
} else {
|
||||
$usage = $usage." MB";
|
||||
}
|
||||
return $usage;
|
||||
}
|
||||
|
||||
function get_percentage($used,$total) {
|
||||
if (!isset($total)) $total = 0;
|
||||
if (!isset($used)) $used = 0;
|
||||
if ( $total == 0 ) {
|
||||
$percent = 0;
|
||||
} else {
|
||||
$percent = $used / $total;
|
||||
$percent = $percent * 100;
|
||||
$percent = number_format($percent, 0, '', '');
|
||||
if ( $percent > 100 ) {
|
||||
$percent = 100;
|
||||
}
|
||||
if ( $percent < 0 ) {
|
||||
$percent = 0;
|
||||
}
|
||||
|
||||
}
|
||||
return $percent;
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue