Languages :: PHP :: Determining Location (Physical) |
|||
| By: Sm3llY |
Date: 22/07/2003 00:00:00 |
Points: 50 | Status: Answered Quality : Excellent |
|
To all Experts I need to find out how to determine the physical location of the user and the redirect him/her accordingly. Could anyone please help? |
|||
| By: VGR | Date: 22/07/2003 01:54:00 | Type : Comment |
|
| I still have the same suggestion as in a recent thread : I use a "globalWhoIs" function that is able to get the best possible data from the IP address we have in (_SERVER[]) $REMOTE_ADDR. It won't ***always*** give you the exact location, in the case of very big ISPs like AOL, but it ***may*** prove useful though. Anyway, you can't get better (public) data. |
|||
| By: Sm3llY | Date: 22/07/2003 02:00:00 | Type : Comment |
|
| Hi I'm honoured to have the great VGR answer my question, thanks!!!!!!! I'm still a newbie :-) , would you mind giving me an example of how I should use it???? Thanks |
|||
| By: VGR | Date: 22/07/2003 02:09:00 | Type : Comment |
|
| I suppose that you want only the country & city ? Only the country will be accurate most of the time (AOL is a good counter-example) I will adapt it, the other person also asked for more simple data out. I use it to get email abuse addresses and such |
|||
| By: Sm3llY | Date: 22/07/2003 02:14:00 | Type : Comment |
|
| Nope, just the country would be fine. Mainly Europe, America, Australia, South Africa Thanks |
|||
| By: ThG | Date: 22/07/2003 02:31:00 | Type : Comment |
|
| > I'm honoured to have the great VGR answer my question, thanks!!!!!!! lol :-) anyway for Sm3llY: I think this is what you need: <A HREF="http://ip-to-country.directi.com/">http://ip-to-country.directi.com/</a> |
|||
| By: VGR | Date: 22/07/2003 03:19:00 | Type : Comment |
|
| yes, lol too :D I'm not that great, I'm only 6" tall |
|||
| By: VGR | Date: 22/07/2003 03:40:00 | Type : Answer |
|
| ok, if you've the curiosity to look at the last IP@ , calling <A HREF="http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=213.193.43.134">http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=213.193.43.134</a> you'll see that I'm focusing on the first (and only guaranteed) record. If you want the town/city with accuracy, you should parse the other records ("role" etc) with a fair chance of invalid data... May-be by counting occurences of the various cities and if a certain threshold is exceeded, then it's a cancidate found... I don't know. I will have the city ***if*** it has been specified in the "address:" fields of the first record ("inetnum") regards. -----------------Here are the results : ------------------- seeking data for IP@='80.65.230.177' NsLookup : let's call <A HREF="http://name.space.xs2.net/cgi-bin/nslookup.pl?pageid=DNS411&nsinput=80.65.230.177&submit=search">http://name.space.xs2.net/cgi-bin/nslookup.pl?pageid=DNS411&nsinput=80.65.230.177&submit=search</a> essai1='' locMachine='' locDomaine='' whois : let's call <A HREF="http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=80.65.230.177">http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=80.65.230.177</a> essai2='FR-NERIM-20010515 : PROVIDER (FR)' locMachine='' locDomaine(*)='FR-NERIM-20010515 : PROVIDER (FR)' email TO : 'bouaziz@nerim.net, hostmaster@ripe.net' email CC : '' -------------------------------------------------------------------------------- seeking data for IP@='82.65.118.217' NsLookup : let's call <A HREF="http://name.space.xs2.net/cgi-bin/nslookup.pl?pageid=DNS411&nsinput=82.65.118.217&submit=search">http://name.space.xs2.net/cgi-bin/nslookup.pl?pageid=DNS411&nsinput=82.65.118.217&submit=search</a> essai1='ns-p19-18-82-65-118-217.adsl.proxad.net' locMachine='ns-p19-18-82-65-118-217.adsl.proxad.net' locDomaine='ns-p19-18-82-65-118-217.adsl.proxad.net' whois : let's call <A HREF="http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=82.65.118.217">http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=82.65.118.217</a> essai2='FR-PROXAD-20030403 : PROVIDER : Proxad, Internet Service Provider in France (FR)' locMachine='ns-p19-18-82-65-118-217.adsl.proxad.net' locDomaine(*)='FR-PROXAD-20030403 : PROVIDER : Proxad, Internet Service Provider in France (FR)' email TO : 'mailto:abuse@proxad.net, hostmaster@proxad.net' email CC : 'ripe-notify@proxad.net, hostmaster@ripe.net' -------------------------------------------------------------------------------- seeking data for IP@='213.193.43.134' NsLookup : let's call <A HREF="http://name.space.xs2.net/cgi-bin/nslookup.pl?pageid=DNS411&nsinput=213.193.43.134&submit=search">http://name.space.xs2.net/cgi-bin/nslookup.pl?pageid=DNS411&nsinput=213.193.43.134&submit=search</a> essai1='' locMachine='' locDomaine='' whois : let's call <A HREF="http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=213.193.43.134">http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=213.193.43.134</a> essai2='UUNET-BOTSWANA-1 : UUNET Africa - Botswana (BW)' locMachine='' locDomaine(*)='UUNET-BOTSWANA-1 : UUNET Africa - Botswana (BW)' email TO : 'ip-maint@za.uu.net, charl@za.uu.net' email CC : '' -------------------------------------------------------------------------------- seeking data for IP@='213.37.180.126' NsLookup : let's call <A HREF="http://name.space.xs2.net/cgi-bin/nslookup.pl?pageid=DNS411&nsinput=213.37.180.126&submit=search">http://name.space.xs2.net/cgi-bin/nslookup.pl?pageid=DNS411&nsinput=213.37.180.126&submit=search</a> essai1='' locMachine='' locDomaine='' whois : let's call <A HREF="http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=213.37.180.126">http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=213.37.180.126</a> essai2='MADRITEL : PROVIDER : Madritel (ES)' locMachine='' locDomaine(*)='MADRITEL : PROVIDER : Madritel (ES)' email TO : 'abuse@auna.es, techauna@auna.es' email CC : '' -------------------------------------------------------------------------------- Done ------ and here's the code -------------- <? // logwarn.php : gestion des log alarms // //VGR15082001 : création à partir de surv.php // [ snip ] //VGR22072003 MODification : limited edition for EE people :D // // $DEBUG=1; header("Refresh: 9999"); /* set browser refresh period à 9999s (jamais) */ if ($DEBUG==1) set_time_limit(30); else set_time_limit(480); // allowed exec. time in seconds //begin echo "<HTML><BODY BACKGROUND=\"\" BGCOLOR=\"000000\" VLINK=\"FF0000\" TEXT=\"FFFFFF\" LINK=\"8080FF\">"; // // ----------------------------- DEFS ----------------------------------- // //[snip] // // ----------------------------- fonctions ph2 -------------------------------- // function Nettoie($par,$debug=FALSE) { // nettoie l'INTERIEUR d'une chaîne des 0A ou 0A0D et espaces... if ($debug) echo "par entrée = '".htmlspecialchars($par)."' "; $poubStr=strip_tags(nl2br($par)); if ($debug) echo "par strippé = '".htmlspecialchars($poubStr)."' "; $poubStr=trim($poubStr); if ($debug) echo "poub lu hex = ".bin2hex($poubStr)." "; if (!(strpos($poubStr,"\r\n")===FALSE)) { for ($i=1;($i<strlen($poubStr))and(substr($poubStr,$i,2)<>chr(13).chr(10));$i++) ; $poub2=substr($poubStr,0,$i); if ($debug) echo "poub2(1) i=$i hex = ".bin2hex($poub2)." "; $j=$i; while (substr($poubStr,$j,2)==chr(13).chr(10)) $j+=2; if ($debug) echo " j=$j "; while (substr($poubStr,$j,1)==' ') $j++; if ($debug) echo "poub2(2) hex = ".bin2hex(substr($poubStr,$j))." "; $poub2.=" ".substr($poubStr,$j); // le reste $poub2=str_replace(chr(10),'',$poub2); } // if travail à faire else $poub2=str_replace(chr(10),'',$poubStr); if ($debug) echo "poub lu = ".htmlspecialchars($poubStr)." "; if ($debug) echo "poub2 calc = ".htmlspecialchars($poub2)." "; if ($debug) echo "poub2 hex = ".bin2hex($poub2)." "; return($poub2); } // Nettoie String Function //VGR26062003 MODified URI called, infobear.com disappeared function tryNsLookup($IP,$debug=FALSE) { $filename = "<A HREF="http://name.space.xs2.net/cgi-bin/nslookup.pl?pageid=DNS411&nsinput=$IP&submit=search">http://name.space.xs2.net/cgi-bin/nslookup.pl?pageid=DNS411&nsinput=$IP&submit=search</a>"; $contents=array(); $resultat=""; //TEST mode for your eyes // if ($debug) echo "NsLookup : let's call $filename "; //EoTest $fd = fopen ($filename, "r"); if ($fd) { while (!feof ($fd)) { $ligne=fgets($fd, 4096); $contents []= $ligne; } // while lecture bloquante // $contents = fread ($fd, filesize ($filename)); non bloquant : merdique fclose ($fd); if ($debug) echo "finished getting NsLookup "; $i=count($contents); while ((($a=strpos($contents[$i],'Name:'))===FALSE)and($i>=0)) $i--; if ($i>=0) $resultat=trim(substr($contents[$i],10)); // le reste // ici contents pointe sur (zb) "swtc180-41.adsl.seed.net.tw" } // if pas trouvé return($resultat); } // tryNsLookup String Function function tryTraceroute($IP,$debug=FALSE) { $filename = "<A HREF="http://www.serveurdedie.com/cgi-bin/nph-traceroute?$IP">http://www.serveurdedie.com/cgi-bin/nph-traceroute?$IP</a>"; $contents=array(); $resultat=""; if ($debug) echo "traceroute : let's call $filename "; $fd = fopen ($filename, "r"); $continue=0; $i=0; if ($fd) { while ((!feof ($fd))and ($continue<2)) { $ligne=fgets($fd, 4096); $contents []= $ligne; $i++; if (strpos('* * *',$ligne)>0) $continue++; else $continue=0; } // while lecture bloquante // $contents = fread ($fd, filesize ($filename)); non bloquant : merdique fclose ($fd); if ($debug) echo "finished getting traceroute "; $i=count($contents); while (strpos($contents[$i],' ms')==0) $i--; //{echo "1 ".$contents[$i]." "; $i--; } while ((strpos($contents[$i],'*')>0) and (strpos($contents[$i],'*')<5)) $i--; //{echo "2 ".$contents[$i]." "; $i--; } // ici contents pointe sur (zb) "12 paris11-nas8-55-25.dial.proxad.net (212.27.55.25) 209 ms 202 ms 199 ms" $resultat=$contents[$i]; } // else NOP return $resultat; } // tryTraceroute String Function $emailsTo=""; $emailsCC=""; $nbEmailsto=0; $nbEmailscc=0; function tryWhois($IP,$debug=FALSE) { GLOBAL $emailsTo, $emailsCC, $locDomaine, $locMachine; $filename = "<A HREF="http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=$IP">http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=$IP</a>"; if ($debug) echo "whois : let's call $filename "; $fd2 = fopen ($filename, "r"); while (!feof ($fd2)) { $contents2 []= fgets($fd2, 4096); } // while lecture bloquante fclose ($fd2); $i=0; while ((strpos($contents2[$i],'netname:')===FALSE) and ($i<count($contents2))) $i++; if ($i==count($contents2)) $locRes="non trouvé"; else { // l'élément I nous intéresse $locRes=trim(substr($contents2[$i],13)); $i++; if ($locRes=='IANA-BLK') { // on essaie avec NsLookup if ($debug) echo "IANA-BLK, let's call NsLookup "; $essai1=tryNsLookup($IP,$debug); // swtc180-41.adsl.seed.net.tw $locMachine=$essai1; $z=explode('.',$essai1); if (count($z)>0) { // cas normal if (count($z)>2) { // cas normal $locDomaine=$z[count($z)-2].'.'.$z[count($z)-1]; } else { // 1 $locDomaine=$locMachine; } } else { // 0 $locDomaine=$locMachine; } if ($debug) echo "essai1='$essai1' "; if ($debug) echo "locMachine='$locMachine' "; if ($debug) echo "locDomaine='$locDomaine' "; $locRes=$locDomaine; } else { while (strpos($contents2[$i],'country:')===false) { $locRes.=" : ".substr($contents2[$i],13); $i++; } // plusieurs descr: possibles $locRes.=" (".substr($contents2[$i],13).")"; // now set up email addresses $emailsTo=array(); $emailsCC=array(); // dans l'ordre : To: via trouble ou remarks + mot-clef "abuse" + adresse email rencontrée // ensuite (CC) ou To (1ère rencontrée) les "e-mail:", "notify:" et "changed:" $i=0; while ($i<count($contents2)) { // passe while (($a=strpos($contents2[$i],'trouble:'))===false) $i++; } // passe if ($a) { // try to get an address from those remarks while ((($a=strpos($contents2[$i],'@'))===false)and(!(strpos($contents2[$i],'trouble:')===false))) $i++; if ($a) { // une adresse mél trouvée $j=$i-1; while ($contents[$i][$j]<>' ') $j--; $k=$i+1; while ($contents[$i][$j]<>' ') $k++; $adresse=substr($contents[$i],$j+1,$k-$j); if ($debug) echo "adresse trouvée = '$adresse' "; // affectation // if (count($emailsTo)<2} } // else RàF, on passe à la passe suivante } // if trouble trouvé } // if domaine trouvé dans RIPE } // if pas trouvé /* exemple de bloc trouvé : netname: INFONIE descr: INFONIE country: BE admin-c: FB324-RIPE tech-c: AA696-RIPE status: ASSIGNED PA mnt-by: INFONIE-MNT changed: aandre@infonie.be 20000929 source: RIPE */ return $locRes; } // tryWhois String Function //VGR31032003 MODification à cause d'ARIN (format whois spécifique...) //VGR09042003 ADDed cas ERX-NETBLOCK (early registration addresses dues à InternIC) // MODified APNIC à cause de 'Not allocated by' au lieu de 'not allocated to' function globalWhois($IP,$debug=FALSE) { GLOBAL $emailsTo, $emailsCC, $locDomaine, $locMachine, $nbEmailsto, $nbEmailscc, $netname; $server[0] = "<A HREF="http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=$IP">http://www.ripe.net/perl/whois?form_type=simple&full_query_string=&searchtext=$IP</a>"; $refus[0]='IANA-BLK'; $chemail[0]='e-mail:'; $chdescr[0]='descr:'; $chcountry[0]='country:'; $chnetname[0]='netname:'; $server[1] = "<A HREF="http://www.apnic.net/apnic-bin/whois.pl?searchtext=$IP">http://www.apnic.net/apnic-bin/whois.pl?searchtext=$IP</a>"; $refus[1]='ot allocated'; $chemail[1]='e-mail:'; $chdescr[1]='descr:'; $chcountry[1]='country:'; $chnetname[1]='netname:'; $server[2] = "<A HREF="http://ws.arin.net/cgi-bin/whois.pl?queryinput=$IP">http://ws.arin.net/cgi-bin/whois.pl?queryinput=$IP</a>"; $refus[2]='not registered in'; $chemail[2]='TechEmail:'; $chdescr[2]='Org'; $chcountry[2]='Country:'; $chnetname[2]='NetName:'; $server[3] = "<A HREF="http://lacnic.net/cgi-bin/lacnic/whois?lg=EN&qr=$IP">http://lacnic.net/cgi-bin/lacnic/whois?lg=EN&qr=$IP</a>"; $refus[3]='Not assigned to'; $chemail[3]='e-mail:'; $chdescr[3]='descr:'; $chcountry[3]='country:'; $chnetname[3]='netname:'; // NB : $chdescr[] non utilisé sauf pour ARIN $index=0; $notfound=TRUE; while (($notfound)and($index<4)) { $filename=$server[$index]; $contents2=array(); // vidage $notalloc=FALSE; // itou //TEST mode for your eyes if ($debug) echo "whois : let's call $filename "; //EoTest $fd2 = fopen ($filename, "r"); while (!feof ($fd2)) { $ligne=fgets($fd2, 4096); $contents2 []= $ligne; if ((! (strpos($ligne,$refus[$index])===FALSE))or(! (strpos($ligne,'ERX-NETBLOCK')===FALSE))) $notalloc=TRUE; } // while lecture bloquante fclose ($fd2); $locRes="non trouvé"; // défaut if ($notalloc) $index++; else { $i=0; if ($debug) echo "recherche ".$chnetname[$index]." "; while ((strpos($contents2[$i],$chnetname[$index])===FALSE) and ($i<count($contents2))) $i++; if ($i==count($contents2)) { // on passe if ($debug) echo "élément ".$chnetname[$index]." non trouvé "; //VGR16042003 ADDed seconde chance pour les reassigned du lacnic if ($index==3) { // seconde chance sur "owner" ;-) $i=0; $chnetname[$index]='owner:'; if ($debug) echo "recherche ".$chnetname[$index]." "; while ((strpos($contents2[$i],$chnetname[$index])===FALSE) and ($i<count($contents2))) $i++; if ($i==count($contents2)) { // on passe if ($debug) echo "élément ".$chnetname[$index]." non trouvé "; $locRes="non trouvé"; // inutile $index++; } else { if ($debug) echo "élément ".$chnetname[$index]." trouvé en seconde chance "; } // RàF, c'est bon } else { $locRes="non trouvé"; // inutile $index++; } //EoAdd } else { // l'élément I nous intéresse //if ($debug) echo "élément brutal lu en $i = '".htmlspecialchars($contents2[$i])."' "; $locRes=trim(substr($contents2[$i],12)); //if ($debug) echo "élément brut ".$chnetname[$index]." lu en $i = '".htmlspecialchars($locRes)."' "; $locRes=Nettoie($locRes,$debug); if ($debug) echo "élément ".$chnetname[$index]." lu en $i = $locRes "; $i++; if ($locRes=='IANA-BLK') { // on passe $index++; } else if ((substr($locRes,0,6)=='LACNIC')and ($index==2)) { // on passe (ARIN référence LACNIC) $index++; } else { $notfound=FALSE; $netname=$locRes; if ($index<>2) { // cas normal //if ($debug) echo "poursuite élément ".$chnetname[$index]." lu en $i = $locRes "; while (strpos($contents2[$i],$chcountry[$index])===false) { $locRes.=" : ".Nettoie(substr($contents2[$i],12),$debug); $i++; } // plusieurs descr: possibles $locRes.=" (".Nettoie(substr($contents2[$i],12),$debug).")"; } else { // cas ARIN $i=0; if ($debug) echo "recherche ".$chdescr[$index]." "; while ((strpos($contents2[$i],$chdescr[$index])===FALSE) and ($i<count($contents2))) $i++; if ($i==count($contents2)) { // on passe (pas de description...) } else { // c'est bon //if ($debug) echo "élément brutal lu en $i = '".htmlspecialchars($contents2[$i])."' "; $poubStr=trim(substr($contents2[$i],12)); //if ($debug) echo "élément brut ".$chdescr[$index]." lu en $i = '".htmlspecialchars($poubStr)."' "; $locRes.=' : '.Nettoie($poubStr,$debug); if ($debug) echo "élément ".$chdescr[$index]." lu en $i = '$poubStr' "; $i++; //if ($debug) echo "poursuite élément ".$chdescr[$index]." lu en $i = $locRes "; while (strpos($contents2[$i],$chcountry[$index])===false) { $locRes.=" : ".Nettoie(substr($contents2[$i],12),$debug); $i++; } // plusieurs descr: possibles $locRes.=" (".Nettoie(substr($contents2[$i],12),$debug).")"; } // found } // ARIN (2 passes) ou non // now set up email addresses $emailsTo=""; $emailsCC=""; $deja=array(); $nbEmailsto=0; $nbEmailscc=0; // dans l'ordre : To: via trouble ou remarks + mot-clef "abuse" + adresse email rencontrée // ensuite (CC) ou To (1ère rencontrée) les "e-mail:", "notify:" et "changed:" $theval='trouble:'; $i=0; while (($i<count($contents2)) and (($a=strpos($contents2[$i],$theval))===FALSE)) { $i++; } if ($i<count($contents2)) { // try to get an address from those remarks while ((($a=strpos($contents2[$i],'@'))===false)and(!(strpos($contents2[$i],$theval)===false))and($i<count($contents2))) $i++; if (($i<count($contents2))and($a)) { // une adresse mél trouvée $j=$a-1; while ($contents2[$i][$j]<>' ') $j--; $k=$a+1; while (($k<strlen($contents2[$i]))and($contents2[$i][$k]<>' ')) $k++; $adresse=trim(substr($contents2[$i],$j+1,$k-$j)); if ($debug) echo "adresse $theval trouvée = '$adresse' "; if ($deja[$adresse]) { // rien if ($debug) echo "adresse '$adresse' déjà placée "; } else { // affectation if ($nbEmailsto<2) { if ($nbEmailsto==1) $emailsTo.=", $adresse"; else $emailsTo="$adresse"; $nbEmailsto++; } $deja[$adresse]=TRUE; } // si pas déjà prise } // else RàF, on passe à la passe suivante } // if trouble trouvé $theval='remarks:'; $i=0; while (($i<count($contents2)) and (($a=strpos($contents2[$i],$theval))===FALSE)) { $i++; } if ($i<count($contents2)) { // try to get an address from those remarks while ((($a=strpos($contents2[$i],'@'))===false)and(!(strpos($contents2[$i],$theval)===false))and($i<count($contents2))) $i++; //VGR07042003 ADDed sécurité sur ($a) if (($i<count($contents2))and($a)) { // une adresse mél trouvée //EoAdd $j=$a-1; while ($contents2[$i][$j]<>' ') $j--; $k=$a+1; while (($k<strlen($contents2[$i]))and($contents2[$i][$k]<>' ')) $k++; $adresse=trim(substr($contents2[$i],$j+1,$k-$j)); if ($deja[$adresse]) { // rien if ($debug) echo "adresse '$adresse' déjà placée "; } else { if ($debug) echo "adresse $theval trouvée = '$adresse' "; // affectation if ($nbEmailsto<2) { if ($nbEmailsto==1) $emailsTo.=", $adresse"; else $emailsTo="$adresse"; $nbEmailsto++; } $deja[$adresse]=TRUE; } // si pas déjà prise } // else RàF, on passe à la passe suivante } // if trouvé $theval=$chemail[$index]; $i=0; while (($i<count($contents2)) and (($a=strpos($contents2[$i],$theval))===FALSE)) { $i++; } if ($i<count($contents2)) { // try to get an address from those remarks while ((($a=strpos($contents2[$i],'@'))===false)and(!(strpos($contents2[$i],$theval)===false))and($i<count($contents2))) $i++; if (($i<count($contents2))and($a)) { // une adresse mél trouvée $j=$a-1; while ($contents2[$i][$j]<>' ') $j--; $k=$a+1; while (($k<strlen($contents2[$i]))and($contents2[$i][$k]<>' ')) $k++; $adresse=trim(substr($contents2[$i],$j+1,$k-$j)); if ($deja[$adresse]) { // rien if ($debug) echo "adresse '$adresse' déjà placée "; } else { if ($debug) echo "adresse $theval trouvée = '$adresse' "; // affectation if ($nbEmailsto<2) { if ($nbEmailsto==1) $emailsTo.=", $adresse"; else $emailsTo="$adresse"; $nbEmailsto++; } $deja[$adresse]=TRUE; } // si pas déjà prise } // else RàF, on passe à la passe suivante } // if trouvé $theval='notify:'; $i=0; while (($i<count($contents2)) and (($a=strpos($contents2[$i],$theval))===FALSE)) { $i++; } if ($i<count($contents2)) { // try to get an address from those remarks while ((($a=strpos($contents2[$i],'@'))===false)and(!(strpos($contents2[$i],$theval)===false))and($i<count($contents2))) $i++; if (($i<count($contents2))and($a)) { // une adresse mél trouvée $j=$a-1; while ($contents2[$i][$j]<>' ') $j--; $k=$a+1; while (($k<strlen($contents2[$i]))and($contents2[$i][$k]<>' ')) $k++; $adresse=trim(substr($contents2[$i],$j+1,$k-$j)); if ($deja[$adresse]) { // rien if ($debug) echo "adresse '$adresse' déjà placée "; } else { if ($debug) echo "adresse $theval trouvée = '$adresse' "; // affectation if ($nbEmailsto<2) { if ($nbEmailsto==1) $emailsTo.=", $adresse"; else $emailsTo="$adresse"; $nbEmailsto++; } else { if ($nbEmailscc==1) $emailsCC.=", $adresse"; else $emailsCC="$adresse"; $nbEmailscc++; } $deja[$adresse]=TRUE; } // si pas déjà prise } // else RàF, on passe à la passe suivante } // if trouvé $theval='changed:'; $i=0; while (($i<count($contents2)) and (($a=strpos($contents2[$i],$theval))===FALSE)) { $i++; } if ($i<count($contents2)) { // try to get an address from those remarks while ((($a=strpos($contents2[$i],'@'))===false)and(!(strpos($contents2[$i],$theval)===false))and($i<count($contents2))) $i++; if (($i<count($contents2))and($a)) { // une adresse mél trouvée $j=$a-1; while ($contents2[$i][$j]<>' ') $j--; $k=$a+1; while (($k<strlen($contents2[$i]))and($contents2[$i][$k]<>' ')) $k++; $adresse=trim(substr($contents2[$i],$j+1,$k-$j)); if ($deja[$adresse]) { // rien if ($debug) echo "adresse '$adresse' déjà placée "; } else { if ($debug) echo "adresse $theval trouvée = '$adresse' "; // affectation if ($nbEmailsto<2) { if ($nbEmailsto==1) $emailsTo.=", $adresse"; else $emailsTo="$adresse"; $nbEmailsto++; } else { if ($nbEmailscc==1) $emailsCC.=", $adresse"; else $emailsCC="$adresse"; $nbEmailscc++; } $deja[$adresse]=TRUE; } // si pas déjà prise } // else RàF, on passe à la passe suivante } // if trouvé } // if domaine trouvé sur ce serveur } // if pas trouvé } // if notallocated } // while not found if ($notfound) { // on essaie avec NsLookup if ($debug) echo "IANA-BLK, let's call NsLookup "; $essai1=tryNsLookup($IP,$debug,1); // swtc180-41.adsl.seed.net.tw $locMachine=$essai1; $z=explode('.',$essai1); if (count($z)>0) { // cas normal if (count($z)>2) { // cas normal $locDomaine=$z[count($z)-2].'.'.$z[count($z)-1]; } else { // 1 $locDomaine=$locMachine; } } else { // 0 $locDomaine=$locMachine; } if ($debug) echo "essai1='$essai1' "; if ($debug) echo "locMachine='$locMachine' "; if ($debug) echo "locDomaine='$locDomaine' "; $locRes=$locDomaine; } // pas encore trouvé return $locRes; } // globalWhois String Function // // ----------------------------- fonctions ph1-------------------------------- // // demo section $locIParr=array('80.65.230.177','82.65.118.217','213.193.43.134','213.37.180.126'); foreach($locIParr as $locIP) { if ($DEBUG==1) echo "seeking data for IP@='$locIP' "; // recherche domaine etc $essai1=tryNsLookup($locIP,(FALSE AND ($DEBUG==1))); // swtc180-41.adsl.seed.net.tw $locMachine=$essai1; $z=explode('.',$essai1); if (count($z)>0) { // cas normal if (count($z)>2) { // cas normal $locDomaine=$z[count($z)-2].'.'.$z[count($z)-1]; } else { // 1 $locDomaine=$locMachine; } } $locDomaine=$locMachine; if ($DEBUG==1) echo "essai1='$essai1' "; if ($DEBUG==1) echo "locMachine='$locMachine' "; // xxx.adsl.seed.net.tw if ($DEBUG==1) echo "locDomaine='$locDomaine' "; // net.tw $essai2=globalWhois($locIP,(FALSE AND ($DEBUG==1))); // modifie aussi $emailsTo, $emailsCC, $locDomaine, $locMachine, $nbEmailsto, $nbEmailscc, $netname; $essai2=Nettoie($essai2); // 'SEEDNET-TW : Digital United Inc. : 9F, No. 125, Song Jiang Road. : Taipei Taiwan 100 ( TW)' $netname=$locDomaine." ($netname)"; // netname = SEEDNET-TW $locDomaine=$essai2; if ($DEBUG==1) echo "essai2='$essai2' "; if ($DEBUG==1) echo "locMachine='$locMachine' "; if ($DEBUG==1) echo "locDomaine(*)='$locDomaine' "; if ($DEBUG==1) echo "email TO : '$emailsTo' "; if ($DEBUG==1) echo "email CC : '$emailsCC' "; if ($DEBUG==1) { echo "<PRE>"; print_r($locdata); echo "</PRE>"; } echo '<hr>'; } // foreach echo " Done "; ?> |
|||
| By: waygood | Date: 22/07/2003 04:32:00 | Type : Comment |
|
| There is a really good free service out there somewhere, but I have forgotten where at the moment, so here is a similar site for you <A HREF="http://www.geobytes.com/IpLocator.htm">http://www.geobytes.com/IpLocator.htm</a> |
|||
| By: waygood | Date: 22/07/2003 04:40:00 | Type : Comment |
|
| nope haven't found it yet but here is a site that has PHP modules you can use for free <A HREF="http://www.maxmind.com/app/php">http://www.maxmind.com/app/php</a> |
|||
| By: Sm3llY | Date: 23/07/2003 05:17:00 | Type : Comment |
|
| Thanks to all for their comments and effort regarding this. In the end it was decided not to use this functionality (higher authority) :( I'll give VGR the point for the effort of writing that enormous amount of code. Once again, thanks to you all!!!!!!! |
|||
| By: VGR | Date: 23/07/2003 05:20:00 | Type : Comment |
|
| "writing" ? you mean "copy-pasting-deleting" :D |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








