1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
IdHTTP1: TIdHTTP;
uniselector: TComboBox;
login: TEdit;
pass: TEdit;
procedure uniselectorChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
AdresseUnivers : string;
implementation
{$R *.dfm}
//*************************************
//Differentes Fonctions
//*************************************
procedure DownloadHTTP(const AUrl : string; out DestStream: TStream; const APort : integer = 80);
var
Port : integer;
begin
with TIdHTTP.Create(Application) do
try
Port := APort;
try
Get(AUrl,DestStream);
except
On e : Exception do
MessageDlg(Format('Erreur : %s',[e.Message]), mtInformation, [mbOK], 0);
end;
finally
Free;
end;
end;
//********************************
//Gestion de la Combobox
//*******************************
procedure TForm1.FormCreate(Sender: TObject);
begin
uniselector.AddItem('31. Univers', TObject(1));
uniselector.AddItem('2. Univers', TObject(2));
end;
procedure TForm1.uniselectorChange(Sender: TObject);
begin
showmessage(inttostr(uniselector.ItemIndex));
if uniselector.ItemIndex = 0 then AdresseUnivers := 'ogame311.de';
if uniselector.ItemIndex = 1 then AdresseUnivers := 'ogame290.de';
end;
//****************************
//Login
//****************************
procedure TForm1.Button1Click(Sender: TObject);
var
Fs : TFileStream;
Ts : TStringList;
url : string;
begin
Ts := TStringList.Create;
Fs := TFileStream.Create('c:\test.txt',fmCreate);
try
url := 'http://'+AdresseUnivers+'/game/reg/login2.php';
//Ajout des données login et pass
Ts.Add('login='+login.text);
Ts.Add('pass='+pass.text);
IdHttp1.Request.ContentType := 'application/x-www-form-urlencoded';
//Envoie de la requete de download
showmessage(url);
IdHTTP1.Post(url,Ts,TStream(fs)) ;
//DownloadHTTP('http://ogame311.de/game/reg/login2.php',TStream(fs));
finally
Fs.Free;
end;
end;
end. |
Partager