user dashboard generates errors in httpd error log (#1873)

* Update extension.php

* Update user_dashboard.php

User dashboard fills the httpd error log with shell_exec errors. These changes add escapeshellcmd which eliminates these errors and adds 2>&1 to the df command which also generates an error when /home is not mounted
This commit is contained in:
nyfon
2016-09-03 22:25:41 -04:00
committed by FusionPBX
parent 19db155e40
commit 49fd2cc3c4

View File

@@ -939,7 +939,7 @@
//disk usage
if (stristr(PHP_OS, 'Linux')) {
$df = shell_exec("/usr/bin/which df");
$tmp = shell_exec($df." /home");
$tmp = shell_exec($df." /home 2>&1");
$tmp = explode("\n", $tmp);
$tmp = preg_replace('!\s+!', ' ', $tmp[1]); // multiple > single space
$tmp = explode(' ', $tmp);
@@ -1005,7 +1005,7 @@
if (stristr(PHP_OS, 'Linux')) {
unset($tmp);
$cut = shell_exec("/usr/bin/which cut");
$uptime = shell_exec($cut." -d. -f1 /proc/uptime");
$uptime = shell_exec(escapeshellcmd($cut." -d. -f1 /proc/uptime"));
$tmp['y'] = floor($uptime/60/60/24/365);
$tmp['d'] = $uptime/60/60/24%365;
$tmp['h'] = $uptime/60/60%24;
@@ -1029,7 +1029,7 @@
if (stristr(PHP_OS, 'Linux')) {
$free = shell_exec("/usr/bin/which free");
$awk = shell_exec("/usr/bin/which awk");
$percent_memory = round(shell_exec($free." | ".$awk." 'FNR == 3 {print $3/($3+$4)*100}'"), 1);
$percent_memory = round(shell_exec(escapeshellcmd($free." | ".$awk." 'FNR == 3 {print $3/($3+$4)*100}'")), 1);
if ($percent_memory != '') {
$hud[$n]['html'] .= "<tr class='tr_link_void'>\n";
$hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'>".$text['label-memory_usage']."</td>\n";