besstop.mobi mobile_carrier mysql dumb

Started on the old forum in November 2007 · view the original in the archive · old links redirect here

41 replies · 7,212 views · started 19 years ago · 1 min read

TL;DR · summary of 41 replies
  • Line 125 'KP' => 'Korea, Democratic People's Republic of', in the database file may cause a syntax error.
  • The script needs to be updated with the latest database file to resolve issues related to country names containing quotes.
  • Adding support for showing phone numbers and operator information is not directly supported by this script.
  • Using Opera browser or proxy settings might affect the accuracy of detecting user's location.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

12 participants
GumSlone Administrator Principal · 1,690 posts #1

besstop.mobi mobile_carrier mysql dumb

Version: 1.0.0 Category: Other useful scripts

Description: ip to country and mobile network Here is a mysql dumb file with ips/countries/mobile networks i collected at besttop.mobi

View File

/tease.gif" style="vertical-align:middle" emoid="8P" border="0" alt="tease.gif" />t;line-height:100%">Submitted by GumSlone, on Nov 10 2007, 01:59 AM

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

GumSlone Administrator Principal · 1,690 posts #2

Here is a php code how to use the database:

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.

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

ori Lead · 512 posts #3

mine is lil different but heres the ranges i hav compiled

Attachments: network.txt
ori Lead · 512 posts #4

function ip() { if($_SERVER["REMOTE_ADDR"]){$ip=$_SERVER["REMOTE_ADDR"];} else{$ip=$_SERVER["HTTP_X_FORWARDED_FOR"];} if(strpos($ip,",")){ $exp_ip=explode(",",$ip); $ip=$exp_ip[0]; } return $ip; }

function ipinrange($ip, $range1, $range2) { $ip=ip2long($ip); $range1=ip2long($range1); $range2=ip2long($range2); return (($ip >= $range1) && ($ip <= $range2)); }

function network($ip) { $result=mysql_query("SELECT * FROM network ORDER BY subone, subtwo"); while($ranges=mysql_fetch_array($result)){ if(ipinrange($ip, $ranges[1], $ranges[2])){ return $ranges["isp"]." ".$ranges["country"]; } } }

Guest #5

thank you very much gumslone

modfiles Developer · 200 posts #6

its odd, they are not showing the result to me. its all blank..

Network: Country code: Country: Country flag :

What could be the problem? heres the check this

Guest #7

try it from your phone.. i didnt try it yet i will try it now nd reply back

GumSlone Administrator Principal · 1,690 posts #8

mine is lil different but heres the ranges i hav compiled

If you dont mind may i add your database to mine?

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

ori Lead · 512 posts #9

yeh thats y i uploaded it lol im doing my site til every user is covered 1 by 1...

Guest #10

Network: Country code: Parse error: syntax error, unexpected T_STRING, expecting ')' in /home/user/public_html/ip1/countries.php on line 125

this is the error i got! trying to find out the prob.. Cos there is no prob on line 125

GumSlone Administrator Principal · 1,690 posts #11

Network: Country code: Parse error: syntax error, unexpected T_STRING, expecting ')' in /home/user/public_html/ip1/countries.php on line 125

this is the error i got! trying to find out the prob.. Cos there is no prob on line 125

Please download the countries script again, i have updated it

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

modfiles Developer · 200 posts #12

Network: Country code: Parse error: syntax error, unexpected T_STRING, expecting ')' in /home/user/public_html/ip1/countries.php on line 125

this is the error i got! trying to find out the prob.. Cos there is no prob on line 125

Line 125 'KP' => 'Korea, Democratic People's Republic of',

it gives error becoz of that single qoute in People's. Remove all the country name that has a qoute.

Guest #13

Please download the countries script again, i have updated it

Line 125 'KP' => 'Korea, Democratic People's Republic of',

it gives error becoz of that single qoute in People's. Remove all the country name that has a qoute.

thanks i downloaded the file again.. ill try it now

Guest #14

its not working, all i get is blank details. maybe the DB must be updated

modfiles Developer · 200 posts #15

its not working, all i get is blank details. maybe the DB must be updated

i thought it was just my host having problem. coz im always get an request timed out when i upload sql files. lolz..

GumSlone Administrator Principal · 1,690 posts #18

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.

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

Guest #19

Here is a php code how to use the database:

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

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close