OSDN Git Service

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