Country Detecter Script Help

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

    #16
    jussst wait im working on that, i'll try to post the codes to make it work on lavalair's script. and also codes to ban the whole country!!

    Comment


      #17
      Here is another ip to country without database script:
      http://www.phptutorial.info/iptocountry/the_script.html

      and here is a function how to use it:

      for iso county code
      Code:
      function iptocountry($ip) {
          $numbers = preg_split( "/\./", $ip);
          include("ip_files/".$numbers[0].".php");
          $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);
          foreach($ranges as $key => $value){
              if($key<=$code){
                  if($ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;}
                  }
          }
          if ($two_letter_country_code==""){$two_letter_country_code="unkown";}
          return $two_letter_country_code;
      }
      for country name:

      Code:
       
      function country_name($two_letter_country_code)
          {
           include("ip_files/countries.php");
          $country_name=$countries[$two_letter_country_code][0];
         return $country_name;
          }
      usage:
      Code:
      $two_letter_country_code=iptocountry($_SERVER[&#39;REMOTE_ADDR&#39;]);
      echo &#39;County flag: &#39;.country_name($two_letter_country_code);

      to show the country flag:
      Code:
           function show_flag($two_letter_country_code)
            {
           $file_to_check=&#39;./ip_flags/&#39;.strtolower($two_letter_country_code).&#39;.gif&#39;;
           if (file_exists($file_to_check)){
                      $FLAG= &#39;[img]&#39;.$file_to_check.&#39;[/img]&#39;;
                      }else{
                      $FLAG= &#39;[img]./ip_flags/noflag.gif[/img]&#39;;
                      }
             return $FLAG;
             }
      usage:
      Code:
      $two_letter_country_code=iptocountry($_SERVER[&#39;REMOTE_ADDR&#39;]);
      echo &#39;County flag: &#39;.show_flag($two_letter_country_code);
      and to ban someone you can use this example:
      Code:
      $two_letter_country_code=iptocountry($_SERVER[&#39;REMOTE_ADDR&#39;]);
      ///ZA- South africa; DE -Germany///////
      if($two_letter_country_code==&#39;ZA&#39; || $two_letter_country_code==&#39;DE&#39;){
      echo &#39;<?xml version="1.0"?>
      <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
      <wml>
        <card>
          
      
      
            We do not provide any services for your country.
          </p>
        </card>
      </wml>&#39;;
      exit;
      }
      Advertise your mobile site for FREE with AdTwirl

      Comment


        #18
        Here is another ip to country without database script:
        http://www.phptutorial.info/iptocountry/the_script.html

        and here is a function how to use it:

        for iso county code
        Code:
        function iptocountry($ip) {
            $numbers = preg_split( "/\./", $ip);
            include("ip_files/".$numbers[0].".php");
            $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);
            foreach($ranges as $key => $value){
                if($key<=$code){
                    if($ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;}
                    }
            }
            if ($two_letter_country_code==""){$two_letter_country_code="unkown";}
            return $two_letter_country_code;
        }



        for country name:

        Code:
         
        function country_name($two_letter_country_code)
            {
             include("ip_files/countries.php");
            $country_name=$countries[$two_letter_country_code][0];
           return $country_name;
            }
        usage:
        Code:
        $two_letter_country_code=iptocountry($_SERVER[&#39;REMOTE_ADDR&#39;]);
        echo &#39;County flag: &#39;.country_name($two_letter_country_code);
        to show the country flag:
        Code:
             function show_flag($two_letter_country_code)
              {
             $file_to_check=&#39;./ip_flags/&#39;.strtolower($two_letter_country_code).&#39;.gif&#39;;
             if (file_exists($file_to_check)){
                        $FLAG= &#39;[img]&#39;.$file_to_check.&#39;[/img]&#39;;
                        }else{
                        $FLAG= &#39;[img]./ip_flags/noflag.gif[/img]&#39;;
                        }
               return $FLAG;
               }
        usage:
        Code:
        $two_letter_country_code=iptocountry($_SERVER[&#39;REMOTE_ADDR&#39;]);
        echo &#39;County flag: &#39;.show_flag($two_letter_country_code);
        and to ban someone you can use this example:
        Code:
        $two_letter_country_code=iptocountry($_SERVER[&#39;REMOTE_ADDR&#39;]);
        ///ZA- South africa; DE -Germany///////
        if($two_letter_country_code==&#39;ZA&#39; || $two_letter_country_code==&#39;DE&#39;){
        echo &#39;<?xml version="1.0"?>
        <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
        <wml>
          <card>
            
        
        
              We do not provide any services for your country.
            </p>
          </card>
        </wml>&#39;;
        exit;
        }
        [/b]


        many thanks to Gum,


        1 more question,how can i reserve one user&#39;s $two_letter_country_code data in that user&#39;s profile to show that user&#39;s $two_letter_country_code to all user,i mean wt will b mysql table to save n show $two_letter_country_code to all users?

        Comment


          #19
          many thanks to Gum,
          1 more question,how can i reserve one user&#39;s $two_letter_country_code data in that user&#39;s profile to show that user&#39;s $two_letter_country_code to all user,i mean wt will b mysql table to save n show $two_letter_country_code to all users?[/b]
          Hmmm, i dont realy understand what do you mean, and i dont know which mysql tables are you using
          so here is very simple example:
          you have to add the country row to your users table
          Code:
          UPDATE `users` SET `country`=&#39;".$two_letter_country_code."&#39; WHERE id=&#39;".$user_id."&#39;
          and to select users (South africans)

          Code:
          SELECT * FROM `users` WHERE `country`=&#39;ZA&#39; LIMIT 0, 10
          Advertise your mobile site for FREE with AdTwirl

          Comment


            #20
            I use database to detect country in main page... and in my portal i made a script which doesnt uses databse... My script also detect users network

            Comment


              #21
              many thanks to Gum,
              1 more question,how can i reserve one user&#39;s $two_letter_country_code data in that user&#39;s profile to show that user&#39;s $two_letter_country_code to all user,i mean wt will b mysql table to save n show $two_letter_country_code to all users?[/b]

              Well yea there is a simple way of doing this in a user friendly way... That is not displaying country code to other users as 2 letter code, instead show it as full name of country...
              As Gumslone suggested, this can be made easy if ur ip2country database has a separate column which displays country&#39;s name as a a whole... If so its a matter of getting value from approapriate column and inserting that data into users profile in ur database...

              Comment


                #22
                ooh man check this http://ip2location.com, it shows my country, state and the city. and my connection through... i want the codes to show the state and city. does anyone have it?

                Comment


                  #23
                  ooh man check this http://ip2location.com, it shows my country, state and the city. and my connection through... i want the codes to show the state and city. does anyone have it?[/b]
                  it would not work with mobile phone users only with pc users also you have to pay for this service and its also does not show correct information as for me.
                  Advertise your mobile site for FREE with AdTwirl

                  Comment


                    #24
                    Hmmm, i dont realy understand what do you mean, and i dont know which mysql tables are you using
                    so here is very simple example:
                    you have to add the country row to your users table
                    Code:
                    UPDATE `users` SET `country`=&#39;".$two_letter_country_code."&#39; WHERE id=&#39;".$user_id."&#39;
                    and to select users (South africans)

                    Code:
                    SELECT * FROM `users` WHERE `country`=&#39;ZA&#39; LIMIT 0, 10
                    [/b]
                    well im using lavalair wml script


                    here is user sql table

                    --
                    -- Table structure for table `ibwf_users`
                    --

                    CREATE TABLE `ibwf_users` (
                    `id` int(100) NOT NULL auto_increment,
                    `name` varchar(30) NOT NULL default &#39;&#39;,
                    `pass` varchar(60) NOT NULL default &#39;&#39;,
                    `birthday` varchar(50) NOT NULL default &#39;&#39;,
                    `sex` char(1) NOT NULL default &#39;&#39;,
                    `location` varchar(100) NOT NULL default &#39;&#39;,
                    `perm` char(1) NOT NULL default &#39;0&#39;,
                    `posts` int(100) NOT NULL default &#39;0&#39;,
                    `plusses` int(100) NOT NULL default &#39;0&#39;,
                    `signature` varchar(100) NOT NULL default &#39;&#39;,
                    `avatar` varchar(100) NOT NULL default &#39;&#39;,
                    `email` varchar(50) NOT NULL default &#39;&#39;,
                    `site` varchar(50) NOT NULL default &#39;&#39;,
                    `browserm` varchar(50) NOT NULL default &#39;&#39;,
                    `ipadd` varchar(30) NOT NULL default &#39;&#39;,
                    `lastact` int(100) NOT NULL default &#39;0&#39;,
                    `regdate` int(100) NOT NULL default &#39;0&#39;,
                    `chmsgs` int(100) NOT NULL default &#39;0&#39;,
                    `chmood` int(100) NOT NULL default &#39;0&#39;,
                    `shield` char(1) NOT NULL default &#39;0&#39;,
                    `gplus` int(100) NOT NULL default &#39;0&#39;,
                    `budmsg` varchar(100) NOT NULL default &#39;&#39;,
                    `lastpnreas` varchar(100) NOT NULL default &#39;&#39;,
                    `lastplreas` varchar(100) NOT NULL default &#39;&#39;,
                    `shouts` int(100) NOT NULL default &#39;0&#39;,
                    `pollid` int(100) NOT NULL default &#39;0&#39;,
                    `rbcid` varchar(255) NOT NULL default &#39;&#39;,
                    `hvia` char(1) NOT NULL default &#39;1&#39;,
                    `lastvst` int(100) NOT NULL default &#39;0&#39;,
                    `battlep` int(100) NOT NULL default &#39;0&#39;,
                    PRIMARY KEY (`id`),
                    UNIQUE KEY `name` (`name`),
                    KEY `id` (`id`)
                    ) TYPE=MyISAM AUTO_INCREMENT=1 ;

                    --
                    -- Dumping data for table `ibwf_users`
                    --
                    and
                    [attachment=1261:index.php]
                    [attachment=1260:core.php]




                    i want to show in users profile like this



                    More Information

                    Send PM

                    add to buddy list



                    Member&#39;s ID:
                    Status: Vinyl Shaker
                    A/S/L: 18/Male/
                    IP country:South Africa Flag image
                    Topics: 9
                    Posts: 127/152
                    PMs IN: 26 - OUT: 52
                    Game Plusses: 93
                    Chat Posts: 22
                    Fun Points: 0
                    Shouts: 28/42
                    Joined rw: 02 07 07-17:23:51
                    Last Active: 07 10 07-18:20:37
                    Last Visit: 07 10 07-12:13:11
                    Browser: Opera
                    E-mail:
                    Signature:
                    Attached Files

                    Comment


                      #25
                      most of the country dedeceter scripts, doesnt detect my country from ip at all. it says unknown country. Where as this one showed exact location of me... and yeah its payable service

                      Comment


                        #26
                        most of the country dedeceter scripts, doesnt detect my country from ip at all. it says unknown country. Where as this one showed exact location of me... and yeah its payable service [/b]

                        Bro pls check country detector in my site and let me know if it doesnt detect ur country...

                        Comment


                          #27
                          it would not work with mobile phone users only with pc users also you have to pay for this service and its also does not show correct information as for me.[/b]

                          Agree with u Gums... U have to pay for the service and what it detects is the nearest exchange of your internet service provider. Which doesn&#39;t always be your hometown.. Similar scripts are used in many porn sites etc just to lure users ... But funny side of it is when it shows a city about 50-100 kms from your city... This happens coz most of the ip2loaction services only use ip to detect the location, and user ip may be interfered by many intermediates..

                          Comment


                            #28
                            hmmm i dont get this lol

                            Comment


                              #29
                              Bro pls check country detector in my site and let me know if it doesnt detect ur country...[/b]
                              oh yeah bro the country scrip on your site dedects my country. it also says im from south india. Which script are you using bro?

                              Comment


                                #30
                                well im using lavalair wml script
                                here is user sql table

                                --
                                -- Table structure for table `ibwf_users`
                                --

                                CREATE TABLE `ibwf_users` (
                                `id` int(100) NOT NULL auto_increment,
                                `name` varchar(30) NOT NULL default &#39;&#39;,
                                `pass` varchar(60) NOT NULL default &#39;&#39;,
                                `birthday` varchar(50) NOT NULL default &#39;&#39;,
                                `sex` char(1) NOT NULL default &#39;&#39;,
                                `location` varchar(100) NOT NULL default &#39;&#39;,
                                `perm` char(1) NOT NULL default &#39;0&#39;,
                                `posts` int(100) NOT NULL default &#39;0&#39;,
                                `plusses` int(100) NOT NULL default &#39;0&#39;,
                                `signature` varchar(100) NOT NULL default &#39;&#39;,
                                `avatar` varchar(100) NOT NULL default &#39;&#39;,
                                `email` varchar(50) NOT NULL default &#39;&#39;,
                                `site` varchar(50) NOT NULL default &#39;&#39;,
                                `browserm` varchar(50) NOT NULL default &#39;&#39;,
                                `ipadd` varchar(30) NOT NULL default &#39;&#39;,
                                `lastact` int(100) NOT NULL default &#39;0&#39;,
                                `regdate` int(100) NOT NULL default &#39;0&#39;,
                                `chmsgs` int(100) NOT NULL default &#39;0&#39;,
                                `chmood` int(100) NOT NULL default &#39;0&#39;,
                                `shield` char(1) NOT NULL default &#39;0&#39;,
                                `gplus` int(100) NOT NULL default &#39;0&#39;,
                                `budmsg` varchar(100) NOT NULL default &#39;&#39;,
                                `lastpnreas` varchar(100) NOT NULL default &#39;&#39;,
                                `lastplreas` varchar(100) NOT NULL default &#39;&#39;,
                                `shouts` int(100) NOT NULL default &#39;0&#39;,
                                `pollid` int(100) NOT NULL default &#39;0&#39;,
                                `rbcid` varchar(255) NOT NULL default &#39;&#39;,
                                `hvia` char(1) NOT NULL default &#39;1&#39;,
                                `lastvst` int(100) NOT NULL default &#39;0&#39;,
                                `battlep` int(100) NOT NULL default &#39;0&#39;,
                                PRIMARY KEY (`id`),
                                UNIQUE KEY `name` (`name`),
                                KEY `id` (`id`)
                                ) TYPE=MyISAM AUTO_INCREMENT=1 ;

                                --
                                -- Dumping data for table `ibwf_users`
                                --
                                and
                                [attachment=1261:index.php]
                                [attachment=1260:core.php]
                                i want to show in users profile like this
                                More Information

                                Send PM

                                add to buddy list
                                Member&#39;s ID:
                                Status: Vinyl Shaker
                                A/S/L: 18/Male/
                                IP country:South Africa Flag image
                                Topics: 9
                                Posts: 127/152
                                PMs IN: 26 - OUT: 52
                                Game Plusses: 93
                                Chat Posts: 22
                                Fun Points: 0
                                Shouts: 28/42
                                Joined rw: 02 07 07-17:23:51
                                Last Active: 07 10 07-18:20:37
                                Last Visit: 07 10 07-12:13:11
                                Browser: Opera
                                E-mail:
                                Signature:[/b]

                                if ($IP_COUNTRY_FROM_SCRIPT_COUNTRY_DETECTOR == $IP_FROM_MY_USERS_DATABASE){echo "FKNG_FLAG"}
                                http://ngeo.ro

                                Comment

                                Working...
                                X