mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2004
Posts: 10
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Nov 2004
Posts: 10
Hi again..i have putten my koc project temp in the freezer :P

Im trying to get more knowledge with GET / POST and cookies
I have the next problem : (this is my whole code)

alias -l extractcookie {
%x = $mid($1-, $pos($1-, $chr(61), 1),50)
%x = $remove(%x, $chr(61))
%y = $pos(%x, $chr(59), 1) - 1
return $mid(%x, 1, %y)
}

alias boardlogin {
sockclose boardlogin
sockopen boardlogin s8.invisionfree.com 80
}

on *:sockopen:boardlogin: {
var %a sockwrite -n $sockname
var %board.login = $+(UserName=Super Koe,$chr(38),PassWord=12345678,$chr(38),submit=Log me in)
%a POST /Elite_Reloaded/index.php?act=Login&CODE=01 HTTP/1.1
%a Host: s8.invisionfree.com
%a Content-Type: application/x-www-form-urlencoded; charset="utf-8"
%a Content-Length: $calc($len(%board.login) +1)
sockwrite -n $sockname
%a %board.login
}

on *:sockread:boardlogin: {
if ($sockerr > 0) return
sockread %boardlogin.tmp
if ($sockbr == 0) return
write files\boardlogin.txt %boardlogin.tmp
}

This part works perfectly...in the boardlogin.txt im getting this :

HTTP/1.1 200 OK
Date: Mon, 08 Nov 2004 17:31:47 GMT
Server: Apache
X-Powered-By: PHP/4.3.4
Set-Cookie: Elite_Reloadedforum_read=deleted; expires=Sun, 09-Nov-03 17:31:47 GMT; path=/; domain=.invisionfree.com
Set-Cookie: Elite_Reloadedtopicsread=deleted; expires=Sun, 09-Nov-03 17:31:47 GMT; path=/; domain=.invisionfree.com
Set-Cookie: Elite_Reloadedsession_id=4cb7810f1345758ea019d76070b6d64f; path=/Elite_Reloaded; domain=.invisionfree.com
Set-Cookie: Elite_Reloadedsession_id=99b949b0909971f90f5a3c56eb735134; path=/Elite_Reloaded; domain=.invisionfree.com
Cache-Control: no-cache, must-revalidate, max-age=0
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Pragma: no-cache
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1
1fa8
~~ skiping part ~~
<td width="100%" align="center">
Thanks,
you are now logged in as: Super Koe<br /><br />
Please wait while we transfer you...<br /><br />
(<a href='http://s8.invisionfree.com/Elite_Reloaded/index.php?s=4cb7810f1345758ea019d76070b6d64f&amp;'>Or click here if you do not wish to wait</a>)


on *:sockclose:boardlogin: {
var %something = $read(files\boardlogin.txt, w, *session*)
var %readline = $readn
var %LOGIN1.RAW = $read(files\boardlogin.txt, %readline)
var %readline = $readn + 1
var %LOGIN2.RAW = $read(files\boardlogin.txt, %readline))
var %hash1.login = $extractcookie(%LOGIN1.RAW)
var %hash2.login = $extractcookie(%LOGIN2.RAW)
readboard
}

alias readboard {
sockclose readboard
sockopen readboard s8.invisionfree.com 80
}

on *:sockopen:readboard: {
var %a sockwrite -n $sockname
%a GET /Elite_Reloaded/index.php?showtopic=670
%a Host: s8.invisionfree.com
%a $sockname Content-type: text/html
%a Cookie: deleted; deleted; %hash1.login $+ ; %hash2.login
sockwrite -n $sockname
}

on *:sockread:readboard: {
if ($sockerr > 0) return
sockread %readboard.tmp
if ($sockbr == 0) return
write files\readboard.txt %readboard.tmp
}

but i cant getting loged in with the cookie.

Does somebody see errors in the code?

Joined: May 2003
Posts: 79
A
Babel fish
Offline
Babel fish
A
Joined: May 2003
Posts: 79
When you have to reload the page with the cookie, try adding "HTTP/1.1" at the end of the GET request, and also, try to add the "cookiename=cookievalue" instead of only the "cookievalue" (maybe adding only the value won't work as you have two values having the same name).

Joined: Nov 2004
Posts: 10
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Nov 2004
Posts: 10
You know what? HTTP/1.1 did it lol..omg im rewrote the script 3 times and every time i forgot HTTP/1.1 lol :P


Link Copied to Clipboard