Develop and Download Open Source Software

Browse CVS Repository

Contents of /gikonavigoeson/gikonavi/Editor.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.151 - (show annotations) (download) (as text)
Sun Sep 25 11:11:03 2011 UTC (12 years, 5 months ago) by h677
Branch: MAIN
CVS Tags: v1_63_1_819, v1_63_0_818, v1_63_0_817, v1_63_0_816, HEAD
Branch point for: Bb63
Changes since 1.150: +1 -1 lines
File MIME type: text/x-pascal
trip12桁のプレビューが出来ない不具合の修正
オフラインの時のエラーメッセージを修正。

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 //?吾??莨若?炊?祉???ゃ?帥?ゃ??
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; ///< ?ュ???≪?激?鴻????????/span>
221 FResistWords: TStringList; ///< ?ュ???≪?激?鴻??????吾???????膣∝???
222 FSambaTimer: TSambaTimer; ///< Samba絲丞????帥?ゃ????/span>
223 FCookieDomain: string; ///< 綽?羈?絽????<?ゃ??/span>
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 /// ????????
234 function GetBody : string;
235 //IdHttp????????
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 //! ?????鴻?吾?с?鴻???c?守??紮?
242 procedure OnGestureStart(Sender: TObject);
243 //! ?????鴻?吾?с?鴻???c?寂賢
244 procedure OnGestureMove(Sender: TObject);
245 //! ?????鴻?吾?с?鴻???c?主?篋?
246 procedure OnGestureEnd(Sender: TObject);
247 //HEAD.TXT????茵?ず
248 procedure ShowBoardHead(ABoard: TBoard; AMemo: TMemo);
249 //LocalFusianaTrapAlart
250 function LFusianaGet(const s: String): Boolean;
251 // Cookie????
252 procedure GetCookie(CookieMng: TIdCookieManager; ABoard: TBoard);
253 // hidden???若?水??
254 procedure GetHiddenParameter(Rawtext: String; ABoard: TBoard);
255 //! ?ュ???≪?激?鴻???????????≪?????<???ャ?若???????????ゃ???潟??
256 procedure InputAssistMenuClick(Sender: TObject);
257 //! TMemo?????若?純???臀?????絖????水??/span>
258 procedure InsertText(Memo: TMemo; Text: String);
259 //! ??篆>賢罩?/span>
260 procedure CancelSend(ABoard: TBoard; ASysMenu: HMENU);
261 //! Samba?帥?ゃ???若?ゃ???潟??
262 procedure SambaTimer(Sender: TObject);
263 //! ???c?潟???????臀????泣?ゃ?冴??┃絎?
264 procedure SetWindowRect;
265 //! ?≦宍?帥??荐??
266 procedure SetExtraTab;
267 //! ?水??
268 function GetBoard : TBoard;
269 //! URL?????若?帥??stream?????莨若??
270 procedure GetWebData(const URL: string; const RefURL: string;
271 Modified: TDateTime; stream: TStream);
272 //! GikoForm???亥???<???祉?若?吾??菴遵??????
273 procedure AddFormMessageNew(icon: TGikoMessageIcon);
274 //! ???若????usiana????????
275 function isLocalFusianaTrap: Boolean;
276 //! ???若????usiana????????
277 function isRemoteFusianaTrap: Boolean;
278 //! Header??絖?????緇?
279 function getHeaderStr(const ACOOKIE: string; const SPID : string;
280 const PON : string; const HAP : string; Board : TBoard) : string;
281 //! fusiana茘??????ゃ?≪????/span>
282 function FusianaMsgBox: Integer;
283 //! sent.ini???<?ゃ????????
284 function CreateSentIniFile: TMemIniFile;
285 //! 茯ょ?????с????/span>
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 = '???潟???? ?鴻??????????c??#39;;
306 CAPTION_NAME_RES: string = '???潟???? ???鴻?????c??#39;;
307
308 // ?????c???????c?潟???????割??????????????霡糸????span>
309 WINDOWMOVE_H = 30;
310 WINDOWMOVE_V = 30;
311
312 //DAX????鐔縁?鐔駈?鐓?!(卒?緒?)
313 READCGI_ERR = '-ERR';
314 READCGI_INCR = '-INCR';
315 READCGI_OK = '+OK';
316 READCGI_PARTIAL = '+PARTIAL';
317 READCGI_ERR_FOUND_KAKO = '-ERR ??サ???医??綺??х?肴?';
318 READCGI_ERR_NOT_HTML = '-ERR html??緇???#39;;
319 READCGI_ERR_NOT_FOUND = '-ERR ????????r?鴻???????????с????';
320 READCGI_ERR_ABONE = '-ERR ???????с???若?若???????c???帥?????с????';
321 READCGI_ERR_TIMEOUT = '-ERR ??絎????????????障??????';
322 READCGI_ERR_CANTUSE = '-ERR ???????ゃ?????障????';
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 //???c?潟???????臀?┃絎?
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 // ???????????処┃絎?
378 TransAction.Enabled := GikoSys.CanUser32DLL;
379
380 // ???c?潟???????鴻???ょ?倶??
381 if GikoSys.Setting.EditWindowStay then begin // ?鴻???ょ?倶??
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 // ?鴻???ゃ??????
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 // ???c?潟????????????倶??
392 if(GikoSys.Setting.EditWindowTranslucent) and (TransAction.Enabled) then begin // ???????????潟?鴻???若?祉?潟??鐚??倶??
393 AlphaBlend := true;
394 TransAction.Checked := true;
395 TransToolButton.Down := true;
396 end else begin // 筝????/span>
397 AlphaBlend := false;
398 TransAction.Checked := false;
399 TransToolButton.Down := false;
400 end;
401 // ??????倶?????絖?
402 GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;
403
404 SpaceToNBSPAction.Checked := GikoSys.Setting.SpaceToNBSP;
405 AmpToCharRefAction.Checked := GikoSys.Setting.AmpToCharRef;
406 // ???若???????若????帥???????糸????帥????┃絎?
407 SetExtraTab;
408
409 // ???取┃絎?????粋昭??/span>
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 // & ??舟?????????????????????/span>
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 // 絎?篏????с? 1 ??絖???
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 := '???<??????';
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 := '???若???????若??????';
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 = '???ュ???????????障??????';
605 ERROR: string = '??????#39;;
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 := '?泣?若???????祉????????????????????篆≦?堺?ャ?障????'#13#10
619 + '?鴻?????????贋?逸???緇?鐚?緇???15腱?緇??c????????篆<???????????';
620 MsgBox(Handle, Msg, ERROR, MB_OK or MB_ICONSTOP);
621 Result := False;
622 end else if BodyEdit.Text = '' then begin
623 Msg := '????' + 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 := '?帥?ゃ????#39; + 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('??39;, NameComboBox.Text) <> 0) then begin
632 Msg := '???違?ゃ?潟?????????????р?????純???????堺?ャ?障??????'#13#10
633 + '?????障?冗??篆<???????????????с????鐚?';
634 rc := MsgBox(Handle, Msg, '腆肴?', 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 //??紊у???祉???c?潟?????臀??絖?
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; // ?鴻???ょ?倶?????絖?
661 GikoSys.Setting.EditWindowTranslucent := TransAction.Checked; // ??????倶?????絖?
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 //! ??篆>賢罩≪?????????<???ャ?若??????
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 //???激?≪??????????茘???(LocalMode) by 絎???箴?/span>
798 if (isLocalFusianaTrap) then begin
799 CancelSend( Board, SysMenu );
800 Exit;
801 end;
802 //???激?≪??????????茘???(Remote)
803 if (isRemoteFusianaTrap) then begin
804 CancelSend( Board, SysMenu );
805 Exit;
806 end;
807 // 茯ょ?????с????/span>
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 //???若???我?
835 if not FirstWriting then
836 raise Exception.Create('');
837
838 MsgResult := MsgBox( Handle,
839 '?紙??腮帥????????絎鴻???潟???若??篆?絖???綣?????荵∵?膈????????翫?????????障????' + #13#10 +
840 '?紙??腮帥???≪?????榊??????莢?算????????腮粋????鍵???障????' + #13#10#13#10 +
841 '??岡篁祉??莢??????????粋??????吾??莨若?帥?障????鐚?',
842 '????#39;,
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 //????筝????????<?純????
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 //???若???我?
862 if not FirstWriting then
863 raise Exception.Create('');
864
865 MsgResult := MsgBox( Handle,
866 '?吾??莨若?帥???≪??????????????井???宴??荐??蚊?????????障????' + #13#10 +
867 '??腮帥???≪?????榊??????莢?算????????腮粋????鍵???障????' + #13#10 +
868 '?????????????????篁?篋冴??新???????????吾??莨若?帥??ァ???????????' + #13#10 +
869 '??腮帥????????絎鴻???潟???若?私?絖??糸????肢拶莠?膈????????翫?????????障????' + #13#10 +
870 #13#10 +
871 '??岡篁祉??莢??????????粋??????吾??莨若?帥?障????鐚?',
872 '腆肴?',
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 '莢贋?鴻???羈?絽???篏???筝??с????綣???菴??????????障????(鐚????祉?????????障??)' + #13#10
894 , '腆肴?',
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 '莢贋?鴻???羈?絽????若?????障??????' + #13#10 +
908 '綽?羈?絽??????ゃ???障??????????篆<?????????????'
909 , '腆肴?',
910 MB_OK or MB_ICONINFORMATION);
911 // 綽?羈?絽?綏紫????羔???
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 // 綽?羈?絽?綏紫???????若??ookie???贋?違????
924 if ResultType = grtNinpouErr then begin
925 GetCookie(Indy.CookieManager, Board);
926 end;
927 State := gdsError;
928 raise Exception.Create('');
929 end;
930 except
931 on E: EIdSocketError do begin
932 State := gdsError;
933 ResponseText := '<html><body>'
934 + '<div>?ョ???紊掩?????障????<br>'
935 + '??膩????倶????茯帥?鴻?????????<br></div>'
936 + '<br><br><div>' + E.Message + '</div>'
937 + '</body></html>';
938 end;
939 on E: EIdConnectException do begin
940 State := gdsError;
941 ResponseText := '<html><body>'
942 + '<div>?ョ???紊掩?????障????<br>'
943 + '??膩??????????激???倶????茯帥?鴻?????????<br></div>'
944 + '<br><br><div>' + E.Message + '</div>'
945 + '</body></html>';
946 end;
947 on E: Exception do begin
948 State := gdsError;
949
950 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '<', '&lt;');
951 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '>', '&gt;');
952 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '<', '&lt;');
953 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '>', '&gt;');
954
955 ResponseText := '<html><body>' + TextStream.DataString;
956 ResponseText := AnsiReplaceText(ResponseText, '</body>', '');
957 ResponseText := AnsiReplaceText(ResponseText, '</html>', '');
958 ResponseText := ResponseText + '<hr><div align="left"><pre>';
959 ResponseText := ResponseText + '<b>???????????潟??????????lt;/b>'#13#10;
960 ResponseText := ResponseText + #13#10'???篆?#39;#13#10;
961 ResponseText := ResponseText + FDebugStrSend;
962 ResponseText := ResponseText + #13#10'???篆?#39;#13#10;
963 ResponseText := ResponseText + FDebugStrReceive;
964 ResponseText := ResponseText + '</pre></div></body></html>';
965 end;
966 end;
967 FStatusCode := Indy.ResponseCode;
968 if FAbort then
969 State := gdsAbort;
970 finally
971 Source.Free;
972 TextStream.Free;
973 if ( Indy.CookieManager <> nil ) then begin
974 Indy.CookieManager.CookieCollection.Clear;
975 end;
976 //sysMenu := GetSystemMenu( Handle, true );
977 EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
978 DrawMenuBar(Handle);
979 end;
980 FWork := false;
981 //????????潟?????帥??????ch篋????鴻??????????/span>
982 //2ch篁ュ??с????esponceCode??302Found?ф?吾??莨若?水?篋?
983 //if (not Board.Is2ch) and (FStatusCode = 302) then begin
984 if FStatusCode = 302 then begin
985 GikoForm.PlaySound('ResEnd');
986 SaveSendFile;
987 AddFormMessageNew( gmiOK );
988 if (not ContinueModeAction.Enabled) or (not ContinueModeAction.Checked) then begin
989 Close;
990 Exit;
991 end;
992 end;
993 if State = gdsComplete then begin
994 GikoForm.PlaySound('ResEnd');
995 SaveSendFile;
996 AddFormMessageNew( gmiOK );
997 if (not ContinueModeAction.Enabled) or (not ContinueModeAction.Checked) then begin
998 Close;
999 end;
1000 end else if State = gdsError then begin
1001 AddFormMessageNew( gmiOK );
1002 EditorPage.ActivePage := PreviewTab;
1003 SetContent(ResponseText, Browser);
1004 end else if State = gdsAbort then begin
1005 GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmAbort), nil, gmiSAD);
1006 end;
1007 end;
1008 function TEditorForm.GetResultType(ResponseText: string): TGikoResultType;
1009 begin
1010 if AnsiPos('?吾?????帥??腟?????障????', ResponseText) <> 0 then
1011 Result := grtOK
1012 else if ( (AnsiPos('<b>????????鐚?莢贋?鴻???羈?絽???篏??????障????鐚???緇?????綺??吾??莨若????????絽違?????????', ResponseText) > 0) or
1013 (AnsiPos('鐚ワ鴫鐚駕鹿鐚駕?莢贋?鴻?????冴???吾??篏???筝??с??', ResponseText) > 0) )
1014 and (AnsiPos(RES2CH_COOKIE, ResponseText) > 0) then
1015 Result := grtNinpou
1016 else if ( (AnsiPos('鐚ワ鴫鐚駕鹿鐚駕?篆????莇潟???障????', ResponseText) > 0) or // ?????惹?宴??
1017 (AnsiPos('鐚ワ鴫鐚駕鹿鐚駕?Lv??莇潟????????鴻??????腴???#39;, ResponseText) > 0) ) // ?????惹?宴??
1018 and (AnsiPos(RES2CH_COOKIE, ResponseText) > 0) then
1019 Result := grtNinpouErr
1020 else if( AnsiPos('<b>?????????с??????鐚?Lv=0 <br>?????????у奨羇祉?с????????', ResponseText) > 0)
1021 and (AnsiPos(RES2CH_COOKIE, ResponseText) > 0) then
1022 Result := grtSuiton
1023 else if ( AnsiPos('???????若?????????????????с??', ResponseText) > 0) or
1024 (AnsiPos('<title>???????主∈茯?鐚?</title>', ResponseText) > 0) or
1025 (AnsiPos('<title>?????????主∈茯?鐚???</title>', ResponseText) > 0) or
1026 (AnsiPos(RES2CH_COOKIE, ResponseText) > 0) then
1027 Result := grtCookie
1028 else if (AnsiPos('<font size=+2 color=#FF0000>?吾??莨若?帥???с????? </font>', ResponseText) > 0) or
1029 (AnsiPos('<title>?? ?吾??莨若?睡∈茯????障?? ??</title>', ResponseText) > 0) or
1030 (AnsiPos('<title>??腮睡∈茯?</title>', ResponseText) > 0) or
1031 (AnsiPos('<b>?吾?????睡∈茯?</b>', ResponseText) > 0) or
1032 (AnsiPos('="../test/subbbs.cgi">', ResponseText) > 0) or
1033 (AnsiPos(RES2CH_FALSE, ResponseText) > 0) then
1034 Result := grtCheck
1035 else if (AnsiPos('?紙??腮粋???????牙ず?翠???区?????????????篏???篋堺?惹┤??筝???茵?篏帥?????????????粋????障????<br>', ResponseText) > 0) or
1036 (AnsiPos('鐚???篏?罔??膃?1?<??????膃?8?<???絎???????罔?????????鐚????????┤?????ゃ????', ResponseText) > 0) then
1037 Result := grtCookie
1038 else
1039 Result := grtError;
1040 end;
1041
1042
1043 procedure TEditorForm.GetSendData(Source: TStringStream);
1044 var
1045 SessionID: string;
1046 s: string;
1047 SendTime: Integer;
1048 Adjust: Integer;
1049 Board: TBoard;
1050 body : string;
1051 begin
1052 Board := GetBoard;
1053
1054 if GikoSys.Setting.UseMachineTime then begin
1055 if GikoSys.Setting.TimeAdjust then
1056 Adjust := Gikosys.Setting.TimeAdjustSec
1057 else
1058 Adjust := GikoSys.Setting.TimeAdjustSec * -1;
1059 SendTime := GikoSys.DateTimeToInt(Now) - (9 * 60 * 60) + Adjust
1060 end else begin
1061 if (Board.LastGetTime = 0) or (Board.LastGetTime = ZERO_DATE) then
1062 SendTime := GikoSys.DateTimeToInt(Now)
1063 else
1064 SendTime := GikoSys.DateTimeToInt(Board.LastGetTime);
1065 end;
1066
1067 body := GetBody;
1068
1069 SessionID := GikoSys.Dolib.SessionID;
1070 if SessionID <> '' then
1071 s := 'sid=' + HttpEncode(SessionID) + '&'
1072 else
1073 s := '';
1074 s := s + 'subject=&'
1075 + 'FROM=' + HttpEncode(NameComboBox.Text) + '&'
1076 + 'mail=' + HttpEncode(MailComboBox.Text) + '&'
1077 + 'MESSAGE=' + HttpEncode(body) + '&'
1078 + 'bbs=' + Board.BBSID + '&'
1079 + 'time=' + IntToStr(SendTime) + '&';
1080
1081 if FThreadItem = nil then begin
1082 s := s + 'subject=' + HttpEncode(TitleEdit.Text) + '&';
1083 s := s + 'submit=' + HttpEncode('??岡篁祉??莢??????????粋??????吾??莨若??') + #13#10;
1084 end else begin
1085 s := s + 'key=' + ChangeFileExt(FThreadItem.FileName, '') + '&';
1086 s := s + 'submit=' + HttpEncode('?吾??莨若??') + #13#10;
1087 end;
1088 Source.WriteString(s);
1089 end;
1090
1091 procedure TEditorForm.SaveSendFile;
1092 var
1093 sDate: string;
1094 ini: TMemIniFile;
1095 begin
1096 ini := CreateSentIniFile;
1097 if (ini <> nil) then begin
1098 try
1099 sDate := IntToStr(GikoSys.DateTimeToInt(Now));
1100
1101 ini.WriteString(sDate, 'Name', NameComboBox.Text);
1102 ini.WriteString(sDate, 'EMail', MailComboBox.Text);
1103 ini.WriteString(sDate, 'Body', HttpEncode(BodyEdit.Text));
1104 ini.WriteInteger(sDate, 'Status', FStatusCode);
1105 ini.WriteDateTime(sDate, 'Date', Now);
1106 if FThreadItem = nil then begin
1107 ini.WriteString(sDate, 'Title', MojuUtils.Sanitize(TitleEdit.Text));
1108 //ini.WriteString(sDate, 'BBS', FBoard.BBSID);
1109 ini.WriteString(sDate, 'URL', FBoard.URL);
1110 ini.WriteInteger(sDate, 'NewThread', 1);
1111 end else begin
1112 ini.WriteString(sDate, 'Title', FThreadItem.Title);
1113 //ini.WriteString(sDate, 'BBS', FThreadItem.ParentBoard.BBSID);
1114 ini.WriteString(sDate, 'URL', FThreadItem.URL);
1115 ini.WriteString(sDate, 'Key', ChangeFileExt(FThreadItem.FileName, ''));
1116 end;
1117
1118 ini.UpdateFile;
1119 finally
1120 ini.Free;
1121 end;
1122 end;
1123 end;
1124 function TEditorForm.CreateSentIniFile: TMemIniFile;
1125 var
1126 maxSize, fileSize, i: Integer;
1127 newName: String;
1128 begin
1129 Result := nil;
1130 // MB -> bytes
1131 maxSize := GikoSys.Setting.SentIniFileSize * 1024 * 1024;
1132 // ???<?ゃ???泣?ゃ?冴??0???翫??????sent.ini???吾??莨若?障????????il??菴???
1133 if (maxSize > 0) then begin
1134 fileSize := GikoSys.GetFileSize(GikoSys.Setting.GetSentFileName);
1135 // ??紊с?泣?ゃ?冴??莇??????????翫?????????若??????
1136 if (fileSize >= maxSize) then begin
1137 i := 0;
1138 // 篁??????祉?????<?ゃ????????????ゃ????
1139 repeat
1140 // 10??篁ヤ?紊掩??????????????????
1141 if (i > 10) then break;
1142 DateTimeToString(newName, 'yyhhnnsszzz', Now());
1143 Inc(i);
1144 until RenameFile(GikoSys.Setting.GetSentFileName,
1145 GikoSys.Setting.GetSentFileName + '.' + newName);
1146 end;
1147 Result := TMemIniFile.Create(GikoSys.Setting.GetSentFileName);
1148 end;
1149 end;
1150 procedure TEditorForm.SendActionExecute(Sender: TObject);
1151 const
1152 TITLE_SAMBA : string = 'Samba24茘???';
1153 var
1154 Board: TBoard;
1155 rc: Integer;
1156 rc2: Integer;
1157 state : TGikoDownloadState;
1158 body : string;
1159 begin
1160 if FWork then
1161 Exit;
1162 try
1163 FWork := True;
1164 SendAction.Enabled := False;
1165 Application.ProcessMessages;
1166 if not Check then Exit;
1167
1168 Board := GetBoard;
1169
1170 if FThreadItem = nil then begin
1171 rc := GikoUtil.MsgBox(Handle,
1172 '??' + Board.Title + '???帥???違?????鴻??????腴????障??'#13#10#13#10
1173 + '?紙?帥?????若????絎??c???吾??莨若?帥?с??????????腆肴????障??????鐚?'#13#10
1174 + '?私??????????????鴻?????????<???c????????腆肴????障??????鐚?'#13#10#13#10
1175 + '???????????若??????篆<???障??',
1176 '腆肴?',
1177 MB_ICONQUESTION or MB_YESNO);
1178 if rc <> ID_YES then
1179 Exit;
1180 end;
1181
1182 SetNameList(NameComboBox.Text, MailComboBox.Text);
1183 if (KotehanCheckBox.Enabled) and (KotehanCheckBox.Checked) then begin
1184 Board.KotehanName := NameComboBox.Text;
1185 Board.KotehanMail := MailComboBox.Text;
1186 end;
1187
1188 if Board.IsBoardPlugInAvailable then begin
1189 body := GetBody;
1190
1191 if FThreadItem = nil then begin
1192 // ?鴻?????/span>
1193 state := TGikoDownloadState( Board.BoardPlugIn.CreateThread(
1194 DWORD( Board ), TitleEdit.Text, NameComboBox.Text, MailComboBox.Text, body ) );
1195
1196 if state = gdsComplete then begin
1197 GikoForm.PlaySound('ResEnd');
1198 SaveSendFile;
1199 GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmNewSure), nil, gmiOK);
1200 FWork := False;
1201 Close;
1202 end else if State = gdsError then begin
1203 GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmSureError), nil, gmiNG);
1204 end else if State = gdsAbort then begin
1205 GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmAbort), nil, gmiNG);
1206 end;
1207 end else begin
1208 // ????/span>
1209 state := TGikoDownloadState( FThreadItem.ParentBoard.BoardPlugIn.WriteThread(
1210 DWORD( FThreadItem ), NameComboBox.Text, MailComboBox.Text, body ) );
1211
1212 if state = gdsComplete then begin
1213 GikoForm.PlaySound('ResEnd');
1214 SaveSendFile;
1215 GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmNewRes), nil, gmiOK);
1216 FWork := False;
1217 Close;
1218 end else if State = gdsError then begin
1219 GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmResError), nil, gmiOK);
1220 end else if State = gdsAbort then begin
1221 GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmAbort), nil, gmiOK);
1222 end;
1223 end;
1224 end else begin
1225 if not FSambaTimer.Enabled then begin
1226 if CompareDateTime(Board.Expires ,Now) <= 0 then begin
1227 Board.Cookie := '';
1228 Board.SPID := '';
1229 Board.PON := '';
1230 end;
1231 // ???冴???吾???????祉???馹?絲上?
1232 if (Board.Is2ch) and (AnsiPos('HAP=', Board.Cookie)>0) then begin
1233 Board.Cookie := '';
1234 end;
1235 Send(Board.Cookie, Board.SPID, Board.PON, True);
1236 end else begin
1237 if not FSambaTimer.CheckSambaTime(Now()) then begin
1238 rc := GikoUtil.MsgBox(Handle,
1239 'Samba24???絎??ゆ???????違????腟??????????障??????'#13#10
1240 + '??篆<??筝?????障????鐚?' + #13#10
1241 + '(????????????????篆<???障??)', TITLE_SAMBA,
1242 MB_YESNO or MB_ICONQUESTION);
1243 if rc = IDYES then begin
1244 FWork := false;
1245 Exit;
1246 end;
1247 if rc = IDNO then begin
1248 rc2 := GikoUtil.MsgBox(Handle,
1249 '???????篆<???障????鐚?',
1250 TITLE_SAMBA,
1251 MB_YESNO or MB_ICONQUESTION);
1252 if rc2 = IDNO then begin
1253 FWork := False;
1254 Exit;
1255 end;
1256 end;
1257 end;
1258 if CompareDateTime(Board.Expires ,Now) <= 0 then begin
1259 Board.Cookie := '';
1260 Board.SPID := '';
1261 Board.PON := '';
1262 end;
1263 // ???冴???吾???????祉???馹?絲上?
1264 if (Board.Is2ch) and (AnsiPos('HAP=', Board.Cookie)>0) then begin
1265 Board.Cookie := '';
1266 end;
1267 Send(Board.Cookie, Board.SPID, Board.PON, True);
1268 end;
1269 end;
1270 finally
1271 FWork := False;
1272 if FSambaTimer.Enabled then begin
1273 FNow := FSambaTimer.Update;
1274 end;
1275 end;
1276 end;
1277
1278 procedure TEditorForm.SaveActionExecute(Sender: TObject);
1279 begin
1280 //
1281 end;
1282
1283 procedure TEditorForm.CloseActionExecute(Sender: TObject);
1284 begin
1285 Close;
1286 end;
1287
1288 procedure TEditorForm.UndoActionExecute(Sender: TObject);
1289 begin
1290 SendMessage(GetActiveControlHandle, WM_UNDO, 0, 0);
1291 end;
1292
1293 procedure TEditorForm.CutActionExecute(Sender: TObject);
1294 begin
1295 SendMessage(GetActiveControlHandle, WM_CUT, 0, 0);
1296 end;
1297
1298 procedure TEditorForm.CopyActionExecute(Sender: TObject);
1299 begin
1300 SendMessage(GetActiveControlHandle, WM_COPY, 0, 0);
1301 end;
1302
1303 procedure TEditorForm.PasteActionExecute(Sender: TObject);
1304 begin
1305 SendMessage(GetActiveControlHandle, WM_PASTE, 0, 0);
1306 end;
1307
1308 procedure TEditorForm.SelectAllActionExecute(Sender: TObject);
1309 begin
1310 SendMessage(GetActiveControlHandle, EM_SETSEL, 0, GetWindowTextLength(GetActiveControlHandle));
1311 end;
1312
1313 procedure TEditorForm.TopActionExecute(Sender: TObject); // ???c?潟??????????Stay)???帥?潟??????
1314 begin
1315 if not (fsShowing in Self.FormState) then begin
1316 if TopAction.Checked then begin // ?鴻???ょ?倶????┃絎?
1317 SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
1318 GikoSys.Setting.EditWindowStay := true;
1319 end else begin // ?鴻???ょ?倶??茹i??/span>
1320 SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
1321 GikoSys.Setting.EditWindowStay := false;
1322 end;
1323 // ?鴻???ょ?倶?????絖?
1324 //GikoSys.Setting.EditWindowStay := FormStyle = fsStayOnTop;
1325 end;
1326 end;
1327
1328 procedure TEditorForm.AbortActionExecute(Sender: TObject);
1329 begin
1330 FAbort := True;
1331 end;
1332
1333 procedure TEditorForm.SendActionUpdate(Sender: TObject);
1334 begin
1335 SendAction.Enabled := not FWork;
1336 end;
1337
1338 procedure TEditorForm.SaveActionUpdate(Sender: TObject);
1339 begin
1340 SaveAction.Enabled := False;
1341 end;
1342
1343 procedure TEditorForm.CloseActionUpdate(Sender: TObject);
1344 begin
1345 CloseAction.Enabled := not FWork;
1346 end;
1347
1348 procedure TEditorForm.UndoActionUpdate(Sender: TObject);
1349 begin
1350 UndoAction.Enabled := (GetActiveControlHandle <> 0)
1351 and (SendMessage(GetActiveControlHandle, EM_CANUNDO, 0, 0) <> 0)
1352 and (not FWork);
1353 end;
1354
1355 procedure TEditorForm.CutActionUpdate(Sender: TObject);
1356 var
1357 Selection: TSelection;
1358 AHandle: THandle;
1359 begin
1360 AHandle := GetActiveControlHandle;
1361 SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
1362 CutAction.Enabled := (AHandle <> 0)
1363 and ((Selection.EndPos - Selection.StartPos) <> 0)
1364 and (not FWork);
1365 end;
1366
1367 procedure TEditorForm.CopyActionUpdate(Sender: TObject);
1368 var
1369 Selection: TSelection;
1370 AHandle: THandle;
1371 begin
1372 AHandle := GetActiveControlHandle;
1373 SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
1374 CopyAction.Enabled := (AHandle <> 0)
1375 and ((Selection.EndPos - Selection.StartPos) <> 0)
1376 and (not FWork);
1377 end;
1378
1379 procedure TEditorForm.PasteActionUpdate(Sender: TObject);
1380 begin
1381 PasteAction.Enabled := (GetActiveControlHandle <> 0)
1382 and (Clipboard.HasFormat(CF_TEXT))
1383 and (not FWork);
1384 end;
1385
1386 procedure TEditorForm.TopActionUpdate(Sender: TObject);
1387 begin
1388 TopAction.Enabled := not FWork;
1389 end;
1390
1391 procedure TEditorForm.SageCheckBoxClick(Sender: TObject);
1392 begin
1393 if SageCheckBox.Checked then begin
1394 if AnsiPos('sage', MailComboBox.Text) = 0 then
1395 MailComboBox.Text := 'sage' + MailComboBox.Text;
1396 end else begin
1397 if AnsiPos('sage', MailComboBox.Text) <> 0 then
1398 MailComboBox.Text := StringReplace(MailComboBox.Text, 'sage', '', [rfReplaceAll]);
1399 end;
1400 end;
1401
1402 procedure TEditorForm.MailComboBoxChange(Sender: TObject);
1403 begin
1404 if AnsiPos('sage', MailComboBox.Text) = 0 then
1405 SageCheckBox.Checked := False
1406 else
1407 SageCheckBox.Checked := True;
1408 end;
1409
1410 procedure TEditorForm.IdLogDebugReceive(ASender: TIdConnectionIntercept;
1411 AStream: TStream);
1412 var
1413 StringStream: TStringStream;
1414 begin
1415 StringStream := TStringStream.Create('');
1416 try
1417 StringStream.CopyFrom(AStream, AStream.Size);
1418 FDebugStrReceive := FDebugStrReceive + StringStream.DataString;
1419 finally
1420 StringStream.Free;
1421 end;
1422 end;
1423
1424 procedure TEditorForm.IdLogDebugSend(ASender: TIdConnectionIntercept;
1425 AStream: TStream);
1426 var
1427 StringStream: TStringStream;
1428 begin
1429 StringStream := TStringStream.Create('');
1430 try
1431 StringStream.CopyFrom(AStream, AStream.Size);
1432 FDebugStrSend := FDebugStrSend + StringStream.DataString;
1433 finally
1434 StringStream.Free;
1435 end;
1436 end;
1437
1438 procedure TEditorForm.TransActionExecute(Sender: TObject);
1439 begin
1440 AlphaBlend := TransAction.Checked;
1441 // ??????倶?????絖?
1442 GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;
1443 end;
1444
1445 procedure TEditorForm.TransActionUpdate(Sender: TObject);
1446 begin
1447 TransAction.Enabled := not FWork;
1448 end;
1449 //StatusBar??anels[0]??????????罧??????阪???????
1450 procedure TEditorForm.StatusBarResize(Sender: TObject);
1451 begin
1452 StatusBar.Panels[0].Width := StatusBar.Width
1453 - StatusBar.Panels[1].Width - StatusBar.Panels[2].Width;
1454
1455 end;
1456
1457 //Form??Active?????c??????腟??吾??莨若?炊??????茯??粋昭??
1458 procedure TEditorForm.FormActivate(Sender: TObject);
1459 begin
1460 if ( FSambaTimer.Enabled ) and ( FThreadItem <> nil ) then
1461 begin
1462 FNow := FSambaTimer.Update;
1463 end;
1464 if GikoSys.Setting.GestureEnabled then begin
1465 GikoSys.Setting.Gestures.ClearGesture;
1466 GikoSys.Setting.Gestures.LoadGesture(
1467 GikoSys.Setting.GetGestureFileName, ActionList );
1468 MouseGesture.UnHook;
1469 MouseGesture.OnGestureStart := OnGestureStart;
1470 MouseGesture.OnGestureMove := OnGestureMove;
1471 MouseGesture.OnGestureEnd := OnGestureEnd;
1472 MouseGesture.SetHook( Handle );
1473 end;
1474 end;
1475 procedure TEditorForm.FormCloseQuery(Sender: TObject;
1476 var CanClose: Boolean);
1477 begin
1478 CanClose := not FWork;
1479 end;
1480
1481 procedure TEditorForm.QuotePasteActionExecute(Sender: TObject);
1482 var
1483 s : TStringList;
1484 i : Integer;
1485 quote : string;
1486 begin
1487
1488 quote := GikoSys.GetOEIndentChar;
1489 s := TStringList.Create;
1490 try
1491 s.Text := Clipboard.AsText;
1492
1493 for i := s.Count - 1 downto 0 do
1494 s[ i ] := quote + s[ i ];
1495
1496 BodyEdit.SelText := s.Text;
1497 finally
1498 s.Free;
1499 end;
1500
1501 end;
1502
1503 procedure TEditorForm.SpaceToNBSPActionExecute(Sender: TObject);
1504 begin
1505 GikoSys.Setting.SpaceToNBSP := SpaceToNBSPAction.Checked;
1506 if EditorPage.ActivePage = PreviewTab then
1507 Preview;
1508 end;
1509
1510 procedure TEditorForm.AmpToCharRefActionExecute(Sender: TObject);
1511 begin
1512 GikoSys.Setting.AmpToCharRef := AmpToCharRefAction.Checked;
1513 if EditorPage.ActivePage = PreviewTab then
1514 Preview;
1515 end;
1516
1517 procedure TEditorForm.BoardTopClick(Sender: TObject);
1518 var
1519 ini: TMemIniFile;
1520 begin
1521 ini := TMemIniFile.Create(GikoSys.Setting.GetFileName);
1522 try
1523 BoardtopTab.TabVisible := BoardTop.Checked;
1524 ini.WriteBool('EditorForm', 'BoardTopTab', BoardtopTab.TabVisible);
1525 ini.UpdateFile;
1526 finally
1527 ini.Free;
1528 end;
1529 end;
1530
1531
1532 procedure TEditorForm.GetSETTINGTXTActionExecute(Sender: TObject);
1533 var
1534 memStream: TMemoryStream;
1535 URL, RefURL: string;
1536 settingBody: TStringList;
1537 tmpBoard: TBoard;
1538 begin
1539 if not FWork then begin
1540 FWork := True;
1541
1542 tmpBoard := GetBoard;
1543 if tmpBoard <> nil then begin
1544
1545 RefURL := tmpBoard.URL;
1546 if RefURL[Length(RefURL)] <> '/' then
1547 URL := RefURL + '/' + 'SETTING.TXT'
1548 else
1549 URL := RefURL + 'SETTING.TXT';
1550 Screen.Cursor := crHourGlass;
1551 memStream := TMemoryStream.Create;
1552 try
1553 try
1554 StatusBar.Panels[0].Text := 'SETTING.TXT?????潟???若??筝?#39;;
1555 GetWebData(URL, RefURL, tmpBoard.SETTINGTXTTime, memStream);
1556 if( Indy.ResponseCode = 200 ) then begin
1557 settingBody := TStringList.Create;
1558 try
1559 memStream.Seek(0, soFromBeginning);
1560 settingBody.LoadFromStream(memStream);
1561 settingBody.SaveToFile(tmpBoard.GetSETTINGTXTFileName);
1562 tmpBoard.SETTINGTXTTime := Indy.Response.LastModified;
1563 tmpBoard.IsSETTINGTXT := true;
1564 tmpBoard.TitlePictureURL := GetTitlePictureURL(settingBody, tmpBoard);
1565 tmpBoard.Modified := true;
1566 finally
1567 settingBody.Free;
1568 end;
1569 StatusBar.Panels[0].Text := 'SETTING.TXT??緇?絎?篋?(' + IntToStr(Indy.ResponseCode) + ')';
1570 end;
1571 except
1572 on E: EIdException do begin
1573 if( AnsiPos('304', E.Message) > 0 ) then
1574 StatusBar.Panels[0].Text := 'SETTING.TXT?贋?亥?<??(' + IntToStr(Indy.ResponseCode) + ')'
1575 else
1576 StatusBar.Panels[0].Text := 'SETTING.TXT??緇???????' + IntToStr(Indy.ResponseCode) + ')';
1577 end;
1578 end;
1579 finally
1580 memStream.Free;
1581 Screen.Cursor := crDefault;
1582 end;
1583 ShowBoardInformation(tmpBoard, BoardInformationMemo);
1584 end;
1585 FWork := False;
1586 end;
1587 end;
1588
1589 procedure TEditorForm.ShowBoardInformation(ABoard: TBoard; AMemo: TMemo);
1590 var
1591 body: TStringList;
1592 begin
1593 AMemo.Clear;
1594 AMemo.Lines.Add('[SETTING.TXT]');
1595 if ABoard.IsSETTINGTXT then begin
1596 if FileExists(ABoard.GetSETTINGTXTFileName) then begin
1597 AMemo.Lines.Add(DateTimeToStr(ABoard.SETTINGTXTTime) + ' ?贋??#39;);
1598 body := TStringList.Create;
1599 try
1600 body.LoadFromFile(ABoard.GetSETTINGTXTFileName);
1601 AMemo.Lines.AddStrings(body);
1602 finally
1603 body.Free;
1604 end;
1605 end else begin
1606 ABoard.IsSETTINGTXT := false;
1607 ABoard.SETTINGTXTTime := ZERO_DATE;
1608 AMemo.Lines.Add('Local???絖???????SETTING.TXT??荀??ゃ?????障????');
1609 AMemo.Lines.Add('?<???ャ?若????????緇??????????????');
1610 end;
1611 end else begin
1612 AMemo.Lines.Add('SETTING.TXT????緇????????障??????');
1613 AMemo.Lines.Add('?<???ャ?若??????緇??????????????');
1614 end;
1615 end;
1616 function TEditorForm.GetTitlePictureURL(body: TStringList; ABoard: TBoard): string;
1617 //BBS_TITLE_PICTURE=
1618 //BBS_FIGUREHEAD=
1619 var
1620 i: Integer;
1621 tmp: string;
1622 begin
1623 Result := '';
1624 for i := 0 to body.Count - 1 do begin
1625 if (AnsiPos('BBS_TITLE_PICTURE=', body[i]) > 0) or
1626 (AnsiPos('BBS_FIGUREHEAD=', body[i]) > 0) then begin
1627 tmp := body[i];
1628 Delete(tmp, 1, AnsiPos('=', tmp));
1629 if AnsiPos('../', tmp) > 0 then begin
1630 tmp := CustomStringReplace(tmp, '../', GikoSys.UrlToServer(ABoard.URL));
1631 end;
1632 Result := tmp;
1633 Exit;
1634 end;
1635 end;
1636 end;
1637
1638 procedure TEditorForm.GetTitlePictureActionUpdate(Sender: TObject);
1639 begin
1640 if FThreadItem = nil then
1641 GetTitlePictureAction.Enabled := FBoard.IsSETTINGTXT
1642 else
1643 GetTitlePictureAction.Enabled := FThreadItem.ParentBoard.IsSETTINGTXT;
1644
1645 if GetTitlePictureAction.Enabled Then begin
1646 // 絎?茵?筝????茵?筝???/span>
1647 GetTitlePictureAction.Enabled := not FWork;
1648 end;
1649 end;
1650
1651 procedure TEditorForm.GetTitlePictureActionExecute(Sender: TObject);
1652 var
1653 memStream: TMemoryStream;
1654 tmpBoard: TBoard;
1655 begin
1656 if FWork then
1657 Exit;
1658
1659 FWork := True;
1660 memStream := TMemoryStream.Create;
1661 try
1662 tmpBoard := GetBoard;
1663
1664 if (tmpBoard <> nil) and (tmpBoard.TitlePictureURL <> '') then begin
1665 StatusBar.Panels[0].Text := '?帥???????糸??????潟???若??筝?#39;;
1666 Screen.Cursor := crHourGlass;
1667 try
1668 // URL????絎??????<?≪??????粋昭??
1669 GetWebData(tmpBoard.TitlePictureURL, tmpBoard.URL,
1670 ZERO_DATE, memStream);
1671 if Indy.ResponseCode = 200 then begin
1672 memStream.SaveToFile(tmpBoard.GetTitlePictureFileName);
1673 ShowTitlePicture();
1674 tmpBoard.Modified := true;
1675 end;
1676 StatusBar.Panels[0].Text := '?帥???????糸? (' + IntToStr(Indy.ResponseCode) + ')';
1677 except
1678 end;
1679 end;
1680 finally
1681 memStream.Free;
1682 FWork := False;
1683 Screen.Cursor := crDefault;
1684 end;
1685 end;
1686 {
1687 \brief URL?????若?帥??stream????粋昭??
1688 \param URL 茯??粋昭????
1689 \param RefURL referer??┃絎?????
1690 \param Modified Modified??┃絎?????
1691 \param stream 茯??粋昭???????若?帥???絖???
1692 }
1693 procedure TEditorForm.GetWebData(const URL: string; const RefURL: string;
1694 Modified: TDateTime; stream: TStream);
1695 begin
1696 InitIdHTTP(Indy);
1697 Indy.Request.Referer := RefURL;
1698 Indy.Request.LastModified := Modified;
1699
1700 IdAntiFreeze.Active := True;
1701 try
1702 Indy.Get(URL, stream);
1703 finally
1704 IdAntiFreeze.Active := False;
1705 end;
1706
1707 end;
1708 procedure TEditorForm.ShowTitlePicture();
1709 var
1710 tmpBoard: TBoard;
1711 s: String;
1712 begin
1713 tmpBoard := GetBoard;
1714
1715 if FileExists(tmpBoard.GetTitlePictureFileName) then begin
1716 TitlePictureBrowser.Navigate(tmpBoard.GetTitlePictureFileName);
1717 end else begin
1718 s := '?帥???????糸??????с????<br>?<???ャ?若??????緇??????????????';
1719 SetContent(s, TitlePictureBrowser);
1720 end;
1721 end;
1722
1723 function TEditorForm.GetFusianaName(body: TStringList; ABoard: TBoard): String;
1724 var
1725 i: Integer;
1726 tmp: string;
1727 begin
1728 for i := 0 to body.Count - 1 do begin
1729 if (AnsiPos('BBS_NONAME_NAME=', body[i]) > 0) then begin
1730 tmp := body[i];
1731 Delete(tmp, 1, AnsiPos('=', tmp));
1732 Result := tmp;
1733 Exit;
1734 end;
1735 end;
1736 end;
1737
1738 procedure TEditorForm.GetHeadTXTActionExecute(Sender: TObject);
1739 var
1740 URL, RefURL: string;
1741 settingBody: TStringList;
1742 tmpBoard: TBoard;
1743 memStream: TMemoryStream;
1744 begin
1745 if not FWork then begin
1746 FWork := True;
1747
1748 tmpBoard := GetBoard;
1749 if (tmpBoard <> nil) then begin
1750
1751 RefURL := tmpBoard.URL;
1752 if RefURL[Length(RefURL)] <> '/' then
1753 URL := RefURL + '/' + 'head.txt'
1754 else
1755 URL := RefURL + 'head.txt';
1756
1757 Screen.Cursor := crHourGlass;
1758 memStream := TMemoryStream.Create;
1759 try
1760 StatusBar.Panels[0].Text := '???若???????若??head.txt)?????潟???若??筝?#39;;
1761 try
1762 GetWebData(URL, RefURL, tmpBoard.HEADTXTTime, memStream);
1763 if( Indy.ResponseCode = 200 ) then begin
1764 settingBody := TStringList.Create;
1765 try
1766 memStream.Seek(0, soFromBeginning);
1767 settingBody.LoadFromStream(memStream);
1768 settingBody.Insert(0, '<HTML lang="ja"><HEAD>');
1769 settingBody.Insert(1, '<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">');
1770 settingBody.Insert(2, '<TITLE>' + tmpBoard.Title + '</TITLE>');
1771 settingBody.Insert(3, '<base href="' + RefURL + '"></HEAD><BODY>');
1772 settingBody.Add('</BODY></HTML>');
1773 settingBody.SaveToFile(tmpBoard.GETHEADTXTFileName);
1774 tmpBoard.HEADTXTTime := Indy.Response.LastModified;
1775 tmpBoard.IsHEADTXT := true;
1776 tmpBoard.Modified := true;
1777 finally
1778 settingBody.Free;
1779 end;
1780 StatusBar.Panels[0].Text := '???若???????若????絎?篋?(' + IntToStr(Indy.ResponseCode) + ')';
1781 end;
1782 except
1783 on E: EIdException do begin
1784 if( AnsiPos('304', E.Message) > 0 ) then
1785 StatusBar.Panels[0].Text := '???若???????若???贋?亥?<??(' + IntToStr(Indy.ResponseCode) + ')'
1786 else
1787 StatusBar.Panels[0].Text := '???若???????若??????????' + IntToStr(Indy.ResponseCode) + ')';
1788 end;
1789 end;
1790 finally
1791 memStream.Free;
1792 Screen.Cursor := crDefault;
1793 end;
1794 if tmpBoard.IsHEADTXT then begin
1795 ShowBoardHead(tmpboard, LocalEdit);
1796 end;
1797 end;
1798 FWork := False;
1799 end;
1800
1801 end;
1802
1803 procedure TEditorForm.CalcCapacityActionExecute(Sender: TObject);
1804 var
1805 Board: TBoard;
1806 body: String;
1807 begin
1808 body := GetBody;
1809 //?????????壕????????????c?純????????????????????????????
1810 Board := GetBoard;
1811
1812 if Board.BoardPlugIn <> nil then
1813 body := CustomStringReplace(body, #13#10, '<br>')
1814 else
1815 body := CustomStringReplace(body, #13#10, ' <br> ');
1816 StatusBar.Panels[0].Text := '絎拷??#39; + IntToStr(Length(body)) + ' byte';
1817 end;
1818
1819 procedure TEditorForm.LocalRuleClick(Sender: TObject);
1820 var
1821 ini: TMemIniFile;
1822 begin
1823 ini := TMemIniFile.Create(GikoSys.Setting.GetFileName);
1824 try
1825 RocalRuleTab.TabVisible := LocalRule.Checked;
1826 ini.WriteBool('EditorForm', 'LocalRuleTab', RocalRuleTab.TabVisible);
1827 ini.UpdateFile;
1828 finally
1829 ini.Free;
1830 end;
1831 end;
1832
1833 procedure TEditorForm.FormDeactivate(Sender: TObject);
1834 begin
1835 if GikoSys.Setting.GestureEnabled then begin
1836 GikoSys.Setting.Gestures.ClearGesture;
1837 MouseGesture.UnHook;
1838 MouseGesture.OnGestureStart := nil;
1839 MouseGesture.OnGestureMove := nil;
1840 MouseGesture.OnGestureEnd := nil;
1841 end;
1842 end;
1843
1844 procedure TEditorForm.OnGestureStart(Sender: TObject);
1845 begin
1846 //
1847 end;
1848
1849 procedure TEditorForm.OnGestureMove(Sender: TObject);
1850 var
1851 s: string;
1852 Action: TAction;
1853 ActStr: string;
1854 begin
1855 s := MouseGesture.GetGestureStr;
1856 ActStr := '';
1857 Action := GikoSys.Setting.Gestures.GetGestureAction(s);
1858 if Action <> nil then
1859 ActStr := '鐚?' + Action.Caption + '鐚?';
1860 s := '?吾?с?鴻???c?? ' + s + ActStr;
1861 StatusBar.Panels[0].Text := s;
1862 end;
1863
1864 procedure TEditorForm.OnGestureEnd(Sender: TObject);
1865 var
1866 s: string;
1867 Action: TAction;
1868 begin
1869 s := MouseGesture.GetGestureStr;
1870 MouseGesture.Clear;
1871 Action := GikoSys.Setting.Gestures.GetGestureAction(s);
1872 if Action <> nil then
1873 Action.Execute;
1874 StatusBar.Panels[0].Text := '';
1875 end;
1876
1877 procedure TEditorForm.ShowBoardHead(ABoard: TBoard; AMemo: TMemo);
1878 var
1879 range: OleVariant;
1880 begin
1881 //??????
1882 //http://www.campus.ne.jp/~ishigami/CREATION/TECHNIC/WEBAP-2.htm
1883 WebBrowser1.Navigate(ABoard.GETHEADTXTFileName);
1884 //???帥???潟?違??????????XT??Щ??????????????rz
1885 //筝??????????<????????粋昭?帥??腟???c?????????????с?????????違????????????
1886 //?????с?????障???????????????????????障??????
1887 while (WebBrowser1.ReadyState <> READYSTATE_COMPLETE) and
1888 (WebBrowser1.ReadyState <> READYSTATE_INTERACTIVE) do begin
1889 Application.ProcessMessages;
1890 end;
1891
1892 try
1893 ;
1894 range := OleVariant(WebBrowser1.Document).body.createTextRange;
1895 LocalEdit.Text := range.text;
1896 except
1897 end;
1898 end;
1899
1900 procedure TEditorForm.LocalRuleBrowseClick(Sender: TObject);
1901 var
1902 URL: String;
1903 ABoard: TBoard;
1904 begin
1905 ABoard := GetBoard;
1906
1907 if ABoard = nil
1908 then Exit;
1909
1910 URL := ABoard.GETHEADTXTFileName;
1911 GikoSys.OpenBrowser(URL, gbtAuto);
1912 end;
1913
1914 procedure TEditorForm.SaveNameMailActionExecute(Sender: TObject);
1915 begin
1916 SaveNameMailAction.Checked := not SaveNameMailAction.Checked;
1917 KotehanCheckBox.Enabled := SaveNameMailAction.Checked;
1918 end;
1919
1920 function TEditorForm.LFusianaGet(const s: String): Boolean;
1921 const
1922 FUSIANA = 'fusianasan';
1923 var
1924 i: Integer;
1925 begin
1926 i := AnsiPos(FUSIANA, s);
1927 Result := (i > 0);
1928 end;
1929
1930 procedure TEditorForm.BeLogInOutEActionExecute(Sender: TObject);
1931 begin
1932 GikoDM.BeLogInOutAction.Execute;
1933 end;
1934
1935 procedure TEditorForm.BeLogInOutEActionUpdate(Sender: TObject);
1936 begin
1937 BeLogInOutEAction.Checked := GikoDM.BeLogInOutAction.Checked;
1938 BeLogInOutEAction.Enabled := GikoDM.BeLogInOutAction.Enabled;
1939 end;
1940 // Cookie????
1941 procedure TEditorForm.GetCookie(CookieMng: TIdCookieManager; ABoard: TBoard);
1942 const
1943 VAL_SPID = 'SPID';
1944 VAL_PON = 'PON';
1945 VAL_HAP = 'HAP';
1946 var
1947 i : Integer;
1948 Cookie : TIdCookieRFC2109;
1949 curCookies : TStringList;
1950 begin
1951 // 2008.12.14 ?≧?>散?????≪?????????????? by ??????
1952 curCookies := TStringList.Create;
1953 curCookies.Delimiter := ';';
1954 curCookies.DelimitedText := ABoard.Cookie;
1955 curCookies.Sort;
1956 curCookies.Duplicates := dupIgnore;
1957 ABoard.Cookie := '';
1958 try
1959 for i := 0 to CookieMng.CookieCollection.Count - 1 do begin
1960 Cookie := CookieMng.CookieCollection.Items[i];
1961 if ( Cookie.CookieName = VAL_PON ) then begin
1962 ABoard.PON := Cookie.Value;
1963 ABoard.Expires := GMTToLocalDateTime(Cookie.Expires);
1964 end else if ( Cookie.CookieName = VAL_SPID ) then begin
1965 ABoard.SPID := Cookie.Value;
1966 ABoard.Expires := GMTToLocalDateTime(Cookie.Expires);
1967 end else if ( Cookie.CookieName = VAL_HAP ) then begin
1968 // HAP???ょ????ookie????絽??????????с?????号?????????с????????
1969 if CompareDateTime(GMTToLocalDateTime(Cookie.Expires) ,Now) > 0 then begin
1970 GikoSys.SetBoukenCookie(Cookie.Value, Cookie.Domain);
1971 // ???冴???吾???絖?
1972 GikoSys.Setting.WriteBoukenSettingFile;
1973 end;
1974 end else begin
1975 if Length( curCookies.Values[ Cookie.CookieName ] ) > 0 then begin
1976 // ?√??ゃ??????帥??
1977 curCookies[curCookies.IndexOfName(Cookie.CookieName)] :=
1978 Cookie.ClientCookie;
1979 end else begin
1980 // 菴遵??
1981 curCookies.Add(Cookie.ClientCookie);
1982 end;
1983 end;
1984 end;
1985 for i := 0 to curCookies.Count - 1 do begin
1986 if (curCookies[i] <> '') then begin
1987 ABoard.Cookie := ABoard.Cookie + curCookies[i] + '; ';
1988 end;
1989 end;
1990 finally
1991 CookieMng.CookieCollection.Clear;
1992 curCookies.Free;
1993 end;
1994 end;
1995 //! hidden???若?水??
1996 procedure TEditorForm.GetHiddenParameter(Rawtext: String; ABoard: TBoard);
1997 const
1998 INPUT_MARK = '<input type=hidden' ; // 紊ф??絖?絨??絖??違???違??????????絵??span>
1999 VALUE_MARK = 'value=' ; // 紊ф??絖?絨??絖??違???違??????????絵??span>
2000 NAME_MARK = 'name=' ; // 紊ф??絖?絨??絖??違???違??????????絵??span>
2001 IGNORE_NAMES : array[0..6] of String =
2002 ('subject', 'from', 'mail', 'message', 'bbs', 'time', 'key');
2003 var
2004 tmp, line, name, value, lname : String;
2005 pos, pose, i : Integer;
2006 begin
2007 tmp := AnsiLowerCase(Rawtext);
2008 pos := AnsiPos(INPUT_MARK, tmp);
2009 while (pos > 0 ) do begin
2010 tmp := Copy(Rawtext, pos + Length(INPUT_MARK), Length(tmp));
2011 Delete(Rawtext, 1, pos+ Length(INPUT_MARK) - 1);
2012 pose := AnsiPos('>', tmp);
2013 // name=xxx value=yyy ???????冴??????
2014 line := Copy(tmp, 1, pose - 1);
2015 name := '';
2016 value := '';
2017 pos := AnsiPos(NAME_MARK, tmp);
2018 if (pos > 0) then begin
2019 name := Copy(Rawtext, pos + Length(NAME_MARK), Length(line));
2020 //??茹?"?у??障?c????????
2021 if AnsiPos('"', name) = 1 then begin
2022 // ??茹?"?障?с???潟????/span>
2023 Delete(name, 1, 1);
2024 pose := AnsiPos('"', name);
2025 if (pose > 0) then begin
2026 Delete(name, pose, Length(name));
2027 end else begin
2028 pose := AnsiPos(' ', name);
2029 if (pose > 0) then begin
2030 Delete(name, pose, Length(name));
2031 end;
2032 end;
2033 end else begin
2034 pose := AnsiPos(' ', name);
2035 if (pose > 0) then begin
2036 Delete(name, pose, Length(name));
2037 end;
2038 end;
2039 end;
2040 lname := AnsiLowerCase(name);
2041 for i := 0 to Length(IGNORE_NAMES) do begin
2042 if lname = IGNORE_NAMES[i] then begin
2043 name := '';
2044 break;
2045 end;
2046 end;
2047 pos := AnsiPos(VALUE_MARK, tmp);
2048 if (name <> '') and (pos > 0) then begin
2049 value := Copy(Rawtext, pos + Length(VALUE_MARK), Length(line));
2050 //??茹?"?у??障?c????????
2051 if AnsiPos('"', value) = 1 then begin
2052 // ??茹?"?障?с???潟????/span>
2053 Delete(value, 1, 1);
2054 pose := AnsiPos('"', value);
2055 if (pose > 0) then begin
2056 Delete(value, pose, Length(value));
2057 end else begin
2058 pose := AnsiPos(' ', value);
2059 if (pose > 0) then begin
2060 Delete(value, pose, Length(value));
2061 end;
2062 end;
2063 end else begin
2064 pose := AnsiPos(' ', value);
2065 if (pose > 0) then begin
2066 Delete(value, pose, Length(name));
2067 end;
2068 end;
2069 end;
2070 if (name <> '') then begin
2071 ABoard.Cookie := ABoard.Cookie + name + '=' + value + '; ';
2072
2073 end;
2074 Delete(tmp, 1, Length(line));
2075 Delete(Rawtext, 1, Length(line));
2076 pos := AnsiPos(INPUT_MARK, tmp);
2077 end;
2078 end;
2079
2080 //! ?泣?潟???贋?違???≪???激?с?潟??pdate?ゃ???潟????膂≦?????????帥?ゃ???若????????????????span>
2081 procedure TEditorForm.UpdateSambaActionUpdate(Sender: TObject);
2082 begin
2083 UpdateSambaAction.Enabled := FSambaTimer.Enabled;
2084 end;
2085
2086 //! ?泣?潟???贋?違?≪???激?с??/span>
2087 procedure TEditorForm.UpdateSambaActionExecute(Sender: TObject);
2088 var
2089 input : String;
2090 i : Integer;
2091 begin
2092 if InputQuery('Samba24荐???ゆ?贋??#39;, '?違????荐???ゃ???ュ?????????????', input) then begin
2093 input := ZenToHan(input);
2094 if GikoSys.IsNumeric(input) then begin
2095 FSambaTimer.UpdateSambaSetting(StrToInt(input));
2096 UpdateSambaStatus;
2097 //???????????若????????Samba?帥?ゃ???若???贋?違????
2098 for i := 0 to Screen.FormCount - 1 do begin
2099 if Screen.Forms[i] is TEditorForm then begin
2100 TEditorForm(Screen.Forms[i]).FSambaTimer.Update;
2101 TEditorForm(Screen.Forms[i]).UpdateSambaStatus;
2102 end;
2103 end;
2104 end else begin
2105 ShowMessage('?医?ゃ???ュ?????????????');
2106 UpdateSambaActionExecute(Sender);
2107 end;
2108 end;
2109 end;
2110
2111 procedure TEditorForm.UpdateSambaStatus;
2112 begin
2113 if (FSambaTimer.Enabled) then begin
2114 StatusBar.Panels[2].Text
2115 := 'Samba24荀鎘???#39; + IntToStr(FSambaTimer.SambaInterval);
2116 end;
2117 end;
2118
2119 procedure TEditorForm.InputAssistActionExecute(Sender: TObject);
2120 var
2121 count, i : Integer;
2122 item : TMenuItem;
2123 point: TPoint;
2124 Bitmap : TBitmap;
2125 TextWidth, ItemWidth, tmpWidth: Integer;
2126 begin
2127 if FInputAssistKey = '' then Exit;
2128
2129 InputAssistPopupMenu.Items.Clear;
2130
2131 if (FResistWords = nil) then begin
2132 FResistWords := TStringList.Create;
2133 end else begin
2134 FResistWords.Clear;
2135 end;
2136
2137 if (GetKeyState( VK_SHIFT ) < 0) then begin
2138 // ?激???????若???????????違?????若?у??障???????眼??/span>
2139 count :=
2140 InputAssistDM.GetStartWithCategoryResistWords(
2141 FInputAssistKey, FResistWords);
2142 end else begin
2143 // ?激???????<?????с?????若?у??障??????/span>
2144 count :=
2145 InputAssistDM.GetStartWithKeyResistWords(
2146 FInputAssistKey, FResistWords);
2147 end;
2148 Bitmap := TBitmap.Create;
2149 try
2150 Bitmap.Canvas.Font.Assign(BodyEdit.Font);
2151 // ???若?吾??px
2152 TextWidth := Bitmap.Canvas.TextWidth(FInputAssistKey) + 5;
2153 ItemWidth := 0;
2154 for i := 0 to count - 1 do begin
2155 item := TMenuItem.Create(nil);
2156 item.Break := mbNone;
2157 item.Caption := FResistWords[i];
2158 item.Tag := i;
2159 item.OnClick := InputAssistMenuClick;
2160 InputAssistPopupMenu.Items.Add(item);
2161
2162 tmpWidth := Bitmap.Canvas.TextWidth(Item.Caption);
2163 if (tmpWidth > ItemWidth) then begin
2164 ItemWidth := tmpWidth;
2165 end;
2166 end;
2167 finally
2168 Bitmap.Free;
2169 end;
2170
2171 if (count > 0) then begin
2172 GetCaretpos(point);
2173 point.X := point.X + Self.Left + (Self.Width - BodyEdit.Width) div 2;
2174 point.Y := point.Y + Self.Top + (Self.Height - Self.ClientHeight);
2175
2176 if Screen.DesktopWidth >
2177 (point.X + TextWidth + ItemWidth) then begin
2178 InputAssistPopupMenu.Popup(
2179 point.X + TextWidth,
2180 point.Y + EditorPage.Top + EditorPage.TabHeight + BodyEdit.Top);
2181 end else begin
2182 InputAssistPopupMenu.Popup(
2183 point.X - TextWidth - ItemWidth,
2184 point.Y + EditorPage.Top + EditorPage.TabHeight + BodyEdit.Top);
2185 end;
2186 end;
2187 end;
2188
2189 procedure TEditorForm.InputAssistMenuClick(Sender: TObject);
2190 var
2191 text : String;
2192 IMC: HIMC;
2193 begin
2194 if not (Sender is TMenuItem) then Exit;
2195
2196 if (FResistWords <> nil) then begin
2197 try
2198 text :=
2199 TResistWord(FResistWords.Objects[TMenuItem(Sender).Tag]).GetText;
2200 except
2201 text := '';
2202 end;
2203 IMC := ImmGetContext(BodyEdit.Handle); //?潟?潟?????鴻????緇?
2204 try
2205 ImmNotifyIME(IMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
2206 finally
2207 ImmReleaseContext(BodyEdit.Handle, IMC); //?潟?潟?????鴻??茹f??/span>
2208 end;
2209
2210 FResistWords.Clear;
2211 FInputAssistKey := '';
2212 end;
2213 InsertText(BodyEdit, text);
2214 end;
2215
2216 //! TMemo?????若?純???臀?????絖????水??/span>
2217 procedure TEditorForm.InsertText(Memo: TMemo; Text: String);
2218 var
2219 line, sel, pos: Integer;
2220 left, right : String;
2221 begin
2222 Memo.Lines.BeginUpdate;
2223 line := SendMessage(Memo.Handle,EM_LINEFROMCHAR,-1,0); //茵?
2224 sel := Memo.SelStart;
2225 pos := sel - SendMessage(Memo.Handle, EM_LINEINDEX, -1, 0); //罅?
2226 if (pos > 0) then begin
2227 left := Copy(Memo.Lines[line], 0, pos);
2228 end else begin
2229 left := '';
2230 end;
2231 right := Copy(Memo.Lines[line], pos + 1, Length(Memo.Lines[line]));
2232 Memo.Lines.Strings[line] := left + Text + right;
2233 Memo.Lines.EndUpdate;
2234 //?????c?????????臀????贋?違????
2235 Memo.SelStart := sel + Length(text);
2236 // ???c?????????臀??障?с?鴻?????若??/span>
2237 Memo.Perform(EM_SCROLLCARET, 0, 0);
2238
2239 end;
2240
2241 procedure TEditorForm.ApplicationEvents1Message(var Msg: tagMSG;
2242 var Handled: Boolean);
2243 var
2244 wmMsg: TWMKey;
2245 IMC: HIMC;
2246 Len: integer;
2247 Str: string;
2248 begin
2249 if (Self.Active) then begin
2250 case Msg.message of
2251 //???惹?寂????水???????
2252 WM_KEYDOWN:
2253 begin
2254 // ?帥??????膩???????trl???若???若??????????????腆肴?????
2255 if (EditorPage.ActivePageIndex = 0)
2256 and (GetKeyState( VK_CONTROL ) < 0) then begin
2257 wmMsg.Msg := Msg.message;
2258 wmMsg.CharCode := Word(Msg.wParam);
2259 wmMsg.KeyData := Msg.lParam;
2260 if (wmMsg.CharCode = 229) and (wmMsg.KeyData = 3735553) then begin
2261 IMC := ImmGetContext(BodyEdit.Handle); //?潟?潟?????鴻????緇?
2262 Len := ImmGetCompositionString(IMC, GCS_COMPSTR, nil, 0); //?障???激??????緇?
2263 if (Len > 0) then begin
2264 SetLength(Str, Len + 1); //Buffer???<?≪????荐??
2265 ImmGetCompositionString(IMC, GCS_COMPSTR, PChar(Str), Len + 1); //?障???激??????緇?
2266 SetLength(Str, Len);
2267 FInputAssistKey := Str;
2268 InputAssistActionExecute(nil);
2269 Handled := True;
2270 end;
2271 ImmReleaseContext(BodyEdit.Handle, IMC); //?潟?潟?????鴻??茹f??/span>
2272 end;
2273 end;
2274 end;
2275 end;
2276
2277 end;
2278 end;
2279
2280 procedure TEditorForm.ShowInputAssistFormExecute(Sender: TObject);
2281 var
2282 form : TInputAssistForm;
2283 begin
2284 form := TInputAssistForm.Create(nil);
2285 try
2286 if TopAction.Checked then begin // ?鴻???ょ?倶????┃絎?
2287 SetWindowPos(form.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2288 end;
2289 form.SetUpFromEditor;
2290 if (form.ShowModal = mrOk) then begin
2291 InsertText(BodyEdit, form.GetInsertText);
2292 end;
2293 finally
2294 form.Release;
2295 end;
2296 end;
2297 //! Cookie???怨????/span>
2298 procedure TEditorForm.ReleaseCookieActionExecute(Sender: TObject);
2299 var
2300 Board : TBoard;
2301 begin
2302 // ?鴻?????????<?????鴻?????????????Board???贋・篏帥??
2303 Board := GetBoard;
2304
2305 // ???????若?????宴????????
2306 Board.Cookie := '';
2307 Board.SPID := '';
2308 Board.PON := '';
2309 // 0??兄???祉??
2310 Board.Expires := 0;
2311 end;
2312 //! ?炊???怨??Update?ゃ???潟??
2313 procedure TEditorForm.GetSETTINGTXTActionUpdate(Sender: TObject);
2314 begin
2315 // 絎?茵?筝????茵?筝???/span>
2316 GetSETTINGTXTAction.Enabled := not FWork;
2317 end;
2318 //! ???若???????若????Update?ゃ???潟??
2319 procedure TEditorForm.GetHeadTXTActionUpdate(Sender: TObject);
2320 begin
2321 // 絎?茵?筝????茵?筝???/span>
2322 GetSETTINGTXTAction.Enabled := not FWork;
2323 end;
2324
2325 //! Samba?帥?ゃ???若?ゃ???潟??
2326 procedure TEditorForm.SambaTimer(Sender: TObject);
2327 begin
2328
2329 if FSambaTimer.WriteDeta = ZERO_DATE then
2330 StatusBar.Panels[1].Text := '????#39;
2331 else begin
2332 FNow := IncMilliSecond(FNow, 500);
2333 StatusBar.Panels[1].Text :=
2334 Format('%8.0f腱?腟???#39;, [SecondSpan(FNow, FSambaTimer.WriteDeta)]);
2335 end;
2336 end;
2337 {
2338 \brief ???c?潟???????臀????泣?ゃ?冴??┃絎?
2339 }
2340 procedure TEditorForm.SetWindowRect;
2341 var
2342 wp: TWindowPlacement;
2343 begin
2344 //???c?潟???????臀?┃絎?
2345 wp.length := sizeof(wp);
2346 wp.rcNormalPosition.Top := GikoSys.Setting.EditWindowTop;
2347 wp.rcNormalPosition.Left := GikoSys.Setting.EditWindowLeft;
2348
2349 wp.rcNormalPosition.Bottom := GikoSys.Setting.EditWindowTop + GikoSys.Setting.EditWindowHeight;
2350 wp.rcNormalPosition.Right := GikoSys.Setting.EditWindowLeft + GikoSys.Setting.EditWindowWidth;
2351 wp.showCmd := SW_HIDE;
2352 SetWindowPlacement(Handle, @wp);
2353
2354 if GikoSys.Setting.EditWindowMax then begin
2355 WindowState := wsMaximized;
2356 end;
2357
2358 //???c?潟???????脂?√??????脂?√????Щ??????
2359 if (Left + Width) > Screen.Width then begin
2360 Left := 0;
2361 end;
2362 if (Top + Height) > Screen.Height then begin
2363 Top := 0;
2364 end;
2365 if Left < 0 then begin
2366 Left := 0;
2367 end;
2368 if Top < 0 then begin
2369 Top := 0;
2370 end;
2371
2372 //?上???????c?潟???????臀???篆?絖?
2373 GikoSys.Setting.EditWindowTop := Top + WINDOWMOVE_V; // 罨<????????c?潟??????/span>
2374 GikoSys.Setting.EditWindowLeft := Left + WINDOWMOVE_H; // ???????恰????筝?????????
2375 //???c?潟??????????????絨???????????医?????祉??
2376 if GikoSys.Setting.EditWindowHeight < 144 then begin
2377 Height := 400;
2378 end;
2379 if GikoSys.Setting.EditWindowWidth < 144 then begin
2380 Width := 640;
2381 end;
2382 end;
2383 {
2384 \brief ?≦宍?帥??荐??
2385 }
2386 procedure TEditorForm.SetExtraTab;
2387 const
2388 SECTION = 'EditorForm';
2389 var
2390 ini: TMemIniFile;
2391 begin
2392 ini := TMemIniFile.Create(GikoSys.Setting.GetFileName);
2393 try
2394 BoardtopTab.TabVisible := ini.Readbool(SECTION, 'BoardTopTab', False);
2395 BoardTop.Checked := BoardtopTab.TabVisible;
2396 RocalRuleTab.TabVisible := ini.ReadBool(SECTION, 'LocalRuleTab', False);
2397 LocalRule.Checked := RocalRuleTab.TabVisible;
2398 finally
2399 ini.Free;
2400 end;
2401 end;
2402 {
2403 \brief ?水??
2404 \return ???鴻?????c?帥????腮帥??????????????????/span>
2405 }
2406 function TEditorForm.GetBoard : TBoard;
2407 begin
2408 // ?鴻???????≪?ゃ??????null??????Board
2409 if FThreadItem = nil then begin
2410 Result := FBoard;
2411 end else begin
2412 Result := FThreadItem.ParentBoard;
2413 end;
2414 end;
2415 {
2416 \brief GikoForm???<???祉?若?吾??菴遵??????
2417 \param icon ?<???祉?若?吾???ゃ??≪?ゃ?潟??/span>
2418 }
2419 procedure TEditorForm.AddFormMessageNew(icon: TGikoMessageIcon);
2420 begin
2421 if FThreadItem = nil then begin
2422 GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmNewSure), nil, icon)
2423 end else begin
2424 GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmNewRes), nil, icon);
2425 end;
2426
2427 end;
2428 {
2429 \brief ???若????usiana????????
2430 \return true:??篆>賢罩 false:??篆?/span>
2431 }
2432 function TEditorForm.isLocalFusianaTrap: Boolean;
2433 var
2434 Namae : string;
2435 begin
2436 Result := False;
2437 if GikoSys.Setting.LocalTrapAtt then begin
2438 Namae := THTMLCreate.RepHtml(NameComboBox.Text);
2439 if (LFusianaGet(Namae)) or (Namae = '絮怨?羝?') then begin
2440 if FusianaMsgBox = IDNO then begin
2441 Result := True;
2442 end;
2443 end;
2444 end;
2445 end;
2446 {
2447 \brief ???≪?若??fusiana????????
2448 \return true:??篆>賢罩 false:??篆?/span>
2449 }
2450 function TEditorForm.isRemoteFusianaTrap: Boolean;
2451 var
2452 Namae : string;
2453 Board : TBoard;
2454 Remote: string;
2455 body : TStringList;
2456 begin
2457 Result := False;
2458 Namae := THTMLCreate.RepHtml(NameComboBox.Text);
2459 if (GikoSys.Setting.RemoteTrapAtt) and (Length(Namae) = 0) then begin
2460 Board := GetBoard;
2461
2462 if Board = nil then Exit;
2463
2464 if not FileExists(Board.GetSETTINGTXTFileName) then begin
2465 //Setting.txt???????c??????緇?
2466 //薇?????激????????????...
2467 try
2468 GetSETTINGTXTAction.Execute;
2469 except
2470 end;
2471 end;
2472
2473 Remote := '';
2474 if FileExists(Board.GetSETTINGTXTFileName) then begin
2475 body := TStringList.Create;
2476 try
2477 body.LoadFromFile(Board.GetSETTINGTXTFileName);
2478 Remote := GetFusianaName(body, Board);
2479 finally
2480 body.Free;
2481 end;
2482 end;
2483
2484 if LFusianaGet(Remote) then begin
2485 if FusianaMsgBox = IDNO then begin
2486 Result := True;
2487 end;
2488 end;
2489 end;
2490 end;
2491 {
2492 \brief Header??絖?????緇?
2493 \param ACOOKIE Cookie
2494 \param SPID SPID
2495 \param PON PON
2496 \param HAP HAP
2497 \param Board ??/span>
2498 \return Header??絖???
2499 }
2500 function TEditorForm.getHeaderStr(const ACOOKIE: string; const SPID : string;
2501 const PON : string; const HAP : string; Board : TBoard) : string;
2502 begin
2503 Result := ACOOKIE;
2504
2505 if SPID <> '' then
2506 Result := Result + 'SPID=' + SPID + '; ';
2507 if PON <> '' then
2508 Result := Result + 'PON=' + PON + '; ';
2509
2510 //???鴻????2ch?с??Be??ogin??????????E?????若?帥??????
2511 //GikoSys.ParseURI( URL, Protocol,Host, Path, Document, Port, Bookmark );
2512 //if GikoSys.Is2chHost(Host) and GikoSys.Setting.BeLogin then
2513 if (Board.Is2ch) then begin
2514 // ?阪??????????若???????育??????
2515 if Length(GikoSys.Setting.FixedCookie) > 0 then begin
2516 // ???鴻????2ch???翫??鐚??阪??????????若??蕋??????
2517 Result := Result + GikoSys.Setting.FixedCookie + '; ';
2518 end;
2519 if (GikoSys.Belib.Connected) then begin
2520 Result := Result + 'MDMD=' + GikoSys.Belib.MDMD + '; '
2521 + 'DMDM=' + GikoSys.Belib.DMDM + '; ';
2522 end;
2523 end;
2524
2525 Result := 'Cookie: ' + Result + 'NAME=' + NameComboBox.Text + '; MAIL=' + MailComboBox.Text;
2526
2527 if HAP <> '' then
2528 Result := Result + '; HAP=' + HAP + '; ';
2529
2530 end;
2531
2532 {
2533 \brief fusiana茘??????ゃ?≪????/span>
2534 \return IDYES ?吾??莨若?? IDNO 筝??
2535 }
2536 function TEditorForm.FusianaMsgBox: Integer;
2537 const
2538 MSG_FUSIANA : string = '???≪?若?????鴻????茵?ず????罘??純??篏帥????????障??'#13#10 +
2539 '???????????c???????号??с???鴻????茵?ず??????????????????訓莢?算?????у???や??若????????障??????' +
2540 #13#10#13#10'莢?算??莢??????????粋??????吾??莨若?帥?障????鐚?';
2541 begin
2542 Result := MsgBox(Handle, MSG_FUSIANA, '????#39;,
2543 MB_YESNO or MB_ICONQUESTION);
2544 end;
2545 {
2546 \brief ?f???≪?若??ON/OFF?????帥??
2547 }
2548 procedure TEditorForm.ContinueModeActionExecute(Sender: TObject);
2549 begin
2550 ContinueModeAction.Checked := not ContinueModeAction.Checked;
2551 end;
2552 {
2553 \brief ?f???≪?若???贋?医????
2554 }
2555 procedure TEditorForm.ContinueModeActionUpdate(Sender: TObject);
2556 begin
2557 // ?鴻???????????????≦??/span>
2558 ContinueModeAction.Enabled := FThreadItem <> nil;
2559 end;
2560 {
2561 \brief ?吾??莨若?????鴻????????茵?ず????
2562 }
2563 procedure TEditorForm.OpenSendTargetActionExecute(Sender: TObject);
2564 begin
2565 if (FThreadItem <> nil) then begin
2566 // ?<?ゃ?潟???贋?違???????障?????х?脂?≪?????帥???水?????帥????????蚊????????/span>
2567 // ???≪?у?阪?????
2568 if not (fsShowing in Self.FormState) then begin
2569 // ?鴻???ょ?倶????┃絎?
2570 SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2571 end;
2572 try
2573 // ?鴻??????
2574 GikoForm.InsertBrowserTab(FThreadItem, True);
2575 finally
2576 if not TopAction.Checked then begin // ?鴻???ょ?倶??茹i??/span>
2577 SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2578 end;
2579 end;
2580 Self.SetFocus;
2581 end else begin
2582 // ??/span>
2583 GikoForm.SelectTreeNode(
2584 GetBoard, True );
2585 end;
2586 end;
2587 procedure TEditorForm.ReloadTargetActionExecute(Sender: TObject);
2588 begin
2589 if (FThreadItem <> nil) then begin
2590 // ?鴻??????
2591 // ?<?ゃ?潟???贋?違???????障?????х?脂?≪?????帥???水?????帥????????蚊????????/span>
2592 // ???≪?у?阪?????(?????潟???若?????榊?????????????帥??c?????障??????????????)
2593 if not (fsShowing in Self.FormState) then begin
2594 // ?鴻???ょ?倶????┃絎?
2595 SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2596 end;
2597 try
2598 GikoForm.DownloadContent(FThreadItem);
2599 finally
2600 if not TopAction.Checked then begin // ?鴻???ょ?倶??茹i??/span>
2601 SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2602 end;
2603 end;
2604 Self.SetFocus;
2605 end else begin
2606 // ??/span>
2607 GikoForm.DownloadList(GetBoard);
2608 end;
2609 end;
2610 //! 茯ょ?????с????/span>
2611 function TEditorForm.isGobaku: Boolean;
2612 const
2613 MSG_GOBAKU : string =
2614 '茵?ず????????%s????腮水????s???違?????障????'#13#10 +
2615 '?????障?丈?吾??莨若?帥?障????鐚?';
2616 var
2617 ThreadItem : TThreadItem;
2618 msg : String;
2619
2620 begin
2621 Result := False;
2622 // ?????激?с?恰???鴻???ゃ???拷??篆<?с???炊????/span>
2623 if (GikoSys.Setting.UseGobakuCheck) then begin
2624 // ???拷??篆?/span>
2625 if (FThreadItem <> nil) then begin
2626 ThreadItem := GikoForm.GetActiveContent(False);
2627 if (ThreadItem <> nil) then begin
2628 if (FThreadItem <> ThreadItem) then begin
2629 msg := Format(MSG_GOBAKU, ['?鴻??????', '?鴻??????']);
2630 Result := MsgBox(Handle, msg, '????#39;, MB_YESNO or MB_ICONQUESTION) = IDNO;
2631 end;
2632 end else begin
2633 if GikoForm.ActiveList is TBBS then begin
2634 if TBBS(GikoForm.ActiveList) <> FThreadItem.ParentBoard.ParentCategory.ParenTBBS then begin
2635 msg := Format(MSG_GOBAKU, ['BBS', '?鴻??????????絮?????BBS']);
2636 Result := MsgBox(Handle, msg, '????#39;, MB_YESNO or MB_ICONQUESTION) = IDNO;
2637 end;
2638 end else if GikoForm.ActiveList is TCategory then begin
2639 if TCategory(GikoForm.ActiveList).FindThreadFromURL(FThreadItem.URL) = nil then begin
2640 msg := Format(MSG_GOBAKU, ['?????眼??#39;, '?鴻??????????絮??????????眼??#39;]);
2641 Result := MsgBox(Handle, msg, '????#39;, MB_YESNO or MB_ICONQUESTION) = IDNO;
2642 end;
2643 end else if GikoForm.ActiveList is TBoard then begin
2644 if TBoard(GikoForm.ActiveList) <> FThreadItem.ParentBoard then begin
2645 msg := Format(MSG_GOBAKU, ['??#39;, '?鴻??????????絮???????#39;]);
2646 Result := MsgBox(Handle, msg, '????#39;, MB_YESNO or MB_ICONQUESTION) = IDNO;
2647 end;
2648 end;
2649 end;
2650 end else begin
2651 // ?鴻??????/span>
2652 if GikoForm.ActiveList is TBBS then begin
2653 if TBBS(GikoForm.ActiveList) <> FBoard.ParentCategory.ParenTBBS then begin
2654 msg := Format(MSG_GOBAKU, ['BBS', '?帥????絮?????BBS']);
2655 Result := MsgBox(Handle, msg, '????#39;, MB_YESNO or MB_ICONQUESTION) = IDNO;
2656 end;
2657 end else if GikoForm.ActiveList is TCategory then begin
2658 if TCategory(GikoForm.ActiveList).FindBoardFromURL(FBoard.URL) = nil then begin
2659 msg := Format(MSG_GOBAKU, ['?????眼??#39;, '?帥????絮??????????眼??#39;]);
2660 Result := MsgBox(Handle, msg, '????#39;, MB_YESNO or MB_ICONQUESTION) = IDNO;
2661 end;
2662 end else if GikoForm.ActiveList is TBoard then begin
2663 if TBoard(GikoForm.ActiveList) <> FBoard then begin
2664 msg := Format(MSG_GOBAKU, ['??#39;, '??#39;]);
2665 Result := MsgBox(Handle, msg, '????#39;, MB_YESNO or MB_ICONQUESTION) = IDNO;
2666 end;
2667 end;
2668 end;
2669 end;
2670 end;
2671
2672 end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26