From 4e9dd1cdc973998eb5cea5b4a961c9d78d34c9c3 Mon Sep 17 00:00:00 2001 From: frytimo Date: Tue, 23 Jan 2024 19:11:51 -0400 Subject: [PATCH] Create information area for bug reports or errors to the Support Team (#6876) * initial commit for system information bug report data * add javascript to copy to clipboard * add javascript to copy to clipboard * Update copy_to_clipboard.js * Update system.php * Update app_languages.php Add other languages * move function file to resources/functions directory * use the array returned from system_information function * Update app_languages.php * update path locations * remove require files * Merge origin/create_json_page_for_bug_report into create_json_page_for_bug_report --- app/system/app_languages.php | 72 ++++ .../functions/system_information.php | 335 ++++++++++++++++ .../resources/javascript/copy_to_clipboard.js | 12 + app/system/system.php | 371 ++++-------------- 4 files changed, 506 insertions(+), 284 deletions(-) create mode 100644 app/system/resources/functions/system_information.php create mode 100644 app/system/resources/javascript/copy_to_clipboard.js diff --git a/app/system/app_languages.php b/app/system/app_languages.php index 23abc300b0..547dbb9e6e 100644 --- a/app/system/app_languages.php +++ b/app/system/app_languages.php @@ -771,4 +771,76 @@ $text['header-sys-status']['zh-cn'] = "系统状况"; $text['header-sys-status']['ja-jp'] = "システムステータス"; $text['header-sys-status']['ko-kr'] = "시스템 상태"; +$text['label-support']['en-us'] = "Support Information"; +$text['label-support']['en-gb'] = "Support Information"; +$text['label-support']['ar-eg'] = ""; +$text['label-support']['de-at'] = ""; +$text['label-support']['de-ch'] = ""; +$text['label-support']['de-de'] = ""; +$text['label-support']['es-cl'] = ""; +$text['label-support']['es-mx'] = ""; +$text['label-support']['fr-ca'] = ""; +$text['label-support']['fr-fr'] = ""; +$text['label-support']['he-il'] = ""; +$text['label-support']['it-it'] = ""; +$text['label-support']['nl-nl'] = ""; +$text['label-support']['pl-pl'] = ""; +$text['label-support']['pt-br'] = ""; +$text['label-support']['pt-pt'] = ""; +$text['label-support']['ro-ro'] = ""; +$text['label-support']['ru-ru'] = ""; +$text['label-support']['sv-se'] = ""; +$text['label-support']['uk-ua'] = ""; +$text['label-support']['zh-cn'] = ""; +$text['label-support']['ja-jp'] = ""; +$text['label-support']['ko-kr'] = ""; + +$text['label-json']['en-us'] = "JSON"; +$text['label-json']['en-gb'] = "JSON"; +$text['label-json']['ar-eg'] = "JSON"; +$text['label-json']['de-at'] = "JSON"; +$text['label-json']['de-ch'] = "JSON"; +$text['label-json']['de-de'] = "JSON"; +$text['label-json']['es-cl'] = "JSON"; +$text['label-json']['es-mx'] = "JSON"; +$text['label-json']['fr-ca'] = "JSON"; +$text['label-json']['fr-fr'] = "JSON"; +$text['label-json']['he-il'] = "JSON"; +$text['label-json']['it-it'] = "JSON"; +$text['label-json']['nl-nl'] = "JSON"; +$text['label-json']['pl-pl'] = "JSON"; +$text['label-json']['pt-br'] = "JSON"; +$text['label-json']['pt-pt'] = "JSON"; +$text['label-json']['ro-ro'] = "JSON"; +$text['label-json']['ru-ru'] = "JSON"; +$text['label-json']['sv-se'] = "JSON"; +$text['label-json']['uk-ua'] = "JSON"; +$text['label-json']['zh-cn'] = "JSON"; +$text['label-json']['ja-jp'] = "JSON"; +$text['label-json']['ko-kr'] = "JSON"; + +$text['label-copy_to_clipboard']['en-us'] = "Copy to Clipboard"; +$text['label-copy_to_clipboard']['en-gb'] = "Copy to Clipboard"; +$text['label-copy_to_clipboard']['ar-eg'] = ""; +$text['label-copy_to_clipboard']['de-at'] = ""; +$text['label-copy_to_clipboard']['de-ch'] = ""; +$text['label-copy_to_clipboard']['de-de'] = ""; +$text['label-copy_to_clipboard']['es-cl'] = ""; +$text['label-copy_to_clipboard']['es-mx'] = ""; +$text['label-copy_to_clipboard']['fr-ca'] = ""; +$text['label-copy_to_clipboard']['fr-fr'] = ""; +$text['label-copy_to_clipboard']['he-il'] = ""; +$text['label-copy_to_clipboard']['it-it'] = ""; +$text['label-copy_to_clipboard']['nl-nl'] = ""; +$text['label-copy_to_clipboard']['pl-pl'] = ""; +$text['label-copy_to_clipboard']['pt-br'] = ""; +$text['label-copy_to_clipboard']['pt-pt'] = ""; +$text['label-copy_to_clipboard']['ro-ro'] = ""; +$text['label-copy_to_clipboard']['ru-ru'] = ""; +$text['label-copy_to_clipboard']['sv-se'] = ""; +$text['label-copy_to_clipboard']['uk-ua'] = ""; +$text['label-copy_to_clipboard']['zh-cn'] = ""; +$text['label-copy_to_clipboard']['ja-jp'] = ""; +$text['label-copy_to_clipboard']['ko-kr'] = ""; + ?> diff --git a/app/system/resources/functions/system_information.php b/app/system/resources/functions/system_information.php new file mode 100644 index 0000000000..0f821af2d5 --- /dev/null +++ b/app/system/resources/functions/system_information.php @@ -0,0 +1,335 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2023 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane + James Rose + Tim Fry + */ + + /* + * Creates the following array structure: + * $array['version'] + * $array['git']['path'] + * $array['git']['branch'] + * $array['git']['origin'] + * $array['git']['commit'] + * $array['git']['status'] + * $array['git']['age'] + * $array['git']['date'] + * $array['path'] + * $array['switch']['version'] + * $array['switch']['bits'] + * $array['switch']['git']['info'] + * $array['php']['version'] + * $array['os']['version'] + * $array['os']['name'] + * $array['os']['kernel'] (*nix only) + * $array['os']['uptime'] + * $array['os']['date'] + * $array['os']['type'] + * $array['os']['mem'] + * $array['os']['cpu'] + * $array['os']['disk']['size'] + * $array['os']['disk']['free'] (Windows only) + * $array['os']['disk']['available'] (Windows only) + * $array['database']['type'] + * $array['database']['version'] + * $array['database']['connections'] + * $array['database']['sizes'][$datname] = $size + * $array['memcache'] + */ + +// 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 + // + +//system information + function system_information(): array { + global $db_type; + $system_information = []; + $esl = event_socket::create(); + + //php and switch version + if (permission_exists('system_view_info')) { + $system_information['version'] = software::version(); + + $git_path = normalize_path_to_os($_SERVER['PROJECT_ROOT'] . "/.git"); + if (file_exists($git_path)) { + $system_information['git']['path'] = $git_path; + $git_exe = 'git'; + if (strtoupper(substr(PHP_OS, 0, 3)) === 'SUN') { + $git_exe = shell_exec('which git'); + } + exec($git_exe . ' --git-dir=' . $git_path . ' status', $dummy, $returnCode); + if ($returnCode) { + $system_information['git']['branch'] = 'unknown'; + $system_information['git']['origin'] = 'unknown'; + $system_information['git']['commit'] = 'unknown'; + $system_information['git']['status'] = 'unknown'; + $system_information['git']['age'] = 'unknown'; + $system_information['git']['date'] = 'unknown'; + } else { + $git_branch = shell_exec($git_exe . ' --git-dir=' . $git_path . ' name-rev --name-only HEAD'); + rtrim($git_branch); + $git_commit = shell_exec($git_exe . ' --git-dir=' . $git_path . ' rev-parse HEAD'); + rtrim($git_commit); + $git_origin = shell_exec($git_exe . ' --git-dir=' . $git_path . ' config --get remote.origin.url'); + rtrim($git_origin); + $git_origin = preg_replace('/\.git$/', '', $git_origin); + $git_status = shell_exec($git_exe . ' --git-dir=' . $git_path . ' status | grep "Your branch"'); + if (!empty($git_status)) + rtrim($git_status); + $git_age = shell_exec($git_exe . ' --git-dir=' . $git_path . ' log --pretty=format:%at "HEAD^!"'); + rtrim($git_age); + $git_date = DateTime::createFromFormat('U', $git_age); + $git_age = $git_date->diff(new DateTime('now')); + $system_information['git']['branch'] = $git_branch; + $system_information['git']['origin'] = $git_origin; + $system_information['git']['commit'] = $git_commit; + $system_information['git']['status'] = $git_status; + $system_information['git']['age'] = $git_age; + $system_information['git']['date'] = $git_date; + } + } else { + $system_information['git']['path'] = 'unknown'; + } + $system_information['path'] = $_SERVER['PROJECT_ROOT']; + + if ($esl->is_connected()) { + $switch_version = $esl->request('api version'); + preg_match("/FreeSWITCH Version (\d+\.\d+\.\d+(?:\.\d+)?).*\(.*?(\d+\w+)\s*\)/", $switch_version, $matches); + $system_information['switch']['version'] = $matches[1]; + $system_information['switch']['bits'] = $matches[2]; + preg_match("/\(git\s*(.*?)\s*\d+\w+\s*\)/", $switch_version, $matches); + $switch_git_info = $matches[1] ?? null; + if (!empty($switch_git_info)) { + $system_information['switch']['git']['info'] = $switch_git_info; + } else { + $system_information['switch']['git']['info'] = 'unknown'; + } + } else { + $system_information['switch']['version'] = 'connection failed'; + $system_information['switch']['bits'] = 'connection failed'; + $system_information['switch']['git']['info'] = 'connection failed'; + } + + $system_information['php']['version'] = phpversion(); + + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + $data = explode("\n", shell_exec('systeminfo /FO CSV 2> nul')); + $data = array_combine(str_getcsv($data[0]), str_getcsv($data[1])); + $os_name = $data['OS Name']; + $os_version = $data['OS Version']; + unset($data); + } else { + $os_kernel = shell_exec('uname -a'); + $os_name = shell_exec('lsb_release -is'); + $os_version = shell_exec('lsb_release -rs'); + } + $system_information['os']['name'] = $os_name; + $system_information['os']['version'] = $os_version; + if (!empty($os_kernel)) { + $system_information['os']['kernel'] = $os_kernel; + } + + $tmp_result = shell_exec('uptime'); + if (!empty($tmp_result)) { + $system_information['os']['uptime'] = $tmp_result; + } else { + $system_information['os']['uptime'] = 'unknown'; + } + } else { + $system_information['os']['name'] = 'permission denied'; + $system_information['os']['version'] = 'permission denied'; + $system_information['os']['uptime'] = 'permission denied'; + $system_information['php']['version'] = 'permission denied'; + $system_information['os']['version'] = 'permission denied'; + } + + $system_information['os']['date'] = date('r'); + $system_information['os']['type'] = PHP_OS; + + //memory information + if (permission_exists('system_view_ram')) { + //linux + if (stristr(PHP_OS, 'Linux')) { + $shell_cmd = 'free -hw'; + $shell_result = shell_exec($shell_cmd); + } + + //freebsd + if (stristr(PHP_OS, 'FreeBSD')) { + $shell_cmd = 'sysctl vm.vmtotal'; + $shell_result = shell_exec($shell_cmd); + } + + //Windows + if (stristr(PHP_OS, 'WIN')) { + // connect to WMI + $wmi = new COM('WinMgmts:root/cimv2'); + // Query this Computer for Total Physical RAM + $res = $wmi->ExecQuery('Select TotalPhysicalMemory from Win32_ComputerSystem'); + // Fetch the first item from the results + $system_information = $res->ItemIndex(0); + $shell_result = round($system_information->TotalPhysicalMemory / 1024 / 1024, 0); + } + if (!empty($shell_result)) { + $system_information['os']['mem'] = $shell_result; + } else { + $system_information['os']['mem'] = 'unknown'; + } + } else { + $system_information['os']['mem'] = 'permission denied'; + } + + //cpu information + if (permission_exists('system_view_cpu')) { + //linux + if (stristr(PHP_OS, 'Linux')) { + $shell_cmd = "ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'"; + $shell_result = shell_exec($shell_cmd); + } + + //freebsd + if (stristr(PHP_OS, 'FreeBSD')) { + $shell_cmd = 'top'; + $shell_result = shell_exec($shell_cmd); + } + + if (!empty($shell_result)) { + $system_information['os']['cpu'] = $shell_result; + } else { + $system_information['os']['cpu'] = 'unknown'; + } + } else { + $system_information['os']['cpu'] = 'permission denied'; + } + + //drive space + if (permission_exists('system_view_hdd')) { + if (stristr(PHP_OS, 'Linux') || stristr(PHP_OS, 'FreeBSD')) { + $shell_cmd = 'df -hP'; //--total is ignored + $shell_result = shell_exec($shell_cmd); + if (!empty($shell_result)) { + $system_information['os']['disk']['size'] = $shell_result; + } + } else if (stristr(PHP_OS, 'WIN')) { + //disk_free_space returns the number of bytes available on the drive; + //1 kilobyte = 1024 byte + //1 megabyte = 1024 kilobyte + $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); + + $system_information['os']['disk']['size'] = $disk_size; + $system_information['os']['disk']['free'] = $disk_size_free; + $system_information['os']['disk']['available'] = $disk_percent_available; + } + } else { + $system_information['os']['disk']['size'] = 'permission denied'; + $system_information['os']['disk']['free'] = 'permission denied'; + $system_information['os']['disk']['available'] = 'permission denied'; + } + + //database information + if (permission_exists('system_view_database')) { + if ($db_type == 'pgsql') { + + //database version + $sql = "select version(); "; + $database = new database; + $database_version = $database->select($sql, null, 'column'); + + //database connections + $sql = "select count(*) from pg_stat_activity; "; + $database_connections = $database->select($sql, null, 'column'); + + //database size + $sql = "SELECT pg_database.datname,"; + $sql .= "pg_size_pretty(pg_database_size(pg_database.datname)) AS size "; + $sql .= "FROM pg_database;"; + $database_size = $database->select($sql, null, 'all'); + + $system_information['database']['type'] = 'pgsql'; + $system_information['database']['version'] = $database_version; + $system_information['database']['connections'] = $database_connections; + + foreach ($database_size as $row) { + $system_information['database']['sizes'][$row['datname']] = $row['size']; + } + } + } else { + $system_information['database'] = 'permission denied'; + } + + //memcache information + if (permission_exists("system_view_memcache") && file_exists($_SERVER["PROJECT_ROOT"] . "/app/sip_status/app_config.php")) { + $memcache_fail = true; + $mod = new modules; + if ($mod->active("mod_memcache")) { + if ($esl->is_connected()) { + $switch_cmd = "memcache status verbose"; + $switch_result = event_socket::api($switch_cmd); + $memcache_lines = preg_split('/\n/', $switch_result); + foreach ($memcache_lines as $memcache_line) { + if (!empty(trim($memcache_line)) > 0 && substr_count($memcache_line, ': ')) { + $memcache_temp = explode(': ', $memcache_line); + $memcache_status[$memcache_temp[0]] = $memcache_temp[1]; + } + } + if (is_array($memcache_status) && sizeof($memcache_status) > 0) { + $system_information['memcache'] = $memcache_status; + $memcache_fail = false; + } + } + } + + if ($memcache_fail) { + $system_information['memcache'] = 'none'; + } + } else { + $system_information['memcache'] = 'permission denied or unavailable'; + } + + return $system_information; + } diff --git a/app/system/resources/javascript/copy_to_clipboard.js b/app/system/resources/javascript/copy_to_clipboard.js new file mode 100644 index 0000000000..92f12c549f --- /dev/null +++ b/app/system/resources/javascript/copy_to_clipboard.js @@ -0,0 +1,12 @@ +function copy_to_clipboard() { + const span_id = document.getElementById("system_information"); + const text_to_copy = span_id.innerText; + + navigator.clipboard.writeText(text_to_copy) + .then(function() { + console.log('Text successfully copied to clipboard'); + }) + .catch(function(err) { + console.error('Unable to copy text to clipboard', err); + }); +} diff --git a/app/system/system.php b/app/system/system.php index fd753477ec..677f25d9ee 100644 --- a/app/system/system.php +++ b/app/system/system.php @@ -28,7 +28,6 @@ //includes files require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once "resources/check_auth.php"; - //check permissions if (permission_exists('system_view_info') || permission_exists('system_view_cpu') @@ -48,32 +47,14 @@ //additional includes require_once "resources/header.php"; + require_once 'app/system/resources/functions/system_information.php'; + +//Load an array of system information + $system_information = system_information(); //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 - // - //system information echo "".$text['header-sys-status'].""; echo "

"; @@ -88,16 +69,13 @@ echo " ".$text['label-version']."\n"; echo " \n"; echo " \n"; - echo " ".software::version()."\n"; + echo " ".$system_information['version']."\n"; echo " \n"; echo "\n"; - $git_path = normalize_path_to_os($_SERVER['PROJECT_ROOT']."/.git"); + $git_path = $system_information['git']['path']; if(file_exists($git_path)){ - $git_exe = 'git'; - if (strtoupper(substr(PHP_OS, 0, 3)) === 'SUN') { $git_exe = shell_exec('which git'); } - exec($git_exe.' --git-dir='.$git_path.' status', $dummy, $returnCode); - if($returnCode){ + if($system_information['git']['status'] === 'unknown'){ echo "\n"; echo " \n"; echo " ".$text['label-git_info']."\n"; @@ -107,29 +85,15 @@ echo " \n"; echo "\n"; }else{ - $git_branch = shell_exec($git_exe.' --git-dir='.$git_path.' name-rev --name-only HEAD'); - rtrim($git_branch); - $git_commit = shell_exec($git_exe.' --git-dir='.$git_path.' rev-parse HEAD'); - rtrim($git_commit); - $git_origin = shell_exec($git_exe.' --git-dir='.$git_path.' config --get remote.origin.url'); - rtrim($git_origin); - $git_origin = preg_replace('/\.git$/','',$git_origin); - $git_status = shell_exec($git_exe.' --git-dir='.$git_path.' status | grep "Your branch"'); - if(!empty($git_status)) - rtrim($git_status); - $git_age = shell_exec($git_exe.' --git-dir='.$git_path.' log --pretty=format:%at "HEAD^!"'); - rtrim($git_age); - $git_date = DateTime::createFromFormat('U', $git_age); - $git_age = $git_date->diff(new DateTime('now')); echo "\n"; echo " \n"; echo " ".$text['label-git_info']."\n"; echo " \n"; echo " \n"; - echo " ".$text['label-git_branch'].": ".$git_branch."
\n"; - echo " ".$text['label-git_commit'].": ".$git_commit."
\n"; - echo " ".$text['label-git_origin'].": ".$git_origin."
\n"; - echo " ".$text['label-git_status'].": ".$git_status.$git_age->format(' %R%a days ago')."
\n"; + echo " ".$text['label-git_branch'].": ".$system_information['git']['branch']."
\n"; + echo " ".$text['label-git_commit'].": ".$system_information['git']['commit']."
\n"; + echo " ".$text['label-git_origin'].": ".$system_information['git']['origin']."
\n"; + echo " ".$text['label-git_status'].": ".$system_information['git']['status'].($system_information['git']['age'])->format(' %R%a days ago')."
\n"; echo " \n"; echo "\n"; } @@ -144,26 +108,19 @@ echo " \n"; echo "\n"; - $esl = event_socket::create(); - if ($esl->is_connected()) { - $switch_version = event_socket::api('version'); - preg_match("/FreeSWITCH Version (\d+\.\d+\.\d+(?:\.\d+)?).*\(.*?(\d+\w+)\s*\)/", $switch_version, $matches); - $switch_version = $matches[1]; - $switch_bits = $matches[2]; + if ($system_information['switch']['version'] !== 'connection failed') { echo "\n"; echo " \n"; echo " ".$text['label-switch']." ".$text['label-version']."\n"; echo " \n"; - echo " $switch_version ($switch_bits)\n"; + echo " {$system_information['switch']['version']} ({$system_information['switch']['bits']})\n"; echo "\n"; - preg_match("/\(git\s*(.*?)\s*\d+\w+\s*\)/", $switch_version, $matches); - $switch_git_info = $matches[1] ?? null; - if(!empty($switch_git_info)){ + if($system_information['switch']['git']['info'] !== 'connection failed'){ echo "\n"; echo " \n"; echo " ".$text['label-switch']." ".$text['label-git_info']."\n"; echo " \n"; - echo " $switch_git_info\n"; + echo " {$system_information['switch']['git']['info']}\n"; echo "\n"; } } @@ -172,83 +129,61 @@ echo " \n"; echo " ".$text['label-php']." ".$text['label-version']."\n"; echo " \n"; - echo " ".phpversion()."\n"; + echo " ".$system_information['php']['version']."\n"; echo "\n"; echo "\n"; echo " ".$text['title-os-info']."\n"; echo "\n"; - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - echo "\n"; - } - else { - echo "\n"; - } - - if (!empty($os_name)) { + if ($system_information['os']['name'] !== 'permission denied') { echo "\n"; echo " \n"; echo " ".$text['label-os']." \n"; echo " \n"; echo " \n"; - echo " ".$os_name." \n"; + echo " ".$system_information['os']['name']." \n"; echo " \n"; echo "\n"; } - if (!empty($os_version)) { + if ($system_information['os']['version'] !== 'permission denied') { echo "\n"; echo " \n"; echo " ".$text['label-version']." \n"; echo " \n"; echo " \n"; - echo " ".$os_version." \n"; + echo " ".$system_information['os']['version']." \n"; echo " \n"; echo "\n"; } - if (!empty($os_kernel)) { + if (!empty($system_information['os']['kernel'])) { echo "\n"; echo " \n"; echo " ".$text['label-kernel']." \n"; echo " \n"; echo " \n"; - echo " ".$os_kernel." \n"; + echo " ".$system_information['os']['kernel']." \n"; echo " \n"; echo "\n"; } - unset($os_name, $os_version, $os_kernel); - echo "\n"; - if (!empty($tmp_result)) { + if ($system_information['os']['uptime'] !== 'unknown') { echo "\n"; echo " \n"; echo " Uptime\n"; echo " \n"; echo " \n"; - echo " ".$tmp_result." \n"; + echo " ".$system_information['os']['uptime']." \n"; echo " \n"; echo "\n"; } - unset($tmp_result); } echo "\n"; echo " \n"; echo " Date\n"; echo " \n"; echo " \n"; - echo " ".date('r')." \n"; + echo " ".$system_information['os']['date']." \n"; echo " \n"; echo "\n"; echo "\n"; @@ -256,153 +191,45 @@ //memory information if (permission_exists('system_view_ram')) { - //linux - if (stristr(PHP_OS, 'Linux')) { - echo "\n"; - if (!empty($shell_result)) { - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "
".$text['title-mem']."
\n"; - echo " ".$text['label-mem']."\n"; - echo " \n"; - echo "
\n";
-				echo "$shell_result
"; - echo "
\n"; - unset($shell_result); - echo "
\n"; - echo "

"; - } - } - - //freebsd - if (stristr(PHP_OS, 'FreeBSD')) { - echo "\n"; - if (!empty($shell_result)) { - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "
".$text['title-mem']."
\n"; - echo " ".$text['label-mem']."\n"; - echo " \n"; - echo "
\n";
-				echo "$shell_result
"; - echo "
\n"; - unset($shell_result); - echo "
\n"; - echo "

"; - } - } - - //Windows - if (stristr(PHP_OS, 'WIN')) { - echo "\n"; - if (!empty($shell_result)) { - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "
".$text['Physical Memory']."
\n"; - echo " ".$text['label-mem']." \n"; - echo " \n"; - echo " $shell_result mb\n"; - echo "
\n"; - echo "

"; - - } + if ($system_information['os']['mem'] !== 'unknown' && $system_information['os']['mem'] !== 'permission denied') { + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo "
".$text['title-mem']."
\n"; + echo " ".$text['label-mem']."\n"; + echo " \n"; + echo "
\n";
+			echo "{$system_information['os']['mem']}
"; + echo "
\n"; + echo "
\n"; + echo "

"; } } //cpu information if (permission_exists('system_view_cpu')) { - //linux - if (stristr(PHP_OS, 'Linux')) { - echo "\n"; - if (!empty($shell_result)) { - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "
".$text['title-cpu']."
\n"; - echo " ".$text['label-cpu']."\n"; - echo " \n"; - echo "
\n";
-
-				//$last_line = shell_exec($shell_cmd, $shell_result);
-				//foreach ($shell_result as $value) {
-				//	echo substr($value, 0, 100);
-				//	echo "
"; - //} - - echo "$shell_result
"; - - echo "
\n"; - unset($shell_result); - echo "
\n"; - echo "

"; - } - } - - //freebsd - if (stristr(PHP_OS, 'FreeBSD')) { - echo "\n"; - if (!empty($shell_result)) { - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "
".$text['title-cpu']."
\n"; - echo " ".$text['label-cpu']."\n"; - echo " \n"; - echo "
\n";
-				echo "$shell_result
"; - echo "
\n"; - unset($shell_result); - echo "
\n"; - echo "

"; - } + if ($system_information['os']['cpu'] !== 'unknown' && $system_information['os']['cpu'] !== 'permission denied') { + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo "
".$text['title-cpu']."
\n"; + echo " ".$text['label-cpu']."\n"; + echo " \n"; + echo "
\n";
+			echo "{$system_information['os']['cpu']}
"; + echo "
\n"; + echo "
\n"; + echo "

"; } } @@ -410,8 +237,6 @@ if (permission_exists('system_view_hdd')) { if (stristr(PHP_OS, 'Linux') || stristr(PHP_OS, 'FreeBSD')) { echo "\n"; echo "\n"; echo "\n"; @@ -423,7 +248,7 @@ echo " \n"; echo " \n"; echo "\n"; @@ -446,7 +271,7 @@ echo " ".$text['label-drive-capacity']." \n"; echo " \n"; echo " \n"; echo "\n"; @@ -455,7 +280,7 @@ echo " ".$text['label-drive-free']." \n"; echo " \n"; echo " \n"; echo "\n"; @@ -464,7 +289,7 @@ echo " ".$text['label-drive-percent']." \n"; echo " \n"; echo " \n"; echo "\n"; echo "
\n"; echo "
\n";
-			echo "$shell_result
"; + echo "{$system_information['os']['disk']['size']}
"; echo "
\n"; echo "
\n"; - echo " $disk_size mb\n"; + echo " {$system_information['os']['disk']['size']} mb\n"; echo "
\n"; - echo " $disk_size_free mb\n"; + echo " {$system_information['os']['disk']['free']} mb\n"; echo "
\n"; - echo " $disk_percent_available% \n"; + echo " {$system_information['os']['disk']['available']}% \n"; echo "
\n"; @@ -474,24 +299,7 @@ //database information if (permission_exists('system_view_database')) { - if ($db_type == 'pgsql') { - - //database version - $sql = "select version(); "; - $database = new database; - $database_version = $database->select($sql, null, 'column'); - - //database connections - $sql = "select count(*) from pg_stat_activity; "; - $database = new database; - $database_connections = $database->select($sql, null, 'column'); - - //database size - $sql = "SELECT pg_database.datname,\n"; - $sql .= "pg_size_pretty(pg_database_size(pg_database.datname)) AS size \n"; - $sql .= "FROM pg_database;\n"; - $database = new database; - $database_size = $database->select($sql, null, 'all'); + if ($system_information['database']['type'] == 'pgsql') { echo "\n"; echo "\n"; @@ -502,7 +310,7 @@ echo " ".$text['label-version']." \n"; echo " \n"; echo " \n"; echo "\n"; @@ -511,7 +319,7 @@ echo " ".$text['label-database_connections']." \n"; echo " \n"; echo " \n"; echo "\n"; @@ -522,8 +330,8 @@ echo " \n"; @@ -541,37 +349,17 @@ echo " \n"; echo " \n"; - $memcache_fail = false; - $mod = new modules; - if ($mod -> active("mod_memcache")) { - $esl = event_socket::create(); - if ($esl->is_connected()) { - $switch_cmd = "memcache status verbose"; - $switch_result = event_socket::api($switch_cmd); - $memcache_lines = preg_split('/\n/', $switch_result); - foreach($memcache_lines as $memcache_line) { - if (!empty(trim($memcache_line)) > 0 && substr_count($memcache_line, ': ')) { - $memcache_temp = explode(': ', $memcache_line); - $memcache_status[$memcache_temp[0]] = $memcache_temp[1]; - } - } - - if (is_array($memcache_status) && sizeof($memcache_status) > 0) { - foreach($memcache_status as $memcache_field => $memcache_value) { + if ($system_information['memcache'] !== 'none' && $system_information['memcache'] !== 'permission denied or unavailable') { + if (is_array($system_information['memcache']) && sizeof($system_information['memcache']) > 0) { + foreach($system_information['memcache'] as $memcache_field => $memcache_value) { echo "\n"; echo " \n"; echo " \n"; echo "\n"; } } - else { $memcache_fail = true; } - } - else { $memcache_fail = true; } - } - else { $memcache_fail = true; } - - if ($memcache_fail) { + else { echo "\n"; echo " \n"; echo " \n"; @@ -582,6 +370,21 @@ echo "

\n"; } + echo ""; + echo "
\n"; - echo " ".$database_version."
\n"; + echo " ".$system_information['database']['version']."
\n"; echo "
\n"; - echo " ".$database_connections."
\n"; + echo " ".$system_information['database']['connections']."
\n"; echo "
\n"; echo " \n"; echo " \n"; - foreach ($database_size as $row) { - echo " \n"; + foreach ($system_information['database']['sizes'] as $datname => $size) { + echo " \n"; } echo "
". $text['label-name'] ." ". $text['label-size'] ."
".$row['datname'] ." ". $row['size'] ."
".$datname ." ". $size ."
\n"; echo "
".$text['title-memcache']."
".$memcache_field."".$memcache_value."
".$text['label-memcache_status']."".$text['message-unavailable']."
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo "
".$text['title-support']."
\n"; + echo ' '." \n"; + echo " \n"; + echo " ". json_encode($system_information)."\n"; + echo "
\n"; + //include the footer require_once "resources/footer.php";