Code: Select all
bind pubm - * rss-chckurl
proc rss-chckurl {n u h c t} {
set zazz {http://vbox7.*/play:([A-Za-z0-9_\-]+)}
if {[regexp $zazz $t match fluff video_id]} {
set url "$match"
szazz $url $c
}
}
proc szazz {url c {refer ""} {cookies ""} { re 0 }} {
http::config -useragent "Opera/9.80 (Windows NT 5.1; U; bg) Presto/2.6.30 Version/10.62"
# if we have cookies, let's use em ;)
if {![string length $cookies]} {
catch {set token [http::geturl $url -timeout 10000]} error
} else {
catch {set token [::http::geturl $url -headers [list "Referer" "$refer" "Cookie" "[string trim [join $cookies {;}] {;}]" ] -timeout 10000]} error
}
# error condition 1, invalid socket or other general error
if {![string match -nocase "::http::*" $error]} {
putlog "Error: [string totitle [string map {"\n" " | "} $error]] \( $url \)"
return 0
}
# error condition 2, http error
if {![string equal -nocase [::http::status $token] "ok"]} {
putlog "Http error: [string totitle [::http::status $token]] \( $url \)"
http::cleanup $token
return 0
}
upvar #0 $token state
# iterate through the meta array to grab cookies
foreach {name value} $state(meta) {
# do we have cookies?
if {[regexp -nocase ^Set-Cookie$ $name]} {
# yes, add them to cookie list
lappend ourCookies [lindex [split $value {;}] 0]
}
}
# if no cookies this iteration remember cookies from last
if {![info exists ourCookies] && [string length $cookies]} {
set ourCookies $cookies
}
# recursive redirect support, 300's
# the full gambit of browser support, hopefully ... ;)
if {[string match "*[http::ncode $token]*" "303|302|301" ]} {
foreach {name value} $state(meta) {
if {[regexp -nocase ^location$ $name]} {
if {![string match "http*" $value]} {
# fix our locations if needed
if {![string match "/" [string index $value 0]]} {
set value "[join [lrange [split $url "/"] 0 2] "/"]/$value"
putlog "$value"
} else {
set value "[join [lrange [split $url "/"] 0 2] "/"]$value"
putlog "$value"
}
}
# catch redirect to self's. There is one rule:
# A url can redirect to itself a few times to attempt to
# gain proper cookies, or referers. This is hard-coded at 2.
# We catch the 3rd time and poison our recursion with it.
# This will stop the madness ;)
if {[string match [string map {" " "%20"} $value] $url]} {
if {![info exists poison]} {
set poison 1
} else {
incr poison
if {$poison > 2} {
putlog "HTTP Error: Redirect error self to self \(3rd instance poisoned\) \( $url \)"
return
}
}
}
# poison any nested recursion over 10 traversals deep. no legitimate
# site needs to do this. EVER!
if {[incr re] > 10} {
putlog "HTTP Error: Redirect error (>10 too deep) \( $url \)"
return
}
# recursive redirect by passing cookies and referer
# this is what makes it now work! :)
szazz [string map {" " "%20"} $value] $url $c $ourCookies $re
# only the last iteration from our recursion is required
# we save time by using return on prior recurses. this does
# not poison the recursion because we have invoked ourself
# before we poison the unneeded iteration.
return
}
}
}
# waaay down here, we finally check the ncode for 400 or 500 codes
if {[string match 4* [http::ncode $token]] || [string match 5* [http::ncode $token]]} {
putlog "Http resource is not evailable: [http::ncode $token] \( $url \)"
return 0
}
set html [split [::http::data $token] \n]
#regsub -all "\n" $html "" html
set f [open z.db w]
puts $f $html
close $f
# if {[regexp {<title>(.*?)</title>} $html - title]} { putquick "privmsg $c : $title" }
# ::http::cleanup $token
}
http://vbox7.com/show:missjavascript?ba ... 3A9b3eb2dc
http://vbox7.com/show:misscookie?back_t ... 3A9b3eb2dc
http://vbox7.com/show:missjavascript?ba ... 3A9b3eb2dc