System Status make the code more consistent.

This commit is contained in:
FusionPBX 2017-06-07 12:47:17 -06:00 committed by GitHub
parent 6f49ff29ff
commit 2611b79ba4
1 changed files with 64 additions and 60 deletions

View File

@ -17,55 +17,63 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
Portions created by the Initial Developer are Copyright (C) 2008-2017
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
James Rose <james.o.rose@gmail.com>
*/
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('system_view_info')
|| permission_exists('system_view_cpu')
|| permission_exists('system_view_hdd')
|| permission_exists('system_view_ram')
|| permission_exists('system_view_backup')) {
//access granted
}
else {
echo "access denied";
exit;
}
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('system_view_info')
|| permission_exists('system_view_cpu')
|| permission_exists('system_view_hdd')
|| permission_exists('system_view_ram')
|| permission_exists('system_view_backup')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
require_once "resources/header.php";
$document['title'] = $text['title-sys-status'];
//additional includes
require_once "resources/header.php";
//set the page title
$document['title'] = $text['title-sys-status'];
// OS Support
//
// For each section below wrap in an OS detection statement like:
// if (stristr(PHP_OS, 'Linux')) {}
//
// Some possibilites for PHP_OS...
//
// CYGWIN_NT-5.1
// Darwin
// FreeBSD
// HP-UX
// IRIX64
// Linux
// NetBSD
// OpenBSD
// SunOS
// Unix
// WIN32
// WINNT
// Windows
//
//
// For each section below wrap in an OS detection statement like:
// if (stristr(PHP_OS, 'Linux')) {}
//
// Some possibilites for PHP_OS...
//
// CYGWIN_NT-5.1
// Darwin
// FreeBSD
// HP-UX
// IRIX64
// Linux
// NetBSD
// OpenBSD
// SunOS
// Unix
// WIN32
// WINNT
// Windows
//
//system information
echo "<b>".$text['header-sys-status']."</b>";
@ -210,8 +218,8 @@ $document['title'] = $text['title-sys-status'];
//linux
if (stristr(PHP_OS, 'Linux')) {
echo "<!--\n";
$shellcmd = 'free -hw';
$shell_result = shell_exec($shellcmd);
$shell_cmd = 'free -hw';
$shell_result = shell_exec($shell_cmd);
echo "-->\n";
if (strlen($shell_result) > 0) {
echo "<table width=\"100%\" border=\"0\" cellpadding=\"7\" cellspacing=\"0\">\n";
@ -237,8 +245,8 @@ $document['title'] = $text['title-sys-status'];
//freebsd
if (stristr(PHP_OS, 'FreeBSD')) {
echo "<!--\n";
$shellcmd = 'sysctl vm.vmtotal';
$shell_result = shell_exec($shellcmd);
$shell_cmd = 'sysctl vm.vmtotal';
$shell_result = shell_exec($shell_cmd);
echo "-->\n";
if (strlen($shell_result) > 0) {
echo "<table width=\"100%\" border=\"0\" cellpadding=\"7\" cellspacing=\"0\">\n";
@ -267,8 +275,8 @@ $document['title'] = $text['title-sys-status'];
//linux
if (stristr(PHP_OS, 'Linux')) {
echo "<!--\n";
$shellcmd = "ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'";
$shell_result = shell_exec($shellcmd);
$shell_cmd = "ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'";
$shell_result = shell_exec($shell_cmd);
echo "-->\n";
if (strlen($shell_result) > 0) {
echo "<table width=\"100%\" border=\"0\" cellpadding=\"7\" cellspacing=\"0\">\n";
@ -282,7 +290,7 @@ $document['title'] = $text['title-sys-status'];
echo " <td class=\"row_style1\">\n";
echo " <pre>\n";
//$last_line = shell_exec($shellcmd, $shell_result);
//$last_line = shell_exec($shell_cmd, $shell_result);
//foreach ($shell_result as $value) {
// echo substr($value, 0, 100);
// echo "<br />";
@ -302,8 +310,8 @@ $document['title'] = $text['title-sys-status'];
//freebsd
if (stristr(PHP_OS, 'FreeBSD')) {
echo "<!--\n";
$shellcmd = 'top';
$shell_result = shell_exec($shellcmd);
$shell_cmd = 'top';
$shell_result = shell_exec($shell_cmd);
echo "-->\n";
if (strlen($shell_result) > 0) {
echo "<table width=\"100%\" border=\"0\" cellpadding=\"7\" cellspacing=\"0\">\n";
@ -331,8 +339,8 @@ $document['title'] = $text['title-sys-status'];
if (permission_exists('system_view_hdd')) {
if (stristr(PHP_OS, 'Linux') || stristr(PHP_OS, 'FreeBSD')) {
echo "<!--\n";
$shellcmd = 'df -hP --total';
$shell_result = shell_exec($shellcmd);
$shell_cmd = 'df -hP --total';
$shell_result = shell_exec($shell_cmd);
echo "-->\n";
echo "<table width=\"100%\" border=\"0\" cellpadding=\"7\" cellspacing=\"0\">\n";
echo "<tr>\n";
@ -353,10 +361,10 @@ $document['title'] = $text['title-sys-status'];
//disk_free_space returns the number of bytes available on the drive;
//1 kilobyte = 1024 byte
//1 megabyte = 1024 kilobyte
$driveletter = substr($_SERVER["DOCUMENT_ROOT"], 0, 2);
$disksize = round(disk_total_space($driveletter)/1024/1024, 2);
$disksizefree = round(disk_free_space($driveletter)/1024/1024, 2);
$diskpercentavailable = round(($disksizefree/$disksize) * 100, 2);
$drive_letter = substr($_SERVER["DOCUMENT_ROOT"], 0, 2);
$disk_size = round(disk_total_space($drive_letter)/1024/1024, 2);
$disk_size_free = round(disk_free_space($drive_letter)/1024/1024, 2);
$disk_percent_available = round(($disk_size_free/$disk_size) * 100, 2);
echo "<table width=\"100%\" border=\"0\" cellpadding=\"7\" cellspacing=\"0\">\n";
echo "<tr>\n";
@ -367,7 +375,7 @@ $document['title'] = $text['title-sys-status'];
echo " ".$text['label-drive-capacity']." \n";
echo " </td>\n";
echo " <td class=\"row_style1\">\n";
echo " $disksize mb\n";
echo " $disk_size mb\n";
echo " </td>\n";
echo "</tr>\n";
@ -376,7 +384,7 @@ $document['title'] = $text['title-sys-status'];
echo " ".$text['label-drive-free']." \n";
echo " </td>\n";
echo " <td class=\"row_style1\">\n";
echo " $disksizefree mb\n";
echo " $disk_size_free mb\n";
echo " </td>\n";
echo "</tr>\n";
@ -385,7 +393,7 @@ $document['title'] = $text['title-sys-status'];
echo " ".$text['label-drive-percent']." \n";
echo " </td>\n";
echo " <td class=\"row_style1\">\n";
echo " $diskpercentavailable% \n";
echo " $disk_percent_available% \n";
echo " </td>\n";
echo "</tr>\n";
echo "</table>\n";
@ -441,11 +449,7 @@ $document['title'] = $text['title-sys-status'];
echo "<br /><br />\n";
}
//backup
if (permission_exists('zzz') && $db_type == 'sqlite') {
require_once "core/backup/backupandrestore.php";
}
//include the footer
require_once "resources/footer.php";
?>