OSDN Git Service

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