first download country arrays script from HERE and place it in the same directory where you put this code:
<?php
$db_host = "localhost";
$db_user = "username";
$db_pass = "password";
$db_name = "database";
$dbc = mysql_connect($db_host, $db_user, $db_pass);
$dbs = mysql_select_db($db_name);
$_dez_ip=getdezIP();
$q = mysql_query("SELECT `cc`, `network` FROM `mobile_carrier` WHERE `num_min` <= '".$_dez_ip."' ORDER BY `num_min` DESC, `num_max` ASC LIMIT 1") or die("MySQL Error: ".mysql_error());
$info = mysql_fetch_array($q);
mysql_close();
$cc=$info[0];
echo 'Network: '.$info[1]; // Mobile network
echo 'Country code: '.$cc; // Country code
include("countries.php"); /* Include the country arrays to convert country code to country name */
echo 'Country: '.$countries[$cc];
/* you can also download famfamfam flag icons from
[url=http://www.famfamfam.com/lab/icons/flags/]famfamfam.com: Flag Icons[/url]
to show the country flag */
// echo 'Country flag : [img]flags/'.strtolower($cc).'.gif[/img]';
function getdezIP(){
$IP = "";
if (isSet($_SERVER)) {
if (isSet($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$IP = $_SERVER["HTTP_X_FORWARDED_FOR"];
} elseif (isSet($_SERVER["HTTP_CLIENT_IP"])) {
$IP = $_SERVER["HTTP_CLIENT_IP"];
} else {
$IP = $_SERVER["REMOTE_ADDR"];
}
} else {
if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {
$IP = getenv( 'HTTP_X_FORWARDED_FOR' );
} elseif ( getenv( 'HTTP_CLIENT_IP' ) ) {
$IP = getenv( 'HTTP_CLIENT_IP' );
} else {
$IP = getenv( 'REMOTE_ADDR' );
}
}
if (strstr($IP, ',')) {
$ips = explode(',', $IP);
$IP = $ips[0];
}
if(empty($IP)) $IP=$_SERVER["REMOTE_ADDR"];
else if(strtolower(trim($IP))=='unknown') $IP=$_SERVER["REMOTE_ADDR"];
$numbers = preg_split( "/\./", $IP);
$dezip=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);
return $dezip;
}
?>
i will update the database dumb as often as i can...
if the code on above does not work properly with some of your users and you want to help this project please link to us like this: ... or ...
put after ref= your sites url without http:// , we dont want to steal your users we just want to get as many mobile networks to our database as we can, thanks.
thanks gum it will help alot for my new script on which m working External image (may be gone) can u pls share script which tells phone number n operator of a user?
thanks gum it will help alot for my new script on which m working External image (may be gone) can u pls share script which tells phone number n operator of a user?
You cant get the phone number...
Download the latest db dumb to detect the operator.
first download country arrays script from HERE and place it in the same directory where you put this code:
<?php
$db_host = "localhost";
$db_user = "username";
$db_pass = "password";
$db_name = "database";
$dbc = mysql_connect($db_host, $db_user, $db_pass);
$dbs = mysql_select_db($db_name);
$_dez_ip=getdezIP();
$q = mysql_query("SELECT `cc`, `network` FROM `mobile_carrier` WHERE `num_min` <= '".$_dez_ip."' ORDER BY `num_min` DESC, `num_max` ASC LIMIT 1") or die("MySQL Error: ".mysql_error());
$info = mysql_fetch_array($q);
mysql_close();
$cc=$info[0];
echo 'Network: '.$info[1]; // Mobile network
echo 'Country code: '.$cc; // Country code
include("countries.php"); /* Include the country arrays to convert country code to country name */
echo 'Country: '.$countries[$cc];
/* you can also download famfamfam flag icons from
http://www.famfamfam.com/lab/icons/flags/
to show the country flag */
// echo 'Country flag : flags/'.strtolower($cc).'.gif';
function getdezIP(){
$IP = "";
if (isSet($_SERVER)) {
if (isSet($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$IP = $_SERVER["HTTP_X_FORWARDED_FOR"];
} elseif (isSet($_SERVER["HTTP_CLIENT_IP"])) {
$IP = $_SERVER["HTTP_CLIENT_IP"];
} else {
$IP = $_SERVER["REMOTE_ADDR"];
}
} else {
if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {
$IP = getenv( 'HTTP_X_FORWARDED_FOR' );
} elseif ( getenv( 'HTTP_CLIENT_IP' ) ) {
$IP = getenv( 'HTTP_CLIENT_IP' );
} else {
$IP = getenv( 'REMOTE_ADDR' );
}
}
if (strstr($IP, ',')) {
$ips = explode(',', $IP);
$IP = $ips[0];
}
if(empty($IP)) $IP=$_SERVER["REMOTE_ADDR"];
else if(strtolower(trim($IP))=='unknown') $IP=$_SERVER["REMOTE_ADDR"];
$numbers = preg_split( "/\./", $IP);
$dezip=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);
return $dezip;
}
?>
i will update the database dumb as often as i can...
if the code on above does not work properly with some of your users and you want to help this project please link to us like this: http://2wap.org/mobile_carrier.php?ref=besttop.mobi or http://2wap.org/mobile_carrier.php?ref=xchanger.mobi
put after ref= your sites url without http:// , we dont want to steal your users we just want to get as many mobile networks to our database as we can, thanks.
ITS WORKING BRO.ThankZ How can i add a country flag to this script