PHP Classes

I've found some bugs in this class.

Recommend this page to a friend!

      Easy Hit Counter  >  All threads  >  I've found some bugs in this class.  >  (Un) Subscribe thread alerts  
Subject:I've found some bugs in this class.
Summary:Package rating comment
Messages:2
Author:Artur Graniszewski
Date:2010-10-29 11:00:09
Update:2010-10-29 15:57:40
 

Artur Graniszewski rated this package as follows:

Utility: Insufficient
Consistency: Good
Examples: Sufficient

  1. I've found some bugs in this class.   Reply   Report abuse  
Picture of Artur Graniszewski Artur Graniszewski - 2010-10-29 11:00:09
I've found some bugs in this class.

1) There is a logic error in getIp() method:
private function getIP()
{
if (isset($_SERVER['REMOTE_ADDR'])) {
return $_SERVER['REMOTE_ADDR'];
} else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
} else ...
}

This kind of condition will always return $_SERVER['REMOTE_ADDR'] because this variable is always set by the HTTP server. Every line of code below this one will not be executed... ever!

2) The list of IP's is stored in a local file. Because of that you have to use flock() mechanism. Without file locking your storage file will become corrupted during a heavy user traffic (see definition of "race condition").

3) Don't use @ to surpress errors and warnings. Check status of fopen, and other file functions instead. Using @ to hide possible errors can seriously harm entire site performance.

  2. Re: I've found some bugs in this class.   Reply   Report abuse  
Picture of Alberto Alberto - 2010-10-29 15:57:40 - In reply to message 1 from Artur Graniszewski
So can this class can be fixed?? can u do it dude? because i wanna use it on my web, and how can i add to this class for in my web appers Total visitor of today and the total visitors of the day before like this:

Visitor Before today: 4522
Visitors Today: 800

?????????