besstop.mobi mobile_carrier mysql dumb

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    besstop.mobi mobile_carrier mysql dumb

    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

    + added the gurfl csv from _http://www.whirlymobile.com/resources/gurfl/operator.csv

    + added the ip/network database by ori

    View File

    /tease.gif" style="vertical-align:middle" emoid="" 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


    #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:

    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

    Comment


      #3
      mine is lil different but heres the ranges i hav compiled
      Attached Files

      Comment


        #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"];
        }
        }
        }

        Comment


          #5
          thank you very much gumslone

          Comment


            #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

            Comment


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

              Comment


                #8
                mine is lil different but heres the ranges i hav compiled[/b]
                If you dont mind may i add your database to mine?
                Advertise your mobile site for FREE with AdTwirl

                Comment


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

                  Comment


                    #10
                    Network: Country code:
                    Parse error: syntax error, unexpected T_STRING, expecting &#39;)&#39; 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

                    Comment


                      #11
                      Network: Country code:
                      Parse error: syntax error, unexpected T_STRING, expecting &#39;)&#39; 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[/b]
                      Please download the countries script again, i have updated it
                      Advertise your mobile site for FREE with AdTwirl

                      Comment


                        #12
                        Network: Country code:
                        Parse error: syntax error, unexpected T_STRING, expecting &#39;)&#39; 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[/b]
                        Line 125
                        &#39;KP&#39; => &#39;Korea, Democratic People&#39;s Republic of&#39;,

                        it gives error becoz of that single qoute in People&#39;s. Remove all the country name that has a qoute.

                        Comment


                          #13
                          Please download the countries script again, i have updated it[/b]

                          Line 125
                          &#39;KP&#39; => &#39;Korea, Democratic People&#39;s Republic of&#39;,

                          it gives error becoz of that single qoute in People&#39;s. Remove all the country name that has a qoute.[/b]
                          thanks i downloaded the file again.. ill try it now

                          Comment


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

                            Comment


                              #15
                              its not working, all i get is blank details. maybe the DB must be updated[/b]
                              i thought it was just my host having problem. coz im always get an request timed out when i upload sql files. lolz..

                              Comment

                              Working...
                              X