ECSC / analogi

Graphical Web Interface for OSSEC
GNU General Public License v3.0
72 stars 35 forks source link

Invalid value passed to foreach() when loading newsfeed #14

Closed magneticstain closed 4 years ago

magneticstain commented 10 years ago

Hello,

It looks like PHP is throwing an error for a foreach located on line 117 of php/newsfeed_trend.php. From the logs in my local install, with PII removed:

[Thu Jan 16 20:21:42 2014] [error] [client x.x.x.x] PHP Warning: Invalid argument supplied for foreach() in /var/www/analogi/php/newsfeed_trend.php on line 117, referer: http://url.example.com/analogi/index.php?

After glancing through the code and doing some minor troubleshooting, $finaltrendinfo seems to be the culprit. For one reason or another, nothing is being populated into it during the if statement on line 96.

I would recommend checking the logic in and near that if statement. If everything is correct and it's just giving me no results, I would add in an if statement to check if that variable is NULL before putting it into the foreach(), as it doesn't look like it is being initialized anywhere.

If I find the time, I'll try to submit a patch for it.

magneticstain commented 10 years ago

Related PHP error confirming it's NULL going into the foreach():

[Thu Jan 16 21:48:33 2014] [error] [client x.x.x.x] PHP Warning: arsort() expects parameter 1 to be array, null given in /var/www/analogi/php/newsfeed_trend.php on line 110, referer: http://url.example.com/analogi/index.php?level=1&hours=72&field=rule_id&category=