OSDN Git Service

・スレタイの特定ワードを非表示にする機能に「©bbspink.com」も追加
[gikonavigoeson/gikonavi.git] / GikoSystem.pas
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,} URLMon, IdGlobal, IdURI, {Masks,}
16         Setting, BoardGroup, gzip, Dolib, bmRegExp, AbonUnit,
17         ExternalBoardManager, ExternalBoardPlugInMain,
18         GikoBayesian, GikoMessage, Belib;
19
20 type
21         TVerResourceKey = (
22                         vrComments,         //!< \83R\83\81\83\93\83g
23                         vrCompanyName,      //!< \89ï\8eÐ\96¼
24                         vrFileDescription,  //!< \90à\96¾
25                         vrFileVersion,      //!< \83t\83@\83C\83\8b\83o\81[\83W\83\87\83\93
26                         vrInternalName,     //!< \93à\95\94\96¼
27                         vrLegalCopyright,   //!< \92\98\8dì\8c 
28                         vrLegalTrademarks,  //!< \8f¤\95W
29                         vrOriginalFilename, //!< \90³\8e®\83t\83@\83C\83\8b\96¼
30                         vrPrivateBuild,     //!< \83v\83\89\83C\83x\81[\83g\83r\83\8b\83h\8fî\95ñ
31                         vrProductName,      //!< \90»\95i\96¼
32                         vrProductVersion,   //!< \90»\95i\83o\81[\83W\83\87\83\93
33                         vrSpecialBuild);    //!< \83X\83y\83V\83\83\83\8b\83r\83\8b\83h\8fî\95ñ
34
35         //! BBS\83^\83C\83v
36         TGikoBBSType = (gbt2ch);
37         //! \83\8d\83O\83^\83C\83v
38         TGikoLogType = (glt2chNew, glt2chOld);
39         //! \83\81\83b\83Z\81[\83W\83A\83C\83R\83\93
40         TGikoMessageIcon = (gmiOK, gmiSAD, gmiNG, gmiWhat, gmiNone);
41         //! URL\83I\81[\83v\83\93\83u\83\89\83E\83U\83^\83C\83v
42         TGikoBrowserType = (gbtIE, gbtUserApp, gbtAuto);
43
44
45         TStrTokSeparator = set of Char;
46         TStrTokRec = record
47                 Str: string;
48                 Pos: Integer;
49         end;
50
51         //! \83C\83\93\83f\83b\83N\83X\83t\83@\83C\83\8b\83\8c\83R\81[\83h
52         TIndexRec = record
53                 FNo: Integer;
54                 FFileName: string;
55                 FTitle: string;
56                 FCount: Integer;
57                 FSize: Integer;
58 //              FRoundNo: Integer;
59                 FRoundDate: TDateTime;
60                 FLastModified: TDateTime;
61                 FKokomade: Integer;
62                 FNewReceive: Integer;
63                 FMishiyou: Boolean;     //!< \96¢\8eg\97p
64                 FUnRead: Boolean;
65                 FScrollTop: Integer;
66                 //Index Ver 1.01
67                 FAllResCount: Integer;
68                 FNewResCount: Integer;
69                 FAgeSage: TGikoAgeSage;
70         end;
71
72         //! \83T\83u\83W\83F\83N\83g\83\8c\83R\81[\83h
73         TSubjectRec = record
74                 FFileName: string;
75                 FTitle: string;
76                 FCount: Integer;
77         end;
78
79         //! \83\8c\83X\83\8c\83R\81[\83h\82Ö\82Ì\83|\83C\83\93\83^
80         PResRec = ^TResRec;
81
82         //! \83\8c\83X\83\8c\83R\81[\83h
83         TResRec = record
84                 FTitle: string;
85                 FMailTo: string;
86                 FName: string;
87                 FDateTime: string;
88                 FBody: string;
89                 FType: TGikoLogType;
90         end;
91
92         //! URLPath\83\8c\83R\81[\83h
93         TPathRec = record
94                 FBBS: string;                           //!< BBSID
95                 FKey: string;                           //!< ThreadID
96                 FSt: Int64;                               //!< \8aJ\8en\83\8c\83X\94Ô
97                 FTo: Int64;                               //!< \8fI\97¹\83\8c\83X\94Ô
98                 FFirst: Boolean;                //!< >>1\82Ì\95\\8e¦
99                 FStBegin: Boolean;      //!< 1\81`\95\\8e¦
100                 FToEnd: Boolean;                //!< \81`\8dÅ\8cã\82Ü\82Å\95\\8e¦
101                 FDone: Boolean;                 //!< \90¬\8c÷
102                 FNoParam: Boolean;  //!< \83\8c\83X\94Ô\83p\83\89\83\81\81[\83^\82È\82µ
103         end;
104
105         TGikoSys = class(TObject)
106         private
107                 { Private \90é\8c¾ }
108                 FSetting: TSetting;
109                 FDolib: TDolib;
110                 FAWKStr: TAWKStr;
111                 FResRange : Longint;
112                 FBayesian       : TGikoBayesian;        //!< \83x\83C\83W\83A\83\93\83t\83B\83\8b\83^
113                 FVersion : String;                    //!< \83t\83@\83C\83\8b\83o\81[\83W\83\87\83\93
114                 FGikoMessage: TGikoMessage;
115         FBelib: TBelib;
116                 //! \82 \82é\83Z\83p\83\8c\81[\83^\82Å\8bæ\90Ø\82ç\82ê\82½\95\8e\9a\97ñ\82©\82ç\82\8e\94Ô\96Ú\82Ì\95\8e\9a\97ñ\82ð\8eæ\82è\8fo\82·
117                 function ChooseString(const Text, Separator: string; Index: integer): string;
118         //! \88ê\8e\9e\83t\83@\83C\83\8b\82©\82ç\82Ì\95\9c\8b\8c
119         procedure RestoreThreadData(Board: TBoard);
120         public
121                 { Public \90é\8c¾ }
122                 FAbon : TAbon;
123                 FSelectResFilter : TAbon;
124                 //FBoardURLList: TStringList;
125                 constructor Create;
126
127                 destructor Destroy; override;
128                 property ResRange : Longint read FResRange write FResRange;
129                 //! \83o\81[\83W\83\87\83\93\8fî\95ñ
130                 property Version : String read FVersion;
131                 function IsNumeric(s: string): boolean;
132                 function IsFloat(s: string): boolean;
133                 function DirectoryExistsEx(const Name: string): Boolean;
134                 function ForceDirectoriesEx(Dir: string): Boolean;
135
136                 function GetBoardFileName: string;
137                 function GetCustomBoardFileName: string;
138                 function GetHtmlTempFileName: string;
139                 function GetAppDir: string;
140                 function GetTempFolder: string;
141                 function GetSentFileName: string;
142                 function GetConfigDir: string;
143         function GetNGWordsDir: string;
144                 function GetSkinDir: string;
145                 function GetSkinHeaderFileName: string;
146                 function GetSkinFooterFileName: string;
147                 function GetSkinResFileName: string;
148                 function GetSkinNewResFileName: string;
149                 function GetSkinBookmarkFileName: string;
150                 function GetSkinNewmarkFileName: string;
151                 function GetStyleSheetDir: string;
152                 function GetOutBoxFileName: string;
153                 function GetUserAgent: string;
154                                 function GetSambaFileName : string;
155
156                 function GetMainKeyFileName : String;
157                 function GetEditorKeyFileName: String;
158                 function GetInputAssistFileName: String;
159                 procedure ReadSubjectFile(Board: TBoard);
160                 procedure CreateThreadDat(Board: TBoard);
161                 procedure WriteThreadDat(Board: TBoard);
162                 function ParseIndexLine(Line: string): TIndexRec;
163                 procedure GetFileList(Path: string; Mask: string; var List: TStringList; SubDir: Boolean; IsPathAdd: Boolean); overload;
164                 procedure GetFileList(Path: string; Mask: string; var List: TStringList; IsPathAdd: Boolean); overload;//\83T\83u\83t\83H\83\8b\83_\82Í\8c\9f\8dõ\82µ\82È\82¢
165                 procedure GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
166
167                 function DivideSubject(Line: string): TSubjectRec;
168                 property Setting: TSetting read FSetting write FSetting;
169                 property Dolib: TDolib read FDolib write FDolib;
170                 property Belib: TBelib read FBelib write FBelib;
171
172                 function UrlToID(url: string): string;
173                 function UrlToServer(url: string): string;
174
175                 function StrTokFirst(const s:string; const sep:TStrTokSeparator; var Rec:TStrTokRec):string;
176                 function StrTokNext(const sep:TStrTokSeparator; var Rec:TStrTokRec): string;
177
178                 function GetFileSize(FileName : string) : longint;
179                 function GetFileLineCount(FileName : string): longint;
180                 function IntToDateTime(val: Int64): TDateTime;
181                 function DateTimeToInt(ADate: TDateTime): Int64;
182
183                 function ReadThreadFile(FileName: string; Line: Integer): string;
184
185                 procedure MenuFont(Font: TFont);
186
187 //              function RemoveToken(var s:string; const delimiter:string):string;
188                 function GetTokenIndex(s: string; delimiter: string; index: Integer): string;
189
190                 function GetShortName(const LongName: string; ALength: integer): string;
191                 function TrimThreadTitle(const SrcTitle: string): string;
192                 function BoolToInt(b: Boolean): Integer;
193                 function IntToBool(i: Integer): Boolean;
194                 function GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
195                 procedure LoadKeySetting(ActionList: TActionList; FileName: String);
196                 procedure SaveKeySetting(ActionList: TActionList; FileName: String);
197                 procedure CreateProcess(const AppPath: string; const Param: string);
198                 procedure OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
199                 function HTMLDecode(const AStr: String): String;
200                 function GetHRefText(s: string): string;
201                 function Is2chHost(Host: string): Boolean;
202                 function Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
203                 function Parse2chURL2(URL: string): TPathRec;
204                 procedure ParseURI(const URL : string; var Protocol, Host, Path, Document, Port, Bookmark: string);
205                 function GetVersionBuild: Integer;
206                 function        GetBrowsableThreadURL( inURL : string ) : string;
207                 function        GetThreadURL2BoardURL( inURL : string ) : string;
208                 function        Get2chThreadURL2BoardURL( inURL : string ) : string;
209                 function        Get2chBrowsableThreadURL( inURL : string ) : string;
210                 function        Get2chBoard2ThreadURL( inBoard : TBoard; inKey : string ) : string;
211                 procedure ListBoardFile;
212                 procedure ReadBoardFile( bbs : TBBS );
213
214                 function        GetUnknownCategory : TCategory;
215                 function        GetUnknownBoard( inPlugIn : TBoardPlugIn; inURL : string ) : TBoard;
216
217                 procedure GetPopupResNumber(URL : string; var stRes, endRes : Int64);
218
219                 property Bayesian : TGikoBayesian read FBayesian write FBayesian;
220         function CreateResAnchor(var Numbers: TStringList; ThreadItem: TThreadItem; limited: Integer):string;
221                 procedure GetSameIDRes(const AID : string; ThreadItem: TThreadItem;var body: TStringList); overload;
222                 procedure GetSameIDRes(AIDNum : Integer; ThreadItem: TThreadItem;var body: TStringList); overload;
223         function GetResID(AIDNum: Integer; ThreadItem: TThreadItem): String;
224         function ExtructResID(ADateStr: String): String;
225                 //! \92P\8cê\89ð\90Í
226                 procedure SpamCountWord( const text : string; wordCount : TWordCount );
227                 //! \8aw\8fK\83N\83\8a\83A
228                 procedure SpamForget( wordCount : TWordCount; isSpam : Boolean );
229                 //! \83X\83p\83\80\8aw\8fK
230                 procedure SpamLearn( wordCount : TWordCount; isSpam : Boolean );
231                 //! \83X\83p\83\80\93x\90\94
232                 function SpamParse( const text : string; wordCount : TWordCount ) : Extended;
233
234                 //! \88ø\90\94\82É\91\97\82ç\82ê\82Ä\82«\82½\93ú\95t/ID\95\94\82ÉBE\82Ì\95\8e\9a\97ñ\82ª\82 \82Á\82½\82ç\81A\83v\83\8d\83t\83@\83C\83\8b\82Ö\82Ì\83\8a\83\93\83N\82ð\92Ç\89Á
235                 function AddBeProfileLink(AID : string; ANum: Integer): string;
236                 //! \83o\81[\83W\83\87\83\93\8fî\95ñ\82Ì\8eæ\93¾
237                 function GetVersionInfo(KeyWord: TVerResourceKey): string;
238                 //! Plugin\82Ì\8fî\95ñ\82Ì\8eæ\93¾
239                 function GetPluginsInfo(): string;
240                 //! IE\82Ì\83o\81[\83W\83\87\83\93\8fî\95ñ\82Ì\8eæ\93¾
241                 function GetIEVersion: string;
242                 function SetUserOptionalStyle(): string;
243                 //! \83M\83R\83i\83r\82Ì\83\81\83b\83Z\81[\83W\82ð\90Ý\92è\82·\82é
244                 procedure SetGikoMessage;
245                 //! \83M\83R\83i\83r\82Ì\83\81\83b\83Z\81[\83W\82ð\8eæ\93¾\82·\82é
246                 function GetGikoMessage(MesType: TGikoMessageListType): String;
247                 //! GMT\82Ì\8e\9e\8d\8f\82ðTDateTime\82É\95Ï\8a·\82·\82é
248                 function  DateStrToDateTime(const DateStr: string): TDateTime;
249         //! User32.dll\82ª\97\98\97p\82Å\82«\82é\82©
250         function CanUser32DLL: Boolean;
251         //! OE\88ø\97p\95\84\8eæ\93¾
252         function GetOEIndentChar : string;
253         //! \92u\8a·\90Ý\92è\83t\83@\83C\83\8b\8eæ\93¾
254         function GetReplaceFileName: String;
255         //! \83C\83\93\83f\83b\83N\83X\82É\82È\82¢dat\81i\82Í\82®\82êdat\81j\82Ì\92Ç\89Á
256         procedure AddOutofIndexDat(Board: TBoard; DatList: TStringList; AllCreate: boolean = True);
257         //! \83t\83@\83C\83\8b\96¼\82©\82ç\82Ì\83X\83\8c\83b\83h\8dì\90¬\93ú\82Ì\8eæ\93¾
258         function GetCreateDateFromName(FileName: String): TDateTime;
259         function GetExtpreviewFileName: String;
260
261         procedure ShowRefCount(msg: String; unk: IUnknown);
262         //! \96`\8c¯\82Ì\8f\91Cookie\8eæ\93¾
263         function GetBoukenCookie(AURL: String): String;
264         //! \96`\8c¯\82Ì\8f\91Cookie\90Ý\92è
265         procedure SetBoukenCookie(ACookieValue, ADomain: String);
266         //! \96`\8c¯\82Ì\8f\91Cookie\8dí\8f\9c
267         procedure DelBoukenCookie(ADomain: String);
268         //! \96`\8c¯\82Ì\8f\91Domain\88ê\97\97\8eæ\93¾
269         procedure GetBoukenDomain(var ADomain: TStringList);
270         //! \96`\8c¯\82Ì\8f\91\83h\83\81\83C\83\93\96¼Cookie\8eæ\93¾
271         function GetBouken(AURL: String; var Domain: String): String;
272         end;
273
274 var
275         GikoSys: TGikoSys;
276 const
277         //LENGTH_RESTITLE                       = 40;
278         ZERO_DATE: Integer      = 25569;
279         BETA_VERSION_NAME_E = 'beta';
280         BETA_VERSION_NAME_J = 'ÊÞÀ';
281         BETA_VERSION                            = 68;
282         BETA_VERSION_BUILD      = '';                           //!< debug\94Å\82È\82Ç
283         APP_NAME                                                = 'gikoNavi';
284         BE_PHP_URL = 'http://be.2ch.net/test/p.php?i=';
285
286
287 implementation
288
289 uses
290         Giko, RoundData, Favorite, Registry, HTMLCreate, MojuUtils, Sort, YofUtils,
291         IniFiles, DateUtils, SkinFiles;
292
293 const
294         FOLDER_INDEX_VERSION                                    = '1.01';
295         USER_AGENT                                                                              = 'Monazilla';
296         DEFAULT_NGWORD_FILE_NAME : String = 'NGword.txt';
297         NGWORDs_DIR_NAME : String               = 'NGwords';
298
299         READ_PATH: string =                     '/test/read.cgi/';
300     HTML_READ_PATH: string =        '/test/read.html/';
301         OLD_READ_PATH: string =         '/test/read.cgi?';
302         KAKO_PATH: string =                     '/kako/';
303
304         KeyWordStr: array [TVerResourceKey] of String = (
305                   'Comments',
306                   'CompanyName',
307                   'FileDescription',
308                   'FileVersion',
309                   'InternalName',
310                   'LegalCopyright',
311                   'LegalTrademarks',
312                   'OriginalFilename',
313                   'PrivateBuild',
314                   'ProductName',
315                   'ProductVersion',
316                   'SpecialBuild');
317
318 // *************************************************************************
319 //! GikoSys\83R\83\93\83X\83g\83\89\83N\83^
320 // *************************************************************************
321 constructor TGikoSys.Create;
322 begin
323     Inherited;
324         FSetting := TSetting.Create;
325         FDolib := TDolib.Create;
326     FBelib := TBelib.Create;
327         FAWKStr := TAWKStr.Create(nil);
328         if DirectoryExists(GetConfigDir) = false then begin
329                 CreateDir(GetConfigDir);
330         end;
331         FAbon := TAbon.Create;
332     FAbon.IgnoreKana := FSetting.IgnoreKana;
333         FAbon.Setroot(GetConfigDir+NGWORDs_DIR_NAME);
334         FAbon.GoHome;
335         FAbon.ReturnNGwordLineNum := FSetting.ShowNGLinesNum;
336         FAbon.SetNGResAnchor := FSetting.AddResAnchor;
337         FAbon.DeleteSyria := FSetting.DeleteSyria;
338         FAbon.Deleterlo := FSetting.AbonDeleterlo;
339         FAbon.Replaceul := FSetting.AbonReplaceul;
340         FAbon.AbonPopupRes := FSetting.PopUpAbon;
341
342         FSelectResFilter := TAbon.Create;
343     FSelectResFilter.IgnoreKana := True;
344         // \8di\82è\8d\9e\82Þ\82Æ\82«\82Í\8bÉ\97Í\88ê\97\97\82ª\8c©\82ç\82ê\82é\82Ù\82¤\82ª\82¢\82¢\82Ì\82Å\91¼\82Í\8a®\91S\82É\8dí\8f\9c
345         FSelectResFilter.AbonString := '';
346     //
347         ResRange := FSetting.ResRange;
348         FVersion := Trim(GetVersionInfo(vrFileVersion));
349         FBayesian := TGikoBayesian.Create;
350         //FBoardURLList := TStringList.Create;
351         //\83\81\83b\83Z\81[\83W\82Ì\8dì\90¬
352         FGikoMessage := TGikoMessage.Create;
353 end;
354
355 // *************************************************************************
356 //! GikoSys\83f\83X\83g\83\89\83N\83^
357 // *************************************************************************
358 destructor TGikoSys.Destroy;
359 var
360         i: Integer;
361         FileList: TStringList;
362 begin
363         //\83e\83\93\83|\83\89\83\8aHTML\82ð\8dí\8f\9c
364         FileList := TStringList.Create;
365         try
366         FileList.BeginUpdate;
367                 GetFileList(GetTempFolder, '*.html', FileList, False, True);
368         FileList.EndUpdate;
369                 for i := 0 to FileList.Count - 1 do begin
370                         DeleteFile(FileList[i]);
371                 end;
372         finally
373                 FileList.Free;
374         end;
375     FreeAndNil(FGikoMessage);
376         FreeAndNil(FBayesian);
377         FreeAndNil(FSelectResFilter);
378         FreeAndNil(FAbon);
379         FreeAndNil(FAWKStr);
380     FreeAndNil(FBelib);
381         FreeAndNil(FDolib);
382         FreeAndNil(FSetting);
383         inherited;
384 end;
385
386 {!
387 \brief \95\8e\9a\97ñ\90\94\8e\9a\83`\83F\83b\83N
388 \param s \83`\83F\83b\83N\82·\82é\95\8e\9a\97ñ
389 \return s \82ª\95\84\8d\86\95t\82«\90®\90\94\82Æ\82µ\82Ä\94F\8e¯\89Â\94\\82È\82ç True
390 }
391 {$HINTS OFF}
392 function TGikoSys.IsNumeric(s: string): boolean;
393 var
394         e: integer;
395         v: integer;
396 begin
397         Val(s, v, e);
398         Result := e = 0;
399 end;
400 {$HINTS ON}
401
402 {!
403 \brief \95\8e\9a\97ñ\95\82\93®\8f¬\90\94\93_\90\94\8e\9a\83`\83F\83b\83N
404 \param s \83`\83F\83b\83N\82·\82é\95\8e\9a\97ñ
405 \return s \82ª\95\84\8d\86\95t\82«\95\82\93®\8f¬\90\94\82Æ\82µ\82Ä\94F\8e¯\89Â\94\\82È\82ç True
406 }
407 function TGikoSys.IsFloat(s: string): boolean;
408 var
409         v: Extended;
410 begin
411         Result := TextToFloat(PChar(s), v, fvExtended);
412 end;
413
414 // *************************************************************************
415 //! \83{\81[\83h\83t\83@\83C\83\8b\96¼\8eæ\93¾\81i\83p\83X\81{\83t\83@\83C\83\8b\96¼\81j
416 // *************************************************************************
417 function TGikoSys.GetBoardFileName: string;
418 begin
419         Result := Setting.GetBoardFileName;
420 end;
421
422 // *************************************************************************
423 //! \83{\81[\83h\83t\83@\83C\83\8b\96¼\8eæ\93¾\81i\83p\83X\81{\83t\83@\83C\83\8b\96¼\81j
424 // *************************************************************************
425 function TGikoSys.GetCustomBoardFileName: string;
426 begin
427         Result := Setting.GetCustomBoardFileName;
428 end;
429
430 // *************************************************************************
431 //! \83e\83\93\83|\83\89\83\8a\83t\83H\83\8b\83_\81[\96¼\8eæ\93¾
432 // *************************************************************************
433 function TGikoSys.GetHtmlTempFileName: string;
434 begin
435         Result := Setting.GetHtmlTempFileName;
436 end;
437
438
439 // *************************************************************************
440 //! \8eÀ\8ds\83t\83@\83C\83\8b\83t\83H\83\8b\83_\8eæ\93¾
441 // *************************************************************************
442 function TGikoSys.GetAppDir: string;
443 begin
444         Result := Setting.GetAppDir;
445 end;
446
447 // *************************************************************************
448 //! TempHtml\83t\83@\83C\83\8b\96¼\8eæ\93¾\81i\83p\83X\81{\83t\83@\83C\83\8b\96¼\81j
449 // *************************************************************************
450 function TGikoSys.GetTempFolder: string;
451 begin
452         Result := Setting.GetTempFolder;
453 end;
454
455 // *************************************************************************
456 //! sent.ini\83t\83@\83C\83\8b\96¼\8eæ\93¾\81i\83p\83X\81{\83t\83@\83C\83\8b\96¼\81j
457 // *************************************************************************)
458 function TGikoSys.GetSentFileName: string;
459 begin
460         Result := Setting.GetSentFileName;
461 end;
462
463 // *************************************************************************
464 //! outbox.ini\83t\83@\83C\83\8b\96¼\8eæ\93¾\81i\83p\83X\81{\83t\83@\83C\83\8b\96¼\81j
465 // *************************************************************************
466 function TGikoSys.GetOutBoxFileName: string;
467 begin
468         Result := Setting.GetOutBoxFileName;
469 end;
470
471 // *************************************************************************
472 //! Config\83t\83H\83\8b\83_\8eæ\93¾
473 // *************************************************************************
474 function TGikoSys.GetConfigDir: string;
475 begin
476         Result := Setting.GetConfigDir;
477 end;
478
479 function TGikoSys.GetNGWordsDir: string;
480 begin
481         Result := Setting.GetConfigDir + NGWORDs_DIR_NAME;
482 end;
483
484
485 //! \83X\83^\83C\83\8b\83V\81[\83g\83t\83H\83\8b\83_
486 function TGikoSys.GetStyleSheetDir: string;
487 begin
488         Result := Setting.GetStyleSheetDir;
489 end;
490
491 //! \83X\83L\83\93\83t\83H\83\8b\83_
492 function TGikoSys.GetSkinDir: string;
493 begin
494         Result := Setting.GetSkinDir;
495 end;
496
497 //! Skin:\83w\83b\83_\82Ì\83t\83@\83C\83\8b\96¼
498 function TGikoSys.GetSkinHeaderFileName: string;
499 begin
500         Result := Setting.SkinFiles.GetSkinHeaderFileName;
501 end;
502
503 //! Skin:\83t\83b\83^\82Ì\83t\83@\83C\83\8b\96¼
504 function TGikoSys.GetSkinFooterFileName: string;
505 begin
506         Result := Setting.SkinFiles.GetSkinFooterFileName;
507 end;
508
509 //! Skin:\90V\92\85\83\8c\83X\82Ì\83t\83@\83C\83\8b\96¼
510 function TGikoSys.GetSkinNewResFileName: string;
511 begin
512         Result := Setting.SkinFiles.GetSkinNewResFileName;
513 end;
514
515 //! Skin:\94ñ\90V\92\85\83\8c\83X\82Ì\83t\83@\83C\83\8b\96¼
516 function TGikoSys.GetSkinResFileName: string;
517 begin
518         Result := Setting.SkinFiles.GetSkinResFileName;
519 end;
520
521 //! Skin:\82µ\82¨\82è(\82±\82±\82Ü\82Å\93Ç\82ñ\82¾)\82Ì\83t\83@\83C\83\8b\96¼
522 function TGikoSys.GetSkinBookmarkFileName: string;
523 begin
524         Result := Setting.SkinFiles.GetSkinBookmarkFileName;
525 end;
526
527 //! Skin:\82µ\82¨\82è(\90V\92\85\83\8c\83X)\82Ì\83t\83@\83C\83\8b\96¼
528 function TGikoSys.GetSkinNewmarkFileName: string;
529 begin
530         Result := Setting.SkinFiles.GetSkinNewmarkFileName;
531 end;
532
533 //! UserAgent\8eæ\93¾
534 function TGikoSys.GetUserAgent: string;
535 begin
536         if Dolib.Connected then begin
537                 Result := Format('%s %s/%s%d/%s', [
538                                                                 Dolib.UserAgent,
539                                                                 APP_NAME,
540                                                                 BETA_VERSION_NAME_E,
541                                                                 BETA_VERSION,
542                                                                 Version]);
543         end else begin
544                 Result := Format('%s/%s %s/%s%d/%s', [
545                                                                 USER_AGENT,
546                                                                 Dolib.Version,
547                                                                 APP_NAME,
548                                                                 BETA_VERSION_NAME_E,
549                                                                 BETA_VERSION,
550                                                                 Version]);
551         end;
552 end;
553
554 {!
555 \brief \8co\89ß\95b\82ð TDateTime \82É\95Ï\8a·
556 \param val 1970/1/1/ 00:00:00 \82©\82ç\82Ì\8co\89ß\95b
557 \return val \82ð\8e¦\82· TDateTime
558 }
559 function TGikoSys.IntToDateTime(val: Int64): TDateTime;
560 begin
561         Result := ZERO_DATE + val / 86400.0;
562 end;
563
564 {!
565 \brief TDateTime \82ð\8co\89ß\95b\82É\95Ï\8a·
566 \param ADate \95Ï\8a·\82·\82é\8e\9e\8d\8f
567 \return 1970/1/1/ 00:00:00 \82©\82ç\82Ì\8co\89ß\95b
568 }
569 function TGikoSys.DateTimeToInt(ADate: TDateTime): Int64;
570 begin
571         Result := Trunc((ADate - ZERO_DATE) * 86400);
572 end;
573
574
575 {!
576 \brief Subject\83t\83@\83C\83\8bRead
577 \param Board \83X\83\8c\88ê\97\97\82ð\8eæ\93¾\82·\82é\94Â
578 }
579 procedure TGikoSys.ReadSubjectFile(Board: TBoard);
580 var
581         ThreadItem: TThreadItem;
582         FileName: string;
583         FileList: TStringList;
584         Index: Integer;
585         sl: TStringList;
586         i: Integer;
587         Rec: TIndexRec;
588         UnRead: Integer;
589         usePlugIn : Boolean;
590         islog : Boolean;
591     urlHead: String;
592     datFileCheck: Boolean;
593         {*
594         FavoThreadItem : TFavoriteThreadItem;
595         Node: TTreeNode;
596         *}
597 {$IFDEF DEBUG}
598     st, rt: Cardinal;
599 {$ENDIF}
600 begin
601 {$IFDEF DEBUG}
602         st := GetTickCount;
603 {$ENDIF}
604         if Board.IsThreadDatRead then
605                 Exit;
606         Board.Clear;
607         UnRead := 0;
608         usePlugIn := Board.IsBoardPlugInAvailable;
609         //server :=  UrlToServer( Board.URL );
610     // \83X\83\8c\83b\83h\82Å\8b¤\92Ê\82ÌURL\95\94
611     if Board.is2ch then begin
612         urlHead := UrlToServer( Board.URL ) + 'test/read.cgi/' + Board.BBSID + '/';
613     end else begin
614         urlHead := UrlToServer( Board.URL ) + 'test/read.cgi?bbs=' + Board.BBSID + '&key=';
615     end;
616
617         FileName := Board.GetFolderIndexFileName;
618
619     //
620     datFileCheck := (Setting.CheckDatFile) or (not FileExists(FileName));
621     if (datFileCheck) then begin
622         FileList := TStringList.Create;
623         FileList.Sorted := True;
624         FileList.BeginUpdate;
625         //IsLogFile\97pDAT\83t\83@\83C\83\8b\83\8a\83X\83g
626         GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False);
627         FileList.EndUpdate;
628     end;
629
630         // \8fd\95¡\82ð\96h\82®
631         Board.BeginUpdate;
632         Board.Sorted := True;
633         sl := TStringList.Create;
634         try
635                 if FileExists(FileName) then begin
636                         sl.LoadFromFile(FileName);
637                         //\82Q\8ds\96Ú\82©\82ç\81i\82P\8ds\96Ú\82Í\83o\81[\83W\83\87\83\93\81j
638                         for i := sl.Count - 1 downto 1 do begin
639                                 Rec := ParseIndexLine(sl[i]);
640                 if (datFileCheck) then begin
641                                 islog := FileList.Find( Rec.FFileName, Index );
642                 end else begin
643                     islog := (Rec.FSize <> 0) and (Rec.FCount <> 0);
644                 end;
645                                 if usePlugIn then
646                                         ThreadItem := TThreadItem.Create(
647                                                         Board.BoardPlugIn,
648                                                         Board,
649                                                         Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), Rec.FFileName ) )
650                                 else begin
651                                         if Board.is2ch then begin
652                                                 ThreadItem := TThreadItem.Create(
653                                                         nil,
654                                                         Board,
655                                                         urlHead + ChangeFileExt( Rec.FFileName, '' ) + '/l50',
656                                                         islog,
657                                                         Rec.FFileName
658                                                         );
659                                         end else begin
660                                                 ThreadItem := TThreadItem.Create(
661                                                         nil,
662                                                         Board,
663                                                         urlHead + ChangeFileExt( Rec.FFileName, '' ) + '&ls=50',
664                                                         islog,
665                                                         Rec.FFileName
666                                                         );
667                                         end;
668                                 end;
669
670                                 //ThreadItem.BeginUpdate;
671                                 if (datFileCheck) and (islog) then
672                                         FileList.Delete( Index );
673
674                                 ThreadItem.No := Rec.FNo;
675                                 ThreadItem.FileName := Rec.FFileName;
676                                 ThreadItem.Title := MojuUtils.UnSanitize(Rec.FTitle);
677                                 ThreadItem.Count := Rec.FCount;
678                                 ThreadItem.Size := Rec.FSize;
679                                 ThreadItem.RoundDate := Rec.FRoundDate;
680                                 ThreadItem.LastModified := Rec.FLastModified;
681                                 ThreadItem.Kokomade := Rec.FKokomade;
682                                 ThreadItem.NewReceive := Rec.FNewReceive;
683                                 ThreadItem.UnRead := Rec.FUnRead;
684                                 ThreadItem.ScrollTop := Rec.FScrollTop;
685                                 ThreadItem.AllResCount := Rec.FAllResCount;
686                                 ThreadItem.NewResCount := Rec.FNewResCount;
687                                 ThreadItem.AgeSage := Rec.FAgeSage;
688                                 ThreadItem.ParentBoard := Board;
689                                 {* \82¨\8bC\82É\93ü\82è\91å\97Ê\90\90¬\83R\81[\83h *}
690                                 {*
691                                 FavoThreadItem := TFavoriteThreadItem.Create( ThreadItem.URL, ThreadItem.Title, ThreadItem );
692                                 Node := FavoriteDM.TreeView.Items.AddChildObject( FavoriteDM.TreeView.Items.Item[0], ThreadItem.Title, FavoThreadItem);
693                                 *}
694
695                                 //ThreadItem.EndUpdate;
696                                 Board.Add(ThreadItem);
697
698                                 if (ThreadItem.UnRead) and (ThreadItem.IsLogFile) then
699                                         Inc(UnRead);
700                         end;
701                 end;
702
703                 if UnRead <> Board.UnRead then
704                         Board.UnRead := UnRead;
705
706         if (datFileCheck) then begin
707                     //\83C\83\93\83f\83b\83N\83X\82É\96³\82©\82Á\82½\83\8d\83O\82ð\92Ç\89Á\81i\95\85\82ê\83C\83\93\83f\83b\83N\83X\91Î\89\9e\81j
708             AddOutofIndexDat(Board, FileList);
709         end;
710                 Board.EndUpdate;
711
712         //\91O\89ñ\88Ù\8fí\8fI\97¹\8e\9e\83`\83F\83b\83N
713         RestoreThreadData( Board );
714         finally
715                 sl.Free;
716         if (datFileCheck) then begin
717                 FileList.Free;
718         end;
719                 Board.Sorted := False;
720         end;
721         Board.IsThreadDatRead := True;
722 {$IFDEF DEBUG}
723         rt := GetTickCount - st;
724         Writeln('Read Done.' + Board.Title + ':' + IntToStr(rt) + ' ms');
725 {$ENDIF}
726 end;
727 {!
728 \brief \83C\83\93\83f\83b\83N\83X\82É\82È\82¢dat\81i\82Í\82®\82êdat\81j\82Ì\92Ç\89Á
729 \param Board \92Ç\89Á\82·\82é\94Â
730 \param DatList  dat\83t\83@\83C\83\8b\96¼
731 }
732 procedure TGikoSys.AddOutofIndexDat(Board: TBoard; DatList: TStringList; AllCreate: Boolean = True);
733 var
734     i : Integer;
735     Boardpath,FileName : String;
736     ResRec: TResRec;
737     ThreadItem: TThreadItem;
738     create: Boolean;
739 begin
740     create := False;
741     Boardpath := ExtractFilePath(Board.GetFolderIndexFileName);
742     //\83C\83\93\83f\83b\83N\83X\82É\96³\82©\82Á\82½\83\8d\83O\82ð\92Ç\89Á\81i\95\85\82ê\83C\83\93\83f\83b\83N\83X\91Î\89\9e\81j
743     for i := 0 to DatList.Count - 1 do begin
744         FileName := Boardpath + DatList[i];
745         ThreadItem := nil;
746         if (not AllCreate) then begin
747             create := False;
748             ThreadItem := Board.FindThreadFromFileName(DatList[i]);
749             if (ThreadItem = nil) then begin
750                 create := True;
751             end else begin
752                 if Board.IsBoardPlugInAvailable then begin
753                     THTMLCreate.DivideStrLine(Board.BoardPlugIn.GetDat( DWORD( ThreadItem ), 1 ), @ResRec);
754                 end else begin
755                     THTMLCreate.DivideStrLine(ReadThreadFile(FileName, 1), @ResRec);
756                 end;
757             end;
758         end;
759         if (ThreadItem = nil) then begin
760             if Board.IsBoardPlugInAvailable then begin
761                 ThreadItem := TThreadItem.Create(
762                     Board.BoardPlugIn,
763                     Board,
764                     Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), DatList[i] ) );
765                 THTMLCreate.DivideStrLine(Board.BoardPlugIn.GetDat( DWORD( ThreadItem ), 1 ), @ResRec);
766             end else begin
767                 ThreadItem := TThreadItem.Create(
768                     nil,
769                     Board,
770                     Get2chBoard2ThreadURL( Board, ChangeFileExt( DatList[i], '' ) ) );
771                 THTMLCreate.DivideStrLine(ReadThreadFile(FileName, 1), @ResRec);
772             end;
773         end;
774         
775
776         ThreadItem.BeginUpdate;
777         ThreadItem.FileName := DatList[i];
778         //ThreadItem.FilePath := FileName;
779         ThreadItem.No := Board.Count + 1;
780         ThreadItem.Title := ResRec.FTitle;
781         ThreadItem.Count := GetFileLineCount(FileName);
782         ThreadItem.AllResCount := ThreadItem.Count;
783         ThreadItem.NewResCount := ThreadItem.Count;
784         ThreadItem.Size := GetFileSize(FileName) - ThreadItem.Count;//1byte\82¸\82ê\82é\82Æ\82«\82ª\82 \82é\82¯\82Ç\82»\82ê\82Í\82 \82«\82ç\82ß\82é
785         ThreadItem.RoundDate := FileDateToDateTime( FileAge( FileName ) );
786         ThreadItem.LastModified := ThreadItem.RoundDate;
787         ThreadItem.Kokomade := -1;
788         ThreadItem.NewReceive := 0;
789         ThreadItem.ParentBoard := Board;
790         ThreadItem.IsLogFile := True;
791         ThreadItem.Round := False;
792         ThreadItem.UnRead := False;
793         ThreadItem.ScrollTop := 0;
794         ThreadItem.AgeSage := gasNone;
795         ThreadItem.EndUpdate;
796         if (AllCreate) or (create) then begin
797             Board.Add(ThreadItem);
798         end;
799     end;
800 end;
801 {!
802 \brief \83X\83\8c\83b\83h\83C\83\93\83f\83b\83N\83X\83t\83@\83C\83\8b(Folder.idx)\8dì\90¬
803 \param Board Folder.idx \82ð\8dì\90¬\82·\82é\94Â
804 }
805 procedure TGikoSys.CreateThreadDat(Board: TBoard);
806 var
807         i: integer;
808         s: string;
809         SubjectList: TStringList;
810         sl: TStringList;
811         Rec: TSubjectRec;
812         FileName: string;
813         cnt: Integer;
814 begin
815         if not FileExists(Board.GetSubjectFileName) then Exit;
816         FileName := Board.GetFolderIndexFileName;
817
818         SubjectList := TStringList.Create;
819         try
820                 SubjectList.LoadFromFile(Board.GetSubjectFileName);
821                 sl := TStringList.Create;
822                 try
823                         cnt := 1;
824                         sl.BeginUpdate;
825                         sl.Add(FOLDER_INDEX_VERSION);
826                         for i := 0 to SubjectList.Count - 1 do begin
827                                 Rec := DivideSubject(SubjectList[i]);
828
829                                 if (Trim(Rec.FFileName) = '') or (Trim(Rec.FTitle) = '') then
830                                         Continue;
831
832                                 {s := Format('%x', [cnt]) + #1                                  //\94Ô\8d\86
833                                          + Rec.FFileName + #1                                                           //\83t\83@\83C\83\8b\96¼
834                                          + Rec.FTitle + #1                                                                      //\83^\83C\83g\83\8b
835                                          + Format('%x', [Rec.FCount]) + #1      //\83J\83E\83\93\83g
836                                          + Format('%x', [0]) + #1                                               //size
837                                          + Format('%x', [0]) + #1                                               //RoundDate
838                                          + Format('%x', [0]) + #1                                               //LastModified
839                                          + Format('%x', [0]) + #1                                               //Kokomade
840                                          + Format('%x', [0]) + #1                                               //NewReceive
841                                          + '0' + #1                                                                                             //\96¢\8eg\97p
842                                          + Format('%x', [0]) + #1                                               //UnRead
843                                          + Format('%x', [0]) + #1                                               //ScrollTop
844                                          + Format('%x', [Rec.FCount]) + #1      //AllResCount
845                                          + Format('%x', [0]) + #1                                               //NewResCount
846                                          + Format('%x', [0]);                                                           //AgeSage
847                                 }
848                                 s := Format('%x'#1'%s'#1'%s'#1'%x'#1'%x'#1'%x'#1'%x'#1'%x'#1'%x'#1 + 
849                                                         '%s'#1'%x'#1'%x'#1'%x'#1'%x'#1'%x',
850                                         [cnt,                   //\94Ô\8d\86
851                                          Rec.FFileName, //\83t\83@\83C\83\8b\96¼
852                                          MojuUtils.Sanitize(Rec.FTitle),    //\83^\83C\83g\83\8b
853                                          Rec.FCount,     //\83J\83E\83\93\83g
854                                          0,             //size
855                                          0,             //RoundDate
856                                          0,                             //LastModified
857                                          0,                             //Kokomade
858                                          0,                             //NewReceive
859                                          '0',                   //\96¢\8eg\97p
860                                          0,                             //UnRead
861                                          0,                             //ScrollTop
862                                          Rec.FCount,    //AllResCount
863                                          0,                             //NewResCount
864                                          0]             //AgeSage
865                                         );
866
867                                 sl.Add(s);
868                                 inc(cnt);
869                         end;
870                         sl.EndUpdate;
871                         sl.SaveToFile(FileName);
872                 finally
873                         sl.Free;
874                 end;
875         finally
876                 SubjectList.Free;
877         end;
878 end;
879
880 {!
881 \brief \83X\83\8c\83b\83h\83C\83\93\83f\83b\83N\83X(Thread.dat)\8f\91\82«\8d\9e\82Ý
882 \param Thread.dat \82ð\8dì\90¬\82·\82é\94Â
883 }
884 procedure TGikoSys.WriteThreadDat(Board: TBoard);
885 //const
886 //      Values: array[Boolean] of string = ('0', '1');
887 var
888         i: integer;
889         FileName: string;
890         sl: TStringList;
891         s: string;
892         TmpFileList: TStringList;
893 begin
894         if not Board.IsThreadDatRead then
895                 Exit;
896         FileName := Board.GetFolderIndexFileName;
897         ForceDirectoriesEx( ExtractFilePath( FileName ) );
898
899         sl := TStringList.Create;
900         TmpFileList := TStringList.Create;
901         TmpFileList.Sorted := true;
902         try
903         TmpFileList.BeginUpdate;
904                 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, false);
905         TmpFileList.EndUpdate;
906                 sl.BeginUpdate;
907                 sl.Add(FOLDER_INDEX_VERSION);
908
909                 // \83X\83\8c\94Ô\8d\86\95Û\91\82Ì\82½\82ß\83\\81[\83g
910                 Sort.SetSortNoFlag(true);
911                 Sort.SetSortOrder(true);
912                 Sort.SetSortIndex(0);
913                 //Sort.SortNonAcquiredCountFlag := GikoSys.Setting.NonAcquiredCount;
914                 Board.CustomSort(ThreadItemSortProc);
915
916                 for i := 0 to Board.Count - 1 do begin
917                         Board.Items[i].No := i + 1;
918                         s := Format('%x'#1'%s'#1'%s'#1'%x'#1'%x'#1'%x'#1'%x'#1'%x'#1'%x'#1 +
919                                                         '%s'#1'%x'#1'%x'#1'%x'#1'%x'#1'%x',
920                                         [Board.Items[i].No,                     //\94Ô\8d\86
921                                          Board.Items[i].FileName, //\83t\83@\83C\83\8b\96¼
922                      MojuUtils.Sanitize(Board.Items[i].Title),    //\83^\83C\83g\83\8b
923                                          Board.Items[i].Count,     //\83J\83E\83\93\83g
924                                          Board.Items[i].Size,             //size
925                                          DateTimeToInt(Board.Items[i].RoundDate),             //RoundDate
926                                          DateTimeToInt(Board.Items[i].LastModified),                            //LastModified
927                                          Board.Items[i].Kokomade,                               //Kokomade
928                                          Board.Items[i].NewReceive,                             //NewReceive
929                                          '0',                   //\96¢\8eg\97p
930                                          BoolToInt(Board.Items[i].UnRead),                              //UnRead
931                                          Board.Items[i].ScrollTop,                              //ScrollTop
932                                          Board.Items[i].AllResCount,    //AllResCount
933                                          Board.Items[i].NewResCount,                            //NewResCount
934                                          Ord(Board.Items[i].AgeSage)]             //AgeSage
935                                         );
936
937                         sl.Add(s);
938                 end;
939                 sl.EndUpdate;
940                 sl.SaveToFile(FileName);
941
942                 for i := 0 to TmpFileList.Count - 1 do begin
943                         DeleteFile(ExtractFilePath(Board.GetFolderIndexFileName) + TmpFileList[i]);
944                 end;
945
946         finally
947                 TmpFileList.Free;
948                 sl.Free;
949         end;
950 end;
951
952 {!
953 \brief Folder.idx \82ð 1 \8ds\89ð\8eß
954 \param Line Folder.idx \82ð\8d\\90¬\82·\82é 1 \8ds
955 \return \83X\83\8c\83b\83h\8fî\95ñ
956 }
957 function TGikoSys.ParseIndexLine(Line: string): TIndexRec;
958 begin
959         Result.FNo := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0);
960         Result.FFileName := MojuUtils.RemoveToken(Line, #1);
961         Result.FTitle := MojuUtils.UnSanitize(MojuUtils.RemoveToken(Line, #1));
962         Result.FCount := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0);
963         Result.FSize := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0);
964         Result.FRoundDate := IntToDateTime(StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), ZERO_DATE));
965         Result.FLastModified := IntToDateTime(StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), ZERO_DATE));
966         Result.FKokomade := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), -1);
967         Result.FNewReceive := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0);
968         MojuUtils.RemoveToken(Line, #1);//9: ;  //\96¢\8eg\97p
969         Result.FUnRead := IntToBool(StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0));
970         Result.FScrollTop := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0);
971         Result.FAllResCount := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0);
972         Result.FNewResCount := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0);
973         Result.FAgeSage := TGikoAgeSage(StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0));
974
975 end;
976
977 {!
978 \brief \8ew\92è\83t\83H\83\8b\83_\93à\82Ì\8ew\92è\83t\83@\83C\83\8b\88ê\97\97\82ð\8eæ\93¾\82·\82é
979 \param Path      \8bN\93_\82Æ\82È\82é\83t\83H\83\8b\83_\83p\83X
980 \param Mask      \83t\83@\83C\83\8b\96¼\82Ì\83}\83X\83N
981 \param List      OUT:\8eæ\93¾\82³\82ê\82½\83t\83@\83C\83\8b\96¼\88ê\97\97\82ª\95Ô\82é
982 \param SubDir    \92\86\82Ì\83t\83H\83\8b\83_\82Ü\82Å\8dÄ\8bA\93I\82É\83\8a\83X\83g\82·\82é\8fê\8d\87\82Í True
983 \param IsPathAdd \83p\83X\95t\82«\82Å\83\8a\83X\83g\83A\83b\83v\82·\82é\8fê\8d\87\82Í True
984
985 Mask \82ð '*.txt' \82Ì\82æ\82¤\82É\8ew\92è\82·\82é\82±\82Æ\82Å\81A
986 \93Á\92è\82Ì\83t\83@\83C\83\8b\96¼\82â\93Á\92è\82Ì\8ag\92£\8eq\82É\8di\82Á\82½\83\8a\83X\83g\83A\83b\83v\82ª\89Â\94\\82Å\82·\81B
987
988 \par \97á:
989 \code
990 GetFileList('c:\', '*.txt', list, True, True);
991 \endcode
992 }
993 procedure TGikoSys.GetFileList(Path: string; Mask: string; var List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
994 var
995         rc: Integer;
996         SearchRec : TSearchRec;
997         s: string;
998 begin
999         Path := IncludeTrailingPathDelimiter(Path);
1000         rc := FindFirst(Path + '*.*', faAnyfile, SearchRec);
1001         try
1002                 while rc = 0 do begin
1003                         if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
1004                                 s := Path + SearchRec.Name;
1005
1006                                 if (SearchRec.Attr and faDirectory = 0) and (MatchesMask(s, Mask)) then
1007                                                 if IsPathAdd then
1008                                                         List.Add(s)
1009                                                 else
1010                                                         List.Add(SearchRec.Name);
1011                                 if SubDir and (SearchRec.Attr and faDirectory > 0) then
1012                                         GetFileList(s, Mask, List, True, IsPathAdd);
1013                         end;
1014                         rc := FindNext(SearchRec);
1015                 end;
1016         finally
1017                 SysUtils.FindClose(SearchRec);
1018         end;
1019         List.Sort;
1020 end;
1021
1022 {!
1023 \breif \8ew\92è\83t\83H\83\8b\83_\93à\82Ì\8ew\92è\83t\83@\83C\83\8b\88ê\97\97\82ð\8eæ\93¾\82·\82é\81B
1024                          \83T\83u\83t\83H\83\8b\83_\82Í\8c\9f\8dõ\82µ\82È\82¢
1025 \param Path      \8bN\93_\82Æ\82È\82é\83t\83H\83\8b\83_\83p\83X
1026 \param Mask      \83t\83@\83C\83\8b\96¼\82Ì\83}\83X\83N
1027 \param List      OUT:\8eæ\93¾\82³\82ê\82½\83t\83@\83C\83\8b\96¼\88ê\97\97\82ª\95Ô\82é
1028 \param IsPathAdd \83p\83X\95t\82«\82Å\83\8a\83X\83g\83A\83b\83v\82·\82é\8fê\8d\87\82Í True
1029 \note \8dÄ\8bN\8ew\92è\89Â\94\\82È GetFileList() \82ª\82 \82é\82Ì\82Å\82±\82Ì\8aÖ\90\94\82Í\95s\97v?
1030 \par \97á
1031 \code
1032 GetFileList('c:\', '*.txt', list, True);
1033 \endcode
1034 }
1035 procedure TGikoSys.GetFileList(Path: string; Mask: string; var List: TStringList; IsPathAdd: Boolean);
1036 var
1037         rc: Integer;
1038         SearchRec : TSearchRec;
1039 begin
1040         Path := IncludeTrailingPathDelimiter(Path);
1041         rc := FindFirst(Path + Mask, faAnyfile, SearchRec);
1042         try
1043                 while rc = 0 do begin
1044                         if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
1045                                 if (SearchRec.Attr and faDirectory = 0) then begin
1046                     if IsPathAdd then begin
1047                         List.Add(Path + SearchRec.Name)
1048                     end else begin
1049                         List.Add(SearchRec.Name);
1050                     end;
1051                 end;
1052                         end;
1053                         rc := FindNext(SearchRec);
1054                 end;
1055         finally
1056                 SysUtils.FindClose(SearchRec);
1057         end;
1058         List.Sort;
1059 end;
1060
1061 {!
1062 \brief \8ew\92è\83t\83H\83\8b\83_\93à\82Ì\83f\83B\83\8c\83N\83g\83\8a\88ê\97\97\82ð\8eæ\93¾\82·\82é
1063 \param Path      \8bN\93_\82Æ\82È\82é\83t\83H\83\8b\83_\83p\83X
1064 \param Mask      \83t\83H\83\8b\83_\96¼\82Ì\83}\83X\83N
1065 \param List      OUT:\8eæ\93¾\82³\82ê\82½\83t\83H\83\8b\83_\96¼\88ê\97\97\82ª\95Ô\82é
1066 \param SubDir    \92\86\82Ì\83t\83H\83\8b\83_\82Ü\82Å\8dÄ\8bA\93I\82É\83\8a\83X\83g\82·\82é\8fê\8d\87\82Í True
1067
1068 Mask \82ð '*.txt' \82Ì\82æ\82¤\82É\8ew\92è\82·\82é\82±\82Æ\82Å\81A
1069 \93Á\92è\82Ì\83t\83@\83C\83\8b\96¼\82â\93Á\92è\82Ì\8ag\92£\8eq\82É\8di\82Á\82½\83\8a\83X\83g\83A\83b\83v\82ª\89Â\94\\82Å\82·\81B
1070
1071 \par \97á:
1072 \code
1073 GetDirectoryList('c:\', '*.txt', list, True);
1074 \endcode
1075 }
1076 procedure TGikoSys.GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
1077 var
1078         rc: Integer;
1079         SearchRec : TSearchRec;
1080         s: string;
1081 begin
1082         Path := IncludeTrailingPathDelimiter(Path);
1083         rc := FindFirst(Path + '*.*', faDirectory, SearchRec);
1084         try
1085                 while rc = 0 do begin
1086                         if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
1087                                 s := Path + SearchRec.Name;
1088                                 //if (SearchRec.Attr and faDirectory > 0) then
1089                                 //      s := IncludeTrailingPathDelimiter(s)
1090
1091                                 if (SearchRec.Attr and faDirectory > 0) and (MatchesMask(s, Mask)) then
1092                                         List.Add( IncludeTrailingPathDelimiter( s ) );
1093                                 if SubDir and (SearchRec.Attr and faDirectory > 0) then
1094                                         GetDirectoryList(s, Mask, List, True);
1095                         end;
1096                         rc := FindNext(SearchRec);
1097                 end;
1098         finally
1099                 SysUtils.FindClose(SearchRec);
1100         end;
1101 end;
1102
1103
1104 {!
1105 \brief Subject.txt \88ê\8ds\82ð\89ð\8eß
1106 \param Line Subject.txt \82ð\8d\\90¬\82·\82é 1 \8ds
1107 \return     \83X\83\8c\83b\83h\8fî\95ñ
1108 }
1109 function TGikoSys.DivideSubject(Line: string): TSubjectRec;
1110 var
1111         i: integer;
1112         ws: WideString;
1113         Delim: string;
1114         LeftK: string;
1115         RightK: string;
1116 begin
1117         Result.FCount := 0;
1118
1119         if AnsiPos('<>', Line) = 0 then
1120                 Delim := ','
1121         else
1122                 Delim := '<>';
1123         Result.FFileName := MojuUtils.RemoveToken(Line, Delim);
1124         Result.FTitle := Trim(MojuUtils.RemoveToken(Line, Delim));
1125
1126         ws := Result.FTitle;
1127         if Copy(ws, Length(ws), 1) = ')' then begin
1128                 LeftK := '(';
1129                 RightK := ')';
1130         end else if Copy(ws, Length(ws)-1, 2) = '\81j' then begin
1131                 LeftK := '\81i';
1132                 RightK := '\81j';
1133         end else if Copy(ws, Length(ws), 1) = '>' then begin
1134                 LeftK := '<';
1135                 RightK := '>';
1136         end;
1137         for i := Length(ws) - 1 downto 1 do begin
1138                 if Copy(ws, i, Length(LeftK)) = LeftK then begin
1139                         Result.FTitle := TrimRight(Copy(ws, 1, i - 1));
1140                         ws := Copy(ws, i + Length(LeftK), Length(ws) - i - Length(RightK));
1141                         if IsNumeric(ws) then
1142                                 Result.FCount := StrToInt(ws);
1143                         //Delete(Result.FTitle, i, Length(LeftK) + Length(ws) + Length(RightK));
1144                         break;
1145                 end;
1146         end;
1147 end;
1148
1149 {!
1150 \brief URL\82©\82çBBSID\82ð\8eæ\93¾
1151 \param url BBSID \82ð\8eæ\93¾\82·\82é URL
1152 \return    BBSID
1153 }
1154 function TGikoSys.UrlToID(url: string): string;
1155 var
1156         i: integer;
1157 begin
1158         Result := '';
1159         url := Trim(url);
1160
1161         if url = '' then Exit;
1162         try
1163                 url := Copy(url, 0, Length(url) - 1);
1164                 for i := Length(url) downto 0 do begin
1165                         if url[i] = '/' then begin
1166                                 Result := Copy(url, i + 1, Length(url));
1167                                 Break;
1168                         end;
1169                 end;
1170         except
1171                 Result := '';
1172         end;
1173 end;
1174
1175 {!
1176 \brief URL\82©\82ç\8dÅ\8cã\82Ì\97v\91f\82ð\8dí\8f\9c
1177 \param url \89ð\8eß\82·\82é URL
1178 \return    \90Ø\82è\8eæ\82ç\82ê\82½\8cã\82Ì URL
1179
1180 URL \82©\82ç BBSID\88È\8aO\82Ì\95\94\95ª\82ð\8eæ\93¾\82·\82é\82Ì\82É\8eg\97p\82µ\82Ü\82·\81B
1181 }
1182 function TGikoSys.UrlToServer(url: string): string;
1183 var
1184         i: integer;
1185         wsURL: WideString;
1186 begin
1187         Result := '';
1188         wsURL := url;
1189         wsURL := Trim(wsURL);
1190
1191         if wsURL = '' then exit;
1192
1193         if Copy(wsURL, Length(wsURL), 1) = '/' then
1194                 wsURL := Copy(wsURL, 0, Length(wsURL) - 1);
1195
1196         for i := Length(wsURL) downto 0 do begin
1197                 if wsURL[i] = '/' then begin
1198                         Result := Copy(wsURL, 0, i);
1199                         break;
1200                 end;
1201         end;
1202 end;
1203
1204 {!
1205 \brief \83f\83B\83\8c\83N\83g\83\8a\82ª\91\8dÝ\82·\82é\82©\83`\83F\83b\83N
1206 \param Name \91\8dÝ\82ð\8am\94F\82·\82é\83t\83H\83\8b\83_\83p\83X
1207 \return     \83t\83H\83\8b\83_\82ª\91\8dÝ\82·\82é\82È\82ç True
1208 }
1209 function TGikoSys.DirectoryExistsEx(const Name: string): Boolean;
1210 var
1211         Code: Cardinal;
1212 begin
1213         Code := GetFileAttributes(PChar(Name));
1214         Result := (Code <> Cardinal(-1)) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
1215 end;
1216
1217 {!
1218 \brief \83f\83B\83\8c\83N\83g\83\8a\8dì\90¬\81i\95¡\90\94\8aK\91w\91Î\89\9e\81j
1219 \param Dir \8dì\90¬\82·\82é\83p\83X
1220 \return    \8dì\90¬\82É\90¬\8c÷\82µ\82½\8fê\8d\87\82Í True
1221 }
1222 function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean;
1223 begin
1224         Result := True;
1225         if Length(Dir) = 0 then
1226                 raise Exception.Create('\83t\83H\83\8b\83_\82ª\8dì\90¬\8fo\97\88\82Ü\82¹\82ñ');
1227         Dir := ExcludeTrailingPathDelimiter(Dir);
1228         if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
1229                 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
1230         Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
1231 end;
1232
1233 {!
1234 \brief \95\8e\9a\97ñ\82©\82ç\83g\81[\83N\83\93\82Ì\90Ø\82è\8fo\82µ\81i\8f\89\8aú\8f\88\97\9d\81j
1235                          FDelphi\82©\82ç\82Ì\83p\83N\83\8a
1236 \param s   \8c³\82É\82È\82é\83L\83\83\83\89\83N\83^
1237 \param sep \8bæ\90Ø\82è\82É\82È\82é\95\8e\9a\97ñ
1238 \param Rec OUT:\95\8e\9a\97ñ\91\96\8d¸\8fî\95ñ\82ª\95Ô\82é
1239 \return    \90Ø\82è\8fo\82µ\82½\83g\81[\83N\83\93
1240 \todo Split, RemoveToken, GetTokenIndex, NthField \8ds\82«
1241 }
1242 function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1243 begin
1244         Rec.Str := s;
1245         Rec.Pos := 1;
1246         Result := StrTokNext(sep, Rec);
1247 end;
1248
1249 {!
1250 \brief \95\8e\9a\97ñ\82©\82ç\83g\81[\83N\83\93\82Ì\90Ø\82è\8fo\82µ
1251                          FDelphi\82©\82ç\82Ì\83p\83N\83\8a
1252 \param sep \8bæ\90Ø\82è\82É\82È\82é\83L\83\83\83\89\83N\83^
1253 \param Rec IN/OUT:StrTokFirst\82Å\8dì\90¬\82³\82ê\82½\95\8e\9a\97ñ\91\96\8d¸\8fî\95ñ
1254 \return    \90Ø\82è\8fo\82µ\82½\83g\81[\83N\83\93
1255 \todo Split, RemoveToken, GetTokenIndex, NthField \8ds\82«
1256 }
1257 function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1258 var
1259         Len, I: Integer;
1260 begin
1261         with Rec do     begin
1262                 Len := Length(Str);
1263                 Result := '';
1264                 if Len >= Pos then begin
1265                         while (Pos <= Len) and (Str[Pos] in sep) do begin
1266                          Inc(Pos);
1267                         end;
1268                         I := Pos;
1269                         while (Pos<= Len) and not (Str[Pos] in sep) do begin
1270                                 if IsDBCSLeadByte(Byte(Str[Pos])) then begin
1271                                         Inc(Pos);
1272                                 end;
1273                                 Inc(Pos);
1274                         end;
1275                         Result := Copy(Str, I, Pos - I);
1276                         while (Pos <= Len) and (Str[Pos] in sep) do begin// \82±\82ê\82Í\82¨\8dD\82Ý
1277                                 Inc(Pos);
1278                         end;
1279                 end;
1280         end;
1281 end;
1282
1283 {!
1284 \brief \83t\83@\83C\83\8b\83T\83C\83Y\8eæ\93¾
1285 \param FileName \83t\83@\83C\83\8b\83T\83C\83Y\82ð\8eæ\93¾\82·\82é\83t\83@\83C\83\8b\83p\83X
1286 \return         \83t\83@\83C\83\8b\83T\83C\83Y(bytes)
1287 }
1288 function TGikoSys.GetFileSize(FileName : string): longint;
1289 var
1290         F : File;
1291 begin
1292         try
1293                 if not FileExists(FileName) then begin
1294                         Result := 0;
1295                         Exit;
1296                 end;
1297                 Assign(F, FileName);
1298                 Reset(F, 1);
1299                 Result := FileSize(F);
1300                 CloseFile(F);
1301         except
1302                 Result := 0;
1303         end;
1304 end;
1305
1306 {!
1307 \brief \83e\83L\83X\83g\83t\83@\83C\83\8b\82Ì\8ds\90\94\82ð\8eæ\93¾
1308 \param FileName \8ds\90\94\82ð\8eæ\93¾\82·\82é\83t\83@\83C\83\8b\83p\83X
1309 \return         \8ds\90\94
1310 \todo \83\81\83\82\83\8a\83}\83b\83v\83h\83t\83@\83C\83\8b\8ds\82«
1311 }
1312 function TGikoSys.GetFileLineCount(FileName : string): longint;
1313 var
1314         sl: TStringList;
1315 begin
1316         sl := TStringList.Create;
1317         try
1318                 try
1319                         sl.LoadFromFile(FileName);
1320                         Result := sl.Count;
1321                 except
1322                         Result := 0;
1323                 end;
1324         finally
1325                 sl.Free;
1326         end;
1327
1328 end;
1329
1330 {!
1331 \brief \83t\83@\83C\83\8b\82©\82ç\8ew\92è\8ds\82ð\8eæ\93¾
1332 \param FileName \83t\83@\83C\83\8b\82Ì\83p\83X
1333 \param Line     \8ew\92è\8ds
1334 \return         \8ew\92è\82³\82ê\82½ 1 \8ds
1335 \todo \83\81\83\82\83\8a\83}\83b\83v\83h\83t\83@\83C\83\8b\8ds\82«
1336 }
1337 function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string;
1338 var
1339         fileTmp : TStringList;
1340 begin
1341         Result := '';
1342         if FileExists(FileName) then begin
1343                 fileTmp := TStringList.Create;
1344                 try
1345                         try
1346                                 fileTmp.LoadFromFile( FileName );
1347                                 if ( Line       >= 1 ) and ( Line       < fileTmp.Count + 1 ) then begin
1348                                         Result := fileTmp.Strings[ Line-1 ];
1349                                 end;
1350                         except
1351                                 //on EFOpenError do Result := '';
1352                         end;
1353                 finally
1354                         fileTmp.Free;
1355                 end;
1356         end;
1357 end;
1358
1359 {!
1360 \brief \83V\83X\83e\83\80\83\81\83j\83\85\81[\83t\83H\83\93\83g\82Ì\91®\90«\82ð\8eæ\93¾
1361 \param Font OUT:\8eæ\93¾\82µ\82½\83t\83H\83\93\83g\91®\90«\82ª\95Ô\82é
1362 }
1363 procedure TGikoSys.MenuFont(Font: TFont);
1364 var
1365         lf: LOGFONT;
1366         nm: NONCLIENTMETRICS;
1367 begin
1368         nm.cbSize := sizeof(NONCLIENTMETRICS);
1369     SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0);
1370     lf := nm.lfMenuFont;
1371     Font.Name := lf.lfFaceName;
1372     Font.Height := lf.lfHeight;
1373     Font.Style := [];
1374     if lf.lfWeight >= 700 then
1375         Font.Style := Font.Style + [fsBold];
1376     if lf.lfItalic = 1 then
1377         Font.Style := Font.Style + [fsItalic];
1378 end;
1379
1380 {!
1381 \brief \90æ\93ª\82Ì\83g\81[\83N\83\93\82ð\90Ø\82è\8fo\82µ
1382 \param s         IN/OUT:\8c³\82É\82È\82é\95\8e\9a\97ñ\81A\90Ø\82è\8fo\82µ\82½\8cã\82Ì\8ec\82è\82Ì\95\8e\9a\97ñ
1383 \param delimiter \8bæ\90Ø\82è\82É\82È\82é\95\8e\9a\97ñ
1384 \return          \90Ø\82è\8fo\82µ\82½\95\8e\9a\97ñ
1385
1386 \82Ç\82±\82©\82Ì\83T\83C\83g\82©\82ç\82Ì\83p\83N\83\8a
1387 }
1388 {function TGikoSys.RemoveToken(var s: string;const delimiter: string): string;
1389 var
1390         p: Integer;
1391 begin
1392         p := AnsiPos(delimiter, s);
1393         if p = 0 then
1394                 Result := s
1395         else
1396                 Result := Copy(s, 1, p - 1);
1397         Delete(s, 1, Length(Result) + Length(delimiter));
1398 end;
1399 }
1400
1401 {!
1402 \brief n \8cÂ\96Ú\82Ì\83g\81[\83N\83\93\82ð\90Ø\82è\8fo\82µ
1403 \param s     \8c³\82É\82È\82é\95\8e\9a\97ñ
1404 \param index 0 \82©\82ç\8en\82Ü\82é\83C\83\93\83f\83b\83N\83X(n \8cÂ\96Ú\82Ì n)
1405 \return \90Ø\82è\8fo\82µ\82½\83g\81[\83N\83\93
1406
1407 \82Ç\82±\82©\82Ì\83T\83C\83g\82©\82ç\82Ì\83p\83N\83\8a
1408 }
1409 function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string;
1410 var
1411         i: Integer;
1412 begin
1413         Result := '';
1414         for i := 0 to index do
1415                 Result := MojuUtils.RemoveToken(s, delimiter);
1416 end;
1417
1418
1419 //\83C\83\93\83f\83b\83N\83X\96¢\8dX\90V\83o\83b\83t\83@\82ð\83t\83\89\83b\83V\83\85\81I
1420 {procedure TGikoSys.FlashExitWrite;
1421 var
1422         i: Integer;
1423 begin
1424         //\83X\83\8c\83b\83h\83f\81[\83^\83t\83@\83C\83\8b\82ð\8dX\90V
1425         for i := 0 to FExitWrite.Count - 1 do
1426                 WriteThreadDat(FExitWrite[i]);
1427         FExitWrite.Clear;
1428 end;}
1429
1430 {!
1431 \brief \83X\83\8c\96¼\82È\82Ç\82ð\92Z\82¢\96¼\91O\82É\95Ï\8a·\82·\82é
1432 \param LongName \8c³\82É\82È\82é\95\8e\9a\97ñ
1433 \param ALength  \8eû\82ß\82é\95\8e\9a\97ñ\92·(bytes)
1434 \return         \95Ï\8a·\82³\82ê\82½\95\8e\9a\97ñ
1435
1436 from HotZonu
1437 }
1438 function TGikoSys.GetShortName(const LongName: string; ALength: integer): string;
1439 const
1440         ERASECHAR : array [1..39] of string =
1441                 ('\81\99','\81\9a','\81¡','\81 ','\81\9f','\81\9e','\81Q','\81\94','\81£','\81¥',
1442                  '\81¢','\81¤','\81\9c','\81\9b','\81\9d','\81y','\81z','\81ô','\81s','\81t',
1443                  '\81g','\81h','\81k','\81l','\81e','\81f','\81\83','\81\84','\81á','\81â',
1444                  '\81o','\81p','\81q','\81r','\81w','\81x','\81¬','\81c', '\81@');
1445 var
1446         Chr : array [0..255]    of      char;
1447         S : string;
1448         i : integer;
1449 begin
1450     s := TrimThreadTitle(Trim(LongName));
1451         if (Length(s) <= ALength) then begin
1452                 Result := s;
1453         end else begin
1454                 S := s;
1455                 for i := Low(ERASECHAR) to      High(ERASECHAR) do      begin
1456                         S := CustomStringReplace(S, ERASECHAR[i], '');
1457                 end;
1458                 if (Length(S) <= ALength) then begin
1459                         Result := S;
1460                 end else begin
1461                         Windows.LCMapString(
1462                                         GetUserDefaultLCID(),
1463                                         LCMAP_HALFWIDTH,
1464                                         PChar(S),
1465                                         Length(S) + 1,
1466                                         chr,
1467                                         Sizeof(chr)
1468                                         );
1469                         S := Chr;
1470                         S := Copy(S,1,ALength);
1471                         while true do begin
1472                                 if (ByteType(S, Length(S)) = mbLeadByte ) then begin
1473                                         S := Copy(S, 1, Length(S) - 1);
1474                                 end else begin
1475                                         Break;
1476                                 end;
1477                         end;
1478                         Result := S;
1479                 end;
1480         end;
1481 end;
1482
1483 function TGikoSys.TrimThreadTitle(const SrcTitle: string): string;
1484 const
1485     TRIM_STRING: array [1..4] of String =
1486         ('[\93]\8dÚ\8bÖ\8e~]', '&copy;2ch.net', '&copy;bbspink.com', #9);
1487 var
1488     i: Integer;
1489     Idx: Integer;
1490     Len: Integer;
1491     DstTitle: String;
1492 begin
1493     if (Setting.ThreadTitleTrim = True) then begin
1494         DstTitle := SrcTitle;
1495                 for i := Low(TRIM_STRING) to High(TRIM_STRING) do begin
1496             Len := Length(TRIM_STRING[i]);
1497             while (True) do begin
1498                 Idx := Pos(TRIM_STRING[i], DstTitle);
1499                 if (Idx < 1) then
1500                     Break;
1501                 Delete(DstTitle, Idx, Len);
1502             end;
1503         end;
1504         Result := Trim(DstTitle);
1505     end else begin
1506         Result := SrcTitle;
1507     end;
1508 end;
1509
1510 {!
1511 \brief Boolean \82ð Integer \82É\95Ï\8a·
1512 \return False..0, True..1
1513 }
1514 function TGikoSys.BoolToInt(b: Boolean): Integer;
1515 begin
1516         Result := IfThen(b, 1, 0);
1517 end;
1518
1519 {!
1520 \brief Integer \82ð Boolean \82É\95Ï\8a·
1521 \return 1..True, other..False
1522 \todo 0..False, other..True \82Ì\95û\82ª\82¢\82¢\82Ì\82Å\82Í?
1523                         (\82±\82Ì\8ed\97l\82É\88Ë\91\82µ\82Ä\82¢\82é\82©\82à\82µ\82ê\82È\82¢\82Ì\82Å\96¢\8fC\90³)
1524 }
1525 function TGikoSys.IntToBool(i: Integer): Boolean;
1526 begin
1527         Result := i = 1;
1528 end;
1529
1530 {!
1531 \brief gzip\82Å\88³\8fk\82³\82ê\82½\82Ì\82ð\96ß\82·
1532 \param ResStream       \93Ç\82Ý\8d\9e\82Þ\83X\83g\83\8a\81[\83\80
1533 \param ContentEncoding \83G\83\93\83R\81[\83f\83B\83\93\83O
1534 \return                \93W\8aJ\82³\82ê\82½\95\8e\9a\97ñ
1535 }
1536 function TGikoSys.GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
1537 const
1538         BUF_SIZE = 4096;
1539 var
1540         GZipStream: TGzipDecompressStream;
1541         TextStream: TStringStream;
1542         buf: array[0..BUF_SIZE - 1] of Byte;
1543         cnt: Integer;
1544         s: string;
1545         i, ln: Integer;
1546 begin
1547         Result := '';
1548         TextStream := TStringStream.Create('');
1549         try
1550 //\83m\81[\83g\83\93\83E\83\93\83`\83E\83B\83\8b\83X2003\91Î\8dô(x-gzip\82Æ\82©\82É\82È\82é\82Ý\82½\82¢)
1551 //              if LowerCase(Trim(ContentEncoding)) = 'gzip' then begin
1552                 if AnsiPos('gzip', LowerCase(Trim(ContentEncoding))) > 0 then begin
1553                         ResStream.Position := 0;
1554                         GZipStream := TGzipDecompressStream.Create(TextStream);
1555                         try
1556                                 repeat
1557                                         FillChar(buf, BUF_SIZE, 0);
1558                                         cnt := ResStream.Read(buf, BUF_SIZE);
1559                                         if cnt > 0 then
1560                                                 GZipStream.Write(buf, BUF_SIZE);
1561                                 until cnt = 0;
1562                         finally
1563                                 GZipStream.Free;
1564                         end;
1565                 end else begin
1566                         ResStream.Position := 0;
1567                         repeat
1568                                 FillChar(buf, BUF_SIZE, 0);
1569                                 cnt := ResStream.Read(buf, BUF_SIZE);
1570                                 if cnt > 0 then
1571                                         TextStream.Write(buf, BUF_SIZE);
1572                         until cnt = 0;
1573                 end;
1574
1575                 //NULL\95\8e\9a\82ð"*"\82É\82·\82é
1576                 s := TextStream.DataString;
1577                 i := Length(s);
1578                 ln := i;
1579                 while (i > 0) and (s[i] = #0) do
1580                         Dec(i);
1581                 Delete(s, i + 1, ln - i);
1582
1583                 i := Pos(#0, s);
1584                 while i <> 0 do begin
1585                         s[i] := '*';
1586                         i := Pos(#0, s);
1587                 end;
1588
1589                 Result := s;
1590         finally
1591                 TextStream.Free;
1592         end;
1593 end;
1594
1595 {!
1596 \brief \83A\83N\83V\83\87\83\93\82É\83V\83\87\81[\83g\83J\83b\83g\83L\81[\82ð\90Ý\92è
1597 \param ActionList \90Ý\92è\82·\82é\83A\83N\83V\83\87\83\93\88ê\97\97
1598 \param FileName Ini\83t\83@\83C\83\8b\82Ì\96¼\91O
1599 }
1600 procedure TGikoSys.LoadKeySetting(ActionList: TActionList; FileName: String);
1601 const
1602         STD_SEC = 'KeySetting';
1603 var
1604         i: Integer;
1605         ini: TMemIniFile;
1606         ActionName: string;
1607         ActionKey: Integer;
1608         SecList: TStringList;
1609         Component: TComponent;
1610 begin
1611         if not FileExists(fileName) then
1612                 Exit;
1613         SecList := TStringList.Create;
1614         ini := TMemIniFile.Create(fileName);
1615         try
1616                 ini.ReadSection(STD_SEC, SecList);
1617                 for i := 0 to SecList.Count - 1 do begin
1618                         ActionName := SecList[i];
1619                         ActionKey := ini.ReadInteger(STD_SEC, ActionName, -1);
1620                         if ActionKey <> -1 then begin
1621                                 Component := ActionList.Owner.FindComponent(ActionName);
1622                                 if TObject(Component) is TAction then begin
1623                                         TAction(Component).ShortCut := ActionKey;
1624                                 end;
1625                         end;
1626                 end;
1627         finally
1628                 ini.Free;
1629                 SecList.Free;
1630         end;
1631 end;
1632
1633 {!
1634 \brief \83A\83N\83V\83\87\83\93\82É\90Ý\92è\82³\82ê\82Ä\82¢\82é\83V\83\87\81[\83g\83J\83b\83g\83L\81[\82ð\83t\83@\83C\83\8b\82É\95Û\91
1635 \param ActionList \95Û\91\82·\82é\83A\83N\83V\83\87\83\93\88ê\97\97
1636 \param FileName Ini\83t\83@\83C\83\8b\96¼
1637
1638 ActionList \82É\90Ý\92è\82³\82ê\82Ä\82¢\82é\83V\83\87\81[\83g\83J\83b\83g\83L\81[\82ð FileName \82É\95Û\91\82µ\82Ü\82·\81B
1639 }
1640 procedure TGikoSys.SaveKeySetting(ActionList: TActionList; FileName: String);
1641 const
1642         STD_SEC = 'KeySetting';
1643 var
1644         i: Integer;
1645         ini: TMemIniFile;
1646 begin
1647         ini := TMemIniFile.Create(GetConfigDir + FileName);
1648         try
1649                 for i := 0 to ActionList.ActionCount - 1 do begin
1650                         if ActionList.Actions[i].Tag = -1 then
1651                                 Continue;
1652                         ini.WriteInteger(STD_SEC, ActionList.Actions[i].Name, TAction(ActionList.Actions[i]).ShortCut);
1653                 end;
1654                 ini.UpdateFile;
1655         finally
1656                 ini.Free;
1657         end;
1658 end;
1659
1660
1661 {!
1662 \brief \83v\83\8d\83Z\83X\82Ì\90\90¬
1663 \param AppPath \8bN\93®\82·\82é\83v\83\8d\83Z\83X\82Ì\83t\83@\83C\83\8b\83p\83X
1664 \param Param   AppPath \82É\93n\82·\88ø\90\94
1665 }
1666 procedure TGikoSys.CreateProcess(const AppPath: string; const Param: string);
1667 var
1668         PI: TProcessInformation;
1669         SI: TStartupInfo;
1670         Path: string;
1671 begin
1672         Path := '"' + AppPath + '"';
1673         if Param <> '' then
1674                 Path := Path + ' ' + Param;
1675
1676         SI.Cb := SizeOf(Si);
1677         SI.lpReserved   := nil;
1678         SI.lpDesktop     := nil;
1679         SI.lpTitle               := nil;
1680         SI.dwFlags               := 0;
1681         SI.cbReserved2 := 0;
1682         SI.lpReserved2 := nil;
1683         SI.dwysize               := 0;
1684     if Windows.CreateProcess(nil,
1685                                                                 PChar(Path),
1686                                                                 nil,
1687                                                                 nil,
1688                                                                 False,
1689                                                                 0,
1690                                                                 nil,
1691                                                                 nil,
1692                                                                 SI,
1693                                                                 PI) then
1694     begin
1695         CloseHandle(PI.hProcess);
1696     end;
1697
1698 end;
1699
1700 {!
1701 \brief Web \83u\83\89\83E\83U\82ð\8bN\93®
1702 \param URL         Web \83u\83\89\83E\83U\82Å\95\\8e¦\82·\82é URL
1703 \param BrowserType \83u\83\89\83E\83U\82Ì\83^\83C\83v(IE \82©\82Ç\82¤\82©)
1704 }
1705 procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
1706 var
1707     i, j : Integer;
1708     path, arg : String;
1709     params : TStringList;
1710 begin
1711         case BrowserType of
1712                 gbtIE:
1713                         HlinkNavigateString(nil, PWideChar(WideString(URL)));
1714                 gbtUserApp, gbtAuto:
1715                         if (Setting.URLApp) then begin
1716                 if (FileExists(Setting.URLAppFile)) then begin
1717                                 GikoSys.CreateProcess(Setting.URLAppFile, URL)
1718                 end else begin
1719                     // \8bN\93®\83p\83\89\83\81\81[\83^\95t\82«\91Î\8dô
1720                     path := '';
1721                     params := TStringList.Create;
1722                     try
1723                         params.Delimiter := ' ';
1724                         params.DelimitedText := Setting.URLAppFile;
1725                         for i := 0 to params.Count - 1 do begin
1726                             path := TrimLeft(path + ' ' + params[i]);
1727                             if (FileExists(path)) then begin
1728                                 arg := '';
1729                                 for j := i + 1 to params.Count - 1 do begin
1730                                     arg := arg + ' ' + params[j];
1731                                 end;
1732                                 break;
1733                             end;
1734                         end;
1735                         if i < params.Count then begin
1736                             GikoSys.CreateProcess(path, arg + ' ' + URL);
1737                         end else begin
1738                             HlinkNavigateString(nil, PWideChar(WideString(URL)));
1739                         end;
1740                     finally
1741                         params.Free;
1742                     end;
1743                 end;
1744                         end else
1745                                 HlinkNavigateString(nil, PWideChar(WideString(URL)));
1746         end;
1747 end;
1748
1749 {!
1750 \brief \95\8e\9a\8eÀ\91Ì\8eQ\8fÆ\82ð\83f\83R\81[\83h
1751 \param AStr \83f\83R\81[\83h\82·\82é\95\8e\9a\97ñ
1752 \return     \83f\83R\81[\83h\82³\82ê\82½\95\8e\9a\97ñ
1753 }
1754 function TGikoSys.HTMLDecode(const AStr: String): String;
1755 var
1756         Sp, Rp, Cp, Tp: PChar;
1757         S: String;
1758         I, Code: Integer;
1759         Num: Boolean;
1760 begin
1761         SetLength(Result, Length(AStr));
1762         Sp := PChar(AStr);
1763         Rp := PChar(Result);
1764         //Cp := Sp;
1765         try
1766                 while Sp^ <> #0 do begin
1767                         case Sp^ of
1768                                 '&': begin
1769                                                          //Cp := Sp;
1770                                                          Inc(Sp);
1771                                                          case Sp^ of
1772                                                                  'a': if AnsiStrPos(Sp, 'amp;') = Sp then
1773                                                                                         begin
1774                                                                                                 Inc(Sp, 3);
1775                                                                                                 Rp^ := '&';
1776                                                                                         end;
1777                                                                  'l',
1778                                                                  'g': if (AnsiStrPos(Sp, 'lt;') = Sp) or (AnsiStrPos(Sp, 'gt;') = Sp) then
1779                                                                                         begin
1780                                                                                                 Cp := Sp;
1781                                                                                                 Inc(Sp, 2);
1782                                                                                                 while (Sp^ <> ';') and (Sp^ <> #0) do
1783                                                                                                         Inc(Sp);
1784                                                                                                 if Cp^ = 'l' then
1785                                                                                                         Rp^ := '<'
1786                                                                                                 else
1787                                                                                                         Rp^ := '>';
1788                                                                                         end;
1789                                                                  'q': if AnsiStrPos(Sp, 'quot;') = Sp then
1790                                                                                         begin
1791                                                                                                 Inc(Sp,4);
1792                                                                                                 Rp^ := '"';
1793                                                                                         end;
1794                                                                  '#': begin
1795                                                                                                 Tp := Sp;
1796                                                                                                 Inc(Tp);
1797                                                                                                 Num := IsNumeric(Copy(Tp, 1, 1));
1798                                                                                                 while (Sp^ <> ';') and (Sp^ <> #0) do begin
1799                                                                                                         if (Num) and (not IsNumeric(Copy(Sp, 1, 1))) then
1800                                                                                                                 Break;
1801                                                                                                         Inc(Sp);
1802                                                                                                 end;
1803                                                                                                 SetString(S, Tp, Sp - Tp);
1804                                                                                                 Val(S, I, Code);
1805                                                                                                 Rp^ := Chr((I));
1806                                                                                         end;
1807                                                          //      else
1808                                                                          //raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
1809                                                                                  //[Cp^ + Sp^, Cp - PChar(AStr)])
1810                                                          end;
1811                                          end
1812                         else
1813                                 Rp^ := Sp^;
1814                         end;
1815                         Inc(Rp);
1816                         Inc(Sp);
1817                 end;
1818         except
1819 //              on E:EConvertError do
1820 //                      raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
1821 //                              [Cp^ + Sp^, Cp - PChar(AStr)])
1822         end;
1823         SetLength(Result, Rp - PChar(Result));
1824 end;
1825
1826 {!
1827 \brief HTML \82Ì\83A\83\93\83J\81[\83^\83O\82©\82ç URL \82ð\8eæ\93¾
1828 \param s URL \82ð\8eæ\93¾\82·\82é HTML
1829 \return  \8eæ\93¾\82µ\82½ URL
1830 }
1831 function TGikoSys.GetHRefText(s: string): string;
1832 var
1833         Index: Integer;
1834         Index2: Integer;
1835 begin
1836         Result := '';
1837         s := Trim(s);
1838         if s = '' then
1839                 Exit;
1840
1841         Index := AnsiPos('href', LowerCase(s));
1842         if Index = 0 then
1843                 Exit;
1844         s := Trim(Copy(s, Index + 4, Length(s)));
1845         s := Trim(Copy(s, 2, Length(s)));
1846
1847         //\8en\82ß\82Ì\95\8e\9a\82ª'"'\82È\82ç\8eæ\82è\8f\9c\82­
1848         //if Copy(s, 1, 1) = '"' then begin
1849     if s[1]  = '"' then begin
1850                 s := Trim(Copy(s, 2, Length(s)));
1851         end;
1852
1853         Index := AnsiPos('"', s);
1854         if Index <> 0 then begin
1855                 //'"'\82Ü\82ÅURL\82Æ\82·\82é
1856                 s := Copy(s, 1, Index - 1);
1857         end else begin
1858                 //'"'\82ª\96³\82¯\82ê\82Î\83X\83y\81[\83X\82©">"\82Ì\91\81\82¢\95û\82Ü\82Å\82ðURL\82Æ\82·\82é
1859                 Index := AnsiPos(' ', s);
1860                 Index2 := AnsiPos('>', s);
1861                 if Index = 0 then
1862                         Index := Index2;
1863                 if Index > Index2 then
1864                         Index := Index2;
1865                 if Index <> 0 then
1866                         s := Copy(s, 1, Index - 1)
1867                 else
1868                         //\82±\82ê\88È\8fã\82à\82¤\92m\82ç\82ñ\82Ê
1869                         ;
1870         end;
1871         Result := Trim(s);
1872 end;
1873
1874 {!
1875 \brief \83z\83X\83g\96¼\82ª\82Q\82\83\82\88\82©\82Ç\82¤\82©\83`\83F\83b\83N\82·\82é
1876 \param Host \83`\83F\83b\83N\82·\82é\83z\83X\83g\96¼
1877 \return     2\82¿\82á\82ñ\82Ë\82é\82Ì\83z\83X\83g\96¼\82È\82ç True
1878 }
1879 function TGikoSys.Is2chHost(Host: string): Boolean;
1880 const
1881         HOST_NAME: array[0..1] of string = ('.2ch.net', '.bbspink.com');
1882 var
1883         i: Integer;
1884 //      Len: Integer;
1885 begin
1886         Result := False;
1887         if RightStr( Host, 1 ) = '/' then
1888                 Host := Copy( Host, 1, Length( Host ) - 1 );
1889         OutputDebugString(pchar(HOST_NAME[0]));
1890         for i := 0 to Length(HOST_NAME) - 1 do begin
1891 //              Len := Length(HOST_NAME[i]);
1892                 if (AnsiPos(HOST_NAME[i], Host) > 0) and
1893                         (AnsiPos(HOST_NAME[i], Host) = (Length(Host) - Length(HOST_NAME[i]) + 1)) then begin
1894                         Result := True;
1895                         Exit;
1896                 end;
1897         end;
1898 end;
1899
1900 {!
1901 \brief 2\82¿\82á\82ñ\82Ë\82é\8c`\8e®\82Ì URL \82ð\95ª\89ð
1902 \param url      2\82¿\82á\82ñ\82Ë\82é\8c`\8e®\82Ì URL
1903 \param path     test/read.cgi \82È\82Ç\82Ì\92\86\8aÔ\83p\83X(ParseURI \82©\82ç\93¾\82é)
1904 \param document index.html \82È\82Ç\82Ì\83h\83L\83\85\83\81\83\93\83g\96¼(ParseURI \82©\82ç\93¾\82é)
1905 \param BBSID    OUT:BBSID \82ª\95Ô\82é(ex. giko)
1906 \param BBSKey   OUT:\83X\83\8c\83b\83h\83L\81[\82ª\95Ô\82é(ex. 10000000000)
1907 \return 2\82¿\82á\82ñ\82Ë\82é\82Ì URL \82Æ\82µ\82Ä\95ª\89ð\82Å\82«\82½\82È\82ç True
1908 }
1909 function TGikoSys.Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
1910 var
1911         Index: Integer;
1912         s: string;
1913         SList: TStringList;
1914 begin
1915         BBSID := '';
1916         BBSKey := '';
1917         Result := False;
1918
1919         Index := AnsiPos(READ_PATH, path);
1920         if Index <> 0 then begin
1921                 s := Copy(path, Index + Length(READ_PATH), Length(path));
1922     end else begin
1923         Index := AnsiPos(HTML_READ_PATH, path);
1924         if Index <> 0 then begin
1925             s := Copy(path, Index + Length(HTML_READ_PATH), Length(path));
1926         end;
1927     end;
1928     if Index <> 0 then begin
1929                 if (Length(s) > 0) and (s[1] = '/') then
1930                         Delete(s, 1, 1);
1931                 BBSID := GetTokenIndex(s, '/', 0);
1932                 BBSKey := GetTokenIndex(s, '/', 1);
1933                 if BBSKey = '' then
1934                         BBSKey := Document;
1935                 Result := (BBSID <> '') or (BBSKey <> '');
1936                 Exit;
1937         end;
1938         Index := AnsiPos(KAKO_PATH, path);
1939         if Index <> 0 then begin
1940                 s := Copy(path, 2, Length(path));
1941                 BBSID := GetTokenIndex(s, '/', 0);
1942                 if (BBSID = 'log') and (GetTokenIndex(s, '/', 2) = 'kako') then
1943                         BBSID := GetTokenIndex(s, '/', 1);
1944                 BBSKey := ChangeFileExt(Document, '');
1945                 Result := (BBSID <> '') or (BBSKey <> '');
1946                 Exit;
1947         end;
1948         Index := AnsiPos('read.cgi?', URL);
1949         if Index <> 0 then begin
1950                 SList := TStringList.Create;
1951                 try
1952                         try
1953 //                              s := HTMLDecode(Document);
1954                                 ExtractHTTPFields(['?', '&'], [], PChar(URL), SList, False);
1955                                 BBSID := SList.Values['bbs'];
1956                                 BBSKey := SList.Values['key'];
1957                                 Result := (BBSID <> '') or (BBSKey <> '');
1958                                 Exit;
1959                         except
1960                                 Exit;
1961                         end;
1962                 finally
1963                         SList.Free;
1964                 end;
1965         end;
1966 end;
1967
1968 {!
1969 \brief 2ch \8c`\8e®\82Ì URL \82©\82ç\83\8c\83X\94Ô\82ð\8eæ\93¾
1970 \param URL    2\82¿\82á\82ñ\82Ë\82é\8c`\8e®\82Ì URL
1971 \param stRes  OUT:\8aJ\8en\83\8c\83X\94Ô\82ª\95Ô\82é
1972 \param endRes OUT:\8fI\97¹\83\8c\83X\94Ô\82ª\95Ô\82é
1973
1974 http://2ch.net/\92\86\97ª/32-50 \n
1975 \82Ì\8fê\8d\87 stRef = 32, endRes = 50 \82É\82È\82é
1976 }
1977 procedure TGikoSys.GetPopupResNumber(URL : string; var stRes, endRes : Int64);
1978 const
1979     START_NAME : array[0..1] of String = ('st=', 'start=');
1980     END_NAME : array[0..1] of String = ('to=', 'end=');
1981     RES_NAME : array[0..0] of String = ('res=');
1982 var
1983         buf : String;
1984         convBuf : String;
1985         ps : Int64;
1986         pch : PChar;
1987     bufList : TStringList;
1988     i, j, idx : Integer;
1989 begin
1990         URL := Trim(LowerCase(URL));
1991     for i := 0 to Length(START_NAME) -1 do begin
1992         idx := AnsiPos(START_NAME[i], URL);
1993         if (idx <> 0) then begin
1994             break;
1995         end;
1996         idx := AnsiPos(END_NAME[i], URL);
1997         if (idx <> 0) then begin
1998             break;
1999         end;
2000
2001     end;
2002
2003     if (idx <> 0) then begin
2004         idx := AnsiPos('?', URL);
2005         if (idx = 0) then begin
2006             idx := LastDelimiter('/', URL);
2007         end;
2008         stRes := 0;
2009         endRes := 0;
2010         bufList := TStringList.Create();
2011         try
2012             bufList.Delimiter := '&';
2013             bufList.DelimitedText := Copy(URL, idx + 1, Length(URL));
2014             for  i := 0 to bufList.Count - 1 do begin
2015                 convBuf := '';
2016                 // \8aJ\8en\83\8c\83X\94Ô\82Ì\8c\9f\8dõ
2017                 if (stRes = 0) then begin
2018                     for j := 0 to Length(START_NAME) - 1 do begin
2019                         idx := AnsiPos(START_NAME[j], bufList[i]);
2020                         if (idx = 1) then begin
2021                             convBuf := Copy(bufList[i], idx + Length(START_NAME[j]), Length(bufList[i]));
2022                             stRes := StrToInt64Def( convBuf, 0 );
2023                             break;
2024                         end;
2025                     end;
2026                 end;
2027                 // \8fI\97¹\83\8c\83X\94Ô\82Ì\8c\9f\8dõ
2028                 if (convBuf = '') and (endRes = 0) then begin
2029                     for j := 0 to Length(END_NAME) - 1 do begin
2030                         idx := AnsiPos(END_NAME[j], bufList[i]);
2031                         if (idx = 1) then begin
2032                             convBuf := Copy(bufList[i], idx + Length(END_NAME[j]), Length(bufList[i]));
2033                             endRes := StrToInt64Def( convBuf, 0 );
2034                             break;
2035                         end;
2036                     end;
2037                 end;
2038                 // \83\8c\83X\94Ô\82Ì\8c\9f\8dõ
2039                 if ((stRes = 0) and (endRes = 0) and (convBuf = '')) then begin
2040                   for j := 0 to Length(RES_NAME) - 1 do begin
2041                       idx := AnsiPos(RES_NAME[j], bufList[i]);
2042                       if (idx = 1) then begin
2043                           convBuf := Copy(bufList[i], idx + Length(RES_NAME[j]), Length(bufList[i]));
2044                           stRes := StrToInt64Def( convBuf, 0 );
2045                           endRes := stRes;
2046                           break;
2047                       end;
2048                   end;
2049                 end;
2050             end;
2051
2052             if (stRes <> 0) and (endRes = 0) then begin
2053                         endRes := stRes + MAX_POPUP_RES;
2054                 end else if (stRes = 0) and (endRes <> 0) then begin
2055                 stRes := endRes - MAX_POPUP_RES;
2056                         if stRes < 1 then begin
2057                                 stRes := 1;
2058                 end;
2059             end;
2060         finally
2061             bufList.clear;
2062             bufList.free;
2063         end;
2064     end else if ( AnsiPos('.html',URL) <> Length(URL) -4 ) and ( AnsiPos('.htm',URL) <> Length(URL) -3 ) then begin
2065                 buf := Copy(URL, LastDelimiter('/',URL)+1,Length(URL)-LastDelimiter('/',URL)+1);
2066                 if  Length(buf) > 0 then begin
2067                         if AnsiPos('-', buf) = 1 then begin
2068                                 stRes := 0;
2069                                 Delete(buf,1,1);
2070                                 ps := 0;
2071                                 pch := PChar(buf);
2072                                 while  ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
2073                 convBuf := Copy( buf, 1, ps );
2074                 if convBuf <> '' then begin
2075                     endRes := StrToInt64Def(convBuf, 0);
2076                 end;
2077                                 if endRes <> 0 then begin
2078                                         stRes := endRes - MAX_POPUP_RES;
2079                                         if stRes < 1 then
2080                                                 stRes := 1;
2081                                 end;
2082                         end else begin
2083                                 ps := 0;
2084                                 pch := PChar(buf);
2085                                 while  ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
2086                                 try
2087                                         convBuf := Copy( buf, 1, ps );
2088                                         if convBuf <> '' then begin
2089                                                 stRes := StrToInt64(convBuf);
2090                                                 Delete(buf,1,ps+1);
2091                                                 ps := 0;
2092                                                 pch := PChar(buf);
2093                                                 while  ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
2094                         convBuf := Copy( buf, 1, ps );
2095                         if convBuf <> '' then begin
2096                             endRes := StrToInt64Def(convBuf, 0);
2097                         end;
2098                                         end else begin
2099                                                 stRes := 0;
2100                                         end;
2101                                 except
2102                                         stRes := 0;
2103                                         endRes := 0;
2104                                 end;
2105                         end;
2106                 end;
2107         end;
2108 end;
2109
2110 {!
2111 \brief 2\82¿\82á\82ñ\82Ë\82é\8c`\8e®\82Ì URL \82ð\95ª\89ð
2112 \param URL 2\82¿\82á\82ñ\82Ë\82é\8c`\8e®\82Ì URL
2113 \return    \95ª\89ð\82³\82ê\82½\97v\91f
2114 }
2115 function TGikoSys.Parse2chURL2(URL: string): TPathRec;
2116 var
2117         i: Integer;
2118         s: string;
2119 //      buf : String;
2120 //      convBuf : String;
2121         wk: string;
2122         wkMin: Integer;
2123         wkMax: Integer;
2124         wkInt: Integer;
2125         RStart: Integer;
2126         RLength: Integer;
2127 //      ps : Integer;
2128 //      pch : PChar;
2129         SList: TStringList;
2130 begin
2131         URL := Trim(LowerCase(URL));
2132         Result.FBBS := '';
2133         Result.FKey := '';
2134         Result.FSt := 0;
2135         Result.FTo := 0;
2136         Result.FFirst := False;
2137         Result.FStBegin := False;
2138         Result.FToEnd := False;
2139         Result.FDone := False;
2140         Result.FNoParam := False;
2141
2142         wkMin := 0;
2143         wkMax := 1;
2144         if URL[length(URL)] = '\' then
2145                 URL := URL + 'n';
2146         FAWKStr.RegExp := 'http://.+\.(2ch\.net|bbspink\.com)/';
2147         if FAWKStr.Match(FAWKStr.ProcessEscSeq(URL), RStart, RLength) <> 0 then begin
2148                 s := Copy(URL, RStart + RLength - 1, Length(URL));
2149
2150                 //\95W\8f\80\8f\91\8e®
2151                 //\8dÅ\8cã\82Íl50, 10, 10-20, 10n, 10-20n, -10, 10-, 10n- \82È\82Ç
2152                 //http://xxx.2ch.net/test/read.cgi/bbsid/1000000000/
2153                 FAWKStr.RegExp := '/test/read.(cgi|html)/.+/[0-9]+/?.*';
2154                 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2155                         s := Copy(s, 15, Length(s));
2156
2157                         SList := TStringList.Create;
2158                         try
2159                                 SList.Clear;
2160                                 FAWKStr.RegExp := '/';
2161                                 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 3 then begin
2162                                         Result.FBBS := SList[1];
2163                                         Result.FKey := SList[2];
2164                                         if SList.Count >= 4 then
2165                                                 s := SList[3]
2166                                         else begin
2167                                                 s := '';
2168                                                 Result.FNoParam := true;
2169                                         end;
2170                                 end else
2171                                         Exit;
2172
2173                                 SList.Clear;
2174                                 FAWKStr.LineSeparator := mcls_CRLF;
2175                                 FAWKStr.RegExp := '-';
2176                                 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) = 0 then begin
2177                                         Result.FFirst := True;
2178                                 end else begin
2179                                         FAWKStr.RegExp := 'l[0-9]+';
2180                                         if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2181                                                 Result.FFirst := True;
2182                                         end else begin
2183                                                 for i := 0 to SList.Count - 1 do begin
2184                                                         if Trim(SList[i]) = '' then begin
2185                                                                 if i = 0 then
2186                                                                         Result.FStBegin := True;
2187                                                                 if i = (SList.Count - 1) then
2188                                                                         Result.FToEnd := True;
2189                                                         end else if IsNumeric(SList[i]) then begin
2190                                                                 wkInt := StrToInt(SList[i]);
2191                                                                 wkMax := Max(wkMax, wkInt);
2192                                                                 if wkMin = 0 then
2193                                                                         wkMin := wkInt
2194                                                                 else
2195                                                                         wkMin := Min(wkMin, wkInt);
2196                                                         end else if Trim(SList[i]) = 'n' then begin
2197                                                                 Result.FFirst := True;
2198                                                         end else begin
2199                                                                 FAWKStr.RegExp := '^n[0-9]+$|^[0-9]+n$';
2200                                                                 if FAWKStr.Match(FAWKStr.ProcessEscSeq(SList[i]), RStart, RLength) > 0 then begin
2201                                                                         if Copy(SList[i], 1, 1) = 'n' then
2202                                                                                 wkInt := StrToInt(Copy(SList[i], 2, Length(SList[i])))
2203                                                                         else
2204                                                                                 wkInt := StrToInt(Copy(SList[i], 1, Length(SList[i]) - 1));
2205                                                                         Result.FFirst := True;
2206                                                                         wkMax := Max(wkMax, wkInt);
2207                                                                         if wkMin = 1 then
2208                                                                                 wkMin := wkInt
2209                                                                         else
2210                                                                                 wkMin := Min(wkMin, wkInt);
2211                                                                 end;
2212                                                         end;
2213                                                 end;
2214                                                 if Result.FStBegin and (not Result.FToEnd) then
2215                                                         Result.FSt := wkMin
2216                                                 else if (not Result.FStBegin) and Result.FToEnd then
2217                                                         Result.FTo := wkMax
2218                                                 else if (not Result.FStBegin) and (not Result.FToEnd) then begin
2219                                                         Result.FSt := wkMin;
2220                                                         Result.FTo := wkMax;
2221                                                 end;
2222                                                 //Result.FSt := wkMin;
2223                                                 //Result.FTo := wkMax;
2224                                         end;
2225                                 end;
2226                         finally
2227                                 SList.Free;
2228                         end;
2229                         Result.FDone := True;
2230                         Exit;
2231                 end;
2232
2233                 //\90Vkako\8f\91\8e®
2234                 //http://server.2ch.net/ITA_NAME/kako/1000/10000/1000000000.html
2235                 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+/[0-9]+\.html';
2236                 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2237                         SList := TStringList.Create;
2238                         try
2239                                 SList.Clear;
2240                                 FAWKStr.RegExp := '/';
2241                                 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2242                                         Result.FBBS := SList[1];
2243                                         Result.FKey := ChangeFileExt(SList[5], '');
2244                                         Result.FFirst := True;
2245                                 end else
2246                                         Exit;
2247                         finally
2248                                 SList.Free;
2249                         end;
2250                         Result.FDone := True;
2251                         Exit;
2252                 end;
2253
2254                 //\8b\8ckako\8f\91\8e®
2255                 //http://server.2ch.net/ITA_NAME/kako/999/999999999.html
2256                 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+\.html';
2257                 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2258                         SList := TStringList.Create;
2259                         try
2260                                 SList.Clear;
2261                                 FAWKStr.RegExp := '/';
2262                                 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 5 then begin
2263                                         Result.FBBS := SList[1];
2264                                         Result.FKey := ChangeFileExt(SList[4], '');
2265                                         Result.FFirst := True;
2266                                 end else
2267                                         Exit;
2268                         finally
2269                                 SList.Free;
2270                         end;
2271                         Result.FDone := True;
2272                         Exit;
2273                 end;
2274
2275                 //log\8by\82Ñlog2\8f\91\8e®
2276                 //http://server.2ch.net/log/ITA_NAME/kako/999/999999999.html
2277                 //http://server.2ch.net/log2/ITA_NAME/kako/999/999999999.html
2278                 FAWKStr.RegExp := '/log2?/.+/kako/[0-9]+/[0-9]+\.html';
2279                 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2280                         SList := TStringList.Create;
2281                         try
2282                                 SList.Clear;
2283                                 FAWKStr.RegExp := '/';
2284                                 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2285                                         Result.FBBS := SList[2];
2286                                         Result.FKey := ChangeFileExt(SList[5], '');
2287                                         Result.FFirst := True;
2288                                 end else
2289                                         Exit;
2290                         finally
2291                                 SList.Free;
2292                         end;
2293                         Result.FDone := True;
2294                         Exit;
2295                 end;
2296
2297
2298                 //\8b\8cURL\8f\91\8e®
2299                 //http://server.2ch.net/test/read.cgi?bbs=ITA_NAME&key=1000000000&st=1&to=5&nofirst=true
2300                 FAWKStr.RegExp := '/test/read\.cgi\?';
2301                 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2302                         s := Copy(s, 16, Length(s));
2303                         SList := TStringList.Create;
2304                         try
2305                                 SList.Clear;
2306                                 FAWKStr.RegExp := '&';
2307                                 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2308                                         Result.FFirst := True;
2309                                         for i := 0 to SList.Count - 1 do begin
2310                                                 if Pos('bbs=', SList[i]) = 1 then begin
2311                                                         Result.FBBS := Copy(SList[i], 5, Length(SList[i]));
2312                                                 end else if Pos('key=', SList[i]) = 1 then begin
2313                                                         Result.FKey := Copy(SList[i], 5, Length(SList[i]));
2314                                                 end else if Pos('st=', SList[i]) = 1 then begin
2315                                                         wk := Copy(SList[i], 4, Length(SList[i]));
2316                                                         if IsNumeric(wk) then
2317                                                                 Result.FSt := StrToInt(wk)
2318                                                         else if wk = '' then
2319                                                                 Result.FStBegin := True;
2320                                                 end else if Pos('to=', SList[i]) = 1 then begin
2321                                                         wk := Copy(SList[i], 4, Length(SList[i]));
2322                                                         if IsNumeric(wk) then
2323                                                                 Result.FTo := StrToInt(wk)
2324                                                         else if wk = '' then
2325                                                                 Result.FToEnd := True;
2326                                                 end else if Pos('nofirst=', SList[i]) = 1 then begin
2327                                                         Result.FFirst := False;
2328                                                 end;
2329                                         end;
2330                                 end else
2331                                         Exit;
2332                         finally
2333                                 SList.Free;
2334                         end;
2335
2336                         if (Result.FBBS <> '') and (Result.FKey <> '') then begin
2337                                 Result.FDone := True;
2338                         end;
2339                         Exit;
2340                 end;
2341         end;
2342 end;
2343
2344 {!
2345 \brief URI \82ð\95ª\89ð
2346 \param URL      \95ª\89ð\82·\82é URI
2347 \param Protocol OUT:\83v\83\8d\83g\83R\83\8b\82ª\95Ô\82é(ex. http)
2348 \param Host     OUT:\83z\83X\83g\82ª\95Ô\82é(ex. hoge.com)
2349 \param Path     OUT:\92\86\8aÔ\83p\83X\82ª\95Ô\82é(ex. test/read.cgi)
2350 \param Document OUT:\83h\83L\83\85\83\81\83\93\83g\96¼\82ª\95Ô\82é(ex. index.html)
2351 \param Port     OUT:\83|\81[\83g\82ª\95Ô\82é(ex. 8080)
2352 \param Bookmark OUT:\83u\83b\83N\83}\81[\83N(?)\82ª\95Ô\82é
2353 }
2354 procedure TGikoSys.ParseURI(const URL : string; var Protocol, Host, Path, Document, Port, Bookmark: string);
2355 var
2356         URI: TIdURI;
2357 begin
2358         Protocol := '';
2359         Host := '';
2360         Path := '';
2361         Document := '';
2362         Port := '';
2363         Bookmark := '';
2364         URI := TIdURI.Create(URL);
2365         try
2366                 Protocol := URI.Protocol;
2367                 Host := URI.Host;
2368                 Path := URI.Path;
2369                 Document := URI.Document;
2370                 Port := URI.Port;
2371                 Bookmark := URI.Bookmark;
2372         finally
2373                 URI.Free;
2374         end;
2375 end;
2376
2377 {!
2378 \brief \83M\83R\83i\83r\82Ì\83o\81[\83W\83\87\83\93\82ð\8eæ\93¾
2379 \return \83o\81[\83W\83\87\83\93\82Ì\89º 2 \8c\85(dwFileVersionLS)
2380 }
2381 function TGikoSys.GetVersionBuild: Integer;
2382 var
2383         FixedFileInfo: PVSFixedFileInfo;
2384         VersionHandle, VersionSize: DWORD;
2385         pVersionInfo: Pointer;
2386         ItemLen : UInt;
2387         AppFile: string;
2388 begin
2389         Result := 0;
2390         AppFile := Application.ExeName;
2391         VersionSize := GetFileVersionInfoSize(pChar(AppFile), VersionHandle);
2392         if VersionSize = 0 then
2393                 Exit;
2394         GetMem(pVersionInfo, VersionSize);
2395         try
2396                 if GetFileVersionInfo(PChar(AppFile),VersionHandle,VersionSize, pVersionInfo) then
2397                         if VerQueryValue(pVersionInfo, '\', Pointer(FixedFileInfo), ItemLen) then
2398                                 Result := LOWORD(FixedFileInfo^.dwFileVersionLS);
2399         finally
2400                 FreeMem(pVersionInfo, VersionSize);
2401         end;
2402 end;
2403
2404 {!
2405 \brief \83X\83\8c\83b\83h URL \82Ì\90³\8bK\89»
2406 \param inURL \90³\8bK\89»\82·\82é\83X\83\8c\83b\83h URL
2407 \return      \90³\8bK\89»\82³\82ê\82½\83X\83\8c\83b\83h URL
2408
2409 \83X\83\8c\83b\83h URL \82ð\83M\83R\83i\83r\82Ì\92\86\82Å\88ê\88Ó\82È\82à\82Ì\82É\90³\8bK\89»\82µ\82Ü\82·\81B
2410 \88ê\88Ó\82È URL \82É\82·\82é\8e\96\82Å\81AURL \82©\82ç\83X\83\8c\83b\83h\82ð\93±\82«\8fo\82·\8dì\8bÆ\82ð\8dÅ\93K\89»\82µ\82Ü\82·\81B\n
2411 \90³\8bK\89»\82Ì\95û\90j\82Æ\82µ\82Ä\81A\83T\83C\83g\82ª\90\84\8f§\82·\82é\83f\83t\83H\83\8b\83g\82Ì URL \82É\82È\82é\82æ\82¤\82É\90S\82ª\82¯\82Ü\82·\81B
2412 (1-1000 \82Ì\82æ\82¤\82È\95\89\89×\82ð\82©\82¯\82é\82à\82Ì\82É\82Í\82µ\82È\82¢\82±\82Æ)
2413
2414 \97á(\90³\8bK\89»\91O):\n
2415 http://\92\86\97ª/ \n
2416 http://\92\86\97ª/20-100
2417
2418 (\90³\8bK\89»\8cã):\n
2419 http://\92\86\97ª/l50
2420 }
2421 function        TGikoSys.GetBrowsableThreadURL(
2422         inURL : string
2423 ) : string;
2424 var
2425         threadItem      : TThreadItem;
2426         boardPlugIn     : TBoardPlugIn;
2427     board               : TBoard;
2428         i                                               : Integer;
2429 begin
2430
2431         //===== \83v\83\89\83O\83C\83\93
2432         try
2433                 for i := Length( BoardGroups ) - 1 downto 1 do begin
2434                         if Assigned( Pointer( BoardGroups[i].BoardPlugIn.Module ) ) then begin
2435                                 if BoardGroups[i].BoardPlugIn.AcceptURL( inURL ) = atThread then begin
2436                     board := BBSsFindBoardFromURL( BoardGroups[i].BoardPlugIn.ExtractBoardURL(inURL) );
2437                                         if board <> nil then begin
2438                                                 boardPlugIn := BoardGroups[i].BoardPlugIn;
2439                                                 threadItem      := TThreadItem.Create( boardPlugIn, board, inURL );
2440                                                 Result                  := threadItem.URL;
2441                                                 threadItem.Free;
2442
2443                                         end;
2444                                         Exit;
2445                                 end;
2446                         end;
2447                 end;
2448         except
2449                 // exception \82ª\94­\90\82µ\82½\8fê\8d\87\82Í\93à\95\94\8f\88\97\9d\82É\94C\82¹\82½\82¢\82Ì\82Å\82±\82±\82Å\82Í\89½\82à\82µ\82È\82¢
2450         end;
2451
2452         if Length( Result ) = 0 then
2453                 Result := GikoSys.Get2chBrowsableThreadURL( inURL );
2454
2455 end;
2456
2457 {!
2458 \brief \83X\83\8c\83b\83h URL \82ð\94 URL \82É\95Ï\8a·
2459 \param inURL \83X\83\8c\83b\83h URL
2460 \return      \94 URL
2461 }
2462 function        TGikoSys.GetThreadURL2BoardURL(
2463         inURL : string
2464 ) : string;
2465 var
2466         threadItem      : TThreadItem;
2467         boardPlugIn     : TBoardPlugIn;
2468     board               : TBoard;
2469         i                                               : Integer;
2470 begin
2471
2472         //===== \83v\83\89\83O\83C\83\93
2473         try
2474                 for i := Length( BoardGroups ) - 1 downto 1 do begin
2475                         if Assigned( Pointer( BoardGroups[i].BoardPlugIn.Module ) ) then begin
2476                                 if BoardGroups[i].BoardPlugIn.AcceptURL( inURL ) = atThread then begin
2477                     board               := BBSsFindBoardFromURL(BoardGroups[i].BoardPlugIn.ExtractBoardURL(inURL));
2478                                         boardPlugIn := BoardGroups[i].BoardPlugIn;
2479                                         threadItem      := TThreadItem.Create( boardPlugIn, board, inURL );
2480                                         Result                  := BoardGroups[i].BoardPlugIn.GetBoardURL( Longword( threadItem ) );
2481                                         threadItem.Free;
2482
2483                                         Break;
2484                                 end;
2485                         end;
2486                 end;
2487         except
2488                 // exception \82ª\94­\90\82µ\82½\8fê\8d\87\82Í\93à\95\94\8f\88\97\9d\82É\94C\82¹\82½\82¢\82Ì\82Å\82±\82±\82Å\82Í\89½\82à\82µ\82È\82¢
2489         end;
2490
2491         if Length( Result ) = 0 then
2492                 Result := GikoSys.Get2chThreadURL2BoardURL( inURL );
2493
2494 end;
2495
2496 {!
2497 \brief 2ch\97p:\83X\83\8c\83b\83h URL \82ð\94 URL \82É\95Ï\8a·
2498 \param inURL \83X\83\8c\83b\83h URL
2499 \return      \94 URL
2500 \see TGikoSys.GetThreadURL2BoardURL
2501 }
2502 function        TGikoSys.Get2chThreadURL2BoardURL(
2503         inURL : string
2504 ) : string;
2505 var
2506         Protocol, Host, Path, Document, Port, Bookmark : string;
2507         BBSID, BBSKey : string;
2508         foundPos                        : Integer;
2509 begin
2510
2511         ParseURI( inURL, Protocol, Host, Path, Document, Port, Bookmark );
2512         Parse2chURL( inURL, Path, Document, BBSID, BBSKey );
2513
2514         foundPos := Pos( '/test/read.cgi', inURL );
2515         if {(Is2chHost(Host)) and} (foundPos > 0) then
2516                 Result := Copy( inURL, 1, foundPos ) + BBSID + '/'
2517         else
2518                 Result := Protocol + '://' + Host + '/' + BBSID + '/';
2519
2520 end;
2521
2522 {!
2523 \brief 2ch\97p:\83X\83\8c\83b\83h URL \82Ì\90³\8bK\89»
2524 \param inURL \90³\8bK\89»\82·\82é\83X\83\8c\83b\83h URL
2525 \return      \90³\8bK\89»\82³\82ê\82½\83X\83\8c\83b\83h URL
2526 \see TGikoSys.GetBrowsableThreadURL
2527 }
2528 function        TGikoSys.Get2chBrowsableThreadURL(
2529         inURL                   : string
2530 ) : string;
2531 var
2532         Protocol, Host, Path, Document, Port, Bookmark : string;
2533         BBSID, BBSKey : string;
2534         foundPos        : Integer;
2535 begin
2536
2537 //      if Pos( KAKO_PATH, inURL ) > 0 then begin
2538 //              Result := inURL;
2539 //      end else begin
2540                 ParseURI( inURL, Protocol, Host, Path, Document, Port, Bookmark );
2541                 Parse2chURL( inURL, Path, Document, BBSID, BBSKey );
2542                 foundPos := Pos( '/test/read.cgi', inURL ) - 1;
2543
2544                 if Is2chHost( Host ) then begin
2545                         Result := Protocol + '://' + Host +
2546                                 READ_PATH + BBSID + '/' + BBSKey + '/l50';
2547                 end else begin
2548                         if foundPos > 0 then
2549                                 Result := Copy( inURL, 1, foundPos ) +
2550                                         OLD_READ_PATH + 'bbs=' + BBSID + '&key=' + BBSKey + '&ls=50'
2551                         else
2552                                 Result := Protocol + '://' + Host +
2553                                         OLD_READ_PATH + 'bbs=' + BBSID + '&key=' + BBSKey + '&ls=50';
2554                 end;
2555 //      end;
2556
2557 end;
2558
2559 {!
2560 \brief 2ch\97p:\94 URL \82©\82ç\83X\83\8c\83b\83h URL \82ð\8dì\90¬
2561 \param inBoard \94 URL
2562 \param inKey   \83X\83\8c\83b\83h\83L\81[(ex. 1000000000)
2563 \return        \83X\83\8c\83b\83h URL
2564 }
2565 function        TGikoSys.Get2chBoard2ThreadURL(
2566         inBoard : TBoard;
2567         inKey           : string
2568 ) : string;
2569 var
2570         server  : string;
2571 begin
2572
2573         server := UrlToServer( inBoard.URL );
2574         //if Is2chHost( server ) then
2575         if inBoard.Is2ch then
2576                 Result := server + 'test/read.cgi/' + inBoard.BBSID + '/' + inKey + '/l50'
2577         else
2578                 Result := server + 'test/read.cgi?bbs=' + inBoard.BBSID + '&key=' + inKey + '&ls=50';
2579
2580 end;
2581
2582 {!
2583 \brief \83{\81[\83h\83t\83@\83C\83\8b\97ñ\8b\93
2584
2585 \97ñ\8b\93\82³\82ê\82½ BBS(\83{\81[\83h) \82Í BBSs \82É\93ü\82è\82Ü\82·\81B
2586 }
2587 procedure TGikoSys.ListBoardFile;
2588 var
2589         boardFileList   : TStringList;
2590         i, l                    : Integer;
2591     sCategory       : TCategory;
2592 begin
2593         // BBS \82Ì\8aJ\95ú
2594         try
2595           for i := 0 to Length( BBSs ) - 1 do
2596                 BBSs[ i ].Free;
2597         except
2598         end;
2599         SetLength( BBSs, 0 );
2600
2601         l := 0;
2602         // \94Â\83\8a\83X\83g\82Ì\97ñ\8b\93
2603         if FileExists( GikoSys.GetBoardFileName ) then begin
2604           SetLength( BBSs, l + 1 );
2605           BBSs[ l ]                             := TBBS.Create( GikoSys.GetBoardFileName );
2606           BBSs[ l ].Title       := '\82Q\82¿\82á\82ñ\82Ë\82é';
2607                   Inc( l );
2608         end;
2609
2610         if FileExists( GikoSys.GetCustomBoardFileName ) then begin
2611           SetLength( BBSs, l + 1 );
2612           BBSs[ l ]                             := TBBS.Create( GikoSys.GetCustomBoardFileName );
2613           BBSs[ l ].Title       := '\82»\82Ì\91¼';
2614                   Inc( l );
2615         end;
2616
2617         // Board \83t\83H\83\8b\83_
2618         if DirectoryExists( GikoSys.Setting.GetBoardDir ) then begin
2619           BoardFileList := TStringList.Create;
2620           try
2621         BoardFileList.BeginUpdate;
2622                 GikoSys.GetFileList( GikoSys.Setting.GetBoardDir, '*.txt', BoardFileList, True, True );
2623         BoardFileList.EndUpdate;
2624         SetLength( BBSs, l + BoardFileList.Count );
2625                 for i := BoardFileList.Count - 1 downto 0 do begin
2626                   BBSs[ l ]                             := TBBS.Create( BoardFileList[ i ] );
2627                   BBSs[ l ].Title       := ChangeFileExt( ExtractFileName( BoardFileList[ i ] ), '' );
2628                   Inc( l );
2629                 end;
2630           finally
2631                 BoardFileList.Free;
2632           end;
2633         end;
2634
2635     // \93Á\8eê\97p\93rBBS\90\90¬
2636     // \8aù\82É\91\8dÝ\82·\82é\8fê\8d\87\82Í\8dí\8f\9c\82·\82é
2637     DestorySpecialBBS(BoardGroup.SpecialBBS);
2638     SpecialBBS := TBBS.Create('');
2639     SpecialBBS.Title := '\93Á\8eê\97p\93r(\94ñ\95\\8e¦)';
2640     sCategory := TCategory.Create;
2641     sCategory.No := 1;
2642     sCategory.Title := '\93Á\8eê\97p\93r(\94ñ\95\\8e¦)';
2643     SpecialBBS.Add(sCategory);
2644     BoardGroup.SpecialBoard := TSpecialBoard.Create(nil, 'http://localhost/gikonavi/special/index.html');
2645     BoardGroup.SpecialBoard.Title := '\83^\83u\88ê\97\97';
2646     BoardGroup.SpecialBoard.IsThreadDatRead := True;
2647     sCategory.Add(BoardGroup.SpecialBoard);
2648 end;
2649
2650 {!
2651 \brief \83{\81[\83h\83t\83@\83C\83\8b\93Ç\82Ý\8d\9e\82Ý
2652 \param bbs \83{\81[\83h\83t\83@\83C\83\8b\82ð\93Ç\82Ý\8d\9e\82Þ BBS
2653 }
2654 procedure TGikoSys.ReadBoardFile( bbs : TBBS );
2655 var
2656 //      idx                                             : Integer;
2657         ini                                             : TMemIniFile;
2658         p : Integer;
2659         boardFile                       : TStringList;
2660         CategoryList    : TStringList;
2661         BoardList                       : TStringList;
2662         Category                        : TCategory;
2663         Board                                   : TBoard;
2664         inistr                          : string;
2665         tmpstring                       : string;
2666 //      RoundItem                       : TRoundItem;
2667
2668         i, iBound                       : Integer;
2669         j, jBound                       : Integer;
2670         k, kBound                       : Integer;
2671 begin
2672
2673         if not FileExists( bbs.FilePath ) then
2674                 Exit;
2675
2676         bbs.Clear;
2677         ini := TMemIniFile.Create('');
2678         boardFile := TStringList.Create;
2679
2680         try
2681                 boardFile.LoadFromFile( bbs.FilePath );
2682
2683                 ini.SetStrings( boardFile );
2684                 CategoryList    := TStringList.Create;
2685                 BoardList                       := TStringList.Create;
2686                 try
2687                         ini.ReadSections( CategoryList );
2688
2689                         iBound := CategoryList.Count - 1;
2690                         for i := 0 to iBound do begin
2691                                 ini.ReadSection( CategoryList[i], BoardList );
2692                                 Category                                := TCategory.Create;
2693                                 Category.No                     := i + 1;
2694                                 Category.Title  := CategoryList[i];
2695
2696                                 jBound := BoardList.Count - 1;
2697                                 for j := 0 to jBound do begin
2698                                         Board := nil;
2699                                         inistr := ini.ReadString(CategoryList[i], BoardList[j], '');
2700                                         //'http://'\82ð\8aÜ\82Ü\82È\82¢\95\8e\9a\97ñ\82Ì\8e\9e\82Í\96³\8e\8b\82·\82é
2701                                         if (AnsiPos('http://', AnsiLowerCase(inistr)) = 0) then Continue;
2702                                         //===== \83v\83\89\83O\83C\83\93
2703                                         try
2704                                                 kBound := Length(BoardGroups) - 1;
2705                                                 for k := 1 to kBound do begin  //0\82Í\81A2\82¿\82á\82ñ
2706                                                         if Assigned( Pointer( BoardGroups[k].BoardPlugIn.Module ) ) then begin
2707                                                                 if BoardGroups[k].BoardPlugIn.AcceptURL( inistr ) = atBoard then begin
2708                                                                         if not BoardGroups[k].Find(inistr, p) then begin
2709                                                                                 tmpstring := BoardGroups[k].BoardPlugIn.ExtractBoardURL( inistr );
2710                                                                                 if AnsiCompareStr(tmpString, inistr) <> 0 then begin
2711                                                                                         if not BoardGroups[k].Find(tmpstring, p) then begin
2712                                                                                                 try
2713                                                                                                         Board := TBoard.Create( BoardGroups[k].BoardPlugIn, tmpstring );
2714                                                                                                         BoardGroups[k].AddObject(tmpstring, Board);
2715                                                                                                         Category.Add(Board);
2716                                                                                                 except
2717                                                                                                         //\82±\82±\82É\97\88\82é\82Æ\82µ\82½\82çBoard\82Ì\8dì\90¬\82É\8e¸\94s\82µ\82½\82Æ\82«\82¾\82©\82çBoard\82ðnil\82É\82·\82é
2718                                                                                                         Board := nil;
2719                                                                                                 end;
2720                                                                                         end else begin
2721                                                                                                 Board := TBoard(BoardGroups[k].Objects[p]);
2722                                                                                                 if Board.ParentCategory <> Category then
2723                                                                                                         Category.Add(Board);
2724                                                                                         end;
2725                                                                                 end else begin
2726                                                                                         try
2727                                                                                                 Board := TBoard.Create( BoardGroups[k].BoardPlugIn, tmpstring );
2728                                                                                                 BoardGroups[k].AddObject(tmpstring, Board);
2729                                                                                                 Category.Add(Board);
2730                                                                                         except
2731                                                                                                 //\82±\82±\82É\97\88\82é\82Æ\82µ\82½\82çBoard\82Ì\8dì\90¬\82É\8e¸\94s\82µ\82½\82Æ\82«\82¾\82©\82çBoard\82ðnil\82É\82·\82é
2732                                                                                                 Board := nil;
2733                                                                                         end;
2734                                                                                 end;
2735                                                                         end else begin
2736                                                                                 Board := TBoard(BoardGroups[k].Objects[p]);
2737                                                                                 if Board.ParentCategory <> Category then
2738                                                                                         Category.Add(Board);
2739                                                                         end;
2740                                                                         Break;
2741                                                                 end;
2742                                                         end;
2743                                                 end;
2744                                         except
2745                                                 // exception \82ª\94­\90\82µ\82½\8fê\8d\87\82Í\93à\95\94\8f\88\97\9d\82É\94C\82¹\82½\82¢\82Ì\82Å\82±\82±\82Å\82Í\89½\82à\82µ\82È\82¢
2746                                         end;
2747                                         try
2748                                                 if (Board = nil) then begin
2749                                                         if not BoardGroups[0].Find(inistr,p) then begin
2750                                                                 Board := TBoard.Create( nil, inistr );
2751                                                                 BoardGroups[0].AddObject(inistr, Board);
2752                                                                 Category.Add(Board);
2753                                                         end else begin
2754                                                                 Board := TBoard(BoardGroups[0].Objects[p]);
2755                                                                 if Board.ParentCategory <> Category then
2756                                                                         Category.Add(Board);
2757                                                         end;
2758                                                 end;
2759
2760                                                 if (Board.Multiplicity = 0) then begin
2761                                                         Board.BeginUpdate;
2762                                                         Board.No := j + 1;
2763                             Board.Multiplicity := 1;
2764                                                         Board.Title := BoardList[j];
2765                                                         Board.RoundDate := ZERO_DATE;
2766                                                         Board.LoadSettings;
2767                                                         Board.EndUpdate;
2768                                                 end else begin
2769                                                         Board.No := j + 1;
2770                                                         Board.Multiplicity := Board.Multiplicity + 1;
2771                                                 end;
2772                                         except
2773                                         end;
2774                                 end;
2775                                 bbs.Add( Category );
2776                         end;
2777
2778
2779                   //end;
2780                   bbs.IsBoardFileRead := True;
2781           finally
2782                 BoardList.Free;
2783                 CategoryList.Free;
2784           end;
2785   finally
2786         boardFile.Free;
2787         ini.Free;
2788   end;
2789
2790 end;
2791
2792 {!
2793 \brief \96¼\8fÌ\82ª\95s\96¾\82È\83J\83e\83S\83\8a\82Ì\90\90¬
2794 \return \90\90¬\82³\82ê\82½\83J\83e\83S\83\8a
2795 }
2796 function        TGikoSys.GetUnknownCategory : TCategory;
2797 const
2798         UNKNOWN_CATEGORY = '(\96¼\8fÌ\95s\96¾)';
2799 begin
2800
2801         if Length( BBSs ) < 2 then begin
2802                 Result := nil;
2803                 Exit;
2804         end;
2805
2806         Result := BBSs[ 1 ].FindCategoryFromTitle( UNKNOWN_CATEGORY );
2807         if Result = nil then begin
2808                 Result                          := TCategory.Create;
2809                 Result.Title    := UNKNOWN_CATEGORY;
2810                 BBSs[ 1 ].Add( Result );
2811         end;
2812
2813 end;
2814
2815 {!
2816 \brief \96¼\8fÌ\82ª\95s\96¾\82È BBS \82Ì\90\90¬
2817 \return \90\90¬\82³\82ê\82½ BBS
2818 }
2819 function        TGikoSys.GetUnknownBoard( inPlugIn : TBoardPlugIn; inURL : string ) : TBoard;
2820 var
2821         category : TCategory;
2822 const
2823         UNKNOWN_BOARD = '(\96¼\8fÌ\95s\96¾)';
2824 begin
2825
2826         category := GetUnknownCategory;
2827         if category = nil then begin
2828                 Result := nil;
2829         end else begin
2830                 Result := category.FindBoardFromTitle( UNKNOWN_BOARD );
2831                 if Result = nil then begin
2832                         Result                          := TBoard.Create( inPlugIn, inURL );
2833                         Result.Title    := UNKNOWN_BOARD;
2834                         category.Add( Result );
2835                 end;
2836         end;
2837
2838 end;
2839
2840 //! Samba.ini
2841 function TGikoSys.GetSambaFileName : string;
2842 begin
2843         Result := Setting.GetSambaFileName;
2844 end;
2845 {!
2846 \brief \97ñ\8b\93\82³\82ê\82½\83\8c\83X\94Ô\8d\86\82Ö\82Ì\83A\83\93\83J\81[\97pHTML\8dì\90¬
2847 \param Numbers    \97ñ\8b\93\82³\82ê\82½\83\8c\83X\94Ô\8d\86
2848 \param ThreadItem \97ñ\8b\93\82·\82é\83X\83\8c\83b\83h
2849 \param limited    \97ñ\8b\93\82·\82é\90\94\82ð\90§\8cÀ\82·\82é\82È\82ç1\88È\8fã
2850 \return           \97ñ\8b\93\82³\82ê\82½\83\8c\83X\83A\83\93\83J\81[
2851 }
2852 function TGikoSys.CreateResAnchor(
2853     var Numbers: TStringList; ThreadItem: TThreadItem;
2854     limited: Integer):string;
2855 var
2856         i: integer;
2857     Res: TResRec;
2858     ResLink : TResLinkRec;
2859 begin
2860     // body\88È\8aO\82Í\8eg\97p\82µ\82È\82¢\82Ì\82Å\8f\89\8aú\89»\82µ\82È\82¢
2861     Res.FBody := '';
2862     Res.FType := glt2chNew;
2863
2864         Result := '';
2865         if (Numbers <> nil) and (Numbers.Count > 0) then begin
2866         if (limited > 0) and (Numbers.Count > limited) then begin
2867             for i := Numbers.Count - limited to Numbers.Count - 1 do begin
2868                 Res.FBody := Res.FBody + '&gt;' + Numbers[i] + ' ';
2869             end;
2870         end else begin
2871             for i := 0 to Numbers.Count - 1 do begin
2872                 Res.FBody := Res.FBody + '&gt;' + Numbers[i] + ' ';
2873             end;
2874         end;
2875         ResLink.FBbs := ThreadItem.ParentBoard.BBSID;
2876         ResLink.FKey := ChangeFileExt(ThreadItem.FileName, '');
2877         HTMLCreater.ConvRes(@Res, @ResLink, false);
2878         Result := Res.FBody;
2879     end;
2880 end;
2881
2882 {!
2883 \brief \93¯\82\93\8a\8de ID \82ð\8e\9d\82Â\83\8c\83X\82ð\97ñ\8b\93
2884 \param AID        \8cÂ\90l\82ð\93Á\92è\82·\82é\93\8a\8de ID
2885 \param ThreadItem \97ñ\8b\93\82·\82é\83X\83\8c\83b\83h
2886 \param body       OUT:\97ñ\8b\93\82³\82ê\82½\83\8c\83X\94Ô\8d\86\82ª\95Ô\82é
2887 }
2888 procedure TGikoSys.GetSameIDRes(const AID : string; ThreadItem: TThreadItem;var body: TStringList);
2889 var
2890         i: integer;
2891         ReadList: TStringList;
2892         Res: TResRec;
2893         boardPlugIn : TBoardPlugIn;
2894
2895     procedure CheckSameID(const AID:String; const Target: String; no: Integer);
2896     var
2897         pos: Integer;
2898     begin
2899         pos := AnsiPos('id:', LowerCase(Target));
2900         if (pos > 0) then begin
2901             if(AnsiPos(AID, Copy(Target, pos-1, Length(Target))) > 0) then begin
2902                 body.Add(IntToStr(no));
2903             end;
2904         end else begin
2905             if(AnsiPos(AID, Target) > 0) then begin
2906                 body.Add(IntToStr(no));
2907             end;
2908         end;
2909     end;
2910 begin
2911         if (not IsNoValidID(AID)) and
2912         (ThreadItem <> nil) and (ThreadItem.IsLogFile) then begin
2913                 //if ThreadItem.IsBoardPlugInAvailable then begin
2914         if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
2915                         //===== \83v\83\89\83O\83C\83\93\82É\82æ\82é\95\\8e¦
2916                         //boardPlugIn           := ThreadItem.BoardPlugIn;
2917             boardPlugIn         := ThreadItem.ParentBoard.BoardPlugIn;
2918
2919                         for i := 0 to threadItem.Count - 1 do begin
2920                                 // \83\8c\83X
2921                                 THTMLCreate.DivideStrLine(boardPlugIn.GetDat(DWORD( threadItem ), i + 1), @Res);
2922                 CheckSameID(AID, Res.FDateTime, i+1);
2923                         end;
2924                 end else begin
2925                         ReadList := TStringList.Create;
2926                         try
2927                                 ReadList.LoadFromFile(ThreadItem.GetThreadFileName);
2928                                 for i := 0 to ReadList.Count - 1 do begin
2929                                         THTMLCreate.DivideStrLine(ReadList[i], @Res);
2930                     CheckSameID(AID, Res.FDateTime, i+1);
2931                                 end;
2932                         finally
2933                                 ReadList.Free;
2934                         end;
2935                 end;
2936         end;
2937 end;
2938
2939 {!
2940 \brief \93¯\82\93\8a\8de ID \82ð\8e\9d\82Â\83\8c\83X\82ð\97ñ\8b\93
2941 \param AIDNum     \8cÂ\90l\82ð\93Á\92è\82·\82é\93\8a\8de ID
2942 \param ThreadItem \97ñ\8b\93\82·\82é\83X\83\8c\83b\83h
2943 \param body       OUT:\97ñ\8b\93\82³\82ê\82½\83\8c\83X\94Ô\8d\86\82ª\95Ô\82é
2944 }
2945 procedure TGikoSys.GetSameIDRes(AIDNum : Integer; ThreadItem: TThreadItem;var body: TStringList);
2946 var
2947         AID : String;
2948 begin
2949     AID := GetResID(AIDNum, ThreadItem);
2950     if not IsNoValidID(AID) then begin
2951             GetSameIDRes(AID, ThreadItem, body);
2952         end;
2953 end;
2954 {!
2955 \brief \93\8a\8de ID \8eæ\93¾
2956 \param AIDNum     \93\8a\8d\83\8c\83X\94Ô\8d\86
2957 \param ThreadItem \93\8a\8de\83X\83\8c\83b\83h
2958 \param body       OUT:\93\8a\8deID
2959 }
2960 function TGikoSys.GetResID(AIDNum: Integer; ThreadItem: TThreadItem): String;
2961 var
2962         Res: TResRec;
2963         boardPlugIn : TBoardPlugIn;
2964 begin
2965     Result := '';
2966         if (ThreadItem <> nil) and (ThreadItem.IsLogFile)
2967                 and (AIDNum > 0) and (AIDNum <= ThreadItem.Count) then begin
2968                 //if ThreadItem.IsBoardPlugInAvailable then begin
2969         if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
2970                         //===== \83v\83\89\83O\83C\83\93\82É\82æ\82é\95\\8e¦
2971                         //boardPlugIn           := ThreadItem.BoardPlugIn;
2972             boardPlugIn         := ThreadItem.ParentBoard.BoardPlugIn;
2973                         THTMLCreate.DivideStrLine(boardPlugIn.GetDat(DWORD( threadItem ), AIDNum), @Res);
2974                 end else begin
2975                         THTMLCreate.DivideStrLine( ReadThreadFile(ThreadItem.GetThreadFileName, AIDNum), @Res);
2976                 end;
2977                 Result := ExtructResID(Res.FDateTime);
2978         end;
2979 end;
2980 {!
2981 \brief \83\8c\83X\82Ì\8e\9e\8d\8f\95\94\82©\82çID\82ð\92\8a\8fo\82·\82é
2982 \param ADateStr \8e\9e\8d\8f\95\94\82Ì\95\8e\9a\97ñ
2983 \return     ID(ID\82Æ\82Ý\82È\82¹\82é\95\94\95ª\82ª\82È\82¢\82Æ\82«\82Í\8bó\95\8e\9a\97ñ)
2984 }
2985 function TGikoSys.ExtructResID(ADateStr: String): String;
2986 var
2987     stlist : TStringList;
2988 begin
2989     Result := '';
2990     if AnsiPos('id', AnsiLowerCase(ADateStr)) > 0 then begin
2991         Result := Copy(ADateStr, AnsiPos('id', AnsiLowerCase(ADateStr)), Length(ADateStr));
2992         if AnsiPos(' ', Result) > 0 then begin
2993             Result := Copy(Result, 1, AnsiPos(' ', Result) - 1);
2994         end;
2995         Result := ' ' + Result;
2996     end else begin
2997         stlist := TStringList.Create;
2998         try
2999             stList.Delimiter := ' ';
3000             stList.DelimitedText := ADateStr;
3001             // \93ú\95\8e\9e\8d\8f ID \91¼\81@\82Æ\8cÅ\92è\82Å\8dl\82¦\82é
3002             if (stList.Count >= 3) then begin
3003                 if Length(stList[3 - 1]) >= 7 then begin
3004                     Result := stList[3 - 1];
3005                 end;
3006             end;
3007         finally
3008             stList.Free;
3009         end;
3010     end;
3011 end;
3012
3013 {!
3014 \brief \83X\83p\83\80:\8cê\90\94\82ð\83J\83E\83\93\83g
3015 \param text      \8c³\82É\82È\82é\95\8fÍ
3016 \param wordCount OUT:\83J\83E\83\93\83g\82³\82ê\82½\92P\8cê\82Ì\88ê\97\97\82ª\95Ô\82é
3017 }
3018 procedure TGikoSys.SpamCountWord( const text : string; wordCount : TWordCount );
3019 begin
3020
3021         if Setting.SpamFilterAlgorithm = gsfaNone then Exit;
3022         Bayesian.CountWord( text, wordCount );
3023
3024 end;
3025
3026 {!
3027 \brief \83X\83p\83\80:\8aw\8fK\8c\8b\89Ê\82ð\95ú\8aü
3028 \param wordCount \95ú\8aü\82·\82é\92P\8cê\82Ì\88ê\97\97
3029 \param isSpam    wordCount \82ª\83X\83p\83\80\82Æ\82µ\82Ä\8aw\8fK\82³\82ê\82Ä\82¢\82½\82È\82ç True
3030 \warning        \8aw\8fK\8dÏ\82Ý\82Ì\95\8fÍ\82©\82Ç\82¤\82©\82Í\8am\94F\8fo\97\88\82Ü\82¹\82ñ\81B\n
3031                                         Learn \82µ\82Ä\82¢\82È\82¢\95\8fÍ\82â isSpam \82ð\8aÔ\88á\82¦\82Ä\8ew\92è\82·\82é\82Æ
3032                                         \83f\81[\83^\83x\81[\83X\82ª\94j\91¹\82µ\82Ü\82·\81B\n
3033                                         \8aw\8fK\8dÏ\82Ý\82©\82Ç\82¤\82©\82Í\93Æ\8e©\82É\8aÇ\97\9d\82µ\82Ä\82­\82¾\82³\82¢\81B
3034
3035 \91S\82Ä\82Ì\8aw\8fK\8c\8b\89Ê\82ð\83N\83\8a\83A\82·\82é\82í\82¯\82Å\82Í\82 \82è\82Ü\82¹\82ñ\81B\n
3036 wordCount \82ð\93¾\82½\95\8fÍ\82Ì\8aw\8fK\8c\8b\89Ê\82Ì\82Ý\83N\83\8a\83A\82µ\82Ü\82·\81B
3037
3038 \8eå\82É\83X\83p\83\80\82Æ\83n\83\80\82ð\90Ø\82è\91Ö\82¦\82é\82½\82ß\82É Forget -> Learn \82Ì\8f\87\82Å\8eg\97p\82µ\82Ü\82·\81B
3039 }
3040 procedure TGikoSys.SpamForget( wordCount : TWordCount; isSpam : Boolean );
3041 begin
3042
3043         if Setting.SpamFilterAlgorithm = gsfaNone then Exit;
3044         Bayesian.Forget( wordCount, isSpam );
3045
3046 end;
3047
3048 {!
3049 \brief \83X\83p\83\80:\8aw\8fK
3050 \param wordCount \8aw\8fK\82·\82é\92P\8cê\82Ì\88ê\97\97
3051 \param isSpam    \83X\83p\83\80\82Æ\82µ\82Ä\8aw\8fK\82·\82é\82È\82ç True
3052 }
3053 procedure TGikoSys.SpamLearn( wordCount : TWordCount; isSpam : Boolean );
3054 begin
3055
3056         if Setting.SpamFilterAlgorithm = gsfaNone then Exit;
3057         Bayesian.Learn( wordCount, isSpam );
3058
3059 end;
3060
3061 {!
3062 \brief \83X\83p\83\80:\95\8fÍ\82ð\89ð\90Í\82µ\81A\83X\83p\83\80\93x\90\94\82ð\93¾\82é
3063 \param text      \8c³\82É\82È\82é\95\8fÍ
3064 \param wordCount OUT:\83J\83E\83\93\83g\82³\82ê\82½\92P\8cê\82Ì\88ê\97\97\82ª\95Ô\82é(SpamCountWord \82Æ\93¯\93\99)
3065 \return          0\81`1 \82Ì\83X\83p\83\80\93x\90\94
3066 }
3067 function TGikoSys.SpamParse( const text : string; wordCount : TWordCount ) : Extended;
3068 begin
3069
3070         case Setting.SpamFilterAlgorithm of
3071         gsfaNone:                                                               Result := 0;
3072         gsfaPaulGraham:                                 Result := Bayesian.Parse( text, wordCount, gbaPaulGraham );
3073         gsfaGaryRobinson:                               Result := Bayesian.Parse( text, wordCount, gbaGaryRobinson );
3074         gsfaGaryRobinsonFisher: Result := Bayesian.Parse( text, wordCount, gbaGaryRobinsonFisher );
3075         else                                                                            Result := 0;
3076         end;
3077
3078 end;
3079
3080 {!
3081 \brief \83\86\81[\83U\90Ý\92è\82Ì CSS \82ð\90\90¬
3082 \return \90\90¬\82³\82ê\82½ CSS
3083
3084 [\83c\81[\83\8b]\83\81\83j\83\85\81[-[\83I\83v\83V\83\87\83\93]-[CSS \82Æ\83X\83L\83\93]\83^\83u\82Ì
3085 [\83t\83H\83\93\83g\82ð\8ew\92è], [\94w\8ci\90F\82ð\8ew\92è] \82É\89\88\82Á\82½ CSS \82ð\90\90¬\82µ\82Ü\82·\81B
3086 }
3087 function TGikoSys.SetUserOptionalStyle(): string;
3088 begin
3089                 Result := '';
3090         if Length( GikoSys.Setting.BrowserFontName ) > 0 then
3091                 Result := 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
3092         if GikoSys.Setting.BrowserFontSize <> 0 then
3093                 Result := Result + 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
3094         if GikoSys.Setting.BrowserFontColor <> -1 then
3095                 Result := Result + 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
3096         if GikoSys.Setting.BrowserBackColor <> -1 then
3097                 Result := Result + 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
3098         case GikoSys.Setting.BrowserFontBold of
3099                 -1: Result := Result + 'font-weight:normal;';
3100                 1:  Result := Result + 'font-weight:bold;';
3101         end;
3102         case GikoSys.Setting.BrowserFontItalic of
3103                 -1: Result := Result + 'font-style:normal;';
3104                 1:  Result := Result + 'font-style:italic;';
3105         end;
3106 end;
3107
3108 {!
3109 \brief Be \83v\83\8d\83t\83@\83C\83\8b\82Ö\82Ì\83A\83\93\83J\81[\83^\83O\82ð\90\90¬
3110 \param AID  \91Î\8fÛ\82Æ\82È\82é\93ú\95tID\95\8e\9a\97ñ
3111 \param ANum \83\8c\83X\94Ô
3112 \param AURL \82»\82Ì\83X\83\8c\83b\83h\82ÌURL
3113 \return     \90\90¬\82³\82ê\82½\83A\83\93\83J\81[\83^\83O
3114 }
3115 function TGikoSys.AddBeProfileLink(AID : string; ANum: Integer):string ;
3116 var
3117         p : integer;
3118         BNum, BMark : string;
3119 begin
3120         p := AnsiPos('BE:', AnsiUpperCase(AID));
3121         if p > 0 then begin
3122                 BNum := Copy(AID, p, Length(AID));
3123                 AID := Copy(AID, 1, p - 1);
3124                 p := AnsiPos('-', BNum);
3125                 if p > 0 then begin
3126                         BMark := '?' + Trim(Copy(BNum, p + 1, Length(BNum)));
3127                         BNum := Copy(BNum, 1, p - 1);
3128                 end;
3129                 BNum := Trim(BNum);
3130                 Result := AID + ' <a href="'  + BNum + '/' + IntToStr(ANum)
3131                         + '" target=_blank>' + BMark + '</a>';
3132         end else
3133                 Result := AID;
3134 end;
3135
3136 {!
3137 \brief \83o\81[\83W\83\87\83\93\8fî\95ñ\82ð\8eæ\93¾
3138 \param KeyWord \8eæ\93¾\82·\82é\8d\80\96Ú
3139 \return        \83o\81[\83W\83\87\83\93\95\8e\9a\97ñ
3140 }
3141 function TGikoSys.GetVersionInfo(KeyWord: TVerResourceKey): string;
3142 const
3143         Translation = '\VarFileInfo\Translation';
3144         FileInfo = '\StringFileInfo\%0.4s%0.4s\';
3145 var
3146         BufSize, HWnd: DWORD;
3147         VerInfoBuf: Pointer;
3148         VerData: Pointer;
3149         VerDataLen: Longword;
3150         PathLocale: String;
3151 begin
3152         // \95K\97v\82È\83o\83b\83t\83@\82Ì\83T\83C\83Y\82ð\8eæ\93¾
3153         BufSize := GetFileVersionInfoSize(PChar(Application.ExeName), HWnd);
3154         if BufSize <> 0 then begin
3155                 // \83\81\83\82\83\8a\82ð\8am\95Û
3156                 GetMem(VerInfoBuf, BufSize);
3157                 try
3158                         GetFileVersionInfo(PChar(Application.ExeName), 0, BufSize, VerInfoBuf);
3159                         // \95Ï\90\94\8fî\95ñ\83u\83\8d\83b\83N\93à\82Ì\95Ï\8a·\83e\81[\83u\83\8b\82ð\8ew\92è
3160                         VerQueryValue(VerInfoBuf, PChar(Translation), VerData, VerDataLen);
3161
3162                         if not (VerDataLen > 0) then
3163                                 raise Exception.Create('\8fî\95ñ\82Ì\8eæ\93¾\82É\8e¸\94s\82µ\82Ü\82µ\82½');
3164
3165                         // 8\8c\85\82Ì\82P\82U\90i\90\94\82É\95Ï\8a·
3166                         // \81¨'\StringFileInfo\027382\FileDescription'
3167                         PathLocale := Format(FileInfo + KeyWordStr[KeyWord],
3168                         [IntToHex(Integer(VerData^) and $FFFF, 4),
3169                         IntToHex((Integer(VerData^) shr 16) and $FFFF, 4)]);
3170                         VerQueryValue(VerInfoBuf, PChar(PathLocale), VerData, VerDataLen);
3171
3172                         if VerDataLen > 0 then begin
3173                                 // VerData\82Í\83[\83\8d\82Å\8fI\82í\82é\95\8e\9a\97ñ\82Å\82Í\82È\82¢\82±\82Æ\82É\92\8d\88Ó
3174                                 result := '';
3175                                 SetLength(result, VerDataLen);
3176                                 StrLCopy(PChar(result), VerData, VerDataLen);
3177                         end;
3178                 finally
3179                         // \89ð\95ú
3180                         FreeMem(VerInfoBuf);
3181                 end;
3182         end;
3183 end;
3184
3185 {!
3186 \brief Load \82³\82ê\82Ä\82¢\82é\83v\83\89\83O\83C\83\93\82Ì\83o\81[\83W\83\87\83\93\82ð\97ñ\8b\93
3187 \return 1\8ds1plugin
3188 }
3189 function TGikoSys.GetPluginsInfo(): String;
3190 var
3191         i : Integer;
3192         major, minor, revision : Cardinal;
3193         agent, release : String;
3194 begin
3195         //\8c\8b\89Ê\82ð\83N\83\8a\83A\82µ\82Ä\82¨\82­
3196         Result := '';
3197
3198         //BoardGroups\8co\97R\82ÅPlugin\82É\83A\83N\83Z\83X\82·\82é
3199         for  i := 0 to Length(BoardGroups) - 1 do begin
3200                 //BoardGroups\82Ì\92\86\82É\82Í\81APlugin\82ð\8e\9d\82Á\82Ä\82¢\82È\82¢\82Ì\81i2\82¿\82á\82ñ\81j\82ª
3201                 //\82¢\82é\82Ì\82Å\82»\82ê\82ð\8f\9c\82­
3202                 if BoardGroups[i].BoardPlugIn <> nil then begin
3203                         BoardGroups[i].BoardPlugIn.VersionInfo(agent, major, minor, release, revision);
3204
3205
3206                         //"Plugin\82Ì\96¼\91O(major.minor.revision)"
3207                         Result := Result +
3208                                 Format('%s(%d.%d.%d)', [agent, major, minor, revision]) + #13#10;
3209                 end;
3210         end;
3211 end;
3212
3213
3214 //! IE\82Ì\83o\81[\83W\83\87\83\93\82ð\8eæ\93¾\82·\82é
3215 function TGikoSys.GetIEVersion: string;
3216 var
3217         R: TRegistry;
3218 begin
3219         R := TRegistry.Create;
3220         try
3221                 //\93Ç\82Ý\8eæ\82è\90ê\97p\82É\82µ\82È\82¢\82Æ\81A\90§\8cÀUSER\82Æ\82©\82Ì\8fê\8d\87\81A\8aJ\82¯\82È\82¢\82Ý\82½\82¢
3222                 R.Access := KEY_EXECUTE;
3223                 R.RootKey := HKEY_LOCAL_MACHINE;
3224                 R.OpenKey('Software\Microsoft\Internet Explorer', False);
3225                 try
3226                         Result := R.ReadString('version');
3227                 except
3228                         Result := '\83o\81[\83W\83\87\83\93\82Ì\8eæ\93¾\82É\8e¸\94s\82µ\82Ü\82µ\82½\81B';
3229                 end;
3230                 R.CloseKey;
3231         finally
3232                 R.Free;
3233         end;
3234 end;
3235 //! main\83t\83H\81[\83\80\82Ì\83V\83\87\81[\83g\83J\83b\83g\83L\81[\82ÌIni\83t\83@\83C\83\8b\96¼
3236 function TGikoSys.GetMainKeyFileName : String;
3237 begin
3238         Result := Setting.GetMainKeyFileName;
3239 end;
3240 //! Editor\83t\83H\81[\83\80\82Ì\83V\83\87\81[\83g\83J\83b\83g\83L\81[\82ÌIni\83t\83@\83C\83\8b\96¼
3241 function TGikoSys.GetEditorKeyFileName: String;
3242 begin
3243         Result := Setting.GetEditorKeyFileName;
3244 end;
3245 //! \93ü\97Í\83A\83V\83X\83g\82Ì\90Ý\92è\83t\83@\83C\83\8b\96¼
3246 function TGikoSys.GetInputAssistFileName: String;
3247 begin
3248         Result := Setting.GetInputAssistFileName;
3249 end;
3250 //! \83M\83R\83i\83r\82Ì\83\81\83b\83Z\81[\83W\82ð\90Ý\92è\82·\82é
3251 procedure TGikoSys.SetGikoMessage;
3252 begin
3253         if FGikoMessage = nil then begin
3254                 FGikoMessage := TGikoMessage.Create;
3255         end else begin
3256                 FGikoMessage.Clear;
3257         end;
3258
3259         if (Setting.GengoSupport) then begin
3260                 try
3261                         if (FileExists(Setting.GetLanguageFileName)) then begin
3262                                 FGikoMessage.LoadFromFile(Setting.GetLanguageFileName);
3263                         end;
3264                 except
3265                         FGikoMessage.Clear;
3266                 end;
3267         end;
3268 end;
3269 //! \83M\83R\83i\83r\82Ì\83\81\83b\83Z\81[\83W\82ð\8eæ\93¾\82·\82é
3270 function TGikoSys.GetGikoMessage(MesType: TGikoMessageListType): String;
3271 begin
3272     Result := '';
3273         if FGikoMessage <> nil then begin
3274                 Result := FGikoMessage.GetMessage(MesType);
3275         end;
3276 end;
3277
3278 //Tue, 17 Dec 2002 12:18:07 GMT \81¨ TDateTime\82Ö
3279 //MonaUtils\82©\82ç\88Ú\93®
3280 function  TGikoSys.DateStrToDateTime(const DateStr: string): TDateTime;
3281         function  StrMonthToMonth(const s: string): integer;
3282         const
3283                 m: array[1..12] of string = ('Jan','Feb','Mar','Apr','May','Jun', 'Jul','Aug','Sep','Oct','Nov','Dec');
3284         var
3285                 i: integer;
3286         begin
3287                 Result  :=  -1;
3288                 for i :=  Low(m)  to  High(m) do  begin
3289                         if  (SameText(s, m[i]))  then  begin
3290                                 Result  :=  i;
3291                                 Break;
3292                         end;
3293                 end;
3294         end;
3295 var
3296         wDay, wMonth, wYear: word;
3297         wHour, wMinute, wSecond: word;
3298         sTime: string;
3299         d: TDateTime;
3300 begin
3301         wDay    :=  StrToIntDef(ChooseString(DateStr, ' ', 1), 0);
3302         wMonth  :=  StrMonthToMonth(ChooseString(DateStr, ' ', 2));
3303         wYear   :=  StrToIntDef(ChooseString(DateStr, ' ', 3), 0);
3304         sTime   :=  ChooseString(DateStr, ' ', 4);
3305         wHour   :=  StrToIntDef(ChooseString(sTime, ':', 0), 0);
3306         wMinute :=  StrToIntDef(ChooseString(sTime, ':', 1), 0);
3307         wSecond :=  StrToIntDef(ChooseString(sTime, ':', 2), 0);
3308         d :=  EncodeDateTime(wYear, wMonth, wDay, wHour, wMinute, wSecond, 0);
3309         Result  :=  d;
3310 end;
3311 //MonaUtils\82©\82ç\88Ú\93®
3312 //! \82 \82é\83Z\83p\83\8c\81[\83^\82Å\8bæ\90Ø\82ç\82ê\82½\95\8e\9a\97ñ\82©\82ç\82\8e\94Ô\96Ú\82Ì\95\8e\9a\97ñ\82ð\8eæ\82è\8fo\82·
3313 function TGikoSys.ChooseString(const Text, Separator: string; Index: integer): string;
3314 var
3315         S : string;
3316         i, p : integer;
3317 begin
3318         S :=  Text;
3319         for i :=  0 to  Index - 1 do  begin
3320                 if  (AnsiPos(Separator, S) = 0) then  S :=  ''
3321                 else  S :=  Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
3322         end;
3323         p :=  AnsiPos(Separator, S);
3324         if  (p > 0) then  Result  :=  Copy(S, 1, p - 1) else Result :=  S;
3325 end;
3326 //! \88ê\8e\9e\83t\83@\83C\83\8b\82©\82ç\82Ì\95\9c\8b\8c
3327 procedure TGikoSys.RestoreThreadData(Board : TBoard);
3328 const
3329     SECTION = 'Setting';
3330 var
3331     TmpFileList : TStringList;
3332     i : Integer;
3333     ini : TMemIniFile;
3334     ThreadItem : TThreadItem;
3335     Boardpath, tmpStr : string;
3336 begin
3337     Boardpath := ExtractFilePath(Board.GetFolderIndexFileName);
3338
3339         TmpFileList := TStringList.Create;
3340         TmpFileList.Sorted := True;
3341         TmpFileList.BeginUpdate;
3342     try
3343         //\91O\89ñ\88Ù\8fí\8fI\97¹\8e\9e\97pTmp\83t\83@\83C\83\8b\83\8a\83X\83g
3344             GetFileList(Boardpath, '*.tmp', TmpFileList, False);
3345             TmpFileList.EndUpdate;
3346                 //\91O\89ñ\88Ù\8fí\8fI\97¹\8e\9e\83`\83F\83b\83N
3347                 for i := TmpFileList.Count - 1 downto 0 do begin
3348                         ThreadItem := Board.FindThreadFromFileName(ChangeFileExt(TmpFileList[i], '.dat'));
3349                         if ThreadItem <> nil then begin
3350                                 ini := TMemIniFile.Create(Boardpath + TmpFileList[i]);
3351                                 try
3352                                         tmpStr := ini.ReadString(SECTION, 'RoundDate', DateTimeToStr(ZERO_DATE));
3353                                         ThreadItem.RoundDate := ConvertDateTimeString(tmpStr);
3354
3355                                         tmpStr := ini.ReadString(SECTION, 'LastModified', DateTimeToStr(ZERO_DATE));
3356                                         ThreadItem.LastModified := ConvertDateTimeString(tmpStr);
3357                                         ThreadItem.Count := ini.ReadInteger(SECTION, 'Count', 0);
3358                                         ThreadItem.NewReceive := ini.ReadInteger(SECTION, 'NewReceive', 0);
3359
3360                                         ThreadItem.Size := ini.ReadInteger(SECTION, 'Size', 0);
3361                     ThreadItem.IsLogFile := FileExists(ThreadItem.GetThreadFileName);
3362                                         if(ThreadItem.Size = 0) and (ThreadItem.IsLogFile) then begin
3363                                                 try
3364                                                         ThreadItem.Size := GetFileSize(ThreadItem.GetThreadFileName) - ThreadItem.Count;
3365                                                 except
3366                                                 end;
3367                                         end;
3368
3369                     //\8f\84\89ñ\82Ì\90Ý\92è\82ÍRoundData\82Ì\95û\82ª\82â\82é\82©\82ç\8f\9f\8eè\82É\90Ý\92è\82µ\82Ä\82Í\83_\83\81\81I\81@by \82à\82\82ã
3370                                         //ThreadItem.Round := ini.ReadBool('Setting', 'Round', False);
3371                                         //ThreadItem.RoundName := ini.ReadString('Setting', 'RoundName', ThreadItem.RoundName);
3372                                         ThreadItem.UnRead := False;//ini.ReadBool('Setting', 'UnRead', False);
3373                                         ThreadItem.ScrollTop := ini.ReadInteger(SECTION, 'ScrollTop', 0);
3374                                         ThreadItem.AllResCount := ini.ReadInteger(SECTION, 'AllResCount', ThreadItem.Count);
3375                                         ThreadItem.NewResCount := ini.ReadInteger(SECTION, 'NewResCount', 0);
3376                                         ThreadItem.AgeSage := TGikoAgeSage(ini.ReadInteger(SECTION, 'AgeSage', Ord(gasNone)));
3377                                 finally
3378                                         ini.Free;
3379                                 end;
3380                                 DeleteFile(Boardpath + TmpFileList[i]);
3381                         end;
3382                 end;
3383     finally
3384         TmpFileList.Clear;
3385         TmpFileList.Free;
3386     end;
3387 end;
3388 {
3389 \brief User32.dll\82ª\97\98\97p\82Å\82«\82é\82©
3390 \return Boolean \97\98\97p\82Å\82«\82é\8fê\8d\87\82ÍTrue
3391 }
3392 function TGikoSys.CanUser32DLL: Boolean;
3393 var
3394     hUser32 : HINST;
3395 begin
3396     Result := False;
3397         hUser32 := 0;
3398         try
3399                 try
3400                         hUser32 := LoadLibrary('User32.dll');
3401                         if hUser32 <> 0 then begin
3402                                 Result := True;
3403             end;
3404                 except
3405                 Result := false;
3406                 end;
3407         finally
3408                 FreeLibrary(hUser32);
3409         end;
3410 end;
3411 {
3412 \brief  OE\88ø\97p\95\84\8eæ\93¾
3413 \return OE\82Ì\88ø\97p\95\84\81i\90Ý\92è\82³\82ê\82Ä\82¢\82È\82¢\8fê\8d\87\82Í'>')
3414 }
3415 function TGikoSys.GetOEIndentChar : string;
3416 var
3417         regKey                  : TRegistry;
3418         Identities      : string;
3419         IndentChar      : DWORD;
3420 const
3421         DEFAULT_CHAR    = '> ';
3422         OE_MAIL_PATH    = '\Software\Microsoft\Outlook Express\5.0\Mail';
3423         INDENT_CHAR             = 'Indent Char';
3424 begin
3425
3426         Result  := DEFAULT_CHAR;
3427         regKey  := TRegistry.Create;
3428         try
3429                 try
3430                         regKey.RootKey  := HKEY_CURRENT_USER;
3431                         if not regKey.OpenKey( 'Identities', False ) then
3432                                 Exit;
3433                         Identities                      := regKey.ReadString( 'Default User ID' );
3434                         if Identities = '' then
3435                                 Exit;
3436                         if not regKey.OpenKey( Identities + OE_MAIL_PATH, False ) then
3437                                 Exit;
3438                         IndentChar := regKey.ReadInteger( INDENT_CHAR );
3439                         Result := Char( IndentChar ) + ' ';
3440                 except
3441                 end;
3442         finally
3443                 regKey.Free;
3444         end;
3445
3446 end;
3447 //! \92u\8a·\90Ý\92è\83t\83@\83C\83\8b\8eæ\93¾
3448 function TGikoSys.GetReplaceFileName: String;
3449 begin
3450     Result := Setting.GetReplaceFileName;
3451 end;
3452 //! \83v\83\8c\83r\83\85\81[\8ag\92£\82Ì\90Ý\92è\83t\83@\83C\83\8b\8eæ\93¾
3453 function TGikoSys.GetExtpreviewFileName: String;
3454 begin
3455     Result := Setting.GetExtprevieFileName;
3456 end;
3457
3458 //! \83t\83@\83C\83\8b\96¼\82©\82ç\82Ì\83X\83\8c\83b\83h\8dì\90¬\93ú\82Ì\8eæ\93¾
3459 function TGikoSys.GetCreateDateFromName(FileName: String): TDateTime;
3460 var
3461     tmp : String;
3462     unixtime: Int64;  
3463 begin
3464     // \83\8d\83O\83t\83@\83C\83\8b\82Ì\8ag\92£\8eq\82ð\82Í\82¸\82µ\82½\82à\82Ì\82ª\83X\83\8c\8dì\90¬\93ú\8e\9e
3465     tmp := ChangeFileExt(FileName, '');
3466     if AnsiPos('_', tmp) <> 0 then
3467         if AnsiPos('_', tmp) > 9 then
3468             tmp := Copy(tmp, 1, AnsiPos('_', tmp)-1)
3469         else
3470             Delete(tmp, AnsiPos('_', tmp), 1);
3471
3472     if ( Length(tmp) = 9) and ( tmp[1] = '0' ) then
3473         Insert('1', tmp, 1);
3474
3475     unixtime := StrToInt64Def(tmp, ZERO_DATE);
3476     Result := UnixToDateTime(unixtime) + OffsetFromUTC;
3477 end;
3478
3479 procedure TGikoSys.ShowRefCount(msg: String; unk: IUnknown);
3480 {$IFDEF DEBUG}
3481 var
3482     count : integer;
3483 {$ENDIF}
3484 begin
3485     if not Assigned(unk) then
3486         Exit;
3487
3488 {$IFDEF DEBUG}
3489     try
3490         unk._AddRef;
3491         count := unk._Release;
3492
3493                 Writeln(msg + ' RefCount=' + IntToStr(count));
3494     except
3495                 Writeln(msg + ' RefCount=exception!!');
3496         end;
3497 {$ENDIF}
3498 end;
3499 function TGikoSys.GetBoukenCookie(AURL: String): String;
3500 var
3501         Protocol, Host, Path, Document, Port,Bookmark : String;
3502 begin
3503     Result := '';
3504     GikoSys.ParseURI(AURL, Protocol, Host, Path, Document, Port,Bookmark);
3505     if ( Length(Host) > 0 ) then begin
3506         Result := Setting.GetBoukenCookie(Host);
3507     end;
3508 end;
3509 procedure TGikoSys.SetBoukenCookie(ACookieValue, ADomain: String);
3510 begin
3511     if ( Length(ADomain) > 0 ) then begin
3512         Setting.SetBoukenCookie(ACookieValue, ADomain);
3513     end;
3514 end;
3515 //! \96`\8c¯\82Ì\8f\91Domain\88ê\97\97\8eæ\93¾
3516 procedure TGikoSys.GetBoukenDomain(var ADomain: TStringList);
3517 var
3518     i : Integer;
3519 begin
3520     ADomain.Clear;
3521     for i := 0 to Setting.BoukenCookieList.Count - 1 do begin
3522         ADomain.Add( Setting.BoukenCookieList.Names[i] );
3523     end;
3524 end;
3525 //! \96`\8c¯\82Ì\8f\91Cookie\8dí\8f\9c
3526 procedure TGikoSys.DelBoukenCookie(ADomain: String);
3527 var
3528     i : Integer;
3529 begin
3530     for i := 0 to Setting.BoukenCookieList.Count - 1 do begin
3531         if ( Setting.BoukenCookieList.Names[i] = ADomain ) then begin
3532             Setting.BoukenCookieList.Delete(i);
3533             Break;
3534         end;
3535     end;
3536 end;
3537 function TGikoSys.GetBouken(AURL: String; var Domain: String): String;
3538 var
3539         Protocol, Host, Path, Document, Port,Bookmark : String;
3540     Cookie : String;
3541 begin
3542     Domain := '';
3543     Cookie := '';
3544     GikoSys.ParseURI(AURL, Protocol, Host, Path, Document, Port,Bookmark);
3545     if ( Length(Host) > 0 ) then begin
3546         Setting.GetBouken(Host, Domain, Cookie);
3547         Result := Cookie;
3548     end;
3549 end;
3550
3551 initialization
3552         GikoSys := TGikoSys.Create;
3553
3554 finalization
3555         if GikoSys <> nil then begin
3556                 FreeAndNil(GikoSys);
3557         end;
3558 end.