• Resolved Matthias Pabst

    (@matthiaspabst)


    Hi Folks,

    the dashboard widget throws the following warnings:

    Warning: A non-numeric value encountered in /www/htdocs/mywebsite/wp-content/plugins/ninjafirewall/lib/dashboard_widget.php on line 42
    
    Warning: A non-numeric value encountered in /www/htdocs/mywebsite/wp-content/plugins/ninjafirewall/lib/dashboard_widget.php on line 45

    The warnings are above the “Blocked threats”, which are specified here with 1695. But in the statistics section they are specified with 34645. Maybe this is the problem?

    Cheers,
    Matthias

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author nintechnet

    (@nintechnet)

    Hi,

    Can you paste here the content of your /wp-content/nfwlog/stats_2018-04.php file?

    Thread Starter Matthias Pabst

    (@matthiaspabst)

    Sure.

    :2194:1709:::::::

    Plugin Author nintechnet

    (@nintechnet)

    I don’t get any PHP error, it’s working as expected:

    Blocked threats 3903
    Critical: 0%
    High: 43.79%
    Medium: 56.21%

    Which version of PHP are you running?

    Thread Starter Matthias Pabst

    (@matthiaspabst)

    But the calculation of the dashboard widget is wrong. See the stats in these screenshots: https://cloudup.com/cYbs0l1AiKw
    Current content of stats_2018-04.php: :2267:2143:::::::

    PHP 7.1.11

    Plugin Author nintechnet

    (@nintechnet)

    Regarding the 2 error messages, can you try to edit the “dashboard_widget.php”?

    Locate line 41 :

    list($tmp, $medium, $high, $critical, $tmp, $upload, $tmp, $tmp, $tmp, $tmp) = explode(':', $nfw_stat . ':');
    

    Right below, add those 4 lines of code:

       $medium = (int) $medium;
       $high = (int) $high;
       $critical = (int) $critical;
       $upload = (int) $upload;
    

    Regarding the stats, the numbers look odd, but the widget relies on the /wp-content/nfwlog/stats_xxxxx.php files, while the stats page relies on the firewall logs (/wp-content/nfwlog/firewall_xxxxx.php).
    If a user deletes the log, the stats_xxxxx.php will not be deleted, and thus numbers will be different. But in that case, I would expect the widget to display higher numbers than the stats page. Yours show the contrary.

    Thread Starter Matthias Pabst

    (@matthiaspabst)

    This resolves the warning in the dashboard widget.

    But the numbers still look odd.
    Dashboard widget: 550
    Stats page: 42385
    I didn’t delete any logs.

    Plugin Author nintechnet

    (@nintechnet)

    I cannot reproduce the warning. I tried with PHP 5.3, 5.6, 7 and 7.2.
    But I will add the code to NF anyway, just in case.

    Regarding the numbers, maybe your stats_xxxxx.php was deleted/corrupted and a new one created?
    In the next release, we will use the stats_xxxxx.php for both the widget and the “Satistics” page. The reason is because of the GDPR, we have many European customers who will likely use the new “Auto-delete log” option and that will affect the “Satistics” page as it relies on the firewall log (firewall_xxxxx.php).

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘A non-numeric value encountered’ is closed to new replies.