DevKB
Web Development Knowledge Base
HOME | TOP 20 | WRITE AN ARTICLE |
Sections :



RSS RSS Feed

You too, please publish your useful code snippets in any programming language :
write an article !


Valid HTML 4.0 Transitional

Plateforme d'envoi de gros fichiers en ligne
Dépannage site web
Blog infogérance
Hébergement e-mail

Olivier Ligny - - 19/08/2012 - vue 30725 fois

Détection du FAI de l'internaute en PHP

Voici un script qui permet de détecter, en PHP,  le fournisseur d'accès à Internet (FAI) de l'internaute qui visite la page.

Vous pouvez bien sûr modifier le script pour l'améliorer et supporter plus de FAIs.
N'hésitez pas à poster vos modifs en commentaire sur cette page !

function getCurrentIP() {
        $ip = (getenv(HTTP_X_FORWARDED_FOR))
    ?  getenv(HTTP_X_FORWARDED_FOR)
    :  getenv(REMOTE_ADDR);
  return $ip;
}

function getCurrentFAI() {
	$ip = getCurrentIP();
	$host = @gethostbyaddr($ip); 
	$fai = false;
	if(substr_count($host, 'proxad')) $fai = 'free';
	if(substr_count($host, 'orange')) $fai = 'orange';
	if(substr_count($host, 'wanadoo')) $fai = 'orange';
	if(substr_count($host, 'sfr')) $fai = 'sfr';
	if(substr_count($host, 'club-internet')) $fai = 'sfr';
	if(substr_count($host, 'neuf')) $fai = 'neuf';
	if(substr_count($host, 'gaoland')) $fai = 'neuf';
	if(substr_count($host, 'bbox')) $fai = 'bouygues';
	if(substr_count($host, 'bouyg')) $fai = 'bouygues';
	if(substr_count($host, 'numericable')) $fai = 'numericable';
	if(substr_count($host, 'tele2')) $fai = 'tele2';
	return $fai;
}

echo "Votre FAI est : ".getCurrentFAI();

 


Anonymous - - 03/01/2013
Niquel pour bannir tous les SFR :-)


Write a comment :
Your name :     E-mail (optional) :

AntiSpam : what animal is visible on this picture ? :

Nos partenaires : iPhone 8 Cases & Protection