NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
bozolino1
Apr 03, 2011Aspirant
NasMonitor: PHPSysInfo problem
I've just installed the latest NasMonitor (3.6.00) on my Ultra 6 - now PHPSysInfo behaves strangely: upon bringing up the interface, i get about a dozen JavaScript pop-up messages with the conten...
szimonek
Dec 03, 2011Aspirant
Hello,
This problem is caused by MDStatus plugin to phpsysinfo and is relatively easy to fix. Problem is that, function addAttribute($name, $value) at /c/webroot/loadavg/phpsysinfo/includes/xml/class.SimpleXMLExtended.inc.php cannot add attribute with empty string as attribute value and such attribute is not added to result XML. No attribute or wrong value, show all that "undefined" warnings when page is generated. The reason why that value is empty, is in function _toUTF8($str) in the same class, which trims input string before conversion to UTF8:
Now what attribute, what value you ask? Every disk in RAID array has status parameter. But in data source file for plugin (/proc/mdstat) this parameter is empty when disk is OK (F when Failed, S when Spare). So plugin gets status of disk, and cannot add it as attribute to result XML element.
Solution is to change disk status value to "_" (as "Disk OK" status) instead of " " which will generate correct attribute.
One need to edit two files:
- plugin class in /c/webroot/loadavg/phpsysinfo/plugins/MDStatus/class.MDStatus.inc.php and change line:
to:
- js plugin file /c/webroot/loadavg/phpsysinfo/plugins/MDStatus/js/MDStatus.js to add in function mdstatus_diskicon(xml) new line after line 'case "":'
to:
Now MDStatus plugin and phpsysinfo, works like a charm again.
It took me two hours, but it was fun to recall my php knowledge. Happy hacking :-)
Best regards.
Szymon
This problem is caused by MDStatus plugin to phpsysinfo and is relatively easy to fix. Problem is that, function addAttribute($name, $value) at /c/webroot/loadavg/phpsysinfo/includes/xml/class.SimpleXMLExtended.inc.php cannot add attribute with empty string as attribute value and such attribute is not added to result XML. No attribute or wrong value, show all that "undefined" warnings when page is generated. The reason why that value is empty, is in function _toUTF8($str) in the same class, which trims input string before conversion to UTF8:
private function _toUTF8($str)
{
if ($this->_encoding != null) {
$enclist = mb_list_encodings();
if (in_array($this->_encoding, $enclist)) {
return mb_convert_encoding(trim($str), 'UTF-8', $this->_encoding);
}
else if (function_exists("iconv")) {
return iconv($this->_encoding, 'UTF-8', trim($str));
}
else {
return mb_convert_encoding(trim($str), 'UTF-8');
}
} else {
return mb_convert_encoding(trim($str), 'UTF-8');
}
}
public function addAttribute($name, $value)
{
$nameUtf8 = $this->_toUTF8($name);
$valueUtf8 = htmlspecialchars($this->_toUTF8($value));
$this->_SimpleXmlElement->addAttribute($nameUtf8, $valueUtf8);
}
Now what attribute, what value you ask? Every disk in RAID array has status parameter. But in data source file for plugin (/proc/mdstat) this parameter is empty when disk is OK (F when Failed, S when Spare). So plugin gets status of disk, and cannot add it as attribute to result XML element.
Solution is to change disk status value to "_" (as "Disk OK" status) instead of " " which will generate correct attribute.
One need to edit two files:
- plugin class in /c/webroot/loadavg/phpsysinfo/plugins/MDStatus/class.MDStatus.inc.php and change line:
$this->_result['devices'][$dev]['partitions'][$partition[1]]['status'] = " ";
to:
$this->_result['devices'][$dev]['partitions'][$partition[1]]['status'] = "_";
- js plugin file /c/webroot/loadavg/phpsysinfo/plugins/MDStatus/js/MDStatus.js to add in function mdstatus_diskicon(xml) new line after line 'case "":'
case " ":
case "":
to:
case " ":
case "":
case "_":
Now MDStatus plugin and phpsysinfo, works like a charm again.
It took me two hours, but it was fun to recall my php knowledge. Happy hacking :-)
Best regards.
Szymon
Related Content
NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!