Mod_serverstat.php division by zero fix

Attention: open in a new window. PDFPrintE-mail

( 3 Votes )

I noticed in AWStats, someone came to our website looking for "mod_serverstat.php division by zero fix". This error was being displayed briefly (and unfortunately at the time particular pages were being first indexed) and was being caused by a Joomla! module that we had installed by the name of Serverstat.

Since someone out there appears to want to know how to fix it and because I've found a work around, I figured I'd share the information. This fix has worked on our site monitoring the Ventrilo server since the beginning.

 

The full error is as follows: "Warning: Division by zero in /path/to/joomla/modules/mod_serverstat.php on line 172".

The division error was being caused by the modulus operator on line 72 which looks like this:
if ($row->tcounter > $serverstat_threshold && ($row->views % $serverstat_threshold !=0) && $serverstat_threshold !=0) {

We can fix this by either A):
changing line 172 to read
if ($row->tcounter > $serverstat_threshold && $serverstat_threshold !=0) {

which eliminates some of the error checking in case the server's status is unknown (i.e. not definitively up or down)

or B) adding a row to the table jos_serverstat_servers a.k.a. #_serverstat_servers.

Note: I suppose you could also just add the '@' symbol to the comparison as well to suppress the error but that's up to you.



Add this page to your favorite Social Bookmarking websites
Reddit! Del.icio.us! Mixx! Free and Open Source Software News Google! Live! Facebook! StumbleUpon! Yahoo! Joomla Free PHP
Comments
Add New Search RSS
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

SEO by Artio