浏览代码

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
nyfon 9 年之前
父节点
当前提交
883ce04c76
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      core/user_settings/user_dashboard.php

+ 3 - 3
core/user_settings/user_dashboard.php

@@ -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";