OSDN Git Service

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