Senin, Oktober 01, 2007

ip chek

on 1:text:!ip *:#:{ .set %c-place $chan | /telusuri $2- }

alias -l _geodisp {
; Since people seem to want this on a single line,
; I've went ahead and added the functionality myself.
if ($_geonfo(nick)) { var %nick = Nick: $v1 }
/msg %c-place IP $_geonfo(ip) . 12Negara: $_geonfo(country) $+([,$_geonfo(ccode),]) . 12Bagian: $_geonfo(region) . 12Kota: $_geonfo(city) . 12kepastiannya seh: $_geonfo(certainty)
.unset %c-place
}
alias telusuri {
if (!$regex($1,/^(\d{1,3}(?:\.\d{1,3}){3})$/)) {
echo -a *** Geoloc: bukan jenis IP. | return
}
if ($sock(geoloc)) { sockclose geoloc }
sockopen geoloc www.geobytes.com 80
sockmark geoloc $1-
}
on *:sockopen:geoloc:{
var %% = sockwrite -n $sockname
var %text = $+(ipaddress=,$_geonfo(ip))
%% POST /IpLocator.htm?GetLocation HTTP/1.0
%% Host: www.geobytes.com
%% User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6)
%% Content-Length: $len(%text)
%% Content-Type: application/x-www-form-urlencoded
%% Connection: close
%%
%% %text
}
on *:sockread:geoloc:{
if ($sockerr) return
var %s | sockread %s
tokenize 32 $left(%s,900)
if (

We are unable to locate the address * iswm $1-) {
echo -a $+([,$_geonfo(ip),]) Unable to locate the address.
sockclose $sockname | return
}
if ($regex($1-,//)) {
var %code = $regml(1) , %value = $regml(2)
if (%code == 12) { _geonfo ccode %value }
elseif (%code == 13) { _geonfo country %value }
elseif (%code == 15) { _geonfo region %value }
elseif (%code == 17) { _geonfo city %value }
elseif (%code == 18) { _geonfo certainty %value | _geodisp | _georem }
}
}
alias -l _geodisp {
if ($_geonfo(nick)) { var %nick = Nick: $v1 }
echo -a $&
%nick IP: $_geonfo(ip) $&
Negara: $_geonfo(country) $+([,$_geonfo(ccode),]) $&
Bagian: $_geonfo(region) $&
Kota: $_geonfo(city) $&
Kepastian: $_geonfo(certainty)
}
alias -l _geonfo {
var %ip = $gettok($sock($sockname).mark,1,32) , %nick = $gettok($sock($sockname).mark,2,32)
if ($isid) {
if ($1 == ip) { return %ip }
elseif ($1 == nick) { return %nick }
return $hget(geoloc,$+(%ip,.,$$1))
}
hadd -m geoloc $+(%ip,.,$1) $$2-
}
alias -l _georem { hdel -w geoloc $+($_geonfo(ip),.*) }

alias geonick { .enable #geonick | .timer.dgeonick 1 30 .disable #geonick | stats L $1 }
#geonick off
raw 211:*:{
haltdef
if ($regex($2,/(.*?)\!.*?@(.*)/)) { geoloc $regml(2) $regml(1) }
}
raw 219:*:{ haltdef }
#geonick end

Tidak ada komentar: