Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Ip to country

  1. #1
    Utente di HTML.it L'avatar di Ranma2
    Registrato dal
    Mar 2003
    Messaggi
    2,648

    Ip to country

    Come posso realizzare una cosa del genere?

    http://www.iptocountry.info/

    inserisco l'ip e mi da la sigla dello stato

  2. #2
    Codice PHP:
    function GetCountry($ip) {

        
    // open ip-to-country file, set correct address...
        
    if ( $file fopen("ip-to-country.csv","r") ) {

            
    // if successfully opened, read each line of the file
            
    while ( $line fgetcsv($file,1024,",") ) {

                
    // if our the ip corresponds, return the country name
                // $line[2] = country code 2 char,
                // $line[3] = country code 3 char, if needed...
                
    if ( ip2long($ip) > $line[0] && ip2long($ip) < $line[1] ) {
                    return 
    $line[4];
                }
            }
        }

        
    // if this ip has something wrong :?
        
    return false;
    }

    $country GetCountry($_SERVER['REMOTE_ADDR']);
    echo 
    "Your country is ".$country
    poi scaricati questo file
    http://ip-to-country.webhosting.info...ountry.csv.zip

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.