Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit LoginFrame;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, FileUtil, IdHTTP, IdCookieManager, Forms,
- Controls, Graphics, Dialogs, StdCtrls, IdGlobalProtocols;
- type
- { TForm1 }
- TForm1 = class(TForm)
- Button_Login: TButton;
- Edit_Password: TEdit;
- Edit_UserName: TEdit;
- HTTP: TIdHTTP;
- IdCookieManager: TIdCookieManager;
- Label_Password: TLabel;
- Label_UserName: TLabel;
- Memo: TMemo;
- procedure Button_LoginClick(Sender: TObject);
- private
- { private declarations }
- public
- { public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.lfm}
- { TForm1 }
- procedure TForm1.Button_LoginClick(Sender: TObject);
- var
- Outputfile, Params: TStringList;
- content: string = '';
- stoken: string = '';
- tokenpos: integer = 0;
- whilecounter: integer = 0;
- state: boolean = true;
- Enc: TEncoding;
- begin
- Outputfile := TStringList.Create;
- HTTP.Request.UserAgent := 'Opera/9.80 (Windows NT 6.1; U; de) Presto/2.5.22 Version/10.51';
- content := HTTP.Get('http://mpgh.net/');
- HTTP.Disconnect(False);
- HTTP.IOHandler.InputBuffer.Clear();
- Outputfile.Text := content;
- Outputfile.SaveToFile('index.html');
- if content <> '' then
- begin
- tokenpos := Pos('name="s"', content);
- whilecounter := tokenpos + 8;
- if tokenpos > 0 then
- begin
- while state do
- begin
- if (content[whilecounter] = '=') and (content[whilecounter + 1] = '"') then
- begin
- whilecounter := whilecounter + 2;
- stoken := '';
- end
- else if content[whilecounter] = '"' then
- state := false
- else
- begin
- stoken := stoken + content[whilecounter];
- whilecounter := whilecounter + 1;
- end;
- end;
- end;
- end;
- if stoken <> '' then
- begin
- HTTP.Request.ContentType := 'application/x-www-form-urlencoded';
- Params := TStringList.Create;
- with Params do
- begin
- Add('vb_login_username=' + Edit_UserName.Text);
- Add('vb_login_password=' + Edit_Password.Text);
- Add('s=' + stoken);
- Add('securitytoken=guest');
- Add('do=login');
- Add('vb_login_md5password=');
- Add('vb_login_md5password_utf=')
- end;
- try
- //HTTP.Post('http://mpgh.net/forum/login.php?do=login', Params);
- except
- on E: EIdHTTPProtocolException do
- begin
- ShowMessage(IntToStr(http.ResponseCode));
- end;
- end;
- Outputfile.Text := content;
- Outputfile.SaveToFile('afterlogin.html');
- end;
- Outputfile.Free;
- Params.Free;
- end;
- {
- <form id="navbar_loginform" action="" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 1)">
- <fieldset>
- <div>
- <div style="width: 100%;">
- <div style="float: left; padding: 3px"><div style="float: left; width: 60px; height: 15px; padding: 3px 10px 0 5px;">Username</div><input style="height: 22px; width: 100px; padding: 0 5px;" type="text" class="textbox" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" /></div>
- <div style="float: left; padding: 3px"><input type="checkbox" name="cookieuser" value="1" id="cb_cookieuser_navbar" class="cb_cookieuser_navbar" accesskey="c" tabindex="103" /> Remember Me?</div>
- </div>
- <div style="width: 100%; clear: both;">
- <div style="float: left; padding: 3px"><div style="float: left; width: 60px; height: 15px; padding: 3px 10px 0 5px;">Password</div><input style="height: 22px; width: 100px; padding: 0 5px;" type="password" class="textbox" tabindex="102" name="vb_login_password" id="navbar_password" size="10" /><input style="height: 22px; width: 100px; padding: 0 5px; display: none;" type="text" class="textbox default-value" tabindex="102" name="vb_login_password_hint" id="navbar_password_hint" size="10" value="Password" /></div>
- <div style="float: left; padding: 3px"><input type="submit" class="loginbutton" tabindex="104" value="Log in" title="Enter your username and password in the boxes provided to login, or click the 'register' button to create a profile for yourself." accesskey="s" /></div>
- </div>
- </div>
- </fieldset>
- <input type="hidden" name="s" value="ab07f01e3c16e2633c5a0681304dd525" />
- <input type="hidden" name="securitytoken" value="guest" />
- <input type="hidden" name="do" value="login" />
- <input type="hidden" name="vb_login_md5password" />
- <input type="hidden" name="vb_login_md5password_utf" />
- </form> }
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement