|
|
|
| Скажите пожалуйста вотесть скрипт взятый из ваших примеров:
<html>
<head>
<title>IP information</title>
</head>
<body>
<center>
<H4>Информация об IP-адресе</H4>
<FORM action=ip.php method=post>
<INPUT type=text name=ip size=35>
<input type=submit value='Проверить'>
</form>
</center>
<?php
if ($ip!="") {
$sock = fsockopen ("whois.ripe.net",43,$errno,$errstr);
//соединение с сокетом TCP, ожидающим на сервере "whois.ripe.net" на 43 порту.
Возвращает дескриптор соединения
if (!$sock) {
echo("$errno($errstr)");
return;
}
else {
fputs ($sock, $ip."\r\n");
//записываем строку из переменной $ip в дескриптор сокета
while (!feof($sock)) {
echo (str_replace(":",": ",fgets ($sock,128))."<br>");
//осуществляем чтение из дескриптора сокета
}
}
fclose ($sock);
//закрытие соединения
}
?>
</body>
</html>
|
Как вывести только Страну город и желательно провайдера
Такого вида:
country: Страна
city: город
Provider: Провайдер
Вывод остальных данных не производить, возможно тут необхожимо рабоать с буфером, помогите пожалуйста!
Заранее благодарен! | |
|
|
|
|
|
|
|
для: cernos
(15.09.2005 в 17:24)
| | Народ что никто не знает! Может кто нибудь всё таки поможет?! | |
|
|
|
|
|
|
|
для: cernos
(16.09.2005 в 10:41)
| | Это можно сделать при помощи регулярных выражений... Я сейчас убегаю, напомните, если я забуду про эту тему... | |
|
|
|
|
|
|
|
для: cheops
(16.09.2005 в 12:58)
| |
<html>
<head>
<title>IP information</title>
</head>
<body>
<center>
<H4>Информация об IP-адресе</H4>
<FORM action=ip.php method=post>
<INPUT type=text name=ip size=35>
<input type=submit value='Проверить'>
</form>
</center>
<?php
if ($ip!="") {
$sock = fsockopen ("whois.ripe.net",43,$errno,$errstr);
//соединение с сокетом TCP, ожидающим на сервере "whois.ripe.net" на 43 порту.
Возвращает дескриптор соединения
if (!$sock) {
echo("$errno($errstr)");
return;
}
else {
fputs ($sock, $ip."\r\n");
//записываем строку из переменной $ip в дескриптор сокета
while (!feof($sock)) {
$x=fgets ($sock,128);
if(substr($x,0,7)=="country"){
echo (str_replace(":",": ",$x)."<br>");
//осуществляем чтение из дескриптора сокета
}
}
}
fclose ($sock);
//закрытие соединения
}
?>
</body>
</html>
|
| |
|
|
|
|
|
|
|
для: Shorr Kan
(17.09.2005 в 08:16)
| | Пожалуйста, а вы не можете сделать чтобы было так:
Город, страна
Т.е.
Donetsk, UA
Заранее спасибо! | |
|
|
|
|
|
|
|
для: cernos
(27.09.2005 в 18:53)
| | Приведите ответ whois-сервера для примера. | |
|
|
|
|
|
|
|
для: cheops
(27.09.2005 в 21:52)
| |
% This is the RIPE Whois query server #1.
% The objects are in RPSL format.
%
% Note: the default output of the RIPE Whois server
% is changed. Your tools may need to be adjusted. See
% http: //www.ripe.net/db/news/abuse-proposal-20050331.html
% for more details.
%
% Rights restricted by copyright.
% See http: //www.ripe.net/db/copyright.html
% Note: This output has been filtered.
% To receive output for a database update, use the "-B" flag.
% Information related to '195.58.224.0 - 195.58.255.255'
inetnum: 195.58.224.0 - 195.58.255.255
org: ORG-JcD1-RIPE
netname: UA-DORIS-971127
descr: PROVIDER
country: UA
admin-c: II83-RIPE
tech-c: II83-RIPE
status: ALLOCATED PA
mnt-by: RIPE-NCC-HM-MNT
mnt-lower: AS8343-MNT
mnt-routes: AS8343-MNT
source: RIPE # Filtered
organisation: ORG-JcD1-RIPE
org-name: Joint-Stock company DORIS
org-type: LIR
address: Stock company DORIS
Prospekt Gurova, 2 r.322
83055 Donetsk
Ukraine
phone: +380 62 3350350
fax-no: +380 62 3359293
e-mail: office@skif.net
admin-c: II83-RIPE
mnt-ref: AS8343-MNT
mnt-ref: RIPE-NCC-HM-MNT
mnt-by: RIPE-NCC-HM-MNT
source: RIPE # Filtered
person: Indick Igor
address: JSC Doris
address: Gurova st.,2
address: 83055 Donetsk
address: UA
phone: +380 (62) 3359474
phone: +380 (62) 3350350
fax-no: +380 (62) 3359293
e-mail: igor@skif.net
nic-hdl: II83-RIPE
source: RIPE # Filtered
% Information related to '195.58.224.0/19AS8343'
route: 195.58.224.0/19
descr: DOnbass Regional Information System
descr: Internet/X.25/FrameRelay solutions
descr: Donetsk, UA
origin: AS8343
holes: 195.58.226.0/24, 195.58.227.0/24, 195.58.229.0/24, 195.58.232.0/24, 195.58.234.0/24, 195.58.235.0/24, 195.58.24
1.0/24, 195.58.243.0/24, 195.58.237.0/24, 195.58.245.0/24
mnt-by: AS8343-MNT
source: RIPE # Filtered
|
Город Donetsk Страна UA
и
еще
допустим:
% This is the RIPE Whois query server #1.
% The objects are in RPSL format.
%
% Note: the default output of the RIPE Whois server
% is changed. Your tools may need to be adjusted. See
% http: //www.ripe.net/db/news/abuse-proposal-20050331.html
% for more details.
%
% Rights restricted by copyright.
% See http: //www.ripe.net/db/copyright.html
% Note: This output has been filtered.
% To receive output for a database update, use the "-B" flag.
% Information related to '158.0.0.0 - 158.255.255.255'
inetnum: 158.0.0.0 - 158.255.255.255
netname: EU-ZZ-158
descr: Various Registries
country: EU # Country is really world wide
remarks: These addresses were issued by
The IANA before the formation of
Regional Internet Registries.
org: ORG-NCC1-RIPE
admin-c: iana1-RIPE
tech-c: iana1-RIPE
status: ALLOCATED UNSPECIFIED
mnt-by: RIPE-NCC-HM-MNT
mnt-lower: RIPE-NCC-HM-MNT
mnt-routes: RIPE-NCC-RPSL-MNT
source: RIPE # Filtered
organisation: ORG-NCC1-RIPE
org-name: RIPE NCC
org-type: RIR
address: RIPE Network Coordination Centre
address: P.O. Box 10096
address: 1001 EB Amsterdam
address: The Netherlands
phone: +31 20 535 4444
fax-no: +31 20 535 4445
e-mail: hostmaster@ripe.net
admin-c: CREW-RIPE
tech-c: CREW-RIPE
ref-nfy: hm-dbm-msgs@ripe.net
mnt-ref: RIPE-NCC-HM-MNT
mnt-by: RIPE-NCC-HM-MNT
source: RIPE # Filtered
role: Internet Assigned Numbers Authority
address: see http: //www.iana.org.
e-mail: bitbucket@ripe.net
admin-c: IANA1-RIPE
tech-c: IANA1-RIPE
nic-hdl: IANA1-RIPE
remarks: For more information on IANA services
remarks: go to IANA web site at http: //www.iana.org.
mnt-by: RIPE-NCC-MNT
source: RIPE # Filtered
| Город address: Amsterdam Страна EU
Мне необходимо вывести Город, страна
т.е.
Amsterdam, EU
Заранее благодарен! | |
|
|
|
|
|
|
|
для: cernos
(28.09.2005 в 12:14)
| | У всех к сожалению совершенно разный формат, если в первом случае ещё можно вытащить так
<?php
preg_match("|country:[\s]+([\w]+)|i",$text,$out);
$country = $out[1];
preg_match("|descr:[\s]+(([\w]+),[\s]+$out[1])|",$text,$out);
echo $out[1];
?>
|
во втором нужно подумать как лучше... | |
|
|
|
|
|
|
|
для: cheops
(28.09.2005 в 13:50)
| | Мда! Ситуация не из приятных!
Скажите cheops а есть ли у вас скрипт с помощью которого можно узнать по ip адресу компа, его местонахождение,
страну город.
Скажу вамчестно очень нужен данный скриптик...
Помогите! :\ | |
|
|
|
|
|
|
|
для: cernos
(29.09.2005 в 11:43)
| | Нет, готового скрипта нет - был бы, выложил сразу. | |
|
|
|
|
|
|
|
для: cheops
(29.09.2005 в 12:17)
| | Ну, а можно чтонибудь придумать?!
Можно вытащить из address значение города! | |
|
|
|
|
|
|
|
для: cernos
(29.09.2005 в 14:37)
| |
country: EU # Country is really world wide
|
Дохлый номер. Страна не определилась. И не определится 100%. Сам голову над этим ломал когда составлял географию посетителей сайта.
function getCountry($ip){
if ($ip!="") {
$sock = fsockopen ("whois.ripe.net",43,$errno,$errstr);
if (!$sock) {
echo("$errno($errstr)");
return;
}
else {
fputs ($sock, $ip."\r\n");
$i=0;
while (!feof($sock)) {
$str= fgets ($sock,128);
if (strpos($str,'ountry')>0){
$b=strpos($str,':');
$end=strpos($str,'#');
//if ($end>0) $s_end=$end-$b;
$res=substr($str,$b,10);
break;
}
}
}
fclose ($sock);
}
return $res;
}
|
Я так вытаскиваю двубуквенные обозначения стран. Работает безотказно, кроме случаев с EU
PS. Можно пробовать прогонять через несколько whois серверов и где-нибудь IP-шник должен засветится.
ripe.net на Европу работает. Американские страны например не определяет. | |
|
|
|
|
|
|
|
для: Axxil
(29.09.2005 в 15:54)
| | Базу создайте и определяйте сколько хотите.
http://www.techinfo.net.ru/ip2ruscity/ - там ссылки на базу городов и на базу стран (бесплатные) есть. | |
|
|
|
|
|
|
|
для: OZ_
(30.09.2005 в 01:13)
| | Да, это всё хорошо! НО для них необходима база городов и стран!
И тем более, что эта база постоянно изменяется, там нет городов украины, только россии!
А мне надо чтобы пусть будет по англ. но опред-ла всё! | |
|
|
|
|
|
|
|
для: cernos
(30.09.2005 в 11:10)
| | Вы бы линк посмотрели сначала. Есть там база и для Украины. И базы есть халявные и свежие (буквально за сентябрь 2005). обновлять не сложно. | |
|
|
|