|
Aleksey - 2008-11-09 01:15:32
Well nice work, i used, but ...
What hapend if my IP do not exist in database?
Answer ... nothink :)
search($beg, $end) function [ from geoip.php ] go to deep recursion and shutdown by server.
Example:
#49 Country_One 12345 ... 23456
#50 Country_Two 34567 ... 45678
My IP int range = 25000 ..yes he is not exist in database range
he between #49 and #50 but array position put to search function agane and agane. And we got infinite loop of recursion with infinite approximation.
Ok stop talking and show code with my updates:
function search($beg, $end) {
......
else
if (($this->_longip > $arr_beg[3]) && ($this->_longip < $arr_mid[2]))
{
unset($arr_beg); unset($arr_mid); unset($arr_end);
//check close array elements positions
if(($beg + 1) == $end) return false;
return $this->search($beg, $mid);
}
else
if (($this->_longip > $arr_mid[3]) && ($this->_longip < $arr_end[2]))
{
unset($arr_beg); unset($arr_mid); unset($arr_end);
//check close array elements positions
if(($beg + 1) == $end) return false;
return $this->search($mid, $end);
}
else
{
.....
}//end function search
My update code is not beautifull, but fast and work ;)
Good luck
Marius Zadara - 2008-11-11 05:27:19 - In reply to message 1 from Aleksey
Hello.
If your IP is not in the database, is normal that the program will not find it since is not there. I don't see any bug in the program itself, but in the database. In this case, please download the latest demo version or subscribe to / buy the full one.
About the code, you may alter it without any problems, so if your updates suits the needs, go for it.
Thank you for your appreciation regarding the code.
Aleksey - 2008-12-27 10:54:11 - In reply to message 2 from Marius Zadara
For example testing your script with IP: 111.111.111.111
There no in database, case IpAddress2IpNumber = 1869573999
#35670----99.208.0.0,"99.255.255.255","1674575872","1677721599","CA","Canada"
#35671----112.63.162.116,"112.63.162.119","1883218548","1883218551","ES","Spain"
search() - function off to infinite loop
freeze between #35670 and #35671 db position
charlotdu13 - 2014-01-12 14:48:11 - In reply to message 2 from Marius Zadara
Hello
Even if it is not normal that the database has a bug, I think the program should provide it.
Thanks to Aleksey to his update code.
|