All pastes #596402 Raw Edit

Someone

public text v1 · immutable
#596402 ·published 2007-06-29 22:39 UTC
rendered paste body
;----------
; IP Whois
;----------
on *:SOCKOPEN:whois_*:{
  if ($sockerr) {
    msg $hget($sockname,chan) Erro ao conectar
    return
  }
  sockwrite -tn $sockname GET /tools/city.ch?ip= $+ $hget($sockname,ip) HTTP/1.1
  sockwrite -tn $sockname Accept: */*
  sockwrite -tn $sockname Referer: http://www.dnsstuff.com/
  sockwrite -tn $sockname Accept-Language: pt-br
  sockwrite -tn $sockname Accept-Encoding: gzip, deflate
  sockwrite -tn $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
  sockwrite -tn $sockname Host: www.dnsstuff.com
  sockwrite -tn $sockname Connection: Close
  sockwrite -tn $sockname 
}
on *:SOCKREAD:whois_*:{
  var %read | sockread %read
  ;echo -s %read
  if (IP: * iswm %read) { hadd $sockname ip $gettok(%read,2,32) }
  if (City: * iswm %read) { hadd $sockname city $gettok(%read,2-,32) }
  if (Country: * iswm %read) { hadd $sockname country $gettok(%read,2-,32) }
  if (Country Code: * iswm %read) { hadd $sockname ccode $gettok(%read,3,32) }
}
on *:SOCKCLOSE:whois_*:{
  if ($hget($sockname,country) == Unknown) {
    msg $hget($sockname,chan) Sem informações para este IP.
  }
  else {
    msg $hget($sockname,chan) Whois $hget($sockname,ip) - País:  $+ $hget($sockname,country) $+  ( $+ $hget($sockname,ccode) $+ ) - Cidade:  $+ $hget($sockname,city) $+ .
  }
  hfree -w $sockname
}
alias ipwhois {
  if (!$1) {  }
  if (!$2) { msg $1 Erro, está faltando o IP/host. }
  elseif (*.* !iswm $2) { msg $1 IP ou Host invalido. }
  else {
    var %s = whois_ $+ $r(1,$ticks)
    sockopen %s www.dnsstuff.com 80
    hadd -m %s chan $1
    hadd %s ip $2
  }
}