; -----------------------------------------------------------------------------
; http://forums.xbconnect.com
; --
; https://forums.mirc.com/showflat.php?Cat=0&Number=171884&page=&vc=1
; -----------------------------------------------------------------------------
[color:red]; Name of the user logging in[/color]
alias -l xbc_username { return BotForTesting }
[color:red]; Password for the user[/color]
alias -l xbc_password { return testingbot }
; Hash table to store information
alias -l xbc_table { return xbc_info }
; Hash file
alias -l xbc_hfile { return xbc.hsh }
; -----------------------------------------------------------------------------
; mIRC Events
; -----------------------------------------------------------------------------
on *:LOAD: {
if ($version < 6.2) /echo -s Older version of mIRC Found--Not tested with $version (Recommends v6.2)
if (!$hget($xbc_table)) /hmake $xbc_table 10
if ($isfile($xbc_hfile)) /hload $xbc_table $xbc_hfile
}
on *:START: {
if (!$hget($xbc_table)) /hmake $xbc_table 10
if ($isfile($xbc_hfile)) /hload $xbc_table $xbc_hfile
}
on *:EXIT: {
if ($hget($xbc_table)) {
/hsave -o $xbc_table $xbc_hfile
/hfree $xbc_table
}
}
on *:UNLOAD: {
if ($hget($xbc_table)) /hfree $xbc_table
if ($isFile($xbc_hfile)) .remove $xbc_hfile
}
; -----------------------------------------------------------------------------
; Initial Login
; -----------------------------------------------------------------------------
alias xbc_login {
var %sock = xbc_login1
if ($sock(%sock)) .sockclose %sock
; clear login session
if ($hget($xbc_table)) {
/hfree $xbc_table
/hmake $xbc_table 10
}
.sockopen %sock forum.xbconnect.com 80
}
on *:SOCKOPEN:xbc_login1: {
if ($sockerr) {
/echo -s XBC Socket Error Could not connect (# $+ $sock($sockname).wserr $+ ) $sock($sockname).wsmsg
}
else {
var %post = vb_login_username= $+ $xbc_username $+ $&
& $+ cookieuser=1 $+ $&
& $+ vb_login_password= $+ $xbc_password $+ $&
& $+ do=login $+ $&
& $+ vb_login_md5password= $+ $&
& $+ vb_login_md5password_utf=
/sockwrite -n $sockname POST /login.php?do=login HTTP/1.1
/sockwrite -n $sockname Host: forum.xbconnect.com
/sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows; en-US) mIRC/ $+ $version
/sockwrite -n $sockname Accept: text/html, text/xml, */*;q=0.5
/sockwrite -n $sockname Accept-Language: en-us,en;q=0.5
/sockwrite -n $sockname Keep-Alive: 300
/sockwrite -n $sockname Connection: keep-alive
/sockwrite -n $sockname Referer: http://forum.xbconnect.com/
/sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
/sockwrite -n $sockname Content-Length: $len(%post)
/sockwrite -n $sockname $crlf
/sockwrite -tn $sockname %post
/sockmark $sockname 1
}
}
on *:SOCKREAD:xbc_login1: {
var %read
if ($sock($sockname).mark) {
/sockread %read
if (!%read) /sockmark $sockname
else {
if (Set-Cookie:* iswm %read) {
var %cookie = $gettok($gettok(%read,2-,32),1,59)
var %c_name = $gettok(%cookie,1,$asc(=)), %c_value = $gettok(%cookie,2-,$asc(=))
/hadd -m $xbc_table %c_name %c_value
}
}
}
else {
/sockread -n &read
; if you want to parse this or whatever, do so here. This is page content, not header information
}
}
on *:SOCKCLOSE:xbc_login1: {
/echo -s XBC Closed! Logging in to main page...
/xbc_visit
}
; -----------------------------------------------------------------------------
; Revisit using sessions
; -----------------------------------------------------------------------------
; use as just play /xbc_visit to get the main index page, or include the path
; of the page (less the domaine itself) to visit that page. e.g.
;
; /xbc_visit
; visits main page (index)
; /xbc_visit /showpost.php?p=97496&postcount=1
; visits post number 97496 (notice the http://www... is gone, / must remain)
;
; http://forum.xbconnect.com/showpost.php?p=97496&postcount=1
; \_____ Domain Name ______/\________ File Path ____________/
alias xbc_visit {
var %sock = xbc_login2
if ($hget($xbc_table,xbcbbuserid) && $hget($xbc_table,xbcbbpassword)) {
if ($sock(%sock)) .sockclose %sock
.sockopen %sock forum.xbconnect.com 80
if ($1-) { /sockmark %sock $1- }
else { /sockmark %sock $+(/?s=,$hget($xbc_table,xbcbbsessionhash),&) }
}
else {
/echo -s XBC Error: No session established
}
}
alias xbc_cookies {
var %i = $hget($xbc_table,0).item
while (%i) {
var %c_name = $hget($xbc_table,%i).item, %c_value = $hget($xbc_table,%c_name)
var %cookies = %cookies $+(%c_name,=,%c_value,$iif(%i > 1,;))
/dec %i
}
return %cookies
}
on *:SOCKOPEN:xbc_login2: {
if ($sockerr) {
/echo -s XBC Socket Error Could not connect (# $+ $sock($sockname).wserr $+ ) $sock($sockname).wsmsg
}
else {
/sockwrite -n $sockname GET $sock($sockname).mark HTTP/1.1
/sockwrite -n $sockname Host: forum.xbconnect.com
/sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows; en-US) mIRC/ $+ $version
/sockwrite -n $sockname Accept: text/html, text/xml, */*;q=0.5
/sockwrite -n $sockname Accept-Language: en-us,en;q=0.5
/sockwrite -n $sockname Keep-Alive: 300
/sockwrite -n $sockname Connection: keep-alive
/sockwrite -n $sockname Referer: http://forum.xbconnect.com/
/sockwrite -n $sockname Cookie: $xbc_cookies
/sockwrite -n $sockname $crlf
/sockmark $sockname 1
}
.remove index.html
}
on *:SOCKREAD:xbc_login2: {
var %read
if ($sock($sockname).mark) {
/sockread %read
if (!%read) /sockmark $sockname
}
else {
/sockread &read
/bwrite index.html -1 -1 &read
}
}
on *:SOCKCLOSE:xbc_login2: {
/echo -s XBC Closed! Main page gathered!
/bread index.html 1 $file(index.html).size &data
;.remove index.html
/echo -s XBC Page contents read in to & $+ data variable
}