The only e-mail i got regarding this, is one since 3 days ago from a user which uses this script, complaining it doesn't work
With this opportunity i release a new version of this script, it should appear on egghelp.org / TCL Archive on the next site update, but for now here it is:
Changes:
-added log in features
-fixed some functionality bugs
-set error message on error events
-updates to IP2location structure
IN WORK:
-----------
-multiple bots sharing the same caching file
-specify what IP address should the script use when fetching information (this requires of new version of HTTP package, reason for not implementing by now)
HOPE it works; I am awaiting suggestions for further development.
WEB: http://hwk.robits.org/internet/programa ... u-eggdrop/
Code: Select all
##########################################################################
# Public IP Info v0.3 by Hawkee - lowraider1@gmail.com #
#----------------------------------------------------------------------- #
# This script uses www.ip2location.com to check info for an ip adresses #
# It with both with and without ip2location account #
#
# Using it without a ip2location.com account limits the script
# functionality to 50 lookup's per day.
#
# If don't have a ip2location.com account your can register one for free #
# and get 200 look-up per day.
# #
# See the ip2location setting bellow #
# #
# Changes from version 0.2: #
# -fixed some bugs #
# -code optimizations #
# -updated the recognition format
# -more error information
# -implemented ip2location.com account #
# #
# #
# Works on all channels, and it can be used by all users. Requires TCL #
# HTTP PACK #
# #
# USAGE: !ipinfo <IP> #
# HAVE PHUN #
# Email me with suggestions and bug reports at lowraider1@gmail.com #
# #
# grtz HWK @ undernet #
#########################################################################
set ipinfo(useaccount) 1 ;#set this to 1 if you have a ip2location.com account and you want to use it
set ipinfo(i2lmail) "myemail@domain.com" ;#set the login e-mail address from ip2location.com
set ipinfo(i2lpass) "mypass" ;#set the account password from ip2location.com
set ipinfo(cachefile) "ipinfo.cache" ;#the cache file
set ipinfo(cacherefresh) "7" ;#the time (in days) to refresh the info for an IP
set ver "0.3"
#### END OF SETTINGs
#### edit with caution from here on
catch {array unset ipinfocache}
unset -nocomplain COOKIES
unset -nocomplain ::ipinfo(loginfailure)
package require http
set ipinfo(islogged) 0
proc ipinfo:parser {nick uhost hand chan args} {
set ip [string trimright [lindex $args 0] "."]
if {![regexp {^(?:(?:[01]?\d?\d|2[0-4]\d|25[0-5])(\.|$)){4}$} $ip]} {
puthelp "privmsg $chan :$nick NO/Invalid IP pattern. USAGE: !ipinfo 193.193.193.193"
putlog "IP INFO $chan $nick - INVALID IP PATTERN"
return
}
set infoip [ipinfo:output $ip]
if {[string equal [lindex $infoip 0] -]} {
puthelp "privmsg $chan :$nick No information found for IP: \00302$ip\003 please redefine your IP"
putlog "IP INFO $chan $nick - No results - SOMETHING MAY WENT WRONG"
return
}
set country [lindex $infoip 0]
set city [lindex $infoip 1]
set isp [lindex $infoip 2]
set domain [lindex $infoip 3]
puthelp "privmsg $chan :$nick IP information for \00302$ip\003: \002Country:\002 \00304$country\003, \002City:\002 \00304$city\003, \002ISP\002: \00302$isp\003, \002Domain:\002 \00302$domain\003"
putlog "IPinfo request: $nick on $chan"
}
proc ipinfo:dologin {} {
## getting login token
set login [::http::geturl "http://www.ip2location.com/login.aspx" -timeout 3000]
set logindata [::http::data $login]
::http::cleanup $login
## making sure we got the login method right
if {[regexp {<input type="hidden" name="__VIEWSTATE" value="([^<]+)" />} $logindata -> logtok]} {
set logque [::http::formatQuery __VIEWSTATE $logtok btnLogin.x 35 btnLogin.y 17 txtEmailAddress $::ipinfo(i2lmail) txtPassword $::ipinfo(i2lpass) chkRememberMe on]
set dologin [::http::geturl "http://www.ip2location.com/login.aspx" -timeout 3000 -query $logque]
if {[regexp {<span id="lblMessage" class="fontredsmall">(Invalid(.*))</span></center>} [::http::data $dologin]]} {
putlog "IP INFO: FAILED - INVALID ACCOUNT DETAILS (mail or password)"
return 0;
}
upvar \#0 $dologin state
set cookies [list]
foreach {name value} $state(meta) {
if {$name eq "Set-Cookie"} {lappend cookies [lindex [split $value {;}] 0];}
}
::http::cleanup $dologin
putlog "IP INFO: LOGGED IN"
return $cookies
}
putlog "IP INFO: FAILED - THE AUTH MECHANISM NOT compatible -- please e-mail: lowraider1@gmail.com with this issue"
return 0;
}
proc ipinfo:cookies {cookielist} {
return [list Cookie [join $cookielist {; }]]
}
proc ipinfo:getinfo {host} {
global ipinfo ipinfocache
::http::config -useragent "Mozilla/5.0 ; Gecko"
set headers {}
if {$::ipinfo(useaccount)} {
if {!$::ipinfo(islogged)} {
putlog "IP INFO: NOT LOGGED TRYING TO LOG IN";
set logstats [ipinfo:dologin]
if {$logstats != 0} {
set headers [ipinfo:cookies $logstats]
set ::COOKIES $headers
set ::ipinfo(islogged) 1
} else {
set ::ipinfo(loginfailure) 1
putlog "IP INFO: ERROR: LOGIN FAIL -- please check message";
}
} elseif {![info exists ::ipinfo(loginfailure)]} {
set headers $::COOKIES
}
}
set http_req [::http::geturl "http://www.ip2location.com/$host" -timeout 3000 -headers $headers]
set data [::http::data $http_req]
::http::cleanup $http_req
if {[regexp {<span id="dgLookup__ctl2_lblICountry">([^<]+)</span></td>} $data -> country]} {
regexp {<span id="dgLookup__ctl2_lblICity">([^<]+)</span></td>} $data -> city
regexp {<span id="dgLookup__ctl2_lblIISP">([^<]+)</span></td>} $data -> isp
regexp {<span id="dgLookup__ctl2_lblIDomain">([^<]+)</span></td>} $data -> domain
set info [list $country $city $isp $domain [unixtime]]
set ipinfocache($host) $info
} else {
putlog "IP INFO: Lookup FAILURE";
set info {-}
}
return $info
}
proc ipinfo:output {host} {
global ipinfo ipinfocache
if {[info exists ipinfocache($host)]} {
if {[expr {(60*60*24)*$ipinfo(cacherefresh)}] < [expr {[unixtime] - [lindex $ipinfocache($host) 4]}]} {
putlog "IPinfo: refreshing cache data for $host"
set info [ipinfo:getinfo $host]
ipinfo:save
return $info
} else {
return $ipinfocache($host)
}
} else {
set info [ipinfo:getinfo $host]
ipinfo:save
return $info
}
}
proc ipinfo:save {} {
global ipinfo ipinfocache
set write [open $ipinfo(cachefile) w]
puts $write [list array set ipinfocache [array get ipinfocache]]
close $write
}
proc ipinfo:read {} {
global ipinfo ipinfocache
if {[file exists $ipinfo(cachefile)]} {
if {![catch {source $ipinfo(cachefile)} cacheerror]} {
putlog "IPinfo: cache file successfully loaded"
} else {
putlog "IPinfo: cache file failed to load -: $cacheerror"
putlog "IPinfo: trying to fix cache file: reset" ; ipinfo:save
}
} else {
ipinfo:save
putlog "IPinfo: cache file written - first time use"
}
}
ipinfo:read
bind pub -|- !ipinfo ipinfo:parser
putlog "Public IP Info $ver by HAWKEE Successfuly loaded"