OSDN Git Service

レスエディタ/スレ立てエディタで通信の例外発生時に例外情報を表示するよう変更。
[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, Registry,
8 {$IF Defined(DELPRO) }
9         SHDocVw,
10         MSHTML,
11 {$ELSE}
12         SHDocVw_TLB,
13         MSHTML_TLB,
14 {$IFEND}
15         ActiveX, {HTTPApp,} YofUtils, IniFiles, StrUtils,
16         GikoSystem, GikoUtil, ImgList, Clipbrd, BoardGroup,
17         IdAntiFreezeBase,       IdAntiFreeze, IdBaseComponent, IdComponent,
18         IdTCPConnection, IdTCPClient, IdHTTP, ActnList, StdActns, IdIntercept,
19         IdLogBase, IdLogDebug, IdException, DateUtils,  bmRegExp,
20         Gesture, AppEvnts, SambaTimer, IdCookieManager;
21
22 type
23 //      TSetLayeredWindowAttributes = function(wnd: HWND; crKey: DWORD; bAlpha: BYTE; dwFlag: DWORD): Boolean; stdcall;
24         //\8f\91\82«\8d\9e\82Ý\96ß\82è\92l\83^\83C\83v
25         TGikoResultType = (grtOK, grtCookie, grtCheck, grtError, grtNinpou, grtNinpouErr, grtSuiton);
26
27         TEditorForm = class(TForm)
28                 MainMenu: TMainMenu;
29                 FileMenu: TMenuItem;
30                 PostMessage: TMenuItem;
31                 SaveMessage: TMenuItem;
32                 CloseMenu: TMenuItem;
33                 N01: TMenuItem;
34                 StatusBar: TStatusBar;
35         EditorPage: TPageControl;
36                 EditorTab: TTabSheet;
37                 PreviewTab: TTabSheet;
38                 Browser: TWebBrowser;
39                 EditMenu: TMenuItem;
40                 UndoMenu: TMenuItem;
41                 CutMenu: TMenuItem;
42                 CopyMenu: TMenuItem;
43                 PasteMenu: TMenuItem;
44                 N02: TMenuItem;
45                 ToolBarImageList: TImageList;
46                 HotToobarImageList: TImageList;
47                 NameBasePanel: TPanel;
48                 NameLabel: TLabel;
49                 MailLabel: TLabel;
50                 NameComboBox: TComboBox;
51                 MailComboBox: TComboBox;
52                 ToolBar: TToolBar;
53                 SendToolButton: TToolButton;
54                 OutBoxToolButton: TToolButton;
55                 ToolButton5: TToolButton;
56                 UndoToolButton: TToolButton;
57                 CutToolButton: TToolButton;
58                 CopyToolButton: TToolButton;
59                 PasteToolButton: TToolButton;
60                 ToolButton3: TToolButton;
61                 TransToolButton: TToolButton;
62                 TopToolButton: TToolButton;
63                 Indy: TIdHTTP;
64                 IdAntiFreeze: TIdAntiFreeze;
65                 ToolButton1: TToolButton;
66                 ToolButton2: TToolButton;
67                 ActionList: TActionList;
68                 SendAction: TAction;
69                 SaveAction: TAction;
70                 CloseAction: TAction;
71                 UndoAction: TAction;
72                 CutAction: TAction;
73                 CopyAction: TAction;
74                 PasteAction: TAction;
75                 AbortAction: TAction;
76                 TopAction: TAction;
77                 Show1: TMenuItem;
78                 T1: TMenuItem;
79                 N1: TMenuItem;
80                 S1: TMenuItem;
81                 SageCheckBox: TCheckBox;
82                 IdLogDebug: TIdLogDebug;
83                 TransAction: TAction;
84                 A1: TMenuItem;
85                 KotehanCheckBox: TCheckBox;
86                 TitlePanel: TPanel;
87                 Label1: TLabel;
88                 TitleEdit: TEdit;
89                 SelectAllAction: TAction;
90                 N2: TMenuItem;
91                 SelectAll1: TMenuItem;
92         QuotePasteAction: TAction;
93         QuotePasteMenuItem: TMenuItem;
94         C1: TMenuItem;
95         SpaceToNBSPAction: TAction;
96         AmpToCharRefAction: TAction;
97         SpaceTabnbsp1: TMenuItem;
98         amp1: TMenuItem;
99         BoardInformationTab: TTabSheet;
100                                 BoardtopTab: TTabSheet;
101         TitlePictureBrowser: TWebBrowser;
102         BoardTop: TMenuItem;
103         BoardInformationMemo: TMemo;
104         GetSETTINGTXTAction: TAction;
105         N3: TMenuItem;
106         SETTINGTXT2: TMenuItem;
107         GetTitlePictureAction: TAction;
108         OP1: TMenuItem;
109     GetHeadTXTAction: TAction;
110     HeadTXT1: TMenuItem;
111     RocalRuleTab: TTabSheet;
112     WebBrowser1: TWebBrowser;
113     CalcCapacityAction: TAction;
114     N4: TMenuItem;
115     N5: TMenuItem;
116     LocalRule: TMenuItem;
117     LocalEdit: TMemo;
118     N6: TMenuItem;
119     LocalRuleBrowse: TMenuItem;
120         ToolButton4: TToolButton;
121     ToolButton6: TToolButton;
122     SaveNameMailAction: TAction;
123     ToolButton7: TToolButton;
124     BeLogInOutEAction: TAction;
125     UpdateSambaAction: TAction;
126     Samba241: TMenuItem;
127     N7: TMenuItem;
128     InputAssistAction: TAction;
129     InputAssistPopupMenu: TPopupMenu;
130     BodyEdit: TMemo;
131     ApplicationEvents1: TApplicationEvents;
132     ToolButton8: TToolButton;
133     ToolButton9: TToolButton;
134     ShowInputAssistForm: TAction;
135     ReleaseCookieAction: TAction;
136     Cookie1: TMenuItem;
137     ContinueModeAction: TAction;
138     ToolButton10: TToolButton;
139     ToolButton11: TToolButton;
140     OpenSendTargetAction: TAction;
141     ReloadTargetAction: TAction;
142     N8: TMenuItem;
143     N9: TMenuItem;
144     N10: TMenuItem;
145
146                 procedure EditorPageChange(Sender: TObject);
147                 procedure FormCreate(Sender: TObject);
148                 procedure BrowserStatusTextChange(Sender: TObject;
149                         const Text: WideString);
150                 procedure FormClose(Sender: TObject; var Action: TCloseAction);
151                 procedure FormDestroy(Sender: TObject);
152                 procedure SendActionExecute(Sender: TObject);
153                 procedure SaveActionExecute(Sender: TObject);
154                 procedure AbortActionExecute(Sender: TObject);
155                 procedure CloseActionExecute(Sender: TObject);
156                 procedure UndoActionExecute(Sender: TObject);
157                 procedure CutActionExecute(Sender: TObject);
158                 procedure CopyActionExecute(Sender: TObject);
159                 procedure PasteActionExecute(Sender: TObject);
160                 procedure SendActionUpdate(Sender: TObject);
161                 procedure SaveActionUpdate(Sender: TObject);
162                 procedure CloseActionUpdate(Sender: TObject);
163                 procedure UndoActionUpdate(Sender: TObject);
164                 procedure CutActionUpdate(Sender: TObject);
165                 procedure CopyActionUpdate(Sender: TObject);
166                 procedure PasteActionUpdate(Sender: TObject);
167                 procedure TopActionExecute(Sender: TObject);
168                 procedure TopActionUpdate(Sender: TObject);
169                 procedure SageCheckBoxClick(Sender: TObject);
170                 procedure MailComboBoxChange(Sender: TObject);
171                 procedure TransActionExecute(Sender: TObject);
172                 procedure TransActionUpdate(Sender: TObject);
173                 procedure IdLogDebugReceive(ASender: TIdConnectionIntercept;
174                         AStream: TStream);
175                 procedure IdLogDebugSend(ASender: TIdConnectionIntercept;
176                         AStream: TStream);
177                 procedure SelectAllActionExecute(Sender: TObject);
178         procedure StatusBarResize(Sender: TObject);
179         procedure FormActivate(Sender: TObject);
180         procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
181                 procedure QuotePasteActionExecute(Sender: TObject);
182         procedure SpaceToNBSPActionExecute(Sender: TObject);
183         procedure AmpToCharRefActionExecute(Sender: TObject);
184         procedure BoardTopClick(Sender: TObject);
185         procedure GetSETTINGTXTActionExecute(Sender: TObject);
186         procedure GetTitlePictureActionUpdate(Sender: TObject);
187         procedure GetTitlePictureActionExecute(Sender: TObject);
188     procedure GetHeadTXTActionExecute(Sender: TObject);
189         procedure CalcCapacityActionExecute(Sender: TObject);
190     procedure LocalRuleClick(Sender: TObject);
191     procedure FormDeactivate(Sender: TObject);
192     procedure LocalRuleBrowseClick(Sender: TObject);
193     procedure SaveNameMailActionExecute(Sender: TObject);
194     procedure BeLogInOutEActionExecute(Sender: TObject);
195     procedure BeLogInOutEActionUpdate(Sender: TObject);
196     procedure UpdateSambaActionUpdate(Sender: TObject);
197     procedure UpdateSambaActionExecute(Sender: TObject);
198     procedure InputAssistActionExecute(Sender: TObject);
199     procedure ApplicationEvents1Message(var Msg: tagMSG;
200       var Handled: Boolean);
201     procedure ShowInputAssistFormExecute(Sender: TObject);
202     procedure ReleaseCookieActionExecute(Sender: TObject);
203     procedure GetSETTINGTXTActionUpdate(Sender: TObject);
204     procedure GetHeadTXTActionUpdate(Sender: TObject);
205     procedure ContinueModeActionExecute(Sender: TObject);
206     procedure ContinueModeActionUpdate(Sender: TObject);
207     procedure OpenSendTargetActionExecute(Sender: TObject);
208     procedure ReloadTargetActionExecute(Sender: TObject);
209         private
210                 FThreadItem: TThreadItem;
211                 FBoard: TBoard;
212                 FNameComboEdit: THandle;
213                 FMailComboEdit: THandle;
214                 FAbort: Boolean;
215                 FWork: Boolean;
216                 FStatusCode: Integer;
217                 FDebugStrReceive: string;
218                 FDebugStrSend: string;
219                 FNow: TDateTime;
220                 FInputAssistKey: String;        ///< \93ü\97Í\83A\83V\83X\83g\82Ì\83L\81[
221                 FResistWords: TStringList;      ///< \93ü\97Í\83A\83V\83X\83g\82Ì\8e«\8f\91\82©\82ç\82Ì\8c\9f\8dõ\8c\8b\89Ê
222         FSambaTimer: TSambaTimer;   ///< Samba\91Î\8dô\82Ì\83^\83C\83}\81[
223         FCookieDomain: string;        ///< \94E\96@\92\9f\83h\83\81\83C\83\93
224                 procedure Preview;
225                 function Check: Boolean;
226                 procedure SetNameList(sName, sMail: string);
227                 procedure Send(const ACOOKIE: string; const SPID: string; const PON: string; FirstWriting: Boolean);
228                 function GetActiveControlHandle: THandle;
229                 procedure GetSendData(Source: TStringStream);
230                 procedure SaveSendFile;
231                 procedure SetContent(Content: string; ABrowser: TWebBrowser);
232                 function GetResultType(ResponseText: string): TGikoResultType;
233                 /// \96{\95\82Ì\8eæ\93¾
234                 function GetBody : string;
235                 //IdHttp\82Ì\8f\89\8aú\89»
236                 procedure InitIdHTTP(http: TIdHTTP);
237                 procedure ShowBoardInformation(ABoard: TBoard; AMemo: TMemo);
238                 function GetTitlePictureURL(body: TStringList; ABoard: TBoard): string;
239                 procedure ShowTitlePicture();
240                                 function GetFusianaName(body: TStringList; ABoard: TBoard): String;
241                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8aJ\8en
242                 procedure OnGestureStart(Sender: TObject);
243                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\92\86
244                 procedure OnGestureMove(Sender: TObject);
245                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8fI\97¹
246                 procedure OnGestureEnd(Sender: TObject);
247                                 //HEAD.TXT\8e©\93®\95\\8e¦
248                                 procedure ShowBoardHead(ABoard: TBoard; AMemo: TMemo);
249                                 //LocalFusianaTrapAlart
250                                 function LFusianaGet(const s: String): Boolean;
251                 // Cookie\82Ì\8eæ\93¾
252                 procedure GetCookie(CookieMng: TIdCookieManager; ABoard: TBoard);
253         // hidden\83f\81[\83^\8eæ\93¾
254         procedure GetHiddenParameter(Rawtext: String; ABoard: TBoard);
255                 //! \93ü\97Í\83A\83V\83X\83g\82Ì\83|\83b\83v\83A\83b\83v\83\81\83j\83\85\81[\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
256                 procedure InputAssistMenuClick(Sender: TObject);
257                 //! TMemo\82Ì\83J\81[\83\\83\8b\88Ê\92u\82É\95\8e\9a\97ñ\91}\93ü
258                 procedure InsertText(Memo: TMemo; Text: String);
259                 //! \91\97\90M\92\86\8e~
260                 procedure CancelSend(ABoard: TBoard; ASysMenu: HMENU);
261         //! Samba\83^\83C\83}\81[\83C\83x\83\93\83g
262         procedure SambaTimer(Sender: TObject);
263         //! \83E\83B\83\93\83h\83E\82Ì\88Ê\92u\82Æ\83T\83C\83Y\82Ì\90Ý\92è
264         procedure SetWindowRect;
265         //! \8ag\92£\83^\83u\90Ý\92è
266         procedure SetExtraTab;
267         //! \94Â\8eæ\93¾
268         function GetBoard : TBoard;
269         //! URL\82Ì\83f\81[\83^\82ðstream\82É\8eæ\82è\8d\9e\82Þ 
270         procedure GetWebData(const URL: string; const RefURL: string;
271              Modified: TDateTime; stream: TStream);
272         //! GikoForm\82É\90V\92\85\83\81\83b\83Z\81[\83W\82ð\92Ç\89Á\82·\82é
273         procedure AddFormMessageNew(icon: TGikoMessageIcon);
274         //! \83\8d\81[\83J\83\8bfusiana\83g\83\89\83b\83v
275         function isLocalFusianaTrap: Boolean;
276         //! \83\8d\81[\83J\83\8bfusiana\83g\83\89\83b\83v
277         function isRemoteFusianaTrap: Boolean;
278         //! Header\95\8e\9a\97ñ\8eæ\93¾
279         function getHeaderStr(const ACOOKIE: string; const SPID : string;
280             const PON : string; const HAP : string; Board : TBoard) : string;
281         //! fusiana\8cx\8d\90\83_\83C\83A\83\8d\83O
282         function FusianaMsgBox: Integer;
283         //! sent.ini\83t\83@\83C\83\8b\82Ì\90\90¬
284         function CreateSentIniFile: TMemIniFile;
285         //! \8cë\94\9a\83`\83F\83b\83N
286         function isGobaku: Boolean;
287         protected
288                 procedure CreateParams(var Params: TCreateParams); override;
289         public
290                 FBBSID: String;
291                 procedure SetFont;
292                 procedure SetThreadItem(Item: TThreadItem);
293                 procedure SetBoard(Item: TBoard);
294         procedure UpdateSambaStatus;
295                 property BBSID: string read FBBSID write FBBSID;
296         end;
297
298 implementation
299
300 uses
301         Giko, ItemDownload, MojuUtils, IdGlobal, GikoMessage,  Imm,
302   InputAssistDataModule, InputAssist, HTMLCreate, IdCookie, GikoDataModule,
303   Belib;
304 const
305         CAPTION_NAME_NEW: string = '\83M\83R\83i\83\83X\83\8c\97§\82Ä\83G\83f\83B\83^';
306         CAPTION_NAME_RES: string = '\83M\83R\83i\83\83\8c\83X\83G\83f\83B\83^';
307
308         // \83G\83f\83B\83b\83g\83E\83B\83\93\83h\83E\82ð\89E\89º\82É\82¸\82ç\82µ\82Ä\8aJ\82­\88Ú\93®\97Ê
309         WINDOWMOVE_H = 30;
310         WINDOWMOVE_V = 30;
311
312         //DAX\82³\82ñ±Ø¶ÞÄ!(\81L\81¤\81M)
313         READCGI_ERR                     = '-ERR';
314         READCGI_INCR            = '-INCR';
315         READCGI_OK                      = '+OK';
316         READCGI_PARTIAL = '+PARTIAL';
317         READCGI_ERR_FOUND_KAKO  = '-ERR \89ß\8b\8e\83\8d\83O\91q\8cÉ\82Å\94­\8c©';
318         READCGI_ERR_NOT_HTML            = '-ERR html\89»\91Ò\82¿';
319         READCGI_ERR_NOT_FOUND           = '-ERR \82»\82ñ\82È\94Âor\83X\83\8c\83b\83h\82È\82¢\82Å\82·\81B';
320         READCGI_ERR_ABONE                               = '-ERR \82Ç\82±\82©\82Å\82 \82Ú\81[\82ñ\82ª\82 \82Á\82½\82Ý\82½\82¢\82Å\82·\81B';
321         READCGI_ERR_TIMEOUT                     = '-ERR \8ew\92è\8e\9e\8aÔ\82ª\89ß\82¬\82Ü\82µ\82½\81B';
322         READCGI_ERR_CANTUSE                     = '-ERR \82à\82¤\81@\82Â\82©\82¦\82Ü\82¹\82ñ';
323         RES2CH_TRUE                             = '<!-- 2ch_X:true -->';
324         RES2CH_FALSE                    = '<!-- 2ch_X:false -->';
325         RES2CH_ERROR                    = '<!-- 2ch_X:error -->';
326         RES2CH_CHECK                    = '<!-- 2ch_X:check -->';
327         RES2CH_COOKIE                   = '<!-- 2ch_X:cookie -->';
328
329 type
330         TSelection = record
331                 StartPos, EndPos: Integer;
332         end;
333
334 {$R *.DFM}
335
336 {constructor TEditorForm.Create(AOwner: TComponent; Item: TBoard);
337 begin
338         inherited Create(AOwner);
339 end;}
340
341 procedure TEditorForm.CreateParams(var Params: TCreateParams);
342 begin
343         inherited;
344         if FormStyle in [fsNormal, fsStayOnTop] then
345                 if BorderStyle in [bsSingle, bsSizeable] then begin
346                         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
347                         Params.WndParent := 0;
348                 end;
349 end;
350
351 {procedure TEditorForm.CreateParams(var Params: TCreateParams);
352 begin
353         inherited CreateParams(Params);
354         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
355 end;}
356
357 procedure TEditorForm.FormCreate(Sender: TObject);
358 begin
359         FWork := False;
360     FSambaTimer := TSambaTimer.Create(Self);
361     FSambaTimer.Interval := 0;
362         Browser.Navigate('about:blank');
363         TitlePictureBrowser.Navigate('about:blank');
364     WebBrowser1.Navigate('about:blank');
365         FBoard := nil;
366         FThreadItem := nil;
367
368     if (Owner <> nil) and (Owner.ClassNameIs('TKeySettingForm') = False) then
369         //\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\90Ý\92è
370         SetWindowRect;
371
372         EditorPage.ActivePage := EditorTab;
373         FNameComboEdit := GetWindow(NameComboBox.Handle, GW_CHILD);
374         FMailComboEdit := GetWindow(MailComboBox.Handle, GW_CHILD);
375         NameComboBox.Items.Assign(GikoSys.Setting.NameList);
376         MailComboBox.Items.Assign(GikoSys.Setting.MailList);
377         SetFont;
378     // \94¼\93§\96¾\97\98\97p\89Â\94\\90Ý\92è
379     TransAction.Enabled := GikoSys.CanUser32DLL;
380
381     // \83E\83B\83\93\83h\83E\82Ì\83X\83e\83C\8fó\91Ô
382         if GikoSys.Setting.EditWindowStay then begin    // \83X\83e\83C\8fó\91Ô
383                 SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
384                 TopAction.Checked := true;
385                 TopToolButton.Down := true;
386         end else begin                                  // \83X\83e\83C\82µ\82È\82¢
387                 SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
388                 TopAction.Checked := false;
389                 TopToolButton.Down := false;
390         end;
391
392     // \83E\83B\83\93\83h\83E\82Ì\94¼\93§\96¾\8fó\91Ô
393         if(GikoSys.Setting.EditWindowTranslucent) and (TransAction.Enabled) then begin // \94¼\93§\96¾\81i\83g\83\89\83\93\83X\83\8b\81[\83Z\83\93\83g\81j\8fó\91Ô
394         AlphaBlend := true;
395         TransAction.Checked := true;
396         TransToolButton.Down := true;
397     end else begin                                      // \95s\93§\96¾
398         AlphaBlend := false;
399         TransAction.Checked := false;
400         TransToolButton.Down := false;
401     end;
402         // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
403         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;
404
405         SpaceToNBSPAction.Checked               := GikoSys.Setting.SpaceToNBSP;
406         AmpToCharRefAction.Checked      := GikoSys.Setting.AmpToCharRef;
407     // \83\8d\81[\83J\83\8b\83\8b\81[\83\8b\81{\94Â\83g\83b\83v\89æ\91\9c\82Ì\83^\83u\82Ì\90Ý\92è
408     SetExtraTab;
409
410         // \83L\81[\90Ý\92è\82Ì\93Ç\82Ý\8d\9e\82Ý
411         GikoSys.LoadKeySetting(ActionList, GikoSys.GetEditorKeyFileName);
412         SaveNameMailAction.Checked := True;
413 end;
414 procedure TEditorForm.SetBoard(Item: TBoard);
415 begin
416         FBoard := Item;
417         Caption := CAPTION_NAME_NEW + ' - [' + Item.Title + ']';
418         NameComboBox.Text := FBoard.KotehanName;
419         MailComboBox.Text := FBoard.KotehanMail;
420         SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
421         TitlePanel.Visible := True;
422
423     if (FSambaTimer.SetBoard(FBoard) >= 0) then begin
424         UpdateSambaStatus;
425         FNow := Now();
426         FSambaTimer.OnTimer := SambaTimer;
427     end;
428
429         ShowBoardInformation(FBoard, BoardInformationMemo);
430         ShowTitlePicture();
431 end;
432
433 procedure TEditorForm.SetThreadItem(Item: TThreadItem);
434 begin
435         FThreadItem := Item;
436         Caption := CAPTION_NAME_RES + ' - [' + FThreadItem.Title + ']';
437         NameComboBox.Text := FThreadItem.ParentBoard.KotehanName;
438         MailComboBox.Text := FThreadItem.ParentBoard.KotehanMail;
439         SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
440         TitlePanel.Visible := False;
441
442     if (FSambaTimer.SetBoard(FThreadItem.ParentBoard) >= 0) then begin
443         UpdateSambaStatus;
444         FNow := Now();
445         FSambaTimer.OnTimer := SambaTimer;
446     end;
447
448         ShowBoardInformation(FThreadItem.ParentBoard, BoardInformationMemo);
449         ShowTitlePicture();
450 end;
451
452 function TEditorForm.GetBody : string;
453 var
454         body, tmp               : string;
455         p, tail                 : PChar;
456         len                                     : Integer;
457 const
458         TAB_LENGTH      = 4;
459 begin
460
461         body := BodyEdit.Text;
462         if AmpToCharRefAction.Checked then
463                 // & \82Ì\92u\8a·\82Í\88ê\94Ô\8dÅ\8f\89\82É\82â\82é\82±\82Æ
464                 body := CustomStringReplace( body, '&', '&amp;' );
465         if SpaceToNBSPAction.Checked then begin
466                 p                       := PChar( body );
467                 tail    := p + Length( body );
468                 len             := 0;
469                 while p < tail do begin
470                         case p^ of
471                         #09:
472                                 begin
473                                         Inc( p );
474                                         repeat
475                                                 Inc( len );
476                                                 tmp := tmp + '&nbsp;';
477                                         until (len mod TAB_LENGTH) = 0;
478                                 end;
479
480                         #10, #13:
481                                 begin
482                                         tmp := tmp + p^;        Inc( p );
483                                         len     := 0;
484                                 end;
485
486                         ' ':
487                                 begin
488                                         tmp     := tmp + '&nbsp;';
489                                         Inc( p );
490                                         Inc( len );
491                                 end;
492                                 
493                         '&':
494                                 // \8eÀ\91Ì\8eQ\8fÆ\82Í 1 \95\8e\9a\95ª
495                                 begin
496                                         tmp := tmp + '&';
497                                         Inc( p );
498                                         Inc( len );
499                                         while p < tail do begin
500                                                 if p^ in ['a'..'z', 'A'..'Z', '0'..'9', '#'] then begin
501                                                         tmp := tmp + p^;
502                                                 end else if p^ = ';' then begin
503                                                         tmp := tmp + p^;
504                                                         Inc( p );
505                                                         Break;
506                                                 end else begin
507                                                         Break;
508                                                 end;
509                                                 Inc( p );
510                                         end;
511                                 end;
512
513                         else
514                                 if p^ in kYofKanji then begin
515                                         tmp := tmp + p^;        Inc( p );
516                                         tmp     := tmp + p^;    Inc( p );
517                                         len     := len + 2;
518                                 end else begin
519                                         tmp := tmp + p^;        Inc( p );
520                                         Inc( len );
521                                 end;
522                         end;
523                 end;
524                 body := tmp;
525         end;
526
527         Result  := body;
528
529 end;
530
531 procedure TEditorForm.SetFont;
532 begin
533         BodyEdit.Font.Name := GikoSys.Setting.EditorFontName;
534         BodyEdit.Font.Size := GikoSys.Setting.EditorFontSize;
535         BodyEdit.Font.Color := GikoSys.Setting.EditorFontColor;
536         BodyEdit.Color := GikoSys.Setting.EditorBackColor;
537 end;
538
539 procedure TEditorForm.Preview;
540 var
541         Title: string;
542         No: string;
543         Mail: string;
544         Namae: string;
545         Body: string;
546         s: string;
547 begin
548         if FThreadItem = nil then begin
549                 No := '1';
550                 Title := THTMLCreate.RepHtml(TitleEdit.Text);
551         end else begin
552                 No := IntToStr(FThreadItem.Count + 1);
553                 Title := THTMLCreate.RepHtml(FThreadItem.Title);
554         end;
555
556         Body := GetBody;
557         Namae := THTMLCreate.RepHtml(NameComboBox.Text);
558         Mail := THTMLCreate.RepHtml(MailComboBox.Text);
559         Body := THTMLCreate.RepHtml(Body);
560         Body := CustomStringReplace(Body, #13#10, '<br>', False);
561
562
563         if Trim(Namae) = '' then
564                 Namae := '\96¼\96³\82µ\82³\82ñ';
565
566     s := THTMLCreate.CreatePreviewHTML(Title, No, Mail, Namae, Body);
567     
568         SetContent(s, Browser);
569 end;
570
571 procedure TEditorForm.EditorPageChange(Sender: TObject);
572 var
573         tmpBoard: TBoard;
574 begin
575
576     tmpBoard := GetBoard;
577
578         if tmpBoard = nil then Exit;
579
580         if EditorPage.ActivePage = PreviewTab then begin
581                 Preview;
582         end else if EditorPage.ActivePage = RocalRuleTab then begin
583                 if not FileExists(tmpBoard.GETHEADTXTFileName) then begin
584                         LocalEdit.Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\96¢\8eæ\93¾';
585                         Exit;
586                 end;
587                 ShowBoardHead(tmpBoard, LocalEdit);
588         end else begin
589                 Browser.Navigate('about:blank');
590         end;
591 end;
592
593 procedure TEditorForm.BrowserStatusTextChange(Sender: TObject;
594         const Text: WideString);
595 begin
596         if EditorPage.ActivePage = PreviewTab then begin
597                 StatusBar.Panels[0].Text := Text;
598         end else begin
599                 StatusBar.Panels[0].Text := '';
600         end;
601 end;
602
603 function TEditorForm.Check: Boolean;
604 const
605         REQUIRED: string = '\82ª\93ü\97Í\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B';
606         ERROR: string = '\83G\83\89\81[';
607 var
608         Msg: string;
609         rc: Integer;
610         Board: TBoard;
611 begin
612         Result := True;
613
614     Board := GetBoard;
615
616         if (not GikoSys.Setting.UseMachineTime) and
617                  ((Board.LastGetTime = 0) or
618                         (Board.LastGetTime = ZERO_DATE)) then begin
619                 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
620                                  + '\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¢';
621                 MsgBox(Handle, Msg, ERROR, MB_OK or MB_ICONSTOP);
622                 Result := False;
623         end else if BodyEdit.Text = '' then begin
624                 Msg := '\96{\95¶' + REQUIRED;
625                 MsgBox(Handle, Msg, ERROR, MB_OK or MB_ICONSTOP);
626                 Result := False;
627         end else if (FBoard <> nil) and (Trim(TitleEdit.Text) = '') then begin
628                 Msg := '\83^\83C\83g\83\8b' + REQUIRED;
629                 MsgBox(Handle, Msg, ERROR, MB_OK or MB_ICONSTOP);
630                 Result := False;
631         end else begin
632                 if (not GikoSys.Dolib.Connected) and (AnsiPos('\81\9c', NameComboBox.Text) <> 0) then begin
633                         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
634                                          + '\82±\82Ì\82Ü\82Ü\91\97\90M\82µ\82Ä\82à\82æ\82ë\82µ\82¢\82Å\82·\82©\81H';
635                         rc := MsgBox(Handle, Msg, '\8am\94F', MB_YESNO or MB_ICONQUESTION);
636                         Result := (rc = IDYES);
637                 end;
638         end;
639 end;
640
641 procedure TEditorForm.FormClose(Sender: TObject; var Action: TCloseAction);
642 begin
643         Action := caFree;
644 end;
645
646 procedure TEditorForm.FormDestroy(Sender: TObject);
647 var
648         wp: TWindowPlacement;
649 begin
650     FSambaTimer.Free;
651     
652     if (Owner <> nil) and (Owner.ClassNameIs('TKeySettingForm') = False) then begin
653         //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95Û\91
654         wp.length := sizeof(wp);
655         GetWindowPlacement(Handle, @wp);
656
657         GikoSys.Setting.EditWindowTop := wp.rcNormalPosition.Top;
658         GikoSys.Setting.EditWindowLeft := wp.rcNormalPosition.Left;
659         GikoSys.Setting.EditWindowHeight := wp.rcNormalPosition.Bottom - wp.rcNormalPosition.Top;
660         GikoSys.Setting.EditWindowWidth := wp.rcNormalPosition.Right - wp.rcNormalPosition.Left;
661         GikoSys.Setting.EditWindowMax := WindowState = wsMaximized;
662         //GikoSys.Setting.EditWindowStay := FormStyle = fsStayOnTop;      // \83X\83e\83C\8fó\91Ô\82Ì\95Û\91
663         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;   // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
664     end;
665
666 end;
667
668 procedure TEditorForm.SetNameList(sName, sMail: string);
669 begin
670         if SaveNameMailAction.Checked then begin
671                 if Trim(sName) <> '' then begin
672                         if GikoSys.Setting.NameList.IndexOf(sName) = -1 then
673                                 GikoSys.Setting.NameList.Insert(0, sName);
674                 end;
675                 if Trim(sMail) <> '' then begin
676                         if GikoSys.Setting.MailList.IndexOf(sMail) = -1 then
677                                 GikoSys.Setting.MailList.Insert(0, sMail);
678                 end;
679         end;
680 end;
681
682 function TEditorForm.GetActiveControlHandle: THandle;
683 begin
684         if EditorPage.ActivePage = EditorTab then begin
685                 if ActiveControl = NameComboBox then
686                         Result := FNameComboEdit
687                 else if ActiveControl = MailComboBox then
688                         Result := FMailComboEdit
689                 else if ActiveControl = BodyEdit then
690                         Result := BodyEdit.Handle
691                 else if ActiveControl = TitleEdit then
692                         Result := TitleEdit.Handle
693                 else
694                         Result := 0;
695         end else if Editorpage.ActivePage = BoardInformationTab then begin
696                 if ActiveControl = BoardInformationMemo then
697                         Result := BoardInformationMemo.Handle
698                 else
699                         Result := 0;
700         end else if Editorpage.ActivePage = RocalRuleTab then begin
701                 if ActiveCOntrol = LocalEdit then
702                         Result := LocalEdit.Handle
703                 else
704                         Result := 0;
705         end else
706                 Result := 0;
707 end;
708
709 procedure TEditorForm.SetContent(Content: string; ABrowser: TWebBrowser);
710 var
711         doc: OleVariant;
712 begin
713         if Assigned(ABrowser.ControlInterface.Document) then begin
714                 doc := OleVariant(ABrowser.Document);
715                 doc.Clear;
716                 doc.open;
717                 doc.charset := 'Shift_JIS';
718                 doc.Write(Content);
719                 doc.Close;
720         end;
721 end;
722 procedure TEditorForm.InitIdHTTP(http: TIdHTTP);
723 begin
724         http.Request.Clear;
725         http.ProxyParams.BasicAuthentication := False;
726         if GikoSys.Setting.WriteProxy then begin
727                 http.ProxyParams.ProxyServer := GikoSys.Setting.WriteProxyAddress;
728                 http.ProxyParams.ProxyPort := GikoSys.Setting.WriteProxyPort;
729                 http.ProxyParams.ProxyUsername := GikoSys.Setting.WriteProxyUserID;
730                 http.ProxyParams.ProxyPassword := GikoSys.Setting.WriteProxyPassword;
731                 if GikoSys.Setting.ReadProxyUserID <> '' then
732                         http.ProxyParams.BasicAuthentication := True;
733         end else begin
734                 http.ProxyParams.ProxyServer := '';
735                 http.ProxyParams.ProxyPort := 80;
736                 http.ProxyParams.ProxyUsername := '';
737                 http.ProxyParams.ProxyPassword := '';
738         end;
739         http.Request.UserAgent := GikoSys.GetUserAgent;
740         http.Request.AcceptEncoding := '';
741     http.AllowCookies := True;
742     http.ReadTimeout := GikoSys.Setting.ReadTimeOut;
743     http.ConnectTimeout := GikoSys.Setting.ReadTimeOut;
744 end;
745 //! \91\97\90M\92\86\8e~\82Ì\82½\82ß\82Ì\83\81\83j\83\85\81[\82Ì\8dÄ\90
746 procedure TEditorForm.CancelSend(ABoard: TBoard; ASysMenu: HMENU);
747 begin
748         ABoard.SPID := '';
749         ABoard.PON := '';
750         FWork := false;
751         EnableMenuItem(ASysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
752         DrawMenuBar(Handle);
753 end;
754
755 procedure TEditorForm.Send( const ACOOKIE: string; const SPID: string;
756  const PON: string; FirstWriting: Boolean);
757 var
758         TextStream: TStringStream;
759         Source: TStringStream;
760         ResponseText: string;
761         URL: string;
762         State: TGikoDownloadState;
763         ResultType: TGikoResultType;
764         MsgResult: Integer;
765         Board: TBoard;
766         sysMenu : HMENU;
767     ExpMsg: String;
768     {Protocol,Host, Path, Document, Port, Bookmark : String;}
769 begin
770         FAbort := False;
771         State := gdsError;
772     Board := GetBoard;
773
774         InitIdHTTP(Indy);
775         if FThreadItem = nil then begin
776                 URL := FBoard.GetSendURL;
777                 Indy.Request.Referer := GikoSys.UrlToServer(FBoard.URL) + 'test/bbs.cgi';
778         end else begin
779                 URL := FThreadItem.GetSendURL;
780                 Indy.Request.Referer := FThreadItem.URL;
781         end;
782         sysMenu := GetSystemMenu( Handle, false );
783         EnableMenuItem( sysMenu, SC_CLOSE, MF_GRAYED );
784 {
785   EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
786   DrawMenuBar(Handle);
787 }
788         Indy.Request.CustomHeaders.Clear;
789 //      Indy.Request.CacheControl := 'no-cache';
790         Indy.Request.CustomHeaders.Add('Pragma: no-cache');
791         Indy.Request.AcceptLanguage := 'ja';
792         Indy.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
793         Indy.Request.ContentType := 'application/x-www-form-urlencoded';
794         Indy.Request.CustomHeaders.Add(getHeaderStr(ACOOKIE, SPID, PON, GikoSys.GetBouken(URL, FCookieDomain), Board));
795         TextStream := TStringStream.Create('');
796         Source := TStringStream.Create('');
797         try
798                 try
799                         FDebugStrReceive := '';
800                         FDebugStrSend := '';
801
802                         if (FirstWriting) then begin
803                                 //\83t\83V\83A\83i\83g\83\89\83b\83v\8cx\8d\90(LocalMode) by \92è\8aú\95Ö
804                 if (isLocalFusianaTrap) then begin
805                     CancelSend( Board, SysMenu );
806                     Exit;
807                 end;
808                 //\83t\83V\83A\83i\83g\83\89\83b\83v\8cx\8d\90(Remote)
809                 if (isRemoteFusianaTrap) then begin
810                     CancelSend( Board, SysMenu );
811                     Exit;
812                 end;
813                 // \8cë\94\9a\83`\83F\83b\83N
814                 if (isGobaku) then begin
815                     CancelSend( Board, SysMenu );
816                     Exit;
817                 end;
818                         end;
819
820                         GetSendData(Source);
821                         IdAntiFreeze.Active := True;
822                         try
823                                 Indy.Post(URL, Source, TextStream);
824                         finally
825                                 IdAntiFreeze.Active := False;
826                         end;
827                         ResponseText := TextStream.DataString;
828
829                         ResultType := GetResultType(ResponseText);
830
831
832                         if ResultType = grtOK then begin
833                                 if (GikoSys.Setting.UseSamba) and  (FSambaTimer.Enabled) then
834                 begin
835                     FSambaTimer.WriteSambaTime(Now());
836                 end;
837                 GetCookie(Indy.CookieManager, Board);
838                                 State := gdsComplete;
839                         end else if ResultType = grtCookie then begin
840                                 //\83\8b\81[\83v\96h\8e~
841                                 if not FirstWriting then
842                                         raise Exception.Create('');
843
844                                 MsgResult := MsgBox( Handle,
845                                                                 '\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 +
846                                                                 '\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 +
847                                                                 '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
848                                                                 '\8fî\95ñ',
849                                                                 MB_YESNO or MB_ICONQUESTION);
850
851                                 if MsgResult = IDYES then begin
852                                         GetCookie(Indy.CookieManager, Board);
853                     if (Board.Is2ch) then begin
854                         GetHiddenParameter(ResponseText, Board);
855                     end;
856
857                                         if (Board.SPID = '') and (Board.PON = '') and (Board.Cookie = '') then
858                                                 raise Exception.Create('');
859                                         //\82à\82¤\88ê\89ñ\82±\82Ì\83\81\83\\83b\83h
860                                         Send(Board.Cookie, Board.SPID, Board.PON, False);
861                                         Exit;
862                                 end else begin
863                                         CancelSend( Board, SysMenu );
864                                         Exit;
865                                 end;
866                         end else if ResultType = grtCheck then begin
867                                 //\83\8b\81[\83v\96h\8e~
868                                 if not FirstWriting then
869                                         raise Exception.Create('');
870
871                                 MsgResult := MsgBox( Handle,
872                                                 '\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 +
873                                                 '\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 +
874                                                 '\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 +
875                                                 '\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 +
876                                                 #13#10 +
877                                                 '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
878                                                 '\8am\94F',
879                                                 MB_YESNO or MB_ICONQUESTION);
880
881                                 if MsgResult = IDYES then begin
882                                         GetCookie(Indy.CookieManager, Board);
883                     if (Board.Is2ch) then begin
884                         GetHiddenParameter(ResponseText, Board);
885                     end;
886
887                                         if (Board.SPID = '') and (Board.PON = '') and (Board.Cookie = '') then
888                                                 raise Exception.Create('');
889
890
891                                         Send(Board.Cookie, Board.SPID, Board.PON, False);
892                                         Exit;
893                                 end else begin
894                                         CancelSend( Board, SysMenu );
895                                         Exit;
896                                 end;
897                         end else if ResultType = grtNinpou then begin
898                                 MsgBox( Handle,
899                                                 '\8bM\95û\82Ì\94E\96@\92\9f\82ð\8dì\90¬\92\86\82Å\82·\81B\88ø\82«\95Ô\82·\82È\82ç\82¢\82Ü\82¾\81B(\82Q\95ª\82Ù\82Ç\82©\82©\82è\82Ü\82·)' + #13#10
900                                                 , '\8am\94F',
901                                                 MB_OK or MB_ICONINFORMATION);
902                                 if (GikoSys.Setting.UseSamba)  and  (FSambaTimer.Enabled) then
903                 begin
904                                         FSambaTimer.WriteSambaTime(Now());
905                 end;
906                 Board.PON  := '';
907                 Board.SPID := '';
908                 Board.Cookie := '';
909                 GetCookie(Indy.CookieManager, Board);
910                                 Exit;
911             end else if ResultType = grtSuiton then begin
912                                 MsgBox( Handle,
913                                                 '\8bM\95û\82Ì\94E\96@\92\9f\82Í\8fÄ\82©\82ê\82Ü\82µ\82½\81B' + #13#10 +
914                         '\94E\96@\92\9f\82ð\8dí\8f\9c\82µ\82Ü\82µ\82½\81A\8dÄ\91\97\90M\82µ\82Ä\82­\82¾\82³\82¢\81B'
915                                                 , '\8am\94F',
916                                                 MB_OK or MB_ICONINFORMATION);
917                 // \94E\96@\92\9f\8aª\95¨\82ð\8fÁ\82·
918                 GikoSys.DelBoukenCookie(FCookieDomain);
919                 GikoSys.Setting.WriteBoukenSettingFile;
920                 Board.PON  := '';
921                 Board.SPID := '';
922                 Board.Cookie := '';
923                 Exit;
924                         end else begin
925                                 if (GikoSys.Setting.UseSamba)  and  (FSambaTimer.Enabled) then
926                 begin
927                                         FSambaTimer.WriteSambaTime(Now());
928                 end;
929                 // \94E\96@\92\9f\8aª\95¨\83G\83\89\81[\82ÍCookie\82ð\8dX\90V\82·\82é
930                 if ResultType = grtNinpouErr then begin
931                     GetCookie(Indy.CookieManager, Board);
932                 end;
933                                 State := gdsError;
934                                 raise Exception.Create('');
935                         end;
936                 except
937             on E: EIdSocketError do begin
938                                 State := gdsError;
939                                 ResponseText := '<html><body>'
940                                                                                         + '<div>\90Ú\91±\82ª\8e¸\94s\82µ\82Ü\82µ\82½<br>'
941                                                                                         + '\89ñ\90ü\82Ì\8fó\91Ô\82ð\92²\82×\82Ä\82­\82¾\82³\82¢<br></div>'
942                                                                                         + '<br><br><div>' + E.Message + '</div>'
943                                                                                         + '</body></html>';
944             end;
945                         on E: EIdConnectException do begin
946                                 State := gdsError;
947                                 ResponseText := '<html><body>'
948                                                                                         + '<div>\90Ú\91±\82ª\8e¸\94s\82µ\82Ü\82µ\82½<br>'
949                                                                                         + '\89ñ\90ü\82â\83v\83\8d\83L\83V\82Ì\8fó\91Ô\82ð\92²\82×\82Ä\82­\82¾\82³\82¢<br></div>'
950                                                                                         + '<br><br><div>' + E.Message + '</div>'
951                                                                                         + '</body></html>';
952                         end;
953                         on E: Exception do begin
954                                 State := gdsError;
955
956                                 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '<', '&lt;');
957                                 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '>', '&gt;');
958                                 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '<', '&lt;');
959                                 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '>', '&gt;');
960                 ExpMsg := AnsiReplaceText(E.Message, '<', '&lt;');
961                                 ExpMsg := AnsiReplaceText(ExpMsg,    '>', '&gt;');
962
963                                 ResponseText := '<html><body>' + TextStream.DataString;
964                                 ResponseText := AnsiReplaceText(ResponseText, '</body>', '');
965                                 ResponseText := AnsiReplaceText(ResponseText, '</html>', '');
966                                 ResponseText := ResponseText + '<hr><div align="left"><pre>';
967                                 ResponseText := ResponseText + '<b>\82±\82±\82©\82ç\83M\83R\83i\83r\82Ì\8fî\95ñ</b>'#13#10;
968                                 ResponseText := ResponseText + #13#10'\81\9c\97á\8aO'#13#10;
969                                 ResponseText := ResponseText + ExpMsg;
970                                 ResponseText := ResponseText + #13#10'\81\9c\91\97\90M'#13#10;
971                                 ResponseText := ResponseText + FDebugStrSend;
972                                 ResponseText := ResponseText + #13#10'\81\9c\8eó\90M'#13#10;
973                                 ResponseText := ResponseText + FDebugStrReceive;
974                                 ResponseText := ResponseText + '</pre></div></body></html>';
975                         end;
976                 end;
977                 FStatusCode := Indy.ResponseCode;
978                 if FAbort then
979                         State := gdsAbort;
980         finally
981                 Source.Free;
982                 TextStream.Free;
983         if ( Indy.CookieManager <> nil ) then begin
984             Indy.CookieManager.CookieCollection.Clear;
985         end;
986                 //sysMenu := GetSystemMenu( Handle, true );
987                 EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
988                 DrawMenuBar(Handle);
989         end;
990         FWork := false;
991     //\94ñ\8cö\8e®\83M\83R\83i\83r\94Â\82È\82Ç\82Ì2ch\8cÝ\8a·\83X\83N\83\8a\83v\83g\97p
992     //2ch\88È\8aO\82Å\82©\82ÂResponceCode\82ª302Found\82Å\8f\91\82«\8d\9e\82Ý\8a®\97¹
993     //if (not Board.Is2ch) and (FStatusCode = 302) then begin
994     if FStatusCode = 302 then begin
995         GikoForm.PlaySound('ResEnd');
996         SaveSendFile;
997         AddFormMessageNew( gmiOK );
998         if (not ContinueModeAction.Enabled) or (not ContinueModeAction.Checked) then begin
999             Close;
1000             Exit;
1001         end;
1002     end;
1003         if State = gdsComplete then begin
1004                 GikoForm.PlaySound('ResEnd');
1005                 SaveSendFile;
1006         AddFormMessageNew( gmiOK );
1007         if (not ContinueModeAction.Enabled) or (not ContinueModeAction.Checked) then begin
1008                 Close;
1009         end;
1010         end else if State = gdsError then begin
1011         AddFormMessageNew( gmiOK );
1012                 EditorPage.ActivePage := PreviewTab;
1013                 SetContent(ResponseText, Browser);
1014         end else if State = gdsAbort then begin
1015                 GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmAbort), nil, gmiSAD);
1016         end;
1017 end;
1018 function TEditorForm.GetResultType(ResponseText: string): TGikoResultType;
1019 begin
1020         if AnsiPos('\8f\91\82«\82±\82Ý\82ª\8fI\82í\82è\82Ü\82µ\82½', ResponseText) <> 0 then
1021                 Result := grtOK
1022     else if ( (AnsiPos('<b>\82æ\82¤\82±\82»\81F\8bM\95û\82Ì\94E\96@\92\9f\82ð\8dì\90¬\82µ\82Ü\82·\81B\82Q\95ª\8cã\82É\8dÄ\93x\8f\91\82«\8d\9e\82Þ\82©\81A\82¨\8bA\82è\82­\82¾\82³\82¢', ResponseText) > 0) or
1023               (AnsiPos('\82d\82q\82q\82n\82q\81F\8bM\95û\82Ì\96`\8c¯\82Ì\8f\91\82ð\8dì\90¬\92\86\82Å\82·', ResponseText) > 0) )
1024                 and (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)  then
1025         Result := grtNinpou
1026     else if ( (AnsiPos('\82d\82q\82q\82n\82q\81F\8fC\8ds\82ª\91«\82è\82Ü\82¹\82ñ', ResponseText) > 0) or   // \83G\83\89\81[\88µ\82¢
1027               (AnsiPos('\82d\82q\82q\82n\82q\81FLv\82ª\91«\82è\82È\82­\82Ä\83X\83\8c\83b\83h\97§\82Ä', ResponseText) > 0) ) // \83G\83\89\81[\88µ\82¢
1028               and (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)    then
1029         Result := grtNinpouErr
1030     else if( AnsiPos('<b>\82â\82ç\82ê\82½\82Å\82²\82´\82é\81FLv=0 <br>\82³\82Ä\8e©\97Í\82Å\95\9c\8a\88\82Å\82«\82é\82©\82È?', ResponseText) > 0) 
1031               and (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)    then
1032         Result := grtSuiton
1033         else if ( AnsiPos('\83N\83b\83L\81[\82ª\82È\82¢\82©\8aú\8cÀ\90Ø\82ê\82Å\82·', ResponseText) > 0) or
1034                                         (AnsiPos('<title>\83N\83b\83L\81[\8am\94F\81I</title>', ResponseText) > 0)    or
1035                                         (AnsiPos('<title>\81¡\83N\83b\83L\81[\8am\94F\81I\81¡</title>', ResponseText) > 0) or
1036                     (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)  then
1037                 Result := grtCookie
1038         else if (AnsiPos('<font size=+2 color=#FF0000>\8f\91\82«\8d\9e\82Ý\83`\83F\83b\83N\81I </font>', ResponseText) > 0)   or
1039                                         (AnsiPos('<title>\81¡ \8f\91\82«\8d\9e\82Ý\8am\94F\82µ\82Ü\82· \81¡</title>', ResponseText) > 0)  or
1040                                         (AnsiPos('<title>\93\8a\8de\8am\94F</title>', ResponseText) > 0)  or
1041                                         (AnsiPos('<b>\8f\91\82«\82±\82Ý\8am\94F</b>', ResponseText) > 0)      or
1042                                         (AnsiPos('="../test/subbbs.cgi">', ResponseText) > 0)   or
1043                                         (AnsiPos(RES2CH_FALSE, ResponseText) > 0)       then
1044                 Result := grtCheck
1045         else if (AnsiPos('\81E\93\8a\8de\8eÒ\82Í\81A\8cf\8e¦\94Â\89^\89c\8eÒ\82É\91Î\82µ\82Ä\81A\92\98\8dì\8eÒ\90l\8ai\8c \82ð\88ê\90Ø\8ds\8eg\82µ\82È\82¢\82±\82Æ\82ð\8f³\91ø\82µ\82Ü\82·\81B<br>', ResponseText) > 0) or
1046                                         (AnsiPos('\81i\92\98\8dì\8c \96@\91æ21\8fð\82È\82¢\82µ\91æ28\8fð\82É\8bK\92è\82³\82ê\82é\8c \97\98\82à\8aÜ\82Þ\81j\82»\82Ì\91¼\82Ì\8c \97\98\82É\82Â\82«\81A', ResponseText) > 0) then
1047                 Result := grtCookie
1048     else
1049         Result := grtError;
1050 end;
1051
1052
1053 procedure TEditorForm.GetSendData(Source: TStringStream);
1054 var
1055         SessionID: string;
1056         s: string;
1057         SendTime: Integer;
1058         Adjust: Integer;
1059         Board: TBoard;
1060         body            : string;
1061 begin
1062     Board := GetBoard;
1063
1064         if GikoSys.Setting.UseMachineTime then begin
1065                 if GikoSys.Setting.TimeAdjust then
1066                         Adjust := Gikosys.Setting.TimeAdjustSec
1067                 else
1068                         Adjust := GikoSys.Setting.TimeAdjustSec * -1;
1069                 SendTime := GikoSys.DateTimeToInt(Now) - (9 * 60 * 60) + Adjust
1070         end else begin
1071                 if (Board.LastGetTime = 0) or (Board.LastGetTime = ZERO_DATE) then
1072                         SendTime := GikoSys.DateTimeToInt(Now)
1073                 else
1074                         SendTime := GikoSys.DateTimeToInt(Board.LastGetTime);
1075         end;
1076
1077         body := GetBody;
1078
1079         SessionID := GikoSys.Dolib.SessionID;
1080         if SessionID <> '' then
1081                 s := 'sid=' + HttpEncode(SessionID) + '&'
1082         else
1083                 s := '';
1084         s := s + 'subject=&'
1085                + 'FROM=' + HttpEncode(NameComboBox.Text) + '&'
1086                + 'mail=' + HttpEncode(MailComboBox.Text) + '&'
1087                + 'MESSAGE=' + HttpEncode(body) + '&'
1088                + 'bbs=' + Board.BBSID + '&'
1089                            + 'time=' + IntToStr(SendTime) + '&';
1090                            
1091         if FThreadItem = nil then begin
1092                 s := s + 'subject=' + HttpEncode(TitleEdit.Text) + '&';
1093                 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;
1094         end else begin
1095                 s := s + 'key=' + ChangeFileExt(FThreadItem.FileName, '') + '&';
1096                 s := s + 'submit=' + HttpEncode('\8f\91\82«\8d\9e\82Þ') + #13#10;
1097         end;
1098         Source.WriteString(s);
1099 end;
1100
1101 procedure TEditorForm.SaveSendFile;
1102 var
1103         sDate: string;
1104         ini: TMemIniFile;
1105 begin
1106         ini := CreateSentIniFile;
1107     if (ini <> nil) then begin
1108         try
1109             sDate := IntToStr(GikoSys.DateTimeToInt(Now));
1110
1111             ini.WriteString(sDate, 'Name', NameComboBox.Text);
1112             ini.WriteString(sDate, 'EMail', MailComboBox.Text);
1113             ini.WriteString(sDate, 'Body', HttpEncode(BodyEdit.Text));
1114             ini.WriteInteger(sDate, 'Status', FStatusCode);
1115             ini.WriteDateTime(sDate, 'Date', Now);
1116             if FThreadItem = nil then begin
1117                 ini.WriteString(sDate, 'Title', MojuUtils.Sanitize(TitleEdit.Text));
1118                 //ini.WriteString(sDate, 'BBS', FBoard.BBSID);
1119                 ini.WriteString(sDate, 'URL', FBoard.URL);
1120                 ini.WriteInteger(sDate, 'NewThread', 1);
1121             end else begin
1122                 ini.WriteString(sDate, 'Title', FThreadItem.Title);
1123                 //ini.WriteString(sDate, 'BBS', FThreadItem.ParentBoard.BBSID);
1124                 ini.WriteString(sDate, 'URL', FThreadItem.URL);
1125                 ini.WriteString(sDate, 'Key', ChangeFileExt(FThreadItem.FileName, ''));
1126             end;
1127
1128             ini.UpdateFile;
1129         finally
1130             ini.Free;
1131         end;
1132     end;
1133 end;
1134 function TEditorForm.CreateSentIniFile: TMemIniFile;
1135 var
1136     maxSize, fileSize, i: Integer;
1137     newName: String;
1138 begin
1139     Result := nil;
1140     // MB -> bytes
1141     maxSize := GikoSys.Setting.SentIniFileSize * 1024 * 1024;
1142     // \83t\83@\83C\83\8b\83T\83C\83Y\82ª0\82Ì\8fê\8d\87\82Í\81Asent.ini\82É\8f\91\82«\8d\9e\82Ü\82È\82¢\82Ì\82Ånil\82ð\95Ô\82·
1143     if (maxSize > 0) then begin
1144         fileSize := GikoSys.GetFileSize(GikoSys.Setting.GetSentFileName);
1145         // \8dÅ\91å\83T\83C\83Y\82ð\92´\82¦\82Ä\82¢\82½\8fê\8d\87\82Í\83\8a\83l\81[\83\80\82·\82é
1146         if (fileSize >= maxSize) then begin
1147             i := 0;
1148             // \8d¡\82Ì\8e\9e\8d\8f\82ð\83t\83@\83C\83\8b\96¼\82Ì\8cã\82ë\82É\82Â\82¯\82é
1149             repeat
1150                 // 10\89ñ\88È\8fã\8e¸\94s\82µ\82½\82ç\82 \82«\82ç\82ß\82é
1151                 if (i > 10) then break;
1152                 DateTimeToString(newName, 'yyhhnnsszzz', Now());
1153                 Inc(i);
1154             until RenameFile(GikoSys.Setting.GetSentFileName,
1155                 GikoSys.Setting.GetSentFileName + '.' + newName);
1156         end;
1157         Result := TMemIniFile.Create(GikoSys.Setting.GetSentFileName);
1158     end;
1159 end;
1160 procedure TEditorForm.SendActionExecute(Sender: TObject);
1161 const
1162         TITLE_SAMBA : string = 'Samba24\8cx\8d\90';
1163 var
1164         Board: TBoard;
1165         rc: Integer;
1166         rc2: Integer;
1167         state : TGikoDownloadState;
1168         body            : string;
1169 begin
1170         if FWork then
1171                 Exit;
1172         try
1173                 FWork := True;
1174                 SendAction.Enabled := False;
1175                 Application.ProcessMessages;
1176                 if not Check then Exit;
1177
1178         Board := GetBoard;
1179
1180                 if FThreadItem = nil then begin
1181                         rc := GikoUtil.MsgBox(Handle,
1182                                                                                                         '\81u' + Board.Title + '\81v\94Â\82É\90V\82µ\82¢\83X\83\8c\83b\83h\97§\82Ä\82Ü\82·'#13#10#13#10
1183                                                                                                         + '\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
1184                                                                                                         + '\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
1185                                                                                                         + '\81u\82Í\82¢\81v\82ð\89\9f\82·\82Æ\91\97\90M\82µ\82Ü\82·',
1186                                                                                                         '\8am\94F',
1187                                                                                                         MB_ICONQUESTION or MB_YESNO);
1188                         if rc <> ID_YES then
1189                                 Exit;
1190                 end;
1191
1192                 SetNameList(NameComboBox.Text, MailComboBox.Text);
1193                 if (KotehanCheckBox.Enabled) and (KotehanCheckBox.Checked) then begin
1194                         Board.KotehanName := NameComboBox.Text;
1195                         Board.KotehanMail := MailComboBox.Text;
1196                 end;
1197
1198                 if Board.IsBoardPlugInAvailable then begin
1199                         body := GetBody;
1200
1201                         if FThreadItem = nil then begin
1202                                 // \83X\83\8c\97§\82Ä
1203                                 state := TGikoDownloadState( Board.BoardPlugIn.CreateThread(
1204                                         DWORD( Board ), TitleEdit.Text, NameComboBox.Text, MailComboBox.Text, body ) );
1205
1206                                 if state = gdsComplete then begin
1207                                         GikoForm.PlaySound('ResEnd');
1208                                         SaveSendFile;
1209                                         GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmNewSure), nil, gmiOK);
1210                                         FWork := False;
1211                                         Close;
1212                                 end else if State = gdsError then begin
1213                                         GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmSureError), nil, gmiNG);
1214                                 end else if State = gdsAbort then begin
1215                                         GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmAbort), nil, gmiNG);
1216                                 end;
1217                         end else begin
1218                                 // \83\8c\83X
1219                                 state := TGikoDownloadState( FThreadItem.ParentBoard.BoardPlugIn.WriteThread(
1220                                         DWORD( FThreadItem ), NameComboBox.Text, MailComboBox.Text, body ) );
1221
1222                                 if state = gdsComplete then begin
1223                                         GikoForm.PlaySound('ResEnd');
1224                                         SaveSendFile;
1225                                         GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmNewRes), nil, gmiOK);
1226                                         FWork := False;
1227                                         Close;
1228                                 end else if State = gdsError then begin
1229                                         GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmResError), nil, gmiOK);
1230                                 end else if State = gdsAbort then begin
1231                     GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmAbort), nil, gmiOK);
1232                                 end;
1233                         end;
1234                 end else begin
1235                         if not FSambaTimer.Enabled then begin
1236                                 if CompareDateTime(Board.Expires ,Now) <= 0 then begin
1237                                         Board.Cookie    := '';
1238                                         Board.SPID      := '';
1239                                         Board.PON               := '';
1240                                 end;
1241                 // \96`\8c¯\82Ì\8f\91\83\8c\83x\83\8b\96ß\82é\96â\91è\91Î\89\9e
1242                 if (Board.Is2ch) and (AnsiPos('HAP=', Board.Cookie)>0) then begin
1243                     Board.Cookie := '';
1244                 end;
1245                                 Send(Board.Cookie, Board.SPID, Board.PON, True);
1246                         end else begin
1247                                 if not FSambaTimer.CheckSambaTime(Now()) then begin
1248                                         rc := GikoUtil.MsgBox(Handle,
1249                                                                 'Samba24\82Ì\8bK\92è\92l\96¢\96\9e\82Ì\95b\90\94\82µ\82©\8co\89ß\82µ\82Ä\82¢\82Ü\82¹\82ñ\81B'#13#10
1250                                                                 + '\91\97\90M\82ð\92\86\8e~\82µ\82Ü\82·\82©\81H' + #13#10
1251                                                                 + '(\81u\82¢\82¢\82¦\81v\82¾\82Æ\91\97\90M\82µ\82Ü\82·)', TITLE_SAMBA,
1252                                                                 MB_YESNO or MB_ICONQUESTION);
1253                                         if rc = IDYES then begin
1254                                                 FWork := false;
1255                                                 Exit;
1256                                         end;
1257                                         if rc = IDNO then begin
1258                                                 rc2 := GikoUtil.MsgBox(Handle,
1259                                                                        '\96{\93\96\82É\91\97\90M\82µ\82Ü\82·\82©\81H',
1260                                                                        TITLE_SAMBA,
1261                                                                        MB_YESNO or MB_ICONQUESTION);
1262                                                 if rc2 = IDNO then begin
1263                                                         FWork := False;
1264                                                         Exit;
1265                                                 end;
1266                                         end;
1267                                 end;
1268                                 if CompareDateTime(Board.Expires ,Now) <= 0 then begin
1269                                         Board.Cookie    := '';
1270                                         Board.SPID      := '';
1271                                         Board.PON               := '';
1272                                 end;
1273                 // \96`\8c¯\82Ì\8f\91\83\8c\83x\83\8b\96ß\82é\96â\91è\91Î\89\9e
1274                 if (Board.Is2ch) and (AnsiPos('HAP=', Board.Cookie)>0) then begin
1275                     Board.Cookie := '';
1276                 end;
1277                                 Send(Board.Cookie, Board.SPID, Board.PON, True);
1278                         end;
1279                 end;
1280         finally
1281                 FWork := False;
1282                 if FSambaTimer.Enabled then begin
1283                         FNow := FSambaTimer.Update;
1284         end;
1285         end;
1286 end;
1287
1288 procedure TEditorForm.SaveActionExecute(Sender: TObject);
1289 begin
1290 //
1291 end;
1292
1293 procedure TEditorForm.CloseActionExecute(Sender: TObject);
1294 begin
1295         Close;
1296 end;
1297
1298 procedure TEditorForm.UndoActionExecute(Sender: TObject);
1299 begin
1300         SendMessage(GetActiveControlHandle, WM_UNDO, 0, 0);
1301 end;
1302
1303 procedure TEditorForm.CutActionExecute(Sender: TObject);
1304 begin
1305         SendMessage(GetActiveControlHandle, WM_CUT, 0, 0);
1306 end;
1307
1308 procedure TEditorForm.CopyActionExecute(Sender: TObject);
1309 begin
1310         SendMessage(GetActiveControlHandle, WM_COPY, 0, 0);
1311 end;
1312
1313 procedure TEditorForm.PasteActionExecute(Sender: TObject);
1314 begin
1315         SendMessage(GetActiveControlHandle, WM_PASTE, 0, 0);
1316 end;
1317
1318 procedure TEditorForm.SelectAllActionExecute(Sender: TObject);
1319 begin
1320         SendMessage(GetActiveControlHandle, EM_SETSEL, 0, GetWindowTextLength(GetActiveControlHandle));
1321 end;
1322
1323 procedure TEditorForm.TopActionExecute(Sender: TObject);     // \83E\83B\83\93\83h\83E\8dÅ\91O\96Ê(Stay)\83{\83^\83\93\82Ì\8f\88\97\9d
1324 begin
1325         if not (fsShowing in Self.FormState) then begin
1326                 if TopAction.Checked then begin // \83X\83e\83C\8fó\91Ô\82É\90Ý\92è
1327                         SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
1328                         GikoSys.Setting.EditWindowStay := true;
1329                 end     else begin   // \83X\83e\83C\8fó\91Ô\89ð\8f\9c
1330                         SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
1331                         GikoSys.Setting.EditWindowStay := false;
1332                 end;
1333                 // \83X\83e\83C\8fó\91Ô\82Ì\95Û\91
1334                 //GikoSys.Setting.EditWindowStay := FormStyle = fsStayOnTop;
1335         end;
1336 end;
1337
1338 procedure TEditorForm.AbortActionExecute(Sender: TObject);
1339 begin
1340         FAbort := True;
1341 end;
1342
1343 procedure TEditorForm.SendActionUpdate(Sender: TObject);
1344 begin
1345         SendAction.Enabled := not FWork;
1346 end;
1347
1348 procedure TEditorForm.SaveActionUpdate(Sender: TObject);
1349 begin
1350         SaveAction.Enabled := False;
1351 end;
1352
1353 procedure TEditorForm.CloseActionUpdate(Sender: TObject);
1354 begin
1355         CloseAction.Enabled := not FWork;
1356 end;
1357
1358 procedure TEditorForm.UndoActionUpdate(Sender: TObject);
1359 begin
1360         UndoAction.Enabled := (GetActiveControlHandle <> 0)
1361                                                                                                 and (SendMessage(GetActiveControlHandle, EM_CANUNDO, 0, 0) <> 0)
1362                                                                                                 and (not FWork);
1363 end;
1364
1365 procedure TEditorForm.CutActionUpdate(Sender: TObject);
1366 var
1367         Selection: TSelection;
1368         AHandle: THandle;
1369 begin
1370         AHandle := GetActiveControlHandle;
1371         SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
1372         CutAction.Enabled := (AHandle <> 0)
1373                                                                                 and ((Selection.EndPos - Selection.StartPos) <> 0)
1374                                                                                 and (not FWork);
1375 end;
1376
1377 procedure TEditorForm.CopyActionUpdate(Sender: TObject);
1378 var
1379         Selection: TSelection;
1380         AHandle: THandle;
1381 begin
1382         AHandle := GetActiveControlHandle;
1383         SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
1384         CopyAction.Enabled := (AHandle <> 0)
1385                                                                                 and ((Selection.EndPos - Selection.StartPos) <> 0)
1386                                                                                 and (not FWork);
1387 end;
1388
1389 procedure TEditorForm.PasteActionUpdate(Sender: TObject);
1390 begin
1391         PasteAction.Enabled := (GetActiveControlHandle <> 0)
1392                                                                                         and (Clipboard.HasFormat(CF_TEXT))
1393                                                                                         and (not FWork);
1394 end;
1395
1396 procedure TEditorForm.TopActionUpdate(Sender: TObject);
1397 begin
1398         TopAction.Enabled := not FWork;
1399 end;
1400
1401 procedure TEditorForm.SageCheckBoxClick(Sender: TObject);
1402 begin
1403         if SageCheckBox.Checked then begin
1404                 if AnsiPos('sage', MailComboBox.Text) = 0 then
1405                         MailComboBox.Text := 'sage' + MailComboBox.Text;
1406         end else begin
1407                 if AnsiPos('sage', MailComboBox.Text) <> 0 then
1408                         MailComboBox.Text := StringReplace(MailComboBox.Text, 'sage', '', [rfReplaceAll]);
1409         end;
1410 end;
1411
1412 procedure TEditorForm.MailComboBoxChange(Sender: TObject);
1413 begin
1414         if AnsiPos('sage', MailComboBox.Text) = 0 then
1415                 SageCheckBox.Checked := False
1416         else
1417                 SageCheckBox.Checked := True;
1418 end;
1419
1420 procedure TEditorForm.IdLogDebugReceive(ASender: TIdConnectionIntercept;
1421         AStream: TStream);
1422 var
1423         StringStream: TStringStream;
1424 begin
1425         StringStream := TStringStream.Create('');
1426         try
1427                 StringStream.CopyFrom(AStream, AStream.Size);
1428                 FDebugStrReceive := FDebugStrReceive + StringStream.DataString;
1429         finally
1430                 StringStream.Free;
1431         end;
1432 end;
1433
1434 procedure TEditorForm.IdLogDebugSend(ASender: TIdConnectionIntercept;
1435         AStream: TStream);
1436 var
1437         StringStream: TStringStream;
1438 begin
1439         StringStream := TStringStream.Create('');
1440         try
1441                 StringStream.CopyFrom(AStream, AStream.Size);
1442                 FDebugStrSend := FDebugStrSend + StringStream.DataString;
1443         finally
1444                 StringStream.Free;
1445         end;
1446 end;
1447
1448 procedure TEditorForm.TransActionExecute(Sender: TObject);
1449 begin
1450         AlphaBlend := TransAction.Checked;
1451         // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
1452         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;
1453 end;
1454
1455 procedure TEditorForm.TransActionUpdate(Sender: TObject);
1456 begin
1457         TransAction.Enabled := not FWork;
1458 end;
1459 //StatusBar\82ÌPanels[0]\82Ì\95\9d\82ð\89Â\95Ï\81B\8ec\82è\82ð\8cÅ\92è\82É\82·\82é
1460 procedure TEditorForm.StatusBarResize(Sender: TObject);
1461 begin
1462         StatusBar.Panels[0].Width := StatusBar.Width
1463                                                                         - StatusBar.Panels[1].Width - StatusBar.Panels[2].Width;
1464
1465 end;
1466
1467 //Form\82ªActive\82É\82È\82Á\82½\82ç\8dÅ\8fI\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82ð\93Ç\82Ý\8d\9e\82Þ
1468 procedure TEditorForm.FormActivate(Sender: TObject);
1469 begin
1470         if ( FSambaTimer.Enabled ) and ( FThreadItem <> nil ) then
1471     begin
1472                 FNow := FSambaTimer.Update;
1473     end;
1474         if GikoSys.Setting.GestureEnabled then begin
1475                 GikoSys.Setting.Gestures.ClearGesture;
1476                 GikoSys.Setting.Gestures.LoadGesture(
1477                         GikoSys.Setting.GetGestureFileName, ActionList );
1478                 MouseGesture.UnHook;
1479                 MouseGesture.OnGestureStart := OnGestureStart;
1480                 MouseGesture.OnGestureMove := OnGestureMove;
1481                 MouseGesture.OnGestureEnd := OnGestureEnd;
1482                 MouseGesture.SetHook( Handle );
1483         end;
1484 end;
1485 procedure TEditorForm.FormCloseQuery(Sender: TObject;
1486   var CanClose: Boolean);
1487 begin
1488         CanClose := not FWork;
1489 end;
1490
1491 procedure TEditorForm.QuotePasteActionExecute(Sender: TObject);
1492 var
1493         s                       : TStringList;
1494         i                       : Integer;
1495         quote   : string;
1496 begin
1497
1498         quote   := GikoSys.GetOEIndentChar;
1499         s                       := TStringList.Create;
1500         try
1501                 s.Text  := Clipboard.AsText;
1502
1503                 for i := s.Count - 1 downto 0 do
1504                         s[ i ]  := quote + s[ i ];
1505
1506                 BodyEdit.SelText        := s.Text;
1507         finally
1508                 s.Free;
1509         end;
1510
1511 end;
1512
1513 procedure TEditorForm.SpaceToNBSPActionExecute(Sender: TObject);
1514 begin
1515         GikoSys.Setting.SpaceToNBSP := SpaceToNBSPAction.Checked;
1516         if EditorPage.ActivePage = PreviewTab then
1517                 Preview;
1518 end;
1519
1520 procedure TEditorForm.AmpToCharRefActionExecute(Sender: TObject);
1521 begin
1522         GikoSys.Setting.AmpToCharRef := AmpToCharRefAction.Checked;
1523         if EditorPage.ActivePage = PreviewTab then
1524                 Preview;
1525 end;
1526
1527 procedure TEditorForm.BoardTopClick(Sender: TObject);
1528 var
1529         ini: TMemIniFile;
1530 begin
1531         ini := TMemIniFile.Create(GikoSys.Setting.GetFileName);
1532         try
1533                 BoardtopTab.TabVisible := BoardTop.Checked;
1534                 ini.WriteBool('EditorForm', 'BoardTopTab', BoardtopTab.TabVisible);
1535         ini.UpdateFile;
1536         finally
1537                 ini.Free;
1538         end;
1539 end;
1540
1541
1542 procedure TEditorForm.GetSETTINGTXTActionExecute(Sender: TObject);
1543 var
1544         memStream: TMemoryStream;
1545         URL, RefURL: string;
1546         settingBody: TStringList;
1547         tmpBoard: TBoard;
1548 begin
1549         if not FWork then begin
1550         FWork := True;
1551
1552         tmpBoard := GetBoard;
1553         if tmpBoard <> nil then begin
1554
1555             RefURL      := tmpBoard.URL;
1556             if RefURL[Length(RefURL)] <> '/' then
1557                 URL     := RefURL + '/' + 'SETTING.TXT'
1558             else
1559                 URL     := RefURL + 'SETTING.TXT';
1560             Screen.Cursor := crHourGlass;
1561             memStream := TMemoryStream.Create;
1562             try
1563                 try
1564                     StatusBar.Panels[0].Text := 'SETTING.TXT\83_\83E\83\93\83\8d\81[\83h\92\86';
1565                     GetWebData(URL, RefURL, tmpBoard.SETTINGTXTTime, memStream);
1566                     if( Indy.ResponseCode = 200 ) then begin
1567                         settingBody := TStringList.Create;
1568                         try
1569                             memStream.Seek(0, soFromBeginning);
1570                             settingBody.LoadFromStream(memStream);
1571                             settingBody.SaveToFile(tmpBoard.GetSETTINGTXTFileName);
1572                             tmpBoard.SETTINGTXTTime := Indy.Response.LastModified;
1573                             tmpBoard.IsSETTINGTXT := true;
1574                             tmpBoard.TitlePictureURL := GetTitlePictureURL(settingBody, tmpBoard);
1575                             tmpBoard.Modified := true;
1576                         finally
1577                             settingBody.Free;
1578                         end;
1579                         StatusBar.Panels[0].Text := 'SETTING.TXT\8eæ\93¾\8a®\97¹(' + IntToStr(Indy.ResponseCode) + ')';
1580                     end;
1581                 except
1582                     on E: EIdException do begin
1583                         if( AnsiPos('304', E.Message) > 0 ) then
1584                             StatusBar.Panels[0].Text := 'SETTING.TXT\8dX\90V\96³\82µ(' + IntToStr(Indy.ResponseCode) + ')'
1585                         else
1586                             StatusBar.Panels[0].Text := 'SETTING.TXT\8eæ\93¾\83G\83\89\81[(' + IntToStr(Indy.ResponseCode) + ')';
1587                     end;
1588                 end;
1589             finally
1590                 memStream.Free;
1591                 Screen.Cursor := crDefault;
1592             end;
1593             ShowBoardInformation(tmpBoard, BoardInformationMemo);
1594         end;
1595         FWork := False;
1596     end;
1597 end;
1598
1599 procedure TEditorForm.ShowBoardInformation(ABoard: TBoard; AMemo: TMemo);
1600 var
1601         body: TStringList;
1602 begin
1603         AMemo.Clear;
1604         AMemo.Lines.Add('[SETTING.TXT]');
1605         if ABoard.IsSETTINGTXT then begin
1606                 if FileExists(ABoard.GetSETTINGTXTFileName)  then begin
1607                         AMemo.Lines.Add(DateTimeToStr(ABoard.SETTINGTXTTime) + ' \8dX\90V');
1608                         body := TStringList.Create;
1609                         try
1610                                 body.LoadFromFile(ABoard.GetSETTINGTXTFileName);
1611                                 AMemo.Lines.AddStrings(body);
1612                         finally
1613                                 body.Free;
1614                         end;
1615                 end else begin
1616                         ABoard.IsSETTINGTXT := false;
1617                         ABoard.SETTINGTXTTime := ZERO_DATE;
1618                         AMemo.Lines.Add('Local\82É\95Û\91\82³\82ê\82½SETTING.TXT\82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ');
1619                         AMemo.Lines.Add('\83\81\83j\83\85\81[\82æ\82è\8dÄ\8eæ\93¾\82µ\82Ä\82­\82¾\82³\82¢\81B');
1620                 end;
1621         end else begin
1622                 AMemo.Lines.Add('SETTING.TXT\82ð\8eæ\93¾\82µ\82Ä\82¢\82Ü\82¹\82ñ\81B');
1623                 AMemo.Lines.Add('\83\81\83j\83\85\81[\82æ\82è\8eæ\93¾\82µ\82Ä\82­\82¾\82³\82¢\81B');
1624         end;
1625 end;
1626 function TEditorForm.GetTitlePictureURL(body: TStringList; ABoard: TBoard): string;
1627 //BBS_TITLE_PICTURE=
1628 //BBS_FIGUREHEAD=
1629 var
1630         i: Integer;
1631         tmp: string;
1632 begin
1633         Result := '';
1634         for i := 0 to body.Count - 1 do begin
1635                 if (AnsiPos('BBS_TITLE_PICTURE=', body[i]) > 0) or
1636                    (AnsiPos('BBS_FIGUREHEAD=', body[i]) > 0) then begin
1637                         tmp := body[i];
1638                         Delete(tmp, 1, AnsiPos('=', tmp));
1639                         if AnsiPos('../', tmp) > 0 then begin
1640                                 tmp := CustomStringReplace(tmp, '../', GikoSys.UrlToServer(ABoard.URL));
1641                         end;
1642                         Result := tmp;
1643                         Exit;
1644                 end;
1645         end;
1646 end;
1647
1648 procedure TEditorForm.GetTitlePictureActionUpdate(Sender: TObject);
1649 begin
1650         if FThreadItem = nil then
1651                 GetTitlePictureAction.Enabled :=  FBoard.IsSETTINGTXT
1652         else
1653                 GetTitlePictureAction.Enabled :=  FThreadItem.ParentBoard.IsSETTINGTXT;
1654
1655         if GetTitlePictureAction.Enabled Then begin
1656                 // \8eÀ\8ds\92\86\82Í\8eÀ\8ds\95s\89Â
1657                 GetTitlePictureAction.Enabled := not FWork;
1658         end;
1659 end;
1660
1661 procedure TEditorForm.GetTitlePictureActionExecute(Sender: TObject);
1662 var
1663         memStream: TMemoryStream;
1664         tmpBoard: TBoard;
1665 begin
1666         if FWork then
1667                 Exit;
1668
1669         FWork := True;
1670         memStream := TMemoryStream.Create;
1671         try
1672         tmpBoard := GetBoard;
1673
1674                 if (tmpBoard <> nil) and (tmpBoard.TitlePictureURL <> '') then begin
1675                         StatusBar.Panels[0].Text := '\94Â\83g\83b\83v\89æ\91\9c\83_\83E\83\93\83\8d\81[\83h\92\86';
1676                         Screen.Cursor := crHourGlass;
1677                         try
1678                 // URL\82ð\8ew\92è\82µ\82Ä\83\81\83\82\83\8a\82É\93Ç\82Ý\8d\9e\82Þ
1679                 GetWebData(tmpBoard.TitlePictureURL, tmpBoard.URL,
1680                     ZERO_DATE, memStream);
1681                                 if Indy.ResponseCode = 200 then begin
1682                                         memStream.SaveToFile(tmpBoard.GetTitlePictureFileName);
1683                                         ShowTitlePicture();
1684                                         tmpBoard.Modified := true;
1685                                 end;
1686                 StatusBar.Panels[0].Text := '\94Â\83g\83b\83v\89æ\91\9c (' + IntToStr(Indy.ResponseCode) + ')';
1687                         except
1688                         end;
1689                 end;
1690         finally
1691                 memStream.Free;
1692         FWork := False;
1693                 Screen.Cursor := crDefault;
1694         end;
1695 end;
1696 {
1697 \brief  URL\82Ì\83f\81[\83^\82ðstream\82É\93Ç\82Ý\8d\9e\82Þ
1698 \param  URL \93Ç\82Ý\8d\9e\82Þ\90æ
1699 \param  RefURL   referer\82É\90Ý\92è\82·\82é
1700 \param  Modified    Modified\82É\90Ý\92è\82·\82é
1701 \param  stream  \93Ç\82Ý\8d\9e\82ñ\82¾\83f\81[\83^\82Ì\95Û\91\90æ
1702 }
1703 procedure TEditorForm.GetWebData(const URL: string; const RefURL: string;
1704              Modified: TDateTime; stream: TStream);
1705 begin
1706     InitIdHTTP(Indy);
1707     Indy.Request.Referer := RefURL;
1708     Indy.Request.LastModified := Modified;
1709     
1710     IdAntiFreeze.Active := True;
1711     try
1712         Indy.Get(URL, stream);
1713     finally
1714         IdAntiFreeze.Active := False;
1715     end;
1716
1717 end;
1718 procedure TEditorForm.ShowTitlePicture();
1719 var
1720         tmpBoard: TBoard;
1721         s: String;
1722 begin
1723     tmpBoard := GetBoard;
1724
1725         if FileExists(tmpBoard.GetTitlePictureFileName) then begin
1726                 TitlePictureBrowser.Navigate(tmpBoard.GetTitlePictureFileName);
1727         end else begin
1728                 s := '\94Â\83g\83b\83v\89æ\91\9c\96¢\8eæ\93¾\82Å\82·\81B<br>\83\81\83j\83\85\81[\82æ\82è\8eæ\93¾\82µ\82Ä\82­\82¾\82³\82¢\81B';
1729                 SetContent(s, TitlePictureBrowser);
1730         end;
1731 end;
1732
1733 function TEditorForm.GetFusianaName(body: TStringList; ABoard: TBoard): String;
1734 var
1735         i: Integer;
1736         tmp: string;
1737 begin
1738         for i := 0 to body.Count - 1 do begin
1739                 if (AnsiPos('BBS_NONAME_NAME=', body[i]) > 0) then begin
1740                         tmp := body[i];
1741                         Delete(tmp, 1, AnsiPos('=', tmp));
1742                         Result := tmp;
1743                         Exit;
1744                 end;
1745         end;
1746 end;
1747
1748 procedure TEditorForm.GetHeadTXTActionExecute(Sender: TObject);
1749 var
1750         URL, RefURL: string;
1751         settingBody: TStringList;
1752         tmpBoard: TBoard;
1753         memStream: TMemoryStream;
1754 begin
1755     if not FWork then begin
1756         FWork := True;
1757
1758         tmpBoard := GetBoard;
1759         if (tmpBoard <> nil) then begin
1760
1761             RefURL      := tmpBoard.URL;
1762             if RefURL[Length(RefURL)] <> '/' then
1763                 URL     := RefURL + '/' + 'head.txt'
1764             else
1765                 URL     := RefURL + 'head.txt';
1766
1767             Screen.Cursor := crHourGlass;
1768             memStream := TMemoryStream.Create;
1769             try
1770                 StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b(head.txt)\83_\83E\83\93\83\8d\81[\83h\92\86';
1771                 try
1772                     GetWebData(URL, RefURL, tmpBoard.HEADTXTTime, memStream);
1773                     if( Indy.ResponseCode = 200 ) then begin
1774                         settingBody := TStringList.Create;
1775                         try
1776                             memStream.Seek(0, soFromBeginning);
1777                             settingBody.LoadFromStream(memStream);
1778                             settingBody.Insert(0, '<HTML lang="ja"><HEAD>');
1779                             settingBody.Insert(1, '<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">');
1780                             settingBody.Insert(2, '<TITLE>' + tmpBoard.Title + '</TITLE>');
1781                             settingBody.Insert(3, '<base href="' + RefURL + '"></HEAD><BODY>');
1782                             settingBody.Add('</BODY></HTML>');
1783                             settingBody.SaveToFile(tmpBoard.GETHEADTXTFileName);
1784                             tmpBoard.HEADTXTTime := Indy.Response.LastModified;
1785                             tmpBoard.IsHEADTXT := true;
1786                             tmpBoard.Modified := true;
1787                         finally
1788                             settingBody.Free;
1789                         end;
1790                         StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8eæ\93¾\8a®\97¹(' + IntToStr(Indy.ResponseCode) + ')';
1791                     end;
1792                 except
1793                     on E: EIdException do begin
1794                         if( AnsiPos('304', E.Message) > 0 ) then
1795                             StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8dX\90V\96³\82µ(' + IntToStr(Indy.ResponseCode) + ')'
1796                         else
1797                             StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8eæ\93¾\83G\83\89\81[(' + IntToStr(Indy.ResponseCode) + ')';
1798                     end;
1799                 end;
1800             finally
1801                 memStream.Free;
1802                 Screen.Cursor := crDefault;
1803             end;
1804             if tmpBoard.IsHEADTXT then begin
1805                 ShowBoardHead(tmpboard, LocalEdit);
1806             end;
1807         end;
1808         FWork := False;
1809     end;
1810
1811 end;
1812
1813 procedure TEditorForm.CalcCapacityActionExecute(Sender: TObject);
1814 var
1815         Board: TBoard;
1816         body: String;
1817 begin
1818         body := GetBody;
1819     //\82Ç\82¤\82à\81A\89ü\8ds\95ª\82¸\82ê\82Ä\82½\82Á\82Û\82¢\82¯\82Ç\81A\96{\93\96\82©\82æ\82­\95ª\82©\82ç\82È\82¢\81B
1820     Board := GetBoard;
1821
1822         if Board.BoardPlugIn <> nil then
1823                 body := CustomStringReplace(body, #13#10, '<br>')
1824         else
1825                 body := CustomStringReplace(body, #13#10, ' <br> ');
1826         StatusBar.Panels[0].Text := '\97e\97Ê:' + IntToStr(Length(body)) + ' byte';
1827 end;
1828
1829 procedure TEditorForm.LocalRuleClick(Sender: TObject);
1830 var
1831   ini: TMemIniFile;
1832 begin
1833         ini := TMemIniFile.Create(GikoSys.Setting.GetFileName);
1834         try
1835                 RocalRuleTab.TabVisible := LocalRule.Checked;
1836                 ini.WriteBool('EditorForm', 'LocalRuleTab', RocalRuleTab.TabVisible);
1837         ini.UpdateFile;
1838         finally
1839                 ini.Free;
1840         end;
1841 end;
1842
1843 procedure TEditorForm.FormDeactivate(Sender: TObject);
1844 begin
1845     if GikoSys.Setting.GestureEnabled then begin
1846         GikoSys.Setting.Gestures.ClearGesture;
1847         MouseGesture.UnHook;
1848                 MouseGesture.OnGestureStart := nil;
1849                 MouseGesture.OnGestureMove := nil;
1850                 MouseGesture.OnGestureEnd := nil;
1851     end;
1852 end;
1853
1854 procedure TEditorForm.OnGestureStart(Sender: TObject);
1855 begin
1856 //
1857 end;
1858
1859 procedure TEditorForm.OnGestureMove(Sender: TObject);
1860 var
1861         s: string;
1862         Action: TAction;
1863         ActStr: string;
1864 begin
1865         s := MouseGesture.GetGestureStr;
1866         ActStr := '';
1867         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
1868         if Action <> nil then
1869                 ActStr := '\81i' + Action.Caption + '\81j';
1870         s := '\83W\83F\83X\83`\83\83\81[: ' + s + ActStr;
1871         StatusBar.Panels[0].Text := s;
1872 end;
1873
1874 procedure TEditorForm.OnGestureEnd(Sender: TObject);
1875 var
1876         s: string;
1877         Action: TAction;
1878 begin
1879         s := MouseGesture.GetGestureStr;
1880     MouseGesture.Clear;
1881         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
1882         if Action <> nil then
1883                 Action.Execute;
1884         StatusBar.Panels[0].Text := '';
1885 end;
1886
1887 procedure TEditorForm.ShowBoardHead(ABoard: TBoard; AMemo: TMemo);
1888 var
1889     range: OleVariant;
1890 begin
1891         //\8eQ\8dl\8c³
1892         //http://www.campus.ne.jp/~ishigami/CREATION/TECHNIC/WEBAP-2.htm
1893         WebBrowser1.Navigate(ABoard.GETHEADTXTFileName);
1894         //\83\8c\83^\83\8a\83\93\83O\82ª\92x\82·\82¬\82ÄTXT\82É\88Ú\82¹\82È\82¢\81B\82Ê\82é\82Ûorz
1895         //\89º\82Ì\82æ\82¤\82É\82¿\82á\82ñ\82Æ\93Ç\82Ý\8d\9e\82Ý\82ª\8fI\82í\82Á\82Ä\82¢\82é\82©\81A\83`\83F\83b\83N\82·\82ê\82Î\82¢\82¢\82ñ\82¾\82æ\81B
1896         //\82±\82ê\82Å\82¢\82¯\82Ü\82µ\82½\81B\82 \82è\82ª\82Æ\82¤\82²\82´\82¢\82Ü\82µ\82½\81B
1897         while (WebBrowser1.ReadyState <> READYSTATE_COMPLETE) and
1898                         (WebBrowser1.ReadyState <> READYSTATE_INTERACTIVE) do begin
1899                 Application.ProcessMessages;
1900         end;
1901
1902     try
1903     ;
1904         range := OleVariant(WebBrowser1.Document).body.createTextRange;
1905             LocalEdit.Text := range.text;
1906     except
1907     end;
1908 end;
1909
1910 procedure TEditorForm.LocalRuleBrowseClick(Sender: TObject);
1911 var
1912     URL: String;
1913     ABoard: TBoard;
1914 begin
1915     ABoard := GetBoard;
1916
1917         if ABoard = nil
1918         then Exit;
1919
1920     URL := ABoard.GETHEADTXTFileName;
1921     GikoSys.OpenBrowser(URL, gbtAuto);
1922 end;
1923
1924 procedure TEditorForm.SaveNameMailActionExecute(Sender: TObject);
1925 begin
1926         SaveNameMailAction.Checked := not SaveNameMailAction.Checked;
1927         KotehanCheckBox.Enabled := SaveNameMailAction.Checked;
1928 end;
1929
1930 function TEditorForm.LFusianaGet(const s: String): Boolean;
1931 const
1932     FUSIANA = 'fusianasan';
1933 var
1934         i: Integer;
1935 begin
1936     i := AnsiPos(FUSIANA, s);
1937     Result := (i > 0);
1938 end;
1939
1940 procedure TEditorForm.BeLogInOutEActionExecute(Sender: TObject);
1941 begin
1942     GikoDM.BeLogInOutAction.Execute;
1943 end;
1944
1945 procedure TEditorForm.BeLogInOutEActionUpdate(Sender: TObject);
1946 begin
1947     BeLogInOutEAction.Checked := GikoDM.BeLogInOutAction.Checked;
1948     BeLogInOutEAction.Enabled := GikoDM.BeLogInOutAction.Enabled;
1949 end;
1950 // Cookie\82Ì\8eæ\93¾
1951 procedure TEditorForm.GetCookie(CookieMng: TIdCookieManager; ABoard: TBoard);
1952 const
1953         VAL_SPID        = 'SPID';
1954         VAL_PON         = 'PON';
1955     VAL_HAP     = 'HAP';
1956 var
1957         i : Integer;
1958     Cookie : TIdCookieRFC2109;
1959     curCookies : TStringList;
1960 begin
1961     // 2008.12.14 \96³\8fð\8c\8f\83N\83\8a\83A\82µ\82Ä\82Í\82¢\82¯\82È\82¢ by \82à\82\82ã
1962     curCookies := TStringList.Create;
1963     curCookies.Delimiter := ';';
1964     curCookies.DelimitedText := ABoard.Cookie;
1965     curCookies.Sort;
1966     curCookies.Duplicates := dupIgnore;
1967         ABoard.Cookie := '';
1968     try
1969         for i := 0 to CookieMng.CookieCollection.Count - 1 do begin
1970             Cookie := CookieMng.CookieCollection.Items[i];
1971             if ( Cookie.CookieName = VAL_PON ) then begin
1972                 ABoard.PON := Cookie.Value;
1973                 ABoard.Expires := GMTToLocalDateTime(Cookie.Expires);
1974             end else if ( Cookie.CookieName = VAL_SPID ) then begin
1975                 ABoard.SPID := Cookie.Value;
1976                 ABoard.Expires := GMTToLocalDateTime(Cookie.Expires);
1977             end else if ( Cookie.CookieName = VAL_HAP ) then begin
1978                 // HAP\8dí\8f\9c\97p\82ÌCookie\82ª\94z\95z\82³\82ê\82é\82Ì\82Å\81A\97L\8cø\8aú\8cÀ\82ð\83`\83F\83b\83N\82·\82é
1979                 if CompareDateTime(GMTToLocalDateTime(Cookie.Expires) ,Now) > 0 then begin
1980                     GikoSys.SetBoukenCookie(Cookie.Value, Cookie.Domain);
1981                     // \96`\8c¯\82Ì\8f\91\82Ì\95Û\91
1982                     GikoSys.Setting.WriteBoukenSettingFile;
1983                 end;
1984             end else begin
1985                 if Length( curCookies.Values[ Cookie.CookieName ] ) > 0 then begin
1986                     // \8aù\91\92l\82Ì\95t\82¯\91Ö\82¦
1987                     curCookies[curCookies.IndexOfName(Cookie.CookieName)] :=
1988                         Cookie.ClientCookie;
1989                 end else begin
1990                     // \92Ç\89Á
1991                     curCookies.Add(Cookie.ClientCookie);
1992                 end;
1993             end;
1994         end;
1995         for i := 0 to curCookies.Count - 1 do begin
1996             if (curCookies[i] <> '') then begin
1997                 ABoard.Cookie := ABoard.Cookie + curCookies[i] + '; ';
1998             end;
1999         end;
2000     finally
2001         CookieMng.CookieCollection.Clear;
2002         curCookies.Free;
2003     end;
2004 end;
2005 //! hidden\83f\81[\83^\8eæ\93¾
2006 procedure TEditorForm.GetHiddenParameter(Rawtext: String; ABoard: TBoard);
2007 const
2008     INPUT_MARK = '<input type=hidden' ; // \91å\95\8e\9a\8f¬\95\8e\9a\82Î\82ç\82Î\82ç\82È\82±\82Æ\82É\92\8d\88Ó
2009     VALUE_MARK = 'value=' ;              // \91å\95\8e\9a\8f¬\95\8e\9a\82Î\82ç\82Î\82ç\82È\82±\82Æ\82É\92\8d\88Ó
2010     NAME_MARK  = 'name=' ;               // \91å\95\8e\9a\8f¬\95\8e\9a\82Î\82ç\82Î\82ç\82È\82±\82Æ\82É\92\8d\88Ó
2011     IGNORE_NAMES : array[0..6] of String =
2012         ('subject', 'from', 'mail', 'message', 'bbs', 'time', 'key');
2013 var
2014     tmp, line, name, value, lname : String;
2015     pos, pose, i : Integer;
2016 begin
2017     tmp := AnsiLowerCase(Rawtext);
2018     pos := AnsiPos(INPUT_MARK, tmp);
2019     while  (pos > 0 ) do begin
2020                 tmp := Copy(Rawtext, pos + Length(INPUT_MARK), Length(tmp));
2021         Delete(Rawtext, 1, pos+ Length(INPUT_MARK) - 1);
2022         pose := AnsiPos('>', tmp);
2023         // name=xxx value=yyy \82ª\90Ø\82è\8fo\82³\82ê\82é
2024         line := Copy(tmp, 1, pose - 1);
2025         name := '';
2026         value := '';
2027         pos := AnsiPos(NAME_MARK, tmp);
2028         if (pos > 0) then begin
2029             name := Copy(Rawtext, pos + Length(NAME_MARK), Length(line));
2030             //\94¼\8ap"\82Å\8en\82Ü\82Á\82Ä\82¢\82é\82©
2031             if AnsiPos('"', name) = 1 then begin
2032                 // \94¼\8ap"\82Ü\82Å\82ð\83R\83s\81[
2033                 Delete(name, 1, 1);
2034                 pose := AnsiPos('"', name);
2035                 if (pose > 0) then begin
2036                     Delete(name, pose, Length(name));
2037                 end else begin
2038                     pose := AnsiPos(' ', name);
2039                     if (pose > 0) then begin
2040                         Delete(name, pose, Length(name));
2041                     end;
2042                 end;
2043             end else begin
2044                 pose := AnsiPos(' ', name);
2045                 if (pose > 0) then begin
2046                     Delete(name, pose, Length(name));
2047                 end;
2048             end;
2049         end;
2050         lname := AnsiLowerCase(name);
2051         for i := 0 to Length(IGNORE_NAMES) do begin
2052             if lname = IGNORE_NAMES[i] then begin
2053                 name := '';
2054                 break;
2055             end;
2056         end;
2057         pos := AnsiPos(VALUE_MARK, tmp);
2058         if (name <> '') and (pos > 0) then begin
2059             value := Copy(Rawtext, pos + Length(VALUE_MARK), Length(line));
2060             //\94¼\8ap"\82Å\8en\82Ü\82Á\82Ä\82¢\82é\82©
2061             if AnsiPos('"', value) = 1 then begin
2062                 // \94¼\8ap"\82Ü\82Å\82ð\83R\83s\81[
2063                 Delete(value, 1, 1);
2064                 pose := AnsiPos('"', value);
2065                 if (pose > 0) then begin
2066                     Delete(value, pose, Length(value));
2067                 end else begin
2068                     pose := AnsiPos(' ', value);
2069                     if (pose > 0) then begin
2070                         Delete(value, pose, Length(value));
2071                     end;
2072                 end;
2073             end else begin
2074                 pose := AnsiPos(' ', value);
2075                 if (pose > 0) then begin
2076                     Delete(value, pose, Length(name));
2077                 end;
2078             end;
2079         end;
2080         if (name <> '') then begin
2081             ABoard.Cookie := ABoard.Cookie + name + '=' + value + '; '; 
2082
2083         end;
2084                 Delete(tmp, 1, Length(line));
2085         Delete(Rawtext, 1, Length(line));
2086         pos := AnsiPos(INPUT_MARK, tmp);
2087     end;
2088 end;
2089
2090 //! \83T\83\93\83o\8dX\90V\82Ì\83A\83N\83V\83\87\83\93\82ÌUpdate\83C\83x\83\93\83g\81@\8aÈ\92P\82Ì\82½\82ß\83^\83C\83}\81[\82Æ\93¯\82\82É\82µ\82Ä\82¨\82­
2091 procedure TEditorForm.UpdateSambaActionUpdate(Sender: TObject);
2092 begin
2093         UpdateSambaAction.Enabled := FSambaTimer.Enabled;
2094 end;
2095
2096 //! \83T\83\93\83o\8dX\90V\83A\83N\83V\83\87\83\93
2097 procedure TEditorForm.UpdateSambaActionExecute(Sender: TObject);
2098 var
2099         input : String;
2100         i : Integer;
2101 begin
2102         if InputQuery('Samba24\90Ý\92è\92l\8dX\90V', '\90V\82µ\82¢\90Ý\92è\92l\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢', input) then begin
2103         input := ZenToHan(input);
2104                 if GikoSys.IsNumeric(input) then begin
2105             FSambaTimer.UpdateSambaSetting(StrToInt(input));
2106             UpdateSambaStatus;
2107                         //\91S\82Ä\82Ì\83t\83H\81[\83\80\82©\82ç\81ASamba\83^\83C\83}\81[\82ð\8dX\90V\82·\82é
2108                         for i := 0 to Screen.FormCount - 1 do begin
2109                                 if Screen.Forms[i] is TEditorForm then begin
2110                     TEditorForm(Screen.Forms[i]).FSambaTimer.Update;
2111                     TEditorForm(Screen.Forms[i]).UpdateSambaStatus;
2112                 end;
2113                         end;
2114                 end else begin
2115                         ShowMessage('\90\94\92l\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢');
2116                         UpdateSambaActionExecute(Sender);
2117                 end;
2118         end;
2119 end;
2120
2121 procedure TEditorForm.UpdateSambaStatus;
2122 begin
2123     if (FSambaTimer.Enabled) then begin
2124         StatusBar.Panels[2].Text
2125             := 'Samba24\8bK\92è\92l' + IntToStr(FSambaTimer.SambaInterval);
2126     end;
2127 end;
2128
2129 procedure TEditorForm.InputAssistActionExecute(Sender: TObject);
2130 var
2131         count, i : Integer;
2132         item : TMenuItem;
2133         point: TPoint;
2134         Bitmap : TBitmap;
2135         TextWidth, ItemWidth, tmpWidth: Integer;
2136 begin
2137         if FInputAssistKey = '' then Exit;
2138
2139         InputAssistPopupMenu.Items.Clear;
2140
2141         if (FResistWords = nil) then begin
2142                 FResistWords := TStringList.Create;
2143         end else begin
2144                 FResistWords.Clear;
2145         end;
2146
2147         if (GetKeyState( VK_SHIFT ) < 0) then begin
2148                 // \83V\83t\83g\82ª\89\9f\82³\82ê\82Ä\82¢\82ê\82Î\81A\83L\81[\82Å\8en\82Ü\82é\83J\83e\83S\83\8a
2149                 count :=
2150                         InputAssistDM.GetStartWithCategoryResistWords(
2151                                                                         FInputAssistKey, FResistWords);
2152         end else begin
2153                 // \83V\83t\83g\82ª\96³\82¢\82Ì\82Å\81A\83L\81[\82Å\8en\82Ü\82é\83L\81[
2154                 count :=
2155                         InputAssistDM.GetStartWithKeyResistWords(
2156                                                                         FInputAssistKey, FResistWords);
2157         end;
2158         Bitmap := TBitmap.Create;
2159         try
2160                 Bitmap.Canvas.Font.Assign(BodyEdit.Font);
2161                 // \83}\81[\83W\83\935px
2162                 TextWidth := Bitmap.Canvas.TextWidth(FInputAssistKey) + 5;
2163                 ItemWidth := 0;
2164                 for i := 0 to count - 1 do begin
2165                         item := TMenuItem.Create(nil);
2166                         item.Break := mbNone;
2167                         item.Caption := FResistWords[i];
2168                         item.Tag := i;
2169                         item.OnClick := InputAssistMenuClick;
2170                         InputAssistPopupMenu.Items.Add(item);
2171
2172                         tmpWidth := Bitmap.Canvas.TextWidth(Item.Caption);
2173                         if (tmpWidth > ItemWidth) then begin
2174                                 ItemWidth := tmpWidth;
2175                         end;
2176                 end;
2177         finally
2178                 Bitmap.Free;
2179         end;
2180
2181         if (count > 0) then begin
2182                 GetCaretpos(point);
2183                 point.X := point.X + Self.Left + (Self.Width - BodyEdit.Width) div 2;
2184                 point.Y := point.Y + Self.Top + (Self.Height - Self.ClientHeight);
2185
2186                 if Screen.DesktopWidth >
2187                         (point.X + TextWidth + ItemWidth) then begin
2188                         InputAssistPopupMenu.Popup(
2189                                 point.X + TextWidth,
2190                                 point.Y + EditorPage.Top + EditorPage.TabHeight + BodyEdit.Top);
2191                 end else begin
2192                         InputAssistPopupMenu.Popup(
2193                                 point.X - TextWidth - ItemWidth,
2194                                 point.Y + EditorPage.Top + EditorPage.TabHeight + BodyEdit.Top);
2195                 end;
2196         end;
2197 end;
2198
2199 procedure TEditorForm.InputAssistMenuClick(Sender: TObject);
2200 var
2201         text : String;
2202         IMC: HIMC;
2203 begin
2204         if not (Sender is TMenuItem) then Exit;
2205
2206         if (FResistWords <> nil) then begin
2207                 try
2208                         text :=
2209                                 TResistWord(FResistWords.Objects[TMenuItem(Sender).Tag]).GetText;
2210                 except
2211                         text := '';
2212                 end;
2213                 IMC := ImmGetContext(BodyEdit.Handle); //\83R\83\93\83e\83L\83X\83g\8eæ\93¾
2214                 try
2215                         ImmNotifyIME(IMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
2216                 finally
2217                         ImmReleaseContext(BodyEdit.Handle, IMC);  //\83R\83\93\83e\83L\83X\83g\89ð\95ú
2218                 end;
2219
2220                 FResistWords.Clear;
2221                 FInputAssistKey := '';
2222         end;
2223         InsertText(BodyEdit, text);
2224 end;
2225
2226 //! TMemo\82Ì\83J\81[\83\\83\8b\88Ê\92u\82É\95\8e\9a\97ñ\91}\93ü
2227 procedure TEditorForm.InsertText(Memo: TMemo; Text: String);
2228 var
2229         line, sel, pos: Integer;
2230         left, right : String;
2231 begin
2232         Memo.Lines.BeginUpdate;
2233         line := SendMessage(Memo.Handle,EM_LINEFROMCHAR,-1,0);  //\8ds
2234         sel := Memo.SelStart;
2235         pos     := sel - SendMessage(Memo.Handle, EM_LINEINDEX, -1, 0); //\8c\85
2236         if (pos > 0) then begin
2237                 left := Copy(Memo.Lines[line], 0, pos);
2238         end else begin
2239                 left := '';
2240         end;
2241         right := Copy(Memo.Lines[line], pos + 1, Length(Memo.Lines[line]));
2242         Memo.Lines.Strings[line] := left + Text + right;
2243         Memo.Lines.EndUpdate;
2244         //\81@\83L\83\83\83\8c\83b\83g\82Ì\88Ê\92u\82ð\8dX\90V\82·\82é
2245         Memo.SelStart := sel + Length(text);
2246         // \83L\83\83\83\8c\83b\83g\82Ì\88Ê\92u\82Ü\82Å\83X\83N\83\8d\81[\83\8b
2247         Memo.Perform(EM_SCROLLCARET, 0, 0);
2248
2249 end;
2250
2251 procedure TEditorForm.ApplicationEvents1Message(var Msg: tagMSG;
2252   var Handled: Boolean);
2253 var
2254         wmMsg: TWMKey;
2255         IMC: HIMC;
2256         Len: integer;
2257         Str: string;
2258 begin
2259         if (Self.Active) then begin
2260                 case Msg.message of
2261                         //\83L\81[\89\9f\89º\82Ì\82Ý\8eó\82¯\8eæ\82é
2262                         WM_KEYDOWN:
2263                         begin
2264                                 // \83^\83u\82ª\81h\95Ò\8fW\81h\82ÅCtrl\83L\81[\82ª\89\9f\82³\82ê\82Ä\82¢\82é\82Ì\82ð\8am\94F\82·\82é
2265                                 if (EditorPage.ActivePageIndex = 0)
2266                                                 and (GetKeyState( VK_CONTROL ) < 0) then begin
2267                                         wmMsg.Msg := Msg.message;
2268                                         wmMsg.CharCode := Word(Msg.wParam);
2269                                         wmMsg.KeyData := Msg.lParam;
2270                                         if (wmMsg.CharCode = 229) and (wmMsg.KeyData = 3735553) then begin
2271                                                 IMC := ImmGetContext(BodyEdit.Handle); //\83R\83\93\83e\83L\83X\83g\8eæ\93¾
2272                                                 Len := ImmGetCompositionString(IMC, GCS_COMPSTR, nil, 0); //\82Ü\82¸\92·\82³\82ð\8eæ\93¾
2273                                                 if (Len > 0) then begin
2274                                                         SetLength(Str, Len + 1); //Buffer\82Ì\83\81\83\82\83\8a\82ð\90Ý\92è
2275                                                         ImmGetCompositionString(IMC, GCS_COMPSTR, PChar(Str), Len + 1); //\82Ü\82¸\92·\82³\82ð\8eæ\93¾
2276                                                         SetLength(Str, Len);
2277                                                         FInputAssistKey := Str;
2278                                                         InputAssistActionExecute(nil);
2279                                                         Handled := True;
2280                                                 end;
2281                                                 ImmReleaseContext(BodyEdit.Handle, IMC);  //\83R\83\93\83e\83L\83X\83g\89ð\95ú
2282                                         end;
2283                                 end;
2284                         end;
2285                 end;
2286
2287         end;
2288 end;
2289
2290 procedure TEditorForm.ShowInputAssistFormExecute(Sender: TObject);
2291 var
2292         form : TInputAssistForm;
2293 begin
2294         form := TInputAssistForm.Create(nil);
2295         try
2296                 if TopAction.Checked then begin // \83X\83e\83C\8fó\91Ô\82É\90Ý\92è
2297                         SetWindowPos(form.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2298         end;
2299                 form.SetUpFromEditor;
2300                 if (form.ShowModal = mrOk) then begin
2301                         InsertText(BodyEdit, form.GetInsertText);
2302                 end;
2303         finally
2304                 form.Release;
2305         end;
2306 end;
2307 //! Cookie\8fî\95ñ\8dí\8f\9c
2308 procedure TEditorForm.ReleaseCookieActionExecute(Sender: TObject);
2309 var
2310         Board : TBoard;
2311 begin
2312         // \83X\83\8c\83b\83h\82ª\96³\82¢\81@\83X\83\8c\97§\82Ä\82Ì\82Æ\82«\82ÍFBoard\82ð\92¼\90Ú\8eg\82¤
2313     Board := GetBoard;
2314
2315         // \83N\83b\83L\81[\82Ì\8fî\95ñ\82ð\8eÌ\82Ä\82é
2316         Board.Cookie := '';
2317         Board.SPID := '';
2318         Board.PON  := '';
2319         // 0\82É\8aª\82«\96ß\82·
2320         Board.Expires := 0;
2321 end;
2322 //! \94Â\8fî\95ñ\8eæ\93¾Update\83C\83x\83\93\83g
2323 procedure TEditorForm.GetSETTINGTXTActionUpdate(Sender: TObject);
2324 begin
2325         // \8eÀ\8ds\92\86\82Í\8eÀ\8ds\95s\89Â
2326         GetSETTINGTXTAction.Enabled := not FWork;
2327 end;
2328 //! \83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8eæ\93¾Update\83C\83x\83\93\83g
2329 procedure TEditorForm.GetHeadTXTActionUpdate(Sender: TObject);
2330 begin
2331         // \8eÀ\8ds\92\86\82Í\8eÀ\8ds\95s\89Â
2332         GetSETTINGTXTAction.Enabled := not FWork;
2333 end;
2334
2335 //! Samba\83^\83C\83}\81[\83C\83x\83\93\83g
2336 procedure TEditorForm.SambaTimer(Sender: TObject);
2337 begin
2338
2339         if FSambaTimer.WriteDeta = ZERO_DATE then
2340                 StatusBar.Panels[1].Text := '\8f\89\8f\91'
2341         else begin
2342                 FNow := IncMilliSecond(FNow, 500);
2343                 StatusBar.Panels[1].Text :=
2344             Format('%8.0f\95b\8co\89ß', [SecondSpan(FNow, FSambaTimer.WriteDeta)]);
2345         end;
2346 end;
2347 {
2348 \brief \83E\83B\83\93\83h\83E\82Ì\88Ê\92u\82Æ\83T\83C\83Y\82Ì\90Ý\92è
2349 }
2350 procedure TEditorForm.SetWindowRect;
2351 var
2352     wp: TWindowPlacement;
2353     MonCnt: Integer;
2354     MonOk: Boolean;
2355     MonR: Integer;
2356     MonB: Integer;
2357     Right: Integer;
2358     Bottom: Integer;
2359 begin
2360         //\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\90Ý\92è
2361         wp.length := sizeof(wp);
2362         wp.rcNormalPosition.Top := GikoSys.Setting.EditWindowTop;
2363         wp.rcNormalPosition.Left := GikoSys.Setting.EditWindowLeft;
2364
2365         wp.rcNormalPosition.Bottom := GikoSys.Setting.EditWindowTop + GikoSys.Setting.EditWindowHeight;
2366         wp.rcNormalPosition.Right := GikoSys.Setting.EditWindowLeft + GikoSys.Setting.EditWindowWidth;
2367         wp.showCmd := SW_HIDE;
2368         SetWindowPlacement(Handle, @wp);
2369
2370         if GikoSys.Setting.EditWindowMax then begin
2371                 WindowState := wsMaximized;
2372     end;
2373
2374         //\83E\83B\83\93\83h\83E\82ª\89æ\96Ê\8aO\82È\82ç\89æ\96Ê\93à\82É\88Ú\93®\82·\82é
2375     Right := Left + Width;
2376     Bottom := Top + Height;
2377     MonOk := False;
2378     MonCnt := 0;
2379     while (MonCnt < Screen.MonitorCount) do begin
2380         MonR := Screen.Monitors[MonCnt].Left + Screen.Monitors[MonCnt].Width;
2381         MonB := Screen.Monitors[MonCnt].Top  + Screen.Monitors[MonCnt].Height;
2382
2383         if ((Left  >= Screen.Monitors[MonCnt].Left) and (Left   <  MonR) and
2384             (Top   >= Screen.Monitors[MonCnt].Top)  and (Top    <  MonB) and
2385             (Right  > Screen.Monitors[MonCnt].Left) and (Right  <= MonR) and
2386             (Bottom > Screen.Monitors[MonCnt].Top)  and (Bottom <= MonB)) then begin
2387             MonOk := True;
2388             Break;
2389         end;
2390
2391         MonCnt := MonCnt + 1;
2392     end;
2393
2394     if (MonOk = False) then begin
2395         Left := 0;
2396         Top := 0;
2397     end;
2398
2399     //\8c»\8dÝ\82Ì\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\82ð\95Û\91
2400     GikoSys.Setting.EditWindowTop := Top  + WINDOWMOVE_V;   // \8e\9f\82É\8aJ\82­\83E\83B\83\93\83h\83E\82Í
2401     GikoSys.Setting.EditWindowLeft := Left + WINDOWMOVE_H;  // \81@\81@\81@\89E\8eÎ\82ß\89º\82É\82¸\82ç\82·
2402     //\83E\83B\83\93\83h\83E\82Ì\95\9d\82Æ\8d\82\82³\82ª\8f¬\82³\82·\82¬\82¢\82ê\82Î\8c³\82É\96ß\82·
2403         if GikoSys.Setting.EditWindowHeight < 144 then begin
2404                 Height := 400;
2405     end;
2406         if GikoSys.Setting.EditWindowWidth < 144 then begin
2407                 Width := 640;
2408     end;
2409 end;
2410 {
2411 \brief \8ag\92£\83^\83u\90Ý\92è
2412 }
2413 procedure TEditorForm.SetExtraTab;
2414 const
2415     SECTION = 'EditorForm';
2416 var
2417     ini: TMemIniFile;
2418 begin
2419     ini := TMemIniFile.Create(GikoSys.Setting.GetFileName);
2420     try
2421         BoardtopTab.TabVisible := ini.Readbool(SECTION, 'BoardTopTab', False);
2422         BoardTop.Checked := BoardtopTab.TabVisible;
2423         RocalRuleTab.TabVisible := ini.ReadBool(SECTION, 'LocalRuleTab', False);
2424         LocalRule.Checked := RocalRuleTab.TabVisible;
2425     finally
2426         ini.Free;
2427     end;
2428 end;
2429 {
2430 \brief \94Â\8eæ\93¾
2431 \return \83\8c\83X\83G\83f\83B\83^\82ª\93\8a\8de\82µ\82æ\82¤\82Æ\82µ\82Ä\82¢\82é\94Â
2432 }
2433 function TEditorForm.GetBoard : TBoard;
2434 begin
2435     // \83X\83\8c\83b\83h\83A\83C\83e\83\80\82ªnull\82Ì\8e\9e\82ÍFBoard
2436     if FThreadItem = nil then begin
2437         Result := FBoard;
2438     end else  begin
2439         Result := FThreadItem.ParentBoard;
2440     end;
2441 end;
2442 {
2443 \brief  GikoForm\82É\83\81\83b\83Z\81[\83W\82ð\92Ç\89Á\82·\82é
2444 \param  icon    \83\81\83b\83Z\81[\83W\82É\82Â\82­\83A\83C\83R\83\93
2445 }
2446 procedure TEditorForm.AddFormMessageNew(icon: TGikoMessageIcon);
2447 begin
2448     if FThreadItem = nil then begin
2449         GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmNewSure), nil, icon)
2450     end else begin
2451         GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmNewRes), nil, icon);
2452     end;
2453
2454 end;
2455 {
2456 \brief  \83\8d\81[\83J\83\8bfusiana\83g\83\89\83b\83v
2457 \return true:\91\97\90M\92\86\8e~ false:\91\97\90M
2458 }
2459 function TEditorForm.isLocalFusianaTrap: Boolean;
2460 var
2461     Namae : string;
2462 begin
2463     Result := False;
2464     if GikoSys.Setting.LocalTrapAtt then begin
2465         Namae := THTMLCreate.RepHtml(NameComboBox.Text);
2466         if (LFusianaGet(Namae)) or (Namae = '\8eR\8dè\8fÂ') then begin
2467             if FusianaMsgBox = IDNO  then begin
2468                 Result := True;
2469             end;
2470         end;
2471     end;
2472 end;
2473 {
2474 \brief  \83\8a\83\82\81[\83gfusiana\83g\83\89\83b\83v
2475 \return true:\91\97\90M\92\86\8e~ false:\91\97\90M
2476 }
2477 function TEditorForm.isRemoteFusianaTrap: Boolean;
2478 var
2479     Namae : string;
2480     Board : TBoard;
2481     Remote: string;
2482     body : TStringList;
2483 begin
2484     Result := False;
2485     Namae := THTMLCreate.RepHtml(NameComboBox.Text);
2486     if (GikoSys.Setting.RemoteTrapAtt) and (Length(Namae) = 0) then begin
2487         Board := GetBoard;
2488
2489         if Board = nil then Exit;
2490
2491         if not FileExists(Board.GetSETTINGTXTFileName)  then begin
2492             //Setting.txt\82ª\82È\82©\82Á\82½\82ç\8eæ\93¾
2493             //\8eI\82É\95\89\89×\82ª\82©\82©\82è\82»\82¤...
2494             try
2495                 GetSETTINGTXTAction.Execute;
2496             except
2497             end;
2498         end;
2499
2500         Remote := '';
2501         if FileExists(Board.GetSETTINGTXTFileName)  then begin
2502             body := TStringList.Create;
2503             try
2504                 body.LoadFromFile(Board.GetSETTINGTXTFileName);
2505                 Remote := GetFusianaName(body, Board);
2506             finally
2507                 body.Free;
2508             end;
2509         end;
2510
2511         if LFusianaGet(Remote) then begin
2512             if FusianaMsgBox = IDNO  then begin
2513                 Result := True;
2514             end;
2515         end;
2516     end;
2517 end;
2518 {
2519 \brief  Header\95\8e\9a\97ñ\8eæ\93¾
2520 \param  ACOOKIE Cookie
2521 \param  SPID    SPID
2522 \param  PON    PON
2523 \param  HAP     HAP
2524 \param  Board   \94Â
2525 \return Header\95\8e\9a\97ñ
2526 }
2527 function TEditorForm.getHeaderStr(const ACOOKIE: string; const SPID : string;
2528     const PON : string; const HAP : string; Board : TBoard) : string;
2529 begin
2530     Result := ACOOKIE;
2531
2532         if SPID <> '' then
2533                 Result := Result + 'SPID=' + SPID + '; ';
2534         if PON <> '' then
2535                 Result := Result + 'PON=' + PON + '; ';
2536
2537         //\83z\83X\83g\82ª2ch\82Å\81ABe\82ÉLogin\82µ\82Ä\82¢\82ê\82ÎBE\82Ì\83f\81[\83^\82ð\91\97\82é
2538         //GikoSys.ParseURI( URL, Protocol,Host, Path, Document, Port, Bookmark );
2539         //if GikoSys.Is2chHost(Host) and GikoSys.Setting.BeLogin then
2540         if (Board.Is2ch) then begin
2541                 // \8cÅ\92è\82Ì\83N\83b\83L\81[\82ª\82 \82ê\82Î\90H\82í\82¹\82é
2542                 if Length(GikoSys.Setting.FixedCookie) > 0 then begin
2543                         // \83z\83X\83g\82ª2ch\82Ì\8fê\8d\87\81C\8cÅ\92è\82Ì\83N\83b\83L\81[\82ð\90H\82í\82¹\82é
2544                         Result := Result + GikoSys.Setting.FixedCookie + '; ';
2545                 end;
2546         if (GikoSys.Belib.Connected) then begin
2547                         Result := Result + 'MDMD=' + GikoSys.Belib.MDMD + '; '
2548                              + 'DMDM=' + GikoSys.Belib.DMDM + '; ';
2549                 end;
2550     end;
2551
2552         Result := 'Cookie: ' + Result + 'NAME=' + NameComboBox.Text + '; MAIL=' + MailComboBox.Text;
2553
2554     if HAP <> '' then
2555         Result := Result + '; HAP=' + HAP + '; ';
2556
2557 end;
2558
2559 {
2560 \brief fusiana\8cx\8d\90\83_\83C\83A\83\8d\83O
2561 \return IDYES \8f\91\82«\8d\9e\82Þ IDNO \92\86\8e~
2562 }
2563 function TEditorForm.FusianaMsgBox: Integer;
2564 const
2565         MSG_FUSIANA : string =  '\83\8a\83\82\81[\83g\83z\83X\83g\82ð\95\\8e¦\82·\82é\8b@\94\\82ª\8eg\82í\82ê\82Ä\82¢\82Ü\82·'#13#10 +
2566                 '\82à\82µ\82à\8aÔ\88á\82Á\82Ä\82±\82Ì\95û\96@\82Å\83z\83X\83g\82ª\95\\8e¦\82³\82ê\82½\82Æ\82µ\82Ä\82à\81A\8e©\8cÈ\90Ó\94C\82È\82Ì\82Å\8dí\8f\9c\88Ë\97\8a\82É\82Í\89\9e\82\82Ü\82¹\82ñ\81B' +
2567                 #13#10#13#10'\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H';
2568 begin
2569     Result := MsgBox(Handle, MSG_FUSIANA, '\8fî\95ñ',
2570                 MB_YESNO or MB_ICONQUESTION);
2571 end;
2572 {
2573 \brief \98A\93\8a\83\82\81[\83hON/OFF\90Ø\82è\91Ö\82¦
2574 }
2575 procedure TEditorForm.ContinueModeActionExecute(Sender: TObject);
2576 begin
2577         ContinueModeAction.Checked := not ContinueModeAction.Checked;
2578 end;
2579 {
2580 \brief \98A\93\8a\83\82\81[\83h\8dX\90V\8f\88\97\9d
2581 }
2582 procedure TEditorForm.ContinueModeActionUpdate(Sender: TObject);
2583 begin
2584     // \83X\83\8c\82½\82Ä\82Ì\82Æ\82«\82Í\96³\8cø
2585     ContinueModeAction.Enabled := FThreadItem <> nil;
2586 end;
2587 {
2588 \brief \8f\91\82«\8d\9e\82Þ\94Â/\83X\83\8c\83b\83h\82ð\95\\8e¦\82·\82é
2589 }
2590 procedure TEditorForm.OpenSendTargetActionExecute(Sender: TObject);
2591 begin
2592     if (FThreadItem <> nil) then begin
2593         // \83\81\83C\83\93\82ð\8dX\90V\82µ\82Ä\82µ\82Ü\82¤\82Ì\82Å\89æ\96Ê\82ª\83p\83^\83p\83^\90Ø\82è\91Ö\82í\82é\82Ì\82ð\96h\82®\82½\82ß\82É
2594         // \91O\96Ê\82Å\8cÅ\92è\82·\82é
2595         if not (fsShowing in Self.FormState) then begin
2596             // \83X\83e\83C\8fó\91Ô\82É\90Ý\92è
2597             SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2598         end;
2599         try
2600             // \83X\83\8c\83b\83h
2601             GikoForm.InsertBrowserTab(FThreadItem, True);
2602         finally
2603             if not TopAction.Checked then begin // \83X\83e\83C\8fó\91Ô\89ð\8f\9c
2604                 SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2605             end;
2606         end;
2607         Self.SetFocus;
2608     end else begin
2609         // \94Â
2610         GikoForm.SelectTreeNode(
2611             GetBoard, True );
2612     end;
2613 end;
2614 procedure TEditorForm.ReloadTargetActionExecute(Sender: TObject);
2615 begin
2616     if (FThreadItem <> nil) then begin
2617         // \83X\83\8c\83b\83h
2618         // \83\81\83C\83\93\82ð\8dX\90V\82µ\82Ä\82µ\82Ü\82¤\82Ì\82Å\89æ\96Ê\82ª\83p\83^\83p\83^\90Ø\82è\91Ö\82í\82é\82Ì\82ð\96h\82®\82½\82ß\82É
2619         // \91O\96Ê\82Å\8cÅ\92è\82·\82é(\83_\83E\83\93\83\8d\81[\83h\82ª\94­\90\82·\82é\82Æ\90Ø\82è\91Ö\82í\82Á\82Ä\82µ\82Ü\82¤\82ª\82 \82«\82ç\82ß\82é)
2620         if not (fsShowing in Self.FormState) then begin
2621             // \83X\83e\83C\8fó\91Ô\82É\90Ý\92è
2622             SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2623         end;
2624         try
2625             GikoForm.DownloadContent(FThreadItem);
2626         finally
2627             if not TopAction.Checked then begin // \83X\83e\83C\8fó\91Ô\89ð\8f\9c
2628                 SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2629             end;
2630         end;
2631         Self.SetFocus;
2632     end else begin
2633         // \94Â
2634         GikoForm.DownloadList(GetBoard);
2635     end;
2636 end;
2637 //! \8cë\94\9a\83`\83F\83b\83N
2638 function TEditorForm.isGobaku: Boolean;
2639 const
2640         MSG_GOBAKU : string =
2641         '\95\\8e¦\82µ\82Ä\82¢\82é%s\82Æ\93\8a\8de\90æ\82Ì%s\82ª\88Ù\82È\82è\82Ü\82·\81B'#13#10 +
2642                 '\82±\82Ì\82Ü\82Ü\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H';
2643 var
2644     ThreadItem : TThreadItem;
2645     msg : String;
2646
2647 begin
2648     Result := False;
2649     // \83I\83v\83V\83\87\83\93\97L\8cø\82©\82Â\83\8c\83X\91\97\90M\82Å\82Ì\82Ý\97L\8cø
2650     if (GikoSys.Setting.UseGobakuCheck) then begin
2651         // \83\8c\83X\91\97\90M
2652         if (FThreadItem <> nil) then begin
2653             ThreadItem := GikoForm.GetActiveContent(False);
2654             if (ThreadItem <> nil) then begin
2655                 if (FThreadItem <> ThreadItem) then begin
2656                     msg := Format(MSG_GOBAKU, ['\83X\83\8c\83b\83h', '\83X\83\8c\83b\83h']);
2657                     Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2658                 end;
2659             end else begin
2660                 if GikoForm.ActiveList is TBBS then begin
2661                     if TBBS(GikoForm.ActiveList) <> FThreadItem.ParentBoard.ParentCategory.ParenTBBS then begin
2662                         msg := Format(MSG_GOBAKU, ['BBS', '\83X\83\8c\83b\83h\82Ì\8f\8a\91®\82·\82éBBS']);
2663                         Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2664                     end;
2665                 end else if GikoForm.ActiveList is TCategory then begin
2666                     if TCategory(GikoForm.ActiveList).FindThreadFromURL(FThreadItem.URL) = nil then begin
2667                         msg := Format(MSG_GOBAKU, ['\83J\83e\83S\83\8a', '\83X\83\8c\83b\83h\82Ì\8f\8a\91®\82·\82é\83J\83e\83S\83\8a']);
2668                         Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2669                     end;
2670                 end else if GikoForm.ActiveList is TBoard then begin
2671                     if TBoard(GikoForm.ActiveList) <> FThreadItem.ParentBoard then begin
2672                         msg := Format(MSG_GOBAKU, ['\94Â', '\83X\83\8c\83b\83h\82Ì\8f\8a\91®\82·\82é\94Â']);
2673                         Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2674                     end;
2675                 end;
2676             end;
2677         end else begin
2678             // \83X\83\8c\82½\82Ä
2679             if GikoForm.ActiveList is TBBS then begin
2680                 if TBBS(GikoForm.ActiveList) <> FBoard.ParentCategory.ParenTBBS then begin
2681                     msg := Format(MSG_GOBAKU, ['BBS', '\94Â\82Ì\8f\8a\91®\82·\82éBBS']);
2682                     Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2683                 end;
2684             end else if GikoForm.ActiveList is TCategory then begin
2685                 if TCategory(GikoForm.ActiveList).FindBoardFromURL(FBoard.URL) = nil then begin
2686                     msg := Format(MSG_GOBAKU, ['\83J\83e\83S\83\8a', '\94Â\82Ì\8f\8a\91®\82·\82é\83J\83e\83S\83\8a']);
2687                     Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2688                 end;
2689             end else if GikoForm.ActiveList is TBoard then begin
2690                 if TBoard(GikoForm.ActiveList) <> FBoard then begin
2691                     msg := Format(MSG_GOBAKU, ['\94Â', '\94Â']);
2692                     Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2693                 end;
2694             end;
2695         end;
2696     end;
2697 end;
2698
2699 end.