That login page encodes the form data as POST. Sometimes GET and POST are interchangeable but it depends on the php script. Most likely you cannot substitute GET for POST.
sid is the php session id. It's different each time you log in. It must be passed also in every request sent to the web server. You have to request a web page from the server in order for it to assign you an sid.
So here's what I would try first:
1. Set up http request to
http://www.phpbbrasil.com.br/phpBB/ucp.php?mode=login2. Have your code scan the html reply for the sid . Ideally you would want to check one of the parameters of the http reply header in the lnet component, (for example, Parameters[hpReferer] or something like that), but in my experience all those parameters are blank for some reason. Maybe next version will be better.
3. Set up http request again to
http://www.phpbbrasil.com.br/phpBB/ucp.php?mode=loginthis time passing username, password, and sid as POST parameters. Of course, lnet doesn't support that without some code hacking.
Once logged in, every additional request must also pass the same sid obtained in step 2. PHP allows the session id to be passed either GET or POST.
The following code changes were done to lnet version 0.5.8.
In unit lhttp, find the following procedure and change to the following:
procedure TLHTTPClientSocket.SendRequest;
var
lMessage: TStringBuffer;
lTemp: string[23];
hasRangeStart, hasRangeEnd: boolean;
PostData: string;
ParamSepPos: integer;
begin
lMessage := InitStringBuffer(504);
{ If POST, split params from URI }
PostData := '';
if FRequest^.Method = hmPost then
begin
ParamSepPos := Pos('?', FRequest^.URI);
if ParamSepPos > 0 then
begin
PostData := copy(FRequest^.URI, ParamSepPos +1, length(FRequest^.URI) - ParamSepPos);
FRequest^.URI := copy(FRequest^.URI, 1, ParamSepPos - 1);
end
else
FRequest^.Method := hmGet;
end;
AppendString(lMessage, HTTPMethodStrings[FRequest^.Method]);
AppendChar(lMessage, ' ');
AppendString(lMessage, FRequest^.URI);
AppendChar(lMessage, ' ');
AppendString(lMessage, 'HTTP/1.1'+#13#10+'Host: ');
AppendString(lMessage, TLHTTPClient(FCreator).Host);
if TLHTTPClient(FCreator).Port <> 80 then
begin
AppendChar(lMessage, ':');
Str(TLHTTPClient(FCreator).Port, lTemp);
AppendString(lMessage, lTemp);
end;
AppendString(lMessage, #13#10);
hasRangeStart := TLHTTPClient(FCreator).RangeStart <> high(qword);
hasRangeEnd := TLHTTPClient(FCreator).RangeEnd <> high(qword);
if hasRangeStart or hasRangeEnd then
begin
AppendString(lMessage, 'Range: bytes=');
if hasRangeStart then
begin
Str(TLHTTPClient(FCreator).RangeStart, lTemp);
AppendString(lMessage, lTemp);
end;
AppendChar(lMessage, '-');
if hasRangeEnd then
begin
Str(TLHTTPClient(FCreator).RangeEnd, lTemp);
AppendString(lMessage, lTemp);
end;
end;
{ Add content-length and content-type headers for POST }
if FRequest^.Method = hmPost then
begin
AppendString(lMessage, 'Content-Length: ' + IntToStr(length(PostData)) + #13#10);
AppendString(lMessage, 'Content-Type: application/x-www-form-urlencoded' + #13#10);
end;
with FHeaderOut^.ExtraHeaders do
AppendString(lMessage, Memory, Pos-Memory);
AppendString(lMessage, #13#10);
{ Add Post data if applicable }
if FRequest^.Method = hmPost then
AppendString(lMessage, PostData);
AddToOutput(TMemoryOutput.Create(Self, lMessage.Memory, 0,
lMessage.Pos-lMessage.Memory, true));
AddToOutput(FCurrentInput);
WriteBlock;
end;