-
Notifications
You must be signed in to change notification settings - Fork 0
/
PostErrorReport.pas
144 lines (126 loc) · 3.76 KB
/
PostErrorReport.pas
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
unit PostErrorReport;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, ExtCtrls, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdHTTP, IdMultipartFormData, clipbrdfunctions,
Prog_Unit;
type
Tfrm_postErrorReport = class(TForm)
Timer1: TTimer;
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ComboBox1: TComboBox;
Label4: TLabel;
Label5: TLabel;
mem_desc: TMemo;
Label6: TLabel;
txt_browser: TEdit;
Button1: TButton;
ProgressBar1: TProgressBar;
Button2: TButton;
HTTP: TIdHTTP;
Label7: TLabel;
txt_email: TEdit;
procedure Timer1Timer(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormHide(Sender: TObject);
procedure HTTPWorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure HTTPWork(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
procedure HTTPWorkEnd(Sender: TObject; AWorkMode: TWorkMode);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
frm_postErrorReport: Tfrm_postErrorReport;
implementation
{$R *.dfm}
uses main, DateUtils;
procedure Tfrm_postErrorReport.Timer1Timer(Sender: TObject);
var s: string;
begin
s := FRM_Main.GetClipboardText();
if s <> Memo1.Text then
Memo1.Text := s;
end;
procedure Tfrm_postErrorReport.FormShow(Sender: TObject);
begin
Timer1.Enabled := true;
end;
procedure Tfrm_postErrorReport.FormHide(Sender: TObject);
begin
Timer1.Enabled := false;
end;
procedure Tfrm_postErrorReport.HTTPWorkBegin(Sender: TObject;
AWorkMode: TWorkMode; const AWorkCountMax: Integer);
begin
ProgressBar1.Position := 0;
ProgressBar1.Max := AWorkCountMax;
end;
procedure Tfrm_postErrorReport.HTTPWork(Sender: TObject;
AWorkMode: TWorkMode; const AWorkCount: Integer);
begin
ProgressBar1.Position := AWorkCount;
Application.ProcessMessages;
end;
procedure Tfrm_postErrorReport.HTTPWorkEnd(Sender: TObject;
AWorkMode: TWorkMode);
begin
ModalResult := mrOk;
end;
procedure Tfrm_postErrorReport.Button1Click(Sender: TObject);
var
Stream: TStringStream;
Params: TIdMultipartFormDataStream;
filename: string;
begin
mem_desc.Lines.Add('------------------');
mem_desc.Lines.Add('content-type:' + ComboBox1.Text);
mem_desc.Lines.Add('browser:' + txt_browser.Text);
mem_desc.Lines.Add('email:' + txt_email.Text);
mem_desc.Lines.Add('cS-version:' + VNumber);
filename := ExtractFilePath(Application.ExeName) +
'postreport_' + IntToStr(DateTimeToUnix(now)) + '.bin';
clipbrdfunctions.SaveClipboardtoFile(filename,
mem_desc.Text,
ODataBase.LanguagePlugIn.PlugInName,
ODataBase.game_domain,
ODataBase.UniDomain);
try
Stream := TStringStream.Create('');
try
Params := TIdMultipartFormDataStream.Create;
try
Params.AddFile('File1', filename, 'application/octet-stream');
try
HTTP.Post('http://www.creaturescan.creax.de/upload/post.php',
Params, Stream);
mem_desc.Clear;
ShowMessage('Send ErrorReport Completed!');
except
on E: Exception do
ShowMessage('Error encountered during POST: ' + E.Message);
end;
if length(Stream.DataString) > 0 then
begin
ShowMessage(Stream.DataString);
mem_desc.Lines.Add('Last Response: ' + Stream.DataString);
end;
finally
Params.Free;
end;
finally
Stream.Free;
end;
except
end;
DeleteFile(filename);
end;
end.