Develop and Download Open Source Software

Browse CVS Repository

Contents of /gikonavigoeson/gikonavi/GikoSystem.pas

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


Revision 1.166 - (show annotations) (download) (as text)
Wed Oct 27 00:30:20 2004 UTC (19 years, 5 months ago) by yoffy
Branch: MAIN
Changes since 1.165: +3 -0 lines
File MIME type: text/x-pascal
skin 用に <NONSPAMMINESS/> を追加。

1 unit GikoSystem;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
7 ComCtrls, IniFiles, ShellAPI, ActnList, Math,
8 {$IF Defined(DELPRO) }
9 SHDocVw,
10 MSHTML,
11 {$ELSE}
12 SHDocVw_TLB,
13 MSHTML_TLB,
14 {$IFEND}
15 {HttpApp,} YofUtils, URLMon, IdGlobal, IdURI, {Masks,}
16 Setting, BoardGroup, gzip, Dolib, bmRegExp, AbonUnit,
17 MojuUtils, ExternalBoardManager, ExternalBoardPlugInMain,
18 Sort, GikoBayesian;
19
20 type
21 //BBS?帥?ゃ??
22 TGikoBBSType = (gbt2ch);
23 //???違?帥?ゃ??
24 TGikoLogType = (glt2chNew, glt2chOld);
25 //?<???祉?若?吾?≪?ゃ?潟??/span>
26 TGikoMessageIcon = (gmiOK, gmiSAD, gmiNG, gmiWhat, gmiNone);
27 //URL???若???潟???????吟?帥?ゃ??
28 TGikoBrowserType = (gbtIE, gbtUserApp, gbtAuto);
29
30
31 TStrTokSeparator = set of Char;
32 TStrTokRec = record
33 Str: string;
34 Pos: Integer;
35 end;
36
37 //?ゃ?潟???????鴻???<?ゃ?????潟?若??
38 TIndexRec = record
39 FNo: Integer;
40 FFileName: string;
41 FTitle: string;
42 FCount: Integer;
43 FSize: Integer;
44 // FRoundNo: Integer;
45 FRoundDate: TDateTime;
46 FLastModified: TDateTime;
47 FKokomade: Integer;
48 FNewReceive: Integer;
49 FMishiyou: Boolean; //??戎??/span>
50 FUnRead: Boolean;
51 FScrollTop: Integer;
52 //Index Ver 1.01
53 FAllResCount: Integer;
54 FNewResCount: Integer;
55 FAgeSage: TGikoAgeSage;
56 end;
57
58 //?泣???吾?с???????潟?若??
59 TSubjectRec = record
60 FFileName: string;
61 FTitle: string;
62 FCount: Integer;
63 end;
64
65 //???鴻???潟?若??
66 TResRec = record
67 FTitle: string;
68 FMailTo: string;
69 FName: string;
70 FDateTime: string;
71 FBody: string;
72 FType: TGikoLogType;
73 end;
74
75 //URLPath???潟?若??
76 TPathRec = record
77 FBBS: string; //BBSID
78 FKey: string; //ThreadID
79 FSt: Int64; //??紮????合??/span>
80 FTo: Int64; //腟?篋????合??/span>
81 FFirst: Boolean; //>>1??;腓?/span>
82 FStBegin: Boolean; //1??茵?ず
83 FToEnd: Boolean; //????緇??障?ц;腓?/span>
84 FDone: Boolean; //????
85 FNoParam: Boolean; //???合???????<?若?帥????
86 end;
87
88 TGikoSys = class(TObject)
89 private
90 { Private 絎h? }
91 FSetting: TSetting;
92 FDolib: TDolib;
93 FAWKStr: TAWKStr;
94 FResRange : Longint;
95 FBayesian : TGikoBayesian; //!< ???ゃ?吾?≪?潟???c????/span>
96
97 // FExitWrite: TStringList;
98 // function StrToFloatDef(s: string; Default: Double): Double;
99 public
100 { Public 絎h? }
101 FAbon : TAbon;
102 FSelectResFilter : TAbon;
103 constructor Create;
104
105 destructor Destroy; override;
106 property ResRange : Longint read FResRange write FResRange;
107 // function MsgBox(Msg: string; Title: string; Flags: Longint): integer; overload;
108 // function MsgBox(Handle: THandle; Msg: string; Title: string; Flags: Longint): integer; overload;
109 function IsNumeric(s: string): boolean;
110 function IsFloat(s: string): boolean;
111 function DirectoryExistsEx(const Name: string): Boolean;
112 function ForceDirectoriesEx(Dir: string): Boolean;
113 // function GetVersion: string;
114
115 function GetBoardFileName: string;
116 function GetCustomBoardFileName: string;
117 function GetHtmlTempFileName: string;
118 function GetAppDir: string;
119 function GetTempFolder: string;
120 function GetSentFileName: string;
121 function GetConfigDir: string;
122 function GetSkinDir: string;
123 function GetSkinHeaderFileName: string;
124 function GetSkinFooterFileName: string;
125 function GetSkinResFileName: string;
126 function GetSkinNewResFileName: string;
127 function GetSkinBookmarkFileName: string;
128 function GetSkinNewmarkFileName: string;
129 function GetStyleSheetDir: string;
130 function GetOutBoxFileName: string;
131 function GetUserAgent: string;
132 function GetSambaFileName : string;
133
134 procedure ReadSubjectFile(Board: TBoard);
135 procedure CreateThreadDat(Board: TBoard);
136 procedure WriteThreadDat(Board: TBoard);
137 function ParseIndexLine(Line: string): TIndexRec;
138 procedure GetFileList(Path: string; Mask: string; var List: TStringList; SubDir: Boolean; IsPathAdd: Boolean); overload;
139 procedure GetFileList(Path: string; Mask: string; var List: TStringList; IsPathAdd: Boolean); overload;//?泣?????????????膣≪??????
140 procedure GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
141
142 procedure CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
143 procedure CreateHTML3(var html: TStringList; ThreadItem: TThreadItem; var sTitle: string);
144 function AddAnchorTag(s: string): string;
145
146 function DivideSubject(Line: string): TSubjectRec;
147 function DivideStrLine(Line: string): TResRec;
148
149 property Setting: TSetting read FSetting write FSetting;
150 property Dolib: TDolib read FDolib write FDolib;
151
152 function UrlToID(url: string): string;
153 function UrlToServer(url: string): string;
154
155 function StrTokFirst(const s:string; const sep:TStrTokSeparator; var Rec:TStrTokRec):string;
156 function StrTokNext(const sep:TStrTokSeparator; var Rec:TStrTokRec): string;
157
158 function GetFileSize(FileName : string) : longint;
159 function GetFileLineCount(FileName : string): longint;
160 function Get2chDate(aDate: TDateTime): string;
161 function IntToDateTime(val: Int64): TDateTime;
162 function DateTimeToInt(ADate: TDateTime): Int64;
163
164 function ReadThreadFile(FileName: string; Line: Integer): string;
165
166 procedure MenuFont(Font: TFont);
167
168 function RemoveToken(var s:string; const delimiter:string):string;
169 function GetTokenIndex(s: string; delimiter: string; index: Integer): string;
170 function DeleteLink(const s: string): string;
171
172 function GetShortName(const LongName: string; ALength: integer): string;
173 function ConvRes(const Body, Bbs, Key, ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string; DatToHTML: boolean = false): string; overload;
174 function ConvRes(const Body, Bbs, Key, ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue, FullURL : string): string; overload;
175 function ConvertResAnchor(res: string): string;
176 function BoolToInt(b: Boolean): Integer;
177 function IntToBool(i: Integer): Boolean;
178 function GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
179 procedure LoadKeySetting(ActionList: TActionList);
180 procedure SaveKeySetting(ActionList: TActionList);
181 procedure LoadEditorKeySetting(ActionList: TActionList);
182 procedure SaveEditorKeySetting(ActionList: TActionList);
183
184 procedure CreateProcess(const AppPath: string; const Param: string);
185 procedure OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
186 function HTMLDecode(const AStr: String): String;
187 function GetHRefText(s: string): string;
188 function Is2chHost(Host: string): Boolean;
189 function Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
190 function Parse2chURL2(URL: string): TPathRec;
191 procedure ParseURI(const URL : string; var Protocol, Host, Path, Document, Port, Bookmark: string);
192 function GetVersionBuild: Integer;
193 function GetBrowsableThreadURL( inURL : string ) : string;
194 function GetThreadURL2BoardURL( inURL : string ) : string;
195 function Get2chThreadURL2BoardURL( inURL : string ) : string;
196 function Get2chBrowsableThreadURL( inURL : string ) : string;
197 function Get2chBoard2ThreadURL( inBoard : TBoard; inKey : string ) : string;
198 procedure ListBoardFile;
199 procedure ReadBoardFile( bbs : TBBS );
200
201 function GetUnknownCategory : TCategory;
202 function GetUnknownBoard( inPlugIn : TBoardPlugIn; inURL : string ) : TBoard;
203
204 procedure GetPopupResNumber(URL : string; var stRes, endRes : Int64);
205
206 // ?鴻???潟??茯??粋昭?帥???ゃ??臀??????
207 function LoadFromSkin( fileName: string; ThreadItem: TThreadItem; SizeByte: Integer ): string;
208 // ???鴻???ゃ??臀??????
209 function SkinedRes( skin: string; Res: TResRec; No: string ): string;
210
211 //Samba24?????<?ゃ????絖???????????絖??????????翫????default???<?ゃ????rename????
212 procedure SambaFileExists();
213
214 property Bayesian : TGikoBayesian read FBayesian write FBayesian;
215 function GetSameIDResAnchor(const AID : string; ThreadItem: TThreadItem):string;
216 //! ??茯?茹f??
217 procedure SpamCountWord( const text : string; wordCount : TWordCount );
218 //! 絖????????/span>
219 procedure SpamForget( wordCount : TWordCount; isSpam : Boolean );
220 //! ?鴻????絖??
221 procedure SpamLearn( wordCount : TWordCount; isSpam : Boolean );
222 //! ?鴻????綺???/span>
223 function SpamParse( const text : string; wordCount : TWordCount ) : Extended;
224 end;
225
226 var
227 GikoSys: TGikoSys;
228 const
229 //LENGTH_RESTITLE = 40;
230 ZERO_DATE: Integer = 25569;
231 BETA_VERSION_NAME_E = 'beta';
232 BETA_VERSION_NAME_J = '鐓?鐓?鐓?';
233 BETA_VERSION = 50;
234 BETA_VERSION_BUILD = ''; //debug??????/span>
235 APP_NAME = 'gikoNavi';
236
237 implementation
238
239 uses
240 Giko, RoundData, Favorite;
241
242 const
243 FOLDER_INDEX_VERSION = '1.01';
244 USER_AGENT = 'Monazilla';
245 DEFAULT_NGWORD_FILE_NAME : String = 'NGword.txt';
246 NGWORDs_DIR_NAME : String = 'NGwords';
247
248 READ_PATH: string = '/test/read.cgi/';
249 OLD_READ_PATH: string = '/test/read.cgi?';
250 KAKO_PATH: string = '/kako/';
251
252 (*************************************************************************
253 *GikoSys?潟?潟?鴻????????/span>
254 *************************************************************************)
255 constructor TGikoSys.Create;
256 begin
257 FSetting := TSetting.Create;
258 FDolib := TDolib.Create;
259 FAWKStr := TAWKStr.Create(nil);
260 if DirectoryExists(GetConfigDir) = false then begin
261 CreateDir(GetConfigDir);
262 end;
263 FAbon := TAbon.Create;
264 FAbon.Setroot(GetConfigDir+NGWORDs_DIR_NAME);
265 FAbon.GoHome;
266 FAbon.ReturnNGwordLineNum := FSetting.ShowNGLinesNum;
267 FAbon.SetNGResAnchor := FSetting.AddResAnchor;
268 FAbon.DeleteSyria := FSetting.DeleteSyria;
269 FAbon.Deleterlo := FSetting.AbonDeleterlo;
270 FAbon.Replaceul := FSetting.AbonReplaceul;
271 FAbon.AbonPopupRes := FSetting.PopUpAbon;
272
273 FSelectResFilter := TAbon.Create;
274 // 腟???莨若????????サ??筝?荀с??荀????????祉???????????т????????????/span>
275 FSelectResFilter.AbonString := '';
276 //
277 ResRange := FSetting.ResRange;
278 FBayesian := TGikoBayesian.Create;
279 end;
280
281 (*************************************************************************
282 *GikoSys???鴻????????/span>
283 *************************************************************************)
284 destructor TGikoSys.Destroy;
285 var
286 i: Integer;
287 FileList: TStringList;
288 begin
289 //?鴻?????????若?帥???<?ゃ?????贋??/span>
290 // FlashExitWrite;
291
292 // FExitWrite.Free;
293 FBayesian.Free;
294 FAWKStr.Free;
295 FSetting.Free;
296 FDolib.Free;
297 FAbon.Free;
298 FSelectResFilter.Free;
299 //???潟??????TML??????/span>
300 FileList := TStringList.Create;
301 try
302 GetFileList(GetTempFolder, '*.html', FileList, False, True);
303 for i := 0 to FileList.Count - 1 do begin
304 DeleteFile(FileList[i]);
305 end;
306 finally
307 FileList.Free;
308 end;
309 inherited;
310 end;
311
312 (*************************************************************************
313 *??絖????医????с????/span>
314 *************************************************************************)
315 {$HINTS OFF}
316 function TGikoSys.IsNumeric(s: string): boolean;
317 var
318 e: integer;
319 v: integer;
320 begin
321 Val(s, v, e);
322 Result := e = 0;
323 end;
324 {$HINTS ON}
325
326 (*************************************************************************
327 *??絖???羌???絨?亥?号?医????с????/span>
328 *************************************************************************)
329 function TGikoSys.IsFloat(s: string): boolean;
330 var
331 v: Extended;
332 begin
333 Result := TextToFloat(PChar(s), v, fvExtended);
334 end;
335
336 (*************************************************************************
337 *???若?????<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
338 *************************************************************************)
339 function TGikoSys.GetBoardFileName: string;
340 begin
341 Result := Setting.GetBoardFileName;
342 end;
343
344 (*************************************************************************
345 *???若?????<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
346 *************************************************************************)
347 function TGikoSys.GetCustomBoardFileName: string;
348 begin
349 Result := Setting.GetCustomBoardFileName;
350 end;
351
352 (*************************************************************************
353 *???潟???????????????弱????緇?
354 *************************************************************************)
355 function TGikoSys.GetHtmlTempFileName: string;
356 begin
357 Result := Setting.GetHtmlTempFileName;
358 end;
359
360
361 (*************************************************************************
362 *絎?茵????<?ゃ????????????緇?
363 *************************************************************************)
364 function TGikoSys.GetAppDir: string;
365 begin
366 Result := Setting.GetAppDir;
367 end;
368
369 (*************************************************************************
370 *TempHtml???<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
371 *************************************************************************)
372 function TGikoSys.GetTempFolder: string;
373 begin
374 Result := Setting.GetTempFolder;
375 end;
376
377 (*************************************************************************
378 *sent.ini???<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
379 *************************************************************************)
380 function TGikoSys.GetSentFileName: string;
381 begin
382 Result := Setting.GetSentFileName;
383 end;
384
385 (*************************************************************************
386 *outbox.ini???<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
387 *************************************************************************)
388 function TGikoSys.GetOutBoxFileName: string;
389 begin
390 Result := Setting.GetOutBoxFileName;
391 end;
392
393 (*************************************************************************
394 *Config??????????緇?
395 *************************************************************************)
396 function TGikoSys.GetConfigDir: string;
397 begin
398 Result := Setting.GetConfigDir;
399 end;
400
401 function TGikoSys.GetStyleSheetDir: string;
402 begin
403 Result := Setting.GetStyleSheetDir;
404 end;
405
406 function TGikoSys.GetSkinDir: string;
407 begin
408 Result := Setting.GetSkinDir;
409 end;
410
411 function TGikoSys.GetSkinHeaderFileName: string;
412 begin
413 Result := Setting.GetSkinHeaderFileName;
414 end;
415
416 function TGikoSys.GetSkinFooterFileName: string;
417 begin
418 Result := Setting.GetSkinFooterFileName;
419 end;
420
421 function TGikoSys.GetSkinNewResFileName: string;
422 begin
423 Result := Setting.GetSkinNewResFileName;
424 end;
425
426 function TGikoSys.GetSkinResFileName: string;
427 begin
428 Result := Setting.GetSkinResFileName;
429 end;
430
431 function TGikoSys.GetSkinBookmarkFileName: string;
432 begin
433 Result := Setting.GetSkinBookmarkFileName;
434 end;
435
436 function TGikoSys.GetSkinNewmarkFileName: string;
437 begin
438 Result := Setting.GetSkinNewmarkFileName;
439 end;
440
441 // UserAgent??緇?
442 function TGikoSys.GetUserAgent: string;
443 begin
444 if Dolib.Connected then begin
445 Result := Format('%s %s/%s%d%s', [
446 Dolib.UserAgent,
447 APP_NAME,
448 //MAJOR_VERSION,
449 //MINOR_VERSION,
450 BETA_VERSION_NAME_E,
451 BETA_VERSION,
452 BETA_VERSION_BUILD]);
453 end else begin
454 Result := Format('%s/%s %s/%s%d%s', [
455 USER_AGENT,
456 Dolib.Version,
457 APP_NAME,
458 //MAJOR_VERSION,
459 //MINOR_VERSION,
460 BETA_VERSION_NAME_E,
461 BETA_VERSION,
462 BETA_VERSION_BUILD]);
463 end;
464 end;
465
466 (*************************************************************************
467 *鐚??<?????????劫????糸??
468 *************************************************************************)
469 function TGikoSys.Get2chDate(aDate: TDateTime): string;
470 var
471 d1: TDateTime;
472 d2: TDateTime;
473 begin
474 d1 := EncodeDate(1970, 1, 1);
475 d2 := aDate - EncodeTime(9, 0, 0, 0);
476 //Result := FloatToStr(Trunc((d2 - d1) * 24 * 60 * 60));
477 Result := FloatToStr(Trunc((d2 - d1) * 86400));
478 end;
479
480
481 function TGikoSys.IntToDateTime(val: Int64): TDateTime;
482 var
483 d1: tdatetime;
484 d2: tdatetime;
485 begin
486 d1 := EncodeDate(1970, 1, 1);
487 d2 := val / 86400.0;//(val * 1000) / (24 * 60 * 60 * 1000);
488 Result := d1 + d2;
489 end;
490
491 function TGikoSys.DateTimeToInt(ADate: TDateTime): Int64;
492 var
493 d: TDateTime;
494 c: Currency;
495 begin
496 d := EncodeDate(1970, 1, 1);
497 c := (ADate - d) * 86400; //(ADate - d) * 24 * 60 * 60;
498 Result := Trunc(c);
499 end;
500
501
502 (*************************************************************************
503 *Subject???<?ゃ??ead
504 *************************************************************************)
505 procedure TGikoSys.ReadSubjectFile(Board: TBoard);
506 var
507 ThreadItem: TThreadItem;
508 FileName: string;
509 FileList: TStringList;
510 TmpFileList: TStringList;
511 Index: Integer;
512 sl: TStringList;
513 i: Integer;
514 Rec: TIndexRec;
515 UnRead: Integer;
516 ini: TMemIniFile;
517 ResRec: TResRec;
518 RoundItem: TRoundItem;
519 idx: Integer;
520 usePlugIn : Boolean;
521 tmpStr: string;
522 {*
523 FavoThreadItem : TFavoriteThreadItem;
524 Node: TTreeNode;
525 *}
526 begin
527 if Board.IsThreadDatRead then
528 Exit;
529 Board.Clear;
530 UnRead := 0;
531
532 usePlugIn := Board.IsBoardPlugInAvailable;
533
534 FileName := Board.GetFolderIndexFileName;
535
536 FileList := TStringList.Create;
537 FileList.Sorted := True;
538 TmpFileList := TStringList.Create;
539 TmpFileList.Sorted := True;
540
541 //IsLogFile??AT???<?ゃ?????鴻??
542 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False);
543 //?????医幻腟?篋?????mp???<?ゃ?????鴻??
544 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, False);
545
546 // ??茲????蚊??
547 Board.BeginUpdate;
548 Board.Sorted := True;
549
550 sl := TStringList.Create;
551 try
552 if FileExists(FileName) then begin
553 sl.LoadFromFile(FileName);
554
555 //鐚?茵???????鐚?鐚?茵????????若?吾?с?鰹?
556 for i := sl.Count - 1 downto 1 do begin
557 Rec := ParseIndexLine(sl[i]);
558 if usePlugIn then
559 ThreadItem := TThreadItem.Create(
560 Board.BoardPlugIn,
561 Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), Rec.FFileName ) )
562 else
563 ThreadItem := TThreadItem.Create(
564 nil,
565 Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) );
566
567 if FileList.Count <> 0 then
568 if FileList.Find( ThreadItem.FileName, Index ) then
569 FileList.Delete( Index );
570
571 ThreadItem.BeginUpdate;
572 ThreadItem.No := Rec.FNo;
573 ThreadItem.FileName := Rec.FFileName;
574 ThreadItem.Title := Rec.FTitle;
575 ThreadItem.ShortTitle := CustomStringReplace(ZenToHan(ThreadItem.Title), ' ', '');
576 ThreadItem.Count := Rec.FCount;
577 ThreadItem.Size := Rec.FSize;
578 // ThreadItem.RoundNo := Rec.FRoundNo;
579 ThreadItem.RoundDate := Rec.FRoundDate;
580 ThreadItem.LastModified := Rec.FLastModified;
581 ThreadItem.Kokomade := Rec.FKokomade;
582 ThreadItem.NewReceive := Rec.FNewReceive;
583 // ThreadItem.Round := Rec.FRound;
584 ThreadItem.UnRead := Rec.FUnRead;
585 ThreadItem.ScrollTop := Rec.FScrollTop;
586 ThreadItem.AllResCount := Rec.FAllResCount;
587 ThreadItem.NewResCount := Rec.FNewResCount;
588 ThreadItem.AgeSage := Rec.FAgeSage;
589 ThreadItem.ParentBoard := Board;
590 {* ??羂????ャ??紊ч??????潟?若?? *}
591 {*
592 FavoThreadItem := TFavoriteThreadItem.Create( ThreadItem.URL, ThreadItem.Title, ThreadItem );
593 Node := FavoriteDM.TreeView.Items.AddChildObject( FavoriteDM.TreeView.Items.Item[0], ThreadItem.Title, FavoThreadItem);
594 *}
595
596 //綏≦?????鴻?????????????綏≦???????違?祉????
597 if ThreadItem.IsLogFile then begin
598 idx := RoundList.Find(ThreadItem);
599 if idx <> -1 then begin
600 RoundItem := RoundList.Items[idx, grtItem];
601 ThreadItem.RoundName := RoundItem.RoundName;
602 ThreadItem.Round := True;
603 end;
604 end;
605
606 //?????医幻腟?篋??????с????/span>
607 if TmpFileList.Count <> 0 then begin
608 if TmpFileList.Find(ChangeFileExt(ThreadItem.FileName, '.tmp'), Index) then begin
609 ini := TMemIniFile.Create(ExtractFilePath(Board.GetFolderIndexFileName) + TmpFileList[Index]);
610 try
611 tmpStr := ini.ReadString('Setting', 'RoundDate', DateTimeToStr(ZERO_DATE));
612 ThreadItem.RoundDate := ConvertDateTimeString(tmpStr);
613
614 tmpStr := ini.ReadString('Setting', 'LastModified', DateTimeToStr(ZERO_DATE));
615 ThreadItem.LastModified := ConvertDateTimeString(tmpStr);
616 ThreadItem.Count := ini.ReadInteger('Setting', 'Count', 0);
617 ThreadItem.NewReceive := ini.ReadInteger('Setting', 'NewReceive', 0);
618
619 ThreadItem.Size := ini.ReadInteger('Setting', 'Size', 0);
620 if(ThreadItem.Size = 0) and (FileExists(ThreadItem.GetThreadFileName)) then begin
621 try
622 ThreadItem.Size := GetFileSize(ThreadItem.GetThreadFileName) - ThreadItem.Count;
623 except
624 end;
625 end;
626
627
628 ThreadItem.Round := ini.ReadBool('Setting', 'Round', False);
629 ThreadItem.UnRead := False;//ini.ReadBool('Setting', 'UnRead', False);
630 ThreadItem.ScrollTop := ini.ReadInteger('Setting', 'ScrollTop', 0);
631 ThreadItem.AllResCount := ini.ReadInteger('Setting', 'AllResCount', ThreadItem.Count);
632 ThreadItem.NewResCount := ini.ReadInteger('Setting', 'NewResCount', 0);
633 ThreadItem.AgeSage := TGikoAgeSage(ini.ReadInteger('Setting', 'AgeSage', Ord(gasNone)));
634 finally
635 ini.Free;
636 end;
637 DeleteFile(ExtractFilePath(Board.GetFolderIndexFileName) + TmpFileList[Index]);
638 TmpFileList.Delete(Index);
639 end;
640 end;
641
642 ThreadItem.EndUpdate;
643 Board.Add(ThreadItem);
644
645 if (ThreadItem.IsLogFile) and (ThreadItem.UnRead) then
646 Inc(UnRead);
647 end;
648 end;
649
650 if UnRead <> Board.UnRead then
651 Board.UnRead := UnRead;
652
653 //?ゃ?潟???????鴻???<???c?????違??菴遵??鐚??????ゃ?潟???????劫?綽?鐚?
654 for i := 0 to FileList.Count - 1 do begin
655 FileName := ExtractFileDir(Board.GetFolderIndexFileName) + '\' + FileList[i];
656
657 //ResRec := DivideStrLine(ReadThreadFile(FileName, 1));
658 if usePlugIn then begin
659 ThreadItem := TThreadItem.Create(
660 Board.BoardPlugIn,
661 Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), FileList[i] ) );
662 ResRec := DivideStrLine(Board.BoardPlugIn.GetDat( DWORD( ThreadItem ), 1 ));
663 end else begin
664 ThreadItem := TThreadItem.Create(
665 nil, Get2chBoard2ThreadURL( Board, ChangeFileExt( FileList[i], '' ) ) );
666 ResRec := DivideStrLine(ReadThreadFile(FileName, 1));
667 end;
668
669 ThreadItem.BeginUpdate;
670 ThreadItem.FilePath := FileName;
671 ThreadItem.No := Board.Count + 1;
672 ThreadItem.FileName := FileList[i];
673 ThreadItem.Title := ResRec.FTitle;
674 ThreadItem.Count := GetFileLineCount(FileName);
675 ThreadItem.AllResCount := ThreadItem.Count;
676 ThreadItem.NewResCount := ThreadItem.Count;
677 ThreadItem.Size := GetFileSize(FileName) - ThreadItem.Count;//1byte????????????????????????????????????
678 ThreadItem.RoundDate := ZERO_DATE;
679 ThreadItem.LastModified := ZERO_DATE;
680 ThreadItem.Kokomade := -1;
681 ThreadItem.NewReceive := ThreadItem.Count;
682 ThreadItem.ParentBoard := Board;
683 ThreadItem.IsLogFile := True;
684 ThreadItem.Round := False;
685 ThreadItem.UnRead := False;
686 ThreadItem.ScrollTop := 0;
687 ThreadItem.AgeSage := gasNone;
688 ThreadItem.EndUpdate;
689 Board.Add(ThreadItem);
690 end;
691 Board.EndUpdate;
692 finally
693 sl.Free;
694 FileList.Free;
695 TmpFileList.Free;
696 Board.Sorted := False;
697 end;
698 Board.IsThreadDatRead := True;
699 end;
700
701 (*************************************************************************
702 *?鴻???????ゃ?潟???????鴻???<?ゃ??Folder.idx)篏???
703 *************************************************************************)
704 procedure TGikoSys.CreateThreadDat(Board: TBoard);
705 var
706 i: integer;
707 s: string;
708 SubjectList: TStringList;
709 sl: TStringList;
710 Rec: TSubjectRec;
711 FileName: string;
712 cnt: Integer;
713 begin
714 if not FileExists(Board.GetSubjectFileName) then Exit;
715 FileName := Board.GetFolderIndexFileName;
716
717 SubjectList := TStringList.Create;
718 try
719 SubjectList.LoadFromFile(Board.GetSubjectFileName);
720 sl := TStringList.Create;
721 try
722 cnt := 1;
723 sl.Add(FOLDER_INDEX_VERSION);
724 for i := 0 to SubjectList.Count - 1 do begin
725 Rec := DivideSubject(SubjectList[i]);
726
727 if (Trim(Rec.FFileName) = '') or (Trim(Rec.FTitle) = '') then
728 Continue;
729
730 s := Format('%x', [cnt]) + #1 //???/span>
731 + Rec.FFileName + #1 //???<?ゃ????
732 + Rec.FTitle + #1 //?帥?ゃ????/span>
733 + Format('%x', [Rec.FCount]) + #1 //?????潟??
734 + Format('%x', [0]) + #1 //size
735 + Format('%x', [0]) + #1 //RoundDate
736 + Format('%x', [0]) + #1 //LastModified
737 + Format('%x', [0]) + #1 //Kokomade
738 + Format('%x', [0]) + #1 //NewReceive
739 + '0' + #1 //??戎??/span>
740 + Format('%x', [0]) + #1 //UnRead
741 + Format('%x', [0]) + #1 //ScrollTop
742 + Format('%x', [Rec.FCount]) + #1 //AllResCount
743 + Format('%x', [0]) + #1 //NewResCount
744 + Format('%x', [0]); //AgeSage
745
746 sl.Add(s);
747 inc(cnt);
748 end;
749 sl.SaveToFile(FileName);
750 finally
751 sl.Free;
752 end;
753 finally
754 SubjectList.Free;
755 end;
756 end;
757
758 (*************************************************************************
759 *?鴻???????ゃ?潟????????Thread.dat)?吾??莨若??/span>
760 *Public
761 *************************************************************************)
762 procedure TGikoSys.WriteThreadDat(Board: TBoard);
763 //const
764 // Values: array[Boolean] of string = ('0', '1');
765 var
766 i: integer;
767 FileName: string;
768 sl: TStringList;
769 s: string;
770 TmpFileList: TStringList;
771 begin
772 if not Board.IsThreadDatRead then
773 Exit;
774 FileName := Board.GetFolderIndexFileName;
775 ForceDirectoriesEx( ExtractFilePath( FileName ) );
776
777 sl := TStringList.Create;
778 TmpFileList := TStringList.Create;
779 TmpFileList.Sorted := true;
780 try
781 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, false);
782 sl.BeginUpdate;
783 sl.Add(FOLDER_INDEX_VERSION);
784
785 // ?鴻????垬?絖????????純?若??
786 Sort.SortNoFlag := true;
787 Sort.SortOrder := true;
788 Sort.SortIndex := 0;
789 //Sort.SortNonAcquiredCountFlag := GikoSys.Setting.NonAcquiredCount;
790 Board.CustomSort(ThreadItemSortProc);
791
792 for i := 0 to Board.Count - 1 do begin
793 Board.Items[i].No := i + 1;
794 s := Format('%x', [Board.Items[i].No]) + #1
795 + Board.Items[i].FileName + #1
796 + Board.Items[i].Title + #1
797 + Format('%x', [Board.Items[i].Count]) + #1
798 + Format('%x', [Board.Items[i].Size]) + #1
799 + Format('%x', [DateTimeToInt(Board.Items[i].RoundDate)]) + #1
800 + Format('%x', [DateTimeToInt(Board.Items[i].LastModified)]) + #1
801 + Format('%x', [Board.Items[i].Kokomade]) + #1
802 + Format('%x', [Board.Items[i].NewReceive]) + #1
803 + '0' + #1 //??戎??/span>
804 + Format('%x', [BoolToInt(Board.Items[i].UnRead)]) + #1
805 + Format('%x', [Board.Items[i].ScrollTop]) + #1
806 + Format('%x', [Board.Items[i].AllResCount]) + #1
807 + Format('%x', [Board.Items[i].NewResCount]) + #1
808 + Format('%x', [Ord(Board.Items[i].AgeSage)]);
809
810 sl.Add(s);
811 end;
812 sl.EndUpdate;
813 sl.SaveToFile(FileName);
814
815 for i := 0 to TmpFileList.Count - 1 do begin
816 DeleteFile(ExtractFilePath(Board.GetFolderIndexFileName) + TmpFileList[i]);
817 end;
818
819 finally
820 TmpFileList.Free;
821 sl.Free;
822 end;
823 end;
824
825 function TGikoSys.ParseIndexLine(Line: string): TIndexRec;
826 begin
827 Result.FNo := StrToIntDef('$' + RemoveToken(Line, #1), 0);
828 Result.FFileName := RemoveToken(Line, #1);
829 Result.FTitle := RemoveToken(Line, #1);
830 Result.FCount := StrToIntDef('$' + RemoveToken(Line, #1), 0);
831 Result.FSize := StrToIntDef('$' + RemoveToken(Line, #1), 0);
832 Result.FRoundDate := IntToDateTime(StrToIntDef('$' + RemoveToken(Line, #1), ZERO_DATE));
833 Result.FLastModified := IntToDateTime(StrToIntDef('$' + RemoveToken(Line, #1), ZERO_DATE));
834 Result.FKokomade := StrToIntDef('$' + RemoveToken(Line, #1), -1);
835 Result.FNewReceive := StrToIntDef('$' + RemoveToken(Line, #1), 0);
836 RemoveToken(Line, #1);//9: ; //??戎??/span>
837 Result.FUnRead := IntToBool(StrToIntDef('$' + RemoveToken(Line, #1), 0));
838 Result.FScrollTop := StrToIntDef('$' + RemoveToken(Line, #1), 0);
839 Result.FAllResCount := StrToIntDef('$' + RemoveToken(Line, #1), 0);
840 Result.FNewResCount := StrToIntDef('$' + RemoveToken(Line, #1), 0);
841 Result.FAgeSage := TGikoAgeSage(StrToIntDef('$' + RemoveToken(Line, #1), 0));
842
843 end;
844
845 //??絎???????????????絎????<?ゃ???荀с????緇?????
846 // ListFiles('c:\', '*.txt', list, True);
847 procedure TGikoSys.GetFileList(Path: string; Mask: string; var List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
848 var
849 rc: Integer;
850 SearchRec : TSearchRec;
851 s: string;
852 maskExt: string;
853 begin
854 maskExt := Copy(Mask, 1, Length(Mask) - 1);
855
856 Path := IncludeTrailingPathDelimiter(Path);
857 rc := FindFirst(Path + '*.*', faAnyfile, SearchRec);
858 try
859 while rc = 0 do begin
860 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
861 s := Path + SearchRec.Name;
862 //if (SearchRec.Attr and faDirectory > 0) then
863 // s := IncludeTrailingPathDelimiter(s)
864
865 if (SearchRec.Attr and faDirectory = 0) and (MatchesMask(s, Mask)) then
866 if IsPathAdd then
867 List.Add(s)
868 else
869 List.Add(SearchRec.Name);
870 if SubDir and (SearchRec.Attr and faDirectory > 0) then
871 GetFileList(s, Mask, List, True, IsPathAdd);
872 end;
873 rc := FindNext(SearchRec);
874 end;
875 finally
876 SysUtils.FindClose(SearchRec);
877 end;
878 List.Sort;
879 end;
880 //??絎???????????????絎????<?ゃ???荀с????緇?????
881 //?泣?????????????膣≪??????
882 // ListFiles('c:\', '*.txt', list, True);
883 procedure TGikoSys.GetFileList(Path: string; Mask: string; var List: TStringList; IsPathAdd: Boolean);
884 var
885 rc: Integer;
886 SearchRec : TSearchRec;
887 s: string;
888 begin
889 Path := IncludeTrailingPathDelimiter(Path);
890 rc := FindFirst(Path + Mask, faAnyfile, SearchRec);
891 try
892 while rc = 0 do begin
893 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
894 s := Path + SearchRec.Name;
895
896 if (SearchRec.Attr and faDirectory = 0) then
897 if IsPathAdd then
898 List.Add(s)
899 else
900 List.Add(SearchRec.Name);
901 end;
902 rc := FindNext(SearchRec);
903 end;
904 finally
905 SysUtils.FindClose(SearchRec);
906 end;
907 List.Sort;
908 end;
909 //??絎????????????????c?????????荀с????緇?????
910 procedure TGikoSys.GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
911 var
912 rc: Integer;
913 SearchRec : TSearchRec;
914 s: string;
915 begin
916 Path := IncludeTrailingPathDelimiter(Path);
917 rc := FindFirst(Path + '*.*', faDirectory, SearchRec);
918 try
919 while rc = 0 do begin
920 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
921 s := Path + SearchRec.Name;
922 //if (SearchRec.Attr and faDirectory > 0) then
923 // s := IncludeTrailingPathDelimiter(s)
924
925 if (SearchRec.Attr and faDirectory > 0) and (MatchesMask(s, Mask)) then
926 List.Add( IncludeTrailingPathDelimiter( s ) );
927 if SubDir and (SearchRec.Attr and faDirectory > 0) then
928 GetDirectoryList(s, Mask, List, True);
929 end;
930 rc := FindNext(SearchRec);
931 end;
932 finally
933 SysUtils.FindClose(SearchRec);
934 end;
935 end;
936
937 // ?鴻???潟??茯??粋昭?帥???ゃ??臀??????
938 function TGikoSys.LoadFromSkin(
939 fileName: string;
940 ThreadItem: TThreadItem;
941 SizeByte: Integer
942 ): string;
943 var
944 Skin: TStringList;
945 begin
946
947 Skin := TStringList.Create;
948 try
949 if FileExists( fileName ) then begin
950 Skin.LoadFromFile( fileName );
951
952 // ???????????????????????????激?с?潟???ゃ?≪???違?????????ャ?主? try
953 try
954 if ThreadItem.ParentBoard <> nil then
955 if ThreadItem.ParentBoard.ParentCategory <> nil then
956 CustomStringReplace( Skin, '<BBSNAME/>', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title);
957 CustomStringReplace( Skin, '<THREADURL/>', ThreadItem.URL);
958 except end;
959 CustomStringReplace( Skin, '<BOARDNAME/>', ThreadItem.ParentBoard.Title);
960 CustomStringReplace( Skin, '<BOARDURL/>', ThreadItem.ParentBoard.URL);
961 CustomStringReplace( Skin, '<THREADNAME/>', ThreadItem.Title);
962 CustomStringReplace( Skin, '<SKINPATH/>', Setting.CSSFileName);
963 CustomStringReplace( Skin, '<GETRESCOUNT/>', IntToStr( ThreadItem.Count - ThreadItem.NewResCount ));
964 CustomStringReplace( Skin, '<NEWRESCOUNT/>', IntToStr( ThreadItem.NewResCount ));
965 CustomStringReplace( Skin, '<ALLRESCOUNT/>', IntToStr( ThreadItem.Count ));
966
967 CustomStringReplace( Skin, '<NEWDATE/>',FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate));
968 CustomStringReplace( Skin, '<SIZEKB/>', IntToStr( Floor( SizeByte / 1024 ) ));
969 CustomStringReplace( Skin, '<SIZE/>', IntToStr( SizeByte ));
970
971 //----- ?????????????<????????篋????????潟?<?潟???≪??????????????
972 // ???????????????????????????激?с?潟???ゃ?≪???違?????????ャ?主? try
973 try
974 if ThreadItem.ParentBoard <> nil then
975 if ThreadItem.ParentBoard.ParentCategory <> nil then
976 CustomStringReplace( Skin, '&BBSNAME', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title);
977 CustomStringReplace( Skin, '&THREADURL', ThreadItem.URL);
978 except end;
979 CustomStringReplace( Skin, '&BOARDNAME', ThreadItem.ParentBoard.Title);
980 CustomStringReplace( Skin, '&BOARDURL', ThreadItem.ParentBoard.URL);
981 CustomStringReplace( Skin, '&THREADNAME', ThreadItem.Title);
982 CustomStringReplace( Skin, '&SKINPATH', Setting.CSSFileName);
983 CustomStringReplace( Skin, '&GETRESCOUNT', IntToStr( ThreadItem.NewReceive - 1 ));
984 CustomStringReplace( Skin, '&NEWRESCOUNT', IntToStr( ThreadItem.NewResCount ));
985 CustomStringReplace( Skin, '&ALLRESCOUNT', IntToStr( ThreadItem.AllResCount ));
986
987 CustomStringReplace( Skin, '&NEWDATE', FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate));
988 CustomStringReplace( Skin, '&SIZEKB', IntToStr( Floor( SizeByte / 1024 ) ));
989 CustomStringReplace( Skin, '&SIZE', IntToStr( SizeByte ));
990 //----- ?????障??/span>
991 end;
992 Result := Skin.Text;
993 finally
994 Skin.Free;
995 end;
996 end;
997
998 // ???鴻???ゃ??臀??????
999 function TGikoSys.SkinedRes(
1000 skin: string;
1001 Res: TResRec;
1002 No: string
1003 ): string;
1004 var
1005 spamminess : Extended;
1006 wordCount : TWordCount;
1007 begin
1008
1009 wordCount := TWordCount.Create;
1010 try
1011 spamminess := Floor( SpamParse(
1012 Res.FName + '<>' + Res.FMailTo + '<>' + Res.FBody, wordCount ) * 100 );
1013
1014 Skin := CustomStringReplace( Skin, '<NUMBER/>',
1015 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>');
1016 Skin := CustomStringReplace( Skin, '<PLAINNUMBER/>', No);
1017 Skin := CustomStringReplace( Skin, '<NAME/>', '<b>' + Res.FName + '</b>');
1018 Skin := CustomStringReplace( Skin, '<MAILNAME/>',
1019 '<a href="mailto:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>');
1020 Skin := CustomStringReplace( Skin, '<MAIL/>', Res.FMailTo);
1021 Skin := CustomStringReplace( Skin, '<DATE/>', Res.FDateTime);
1022 Skin := CustomStringReplace( Skin, '<MESSAGE/>', Res.FBody);
1023 Skin := CustomStringReplace( Skin, '<SPAMMINESS/>', FloatToStr( spamminess ) );
1024 Skin := CustomStringReplace( Skin, '<NONSPAMMINESS/>', FloatToStr( 100 - spamminess ) );
1025
1026 //----- ???<????????篋????????潟?<?潟???≪??????????????
1027 Skin := CustomStringReplace( Skin, '&NUMBER',
1028 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>');
1029 Skin := CustomStringReplace( Skin, '&PLAINNUMBER', No);
1030 Skin := CustomStringReplace( Skin, '&NAME', '<b>' + Res.FName + '</b>');
1031 Skin := CustomStringReplace( Skin, '&MAILNAME',
1032 '<a href="mailto:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>');
1033 Skin := CustomStringReplace( Skin, '&MAIL', Res.FMailTo);
1034 Skin := CustomStringReplace( Skin, '&DATE', Res.FDateTime);
1035 Skin := CustomStringReplace( Skin, '&MESSAGE', Res.FBody);
1036 Skin := CustomStringReplace( Skin, '&SPAMMINESS', FloatToStr( spamminess ) );
1037 Skin := CustomStringReplace( Skin, '&NONSPAMMINESS', FloatToStr( 100 - spamminess ) );
1038 //----- ?????障??/span>
1039
1040 Result := Skin;
1041 finally
1042 wordCount.Free;
1043 end;
1044
1045 end;
1046
1047 procedure TGikoSys.CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
1048 var
1049 i: integer;
1050 No: string;
1051 //bufList : TStringList;
1052 ReadList: TStringList;
1053 SaveList: TStringList;
1054 CSSFileName: string;
1055 BBSID: string;
1056 FileName: string;
1057 NewReceiveNo: Integer;
1058 Res: TResRec;
1059 boardPlugIn : TBoardPlugIn;
1060
1061 UserOptionalStyle: string;
1062 SkinHeader: string;
1063 SkinNewRes: string;
1064 SkinRes: string;
1065
1066 strTmp : string;
1067
1068 function LoadSkin( fileName: string ): string;
1069 begin
1070 Result := LoadFromSkin( fileName, ThreadItem, ThreadItem.Size );
1071 end;
1072 function ReplaceRes( skin: string ): string;
1073 begin
1074 Result := SkinedRes( skin, Res, No );
1075 end;
1076 begin
1077 if ThreadItem <> nil then begin
1078 if ThreadItem.IsBoardPlugInAvailable then begin
1079 //===== ?????違?ゃ?潟??????茵?ず
1080 boardPlugIn := ThreadItem.BoardPlugIn;
1081 NewReceiveNo := ThreadItem.NewReceive;
1082 // ?????潟?????泣?ゃ?冴??┃絎?
1083 if Length( GikoSys.Setting.BrowserFontName ) > 0 then
1084 UserOptionalStyle := UserOptionalStyle +
1085 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
1086 if GikoSys.Setting.BrowserFontSize <> 0 then
1087 UserOptionalStyle := UserOptionalStyle +
1088 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
1089 if GikoSys.Setting.BrowserFontColor <> -1 then
1090 UserOptionalStyle := UserOptionalStyle +
1091 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
1092 if GikoSys.Setting.BrowserBackColor <> -1 then
1093 UserOptionalStyle := UserOptionalStyle +
1094 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
1095 case GikoSys.Setting.BrowserFontBold of
1096 -1: UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
1097 1: UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;';
1098 end;
1099 case GikoSys.Setting.BrowserFontItalic of
1100 -1: UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
1101 1: UserOptionalStyle := UserOptionalStyle + 'font-style:italic;';
1102 end;
1103
1104 SaveList := TStringList.Create;
1105 try
1106 doc.open;
1107 // ??絖??潟?若?????????違?ゃ?潟??算????
1108 // doc.charset := 'Shift_JIS';
1109
1110 // ??????
1111 SaveList.Add( boardPlugIn.GetHeader( DWORD( threadItem ),
1112 '<style type="text/css">body {' + UserOptionalStyle + '}</style>' ) );
1113
1114 SaveList.Add('<p id="idSearch"></p>');
1115 for i := 0 to threadItem.Count - 1 do begin
1116 // 1 ?????茵?ず
1117 if i <> 0 then begin
1118 // 茵?ず膀??蚊????絎?
1119 case ResRange of
1120 Ord( grrKoko ):
1121 if ThreadItem.Kokomade > (i + 1) then
1122 Continue;
1123 Ord( grrNew ):
1124 if NewReceiveNo > (i + 1) then
1125 Continue;
1126 10..65535:
1127 if (threadItem.Count - i) > ResRange then
1128 Continue;
1129 end;
1130 end;
1131
1132 // ?亥?????若??/span>
1133 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1134 try
1135 if GikoSys.Setting.UseSkin then begin
1136 if FileExists( GetSkinNewmarkFileName ) then
1137 SaveList.Add( LoadSkin( GetSkinNewmarkFileName ) )
1138 else
1139 SaveList.Add( '<a name="new"></a>' );
1140 end else if GikoSys.Setting.UseCSS then begin
1141 SaveList.Add('<a name="new"></a><div class="new">?亥????? <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>');
1142 end else begin
1143 SaveList.Add('</dl>');
1144 SaveList.Add('<a name="new"></a>');
1145 SaveList.Add('<table width="100%" bgcolor="#3333CC" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#6666FF" valign="middle"><font size="-1" color="#ffffff"><b>?亥????? ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</b></font></td></tr></table>');
1146 SaveList.Add('<dl>');
1147 end;
1148 except
1149 SaveList.Add( '<a name="new"></a>' );
1150 end;
1151 end;
1152
1153 // ????/span>
1154 SaveList.Add( boardPlugIn.GetRes( DWORD( threadItem ), i + 1 ) );
1155
1156 if ThreadItem.Kokomade = (i + 1) then begin
1157 // ?????障?ц?????
1158 try
1159 if GikoSys.Setting.UseSkin then begin
1160 if FileExists( GetSkinBookmarkFileName ) then
1161 SaveList.Add( LoadSkin( GetSkinBookmarkFileName ) )
1162 else
1163 SaveList.Add( '<a name="koko"></a>' );
1164 end else if GikoSys.Setting.UseCSS then begin
1165 SaveList.Add('<a name="koko"></a><div class="koko">?潟?潟?障?ц?????</div>');
1166 end else begin
1167 SaveList.Add('</dl>');
1168 SaveList.Add('<a name="koko"></a><table width="100%" bgcolor="#55AA55" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#77CC77" valign="middle"><font size="-1" color="#ffffff"><b>?潟?潟?障?ц?????</b></font></td></tr></table>');
1169 SaveList.Add('<dl>');
1170 end;
1171 except
1172 SaveList.Add( '<a name="koko"></a>' );
1173 end;
1174 end;
1175
1176 doc.Write(SaveList.Text);
1177 SaveList.Clear;
1178 end;
1179
1180
1181 // ?鴻??????????
1182 SaveList.Add( boardPlugIn.GetFooter( DWORD( threadItem ), '<a name="bottom"></a>' ) );
1183
1184 doc.Write(SaveList.Text);
1185 finally
1186 SaveList.Free;
1187 doc.Close;
1188 end;
1189
1190 Exit;
1191 end;
1192 end;
1193 ShortDayNames[1] := '??#39;; ShortDayNames[2] := '??';
1194 ShortDayNames[3] := '??#39;; ShortDayNames[4] := '羂?#39;;
1195 ShortDayNames[5] := '??#39;; ShortDayNames[6] := '??';
1196 ShortDayNames[7] := '??';
1197 BBSID := ThreadItem.ParentBoard.BBSID;
1198 NewReceiveNo := ThreadItem.NewReceive;
1199 ReadList := TStringList.Create;
1200 try
1201 if ThreadItem.IsLogFile then begin
1202 FileName := ThreadItem.GetThreadFileName;
1203 ReadList.LoadFromFile(FileName);
1204 FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
1205 FAbon.Execute(ReadList); // ???若????????/span>
1206 FSelectResFilter.Execute(ReadList); //???鴻?????c???帥???潟?違??????
1207 Res := DivideStrLine(ReadList[0]);
1208 Res.FTitle := CustomStringReplace(Res.FTitle, '鐚?鐔?', ',');
1209 sTitle := Res.FTitle;
1210 end else begin
1211 sTitle := CustomStringReplace(ThreadItem.Title, '鐚?鐔?', ',');
1212 end;
1213 SaveList := TStringList.Create;
1214 try
1215 doc.open;
1216 doc.charset := 'Shift_JIS';
1217
1218 // ?????潟?????泣?ゃ?冴??┃絎?
1219 if Length( GikoSys.Setting.BrowserFontName ) > 0 then
1220 UserOptionalStyle := UserOptionalStyle +
1221 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
1222 if GikoSys.Setting.BrowserFontSize <> 0 then
1223 UserOptionalStyle := UserOptionalStyle +
1224 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
1225 if GikoSys.Setting.BrowserFontColor <> -1 then
1226 UserOptionalStyle := UserOptionalStyle +
1227 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
1228 if GikoSys.Setting.BrowserBackColor <> -1 then
1229 UserOptionalStyle := UserOptionalStyle +
1230 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
1231 case GikoSys.Setting.BrowserFontBold of
1232 -1: UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
1233 1: UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;';
1234 end;
1235 case GikoSys.Setting.BrowserFontItalic of
1236 -1: UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
1237 1: UserOptionalStyle := UserOptionalStyle + 'font-style:italic;';
1238 end;
1239
1240 CSSFileName := GetStyleSheetDir + Setting.CSSFileName;
1241 if GikoSys.Setting.UseSkin then begin
1242 // ?鴻???割戎??/span>
1243 // ?鴻???潟??┃絎?
1244 try
1245 SkinHeader := LoadSkin( GetSkinHeaderFileName );
1246 if Length( UserOptionalStyle ) > 0 then
1247 SkinHeader := CustomStringReplace( SkinHeader, '</head>',
1248 '<style type="text/css">body {' + UserOptionalStyle + '}</style></head>');
1249 SaveList.Add( SkinHeader );
1250 except
1251 end;
1252 try
1253 SkinNewRes := LoadSkin( GetSkinNewResFileName );
1254 except
1255 end;
1256 try
1257 SkinRes := LoadSkin( GetSkinResFileName );
1258 except
1259 end;
1260 SaveList.Add('<p id="idSearch"></p>');
1261 SaveList.Add('<a name="top"></a>');
1262
1263 for i := 0 to ReadList.Count - 1 do begin
1264 // 1 ?????茵?ず
1265 if i <> 0 then begin
1266 // 茵?ず膀??蚊????絎?
1267 case ResRange of
1268 Ord( grrKoko ):
1269 if ThreadItem.Kokomade > (i + 1) then
1270 Continue;
1271 Ord( grrNew ):
1272 if NewReceiveNo > (i + 1) then
1273 Continue;
1274 10..65535:
1275 if (threadItem.Count - i) > ResRange then
1276 Continue;
1277 end;
1278 end;
1279
1280 // ?亥?????若??/span>
1281 if (NewReceiveNo = i + 1) or ((NewReceiveNo = 0) and (i = 0)) then begin
1282 try
1283 if FileExists( GetSkinNewmarkFileName ) then
1284 SaveList.Add( LoadSkin( GetSkinNewmarkFileName ) )
1285 else
1286 SaveList.Add( '<a name="new"></a>' );
1287 except
1288 SaveList.Add( '<a name="new"></a>' );
1289 end;
1290 end;
1291 if (Trim(ReadList[i]) <> '') then begin
1292 No := IntToStr(i + 1);
1293
1294 Res := DivideStrLine(ReadList[i]);
1295 if Res.FType = glt2chOld then begin
1296 Res.FMailTo := CustomStringReplace(Res.FMailTo, '鐚?鐔?', ',');
1297 Res.FName := CustomStringReplace(Res.FName, '鐚?鐔?', ',');
1298 Res.FBody := CustomStringReplace(Res.FBody, '鐚?鐔?', ',');
1299 end;
1300
1301 Res.FBody := AddAnchorTag(Res.FBody);
1302 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1303
1304 try
1305 if NewReceiveNo <= (i + 1) then
1306 // ?亥??????/span>
1307 strTmp := ReplaceRes( SkinNewRes )
1308 else
1309 // ??絽吾??????/span>
1310 strTmp := ReplaceRes( SkinRes );
1311
1312 SaveList.Add( strTmp );
1313 except
1314 end;
1315 end;
1316
1317 if ThreadItem.Kokomade = (i + 1) then begin
1318 // ?????障?ц?????
1319 try
1320 if FileExists( GetSkinBookmarkFileName ) then
1321 SaveList.Add( LoadSkin( GetSkinBookmarkFileName ) )
1322 else
1323 SaveList.Add( '<a name="koko"></a>' );
1324 except
1325 SaveList.Add( '<a name="koko"></a>' );
1326 end;
1327 end;
1328 doc.Write(SaveList.Text);
1329 SaveList.Clear;
1330 end;
1331 SaveList.Add('<a name="bottom"></a>');
1332 // ?鴻??????????
1333 try
1334 SaveList.Add( LoadSkin( GetSkinFooterFileName ) );
1335 except
1336 end;
1337 doc.Write(SaveList.Text);
1338
1339 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
1340 //CSS篏睡??/span>
1341 //CSSFileName := GetAppDir + CSS_FILE_NAME;
1342 // SaveList.Add('<html lang="ja"><head>');
1343 SaveList.Add('<html><head>');
1344 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1345 SaveList.Add('<title>' + sTitle + '</title>');
1346 SaveList.Add('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
1347 if Length( UserOptionalStyle ) > 0 then
1348 SaveList.Add('<style type="text/css">body {' + UserOptionalStyle + '}</style>');
1349 SaveList.Add('</head>');
1350 SaveList.Add('<body>');
1351 SaveList.Add('<a name="top"></a>');
1352 SaveList.Add('<p id="idSearch"></p>');
1353 SaveList.Add('<div class="title">' + sTitle + '</div>');
1354 doc.Write(SaveList.Text);
1355 SaveList.Clear;
1356 //Application.ProcessMessages;
1357 for i := 0 to ReadList.Count - 1 do begin
1358 // 1 ?????茵?ず
1359 if i <> 0 then begin
1360 // 茵?ず膀??蚊????絎?
1361 case ResRange of
1362 Ord( grrKoko ):
1363 if ThreadItem.Kokomade > (i + 1) then
1364 Continue;
1365 Ord( grrNew ):
1366 if NewReceiveNo > (i + 1) then
1367 Continue;
1368 10..65535:
1369 if (threadItem.Count - i) > ResRange then
1370 Continue;
1371 end;
1372 end;
1373
1374 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1375 SaveList.Add('<a name="new"></a><div class="new">?亥????? <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>');
1376 end;
1377 if (Trim(ReadList[i]) <> '') then begin
1378 No := IntToStr(i + 1);
1379 Res := DivideStrLine(ReadList[i]);
1380 Res.FBody := AddAnchorTag(Res.FBody);
1381 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1382 if Res.FMailTo = '' then
1383 SaveList.Add('<a name="' + No + '"></a>'
1384 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span> '
1385 + '<span class="name_label">????鐚?</span> '
1386 + '<span class="name"><b>' + Res.FName + '</b></span> '
1387 + '<span class="date_label">??腮炊?ワ?</span> '
1388 + '<span class="date">' + Res.FDateTime+ '</span></div>'
1389 + '<div class="mes">' + Res.FBody + ' </div>')
1390 else if GikoSys.Setting.ShowMail then
1391 SaveList.Add('<a name="' + No + '"></a>'
1392 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1393 + '<span class="name_label"> ????鐚? </span>'
1394 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1395 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
1396 + '<span class="date_label"> ??腮炊?ワ?</span>'
1397 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1398 + '<div class="mes">' + Res.FBody + ' </div>')
1399 else
1400 SaveList.Add('<a name="' + No + '"></a>'
1401 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1402 + '<span class="name_label"> ????鐚? </span>'
1403 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1404 + '<b>' + Res.FName + '</b></a>'
1405 + '<span class="date_label"> ??腮炊?ワ?</span>'
1406 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1407 + '<div class="mes">' + Res.FBody + ' </div>');
1408 end;
1409 if ThreadItem.Kokomade = (i + 1) then begin
1410 SaveList.Add('<a name="koko"></a><div class="koko">?潟?潟?障?ц?????</div>');
1411 end;
1412
1413 doc.Write(SaveList.Text);
1414 SaveList.Clear;
1415 end;
1416 SaveList.Add('<a name="bottom"></a>');
1417 //SaveList.Add('</body></html>');
1418 SaveList.Add('<a name="last"></a>');
1419 SaveList.Add('</body></html>');
1420
1421 doc.Write(SaveList.Text);
1422 end else begin
1423 //CSS??篏睡??/span>
1424 // SaveList.Add('<html lang="ja"><head>');
1425 SaveList.Add('<html><head>');
1426 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1427 SaveList.Add('<title>' + sTitle + '</title></head>');
1428 SaveList.Add('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1429 SaveList.Add('<a name="top"></a>');
1430 SaveList.Add('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1431 SaveList.Add('<dl>');
1432 SaveList.Add('<p id="idSearch"></p>');
1433 doc.Write(SaveList.Text);
1434 SaveList.Clear;
1435 //Application.ProcessMessages;
1436 for i := 0 to ReadList.Count - 1 do begin
1437 // 1 ?????茵?ず
1438 if i <> 0 then begin
1439 // 茵?ず膀??蚊????絎?
1440 case ResRange of
1441 Ord( grrKoko ):
1442 if ThreadItem.Kokomade > (i + 1) then
1443 Continue;
1444 Ord( grrNew ):
1445 if NewReceiveNo > (i + 1) then
1446 Continue;
1447 10..65535:
1448 if (threadItem.Count - i) > ResRange then
1449 Continue;
1450 end;
1451 end;
1452
1453 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1454 SaveList.Add('</dl>');
1455 SaveList.Add('<a name="new"></a>');
1456 SaveList.Add('<table width="100%" bgcolor="#3333CC" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#6666FF" valign="middle"><font size="-1" color="#ffffff"><b>?亥????? ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</b></font></td></tr></table>');
1457 SaveList.Add('<dl>');
1458 end;
1459 if (Trim(ReadList[i]) <> '') then begin
1460 No := IntToStr(i + 1);
1461 Res := DivideStrLine(ReadList[i]);
1462 if Res.FType = glt2chOld then begin
1463 Res.FMailTo := CustomStringReplace(Res.FMailTo, '鐚?鐔?', ',');
1464 Res.FName := CustomStringReplace(Res.FName, '鐚?鐔?', ',');
1465 Res.FBody := CustomStringReplace(Res.FBody, '鐚?鐔?', ',');
1466 end;
1467 Res.FBody := AddAnchorTag(Res.FBody);
1468 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1469 if Res.FMailTo = '' then
1470 SaveList.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ????鐚?<font color="forestgreen"><b> ' + Res.FName + ' </b></font> ??腮炊?ワ? <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>')
1471 else if GikoSys.Setting.ShowMail then
1472 SaveList.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ????鐚?<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> [' + Res.FMailTo + '] ??腮炊?ワ? <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>')
1473 else
1474 SaveList.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ????鐚?<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> ??腮炊?ワ? <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>');
1475 end;
1476 if ThreadItem.Kokomade = (i + 1) then begin
1477 SaveList.Add('</dl>');
1478 SaveList.Add('<a name="koko"></a><table width="100%" bgcolor="#55AA55" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#77CC77" valign="middle"><font size="-1" color="#ffffff"><b>?潟?潟?障?ц?????</b></font></td></tr></table>');
1479 SaveList.Add('<dl>');
1480 end;
1481 doc.Write(SaveList.Text);
1482 SaveList.Clear;
1483 end;
1484 SaveList.Add('</dl>');
1485 SaveList.Add('<a name="bottom"></a>');
1486 SaveList.Add('</body></html>');
1487 doc.Write(SaveList.Text);
1488 end;
1489 finally
1490 SaveList.Free;
1491 doc.Close;
1492 end;
1493 finally
1494 ReadList.Free;
1495 end;
1496 end;
1497 procedure TGikoSys.CreateHTML3(var html: TStringList; ThreadItem: TThreadItem; var sTitle: string);
1498 var
1499 i: integer;
1500 No: string;
1501 //bufList : TStringList;
1502 ReadList: TStringList;
1503 // SaveList: TStringList;
1504 CSSFileName: string;
1505 BBSID: string;
1506 FileName: string;
1507 Res: TResRec;
1508 boardPlugIn : TBoardPlugIn;
1509
1510 UserOptionalStyle: string;
1511 SkinHeader: string;
1512 SkinRes: string;
1513 tmp, tmp1: string;
1514 function LoadSkin( fileName: string ): string;
1515 begin
1516 Result := LoadFromSkin( fileName, ThreadItem, ThreadItem.Size );
1517 end;
1518 function ReplaceRes( skin: string ): string;
1519 begin
1520 Result := SkinedRes( skin, Res, No );
1521 end;
1522
1523 begin
1524 if ThreadItem <> nil then begin
1525 CSSFileName := GetStyleSheetDir + Setting.CSSFileName;
1526 html.Clear;
1527 html.BeginUpdate;
1528 if ThreadItem.IsBoardPlugInAvailable then begin
1529 //===== ?????違?ゃ?潟??????茵?ず
1530 boardPlugIn := ThreadItem.BoardPlugIn;
1531 // ?????潟?????泣?ゃ?冴??┃絎?
1532 if Length( GikoSys.Setting.BrowserFontName ) > 0 then
1533 UserOptionalStyle := UserOptionalStyle +
1534 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
1535 if GikoSys.Setting.BrowserFontSize <> 0 then
1536 UserOptionalStyle := UserOptionalStyle +
1537 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
1538 if GikoSys.Setting.BrowserFontColor <> -1 then
1539 UserOptionalStyle := UserOptionalStyle +
1540 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
1541 if GikoSys.Setting.BrowserBackColor <> -1 then
1542 UserOptionalStyle := UserOptionalStyle +
1543 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
1544 case GikoSys.Setting.BrowserFontBold of
1545 -1: UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
1546 1: UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;';
1547 end;
1548 case GikoSys.Setting.BrowserFontItalic of
1549 -1: UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
1550 1: UserOptionalStyle := UserOptionalStyle + 'font-style:italic;';
1551 end;
1552
1553 try
1554 // ??絖??潟?若?????????違?ゃ?潟??算????
1555 // ??????
1556 tmp := boardPlugIn.GetHeader( DWORD( threadItem ),
1557 '<style type="text/css">body {' + UserOptionalStyle + '}</style>' );
1558 //腟九????с?????後????с??/span>
1559 if Setting.UseSkin then begin
1560 tmp1 := './' +Setting.CSSFileName;
1561 tmp1 := CustomStringReplace(tmp1, GetConfigDir, '');
1562 tmp1 := CustomStringReplace(tmp1, '\', '/');
1563 tmp := CustomStringReplace(tmp, ExtractFilePath(Setting.CSSFileName), tmp1);
1564 end else if Setting.UseCSS then begin
1565 tmp1 := './' + CSSFileName;
1566 tmp1 := CustomStringReplace(tmp1, GetConfigDir, '');
1567 tmp1 := CustomStringReplace(tmp1, '\', '/');
1568 tmp := CustomStringReplace(tmp, CSSFileName, tmp1);
1569 end;
1570 html.Append( tmp );
1571
1572 for i := 0 to threadItem.Count - 1 do begin
1573
1574 // ????/span>
1575 html.Append( ConvertResAnchor(boardPlugIn.GetRes( DWORD( threadItem ), i + 1 )) );
1576
1577 end;
1578 // ?鴻??????????
1579 html.Append( boardPlugIn.GetFooter( DWORD( threadItem ), '<a name="bottom"></a>' ) );
1580 finally
1581 end;
1582 html.EndUpdate;
1583 Exit;
1584 end;
1585 end;
1586 ShortDayNames[1] := '??#39;; ShortDayNames[2] := '??';
1587 ShortDayNames[3] := '??#39;; ShortDayNames[4] := '羂?#39;;
1588 ShortDayNames[5] := '??#39;; ShortDayNames[6] := '??';
1589 ShortDayNames[7] := '??';
1590 BBSID := ThreadItem.ParentBoard.BBSID;
1591 ReadList := TStringList.Create;
1592 try
1593 if ThreadItem.IsLogFile then begin
1594 FileName := ThreadItem.GetThreadFileName;
1595 ReadList.LoadFromFile(FileName);
1596 FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
1597 FAbon.Execute(ReadList); // ???若????????/span>
1598 FSelectResFilter.Execute(ReadList); //???鴻?????c???帥???潟?違??????
1599 Res := DivideStrLine(ReadList[0]);
1600 Res.FTitle := CustomStringReplace(Res.FTitle, '鐚?鐔?', ',');
1601 sTitle := Res.FTitle;
1602 end else begin
1603 sTitle := CustomStringReplace(ThreadItem.Title, '鐚?鐔?', ',');
1604 end;
1605 try
1606 // ?????潟?????泣?ゃ?冴??┃絎?
1607 if Length( GikoSys.Setting.BrowserFontName ) > 0 then
1608 UserOptionalStyle := UserOptionalStyle +
1609 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
1610 if GikoSys.Setting.BrowserFontSize <> 0 then
1611 UserOptionalStyle := UserOptionalStyle +
1612 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
1613 if GikoSys.Setting.BrowserFontColor <> -1 then
1614 UserOptionalStyle := UserOptionalStyle +
1615 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
1616 if GikoSys.Setting.BrowserBackColor <> -1 then
1617 UserOptionalStyle := UserOptionalStyle +
1618 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
1619 case GikoSys.Setting.BrowserFontBold of
1620 -1: UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
1621 1: UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;';
1622 end;
1623 case GikoSys.Setting.BrowserFontItalic of
1624 -1: UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
1625 1: UserOptionalStyle := UserOptionalStyle + 'font-style:italic;';
1626 end;
1627
1628
1629 if GikoSys.Setting.UseSkin then begin
1630 // ?鴻???割戎??/span>
1631 // ?鴻???潟??┃絎?
1632 try
1633 SkinHeader := LoadSkin( GetSkinHeaderFileName );
1634 if Length( UserOptionalStyle ) > 0 then
1635 SkinHeader := CustomStringReplace( SkinHeader, '</head>',
1636 '<style type="text/css">body {' + UserOptionalStyle + '}</style></head>');
1637 //腟九????с?????後????с??/span>
1638 tmp1 := './' +Setting.CSSFileName;
1639 tmp1 := CustomStringReplace(tmp1, GetConfigDir, '');
1640 tmp1 := CustomStringReplace(tmp1, '\', '/');
1641 SkinHeader := CustomStringReplace(SkinHeader, ExtractFilePath(Setting.CSSFileName), tmp1);
1642 html.Append( SkinHeader );
1643 except
1644 end;
1645 try
1646 SkinRes := LoadSkin( GetSkinResFileName );
1647 except
1648 end;
1649 html.Append('<a name="top"></a>');
1650 for i := 0 to ReadList.Count - 1 do begin
1651 if (Trim(ReadList[i]) <> '') then begin
1652 No := IntToStr(i + 1);
1653
1654 Res := DivideStrLine(ReadList[i]);
1655 if Res.FType = glt2chOld then begin
1656 Res.FMailTo := CustomStringReplace(Res.FMailTo, '鐚?鐔?', ',');
1657 Res.FName := CustomStringReplace(Res.FName, '鐚?鐔?', ',');
1658 Res.FBody := CustomStringReplace(Res.FBody, '鐚?鐔?', ',');
1659 end;
1660
1661 Res.FBody := AddAnchorTag(Res.FBody);
1662 Res.FBody := ConvertResAnchor(ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true', true));
1663
1664 try
1665 html.Append( ReplaceRes( SkinRes ) );
1666 except
1667 end;
1668 end;
1669
1670 end;
1671 html.Append('<a name="bottom"></a>');
1672 // ?鴻??????????
1673 try
1674 html.Append( LoadSkin( GetSkinFooterFileName ) );
1675 except
1676 end;
1677 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
1678 //CSS篏睡??/span>
1679 //CSSFileName := GetAppDir + CSS_FILE_NAME;
1680 html.Append('<html><head>');
1681 html.Append('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1682 html.Append('<title>' + sTitle + '</title>');
1683 //腟九????с?????後????с??/span>
1684 tmp1 := './' + CSSFileName;
1685 tmp1 := CustomStringReplace(tmp1, GetConfigDir, '');
1686 tmp1 := CustomStringReplace(tmp1, '\', '/');
1687
1688 html.Append('<link rel="stylesheet" href="'+tmp1+'" type="text/css">');
1689 if Length( UserOptionalStyle ) > 0 then
1690 html.Append('<style type="text/css">body {' + UserOptionalStyle + '}</style>');
1691 html.Append('</head>');
1692 html.Append('<body>');
1693 html.Append('<a name="top"></a>');
1694 html.Append('<div class="title">' + sTitle + '</div>');
1695 for i := 0 to ReadList.Count - 1 do begin
1696 if (Trim(ReadList[i]) <> '') then begin
1697 No := IntToStr(i + 1);
1698 Res := DivideStrLine(ReadList[i]);
1699 Res.FBody := AddAnchorTag(Res.FBody);
1700 Res.FBody := ConvertResAnchor(ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true', true));
1701 if Res.FMailTo = '' then
1702 html.Append('<a name="' + No + '"></a>'
1703 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span> '
1704 + '<span class="name_label">????鐚?</span> '
1705 + '<span class="name"><b>' + Res.FName + '</b></span> '
1706 + '<span class="date_label">??腮炊?ワ?</span> '
1707 + '<span class="date">' + Res.FDateTime+ '</span></div>'
1708 + '<div class="mes">' + Res.FBody + ' </div>')
1709 else if GikoSys.Setting.ShowMail then
1710 html.Append('<a name="' + No + '"></a>'
1711 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1712 + '<span class="name_label"> ????鐚? </span>'
1713 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1714 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
1715 + '<span class="date_label"> ??腮炊?ワ?</span>'
1716 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1717 + '<div class="mes">' + Res.FBody + ' </div>')
1718 else
1719 html.Append('<a name="' + No + '"></a>'
1720 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1721 + '<span class="name_label"> ????鐚? </span>'
1722 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1723 + '<b>' + Res.FName + '</b></a>'
1724 + '<span class="date_label"> ??腮炊?ワ?</span>'
1725 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1726 + '<div class="mes">' + Res.FBody + ' </div>');
1727 end;
1728 end;
1729 html.Append('<a name="bottom"></a>');
1730 html.Append('</body></html>');
1731 html.Append('<a name="last"></a>');
1732 html.Append('</body></html>');
1733 end else begin
1734 //CSS??篏睡??/span>
1735 html.Append('<html><head>');
1736 html.Append('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1737 html.Append('<title>' + sTitle + '</title></head>');
1738 html.Append('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1739 html.Append('<a name="top"></a>');
1740 html.Append('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1741 html.Append('<dl>');
1742 for i := 0 to ReadList.Count - 1 do begin
1743 if (Trim(ReadList[i]) <> '') then begin
1744 No := IntToStr(i + 1);
1745 Res := DivideStrLine(ReadList[i]);
1746 if Res.FType = glt2chOld then begin
1747 Res.FMailTo := CustomStringReplace(Res.FMailTo, '鐚?鐔?', ',');
1748 Res.FName := CustomStringReplace(Res.FName, '鐚?鐔?', ',');
1749 Res.FBody := CustomStringReplace(Res.FBody, '鐚?鐔?', ',');
1750 end;
1751 Res.FBody := AddAnchorTag(Res.FBody);
1752 Res.FBody := ConvertResAnchor(ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true', true));
1753 if Res.FMailTo = '' then
1754 html.Append('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ????鐚?<font color="forestgreen"><b> ' + Res.FName + ' </b></font> ??腮炊?ワ? ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>')
1755 else if GikoSys.Setting.ShowMail then
1756 html.Append('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ????鐚?<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> [' + Res.FMailTo + '] ??腮炊?ワ? ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>')
1757 else
1758 html.Append('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ????鐚?<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> ??腮炊?ワ? ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>');
1759 end;
1760 end;
1761 html.Append('</dl>');
1762 html.Append('<a name="bottom"></a>');
1763 html.Append('</body></html>');
1764 end;
1765 finally
1766 html.EndUpdate;
1767 end;
1768 finally
1769 ReadList.Free;
1770 end;
1771 end;
1772 function TGikoSys.ConvertResAnchor(res: string): string;
1773 const
1774 _HEAD : string = '<a href="../';
1775 _TAIL : string = ' target="_blank">';
1776 _ST: string = '&st=';
1777 _TO: string = '&to=';
1778 _STA: string = '&START=';
1779 _END: string = '&END=';
1780 var
1781 i, j, k: Integer;
1782 tmp: string;
1783 begin
1784 Result := '';
1785 i := AnsiPos(_HEAD, res);
1786 while i <> 0 do begin
1787 Result := Result + Copy(res, 1, i -1);
1788 Delete(res, 1, i - 1);
1789 j := AnsiPos(_TAIL, res);
1790 if j = 0 then begin
1791 Result := Result + res;
1792 Exit;
1793 end;
1794 tmp := Copy(res, 1, j - 1);
1795 Delete(res, 1, j + 16);
1796 if (AnsiPos(_ST, tmp) <> 0) and (AnsiPos(_TO, tmp) <> 0) then begin
1797 Delete(tmp, 1, AnsiPos(_ST, tmp) + 3);
1798 Delete(tmp, AnsiPos(_TO, tmp), Length(tmp));
1799 Result := Result + '<a href="#' + tmp + '">';
1800 end else if (AnsiPos(_STA, tmp) <> 0) and (AnsiPos(_END, tmp) <> 0) then begin
1801 Delete(tmp, 1, AnsiPos(_STA, tmp) + 6);
1802 Delete(tmp, AnsiPos(_END, tmp), Length(tmp));
1803 Result := Result + '<a href="#' + tmp + '">';
1804 end else begin
1805 k := LastDelimiter('/', tmp);
1806 Delete(tmp, 1, k);
1807 if AnsiPos('-', tmp) < AnsiPos('"', tmp) then
1808 Delete(tmp, AnsiPos('-', tmp), Length(tmp))
1809 else
1810 Delete(tmp, AnsiPos('"', tmp), Length(tmp));
1811
1812 Result := Result + '<a href="#' + tmp + '">';
1813 end;
1814 i := AnsiPos(_HEAD, res);
1815 end;
1816 Result := Result + res;
1817
1818 end;
1819
1820 (*************************************************************************
1821 *http://????絖?????anchor?帥?遺???????????
1822 *************************************************************************)
1823 function TGikoSys.AddAnchorTag(s: string): string;
1824 const
1825 URL_CHAR: string = '0123456789'
1826 + 'abcdefghijklmnopqrstuvwxyz'
1827 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1828 + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
1829 ANCHOR_REF = 'href=';
1830 RES_REF = '&gt;&gt;';
1831 var
1832 wkIdx: array[0..9] of Integer;
1833 url: string;
1834 href: string;
1835 i, b: Integer;
1836 idx: Integer;
1837 anchorLen : Integer;
1838 begin
1839 Result := '';
1840 // + 3 ? 'href="' ('"'?ゃ??)?????????????若?激?с?潟???茖???????????????
1841 anchorLen := Length( ANCHOR_REF ) + 3;
1842
1843 while True do begin
1844 wkIdx[0] := AnsiPos('http://', s);
1845 wkIdx[1] := AnsiPos('ttp://', s);
1846 wkIdx[2] := AnsiPos('tp://', s);
1847 wkIdx[3] := AnsiPos('ms-help://', s);
1848 wkIdx[4] := AnsiPos('p://', s);
1849 wkIdx[5] := AnsiPos('https://', s);
1850 wkIdx[6] := AnsiPos('www.', s);
1851 wkIdx[7] := AnsiPos('ftp://', s);
1852 wkIdx[8] := AnsiPos('news://', s);
1853 wkIdx[9] := AnsiPos('rtsp://', s);
1854
1855 idx := MaxInt;
1856 for i := 0 to 9 do
1857 if wkIdx[i] <> 0 then idx := Min(wkIdx[i], idx);
1858
1859 if idx = MaxInt then begin
1860 //???潟?????<??????
1861 Result := Result + s;
1862 Break;
1863 end;
1864
1865 if (idx > 1) and
1866 (Pos( ANCHOR_REF, Copy(s, idx - anchorLen, anchorLen ) ) > 0) then begin
1867 //?≪?????潟???帥?違???ゃ?????????c?純????????????/span>
1868 href := Copy( s, idx, Length( s ) );
1869 Result := Result + Copy( s, 1, idx + Pos( '</a>', href ) + Length( '</a>' ) - 2 );
1870 s := href;
1871 s := Copy( s, Pos( '</a>', s ) + Length( '</a>' ), Length( s ) );
1872
1873 Continue;
1874 end;
1875
1876 Result := Result + Copy(s, 0, idx - 1);
1877
1878 s := Copy(s, idx, length(s));
1879
1880 b := Length( s ) + 1;
1881 for i := 1 to b do begin
1882 if i = b then
1883 idx := 0
1884 else
1885 idx := AnsiPos(s[i], URL_CHAR);
1886 if idx = 0 then begin
1887 //URL??????????絖??肴?鐚?????????絖?????????c????
1888 url := Copy(s, 0, i - 1);
1889
1890 if AnsiPos('ttp://', url) = 1 then
1891 href := 'h' + url
1892 else if AnsiPos('tp://', url) = 1 then
1893 href := 'ht' + url
1894 else if AnsiPos('p://', url) = 1 then
1895 href := 'htt' + url
1896 else if AnsiPos('www.', url) = 1 then
1897 href := 'http://' + url
1898 else
1899 href := url;
1900 Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
1901 s := Copy(s, i, MaxInt);
1902 Break;
1903 end;
1904 end;
1905 end;
1906 end;
1907
1908 (*************************************************************************
1909 *?泣???吾?с????筝?茵???????/span>
1910 *************************************************************************)
1911 function TGikoSys.DivideSubject(Line: string): TSubjectRec;
1912 var
1913 i: integer;
1914 ws: WideString;
1915 Delim: string;
1916 LeftK: string;
1917 RightK: string;
1918 begin
1919 Result.FCount := 0;
1920
1921 if AnsiPos('<>', Line) = 0 then
1922 Delim := ','
1923 else
1924 Delim := '<>';
1925 Result.FFileName := RemoveToken(Line, Delim);
1926 Result.FTitle := RemoveToken(Line, Delim);
1927
1928 ws := Trim(Result.FTitle);
1929
1930 if Copy(ws, Length(ws), 1) = ')' then begin
1931 LeftK := '(';
1932 RightK := ')';
1933 end else if Copy(ws, Length(ws), 1) = '鐚?' then begin
1934 LeftK := '鐚?';
1935 RightK := '鐚?';
1936 end else if Copy(ws, Length(ws), 1) = '<' then begin
1937 LeftK := '<';
1938 RightK := '>';
1939 end;
1940
1941 for i := Length(ws) - 1 downto 1 do begin
1942 if ws[i] = LeftK then begin
1943 ws := Copy(ws, i + 1, Length(ws) - i - 1);
1944 if IsNumeric(ws) then
1945 Result.FCount := StrToInt(ws);
1946 Result.FTitle := Trim(CustomStringReplace(Result.FTitle, LeftK + ws + RightK, ''));
1947 break;
1948 end;
1949 end;
1950 end;
1951
1952 (*************************************************************************
1953 * dat???<?ゃ????????ゃ?潟????茹?/span>
1954 *************************************************************************)
1955 function TGikoSys.DivideStrLine(Line: string): TResRec;
1956 var
1957 Delim: string;
1958 bufbody : String;
1959 begin
1960 if AnsiPos('<>', Line) = 0 then begin
1961 Delim := ',';
1962 Result.FType := glt2chOld;
1963 end else begin
1964 Delim := '<>';
1965 Result.FType := glt2chNew;
1966 end;
1967 Result.FName := Trim(RemoveToken(Line, Delim));
1968 Result.FMailTo := Trim(RemoveToken(Line, Delim));
1969 Result.FDateTime := Trim(RemoveToken(Line, Delim));
1970 bufBody := Trim(RemoveToken(Line, Delim));
1971
1972 if bufbody = '' then begin
1973 Insert('&nbsp;',bufbody, 1);
1974 end;
1975 Result.FBody := bufBody;
1976 Result.FTitle := Trim(RemoveToken(Line, Delim));
1977
1978 end;
1979
1980 (*************************************************************************
1981 * URL????BBSID????緇?
1982 *************************************************************************)
1983 function TGikoSys.UrlToID(url: string): string;
1984 var
1985 i: integer;
1986 begin
1987 Result := '';
1988 url := Trim(url);
1989
1990 if url = '' then Exit;
1991
1992 url := Copy(url, 0, Length(url) - 1);
1993 for i := Length(url) downto 0 do begin
1994 if url[i] = '/' then begin
1995 Result := Copy(url, i + 1, Length(url));
1996 Break;
1997 end;
1998 end;
1999 end;
2000
2001 (*************************************************************************
2002 *URL????BBSID篁ュ???????(http://teri.2ch.net/)????緇?
2003 *************************************************************************)
2004 function TGikoSys.UrlToServer(url: string): string;
2005 var
2006 i: integer;
2007 wsURL: WideString;
2008 begin
2009 Result := '';
2010 wsURL := url;
2011 wsURL := Trim(wsURL);
2012
2013 if wsURL = '' then exit;
2014
2015 if Copy(wsURL, Length(wsURL), 1) = '/' then
2016 wsURL := Copy(wsURL, 0, Length(wsURL) - 1);
2017
2018 for i := Length(wsURL) downto 0 do begin
2019 if wsURL[i] = '/' then begin
2020 Result := Copy(wsURL, 0, i);
2021 break;
2022 end;
2023 end;
2024 end;
2025
2026 (*************************************************************************
2027 *???c??????????絖????????????с????/span>
2028 *************************************************************************)
2029 function TGikoSys.DirectoryExistsEx(const Name: string): Boolean;
2030 var
2031 Code: Integer;
2032 begin
2033 Code := GetFileAttributes(PChar(Name));
2034 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
2035 end;
2036
2037 (*************************************************************************
2038 *???c???????????鐚?茲??育??韻絲上?鐚?
2039 *************************************************************************)
2040 function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean;
2041 begin
2042 Result := True;
2043 if Length(Dir) = 0 then
2044 raise Exception.Create('??????????篏????堺?ャ?障????');
2045 Dir := ExcludeTrailingPathDelimiter(Dir);
2046 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
2047 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
2048 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
2049 end;
2050
2051 (*************************************************************************
2052 *??絖??????????若???潟???????冴??鐚?????????鐚?
2053 *FDelphi????????????/span>
2054 *************************************************************************)
2055 function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
2056 begin
2057 Rec.Str := s;
2058 Rec.Pos := 1;
2059 Result := StrTokNext(sep, Rec);
2060 end;
2061
2062 (*************************************************************************
2063 *??絖??????????若???潟???????冴??
2064 *FDelphi????????????/span>
2065 *************************************************************************)
2066 function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
2067 var
2068 Len, I: Integer;
2069 begin
2070 with Rec do begin
2071 Len := Length(Str);
2072 Result := '';
2073 if Len >= Pos then begin
2074 while (Pos <= Len) and (Str[Pos] in sep) do begin
2075 Inc(Pos);
2076 end;
2077 I := Pos;
2078 while (Pos<= Len) and not (Str[Pos] in sep) do begin
2079 if IsDBCSLeadByte(Byte(Str[Pos])) then begin
2080 Inc(Pos);
2081 end;
2082 Inc(Pos);
2083 end;
2084 Result := Copy(Str, I, Pos - I);
2085 while (Pos <= Len) and (Str[Pos] in sep) do begin// ????????絅純??/span>
2086 Inc(Pos);
2087 end;
2088 end;
2089 end;
2090 end;
2091
2092 (*************************************************************************
2093 *???<?ゃ???泣?ゃ?阪??
2094 *************************************************************************)
2095 function TGikoSys.GetFileSize(FileName : string): longint;
2096 var
2097 F : File;
2098 begin
2099 try
2100 if not FileExists(FileName) then begin
2101 Result := 0;
2102 Exit;
2103 end;
2104 Assign(F, FileName);
2105 Reset(F, 1);
2106 Result := FileSize(F);
2107 CloseFile(F);
2108 except
2109 Result := 0;
2110 end;
2111 end;
2112
2113 (*************************************************************************
2114 *???<?ゃ????医??
2115 *************************************************************************)
2116 function TGikoSys.GetFileLineCount(FileName : string): longint;
2117 var
2118 sl: TStringList;
2119 begin
2120 sl := TStringList.Create;
2121 try
2122 try
2123 sl.LoadFromFile(FileName);
2124 Result := sl.Count;
2125 except
2126 Result := 0;
2127 end;
2128 finally
2129 sl.Free;
2130 end;
2131
2132 end;
2133
2134 (*************************************************************************
2135 *?鴻?????????<?ゃ????????絎?茵?????緇?
2136 *************************************************************************)
2137 function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string;
2138 var
2139 fileTmp : TStringList;
2140 begin
2141 Result := '';
2142 if FileExists(FileName) then begin
2143 fileTmp := TStringList.Create;
2144 try
2145 try
2146 fileTmp.LoadFromFile( FileName );
2147 if ( Line >= 1 ) and ( Line < fileTmp.Count + 1 ) then begin
2148 Result := fileTmp.Strings[ Line-1 ];
2149 end;
2150 except
2151 //on EFOpenError do Result := '';
2152 end;
2153 finally
2154 fileTmp.Free;
2155 end;
2156 end;
2157 end;
2158
2159 (*************************************************************************
2160 *?激?鴻?????<???ャ?若?????潟??????с????緇?
2161 *************************************************************************)
2162 procedure TGikoSys.MenuFont(Font: TFont);
2163 var
2164 lf: LOGFONT;
2165 nm: NONCLIENTMETRICS;
2166 begin
2167 nm.cbSize := sizeof(NONCLIENTMETRICS);
2168
2169 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0);
2170 lf := nm.lfMenuFont;
2171
2172 Font.Name := lf.lfFaceName;
2173 Font.Height := lf.lfHeight;
2174 Font.Style := [];
2175 if lf.lfWeight >= 700 then
2176 Font.Style := Font.Style + [fsBold];
2177 if lf.lfItalic = 1 then
2178 Font.Style := Font.Style + [fsItalic];
2179 end;
2180
2181 (*************************************************************************
2182 *
2183 *?????????泣?ゃ??????????????/span>
2184 *************************************************************************)
2185 function TGikoSys.RemoveToken(var s: string;const delimiter: string): string;
2186 var
2187 p: Integer;
2188 begin
2189 p := AnsiPos(delimiter, s);
2190 if p = 0 then
2191 Result := s
2192 else
2193 Result := Copy(s, 1, p - 1);
2194 s := Copy(s, Length(Result) + Length(delimiter) + 1, Length(s));
2195 end;
2196
2197 (*************************************************************************
2198 *
2199 *?????????泣?ゃ??????????????/span>
2200 *************************************************************************)
2201 function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string;
2202 var
2203 i: Integer;
2204 begin
2205 Result := '';
2206 for i := 0 to index do
2207 Result := RemoveToken(s, delimiter);
2208 end;
2209
2210 (*************************************************************************
2211 *
2212 *************************************************************************)
2213 function TGikoSys.DeleteLink(const s: string): string;
2214 var
2215 s1: string;
2216 s2: string;
2217 idx: Integer;
2218 i: Integer;
2219 begin
2220 i := 0;
2221 Result := '';
2222 while True do begin
2223 s1 := GetTokenIndex(s, '<a href="', i);
2224 s2 := GetTokenIndex(s, '<a href="', i + 1);
2225
2226 idx := Pos('">', s1);
2227 if idx <> 0 then
2228 Delete(s1, 1, idx + 1);
2229 idx := Pos('">', s2);
2230 if idx <> 0 then
2231 Delete(s2, 1, idx + 1);
2232
2233 Result := Result + s1 + s2;
2234
2235 if s2 = '' then
2236 Break;
2237
2238 inc(i, 2);
2239 end;
2240 end;
2241
2242 //?ゃ?潟???????号???贋?違???????<?????????激?ワ?
2243 {procedure TGikoSys.FlashExitWrite;
2244 var
2245 i: Integer;
2246 begin
2247 //?鴻?????????若?帥???<?ゃ?????贋??/span>
2248 for i := 0 to FExitWrite.Count - 1 do
2249 WriteThreadDat(FExitWrite[i]);
2250 FExitWrite.Clear;
2251 end;}
2252
2253 (*************************************************************************
2254 *?鴻???????????????????????????
2255 *from HotZonu
2256 *************************************************************************)
2257 function TGikoSys.GetShortName(const LongName: string; ALength: integer): string;
2258 const
2259 ERASECHAR : array [1..39] of string =
2260 ('??','??','??','??#39;,'??','??','鐚?#39;,'鐚?','??#39;,'??#39;,
2261 '??#39;,'??#39;,'??39;,'??','??#39;,'??','??','??#39;,'??','??',
2262 '??','??','??','??','??','??','鐚?','鐚?','??#39;,'??#39;,
2263 '鐔?','鐔?','??','??','??#39;,'??39;,'??','??#39;, '??');
2264 var
2265 Chr : array [0..255] of char;
2266 S : string;
2267 i : integer;
2268 begin
2269 s := Trim(LongName);
2270 if (Length(s) <= ALength) then begin
2271 Result := s;
2272 end else begin
2273 S := s;
2274 for i := Low(ERASECHAR) to High(ERASECHAR) do begin
2275 S := CustomStringReplace(S, ERASECHAR[i], '');
2276 end;
2277 if (Length(S) <= ALength) then begin
2278 Result := S;
2279 end else begin
2280 Windows.LCMapString(
2281 GetUserDefaultLCID(),
2282 LCMAP_HALFWIDTH,
2283 PChar(S),
2284 Length(S) + 1,
2285 chr,
2286 Sizeof(chr)
2287 );
2288 S := Chr;
2289 S := Copy(S,1,ALength);
2290 while true do begin
2291 if (ByteType(S, Length(S)) = mbLeadByte ) then begin
2292 S := Copy(S, 1, Length(S) - 1);
2293 end else begin
2294 Break;
2295 end;
2296 end;
2297 Result := S;
2298 end;
2299 end;
2300 end;
2301
2302 (*************************************************************************
2303 *
2304 * from HotZonu
2305 *************************************************************************)
2306 function TGikoSys.ConvRes(const Body, Bbs, Key,
2307 ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string;
2308 DatToHTML: boolean = false): string;
2309 type
2310 PIndex = ^TIndex;
2311 TIndex = record
2312 FIndexFrom : integer;
2313 FIndexTo : integer;
2314 FNo : string;
2315 end;
2316 const
2317 GT = '&gt;';
2318 SN = '0123456789-';
2319 ZN = '鐚?鐚?鐚?鐚?鐚?鐚?鐚?鐚?鐚?鐚???';
2320 var
2321 i : integer;
2322 s,r : string;
2323 b : TMbcsByteType;
2324 sw: boolean;
2325 sp: integer;
2326 No: string;
2327 sx: string;
2328 List: TList;
2329 oc : string;
2330 st, et: string;
2331 chk : boolean;
2332 al : boolean;
2333 procedure Add(IndexFrom, IndexTo: integer; const No: string);
2334 var
2335 FIndex : PIndex;
2336 begin
2337 New(FIndex);
2338 FIndex.FIndexFrom := IndexFrom;
2339 FIndex.FIndexTo := IndexTo;
2340 FIndex.FNo := No;
2341 List.Add(FIndex);
2342 end;
2343 function ChooseString(const Text, Separator: string; Index: integer): string;
2344 var
2345 S : string;
2346 i, p : integer;
2347 begin
2348 S := Text;
2349 for i := 0 to Index - 1 do begin
2350 if (AnsiPos(Separator, S) = 0) then S := ''
2351 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
2352 end;
2353 p := AnsiPos(Separator, S);
2354 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
2355 end;
2356 begin
2357 { v1.0 b2 - 03 }
2358 s := Body;
2359 r := Body;
2360 i := 1;
2361 sw := False;
2362 No := '';
2363 List:= TList.Create;
2364 oc := '';
2365 sp := 0;
2366 chk := False;
2367 al := False;
2368 while true do begin
2369 b := ByteType(s, i);
2370 case b of
2371 mbSingleByte : begin
2372 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
2373 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
2374 sw := True;
2375 sp := i;
2376 i := i + 7;
2377 oc:='';
2378 chk := True;
2379 end;
2380 end else
2381 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
2382 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
2383 i := i + 7;
2384 oc:='';
2385 chk := True;
2386 end;
2387 end else
2388 if (not sw) and (Copy(s,i,4) = GT) then begin
2389 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
2390 sw := True;
2391 sp := i;
2392 i := i + 3;
2393 oc:='';
2394 chk := True;
2395 end;
2396 end else
2397 if ((not sw) and (Copy(s,i,1) = ',')) or
2398 ((not sw) and (Copy(s,i,1) = '=')) then begin
2399 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
2400 ((Chk) and (oc = '')) or
2401 ((not Chk) and (al)) then
2402 begin
2403 sw := True;
2404 sp := i;
2405 //i := i + 1;
2406 oc:='';
2407 end;
2408 end else
2409 if (sw) then begin
2410 sx := Copy(s,i,1);
2411 if (AnsiPos(sx, SN) > 0) then begin
2412 No := No + sx;
2413 end else begin
2414 if (No <> '') and (No <> '-') then begin
2415 Add(sp, i, No);
2416 al := True;
2417 end;
2418 sw := False;
2419 //
2420 i := i - 1;
2421 //
2422 No := '';
2423 oc:='';
2424 //chk := False;
2425 end;
2426 end else begin
2427 if Copy(s,i,1) = '<' then oc := '';
2428 oc := oc + Copy(s,i,1);
2429 chk := False;
2430 al := False;
2431 end;
2432 end;
2433 mbLeadByte : begin
2434 if (not sw) and (Copy(s,i,4) = '鐚?鐚?') then begin
2435 sw := True;
2436 sp := i;
2437 i := i + 3;
2438 chk := True;
2439 end else
2440 if (not sw) and (Copy(s,i,2) = '鐚?') then begin
2441 sw := True;
2442 sp := i;
2443 i := i + 1;
2444 chk := True;
2445 end else
2446 if (sw) then begin
2447 sx := Copy(s,i,2);
2448 if (AnsiPos(sx, ZN) > 0) then begin
2449 No := No + ZenToHan(sx);
2450 end else begin
2451 if (No <> '') and (No <> '-') and (No <> '??') then begin
2452 Add(sp, i, No);
2453 end;
2454 sw := False;
2455 i := i - 1;
2456 No := '';
2457 end;
2458 end else begin
2459 oc := '';
2460 chk := False;
2461 end;
2462 al := False;
2463 end;
2464 end;
2465 inc(i);
2466 if (i > Length(Body)) then begin
2467 if (sw) then begin
2468 if (No <> '') then Add(sp, i, No);
2469 end;
2470 Break;
2471 end;
2472 end;
2473 for i := List.Count - 1 downto 0 do begin
2474 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
2475 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
2476 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
2477 end else begin
2478 st := PIndex(List[i]).FNo;
2479 et := PIndex(List[i]).FNo;
2480 end;
2481 if not DatToHTML then
2482 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
2483 Format('<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">',
2484 [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
2485 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
2486 Copy(r,PIndex(List[i]).FIndexTo,Length(r))
2487 else
2488 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
2489 Format('<a href="#%s">', [st]) +
2490 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
2491 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
2492
2493 Dispose(PIndex(List[i]));
2494 end;
2495 List.Free;
2496 Result := r;
2497 end;
2498
2499 function TGikoSys.ConvRes(
2500 const Body, Bbs, Key, ParamBBS, ParamKey,
2501 ParamStart, ParamTo, ParamNoFirst,
2502 ParamTrue, FullURL : string
2503 ): string;
2504 type
2505 PIndex = ^TIndex;
2506 TIndex = record
2507 FIndexFrom : integer;
2508 FIndexTo : integer;
2509 FNo : string;
2510 end;
2511 const
2512 GT = '&gt;';
2513 SN = '0123456789-';
2514 ZN = '鐚?鐚?鐚?鐚?鐚?鐚?鐚?鐚?鐚?鐚???';
2515 var
2516 i : integer;
2517 s,r : string;
2518 b : TMbcsByteType;
2519 sw: boolean;
2520 sp: integer;
2521 No: string;
2522 sx: string;
2523 List: TList;
2524 oc : string;
2525 st, et: string;
2526 chk : boolean;
2527 al : boolean;
2528 procedure Add(IndexFrom, IndexTo: integer; const No: string);
2529 var
2530 FIndex : PIndex;
2531 begin
2532 New(FIndex);
2533 FIndex.FIndexFrom := IndexFrom;
2534 FIndex.FIndexTo := IndexTo;
2535 FIndex.FNo := No;
2536 List.Add(FIndex);
2537 end;
2538 function ChooseString(const Text, Separator: string; Index: integer): string;
2539 var
2540 S : string;
2541 i, p : integer;
2542 begin
2543 S := Text;
2544 for i := 0 to Index - 1 do begin
2545 if (AnsiPos(Separator, S) = 0) then S := ''
2546 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
2547 end;
2548 p := AnsiPos(Separator, S);
2549 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
2550 end;
2551 begin
2552 { v1.0 b2 - 03 }
2553 s := Body;
2554 r := Body;
2555 i := 1;
2556 sw := False;
2557 No := '';
2558 List:= TList.Create;
2559 oc := '';
2560 sp := 0;
2561 chk := False;
2562 al := False;
2563 while true do begin
2564 b := ByteType(s, i);
2565 case b of
2566 mbSingleByte : begin
2567 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
2568 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
2569 sw := True;
2570 sp := i;
2571 i := i + 7;
2572 oc:='';
2573 chk := True;
2574 end;
2575 end else
2576 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
2577 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
2578 i := i + 7;
2579 oc:='';
2580 chk := True;
2581 end;
2582 end else
2583 if (not sw) and (Copy(s,i,4) = GT) then begin
2584 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
2585 sw := True;
2586 sp := i;
2587 i := i + 3;
2588 oc:='';
2589 chk := True;
2590 end;
2591 end else
2592 if ((not sw) and (Copy(s,i,1) = ',')) or
2593 ((not sw) and (Copy(s,i,1) = '=')) then begin
2594 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
2595 ((Chk) and (oc = '')) or
2596 ((not Chk) and (al)) then
2597 begin
2598 sw := True;
2599 sp := i;
2600 //i := i + 1;
2601 oc:='';
2602 end;
2603 end else
2604 if (sw) then begin
2605 sx := Copy(s,i,1);
2606 if (AnsiPos(sx, SN) > 0) then begin
2607 No := No + sx;
2608 end else begin
2609 if (No <> '') and (No <> '-') then begin
2610 Add(sp, i, No);
2611 al := True;
2612 end;
2613 sw := False;
2614 //
2615 i := i - 1;
2616 //
2617 No := '';
2618 oc:='';
2619 //chk := False;
2620 end;
2621 end else begin
2622 if Copy(s,i,1) = '<' then oc := '';
2623 oc := oc + Copy(s,i,1);
2624 chk := False;
2625 al := False;
2626 end;
2627 end;
2628 mbLeadByte : begin
2629 if (not sw) and (Copy(s,i,4) = '鐚?鐚?') then begin
2630 sw := True;
2631 sp := i;
2632 i := i + 3;
2633 chk := True;
2634 end else
2635 if (not sw) and (Copy(s,i,2) = '鐚?') then begin
2636 sw := True;
2637 sp := i;
2638 i := i + 1;
2639 chk := True;
2640 end else
2641 if (sw) then begin
2642 sx := Copy(s,i,2);
2643 if (AnsiPos(sx, ZN) > 0) then begin
2644 No := No + ZenToHan(sx);
2645 end else begin
2646 if (No <> '') and (No <> '-') and (No <> '??') then begin
2647 Add(sp, i, No);
2648 end;
2649 sw := False;
2650 i := i - 1;
2651 No := '';
2652 end;
2653 end else begin
2654 oc := '';
2655 chk := False;
2656 end;
2657 al := False;
2658 end;
2659 end;
2660 inc(i);
2661 if (i > Length(Body)) then begin
2662 if (sw) then begin
2663 if (No <> '') then Add(sp, i, No);
2664 end;
2665 Break;
2666 end;
2667 end;
2668 for i := List.Count - 1 downto 0 do begin
2669 //plName := Copy(PluginName, LastDelimiter('\',PluginName) + 1, Length(PluginName) - LastDelimiter('/',PluginName) -1 );
2670 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
2671 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
2672 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
2673 end else begin
2674 st := PIndex(List[i]).FNo;
2675 et := PIndex(List[i]).FNo;
2676 end;
2677 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
2678 Format('<a href="%s&%s=%s&%s=%s&%s=%s" target="_blank">',
2679 [FullURL, ParamStart, st,