OSDN Git Service

・TBoard および TThreadItem のコンストラクタは
[gikonavigoeson/gikonavi.git] / Editor.pas
1 unit Editor;
2
3 interface
4
5 uses
6         Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
7         Dialogs, StdCtrls, ComCtrls, ExtCtrls, ToolWin, Menus, OleCtrls,
8 {$IF Defined(DELPRO) }
9         SHDocVw,
10 {$ELSE}
11         SHDocVw_TLB,
12 {$IFEND}
13         ActiveX, {HTTPApp,} YofUtils, Trip, IniFiles, StrUtils,
14         GikoSystem, GikoUtil, ImgList, Clipbrd, BoardGroup,
15         IdAntiFreezeBase,       IdAntiFreeze, IdBaseComponent, IdComponent,
16         IdTCPConnection, IdTCPClient, IdHTTP, ActnList, StdActns, IdIntercept,
17         IdLogBase, IdLogDebug, IdException;
18
19 type
20 //      TSetLayeredWindowAttributes = function(wnd: HWND; crKey: DWORD; bAlpha: BYTE; dwFlag: DWORD): Boolean; stdcall;
21         //\8f\91\82«\8d\9e\82Ý\96ß\82è\92l\83^\83C\83v
22         TGikoResultType = (grtOK, grtCookie, grtCheck, grtError);
23
24         TEditorForm = class(TForm)
25                 MainMenu: TMainMenu;
26                 FileMenu: TMenuItem;
27                 PostMessage: TMenuItem;
28                 SaveMessage: TMenuItem;
29                 CloseMenu: TMenuItem;
30                 N01: TMenuItem;
31                 StatusBar: TStatusBar;
32                 EditorPage: TPageControl;
33                 EditorTab: TTabSheet;
34                 PreviewTab: TTabSheet;
35                 Browser: TWebBrowser;
36                 EditMenu: TMenuItem;
37                 UndoMenu: TMenuItem;
38                 CutMenu: TMenuItem;
39                 CopyMenu: TMenuItem;
40                 PasteMenu: TMenuItem;
41                 N02: TMenuItem;
42                 ToolBarImageList: TImageList;
43                 HotToobarImageList: TImageList;
44                 BodyEdit: TMemo;
45                 NameBasePanel: TPanel;
46                 NameLabel: TLabel;
47                 MailLabel: TLabel;
48                 NameComboBox: TComboBox;
49                 MailComboBox: TComboBox;
50                 ToolBar: TToolBar;
51                 SendToolButton: TToolButton;
52                 OutBoxToolButton: TToolButton;
53                 ToolButton5: TToolButton;
54                 UndoToolButton: TToolButton;
55                 CutToolButton: TToolButton;
56                 CopyToolButton: TToolButton;
57                 PasteToolButton: TToolButton;
58                 ToolButton3: TToolButton;
59                 TransToolButton: TToolButton;
60                 TopToolButton: TToolButton;
61                 Indy: TIdHTTP;
62                 IdAntiFreeze: TIdAntiFreeze;
63                 ToolButton1: TToolButton;
64                 ToolButton2: TToolButton;
65                 ActionList: TActionList;
66                 SendAction: TAction;
67                 SaveAction: TAction;
68                 CloseAction: TAction;
69                 UndoAction: TAction;
70                 CutAction: TAction;
71                 CopyAction: TAction;
72                 PasteAction: TAction;
73                 AbortAction: TAction;
74                 TopAction: TAction;
75                 Show1: TMenuItem;
76                 T1: TMenuItem;
77                 N1: TMenuItem;
78                 S1: TMenuItem;
79                 SageCheckBox: TCheckBox;
80                 IdLogDebug: TIdLogDebug;
81                 TransAction: TAction;
82                 A1: TMenuItem;
83                 KotehanCheckBox: TCheckBox;
84                 TitlePanel: TPanel;
85                 Label1: TLabel;
86                 TitleEdit: TEdit;
87                 SelectAllAction: TAction;
88                 N2: TMenuItem;
89                 SelectAll1: TMenuItem;
90                 procedure EditorPageChange(Sender: TObject);
91                 procedure FormCreate(Sender: TObject);
92                 procedure BrowserStatusTextChange(Sender: TObject;
93                         const Text: WideString);
94                 procedure FormClose(Sender: TObject; var Action: TCloseAction);
95                 procedure FormDestroy(Sender: TObject);
96                 procedure SendActionExecute(Sender: TObject);
97                 procedure SaveActionExecute(Sender: TObject);
98                 procedure AbortActionExecute(Sender: TObject);
99                 procedure CloseActionExecute(Sender: TObject);
100                 procedure UndoActionExecute(Sender: TObject);
101                 procedure CutActionExecute(Sender: TObject);
102                 procedure CopyActionExecute(Sender: TObject);
103                 procedure PasteActionExecute(Sender: TObject);
104                 procedure SendActionUpdate(Sender: TObject);
105                 procedure SaveActionUpdate(Sender: TObject);
106                 procedure CloseActionUpdate(Sender: TObject);
107                 procedure UndoActionUpdate(Sender: TObject);
108                 procedure CutActionUpdate(Sender: TObject);
109                 procedure CopyActionUpdate(Sender: TObject);
110                 procedure PasteActionUpdate(Sender: TObject);
111                 procedure TopActionExecute(Sender: TObject);
112                 procedure TopActionUpdate(Sender: TObject);
113                 procedure SageCheckBoxClick(Sender: TObject);
114                 procedure MailComboBoxChange(Sender: TObject);
115                 procedure TransActionExecute(Sender: TObject);
116                 procedure TransActionUpdate(Sender: TObject);
117                 procedure IdLogDebugReceive(ASender: TIdConnectionIntercept;
118                         AStream: TStream);
119                 procedure IdLogDebugSend(ASender: TIdConnectionIntercept;
120                         AStream: TStream);
121                 procedure SelectAllActionExecute(Sender: TObject);
122         private
123                 FThreadItem: TThreadItem;
124                 FBoard: TBoard;
125                 FNameComboEdit: THandle;
126                 FMailComboEdit: THandle;
127                 FAbort: Boolean;
128                 FWork: Boolean;
129                 FStatusCode: Integer;
130                 FDebugStrReceive: string;
131                 FDebugStrSend: string;
132
133                 procedure Preview;
134                 function RepHtml(s: string): string;
135                 function Check: Boolean;
136                 procedure SetNameList(sName, sMail: string);
137 //              procedure Send(SendType: TGikoSendType; SPID: string; PON: string; FirstWriting: Boolean);
138                 procedure Send(SPID: string; PON: string; FirstWriting: Boolean);
139
140                 function GetActiveControlHandle: THandle;
141 //              function GetSendData: string;
142 //              procedure GetSendData(Source: TStringStream);
143                 procedure GetSendData(Source: TStringStream);
144                 procedure SaveSendFile;
145                 procedure SetContent(Content: string);
146                 function GetSPID(CookieLine: string): string;
147                 function GetPON(CookieLine: string): string;
148                 function GetResultType(ResponseText: string): TGikoResultType;
149         protected
150                 procedure CreateParams(var Params: TCreateParams); override;
151         public
152                 procedure SetFont;
153                 procedure SetThreadItem(Item: TThreadItem);
154                 procedure SetBoard(Item: TBoard);
155         end;
156
157 implementation
158
159 uses
160         Giko, ItemDownload;
161 const
162         CAPTION_NAME_NEW: string = '\83M\83R\83i\83\83X\83\8c\97§\82Ä\83G\83f\83B\83^';
163         CAPTION_NAME_RES: string = '\83M\83R\83i\83\83\8c\83X\83G\83f\83B\83^';
164
165         //DAX\82³\82ñ±Ø¶ÞÄ!(\81L\81¤\81M)
166         READCGI_ERR                     = '-ERR';
167         READCGI_INCR            = '-INCR';
168         READCGI_OK                      = '+OK';
169         READCGI_PARTIAL = '+PARTIAL';
170         READCGI_ERR_FOUND_KAKO  = '-ERR \89ß\8b\8e\83\8d\83O\91q\8cÉ\82Å\94­\8c©';
171         READCGI_ERR_NOT_HTML            = '-ERR html\89»\91Ò\82¿';
172         READCGI_ERR_NOT_FOUND           = '-ERR \82»\82ñ\82È\94Âor\83X\83\8c\83b\83h\82È\82¢\82Å\82·\81B';
173         READCGI_ERR_ABONE                               = '-ERR \82Ç\82±\82©\82Å\82 \82Ú\81[\82ñ\82ª\82 \82Á\82½\82Ý\82½\82¢\82Å\82·\81B';
174         READCGI_ERR_TIMEOUT                     = '-ERR \8ew\92è\8e\9e\8aÔ\82ª\89ß\82¬\82Ü\82µ\82½\81B';
175         READCGI_ERR_CANTUSE                     = '-ERR \82à\82¤\81@\82Â\82©\82¦\82Ü\82¹\82ñ';
176         RES2CH_TRUE                             = '<!-- 2ch_X:true -->';
177         RES2CH_FALSE                    = '<!-- 2ch_X:false -->';
178         RES2CH_ERROR                    = '<!-- 2ch_X:error -->';
179         RES2CH_CHECK                    = '<!-- 2ch_X:check -->';
180         RES2CH_COOKIE                   = '<!-- 2ch_X:cookie -->';
181
182 type
183         TSelection = record
184                 StartPos, EndPos: Integer;
185         end;
186
187 {$R *.DFM}
188
189 {constructor TEditorForm.Create(AOwner: TComponent; Item: TBoard);
190 begin
191         inherited Create(AOwner);
192 end;}
193
194 procedure TEditorForm.CreateParams(var Params: TCreateParams);
195 begin
196         inherited;
197         if FormStyle in [fsNormal, fsStayOnTop] then
198                 if BorderStyle in [bsSingle, bsSizeable] then begin
199                         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
200                         Params.WndParent := 0;
201                 end;
202 end;
203
204 {procedure TEditorForm.CreateParams(var Params: TCreateParams);
205 begin
206         inherited CreateParams(Params);
207         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
208 end;}
209
210 procedure TEditorForm.FormCreate(Sender: TObject);
211 var
212         wp: TWindowPlacement;
213                 hUser32 : HINST;
214 begin
215         FWork := False;
216         Browser.Navigate('about:blank');
217
218         FBoard := nil;
219         FThreadItem := nil;
220
221         //\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\90Ý\92è
222 {       i := GikoSys.Setting.EditWindowLeft +
223                          GikoSys.Setting.EditWindowTop +
224                          GikoSys.Setting.EditWindowWidth +
225                          GikoSys.Setting.EditWindowHeight;
226         if i > 0 then begin
227                 SetBounds(GikoSys.Setting.EditWindowLeft, GikoSys.Setting.EditWindowTop,
228                                                         GikoSys.Setting.EditWindowWidth, GikoSys.Setting.EditWindowHeight);
229                 if GikoSys.Setting.EditWindowMax then
230                         WindowState := wsMaximized;
231         end;}
232         //\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\90Ý\92è
233         wp.length := sizeof(wp);
234         wp.rcNormalPosition.Top := GikoSys.Setting.EditWindowTop;
235         wp.rcNormalPosition.Left := GikoSys.Setting.EditWindowLeft;
236         wp.rcNormalPosition.Bottom := GikoSys.Setting.EditWindowTop + GikoSys.Setting.EditWindowHeight;
237         wp.rcNormalPosition.Right := GikoSys.Setting.EditWindowLeft + GikoSys.Setting.EditWindowWidth;
238         wp.showCmd := SW_HIDE;
239         SetWindowPlacement(Handle, @wp);
240
241         if GikoSys.Setting.EditWindowMax then
242                 WindowState := wsMaximized;
243
244         //\83E\83B\83\93\83h\83E\82ª\89æ\96Ê\8aO\82È\82ç\89æ\96Ê\93à\82É\88Ú\93®\82·\82é
245         if (Left + Width) > Screen.Width then
246                 Left := Screen.Width - Width;
247         if (Top + Height) > Screen.Height then
248                 Top := Screen.Height - Height;
249         if Left < 0 then
250                 Left := 0;
251         if Top < 0 then
252                 Top := 0;
253
254         //\95\9d\82Æ\8d\82\82³\82ª0\82È\82ç\91å\82«\82­\82·\82é
255         if GikoSys.Setting.EditWindowHeight < 0 then
256                 Height := 400;
257         if GikoSys.Setting.EditWindowWidth < 0 then
258                 Width := 600;
259
260         EditorPage.ActivePage := EditorTab;
261         FNameComboEdit := GetWindow(NameComboBox.Handle, GW_CHILD);
262         FMailComboEdit := GetWindow(MailComboBox.Handle, GW_CHILD);
263         NameComboBox.Items.Assign(GikoSys.Setting.NameList);
264         MailComboBox.Items.Assign(GikoSys.Setting.MailList);
265         SetFont;
266         //u32 := GetModuleHandle('User32.dll') <> 0;
267                 hUser32 := LoadLibrary('User32.dll');
268                 if hUser32 <> 0 then
269                         TransAction.Enabled := true
270                 else
271                                 TransAction.Enabled := false;
272                 FreeLibrary(hUser32);
273
274 end;
275
276 procedure TEditorForm.SetBoard(Item: TBoard);
277 begin
278         FBoard := Item;
279         Caption := CAPTION_NAME_NEW + ' - [' + Item.Title + ']';
280         NameComboBox.Text := FBoard.KotehanName;
281         MailComboBox.Text := FBoard.KotehanMail;
282         SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
283         TitlePanel.Visible := True;
284 end;
285
286 procedure TEditorForm.SetThreadItem(Item: TThreadItem);
287 begin
288         FThreadItem := Item;
289         Caption := CAPTION_NAME_RES + ' - [' + FThreadItem.Title + ']';
290         NameComboBox.Text := FThreadItem.ParentBoard.KotehanName;
291         MailComboBox.Text := FThreadItem.ParentBoard.KotehanMail;
292         SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
293         TitlePanel.Visible := False;
294 end;
295
296 procedure TEditorForm.SetFont;
297 begin
298         BodyEdit.Font.Name := GikoSys.Setting.EditorFontName;
299         BodyEdit.Font.Size := GikoSys.Setting.EditorFontSize;
300         BodyEdit.Font.Color := GikoSys.Setting.EditorFontColor;
301         BodyEdit.Color := GikoSys.Setting.EditorBackColor;
302 end;
303
304 procedure TEditorForm.Preview;
305 var
306         Title: string;
307         No: string;
308         Mail: string;
309         Namae: string;
310         DateTime: string;
311         Body: string;
312         s: string;
313
314                                 posTrip : Integer;
315                                 tripOrigin : string;
316 begin
317         if FThreadItem = nil then begin
318                 No := '1';
319                 Title := RepHtml(TitleEdit.Text);
320         end else begin
321                 No := IntToStr(FThreadItem.Count + 1);
322                 Title := RepHtml(FThreadItem.Title);
323         end;
324
325         Namae := RepHtml(NameComboBox.Text);
326         Mail := RepHtml(MailComboBox.Text);
327         Body := RepHtml(BodyEdit.Text);
328         Body := StringReplace(Body, #13#10, '<br>', [rfReplaceAll]);
329         DateTime := FormatDateTime('yyyy/mm/dd(aaa) hh:nn', now);
330
331         if Trim(Namae) = '' then
332                 Namae := '\96¼\96³\82µ\82³\82ñ';
333
334         s := '<HTML><HEAD>' + #13#10
335                         + '<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">' + #13#10
336                         + '<TITLE>' + title + '</TITLE>' + #13#10
337 //                      + '<STYLE><!--BODY{font-size : 9pt;font-family : "\82l\82\82o\83S\83V\83b\83N";}--></STYLE>' + #13#10
338                         + '</HEAD>' + #13#10
339                         + '<BODY text="#000000" bgcolor="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">' + #13#10
340                         + '<FONT COLOR="#FF0000">' + title + '</FONT>' + #13#10
341                         + '<DL>' + #13#10;
342                                 posTrip := Pos( '#', Namae );
343                                 if posTrip > 0 then
344                                 begin
345                                                                 tripOrigin := Copy( Namae, posTrip + 1, Length( Namae ) );
346                                                                 Namae :=
347                                                                                                 Copy( Namae, 1, posTrip - 1 ) + '</B> \81\9f' +
348                                                                                                 get_2ch_trip( PChar( tripOrigin ) ) + '<B>';
349                                 end;
350         if Mail = '' then
351                 s := s + '<DT>' + No + ' \81F <FONT color="forestgreen"><B>' + Namae + '</B></FONT> \81F ' + DateTime+ '<BR><DD>' + Body + '<BR><BR><BR>' + #13#10
352         else
353                 s := s + '<DT>' + No + ' \81F <A href="mailto:' + Mail + '"><B>' + Namae + '</B></A> [' + Mail + ']\81F ' + DateTime+ '<BR><DD>' + Body + '<BR><BR><BR>' + #13#10;
354         s := s + '</BODY></HTML>';
355         SetContent(s);
356 end;
357
358 function TEditorForm.RepHtml(s: string): string;
359 begin
360 //      s := StringReplace(s, '&', '&amp;', [rfReplaceAll]);
361         s := StringReplace(s, '<', '&lt;', [rfReplaceAll]);
362         s := StringReplace(s, '>', '&gt;', [rfReplaceAll]);
363 //      s := StringReplace(s, ' ', '&nbsp;', [rfReplaceAll]);   //\8ed\97l\95Ï\8dX\82É\82æ\82è&nbsp;\8eg\97p\95s\89Â
364         s := StringReplace(s, '"', '&quot;', [rfReplaceAll]);
365         Result := s;
366 end;
367
368 procedure TEditorForm.EditorPageChange(Sender: TObject);
369 begin
370         if EditorPage.ActivePage = PreviewTab then begin
371                 Preview;
372         end else begin
373                 Browser.Navigate('about:blank');
374         end;
375 end;
376
377 procedure TEditorForm.BrowserStatusTextChange(Sender: TObject;
378         const Text: WideString);
379 begin
380         if EditorPage.ActivePage = PreviewTab then begin
381                 StatusBar.Panels[0].Text := Text;
382         end else begin
383                 StatusBar.Panels[0].Text := '';
384         end;
385 end;
386
387 function TEditorForm.Check: Boolean;
388 var
389         Msg: string;
390         rc: Integer;
391         Board: TBoard;
392 begin
393         Result := True;
394         if FThreadItem = nil then
395                 Board := FBoard
396         else
397                 Board := FThreadItem.ParentBoard;
398
399         if (not GikoSys.Setting.UseMachineTime) and
400                  ((Board.LastGetTime = 0) or
401                         (Board.LastGetTime = ZERO_DATE)) then begin
402                 Msg := '\83T\81[\83o\82Ì\8e\9e\8d\8f\82ª\95ª\82©\82ç\82È\82¢\82½\82ß\81A\91\97\90M\8fo\97\88\82Ü\82¹\82ñ'#13#10
403                                  + '\83X\83\8c\83b\83h\82ð\8dX\90V\81i\8eæ\93¾\81j\8cã\81A15\95b\91Ò\82Á\82Ä\82©\82ç\91\97\90M\82µ\82Ä\82­\82¾\82³\82¢';
404                 MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
405                 Result := False;
406         end else if BodyEdit.Text = '' then begin
407                 Msg := '\96{\95\82ª\93ü\97Í\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B';
408                 MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
409                 Result := False;
410         end else if (FBoard <> nil) and (Trim(TitleEdit.Text) = '') then begin
411                 Msg := '\83^\83C\83g\83\8b\82ª\93ü\97Í\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B';
412                 MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
413                 Result := False;
414         end else begin
415                 if (not GikoSys.Dolib.Connected) and (AnsiPos('\81\9c', NameComboBox.Text) <> 0) then begin
416                         Msg := '\83\8d\83O\83C\83\93\82µ\82Ä\82¢\82È\82¢\82Ì\82Å\81\9c\82Ì\8b@\94\\82Í\97\98\97p\8fo\97\88\82Ü\82¹\82ñ\81B'#13#10
417                                          + '\82±\82Ì\82Ü\82Ü\91\97\90M\82µ\82Ä\82à\82æ\82ë\82µ\82¢\82Å\82·\82©\81H';
418                         rc := MsgBox(Handle, Msg, '\8am\94F', MB_YESNO or MB_ICONQUESTION);
419                         Result := (rc = IDYES);
420                 end;
421         end;
422 end;
423
424 procedure TEditorForm.FormClose(Sender: TObject; var Action: TCloseAction);
425 begin
426         Action := caFree;
427 end;
428
429 procedure TEditorForm.FormDestroy(Sender: TObject);
430 var
431         wp: TWindowPlacement;
432 begin
433         //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95Û\91
434         wp.length := sizeof(wp);
435         GetWindowPlacement(Handle, @wp);
436
437         GikoSys.Setting.EditWindowTop := wp.rcNormalPosition.Top;
438         GikoSys.Setting.EditWindowLeft := wp.rcNormalPosition.Left;
439         GikoSys.Setting.EditWindowHeight := wp.rcNormalPosition.Bottom - wp.rcNormalPosition.Top;
440         GikoSys.Setting.EditWindowWidth := wp.rcNormalPosition.Right - wp.rcNormalPosition.Left;
441         GikoSys.Setting.EditWindowMax := WindowState = wsMaximized;
442 end;
443
444 procedure TEditorForm.SetNameList(sName, sMail: string);
445 begin
446         if Trim(sName) <> '' then begin
447                 if GikoSys.Setting.NameList.IndexOf(sName) = -1 then
448                         GikoSys.Setting.NameList.Insert(0, sName);
449         end;
450         if Trim(sMail) <> '' then begin
451                 if GikoSys.Setting.MailList.IndexOf(sMail) = -1 then
452                         GikoSys.Setting.MailList.Insert(0, sMail);
453         end;
454 end;
455
456 function TEditorForm.GetActiveControlHandle: THandle;
457 begin
458         if EditorPage.ActivePage = EditorTab then begin
459                 if ActiveControl = NameComboBox then
460                         Result := FNameComboEdit
461                 else if ActiveControl = MailComboBox then
462                         Result := FMailComboEdit
463                 else if ActiveControl = BodyEdit then
464                         Result := BodyEdit.Handle
465                 else if ActiveControl = TitleEdit then
466                         Result := TitleEdit.Handle
467                 else
468                         Result := 0;
469         end else
470                 Result := 0;
471 end;
472
473 procedure TEditorForm.SetContent(Content: string);
474 var
475         doc : Variant;
476 begin
477         doc := Browser.Document;
478         doc.Clear;
479         doc.open;
480         doc.charset := 'Shift_JIS';
481         doc.Write(Content);
482         doc.Close;
483 end;
484
485 procedure TEditorForm.Send(SPID: string; PON: string; FirstWriting: Boolean);
486 var
487         TextStream: TStringStream;
488         Source: TStringStream;
489         ResponseText: string;
490         URL: string;
491         RefURL: string;
492         State: TGikoDownloadState;
493         ResultType: TGikoResultType;
494         MsgResult: Integer;
495         Cookie: string;
496         Board: TBoard;
497 begin
498         FAbort := False;
499         State := gdsError;
500         if FThreadItem = nil then
501                 Board := FBoard
502         else
503                 Board := FThreadItem.ParentBoard;
504
505         Indy.Request.Clear;
506         Indy.ProxyParams.BasicAuthentication := False;
507         if GikoSys.Setting.WriteProxy then begin
508                 Indy.ProxyParams.ProxyServer := GikoSys.Setting.WriteProxyAddress;
509                 Indy.ProxyParams.ProxyPort := GikoSys.Setting.WriteProxyPort;
510                 Indy.ProxyParams.ProxyUsername := GikoSys.Setting.WriteProxyUserID;
511                 Indy.ProxyParams.ProxyPassword := GikoSys.Setting.WriteProxyPassword;
512                 if GikoSys.Setting.ReadProxyUserID <> '' then
513                         Indy.ProxyParams.BasicAuthentication := True;
514         end else begin
515                 Indy.ProxyParams.ProxyServer := '';
516                 Indy.ProxyParams.ProxyPort := 80;
517                 Indy.ProxyParams.ProxyUsername := '';
518                 Indy.ProxyParams.ProxyPassword := '';
519         end;
520         if FThreadItem = nil then begin
521                 URL := FBoard.GetSendURL;
522                 RefURL := GikoSys.UrlToServer(FBoard.URL) + 'test/bbs.cgi';
523         end else begin
524                 URL := FThreadItem.GetSendURL;
525                 RefURL := FThreadItem.URL;
526         end;
527         Indy.Request.UserAgent := GikoSys.GetUserAgent;
528         Indy.Request.Referer := RefURL;
529         Indy.Request.AcceptEncoding := '';
530
531         Cookie := '';
532         if SPID <> '' then
533                 Cookie := Cookie + 'SPID=' + SPID + '; ';
534         if PON <> '' then
535                 Cookie := Cookie + 'PON=' + PON + '; ';
536         Cookie := 'Cookie: ' + Cookie + 'NAME=' + NameComboBox.Text + '; MAIL=' + MailComboBox.Text;
537
538         Indy.Request.CustomHeaders.Clear;
539 //      Indy.Request.CacheControl := 'no-cache';
540         Indy.Request.CustomHeaders.Add('Pragma: no-cache');
541         Indy.Request.AcceptLanguage := 'ja';
542         Indy.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
543         Indy.Request.ContentType := 'application/x-www-form-urlencoded';
544         Indy.Request.CustomHeaders.Add(Cookie);
545         TextStream := TStringStream.Create('');
546         Source := TStringStream.Create('');
547         try
548                 try
549                         FDebugStrReceive := '';
550                         FDebugStrSend := '';
551                         GetSendData(Source);
552                         Indy.Post(URL, Source, TextStream);
553                         ResponseText := TextStream.DataString;
554
555                         ResultType := GetResultType(ResponseText);
556
557                         if ResultType = grtOK then
558                                 State := gdsComplete
559                         else if ResultType = grtCookie then begin
560                                 //\83\8b\81[\83v\96h\8e~
561                                 if not FirstWriting then
562                                         raise Exception.Create('');
563                                 MsgResult := MsgBox(
564                                         Handle,
565                                         '\81E\93\8a\8de\82³\82ê\82½\93à\97e\82Í\83R\83s\81[\81A\95Û\91\81A\88ø\97p\81A\93]\8dÚ\93\99\82³\82ê\82é\8fê\8d\87\82ª\82 \82è\82Ü\82·\81B' + #13#10 +
566                                         '\81E\93\8a\8de\82É\8aÖ\82µ\82Ä\94­\90\82·\82é\90Ó\94C\82Í\91S\82Ä\93\8a\8de\8eÒ\82É\8bA\82µ\82Ü\82·\81B' + #13#10#13#10 +
567                                         '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
568                                         '\8fî\95ñ',
569                                         MB_YESNO or MB_ICONQUESTION);
570                                 if MsgResult = IDYES then begin
571                                         Board.SPID := GetSPID(Indy.Response.RawHeaders.Values['Set-Cookie']);
572                                         Board.PON := GetPON(Indy.Response.RawHeaders.Values['Set-Cookie']);
573                                         if (Board.SPID = '') and (Board.PON = '') then
574                                                 raise Exception.Create('');
575                                         //\82à\82¤\88ê\89ñ\82±\82Ì\83\81\83\\83b\83h
576                                         Send(Board.SPID, Board.PON, False);
577                                         Exit;
578                                 end else begin
579                                         Board.SPID := '';
580                                         Board.PON := '';
581                                         Exit;
582                                 end;
583                         end else if ResultType = grtCheck then begin
584                                 //
585                                 //\83\8b\81[\83v\96h\8e~
586                                 if not FirstWriting then
587                                         raise Exception.Create('');
588
589                                 MsgResult := MsgBox(
590                                         Handle,
591                                         '\8f\91\82«\8d\9e\82Ý\82É\8aÖ\82µ\82Ä\82Í\97l\81X\82È\83\8d\83O\8fî\95ñ\82ª\8bL\98^\82³\82ê\82Ä\82¢\82Ü\82·\81B' + #13#10 +
592                                         '\93\8a\8de\82É\8aÖ\82µ\82Ä\94­\90\82·\82é\90Ó\94C\82Í\91S\82Ä\93\8a\8de\8eÒ\82É\8bA\82µ\82Ü\82·\81B' + #13#10 +
593                                         '\8cö\8f\98\97Ç\91­\82É\94½\82µ\82½\82è\81A\91¼\90l\82É\96À\98f\82ð\82©\82¯\82é\8f\91\82«\8d\9e\82Ý\82Í\8dT\82¦\82Ä\89º\82³\82¢\81B' + #13#10 +
594                                         '\93\8a\8de\82³\82ê\82½\93à\97e\82Í\83R\83s\81[\81E\95Û\91\81E\88ø\97p\81E\93]\8dÚ\93\99\82³\82ê\82é\8fê\8d\87\82ª\82 \82è\82Ü\82·\81B' + #13#10 +
595                                         #13#10 +
596                                         '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
597                                         '\8am\94F',
598                                         MB_YESNO or MB_ICONQUESTION);
599
600                                 if MsgResult = IDYES then begin
601                                         Board.SPID := GetSPID(Indy.Response.RawHeaders.Values['Set-Cookie']);
602                                         Board.PON := GetPON(Indy.Response.RawHeaders.Values['Set-Cookie']);
603                                         if (Board.SPID = '') and (Board.PON = '') then
604                                                 raise Exception.Create('');
605                                         Send(Board.SPID, Board.PON, False);
606                                         Exit;
607                                 end else begin
608                                         Board.SPID := '';
609                                         Board.PON := '';
610                                         Exit;
611                                 end;
612                         end else begin
613                                 State := gdsError;
614                                 raise Exception.Create('');
615                         end;
616                 except
617                         on E: EIdConnectException do begin
618                                 State := gdsError;
619                                 ResponseText := '<html><body>'
620                                                                                         + '<div>\90Ú\91±\82ª\8e¸\94s\82µ\82Ü\82µ\82½<br>'
621                                                                                         + '\89ñ\90ü\82â\83v\83\8d\83L\83V\82Ì\8fó\91Ô\82ð\92²\82×\82Ä\82­\82¾\82³\82¢<br></div>'
622                                                                                         + '<br><br><div>' + E.Message + '</div>'
623                                                                                         + '</body></html>';
624                         end;
625                         on E: Exception do begin
626                                 State := gdsError;
627
628                                 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '<', '&lt;');
629                                 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '>', '&gt;');
630                                 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '<', '&lt;');
631                                 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '>', '&gt;');
632
633                                 ResponseText := '<html><body>' + TextStream.DataString;
634                                 ResponseText := AnsiReplaceText(ResponseText, '</body>', '');
635                                 ResponseText := AnsiReplaceText(ResponseText, '</html>', '');
636                                 ResponseText := ResponseText + '<hr><div align="left"><pre>';
637                                 ResponseText := ResponseText + '<b>\82±\82±\82©\82ç\83M\83R\83i\83r\82Ì\8fî\95ñ</b>'#13#10;
638                                 ResponseText := ResponseText + #13#10'\81\9c\91\97\90M'#13#10;
639                                 ResponseText := ResponseText + FDebugStrSend;
640                                 ResponseText := ResponseText + #13#10'\81\9c\8eó\90M'#13#10;
641                                 ResponseText := ResponseText + FDebugStrReceive;
642                                 ResponseText := ResponseText + '</pre></div></body></html>';
643                         end;
644                 end;
645                 FStatusCode := Indy.ResponseCode;
646                 if FAbort then
647                         State := gdsAbort;
648         finally
649                 Source.Free;
650                 TextStream.Free;
651         end;
652
653         if State = gdsComplete then begin
654                 GikoForm.PlaySound('ResEnd');
655                 SaveSendFile;
656                 if FThreadItem = nil then
657                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8fI\97¹]', nil, gmiOK)
658                 else
659                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8fI\97¹]', nil, gmiOK);
660                 Close;
661         end else if State = gdsError then begin
662                 if FThreadItem = nil then
663                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8e¸\94s]', nil, gmiNG)
664                 else
665                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8e¸\94s]', nil, gmiNG);
666                 EditorPage.ActivePage := PreviewTab;
667                 SetContent(ResponseText);
668         end else if State = gdsAbort then begin
669                 GikoForm.AddMessageList(FThreadItem.Title + ' [\92\86\92f]', nil, gmiSAD);
670         end;
671 end;
672
673 function TEditorForm.GetResultType(ResponseText: string): TGikoResultType;
674 begin
675         if AnsiPos('\8f\91\82«\82±\82Ý\82ª\8fI\82í\82è\82Ü\82µ\82½', ResponseText) <> 0 then
676                 Result := grtOK
677         else if (AnsiPos('\83N\83b\83L\81[\82ª\82È\82¢\82©\8aú\8cÀ\90Ø\82ê\82Å\82·', ResponseText) > 0) or
678                                         (AnsiPos('<title>\83N\83b\83L\81[\8am\94F\81I</title>', ResponseText) > 0)    or
679                                         (AnsiPos('<title>\81¡\83N\83b\83L\81[\8am\94F\81I\81¡</title>', ResponseText) > 0)        or
680                                         //(AnsiPos('\83N\83b\83L\81[\8am\94F', ResponseText) > 0) or
681                                         (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)      then
682                 Result := grtCookie
683         else if (AnsiPos('<font size=+2 color=#FF0000>\8f\91\82«\8d\9e\82Ý\83`\83F\83b\83N\81I </font>', ResponseText) > 0)   or
684                                         (AnsiPos('<title>\81¡ \8f\91\82«\8d\9e\82Ý\8am\94F\82µ\82Ü\82· \81¡</title>', ResponseText) > 0)  or
685                                         (AnsiPos('<title>\93\8a\8de\8am\94F</title>', ResponseText) > 0)  or
686                                         (AnsiPos('<b>\8f\91\82«\82±\82Ý\8am\94F</b>', ResponseText) > 0)      or
687                                         (AnsiPos('="../test/subbbs.cgi">', ResponseText) > 0)   or
688                                         (AnsiPos(RES2CH_FALSE, ResponseText) > 0)       then
689                 Result := grtCheck
690         else
691                 Result := grtError;
692 end;
693
694
695 procedure TEditorForm.GetSendData(Source: TStringStream);
696 var
697         SessionID: string;
698         s: string;
699         SendTime: Integer;
700         Adjust: Integer;
701         Board: TBoard;
702 begin
703         if FThreadItem = nil then
704                 Board := FBoard
705         else
706                 Board := FThreadItem.ParentBoard;
707
708         if GikoSys.Setting.UseMachineTime then begin
709                 if GikoSys.Setting.TimeAdjust then
710                         Adjust := Gikosys.Setting.TimeAdjustSec
711                 else
712                         Adjust := GikoSys.Setting.TimeAdjustSec * -1;
713                 SendTime := GikoSys.DateTimeToInt(Now) - (9 * 60 * 60) + Adjust
714         end else begin
715                 if (Board.LastGetTime = 0) or (Board.LastGetTime = ZERO_DATE) then
716                         SendTime := GikoSys.DateTimeToInt(Now)
717                 else
718                         SendTime := GikoSys.DateTimeToInt(Board.LastGetTime);
719         end;
720         SessionID := GikoSys.Dolib.SessionID;
721         if SessionID <> '' then
722                 s := 'sid=' + HttpEncode(SessionID) + '&'
723         else
724                 s := '';
725         s := s + 'subject=&'
726                                  + 'FROM=' + HttpEncode(NameComboBox.Text) + '&'
727                                  + 'mail=' + HttpEncode(MailComboBox.Text) + '&'
728                                  + 'MESSAGE=' + HttpEncode(BodyEdit.Text) + '&'
729                                  + 'bbs=' + Board.BBSID + '&'
730                                  + 'time=' + IntToStr(SendTime) + '&';
731         if FThreadItem = nil then begin
732                 s := s + 'subject=' + HttpEncode(TitleEdit.Text) + '&';
733                 s := s + 'submit=' + HttpEncode('\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Þ') + #13#10;
734         end else begin
735                 s := s + 'key=' + ChangeFileExt(FThreadItem.FileName, '') + '&';
736                 s := s + 'submit=' + HttpEncode('\8f\91\82«\8d\9e\82Þ') + #13#10;
737         end;
738         Source.WriteString(s);
739 end;
740
741 procedure TEditorForm.SaveSendFile;
742 var
743         sDate: string;
744         ini: TMemIniFile;
745 begin
746         ini := TMemIniFile.Create(GikoSys.GetSentFileName);
747         try
748                 sDate := IntToStr(GikoSys.DateTimeToInt(Now));
749
750                 ini.WriteString(sDate, 'Name', NameComboBox.Text);
751                 ini.WriteString(sDate, 'EMail', MailComboBox.Text);
752                 ini.WriteString(sDate, 'Body', HttpEncode(BodyEdit.Text));
753                 ini.WriteInteger(sDate, 'Status', FStatusCode);
754                 ini.WriteDateTime(sDate, 'Date', Now);
755                 if FThreadItem = nil then begin
756                         ini.WriteString(sDate, 'Title', TitleEdit.Text);
757                         ini.WriteString(sDate, 'BBS', FBoard.BBSID);
758                         ini.WriteInteger(sDate, 'NewThread', 1);
759                 end else begin
760                         ini.WriteString(sDate, 'Title', FThreadItem.Title);
761                         ini.WriteString(sDate, 'BBS', FThreadItem.ParentBoard.BBSID);
762                         ini.WriteString(sDate, 'Key', ChangeFileExt(FThreadItem.FileName, ''));
763                 end;
764
765                 ini.UpdateFile;
766         finally
767                 ini.Free;
768         end;
769 end;
770
771 procedure TEditorForm.SendActionExecute(Sender: TObject);
772 var
773         Board: TBoard;
774         rc: Integer;
775         state : TGikoDownloadState;
776 begin
777         if FWork then
778                 Exit;
779         try
780                 FWork := True;
781                 SendAction.Enabled := False;
782                 Application.ProcessMessages;
783                 if not Check then Exit;
784
785                 if FThreadItem = nil then
786                         Board := FBoard
787                 else
788                         Board := FThreadItem.ParentBoard;
789
790                 if FThreadItem = nil then begin
791                         rc := GikoUtil.MsgBox(Handle,
792                                                                                                         '\81u' + Board.Title + '\81v\94Â\82É\90V\82µ\82¢\83X\83\8c\83b\83h\97§\82Ä\82Ü\82·'#13#10#13#10
793                                                                                                         + '\81E\94Â\82Ì\83\8b\81[\83\8b\82ð\8eç\82Á\82½\8f\91\82«\8d\9e\82Ý\82Å\82 \82é\82±\82Æ\82ð\8am\94F\82µ\82Ü\82µ\82½\82©\81H'#13#10
794                                                                                                         + '\81E\91¼\82É\93¯\82\82æ\82¤\82È\83X\83\8c\83b\83h\82ª\96³\82©\82Á\82½\82±\82Æ\82ð\8am\94F\82µ\82Ü\82µ\82½\82©\81H'#13#10#13#10
795                                                                                                         + '\81u\82Í\82¢\81v\82ð\89\9f\82·\82Æ\91\97\90M\82µ\82Ü\82·',
796                                                                                                         '\8am\94F',
797                                                                                                         MB_ICONQUESTION or MB_YESNO);
798                         if rc <> ID_YES then
799                                 Exit;
800                 end;
801
802                 SetNameList(NameComboBox.Text, MailComboBox.Text);
803                 if KotehanCheckBox.Checked then begin
804                         Board.KotehanName := NameComboBox.Text;
805                         Board.KotehanMail := MailComboBox.Text;
806                 end;
807
808                 if Board.IsBoardPlugInAvailable then begin
809                         if FThreadItem = nil then begin
810                                 // \83X\83\8c\97§\82Ä
811                                 state := TGikoDownloadState( Board.BoardPlugIn.CreateThread(
812                                         DWORD( Board ), TitleEdit.Text, NameComboBox.Text, MailComboBox.Text, BodyEdit.Text ) );
813
814                                 if state = gdsComplete then begin
815                                         GikoForm.PlaySound('ResEnd');
816                                         SaveSendFile;
817                                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8fI\97¹]', nil, gmiOK);
818                                         Close;
819                                 end else if State = gdsError then begin
820                                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8e¸\94s]', nil, gmiNG);
821                                 end else if State = gdsAbort then begin
822                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\92\86\92f]', nil, gmiSAD);
823                                 end;
824                         end else begin
825                                 // \83\8c\83X
826                                 state := TGikoDownloadState( FThreadItem.BoardPlugIn.WriteThread(
827                                         DWORD( FThreadItem ), NameComboBox.Text, MailComboBox.Text, BodyEdit.Text ) );
828
829                                 if state = gdsComplete then begin
830                                         GikoForm.PlaySound('ResEnd');
831                                         SaveSendFile;
832                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8fI\97¹]', nil, gmiOK);
833                                         Close;
834                                 end else if State = gdsError then begin
835                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8e¸\94s]', nil, gmiNG);
836                                 end else if State = gdsAbort then begin
837                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\92\86\92f]', nil, gmiSAD);
838                                 end;
839                         end;
840                 end else begin
841                         Send(Board.SPID, Board.PON, True);
842                 end;
843         finally
844                 FWork := False;
845         end;
846 end;
847
848 procedure TEditorForm.SaveActionExecute(Sender: TObject);
849 begin
850 //
851 end;
852
853 procedure TEditorForm.CloseActionExecute(Sender: TObject);
854 begin
855         Close;
856 end;
857
858 procedure TEditorForm.UndoActionExecute(Sender: TObject);
859 begin
860         SendMessage(GetActiveControlHandle, WM_UNDO, 0, 0);
861 end;
862
863 procedure TEditorForm.CutActionExecute(Sender: TObject);
864 begin
865         SendMessage(GetActiveControlHandle, WM_CUT, 0, 0);
866 end;
867
868 procedure TEditorForm.CopyActionExecute(Sender: TObject);
869 begin
870         SendMessage(GetActiveControlHandle, WM_COPY, 0, 0);
871 end;
872
873 procedure TEditorForm.PasteActionExecute(Sender: TObject);
874 begin
875         SendMessage(GetActiveControlHandle, WM_PASTE, 0, 0);
876 end;
877
878 procedure TEditorForm.SelectAllActionExecute(Sender: TObject);
879 begin
880         SendMessage(GetActiveControlHandle, EM_SETSEL, 0, GetWindowTextLength(GetActiveControlHandle));
881 end;
882
883 procedure TEditorForm.TopActionExecute(Sender: TObject);
884 begin
885         if TopAction.Checked then
886                 FormStyle := fsStayOnTop
887         else
888                 FormStyle := fsNormal;
889 end;
890
891 procedure TEditorForm.AbortActionExecute(Sender: TObject);
892 begin
893         FAbort := True;
894 end;
895
896 procedure TEditorForm.SendActionUpdate(Sender: TObject);
897 begin
898         SendAction.Enabled := not FWork;
899 end;
900
901 procedure TEditorForm.SaveActionUpdate(Sender: TObject);
902 begin
903         SaveAction.Enabled := False;
904 end;
905
906 procedure TEditorForm.CloseActionUpdate(Sender: TObject);
907 begin
908         SendAction.Enabled := not FWork;
909 end;
910
911 procedure TEditorForm.UndoActionUpdate(Sender: TObject);
912 begin
913         UndoAction.Enabled := (GetActiveControlHandle <> 0)
914                                                                                                 and (SendMessage(GetActiveControlHandle, EM_CANUNDO, 0, 0) <> 0)
915                                                                                                 and (not FWork);
916 end;
917
918 procedure TEditorForm.CutActionUpdate(Sender: TObject);
919 var
920         Selection: TSelection;
921         AHandle: THandle;
922 begin
923         AHandle := GetActiveControlHandle;
924         SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
925         CutAction.Enabled := (AHandle <> 0)
926                                                                                 and ((Selection.EndPos - Selection.StartPos) <> 0)
927                                                                                 and (not FWork);
928 end;
929
930 procedure TEditorForm.CopyActionUpdate(Sender: TObject);
931 var
932         Selection: TSelection;
933         AHandle: THandle;
934 begin
935         AHandle := GetActiveControlHandle;
936         SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
937         CopyAction.Enabled := (AHandle <> 0)
938                                                                                 and ((Selection.EndPos - Selection.StartPos) <> 0)
939                                                                                 and (not FWork);
940 end;
941
942 procedure TEditorForm.PasteActionUpdate(Sender: TObject);
943 begin
944         PasteAction.Enabled := (GetActiveControlHandle <> 0)
945                                                                                         and (Clipboard.HasFormat(CF_TEXT))
946                                                                                         and (not FWork);
947 end;
948
949 procedure TEditorForm.TopActionUpdate(Sender: TObject);
950 begin
951         TopAction.Enabled := not FWork;
952 end;
953
954 procedure TEditorForm.SageCheckBoxClick(Sender: TObject);
955 begin
956         if SageCheckBox.Checked then begin
957                 if AnsiPos('sage', MailComboBox.Text) = 0 then
958                         MailComboBox.Text := 'sage' + MailComboBox.Text;
959         end else begin
960                 if AnsiPos('sage', MailComboBox.Text) <> 0 then
961                         MailComboBox.Text := StringReplace(MailComboBox.Text, 'sage', '', [rfReplaceAll]);
962         end;
963 end;
964
965 procedure TEditorForm.MailComboBoxChange(Sender: TObject);
966 begin
967         if AnsiPos('sage', MailComboBox.Text) = 0 then
968                 SageCheckBox.Checked := False
969         else
970                 SageCheckBox.Checked := True;
971 end;
972
973
974 function TEditorForm.GetSPID(CookieLine: string): string;
975 var
976         s: string;
977         i: Integer;
978 begin
979         Result := '';
980         i := 0;
981         while True do begin
982                 s := Trim(GikoSys.GetTokenIndex(CookieLine, ';', i));
983                 if s = '' then
984                         Break
985                 else begin
986                         if Pos('SPID=', s) = 1 then begin
987                                 Result := Trim(Copy(s, 6, Length(s)));
988                                 Break;
989                         end;
990                 end;
991                 inc(i);
992         end;
993 end;
994
995 function TEditorForm.GetPON(CookieLine: string): string;
996 var
997         s: string;
998         i: Integer;
999 begin
1000         Result := '';
1001         i := 0;
1002         while True do begin
1003                 s := Trim(GikoSys.GetTokenIndex(CookieLine, ';', i));
1004                 if s = '' then
1005                         Break
1006                 else begin
1007                         if Pos('PON=', s) = 1 then begin
1008                                 Result := Trim(Copy(s, 5, Length(s)));
1009                                 Break;
1010                         end;
1011                 end;
1012                 inc(i);
1013         end;
1014 end;
1015
1016 procedure TEditorForm.IdLogDebugReceive(ASender: TIdConnectionIntercept;
1017         AStream: TStream);
1018 var
1019         StringStream: TStringStream;
1020 begin
1021         StringStream := TStringStream.Create('');
1022         try
1023                 StringStream.CopyFrom(AStream, AStream.Size);
1024                 FDebugStrReceive := FDebugStrReceive + StringStream.DataString;
1025         finally
1026                 StringStream.Free;
1027         end;
1028 end;
1029
1030 procedure TEditorForm.IdLogDebugSend(ASender: TIdConnectionIntercept;
1031         AStream: TStream);
1032 var
1033         StringStream: TStringStream;
1034 begin
1035         StringStream := TStringStream.Create('');
1036         try
1037                 StringStream.CopyFrom(AStream, AStream.Size);
1038                 FDebugStrSend := FDebugStrSend + StringStream.DataString;
1039         finally
1040                 StringStream.Free;
1041         end;
1042 end;
1043
1044 procedure TEditorForm.TransActionExecute(Sender: TObject);
1045 begin
1046         AlphaBlend := TransAction.Checked;
1047 end;
1048
1049 procedure TEditorForm.TransActionUpdate(Sender: TObject);
1050 begin
1051         TransAction.Enabled := not FWork;
1052 end;
1053
1054 end.
1055