alias -l e echo -ac info * Future-FTA: $1-
[color:red] [/color]
alias future-fta.check {
if (!%future-fta.cookie) {
if ($0 != 2) tokenize 32 $input(Please enter your username,eo) $input(Please enter your password,po)
sockopen future-fta.login future-fta.info 80
sockmark future-fta.login $1 $md5($2)
e logging in to forum... please stand by.
}
elseif (%future-fta.lastcheck) {
e The forum requires for you to wait atleast $ifmatch seconds before performing a new search.
}
elseif (!%future-fta.searchid) {
sockopen future-fta.searchid future-fta.info 80
sockmark future-fta.searchid do=getnew
e retrieving a searchid in order to check new posts... please hold on.
}
else {
.fopen -o future-fta.check tmp
sockopen future-fta.check future-fta.info 80
sockmark future-fta.check searchid= $+ %future-fta.searchid
e checking for new posts on forums... this may take a while.
}
}
[color:red] [/color]
on *:sockopen:future-fta.*:{
var %s = $sockname, %sw = sockwrite -tn %s
if ($sockerr) { e Error connecting to $sockname $+ , please try again. | halt }
if ($gettok(%s,2,46) == login) {
tokenize 32 $sock(%s).mark
var %data = $+(vb_login_username=,$1,&cookieuser=1&vb_login_password=&s=&do=login&vb_login_md5password=,$2,&vb_login_md5password_utf=,$2)
%sw POST /Forums/login.php?do=login HTTP/1.0
%sw Referer: http://www.future-fta.info/Forums/
%sw Content-Type: application/x-www-form-urlencoded
%sw Content-Length: $len(%data)
%sw Host: www.future-fta.info
%sw
%sw %data
}
else {
%sw GET /Forums/search.php? $+ $sock(%s).mark HTTP/1.0
%sw Cookie: %future-fta.cookie
%sw Host: www.future-fta.info
%sw
}
}
[color:red] [/color]
on *:sockread:future-fta.*:{
var %in, %s = $sockname, %type = $gettok(%s,2,46)
if (%type == login) {
sockread -f %in
tokenize 32 $left(%in,930)
if ($1 == Set-Cookie:) {
%future-fta.cookie = %future-fta.cookie $2
}
elseif (* !iswm $1) {
sockclose %s
if (*bbuserid=*; bbpassword=* !iswm %future-fta.cookie) {
e Incorrect username/password or an error has occured, please try again.
}
else future-fta.check
}
}
elseif (%type == searchid) {
sockread -f %in
if (!%future-fta.searchid) && ($regex(%s,%in,/URL=http\S+?searchid=(\d+)/)) {
sockclose %s
%future-fta.searchid = $regml(%s,1)
future-fta.check
}
}
else {
sockread &in
while ($sockbr) {
.fwrite -b %s &in
sockread &in
}
}
}
[color:red] [/color]
on *:sockclose:future-fta.check: {
.fclose $sockname
unset %future-fta.searchid
set -z %future-fta.lastcheck 110
future-fta.parse
}
[color:red] [/color]
alias future-fta.parse {
var %size = $file(tmp), %pos = 1, %id = future-fta, %i = 1, %t
if (!%size) { e no data was saved to tmp file. | return }
bread tmp 0 %size &in
if ($hget(%id)) hfree %id
hmake %id
while ($bfind(&in,%pos,id="thread_title_)) {
%pos = $v1
%t = $regex(a,$bvar(&in,%pos,930).text,/:bold">(.+?)<.+?title="Replies: (\d+)\54 Views: (\d+).+?white-space:nowrap"> (\S+) <span class="time">(.+?)</span>/i)
inc %pos $regml(a,5).pos
%t = $regex(b,$bvar(&in,%pos,930).text,/by <a href=.+?>(\S+?)<.+?forumdisplay.+?>(.+?)</a>/i)
%t = $chr(127)
hadd %id %i $+($regml(b,2),%t,$regml(a,1),%t,$regml(a,3),%t,$regml(a,2),%t,$regml(b,1),%t,$regml(a,4) $regml(a,5))
inc %i
}
.signal %id $calc(%i -1)
}
[color:red] [/color]
on *:signal:future-fta:{
e Found $1 new posts, stored in hash table future-fta
future-fta.shownew
}
[color:red] [/color]
alias future-fta.shownew {
var %a = 1
while ($hget(future-fta,%a)) {
tokenize 127 $ifmatch
echo -a # $+ %a
echo -a Forum: $1
echo -a Thread: $2
echo -a Views: $3 - Replies: $4
echo -a Last post by: $5, $6
echo -a
inc %a
}
}