How Can I Show Users Country And Isp Name In My Wap Site>>?
Started on the old forum in August 2008 · view the original in the archive · old links redirect here
TL;DR · summary of 12 replies
- - The code provided in the thread does not work as expected due to missing vital files like IpToCountry.csv, ip_flags directory.
- - A solution was proposed by wolf77ar, including a new row for country in the ibwf_users table and modifying SQL queries. However, it is noted that the database might still have issues showing correct information.
- - The thread mentions a demo site at which uses the code successfully, but some users reported incorrect country data from Gumslone's database.
- - rukiya provided an updated solution with reduced database size to 468MB, suggesting that the issue might be related to the database itself.
Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.
try this :
<?php
// Get the surfer's ip address
$addr = $usip;
echo "Your IP, IPv4: " . $addr . "
\n";
$ip = sprintf("%010u", ip2long($addr));
echo "Your IP, numerical: " . $ip . "
\n";
// Initiate the timer
$time_start = microtime_float();
// Open the csv file for reading
$handle = fopen("IpToCountry.csv", "r");
// Load array with start ips
$row = 1;
while (($buffer = fgets($handle, 4096)) !== FALSE) {
$array[$row] = $buffer;
$row++;
}
// Time loading
$time_end = microtime_float();
$time = substr($time_end - $time_start, 0, 7);
//echo "Array with " . $row . " start ips loaded in $time seconds
\n";
// Locate the row with our ip using bisection
$row_lower = '0';
$row_upper = $row;
while (($row_upper - $row_lower) > 1) {
$row_midpt = (int) (($row_upper + $row_lower) / 2);
$buffer = $array[$row_midpt];
$start_ip = sprintf("%010u", substr($buffer, 1, strpos($buffer, ",") - 1));
if ($ip >= $start_ip) {
$row_lower = $row_midpt;
} else {
$row_upper = $row_midpt;
}
}
// Time locating
$time_end = microtime_float();
$time = substr($time_end - $time_start, 0, 7);
//echo "Row with your ip (# " . $row_lower . ") located after $time seconds
\n";
// Read the row with our ip
$buffer = $array[$row_lower];
$buffer = str_replace("\"", "", $buffer);
$ipdata = explode(",", $buffer);
//echo "Data retrieved from the csv file:
\n";
//echo "ipstart = " . sprintf("%010u", $ipdata[0]) . "
\n";
//echo "ipend = " . sprintf("%010u", $ipdata[1]) . "
\n";
//echo "registry = " . $ipdata[2] . "
\n";
//echo "assigned = " . date('j.n.Y', $ipdata[3]) . "
\n";
//echo "iso2 = " . $ipdata[4] . "
\n";
//echo "iso3 = " . $ipdata[5] . "
\n";
echo "country : " . $ipdata[6] . "
\n";
echo 'Country flag : [img]ip_flags/'.($ipdata[4]).'.gif[/img]
';
// Close the csv file
fclose($handle);
// Total execution time
$time_end = microtime_float();
$time = substr($time_end - $time_start, 0, 7);
//echo "Executing the whole script took $time seconds\n";
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
?>
if like my post click:
But it does not work..please give me another tips...
this code is not working because the vital files are missing like IpToCountry.csv ,ip_flags dir
Here is IpToCountry.csv in zip arhive:
And here all countrys flags:
And original code:
its work whith: CODEinclude("iptest.php"); Where you want to show
echo "<a href="http://wapcomunity.ro">[-Enter Here-]</a>";
how to add in lava user pro any working coding anyone got?
Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!
how to add in lava user pro any working coding anyone got?
This code work well in index.php welcome page whith include file
If you want to add this in profile user you need to add 1 new row in ibwf_users table
example:
country varchar(120) NOT NULL default '',
and
To put entire code from iptest.php in User profile or you can add new function in core.php like:
function country()
{
php code
}
and called whith:
echo country($sid);
and
SQL insert
Modify this line from index.php is in top of main page
$res = mysql_query("UPDATE ibwf_users SET browserm='".$ubr."', ipadd='".$uip."' WHERE id='".getuid_sid($sid)."'");
whith
$res = mysql_query("UPDATE ibwf_users SET browserm='".$ubr."', ipadd='".$uip."', country='". $ipdata[6] ."' WHERE id='".getuid_sid($sid)."'");
and finnaly you can add in user profile to show user country from database:
$user_country = mysql_fetch_array(mysql_query("SELECT country FROM ibwf_users WHERE id='".$who."'"));
echo "- Country: $user_country[0]
";
Someting like this I dont know, i`m not testing in my script Is just 1 ideea
echo "<a href="http://wapcomunity.ro">[-Enter Here-]</a>";
I added this usage a year's ago
demo http://bdfun.co.cc/wap http://bdfun.uni.cc/web and a new usage of flag in the chatroom http://bdfun.uni.cc/chat
I added this usage a year's ago
demo http://bdfun.co.cc/wap http://bdfun.uni.cc/web and a new usage of flag in the chatroom http://bdfun.uni.cc/chat
it surely doesnt work correct.. as it shows im from palestina?? eventhough im from slovenia 😉
It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.
キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!
it surely doesnt work correct.. as it shows im from palestina?? eventhough im from slovenia ;)
Yep I know that and thats not my fault thats gumslone's database's fault and read my post here http://www.2wap.org/forums/index.php?showt...sttop&st=30
and check your country from http://bdfun.uni.cc bdfun.uni.cc/web
I have correct ISP database from ip2location.com but its over 350mb
anyone have the codes for ore? i tried but it not work
Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!
Yep I know that and thats not my fault thats gumslone's database's fault and read my post here http://www.2wap.org/forums/index.php?showt...sttop&st=30
and check your country from http://bdfun.uni.cc bdfun.uni.cc/web
I have correct ISP database from ip2location.com but its over 350mb
http://bdfun.uni.cc <<== yep here works ok 😉 over 350MB ?? huh.. means i can load database and almost no free space left lmao
It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.
キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!
http://bdfun.uni.cc <<== yep here works ok 😉 over 350MB ?? huh.. means i can load database and almost no free space left lmao
actually the real database was 468mb.I reduced some keeping the ip range,country code and ISP
Showing rows 0 - 29 (2,075,699 total, Query took 0.0011 sec)
SQL query:
SELECT *
FROM `ip2loc`
LIMIT 0 , 30
[ Edit ] [ Explain SQL ] [ Create PHP Code ] [ Refresh ]
Query results operations
Print view Print view (with full texts) Export
row(s) starting from record #
in mode and repeat headers after cells Page number:
Sort by key: ipFROM ipTO countrySHORT ipISP
0000000000 0033996343 - -
0033996352 0050331647 - -
0050331904 0050332671 US GENERAL ELECTRIC COMPANY
0050332928 0050333695 US GENERAL ELECTRIC COMPANY
0050333952 0050334719 US GENERAL ELECTRIC COMPANY
0050334976 0050335487 US GENERAL ELECTRIC COMPANY
0050335744 0050358271 US GENERAL ELECTRIC COMPANY
0050358528 0050361855 US GENERAL ELECTRIC COMPANY
0050362112 0050390527 US GENERAL ELECTRIC COMPANY
0050390784 0050397183 US GENERAL ELECTRIC COMPANY
0050397952 0050398207 US GENERAL ELECTRIC COMPANY
0050398464 0050398719 US GENERAL ELECTRIC COMPANY
0050398976 0050399231 US GENERAL ELECTRIC COMPANY
0050399488 0050399743 US GENERAL ELECTRIC COMPANY
0050400000 0050400255 US GENERAL ELECTRIC COMPANY
0050400512 0050400767 US GENERAL ELECTRIC COMPANY
0050401024 0050401279 US GENERAL ELECTRIC COMPANY
0050401536 0050405631 US GENERAL ELECTRIC COMPANY
0050405888 0050411263 US GENERAL ELECTRIC COMPANY
0050411520 0050414079 US GENERAL ELECTRIC COMPANY
0050414336 0050432255 US GENERAL ELECTRIC COMPANY
0050432512 0050448639 US GENERAL ELECTRIC COMPANY
0050448896 0050457087 US GENERAL ELECTRIC COMPANY
0050457344 0050463487 US GENERAL ELECTRIC COMPANY
0050463744 0050490367 US GENERAL ELECTRIC COMPANY
0050490624 0050497023 US GENERAL ELECTRIC COMPANY
0050497280 0050511359 US GENERAL ELECTRIC COMPANY
0050511616 0050528255 US GENERAL ELECTRIC COMPANY
0050528512 0050528767 US GENERAL ELECTRIC COMPANY
0050529024 0050530303 US GENERAL ELECTRIC COMPA
1st 30 record of Bangladesh
Showing rows 0 - 29 (214 total, Query took 0.4284 sec)
SQL query:
SELECT *
FROM `ip2loc`
WHERE countryshort = 'bd'
LIMIT 0 , 30
[ Edit ] [ Explain SQL ] [ Create PHP Code ] [ Refresh ]
Query results operations
Print view Print view (with full texts) Export
row(s) starting from record #
in mode and repeat headers after cells Page number:
Sort by key: ipFROM ipTO countrySHORT ipISP
1025630048 1025630079 BD LEEHYUNGWOO4023416D
1025630144 1025630175 BD CHOI MYEONG HYEON
1025756992 1025757055 BD CYBERNET4039198D
1025996736 1025996799 BD GU DUK YON
1046350848 1046351103 BD EDISONTEL S.P.A
1072932608 1072932863 BD AGNI SYSTEM LTD
1072933888 1072934143 BD BIJOY ONLINE LTD
1079383808 1079384063 BD GDXC INC
1103116032 1103116287 BD UUNET TECHNOLOGIES INC
1158517427 1158517435 BD PRIVATE CUSTOMER - CI HOST
1163395848 1163395863 BD SKYNET SERVICES POP
1163395872 1163395879 BD DRUTI NETWORKS POP
1163395888 1163395895 BD GLOBAL TECHNOLOGIES
1163395904 1163395911 BD BTS COMMUNICATION
1163395936 1163395943 BD SIRIUS BROADBAND - ROYALTEN DOT NET
1163395952 1163395959 BD SKYNET SERVICES
1163396024 1163396031 BD BANGLASAT COM - POP
1163396040 1163396047 BD SKYNET SERVICES POP
1163396152 1163396159 BD BANGLASAT COMMUNICATIONS
1163396168 1163396175 BD AGNI SYSTEMS
1163396344 1163396351 BD DHAKA COM
1163396368 1163396375 BD MAXLEAD LTD
1163396400 1163396431 BD AKIJ ONLINE
1163396456 1163396463 BD BTS COMMUNICATION
1163396656 1163396671 BD GLOBAL TECHNOLOGIES DVB
1163396688 1163396719 BD AKIJ ONLINE DVB
1163396736 1163396767 BD ASIATEL NETWORK LTD
1163396800 1163396831 BD SKYNET SERVICES
1163396864 1163396895 BD TECHNO ONLINE LTD
1163396928 1163396959 BD DRUTI NETWORKS POP