Sei sulla pagina 1di 2

; ip locator v1.

0 - entropy dalnet

;============================== menus

menu menubar,status,channel,query {
-
ip locator { locate }
-
}

;============================== dialogs

dialog locate {
title "ip locator"
size -1 -1 134 93
option dbu notheme
text "ip address", 1, 4 4 26 8, right
edit "", 2, 32 2 62 11
button "locate", 3, 96 2 34 11
text "status", 4, 4 16 25 8, right
edit "", 5, 32 14 62 11, read
text "city", 6, 4 34 25 8, right
text "state", 7, 4 43 25 8, right
text "country", 8, 4 52 25 8, right
text "isp", 9, 4 61 25 8, right
text "", 10, 32 34 98 8
text "", 11, 32 43 98 8
text "", 12, 32 52 98 8
text "", 13, 32 61 98 8
button "clipboard", 14, 62 78 34 11
button "ok", 15, 96 78 34 11, ok
box "", 16, -4 25 142 4
box "", 17, -3 70 142 4
}

;============================== aliases

alias -l locate {
if ($1) {
did -ra locate 5 opening socket...
did -r locate 10,11,12,13
sockclose locate
sockopen locate www.melissadata.com 80
sockmark locate $1-
}
else {
dialog $iif($dialog(locate),-x,-m) locate locate
}
}
alias -l striphtml {
var %txt = $mid($1-,1,800)
var %p = 1, %b =
$replace(%txt,$chr(38),$+($chr(32),$chr(38)),;,$+(;,$chr(32)),>,$+(>,$chr(32)),<,$
+($chr(32),<,)), %c
while ($gettok(%b,%p,32)) {
%c = $ifmatch
if (*<* iswm %c || *&*; iswm %c || *</* iswm %c || *solid* iswm %c || *px*
iswm %c || *:* iswm %c && $remove(%c,:) !isnum || */* iswm %c || *'* iswm %c ||
*;* iswm %c || *&* iswm %c || *<*>* iswm %c || *=* iswm %c || *"* iswm %c || *>*
iswm %c || $+(*,$chr(40),*) iswm %c || $+(*,$chr(41),*) iswm %c ||
$+(*,$chr(123),*) iswm %c || $+(*,$chr(125),*) iswm %c) { %b = $remove(%b,%c) | %p
= 0 }
inc %p
}
return %b
}
alias -l endlocate {
did -ra locate 5 transaction complete.
if (%ip) { did -ra locate 10 %city | did -ra locate 11 %state | did -ra locate
12 %country | did -ra locate 13 %isp }
else { did -r locate 10,11,12,13 | did -ra locate 5 nothing found. }
unset %isp
unset %ip
unset %city
unset %state
unset %country
unset %isp
}

;============================== events

on *:dialog:locate:sclick:14:{
var %a = ip: $did(2).text city: $did(10).text state: $did(11).text country:
$did(12).text isp: $did(13).text
clipboard %a
}
on *:dialog:locate:sclick:3:{
if (!$did(2).text) { beep | return }
locate $did(2).text
}
on *:sockopen:locate:{
if ($sockerr > 0 && $dialog(locate)) { did -ra locate 5 socket open error(s). |
did -r locate 10,11,12,13 | return }
sockwrite -n $sockname get
$+(/lookups/iplocation.asp?ipaddress=,$sock($sockname).mark) http/1.1
sockwrite -n $sockname host: $+(www.melissadata.com,$str($crlf, 2))
sockwrite -n $sockname connection: keep-alive
}
on *:sockread:locate:{
if ($sockerr > 0 && $dialog(locate)) { did -ra locate 5 socket read error(s). |
did -r locate 10,11,12,13 | return }
var %q
sockread %q
tokenize 32 $striphtml(%q)
did -ra locate 5 reading data...
if (* ip address *.*.*.* iswm $1-) { %ip = $4 }
if (* city * iswm $1-) { %city = $3- }
if (* state or region * iswm $1-) { %state = $5- }
if (* country * iswm $1-) { %country = $3- }
if (* isp * iswm $1-) { %isp = $3- }
.timertrace -o 1 1 endlocate $sock($sockname).mark
}

Potrebbero piacerti anche