6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
7 ComCtrls, IniFiles, ShellAPI, ActnList, Math,
15 {HttpApp,} YofUtils, URLMon, IdGlobal, IdURI, {Masks,}
16 Setting, BoardGroup, gzip, Dolib, bmRegExp, AbonUnit,
17 MojuUtils, ExternalBoardManager, ExternalBoardPlugInMain;
21 TGikoBBSType = (gbt2ch);
22 //
\83\8d\83O
\83^
\83C
\83v
23 TGikoLogType = (glt2chNew, glt2chOld);
24 //
\83\81\83b
\83Z
\81[
\83W
\83A
\83C
\83R
\83\93
25 TGikoMessageIcon = (gmiOK, gmiSAD, gmiNG, gmiWhat, gmiNone);
26 //URL
\83I
\81[
\83v
\83\93\83u
\83\89\83E
\83U
\83^
\83C
\83v
27 TGikoBrowserType = (gbtIE, gbtUserApp, gbtAuto);
30 TStrTokSeparator = set of Char;
36 //
\83C
\83\93\83f
\83b
\83N
\83X
\83t
\83@
\83C
\83\8b\83\8c\83R
\81[
\83h
44 FRoundDate: TDateTime;
45 FLastModified: TDateTime;
48 FMishiyou: Boolean; //
\96¢
\8eg
\97p
52 FAllResCount: Integer;
53 FNewResCount: Integer;
54 FAgeSage: TGikoAgeSage;
57 //
\83T
\83u
\83W
\83F
\83N
\83g
\83\8c\83R
\81[
\83h
64 //
\83\8c\83X
\83\8c\83R
\81[
\83h
74 //URLPath
\83\8c\83R
\81[
\83h
77 FKey: string; //ThreadID
78 FSt: Integer; //
\8aJ
\8en
\83\8c\83X
\94Ô
79 FTo: Integer; //
\8fI
\97¹
\83\8c\83X
\94Ô
80 FFirst: Boolean; //>>1
\82Ì
\95\
\8e¦
81 FStBegin: Boolean; //1
\81`
\95\
\8e¦
82 FToEnd: Boolean; //
\81`
\8dÅ
\8cã
\82Ü
\82Å
\95\
\8e¦
83 FDone: Boolean; //
\90¬
\8c÷
86 TGikoSys = class(TObject)
92 FOnlyAHundredRes : Boolean;
93 // FExitWrite: TStringList;
94 // function StrToFloatDef(s: string; Default: Double): Double;
98 FSelectResFilter : TAbon;
101 destructor Destroy; override;
102 property OnlyAHundredRes : Boolean read FOnlyAHundredRes write FOnlyAHundredRes;
104 // function MsgBox(Msg: string; Title: string; Flags: Longint): integer; overload;
105 // function MsgBox(Handle: THandle; Msg: string; Title: string; Flags: Longint): integer; overload;
106 function IsNumeric(s: string): boolean;
107 function IsFloat(s: string): boolean;
108 function DirectoryExistsEx(const Name: string): Boolean;
109 function ForceDirectoriesEx(Dir: string): Boolean;
110 // function GetVersion: string;
112 function GetBoardFileName: string;
113 function GetCustomBoardFileName: string;
114 function GetHtmlTempFileName: string;
115 function GetAppDir: string;
116 function GetTempFolder: string;
117 function GetSentFileName: string;
118 function GetConfigDir: string;
119 function GetSkinDir: string;
120 function GetSkinHeaderFileName: string;
121 function GetSkinFooterFileName: string;
122 function GetSkinResFileName: string;
123 function GetSkinNewResFileName: string;
124 function GetSkinBookmarkFileName: string;
125 function GetSkinNewmarkFileName: string;
126 function GetStyleSheetDir: string;
127 function GetOutBoxFileName: string;
128 function GetUserAgent: string;
130 procedure ReadSubjectFile(Board: TBoard);
131 procedure CreateThreadDat(Board: TBoard);
132 procedure WriteThreadDat(Board: TBoard);
133 function ParseIndexLine(Line: string): TIndexRec;
134 procedure GetFileList(Path: string; Mask: string; List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
135 procedure GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
137 procedure CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
138 function AddAnchorTag(s: string): string;
140 function DivideSubject(Line: string): TSubjectRec;
141 function DivideStrLine(Line: string): TResRec;
143 property Setting: TSetting read FSetting write FSetting;
144 property Dolib: TDolib read FDolib write FDolib;
146 function UrlToID(url: string): string;
147 function UrlToServer(url: string): string;
149 function StrTokFirst(const s:string; const sep:TStrTokSeparator; var Rec:TStrTokRec):string;
150 function StrTokNext(const sep:TStrTokSeparator; var Rec:TStrTokRec): string;
152 function GetFileSize(FileName : string) : longint;
153 function GetFileLineCount(FileName : string): longint;
154 function Get2chDate(aDate: TDateTime): string;
155 function IntToDateTime(val: Int64): TDateTime;
156 function DateTimeToInt(ADate: TDateTime): Integer;
158 function ReadThreadFile(FileName: string; Line: Integer): string;
160 procedure MenuFont(Font: TFont);
162 function RemoveToken(var s:string;delimiter:string):string;
163 function GetTokenIndex(s: string; delimiter: string; index: Integer): string;
165 function DeleteLink(const s: string): string;
167 function GetShortName(const LongName: string; ALength: integer): string;
168 function ConvRes(const Body, Bbs, Key, ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string; overload;
169 function ConvRes(const Body, Bbs, Key, ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue, FullURL : string): string; overload;
171 function ZenToHan(const s: string): string;
172 function VaguePos(const Substr, S: string): Integer;
173 function BoolToInt(b: Boolean): Integer;
174 function IntToBool(i: Integer): Boolean;
175 function GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
176 procedure LoadKeySetting(ActionList: TActionList);
177 procedure SaveKeySetting(ActionList: TActionList);
178 procedure CreateProcess(const AppPath: string; const Param: string);
179 procedure OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
180 function HTMLDecode(const AStr: String): String;
181 function GetHRefText(s: string): string;
182 function Is2chHost(Host: string): Boolean;
183 function Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
184 function Parse2chURL2(URL: string): TPathRec;
185 procedure ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
186 function GetVersionBuild: Integer;
187 function GetBrowsableThreadURL( inURL : string ) : string;
188 function GetThreadURL2BoardURL( inURL : string ) : string;
189 function Get2chThreadURL2BoardURL( inURL : string ) : string;
190 function Get2chBrowsableThreadURL( inURL : string ) : string;
191 function Get2chBoard2ThreadURL( inBoard : TBoard; inKey : string ) : string;
192 procedure ReadBoardFile;
194 function GetUnknownCategory : TCategory;
195 function GetUnknownBoard( inPlugIn : TBoardPlugIn; inURL : string ) : TBoard;
197 //
\83X
\83L
\83\93\82ð
\93Ç
\82Ý
\8d\9e\82Ý
\81A
\92l
\82ð
\92u
\8a·
\82·
\82é
198 function LoadFromSkin( fileName: string; ThreadItem: TThreadItem; SizeByte: Integer ): string;
199 //
\83\8c\83X
\82Ì
\92l
\82ð
\92u
\8a·
\82·
\82é
200 function SkinedRes( skin: string; Res: TResRec; No: string ): string;
207 LENGTH_RESTITLE = 40;
208 ZERO_DATE: Integer = 25569;
209 BETA_VERSION_NAME_E = 'beta';
210 BETA_VERSION_NAME_J = 'ÊÞÀ';
212 BETA_VERSION_BUILD = ''; //debug
\94Å
\82È
\82Ç
213 APP_NAME = 'gikoNavi';
221 FOLDER_INDEX_VERSION = '1.01';
222 USER_AGENT = 'Monazilla';
223 DEFAULT_NGWORD_FILE_NAME : String = 'NGword.txt';
224 NGWORDs_DIR_NAME : String = 'NGwords';
226 READ_PATH: string = '/test/read.cgi/';
227 OLD_READ_PATH: string = '/test/read.cgi?';
228 KAKO_PATH: string = '/kako/';
230 (*************************************************************************
231 *GikoSys
\83R
\83\93\83X
\83g
\83\89\83N
\83^
232 *************************************************************************)
233 constructor TGikoSys.Create;
235 FSetting := TSetting.Create;
236 FDolib := TDolib.Create;
237 FAWKStr := TAWKStr.Create(nil);
238 if DirectoryExists(GetConfigDir) = false then begin
239 CreateDir(GetConfigDir);
241 FAbon := TAbon.Create;
242 FAbon.Setroot(GetConfigDir+NGWORDs_DIR_NAME);
244 FAbon.ReturnNGwordLineNum := FSetting.ShowNGLinesNum;
245 FAbon.SetNGResAnchor := FSetting.AddResAnchor;
246 FAbon.Deleterlo := FSetting.AbonDeleterlo;
247 FAbon.Replaceul := FSetting.AbonReplaceul;
248 FAbon.AbonPopupRes := FSetting.PopUpAbon;
250 FSelectResFilter := TAbon.Create;
251 //
\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
252 FSelectResFilter.AbonString := '';
254 OnlyAHundredRes := FSetting.OnlyAHundredRes;
257 (*************************************************************************
258 *GikoSys
\83f
\83X
\83g
\83\89\83N
\83^
259 *************************************************************************)
260 destructor TGikoSys.Destroy;
263 FileList: TStringList;
265 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
273 FSelectResFilter.Free;
274 //
\83e
\83\93\83|
\83\89\83\8aHTML
\82ð
\8dí
\8f\9c
275 FileList := TStringList.Create;
277 GetFileList(GetTempFolder, '*.html', FileList, False, True);
278 for i := 0 to FileList.Count - 1 do begin
279 DeleteFile(FileList[i]);
287 (*************************************************************************
288 *
\95¶
\8e\9a\97ñ
\90\94\8e\9a\83`
\83F
\83b
\83N
289 *************************************************************************)
291 function TGikoSys.IsNumeric(s: string): boolean;
301 (*************************************************************************
302 *
\95¶
\8e\9a\97ñ
\95\82\93®
\8f¬
\90\94\93_
\90\94\8e\9a\83`
\83F
\83b
\83N
303 *************************************************************************)
304 function TGikoSys.IsFloat(s: string): boolean;
308 Result := TextToFloat(PChar(s), v, fvExtended);
311 (*************************************************************************
312 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
313 *************************************************************************)
314 function TGikoSys.GetBoardFileName: string;
316 Result := Setting.GetBoardFileName;
319 (*************************************************************************
320 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
321 *************************************************************************)
322 function TGikoSys.GetCustomBoardFileName: string;
324 Result := Setting.GetCustomBoardFileName;
327 (*************************************************************************
328 *
\83e
\83\93\83|
\83\89\83\8a\83t
\83H
\83\8b\83_
\81[
\96¼
\8eæ
\93¾
329 *************************************************************************)
330 function TGikoSys.GetHtmlTempFileName: string;
332 Result := Setting.GetHtmlTempFileName;
336 (*************************************************************************
337 *
\8eÀ
\8ds
\83t
\83@
\83C
\83\8b\83t
\83H
\83\8b\83_
\8eæ
\93¾
338 *************************************************************************)
339 function TGikoSys.GetAppDir: string;
341 Result := Setting.GetAppDir;
344 (*************************************************************************
345 *TempHtml
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
346 *************************************************************************)
347 function TGikoSys.GetTempFolder: string;
349 Result := Setting.GetTempFolder;
352 (*************************************************************************
353 *sent.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
354 *************************************************************************)
355 function TGikoSys.GetSentFileName: string;
357 Result := Setting.GetSentFileName;
360 (*************************************************************************
361 *outbox.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
362 *************************************************************************)
363 function TGikoSys.GetOutBoxFileName: string;
365 Result := Setting.GetOutBoxFileName;
368 (*************************************************************************
369 *Config
\83t
\83H
\83\8b\83_
\8eæ
\93¾
370 *************************************************************************)
371 function TGikoSys.GetConfigDir: string;
373 Result := Setting.GetConfigDir;
376 function TGikoSys.GetStyleSheetDir: string;
378 Result := Setting.GetStyleSheetDir;
381 function TGikoSys.GetSkinDir: string;
383 Result := Setting.GetSkinDir;
386 function TGikoSys.GetSkinHeaderFileName: string;
388 Result := Setting.GetSkinHeaderFileName;
391 function TGikoSys.GetSkinFooterFileName: string;
393 Result := Setting.GetSkinFooterFileName;
396 function TGikoSys.GetSkinNewResFileName: string;
398 Result := Setting.GetSkinNewResFileName;
401 function TGikoSys.GetSkinResFileName: string;
403 Result := Setting.GetSkinResFileName;
406 function TGikoSys.GetSkinBookmarkFileName: string;
408 Result := Setting.GetSkinBookmarkFileName;
411 function TGikoSys.GetSkinNewmarkFileName: string;
413 Result := Setting.GetSkinNewmarkFileName;
417 function TGikoSys.GetUserAgent: string;
419 if Dolib.Connected then begin
420 Result := Format('%s %s/%s%d%s', [
427 BETA_VERSION_BUILD]);
429 Result := Format('%s/%s %s/%s%d%s', [
437 BETA_VERSION_BUILD]);
441 (*************************************************************************
442 *
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é
\95û
\8e®
\8e\9e\8d\8f\8eæ
\93¾
443 *************************************************************************)
444 function TGikoSys.Get2chDate(aDate: TDateTime): string;
449 d1 := EncodeDate(1970, 1, 1);
450 d2 := aDate - EncodeTime(9, 0, 0, 0);
451 Result := FloatToStr(Trunc((d2 - d1) * 24 * 60 * 60));
455 function TGikoSys.IntToDateTime(val: Int64): TDateTime;
460 d1 := EncodeDate(1970, 1, 1);
461 d2 := (val * 1000) / (24 * 60 * 60 * 1000);
465 function TGikoSys.DateTimeToInt(ADate: TDateTime): Integer;
470 d := EncodeDate(1970, 1, 1);
471 c := (ADate - d) * 24 * 60 * 60;
476 (*************************************************************************
477 *Subject
\83t
\83@
\83C
\83\8bRead
478 *************************************************************************)
479 procedure TGikoSys.ReadSubjectFile(Board: TBoard);
481 ThreadItem: TThreadItem;
483 FileList: TStringList;
484 TmpFileList: TStringList;
485 // SrchRec: TSearchRec;
492 // TmpUpdate: Boolean;
495 RoundItem: TRoundItem;
501 // TmpUpdate := False;
503 usePlugIn := Board.IsBoardPlugInAvailable;
505 FileName := Board.GetFolderIndexFileName;
506 if not FileExists(FileName) then CreateThreadDat(Board);
507 // if not FileExists(FileName) then Exit;
509 { R := FindFirst(ExtractFileDir(Board.GetFolderIndexFileName) + '\*.dat', 0, SrchRec);
511 FileList.Add(SrchRec.Name);
512 R := FindNext(SrchRec);
516 FileList := TStringList.Create;
517 FileList.Sorted := True;
518 TmpFileList := TStringList.Create;
519 TmpFileList.Sorted := True;
521 //IsLogFile
\97pDAT
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
522 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False, False);
524 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\97pTmp
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
525 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, False, False);
527 sl := TStringList.Create;
529 if FileExists(FileName) then
530 sl.LoadFromFile(FileName);
532 //
\82Q
\8ds
\96Ú
\82©
\82ç
\81i
\82P
\8ds
\96Ú
\82Í
\83o
\81[
\83W
\83\87\83\93\81j
533 for i := sl.Count - 1 downto 1 do begin
534 Rec := ParseIndexLine(sl[i]);
537 ThreadItem := TThreadItem.Create(
539 Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), Rec.FFileName ) )
541 ThreadItem := TThreadItem.Create(
543 Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) );
545 if FileList.Count <> 0 then
546 if FileList.Find( ThreadItem.FileName, Index ) then
547 //ThreadItem.IsLogFile := True;
548 FileList.Delete( Index );
550 ThreadItem.BeginUpdate;
551 ThreadItem.No := Rec.FNo;
552 ThreadItem.FileName := Rec.FFileName;
553 ThreadItem.Title := Rec.FTitle;
554 ThreadItem.Count := Rec.FCount;
555 ThreadItem.Size := Rec.FSize;
556 // ThreadItem.RoundNo := Rec.FRoundNo;
557 ThreadItem.RoundDate := Rec.FRoundDate;
558 ThreadItem.LastModified := Rec.FLastModified;
559 ThreadItem.Kokomade := Rec.FKokomade;
560 ThreadItem.NewReceive := Rec.FNewReceive;
561 // ThreadItem.Round := Rec.FRound;
562 ThreadItem.UnRead := Rec.FUnRead;
563 ThreadItem.ScrollTop := Rec.FScrollTop;
564 ThreadItem.AllResCount := Rec.FAllResCount;
565 ThreadItem.NewResCount := Rec.FNewResCount;
566 ThreadItem.AgeSage := Rec.FAgeSage;
567 ThreadItem.ParentBoard := Board;
569 //
\8f\84\89ñ
\83\8a\83X
\83g
\82É
\91¶
\8dÝ
\82µ
\82½
\82ç
\8f\84\89ñ
\83t
\83\89\83O
\83Z
\83b
\83g
570 if ThreadItem.IsLogFile then begin
571 idx := RoundList.Find(ThreadItem);
572 if idx <> -1 then begin
573 RoundItem := RoundList.Items[idx, grtItem];
574 ThreadItem.RoundName := RoundItem.RoundName;
575 ThreadItem.Round := True;
579 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\83`
\83F
\83b
\83N
580 if TmpFileList.Count <> 0 then begin
581 if TmpFileList.Find(ChangeFileExt(ThreadItem.FileName, '.tmp'), Index) then begin
582 ini := TMemIniFile.Create(ChangeFileExt(ThreadItem.GetThreadFileName, '.tmp'));
584 ThreadItem.RoundDate := ini.ReadDateTime('Setting', 'RoundDate', ZERO_DATE);
585 ThreadItem.LastModified := ini.ReadDateTime('Setting', 'LastModified', ZERO_DATE);
586 ThreadItem.Size := ini.ReadInteger('Setting', 'Size', 0);
587 ThreadItem.Count := ini.ReadInteger('Setting', 'Count', 0);
588 ThreadItem.NewReceive := ini.ReadInteger('Setting', 'NewReceive', 0);
589 ThreadItem.Round := ini.ReadBool('Setting', 'Round', False);
590 ThreadItem.UnRead := False;//ini.ReadBool('Setting', 'UnRead', False);
591 ThreadItem.ScrollTop := ini.ReadInteger('Setting', 'ScrollTop', 0);
592 ThreadItem.AllResCount := ini.ReadInteger('Setting', 'AllResCount', 0);
593 ThreadItem.NewResCount := ini.ReadInteger('Setting', 'NewResCount', 0);
594 ThreadItem.AgeSage := TGikoAgeSage(ini.ReadInteger('Setting', 'AgeSage', Ord(gasNone)));
598 TmpFileList.Delete(Index);
602 ThreadItem.EndUpdate;
603 Board.Add(ThreadItem);
605 // if (ThreadItem.IsLogFile) and (ThreadItem.Count > ThreadItem.Kokomade) then
606 if (ThreadItem.IsLogFile) and (ThreadItem.UnRead) then
610 if UnRead <> Board.UnRead then
611 Board.UnRead := UnRead;
613 //
\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
614 for i := 0 to FileList.Count - 1 do begin
615 FileName := ExtractFileDir(Board.GetFolderIndexFileName) + '\' + FileList[i];
617 ResRec := DivideStrLine(ReadThreadFile(FileName, 1));
619 ThreadItem := TThreadItem.Create(
621 Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), Rec.FFileName ) )
623 ThreadItem := TThreadItem.Create(
624 nil, Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) );
625 ThreadItem.No := Board.Count + 1;
626 ThreadItem.FileName := FileList[i];
627 ThreadItem.Title := ResRec.FTitle;
628 ThreadItem.Count := GetFileLineCount(FileName);
629 ThreadItem.AllResCount := ThreadItem.Count;
630 ThreadItem.NewResCount := 0;
631 ThreadItem.Size := 0;
632 ThreadItem.RoundDate := ZERO_DATE;
633 ThreadItem.LastModified := ZERO_DATE;
634 ThreadItem.Kokomade := -1;
635 ThreadItem.NewReceive := 0;
636 ThreadItem.ParentBoard := Board;
637 ThreadItem.IsLogFile := True;
638 ThreadItem.Round := False;
639 ThreadItem.UnRead := False;
640 ThreadItem.ScrollTop := 0;
641 ThreadItem.AgeSage := gasNone;
642 Board.Add(ThreadItem);
649 Board.IsThreadDatRead := True;
652 (*************************************************************************
653 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X
\83t
\83@
\83C
\83\8b(Folder.idx)
\8dì
\90¬
654 *************************************************************************)
655 procedure TGikoSys.CreateThreadDat(Board: TBoard);
659 SubjectList: TStringList;
665 if not FileExists(Board.GetSubjectFileName) then Exit;
666 FileName := Board.GetFolderIndexFileName;
668 SubjectList := TStringList.Create;
670 SubjectList.LoadFromFile(Board.GetSubjectFileName);
671 sl := TStringList.Create;
674 sl.Add(FOLDER_INDEX_VERSION);
675 for i := 0 to SubjectList.Count - 1 do begin
676 Rec := DivideSubject(SubjectList[i]);
678 if (Trim(Rec.FFileName) = '') or (Trim(Rec.FTitle) = '') then
681 s := Format('%x', [cnt]) + #1 //
\94Ô
\8d\86
682 + Rec.FFileName + #1 //
\83t
\83@
\83C
\83\8b\96¼
683 + Rec.FTitle + #1 //
\83^
\83C
\83g
\83\8b
684 + Format('%x', [Rec.FCount]) + #1 //
\83J
\83E
\83\93\83g
685 + Format('%x', [0]) + #1 //size
686 + Format('%x', [0]) + #1 //RoundDate
687 + Format('%x', [0]) + #1 //LastModified
688 + Format('%x', [0]) + #1 //Kokomade
689 + Format('%x', [0]) + #1 //NewReceive
690 + '0' + #1 //
\96¢
\8eg
\97p
691 + Format('%x', [0]) + #1 //UnRead
692 + Format('%x', [0]) + #1 //ScrollTop
693 + Format('%x', [Rec.FCount]) + #1 //AllResCount
694 + Format('%x', [0]) + #1 //NewResCount
695 + Format('%x', [0]); //AgeSage
700 sl.SaveToFile(FileName);
709 (*************************************************************************
710 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X(Thread.dat)
\8f\91\82«
\8d\9e\82Ý
712 *************************************************************************)
713 procedure TGikoSys.WriteThreadDat(Board: TBoard);
715 // Values: array[Boolean] of string = ('0', '1');
721 FileList: TStringList;
723 if not Board.IsThreadDatRead then
725 FileName := Board.GetFolderIndexFileName;
726 ForceDirectoriesEx( ExtractFilePath( FileName ) );
728 sl := TStringList.Create;
730 sl.Add(FOLDER_INDEX_VERSION);
731 for i := 0 to Board.Count - 1 do begin
732 if Board.Items[i].No = 0 then
733 Board.Items[i].No := i + 1;
735 s := Format('%x', [Board.Items[i].No]) + #1
736 + Board.Items[i].FileName + #1
737 + Board.Items[i].Title + #1
738 + Format('%x', [Board.Items[i].Count]) + #1
739 + Format('%x', [Board.Items[i].Size]) + #1
740 + Format('%x', [DateTimeToInt(Board.Items[i].RoundDate)]) + #1
741 + Format('%x', [DateTimeToInt(Board.Items[i].LastModified)]) + #1
742 + Format('%x', [Board.Items[i].Kokomade]) + #1
743 + Format('%x', [Board.Items[i].NewReceive]) + #1
744 + '0' + #1 //
\96¢
\8eg
\97p
745 + Format('%x', [BoolToInt(Board.Items[i].UnRead)]) + #1
746 + Format('%x', [Board.Items[i].ScrollTop]) + #1
747 + Format('%x', [Board.Items[i].AllResCount]) + #1
748 + Format('%x', [Board.Items[i].NewResCount]) + #1
749 + Format('%x', [Ord(Board.Items[i].AgeSage)]);
754 sl.SaveToFile(FileName);
756 FileList := TStringList.Create;
758 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', FileList, False, True);
759 for i := 0 to FileList.Count - 1 do begin
760 DeleteFile(FileList[i]);
770 function TGikoSys.ParseIndexLine(Line: string): TIndexRec;
775 for i := 0 to 14 do begin
776 s := GetTokenIndex(Line, #1, i);
778 0: Result.FNo := StrToIntDef('$' + s, 0);
779 1: Result.FFileName := s;
780 2: Result.FTitle := s;
781 3: Result.FCount := StrToIntDef('$' + s, 0);
782 4: Result.FSize := StrToIntDef('$' + s, 0);
783 5: Result.FRoundDate := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
784 6: Result.FLastModified := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
785 7: Result.FKokomade := StrToIntDef('$' + s, -1);
786 8: Result.FNewReceive := StrToIntDef('$' + s, 0);
788 10: Result.FUnRead := IntToBool(StrToIntDef('$' + s, 0));
789 11: Result.FScrollTop := StrToIntDef('$' + s, 0);
790 12: Result.FAllResCount := StrToIntDef('$' + s, 0);
791 13: Result.FNewResCount := StrToIntDef('$' + s, 0);
792 14: Result.FAgeSage := TGikoAgeSage(StrToIntDef('$' + s, 0));
797 //
\8ew
\92è
\83t
\83H
\83\8b\83_
\93à
\82Ì
\8ew
\92è
\83t
\83@
\83C
\83\8b\88ê
\97\97\82ð
\8eæ
\93¾
\82·
\82é
798 // ListFiles('c:\', '*.txt', list, True);
799 procedure TGikoSys.GetFileList(Path: string; Mask: string; List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
802 SearchRec : TSearchRec;
805 Path := IncludeTrailingPathDelimiter(Path);
806 rc := FindFirst(Path + '*.*', faAnyfile, SearchRec);
808 while rc = 0 do begin
809 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
810 s := Path + SearchRec.Name;
811 //if (SearchRec.Attr and faDirectory > 0) then
812 // s := IncludeTrailingPathDelimiter(s)
814 if (SearchRec.Attr and faDirectory = 0) and (MatchesMask(s, Mask)) then
818 List.Add(SearchRec.Name);
819 if SubDir and (SearchRec.Attr and faDirectory > 0) then
820 GetFileList(s, Mask, List, True, IsPathAdd);
822 rc := FindNext(SearchRec);
825 SysUtils.FindClose(SearchRec);
829 //
\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é
830 procedure TGikoSys.GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
833 SearchRec : TSearchRec;
836 Path := IncludeTrailingPathDelimiter(Path);
837 rc := FindFirst(Path + '*.*', faDirectory, SearchRec);
839 while rc = 0 do begin
840 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
841 s := Path + SearchRec.Name;
842 //if (SearchRec.Attr and faDirectory > 0) then
843 // s := IncludeTrailingPathDelimiter(s)
845 if (SearchRec.Attr and faDirectory > 0) and (MatchesMask(s, Mask)) then
846 List.Add( IncludeTrailingPathDelimiter( s ) );
847 if SubDir and (SearchRec.Attr and faDirectory > 0) then
848 GetDirectoryList(s, Mask, List, True);
850 rc := FindNext(SearchRec);
853 SysUtils.FindClose(SearchRec);
857 //
\83X
\83L
\83\93\82ð
\93Ç
\82Ý
\8d\9e\82Ý
\81A
\92l
\82ð
\92u
\8a·
\82·
\82é
858 function TGikoSys.LoadFromSkin(
860 ThreadItem: TThreadItem;
867 Skin := TStringList.Create;
869 if FileExists( fileName ) then begin
870 Skin.LoadFromFile( fileName );
872 //
\82â
\82è
\82©
\82½
\82ª
\8bê
\82µ
\82¢
\82¯
\82Ç
\81A
\83I
\83v
\83V
\83\87\83\93\83_
\83C
\83A
\83\8d\83O
\82Ì
\83v
\83\8c\83r
\83\85\81[
\97p try
874 if ThreadItem.ParentBoard <> nil then
875 if ThreadItem.ParentBoard.ParentCategory <> nil then
876 CustomStringReplace( Skin, '<BBSNAME/>', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title);
877 //Skin.Text := CustomStringReplace( Skin.Text, '<BBSNAME/>', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title);
878 //Skin.Text := CustomStringReplace( Skin.Text, '<THREADURL/>', ThreadItem.URL);
879 CustomStringReplace( Skin, '<THREADURL/>', ThreadItem.URL);
881 //Skin.Text := CustomStringReplace( Skin.Text, '<BOARDNAME/>', ThreadItem.ParentBoard.Title);
882 CustomStringReplace( Skin, '<BOARDNAME/>', ThreadItem.ParentBoard.Title);
883 //Skin.Text := CustomStringReplace( Skin.Text, '<BOARDURL/>', ThreadItem.ParentBoard.URL);
884 CustomStringReplace( Skin, '<BOARDURL/>', ThreadItem.ParentBoard.URL);
885 //Skin.Text := CustomStringReplace( Skin.Text, '<THREADNAME/>', ThreadItem.Title);
886 CustomStringReplace( Skin, '<THREADNAME/>', ThreadItem.Title);
887 //Skin.Text := CustomStringReplace( Skin.Text, '<SKINPATH/>', Setting.CSSFileName);
888 CustomStringReplace( Skin, '<SKINPATH/>', Setting.CSSFileName);
889 //Skin.Text := CustomStringReplace( Skin.Text, '<GETRESCOUNT/>', IntToStr( ThreadItem.NewReceive - 1 ));
890 CustomStringReplace( Skin, '<GETRESCOUNT/>', IntToStr( ThreadItem.NewReceive - 1 ));
891 //Skin.Text := CustomStringReplace( Skin.Text, '<NEWRESCOUNT/>', IntToStr( ThreadItem.NewResCount ));
892 CustomStringReplace( Skin, '<NEWRESCOUNT/>', IntToStr( ThreadItem.NewResCount ));
893 //Skin.Text := CustomStringReplace( Skin.Text, '<ALLRESCOUNT/>', IntToStr( ThreadItem.AllResCount ));
894 CustomStringReplace( Skin, '<ALLRESCOUNT/>', IntToStr( ThreadItem.AllResCount ));
896 //Skin.Text := CustomStringReplace( Skin.Text, '<NEWDATE/>',
897 //FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate));
898 CustomStringReplace( Skin, '<NEWDATE/>',FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate));
899 //Skin.Text := CustomStringReplace( Skin.Text, '<SIZEKB/>', IntToStr( Floor( SizeByte / 1024 ) ));
900 CustomStringReplace( Skin, '<SIZEKB/>', IntToStr( Floor( SizeByte / 1024 ) ));
901 //Skin.Text := CustomStringReplace( Skin.Text, '<SIZE/>', IntToStr( SizeByte ));
902 CustomStringReplace( Skin, '<SIZE/>', IntToStr( SizeByte ));
904 //-----
\82Æ
\82è
\82 \82¦
\82¸
\82©
\82¿
\82ã
\81`
\82µ
\82á
\8cÝ
\8a·
\97p
\81B
\83R
\83\81\83\93\83g
\83A
\83E
\83g
\82µ
\82Ä
\82à
\82æ
\82µ
905 //
\82â
\82è
\82©
\82½
\82ª
\8bê
\82µ
\82¢
\82¯
\82Ç
\81A
\83I
\83v
\83V
\83\87\83\93\83_
\83C
\83A
\83\8d\83O
\82Ì
\83v
\83\8c\83r
\83\85\81[
\97p try
907 if ThreadItem.ParentBoard <> nil then
908 if ThreadItem.ParentBoard.ParentCategory <> nil then
909 CustomStringReplace( Skin, '&BBSNAME', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title);
910 //Skin.Text := CustomStringReplace( Skin.Text, '&BBSNAME', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title);
911 //Skin.Text := CustomStringReplace( Skin.Text, '&THREADURL', ThreadItem.URL);
912 CustomStringReplace( Skin, '&THREADURL', ThreadItem.URL);
914 //Skin.Text := CustomStringReplace( Skin.Text, '&BOARDNAME', ThreadItem.ParentBoard.Title);
915 CustomStringReplace( Skin, '&BOARDNAME', ThreadItem.ParentBoard.Title);
916 //Skin.Text := CustomStringReplace( Skin.Text, '&BOARDURL', ThreadItem.ParentBoard.URL);
917 CustomStringReplace( Skin, '&BOARDURL', ThreadItem.ParentBoard.URL);
918 //Skin.Text := CustomStringReplace( Skin.Text, '&THREADNAME', ThreadItem.Title);
919 CustomStringReplace( Skin, '&THREADNAME', ThreadItem.Title);
920 //Skin.Text := CustomStringReplace( Skin.Text, '&SKINPATH', Setting.CSSFileName);
921 CustomStringReplace( Skin, '&SKINPATH', Setting.CSSFileName);
922 //Skin.Text := CustomStringReplace( Skin.Text, '&GETRESCOUNT', IntToStr( ThreadItem.NewReceive - 1 ));
923 CustomStringReplace( Skin, '&GETRESCOUNT', IntToStr( ThreadItem.NewReceive - 1 ));
924 //Skin.Text := CustomStringReplace( Skin.Text, '&NEWRESCOUNT', IntToStr( ThreadItem.NewResCount ));
925 CustomStringReplace( Skin, '&NEWRESCOUNT', IntToStr( ThreadItem.NewResCount ));
926 //Skin.Text := CustomStringReplace( Skin.Text, '&ALLRESCOUNT', IntToStr( ThreadItem.AllResCount ));
927 CustomStringReplace( Skin, '&ALLRESCOUNT', IntToStr( ThreadItem.AllResCount ));
929 //Skin.Text := CustomStringReplace( Skin.Text, '&NEWDATE',
930 // FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate));
931 CustomStringReplace( Skin, '&NEWDATE', FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate));
932 //Skin.Text := CustomStringReplace( Skin.Text, '&SIZEKB', IntToStr( Floor( SizeByte / 1024 ) ));
933 CustomStringReplace( Skin, '&SIZEKB', IntToStr( Floor( SizeByte / 1024 ) ));
934 //Skin.Text := CustomStringReplace( Skin.Text, '&SIZE', IntToStr( SizeByte ));
935 CustomStringReplace( Skin, '&SIZE', IntToStr( SizeByte ));
936 //-----
\82±
\82±
\82Ü
\82Å
944 //
\83\8c\83X
\82Ì
\92l
\82ð
\92u
\8a·
\82·
\82é
945 function TGikoSys.SkinedRes(
953 Skin := CustomStringReplace( Skin, '<NUMBER/>',
954 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>');
955 Skin := CustomStringReplace( Skin, '<PLAINNUMBER/>', No);
956 Skin := CustomStringReplace( Skin, '<NAME/>', '<b>' + Res.FName + '</b>');
957 Skin := CustomStringReplace( Skin, '<MAILNAME/>',
958 '<a href="mailo:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>');
959 Skin := CustomStringReplace( Skin, '<MAIL/>', Res.FMailTo);
960 Skin := CustomStringReplace( Skin, '<DATE/>', Res.FDateTime);
961 Skin := CustomStringReplace( Skin, '<MESSAGE/>', Res.FBody);
963 //-----
\82©
\82¿
\82ã
\81`
\82µ
\82á
\8cÝ
\8a·
\97p
\81B
\83R
\83\81\83\93\83g
\83A
\83E
\83g
\82µ
\82Ä
\82à
\82æ
\82µ
964 Skin := CustomStringReplace( Skin, '&NUMBER',
965 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>');
966 Skin := CustomStringReplace( Skin, '&PLAINNUMBER', No);
967 Skin := CustomStringReplace( Skin, '&NAME', '<b>' + Res.FName + '</b>');
968 Skin := CustomStringReplace( Skin, '&MAILNAME',
969 '<a href="mailo:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>');
970 Skin := CustomStringReplace( Skin, '&MAIL', Res.FMailTo);
971 Skin := CustomStringReplace( Skin, '&DATE', Res.FDateTime);
972 Skin := CustomStringReplace( Skin, '&MESSAGE', Res.FBody);
973 //-----
\82±
\82±
\82Ü
\82Å
981 procedure TGikoSys.CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
985 //bufList : TStringList;
986 ReadList: TStringList;
987 SaveList: TStringList;
991 NewReceiveNo: Integer;
993 boardPlugIn : TBoardPlugIn;
995 UserOptionalStyle: string;
1001 function LoadSkin( fileName: string ): string;
1003 Result := LoadFromSkin( fileName, ThreadItem, SizeByte );
1005 function ReplaceRes( skin: string ): string;
1007 Result := SkinedRes( skin, Res, No );
1010 if ThreadItem <> nil then begin
1011 if ThreadItem.IsBoardPlugInAvailable then begin
1012 //=====
\83v
\83\89\83O
\83C
\83\93\82É
\82æ
\82é
\95\
\8e¦
1013 boardPlugIn := ThreadItem.BoardPlugIn;
1014 NewReceiveNo := ThreadItem.NewReceive;
1016 //
\83t
\83H
\83\93\83g
\82â
\83T
\83C
\83Y
\82Ì
\90Ý
\92è
1017 if Length( GikoSys.Setting.BrowserFontName ) > 0 then
1018 UserOptionalStyle := UserOptionalStyle +
1019 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
1020 if GikoSys.Setting.BrowserFontSize <> 0 then
1021 UserOptionalStyle := UserOptionalStyle +
1022 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
1023 if GikoSys.Setting.BrowserFontColor <> -1 then
1024 UserOptionalStyle := UserOptionalStyle +
1025 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
1026 if GikoSys.Setting.BrowserBackColor <> -1 then
1027 UserOptionalStyle := UserOptionalStyle +
1028 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
1029 case GikoSys.Setting.BrowserFontBold of
1030 -1: UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
1031 1: UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;';
1033 case GikoSys.Setting.BrowserFontItalic of
1034 -1: UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
1035 1: UserOptionalStyle := UserOptionalStyle + 'font-style:italic;';
1038 SaveList := TStringList.Create;
1041 //
\95¶
\8e\9a\83R
\81[
\83h
\82Í
\83v
\83\89\83O
\83C
\83\93\82É
\94C
\82¹
\82é
1042 // doc.charset := 'Shift_JIS';
1043 threadItem.SizeByte := 0;
1046 SaveList.Add( boardPlugIn.GetHeader( DWORD( threadItem ),
1047 '<style type="text/css">body {' + UserOptionalStyle + '}</style>' ) );
1049 for i := 0 to threadItem.Count - 1 do begin
1050 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (threadItem.Count-i) > 101 ) then begin
1054 //
\90V
\92\85\83}
\81[
\83N
1055 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1057 if GikoSys.Setting.UseSkin then begin
1058 if FileExists( GetSkinNewmarkFileName ) then
1059 SaveList.Add( LoadSkin( GetSkinNewmarkFileName ) )
1061 SaveList.Add( '<a name="new"></a>' );
1062 end else if GikoSys.Setting.UseCSS then begin
1063 SaveList.Add('<a name="new"></a><div class="new">
\90V
\92\85\83\8c\83X <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>');
1065 SaveList.Add('</dl>');
1066 SaveList.Add('<a name="new"></a>');
1067 SaveList.Add('<table width="100%" bgcolor="#3333CC" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#6666FF" valign="middle"><font size="-1" color="#ffffff"><b>
\90V
\92\85\83\8c\83X ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</b></font></td></tr></table>');
1068 SaveList.Add('<dl>');
1071 SaveList.Add( '<a name="new"></a>' );
1076 SaveList.Add( boardPlugIn.GetRes( DWORD( threadItem ), i + 1 ) );
1078 if ThreadItem.Kokomade = (i + 1) then begin
1079 //
\82±
\82±
\82Ü
\82Å
\93Ç
\82ñ
\82¾
1081 if GikoSys.Setting.UseSkin then begin
1082 if FileExists( GetSkinBookmarkFileName ) then
1083 SaveList.Add( LoadSkin( GetSkinBookmarkFileName ) )
1085 SaveList.Add( '<a name="koko"></a>' );
1086 end else if GikoSys.Setting.UseCSS then begin
1087 SaveList.Add('<a name="koko"></a><div class="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</div>');
1089 SaveList.Add('</dl>');
1090 SaveList.Add('<a name="koko"></a><table width="100%" bgcolor="#55AA55" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#77CC77" valign="middle"><font size="-1" color="#ffffff"><b>
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</b></font></td></tr></table>');
1091 SaveList.Add('<dl>');
1094 SaveList.Add( '<a name="koko"></a>' );
1098 threadItem.SizeByte := threadItem.SizeByte + Length( SaveList.Text );
1099 doc.Write(SaveList.Text);
1103 threadItem.SizeByte := threadItem.SizeByte + Length( SaveList.Text );
1105 //
\83X
\83L
\83\93(
\83t
\83b
\83^)
1106 SaveList.Add( boardPlugIn.GetFooter( DWORD( threadItem ), '<a name="bottom"></a>' ) );
1108 doc.Write(SaveList.Text);
1117 ShortDayNames[1] := '
\93ú'; ShortDayNames[2] := '
\8c\8e';
1118 ShortDayNames[3] := '
\89Î'; ShortDayNames[4] := '
\90\85';
1119 ShortDayNames[5] := '
\96Ø'; ShortDayNames[6] := '
\8bà';
1120 ShortDayNames[7] := '
\93y';
1122 BBSID := ThreadItem.ParentBoard.BBSID;
1123 NewReceiveNo := ThreadItem.NewReceive;
1124 ReadList := TStringList.Create;
1126 if ThreadItem.IsLogFile then begin
1127 FileName := ThreadItem.GetThreadFileName;
1128 ReadList.LoadFromFile(FileName);
1129 FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
1130 FAbon.Execute(ReadList); //
\82 \82Ú
\81`
\82ñ
\82µ
\82Ä
1131 FSelectResFilter.Execute(ReadList); //
\83\8c\83X
\82Ì
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\82·
\82é
1132 Res := DivideStrLine(ReadList[0]);
1133 Res.FTitle := CustomStringReplace(Res.FTitle, '
\81\97\81M', ',');
1134 sTitle := Res.FTitle;
1136 sTitle := CustomStringReplace(ThreadItem.Title, '
\81\97\81M', ',');
1138 SaveList := TStringList.Create;
1141 doc.charset := 'Shift_JIS';
1143 //
\83t
\83H
\83\93\83g
\82â
\83T
\83C
\83Y
\82Ì
\90Ý
\92è
1144 if Length( GikoSys.Setting.BrowserFontName ) > 0 then
1145 UserOptionalStyle := UserOptionalStyle +
1146 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
1147 if GikoSys.Setting.BrowserFontSize <> 0 then
1148 UserOptionalStyle := UserOptionalStyle +
1149 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
1150 if GikoSys.Setting.BrowserFontColor <> -1 then
1151 UserOptionalStyle := UserOptionalStyle +
1152 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
1153 if GikoSys.Setting.BrowserBackColor <> -1 then
1154 UserOptionalStyle := UserOptionalStyle +
1155 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
1156 case GikoSys.Setting.BrowserFontBold of
1157 -1: UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
1158 1: UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;';
1160 case GikoSys.Setting.BrowserFontItalic of
1161 -1: UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
1162 1: UserOptionalStyle := UserOptionalStyle + 'font-style:italic;';
1165 CSSFileName := GetStyleSheetDir + Setting.CSSFileName;
1166 if GikoSys.Setting.UseSkin then begin
1167 //
\83X
\83L
\83\93\8eg
\97p
1168 //
\83X
\83L
\83\93\82Ì
\90Ý
\92è
1170 SkinHeader := LoadSkin( GetSkinHeaderFileName );
1171 if Length( UserOptionalStyle ) > 0 then
1172 SkinHeader := CustomStringReplace( SkinHeader, '</head>',
1173 '<style type="text/css">body {' + UserOptionalStyle + '}</style></head>');
1174 SaveList.Add( SkinHeader );
1178 SkinNewRes := LoadSkin( GetSkinNewResFileName );
1182 SkinRes := LoadSkin( GetSkinResFileName );
1186 SaveList.Add('<a name="top"></a>');
1188 for i := 0 to ReadList.Count - 1 do begin
1189 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1192 if (Trim(ReadList[i]) <> '') then begin
1193 No := IntToStr(i + 1);
1195 Res := DivideStrLine(ReadList[i]);
1196 if Res.FType = glt2chOld then begin
1197 Res.FMailTo := CustomStringReplace(Res.FMailTo, '
\81\97\81M', ',');
1198 Res.FName := CustomStringReplace(Res.FName, '
\81\97\81M', ',');
1199 Res.FBody := CustomStringReplace(Res.FBody, '
\81\97\81M', ',');
1202 Res.FBody := AddAnchorTag(Res.FBody);
1203 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true',ThreadItem.URL);
1205 if Res.FName = '' then
1206 Res.FName := ' ';
1208 //
\90V
\92\85\83}
\81[
\83N
1209 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1211 if FileExists( GetSkinNewmarkFileName ) then
1212 SaveList.Add( LoadSkin( GetSkinNewmarkFileName ) )
1214 SaveList.Add( '<a name="new"></a>' );
1216 SaveList.Add( '<a name="new"></a>' );
1220 if NewReceiveNo <= (i + 1) then
1221 //
\90V
\92\85\83\8c\83X
1222 SaveList.Add( ReplaceRes( SkinNewRes ) )
1224 //
\92Ê
\8fí
\82Ì
\83\8c\83X
1225 SaveList.Add( ReplaceRes( SkinRes ) );
1228 if ThreadItem.Kokomade = (i + 1) then begin
1229 //
\82±
\82±
\82Ü
\82Å
\93Ç
\82ñ
\82¾
1231 if FileExists( GetSkinBookmarkFileName ) then
1232 SaveList.Add( LoadSkin( GetSkinBookmarkFileName ) )
1234 SaveList.Add( '<a name="koko"></a>' );
1236 SaveList.Add( '<a name="koko"></a>' );
1240 SizeByte := SizeByte + Length( SaveList.Text );
1241 doc.Write(SaveList.Text);
1244 SaveList.Add('<a name="bottom"></a>');
1245 SizeByte := SizeByte + Length( SaveList.Text );
1246 //
\83X
\83L
\83\93(
\83t
\83b
\83^)
1248 SaveList.Add( LoadSkin( GetSkinFooterFileName ) );
1251 doc.Write(SaveList.Text);
1253 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
1255 //CSSFileName := GetAppDir + CSS_FILE_NAME;
1256 // SaveList.Add('<html lang="ja"><head>');
1257 SaveList.Add('<html><head>');
1258 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1259 SaveList.Add('<title>' + sTitle + '</title>');
1260 SaveList.Add('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
1261 if Length( UserOptionalStyle ) > 0 then
1262 SaveList.Add('<style type="text/css">body {' + UserOptionalStyle + '}</style>');
1263 SaveList.Add('</head>');
1264 SaveList.Add('<body>');
1265 SaveList.Add('<a name="top"></a>');
1266 SaveList.Add('<div class="title">' + sTitle + '</div>');
1267 doc.Write(SaveList.Text);
1269 //Application.ProcessMessages;
1270 for i := 0 to ReadList.Count - 1 do begin
1271 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1274 if (Trim(ReadList[i]) <> '') then begin
1275 No := IntToStr(i + 1);
1276 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1277 SaveList.Add('<a name="new"></a><div class="new">
\90V
\92\85\83\8c\83X <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>');
1279 Res := DivideStrLine(ReadList[i]);
1280 Res.FBody := AddAnchorTag(Res.FBody);
1281 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true',ThreadItem.URL);
1283 if Res.FName = '' then
1284 Res.FName := ' ';
1285 if Res.FMailTo = '' then
1286 SaveList.Add('<a name="' + No + '"></a>'
1287 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span> '
1288 + '<span class="name_label">
\96¼
\91O
\81F</span> '
1289 + '<span class="name"><b>' + Res.FName + '</b></span> '
1290 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span> '
1291 + '<span class="date">' + Res.FDateTime+ '</span></div>'
1292 + '<div class="mes">' + Res.FBody + ' </div>')
1293 else if GikoSys.Setting.ShowMail then
1294 SaveList.Add('<a name="' + No + '"></a>'
1295 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1296 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1297 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1298 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
1299 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1300 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1301 + '<div class="mes">' + Res.FBody + ' </div>')
1303 SaveList.Add('<a name="' + No + '"></a>'
1304 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1305 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1306 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1307 + '<b>' + Res.FName + '</b></a>'
1308 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1309 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1310 + '<div class="mes">' + Res.FBody + ' </div>');
1311 if ThreadItem.Kokomade = (i + 1) then begin
1312 SaveList.Add('<a name="koko"></a><div class="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</div>');
1316 doc.Write(SaveList.Text);
1320 SaveList.Add('<a name="bottom"></a>');
1321 SaveList.Add('</body></html>');
1322 SaveList.Add('<a name="last"></a>');
1323 SaveList.Add('</body></html>');
1325 doc.Write(SaveList.Text);
1328 // SaveList.Add('<html lang="ja"><head>');
1329 SaveList.Add('<html><head>');
1330 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1331 SaveList.Add('<title>' + sTitle + '</title></head>');
1332 SaveList.Add('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1333 SaveList.Add('<a name="top"></a>');
1334 SaveList.Add('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1335 SaveList.Add('<dl>');
1336 doc.Write(SaveList.Text);
1338 //Application.ProcessMessages;
1339 for i := 0 to ReadList.Count - 1 do begin
1340 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1343 if (Trim(ReadList[i]) <> '') then begin
1344 No := IntToStr(i + 1);
1346 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1347 SaveList.Add('</dl>');
1348 SaveList.Add('<a name="new"></a>');
1349 SaveList.Add('<table width="100%" bgcolor="#3333CC" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#6666FF" valign="middle"><font size="-1" color="#ffffff"><b>
\90V
\92\85\83\8c\83X ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</b></font></td></tr></table>');
1350 SaveList.Add('<dl>');
1352 Res := DivideStrLine(ReadList[i]);
1353 if Res.FType = glt2chOld then begin
1354 Res.FMailTo := CustomStringReplace(Res.FMailTo, '
\81\97\81M', ',');
1355 Res.FName := CustomStringReplace(Res.FName, '
\81\97\81M', ',');
1356 Res.FBody := CustomStringReplace(Res.FBody, '
\81\97\81M', ',');
1358 Res.FBody := AddAnchorTag(Res.FBody);
1359 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true',ThreadItem.URL);
1360 if Res.FMailTo = '' then
1361 SaveList.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a>
\96¼
\91O
\81F<font color="forestgreen"><b> ' + Res.FName + ' </b></font>
\93\8a\8de
\93ú
\81F ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>')
1362 else if GikoSys.Setting.ShowMail then
1363 SaveList.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a>
\96¼
\91O
\81F<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> [' + Res.FMailTo + ']
\93\8a\8de
\93ú
\81F ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>')
1365 SaveList.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a>
\96¼
\91O
\81F<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a>
\93\8a\8de
\93ú
\81F ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>');
1366 if ThreadItem.Kokomade = (i + 1) then begin
1367 SaveList.Add('</dl>');
1368 SaveList.Add('<a name="koko"></a><table width="100%" bgcolor="#55AA55" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#77CC77" valign="middle"><font size="-1" color="#ffffff"><b>
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</b></font></td></tr></table>');
1369 SaveList.Add('<dl>');
1372 //if SaveList.Count > 50 then begin
1373 doc.Write(SaveList.Text);
1375 //Application.ProcessMessages;
1378 SaveList.Add('</dl>');
1379 SaveList.Add('<a name="bottom"></a>');
1380 SaveList.Add('</body></html>');
1381 doc.Write(SaveList.Text);
1391 (*************************************************************************
1392 *http://
\82Ì
\95¶
\8e\9a\97ñ
\82ðanchor
\83^
\83O
\95t
\82«
\82É
\82·
\82é
\81B
1393 *************************************************************************)
1394 function TGikoSys.AddAnchorTag(s: string): string;
1396 URL_CHAR: string = '0123456789'
1397 + 'abcdefghijklmnopqrstuvwxyz'
1398 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1399 + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
1400 ANCHOR_REF = 'href=';
1401 RES_REF = '>>';
1403 wkIdx: array[0..9] of Integer;
1408 anchorLen : Integer;
1411 // + 3
\82Í 'href="' ('"'
\82Â
\82«)
\82È
\82Ç
\82Ì
\83o
\83\8a\83G
\81[
\83V
\83\87\83\93\82É
\97]
\97T
\82ð
\8e\9d\82½
\82¹
\82é
\82½
\82ß
1412 anchorLen := Length( ANCHOR_REF ) + 3;
1415 wkIdx[0] := AnsiPos('http://', s);
1416 wkIdx[1] := AnsiPos('ttp://', s);
1417 wkIdx[2] := AnsiPos('tp://', s);
1418 wkIdx[3] := AnsiPos('ms-help://', s);
1419 wkIdx[4] := AnsiPos('p://', s);
1420 wkIdx[5] := AnsiPos('https://', s);
1421 wkIdx[6] := AnsiPos('www.', s);
1422 wkIdx[7] := AnsiPos('ftp://', s);
1423 wkIdx[8] := AnsiPos('news://', s);
1424 wkIdx[9] := AnsiPos('rtsp://', s);
1428 if wkIdx[i] <> 0 then idx := Min(wkIdx[i], idx);
1430 if idx = MaxInt then begin
1431 //
\83\8a\83\93\83N
\82ª
\96³
\82¢
\82æ
\81B
1432 Result := Result + s;
1437 (Pos( ANCHOR_REF, Copy(s, idx - anchorLen, anchorLen ) ) > 0) then begin
1438 //
\8aù
\82É
\83\8a\83\93\83N
\83^
\83O
\82ª
\82Â
\82¢
\82Ä
\82¢
\82é
\82Á
\82Û
\82¢
\82Æ
\82«
\82Í
\83\80\83V
1439 href := Copy( s, idx, Length( s ) );
1440 Result := Result + Copy( s, 1, idx + Pos( '</a>', href ) + Length( '</a>' ) - 2 );
1442 s := Copy( s, Pos( '</a>', s ) + Length( '</a>' ), Length( s ) );
1447 Result := Result + Copy(s, 0, idx - 1);
1449 s := Copy(s, idx, length(s));
1451 for i := 0 to Length(s) do begin
1452 idx := AnsiPos(s[i + 1], URL_CHAR);
1453 if (idx = 0) or (i = (Length(s))) then begin
1454 //URL
\82¶
\82á
\82È
\82¢
\95¶
\8e\9a\94
\8c©
\81I
\82Æ
\82©
\81A
\95¶
\8e\9a\82ª
\82È
\82
\82È
\82Á
\82½
\81B
1455 url := Copy(s, 0, i);
1457 if AnsiPos('ttp://', url) = 1 then
1459 else if AnsiPos('tp://', url) = 1 then
1461 else if AnsiPos('p://', url) = 1 then
1463 else if AnsiPos('www.', url) = 1 then
1464 href := 'http://' + url
1467 Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
1468 s := Copy(s, i + 1, Length(s));
1475 (*************************************************************************
1476 *
\83T
\83u
\83W
\83F
\83N
\83g
\88ê
\8ds
\82ð
\95ª
\8a\84
1477 *************************************************************************)
1478 function TGikoSys.DivideSubject(Line: string): TSubjectRec;
1488 if Pos('<>', Line) = 0 then
1493 Result.FFileName := GetTokenIndex(Line, Delim, 0);
1494 Result.FTitle := GetTokenIndex(Line, Delim, 1);
1496 ws := Trim(Result.FTitle);
1498 if Copy(ws, Length(ws), 1) = ')' then begin
1501 end else if Copy(ws, Length(ws), 1) = '
\81j' then begin
1504 end else if Copy(ws, Length(ws), 1) = '<' then begin
1509 for i := Length(ws) - 1 downto 1 do begin
1510 if ws[i] = LeftK then begin
1511 ws := Copy(ws, i + 1, Length(ws) - i - 1);
1512 if IsNumeric(ws) then
1513 Result.FCount := StrToInt(ws);
1514 Result.FTitle := Trim(CustomStringReplace(Result.FTitle, LeftK + ws + RightK, ''));
1520 (*************************************************************************
1521 * dat
\83t
\83@
\83C
\83\8b\82Ì
\88ê
\83\89\83C
\83\93\82ð
\95ª
\89ð
1522 *************************************************************************)
1523 function TGikoSys.DivideStrLine(Line: string): TResRec;
1528 if Pos('<>', Line) = 0 then begin
1530 Result.FType := glt2chOld;
1533 Result.FType := glt2chNew;
1535 Result.FName := Trim(GetTokenIndex(Line, Delim, 0));
1536 Result.FMailTo := Trim(GetTokenIndex(Line, Delim, 1));
1537 Result.FDateTime := Trim(GetTokenIndex(Line, Delim, 2));
1538 bufBody := Trim(GetTokenIndex(Line, Delim, 3));
1539 if bufbody = '' then begin
1540 Insert(' ',bufbody, 1);
1542 Result.FBody := bufBody;
1543 Result.FTitle := Trim(GetTokenIndex(Line, Delim, 4));
1547 (*************************************************************************
1548 * URL
\82©
\82çBBSID
\82ð
\8eæ
\93¾
1549 *************************************************************************)
1550 function TGikoSys.UrlToID(url: string): string;
1557 if url = '' then Exit;
1559 url := Copy(url, 0, Length(url) - 1);
1560 for i := Length(url) downto 0 do begin
1561 if url[i] = '/' then begin
1562 Result := Copy(url, i + 1, Length(url));
1568 (*************************************************************************
1569 *URL
\82©
\82çBBSID
\88È
\8aO
\82Ì
\95\94\95ª(http://teri.2ch.net/)
\82ð
\8eæ
\93¾
1570 *************************************************************************)
1571 function TGikoSys.UrlToServer(url: string): string;
1578 wsURL := Trim(wsURL);
1580 if wsURL = '' then exit;
1582 if Copy(wsURL, Length(wsURL), 1) = '/' then
1583 wsURL := Copy(wsURL, 0, Length(wsURL) - 1);
1585 for i := Length(wsURL) downto 0 do begin
1586 if wsURL[i] = '/' then begin
1587 Result := Copy(wsURL, 0, i);
1593 (*************************************************************************
1594 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ª
\91¶
\8dÝ
\82·
\82é
\82©
\83`
\83F
\83b
\83N
1595 *************************************************************************)
1596 function TGikoSys.DirectoryExistsEx(const Name: string): Boolean;
1600 Code := GetFileAttributes(PChar(Name));
1601 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
1604 (*************************************************************************
1605 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\8dì
\90¬
\81i
\95¡
\90\94\8aK
\91w
\91Î
\89\9e\81j
1606 *************************************************************************)
1607 function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean;
1610 if Length(Dir) = 0 then
1611 raise Exception.Create('
\83t
\83H
\83\8b\83_
\82ª
\8dì
\90¬
\8fo
\97\88\82Ü
\82¹
\82ñ');
1612 Dir := ExcludeTrailingPathDelimiter(Dir);
1613 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
1614 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
1615 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
1618 (*************************************************************************
1619 *
\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
1620 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1621 *************************************************************************)
1622 function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1626 Result := StrTokNext(sep, Rec);
1629 (*************************************************************************
1630 *
\95¶
\8e\9a\97ñ
\82©
\82ç
\83g
\81[
\83N
\83\93\82Ì
\90Ø
\82è
\8fo
\82µ
1631 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1632 *************************************************************************)
1633 function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1640 if Len >= Pos then begin
1641 while (Pos <= Len) and (Str[Pos] in sep) do begin
1645 while (Pos<= Len) and not (Str[Pos] in sep) do begin
1646 if IsDBCSLeadByte(Byte(Str[Pos])) then begin
1651 Result := Copy(Str, I, Pos - I);
1652 while (Pos <= Len) and (Str[Pos] in sep) do begin//
\82±
\82ê
\82Í
\82¨
\8dD
\82Ý
1659 (*************************************************************************
1660 *
\83t
\83@
\83C
\83\8b\83T
\83C
\83Y
\8eæ
\93¾
1661 *************************************************************************)
1662 function TGikoSys.GetFileSize(FileName : string): longint;
1667 if not FileExists(FileName) then begin
1671 Assign(F, FileName);
1673 Result := FileSize(F);
1680 (*************************************************************************
1681 *
\83t
\83@
\83C
\83\8b\8ds
\90\94\8eæ
\93¾
1682 *************************************************************************)
1683 function TGikoSys.GetFileLineCount(FileName : string): longint;
1687 sl := TStringList.Create;
1690 sl.LoadFromFile(FileName);
1701 (*************************************************************************
1702 *
\83X
\83\8c\83b
\83h
\83t
\83@
\83C
\83\8b\82©
\82ç
\8ew
\92è
\8ds
\82ð
\8eæ
\93¾
1703 *************************************************************************)
1704 function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string;
1706 fileTmp : TStringList;
1709 if FileExists(FileName) then begin
1710 fileTmp := TStringList.Create;
1713 fileTmp.LoadFromFile( FileName );
1714 if ( Line >= 1 ) and ( Line < fileTmp.Count + 1 ) then begin
1715 Result := fileTmp.Strings[ Line-1 ];
1718 //on EFOpenError do Result := '';
1726 (*************************************************************************
1727 *
\83V
\83X
\83e
\83\80\83\81\83j
\83\85\81[
\83t
\83H
\83\93\83g
\82Ì
\91®
\90«
\82ð
\8eæ
\93¾
1728 *************************************************************************)
1729 procedure TGikoSys.MenuFont(Font: TFont);
1732 nm: NONCLIENTMETRICS;
1734 nm.cbSize := sizeof(NONCLIENTMETRICS);
1736 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0);
1737 lf := nm.lfMenuFont;
1739 Font.Name := lf.lfFaceName;
1740 Font.Height := lf.lfHeight;
1742 if lf.lfWeight >= 700 then
1743 Font.Style := Font.Style + [fsBold];
1744 if lf.lfItalic = 1 then
1745 Font.Style := Font.Style + [fsItalic];
1748 (*************************************************************************
1750 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1751 *************************************************************************)
1752 function TGikoSys.RemoveToken(var s: string; delimiter: string): string;
1756 p := AnsiPos(delimiter, s);
1760 Result := Copy(s, 1, p - 1);
1761 s := Copy(s, Length(Result) + Length(delimiter) + 1, Length(s));
1764 (*************************************************************************
1766 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1767 *************************************************************************)
1768 function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string;
1773 for i := 0 to index do
1774 Result := RemoveToken(s, delimiter);
1777 (*************************************************************************
1779 *************************************************************************)
1780 function TGikoSys.DeleteLink(const s: string): string;
1790 s1 := GetTokenIndex(s, '<a href="', i);
1791 s2 := GetTokenIndex(s, '<a href="', i + 1);
1793 idx := Pos('">', s1);
1795 Delete(s1, 1, idx + 1);
1796 idx := Pos('">', s2);
1798 Delete(s2, 1, idx + 1);
1800 Result := Result + s1 + s2;
1809 //
\83C
\83\93\83f
\83b
\83N
\83X
\96¢
\8dX
\90V
\83o
\83b
\83t
\83@
\82ð
\83t
\83\89\83b
\83V
\83\85\81I
1810 {procedure TGikoSys.FlashExitWrite;
1814 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
1815 for i := 0 to FExitWrite.Count - 1 do
1816 WriteThreadDat(FExitWrite[i]);
1820 (*************************************************************************
1821 *
\83X
\83\8c\96¼
\82È
\82Ç
\82ð
\92Z
\82¢
\96¼
\91O
\82É
\95Ï
\8a·
\82·
\82é
1823 *************************************************************************)
1824 function TGikoSys.GetShortName(const LongName: string; ALength: integer): string;
1826 ERASECHAR : array [1..39] of string =
1827 ('
\81\99','
\81\9a','
\81¡','
\81 ','
\81\9f','
\81\9e','
\81Q','
\81\94','
\81£','
\81¥',
1828 '
\81¢','
\81¤','
\81\9c','
\81\9b','
\81\9d','
\81y','
\81z','
\81ô','
\81s','
\81t',
1829 '
\81g','
\81h','
\81k','
\81l','
\81e','
\81f','
\81\83','
\81\84','
\81á','
\81â',
1830 '
\81o','
\81p','
\81q','
\81r','
\81w','
\81x','
\81¬','
\81c', '
\81@');
1832 Chr : array [0..255] of char;
1836 s := Trim(LongName);
1837 if (Length(s) <= ALength) then begin
1841 for i := Low(ERASECHAR) to High(ERASECHAR) do begin
1842 S := CustomStringReplace(S, ERASECHAR[i], '');
1844 if (Length(S) <= ALength) then begin
1847 Windows.LCMapString(
1848 GetUserDefaultLCID(),
1856 S := Copy(S,1,ALength);
1858 if (ByteType(S, Length(S)) = mbLeadByte ) then begin
1859 S := Copy(S, 1, Length(S) - 1);
1869 (*************************************************************************
1872 *************************************************************************)
1873 function TGikoSys.ConvRes(const Body, Bbs, Key,
1874 ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
1878 FIndexFrom : integer;
1885 ZN = '
\82O
\82P
\82Q
\82R
\82S
\82T
\82U
\82V
\82W
\82X
\81|';
1899 procedure Add(IndexFrom, IndexTo: integer; const No: string);
1904 FIndex.FIndexFrom := IndexFrom;
1905 FIndex.FIndexTo := IndexTo;
1909 function ChooseString(const Text, Separator: string; Index: integer): string;
1915 for i := 0 to Index - 1 do begin
1916 if (AnsiPos(Separator, S) = 0) then S := ''
1917 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
1919 p := AnsiPos(Separator, S);
1920 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
1929 List:= TList.Create;
1935 b := ByteType(s, i);
1937 mbSingleByte : begin
1938 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1939 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1947 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1948 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
1954 if (not sw) and (Copy(s,i,4) = GT) then begin
1955 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1963 if ((not sw) and (Copy(s,i,1) = ',')) or
1964 ((not sw) and (Copy(s,i,1) = '=')) then begin
1965 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
1966 ((Chk) and (oc = '')) or
1967 ((not Chk) and (al)) then
1977 if (AnsiPos(sx, SN) > 0) then begin
1980 if (No <> '') and (No <> '-') then begin
1993 if Copy(s,i,1) = '<' then oc := '';
1994 oc := oc + Copy(s,i,1);
2000 if (not sw) and (Copy(s,i,4) = '
\81\84\81\84') then begin
2006 if (not sw) and (Copy(s,i,2) = '
\81\84') then begin
2014 if (AnsiPos(sx, ZN) > 0) then begin
2015 No := No + ZenToHan(sx);
2017 if (No <> '') and (No <> '-') and (No <> '
\81|') then begin
2032 if (i > Length(Body)) then begin
2034 if (No <> '') then Add(sp, i, No);
2039 for i := List.Count - 1 downto 0 do begin
2040 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
2041 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
2042 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
2044 st := PIndex(List[i]).FNo;
2045 et := PIndex(List[i]).FNo;
2047 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
2048 Format('<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">',
2049 [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
2050 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
2051 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
2052 Dispose(PIndex(List[i]));
2058 function TGikoSys.ConvRes(
2059 const Body, Bbs, Key, ParamBBS, ParamKey,
2060 ParamStart, ParamTo, ParamNoFirst,
2061 ParamTrue, FullURL : string
2066 FIndexFrom : integer;
2073 ZN = '
\82O
\82P
\82Q
\82R
\82S
\82T
\82U
\82V
\82W
\82X
\81|';
2087 procedure Add(IndexFrom, IndexTo: integer; const No: string);
2092 FIndex.FIndexFrom := IndexFrom;
2093 FIndex.FIndexTo := IndexTo;
2097 function ChooseString(const Text, Separator: string; Index: integer): string;
2103 for i := 0 to Index - 1 do begin
2104 if (AnsiPos(Separator, S) = 0) then S := ''
2105 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
2107 p := AnsiPos(Separator, S);
2108 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
2117 List:= TList.Create;
2123 b := ByteType(s, i);
2125 mbSingleByte : begin
2126 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
2127 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
2135 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
2136 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
2142 if (not sw) and (Copy(s,i,4) = GT) then begin
2143 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
2151 if ((not sw) and (Copy(s,i,1) = ',')) or
2152 ((not sw) and (Copy(s,i,1) = '=')) then begin
2153 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
2154 ((Chk) and (oc = '')) or
2155 ((not Chk) and (al)) then
2165 if (AnsiPos(sx, SN) > 0) then begin
2168 if (No <> '') and (No <> '-') then begin
2181 if Copy(s,i,1) = '<' then oc := '';
2182 oc := oc + Copy(s,i,1);
2188 if (not sw) and (Copy(s,i,4) = '
\81\84\81\84') then begin
2194 if (not sw) and (Copy(s,i,2) = '
\81\84') then begin
2202 if (AnsiPos(sx, ZN) > 0) then begin
2203 No := No + ZenToHan(sx);
2205 if (No <> '') and (No <> '-') and (No <> '
\81|') then begin
2220 if (i > Length(Body)) then begin
2222 if (No <> '') then Add(sp, i, No);
2227 for i := List.Count - 1 downto 0 do begin
2228 //plName := Copy(PluginName, LastDelimiter('\',PluginName) + 1, Length(PluginName) - LastDelimiter('/',PluginName) -1 );
2229 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
2230 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
2231 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
2233 st := PIndex(List[i]).FNo;
2234 et := PIndex(List[i]).FNo;
2236 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
2237 Format('<a href="%s=%s=%s=%s=%s=%s=%s" target="_blank">',
2238 [FullURL, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
2239 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
2240 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
2241 Dispose(PIndex(List[i]));
2247 (*************************************************************************
2248 *
\91S
\8ap
\81¨
\94¼
\8ap
2250 *************************************************************************)
2251 function TGikoSys.ZenToHan(const s: string): string;
2253 Chr: array [0..255] of char;
2255 Windows.LCMapString(
2256 GetUserDefaultLCID(),
2258 LCMAP_HALFWIDTH or LCMAP_KATAKANA or LCMAP_LOWERCASE,
2267 (*************************************************************************
2268 *
\91S
\8ap
\94¼
\8ap
\82Ð
\82ç
\82ª
\82È
\82©
\82½
\82©
\82È
\82ð
\8bæ
\95Ê
\82µ
\82È
\82¢
\90¦
\82¢Pos
2269 *************************************************************************)
2270 function TGikoSys.VaguePos(const Substr, S: string): Integer;
2272 Result := Pos(ZenToHan(Substr), ZenToHan(S));
2275 function TGikoSys.BoolToInt(b: Boolean): Integer;
2277 Result := IfThen(b, 1, 0);
2280 function TGikoSys.IntToBool(i: Integer): Boolean;
2285 //gzip
\82Å
\88³
\8fk
\82³
\82ê
\82½
\82Ì
\82ð
\96ß
\82·
2286 function TGikoSys.GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
2290 GZipStream: TGzipDecompressStream;
2291 TextStream: TStringStream;
2292 buf: array[0..BUF_SIZE - 1] of Byte;
2298 TextStream := TStringStream.Create('');
2300 //
\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¢)
2301 // if LowerCase(Trim(ContentEncoding)) = 'gzip' then begin
2302 if AnsiPos('gzip', LowerCase(Trim(ContentEncoding))) > 0 then begin
2303 ResStream.Position := 0;
2304 GZipStream := TGzipDecompressStream.Create(TextStream);
2307 FillChar(buf, BUF_SIZE, 0);
2308 cnt := ResStream.Read(buf, BUF_SIZE);
2310 GZipStream.Write(buf, BUF_SIZE);
2316 ResStream.Position := 0;
2318 FillChar(buf, BUF_SIZE, 0);
2319 cnt := ResStream.Read(buf, BUF_SIZE);
2321 TextStream.Write(buf, BUF_SIZE);
2325 //NULL
\95¶
\8e\9a\82ð"*"
\82É
\82·
\82é
2326 s := TextStream.DataString;
2328 while (i > 0) and (s[i] = #0) do
2333 while i <> 0 do begin
2343 procedure TGikoSys.LoadKeySetting(ActionList: TActionList);
2345 STD_SEC = 'KeySetting';
2351 SecList: TStringList;
2352 Component: TComponent;
2354 if not FileExists(GetConfigDir + KEY_SETTING_FILE_NAME) then
2356 SecList := TStringList.Create;
2357 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
2359 ini.ReadSection(STD_SEC, SecList);
2360 for i := 0 to SecList.Count - 1 do begin
2361 ActionName := SecList[i];
2362 ActionKey := ini.ReadInteger(STD_SEC, ActionName, -1);
2363 if ActionKey <> -1 then begin
2364 Component := ActionList.Owner.FindComponent(ActionName);
2365 if TObject(Component) is TAction then begin
2366 TAction(Component).ShortCut := ActionKey;
2376 procedure TGikoSys.SaveKeySetting(ActionList: TActionList);
2378 STD_SEC = 'KeySetting';
2383 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
2385 for i := 0 to ActionList.ActionCount - 1 do begin
2386 if ActionList.Actions[i].Tag = -1 then
2388 ini.WriteInteger(STD_SEC, ActionList.Actions[i].Name, TAction(ActionList.Actions[i]).ShortCut);
2397 procedure TGikoSys.CreateProcess(const AppPath: string; const Param: string);
2399 PI: TProcessInformation;
2403 Path := '"' + AppPath + '"';
2405 Path := Path + ' ' + Param;
2407 SI.Cb := SizeOf(Si);
2408 SI.lpReserved := nil;
2409 SI.lpDesktop := nil;
2412 SI.cbReserved2 := 0;
2413 SI.lpReserved2 := nil;
2415 Windows.CreateProcess(nil,
2427 procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
2431 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2432 gbtUserApp, gbtAuto:
2433 if (Setting.URLApp) and (FileExists(Setting.URLAppFile)) then
2434 GikoSys.CreateProcess(Setting.URLAppFile, URL)
2436 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2440 function TGikoSys.HTMLDecode(const AStr: String): String;
2442 Sp, Rp, Cp, Tp: PChar;
2447 SetLength(Result, Length(AStr));
2449 Rp := PChar(Result);
2452 while Sp^ <> #0 do begin
2458 'a': if AnsiStrPos(Sp, 'amp;') = Sp then
2464 'g': if (AnsiStrPos(Sp, 'lt;') = Sp) or (AnsiStrPos(Sp, 'gt;') = Sp) then
2468 while (Sp^ <> ';') and (Sp^ <> #0) do
2475 'q': if AnsiStrPos(Sp, 'quot;') = Sp then
2483 Num := IsNumeric(Copy(Tp, 1, 1));
2484 while (Sp^ <> ';') and (Sp^ <> #0) do begin
2485 if (Num) and (not IsNumeric(Copy(Sp, 1, 1))) then
2489 SetString(S, Tp, Sp - Tp);
2494 //raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2495 //[Cp^ + Sp^, Cp - PChar(AStr)])
2505 // on E:EConvertError do
2506 // raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2507 // [Cp^ + Sp^, Cp - PChar(AStr)])
2509 SetLength(Result, Rp - PChar(Result));
2512 function TGikoSys.GetHRefText(s: string): string;
2522 Index := AnsiPos('href', LowerCase(s));
2525 s := Trim(Copy(s, Index + 4, Length(s)));
2526 s := Trim(Copy(s, 2, Length(s)));
2528 //
\8en
\82ß
\82Ì
\95¶
\8e\9a\82ª'"'
\82È
\82ç
\8eæ
\82è
\8f\9c\82
2529 if Copy(s, 1, 1) = '"' then begin
2530 s := Trim(Copy(s, 2, Length(s)));
2533 Index := AnsiPos('"', s);
2534 if Index <> 0 then begin
2535 //'"'
\82Ü
\82ÅURL
\82Æ
\82·
\82é
2536 s := Copy(s, 1, Index - 1);
2538 //'"'
\82ª
\96³
\82¯
\82ê
\82Î
\83X
\83y
\81[
\83X
\82©">"
\82Ì
\91\81\82¢
\95û
\82Ü
\82Å
\82ðURL
\82Æ
\82·
\82é
2539 Index := AnsiPos(' ', s);
2540 Index2 := AnsiPos('>', s);
2543 if Index > Index2 then
2546 s := Copy(s, 1, Index - 1)
2548 //
\82±
\82ê
\88È
\8fã
\82à
\82¤
\92m
\82ç
\82ñ
\82Ê
2554 //
\83z
\83X
\83g
\96¼
\82ª
\82Q
\82\83\82\88\82©
\82Ç
\82¤
\82©
\83`
\83F
\83b
\83N
\82·
\82é
2555 function TGikoSys.Is2chHost(Host: string): Boolean;
2557 HOST_NAME: array[0..1] of string = ('2ch.net', 'bbspink.com');
2563 if RightStr( Host, 1 ) = '/' then
2564 Host := Copy( Host, 1, Length( Host ) - 1 );
2565 OutputDebugString(pchar(HOST_NAME[0]));
2566 for i := 0 to Length(HOST_NAME) - 1 do begin
2567 // Len := Length(HOST_NAME[i]);
2568 if AnsiPos(HOST_NAME[i], Host) = (Length(Host) - Length(HOST_NAME[i]) + 1) then begin
2575 function TGikoSys.Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
2585 Index := AnsiPos(READ_PATH, path);
2586 if Index <> 0 then begin
2587 s := Copy(path, Length(READ_PATH) + 1, Length(path));
2588 BBSID := GetTokenIndex(s, '/', 0);
2589 BBSKey := GetTokenIndex(s, '/', 1);
2592 Result := (BBSID <> '') or (BBSKey <> '');
2595 Index := AnsiPos(KAKO_PATH, path);
2596 if Index <> 0 then begin
2597 s := Copy(path, 2, Length(path));
2598 BBSID := GetTokenIndex(s, '/', 0);
2599 if (BBSID = 'log') and (GetTokenIndex(s, '/', 2) = 'kako') then
2600 BBSID := GetTokenIndex(s, '/', 1);
2601 BBSKey := ChangeFileExt(Document, '');
2602 Result := (BBSID <> '') or (BBSKey <> '');
2605 Index := AnsiPos('read.cgi?', URL);
2606 if Index <> 0 then begin
2607 SList := TStringList.Create;
2610 // s := HTMLDecode(Document);
2611 ExtractHTTPFields(['?', '&'], [], PChar(URL), SList, False);
2612 BBSID := SList.Values['bbs'];
2613 BBSKey := SList.Values['key'];
2614 Result := (BBSID <> '') or (BBSKey <> '');
2625 function TGikoSys.Parse2chURL2(URL: string): TPathRec;
2637 URL := Trim(LowerCase(URL));
2642 Result.FFirst := False;
2643 Result.FStBegin := False;
2644 Result.FToEnd := False;
2645 Result.FDone := False;
2650 FAWKStr.RegExp := 'http://.+\.(2ch\.net|bbspink\.com)/';
2651 if FAWKStr.Match(FAWKStr.ProcessEscSeq(URL), RStart, RLength) = 0 then
2653 s := Copy(URL, RStart + RLength - 1, Length(URL));
2655 //
\95W
\8f\80\8f\91\8e®
2656 //
\8dÅ
\8cã
\82Íl50, 10, 10-20, 10n, 10-20n, -10, 10-, 10n-
\82È
\82Ç
2657 //http://xxx.2ch.net/test/read.cgi/bbsid/1000000000/
2658 FAWKStr.RegExp := '/test/read.cgi/.+/[0-9]+/.*';
2659 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2660 s := Copy(s, 15, Length(s));
2662 SList := TStringList.Create;
2665 FAWKStr.RegExp := '/';
2666 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2667 Result.FBBS := SList[1];
2668 Result.FKey := SList[2];
2669 if SList.Count >= 3 then
2677 FAWKStr.LineSeparator := mcls_CRLF;
2678 FAWKStr.RegExp := '-';
2679 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) = 0 then begin
2680 Result.FFirst := True;
2682 FAWKStr.RegExp := 'l[0-9]+';
2683 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2684 Result.FFirst := True;
2686 for i := 0 to SList.Count - 1 do begin
2687 if Trim(SList[i]) = '' then begin
2689 Result.FStBegin := True;
2690 if i = (SList.Count - 1) then
2691 Result.FToEnd := True;
2692 end else if IsNumeric(SList[i]) then begin
2693 wkInt := StrToInt(SList[i]);
2694 wkMax := Max(wkMax, wkInt);
2698 wkMin := Min(wkMin, wkInt);
2699 end else if Trim(SList[i]) = 'n' then begin
2700 Result.FFirst := True;
2702 FAWKStr.RegExp := '^n[0-9]+$|^[0-9]+n$';
2703 if FAWKStr.Match(FAWKStr.ProcessEscSeq(SList[i]), RStart, RLength) > 0 then begin
2704 if Copy(SList[i], 1, 1) = 'n' then
2705 wkInt := StrToInt(Copy(SList[i], 2, Length(SList[i])))
2707 wkInt := StrToInt(Copy(SList[i], 1, Length(SList[i]) - 1));
2708 Result.FFirst := True;
2709 wkMax := Max(wkMax, wkInt);
2713 wkMin := Min(wkMin, wkInt);
2717 if Result.FStBegin and (not Result.FToEnd) then
2719 else if (not Result.FStBegin) and Result.FToEnd then
2721 else if (not Result.FStBegin) and (not Result.FToEnd) then begin
2722 Result.FSt := wkMin;
2723 Result.FTo := wkMax;
2725 //Result.FSt := wkMin;
2726 //Result.FTo := wkMax;
2732 Result.FDone := True;
2736 //
\90Vkako
\8f\91\8e®
2737 //http://server.2ch.net/ITA_NAME/kako/1000/10000/1000000000.html
2738 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+/[0-9]+\.html';
2739 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2740 SList := TStringList.Create;
2743 FAWKStr.RegExp := '/';
2744 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2745 Result.FBBS := SList[1];
2746 Result.FKey := ChangeFileExt(SList[5], '');
2747 Result.FFirst := True;
2753 Result.FDone := True;
2757 //
\8b\8ckako
\8f\91\8e®
2758 //http://server.2ch.net/ITA_NAME/kako/999/999999999.html
2759 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+\.html';
2760 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2761 SList := TStringList.Create;
2764 FAWKStr.RegExp := '/';
2765 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 5 then begin
2766 Result.FBBS := SList[1];
2767 Result.FKey := ChangeFileExt(SList[4], '');
2768 Result.FFirst := True;
2774 Result.FDone := True;
2778 //log
\8by
\82Ñlog2
\8f\91\8e®
2779 //http://server.2ch.net/log/ITA_NAME/kako/999/999999999.html
2780 //http://server.2ch.net/log2/ITA_NAME/kako/999/999999999.html
2781 FAWKStr.RegExp := '/log2?/.+/kako/[0-9]+/[0-9]+\.html';
2782 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2783 SList := TStringList.Create;
2786 FAWKStr.RegExp := '/';
2787 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2788 Result.FBBS := SList[2];
2789 Result.FKey := ChangeFileExt(SList[5], '');
2790 Result.FFirst := True;
2796 Result.FDone := True;
2801 //
\8b\8cURL
\8f\91\8e®
2802 //http://server.2ch.net/test/read.cgi?bbs=ITA_NAME&key=1000000000&st=1&to=5&nofirst=true
2803 FAWKStr.RegExp := '/test/read\.cgi\?';
2804 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2805 s := Copy(s, 16, Length(s));
2806 SList := TStringList.Create;
2809 FAWKStr.RegExp := '&';
2810 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2811 Result.FFirst := True;
2812 for i := 0 to SList.Count - 1 do begin
2813 if Pos('bbs=', SList[i]) = 1 then begin
2814 Result.FBBS := Copy(SList[i], 5, Length(SList[i]));
2815 end else if Pos('key=', SList[i]) = 1 then begin
2816 Result.FKey := Copy(SList[i], 5, Length(SList[i]));
2817 end else if Pos('st=', SList[i]) = 1 then begin
2818 wk := Copy(SList[i], 4, Length(SList[i]));
2819 if IsNumeric(wk) then
2820 Result.FSt := StrToInt(wk)
2821 else if wk = '' then
2822 Result.FStBegin := True;
2823 end else if Pos('to=', SList[i]) = 1 then begin
2824 wk := Copy(SList[i], 4, Length(SList[i]));
2825 if IsNumeric(wk) then
2826 Result.FTo := StrToInt(wk)
2827 else if wk = '' then
2828 Result.FToEnd := True;
2829 end else if Pos('nofirst=', SList[i]) = 1 then begin
2830 Result.FFirst := False;
2839 if (Result.FBBS <> '') and (Result.FKey <> '') then begin
2840 Result.FDone := True;
2846 procedure TGikoSys.ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
2856 URI := TIdURI.Create(URL);
2858 Protocol := URI.Protocol;
2861 Document := URI.Document;
2863 Bookmark := URI.Bookmark;
2869 function TGikoSys.GetVersionBuild: Integer;
2871 FixedFileInfo: PVSFixedFileInfo;
2872 VersionHandle, VersionSize: DWORD;
2873 pVersionInfo: Pointer;
2878 AppFile := Application.ExeName;
2879 VersionSize := GetFileVersionInfoSize(pChar(AppFile), VersionHandle);
2880 if VersionSize = 0 then
2882 GetMem(pVersionInfo, VersionSize);
2884 if GetFileVersionInfo(PChar(AppFile),VersionHandle,VersionSize, pVersionInfo) then
2885 if VerQueryValue(pVersionInfo, '\', Pointer(FixedFileInfo), ItemLen) then
2886 Result := LOWORD(FixedFileInfo^.dwFileVersionLS);
2888 FreeMem(pVersionInfo, VersionSize);
2892 function TGikoSys.GetBrowsableThreadURL(
2896 threadItem : TThreadItem;
2897 boardPlugIn : TBoardPlugIn;
2901 //=====
\83v
\83\89\83O
\83C
\83\93
2903 for i := Length( BoardPlugIns ) - 1 downto 0 do begin
2904 if Assigned( Pointer( BoardPlugIns[ i ].Module ) ) then begin
2905 if BoardPlugIns[ i ].AcceptURL( inURL ) = atThread then begin
2906 boardPlugIn := BoardPlugIns[ i ];
2907 threadItem := TThreadItem.Create( boardPlugIn, inURL );
2908 Result := threadItem.URL;
2916 // 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¢
2919 if Length( Result ) = 0 then
2920 Result := GikoSys.Get2chBrowsableThreadURL( inURL );
2924 function TGikoSys.GetThreadURL2BoardURL(
2928 threadItem : TThreadItem;
2929 boardPlugIn : TBoardPlugIn;
2933 //=====
\83v
\83\89\83O
\83C
\83\93
2935 for i := Length( BoardPlugIns ) - 1 downto 0 do begin
2936 if Assigned( Pointer( BoardPlugIns[ i ].Module ) ) then begin
2937 if BoardPlugIns[ i ].AcceptURL( inURL ) = atThread then begin
2938 boardPlugIn := BoardPlugIns[ i ];
2939 threadItem := TThreadItem.Create( boardPlugIn, inURL );
2940 Result := BoardPlugIns[ i ].GetBoardURL( Longword( threadItem ) );
2948 // 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¢
2951 if Length( Result ) = 0 then
2952 Result := GikoSys.Get2chThreadURL2BoardURL( inURL );
2956 function TGikoSys.Get2chThreadURL2BoardURL(
2960 Protocol, Host, Path, Document, Port, Bookmark : string;
2961 BBSID, BBSKey : string;
2964 ParseURI( inURL, Protocol, Host, Path, Document, Port, Bookmark );
2965 Parse2chURL( inURL, Path, Document, BBSID, BBSKey );
2967 Result := Copy( inURL, 1, Pos( '/test/read.cgi', inURL ) ) + BBSID + '/';
2971 function TGikoSys.Get2chBrowsableThreadURL(
2975 Protocol, Host, Path, Document, Port, Bookmark : string;
2976 BBSID, BBSKey : string;
2980 if Pos( KAKO_PATH, inURL ) > 0 then begin
2983 ParseURI( inURL, Protocol, Host, Path, Document, Port, Bookmark );
2984 Parse2chURL( inURL, Path, Document, BBSID, BBSKey );
2985 foundPos := Pos( '/test/read.cgi', inURL ) - 1;
2987 if Is2chHost( Host ) then begin
2988 Result := Copy( inURL, 1, foundPos ) +
2989 READ_PATH + BBSID + '/' + BBSKey + '/l50';
2991 Result := Copy( inURL, 1, foundPos ) +
2992 OLD_READ_PATH + 'bbs=' + BBSID + '&key=' + BBSKey + '&ls=50';
2998 function TGikoSys.Get2chBoard2ThreadURL(
3006 server := UrlToServer( inBoard.URL );
3007 if Is2chHost( server ) then
3008 Result := server + 'test/read.cgi/' + inBoard.BBSID + '/' + inKey + '/l50'
3010 Result := server + 'test/read.cgi?bbs=' + inBoard.BBSID + '&key=' + inKey + '&ls=50';
3014 (*************************************************************************
3015 *
\8b@
\94\
\96¼
\81@
\81@
\81F
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\93Ç
\82Ý
\8d\9e\82Ý
3016 *
\89Â
\8e\8b\81@
\81@
\81@
\81FPublic
3017 *
\97\9a\97ð
\82P
\81@
\81@
\81F
\90V
\8bK
\8dì
\90¬
3018 *************************************************************************)
3019 procedure TGikoSys.ReadBoardFile;
3023 CategoryList: TStringList;
3024 BoardList: TStringList;
3025 Category: TCategory;
3028 RoundItem: TRoundItem;
3030 // BBS
\94z
\97ñ(1
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\82É
\82Â
\82« 1
\8d\80\96Ú)
3031 bbsList : array of TStringList;
3032 boardFileList : TStringList;
3034 i, iBound : Integer;
3035 j, jBound : Integer;
3036 k, kBound : Integer;
3037 l, lBound : Integer;
3039 ini := TMemIniFile.Create('');
3043 for i := 0 to Length( BBSs ) - 1 do
3047 SetLength( BBSs, 0 );
3049 //
\94Â
\83\8a\83X
\83g
\82Ì
\97ñ
\8b\93
3050 if FileExists( GikoSys.GetBoardFileName ) then begin
3051 l := Length( bbsList );
3052 SetLength( bbsList, l + 1 );
3053 bbsList[ l ] := TStringList.Create;
3054 bbsList[ l ].LoadFromFile( GikoSys.GetBoardFileName );
3056 SetLength( BBSs, l + 1 );
3057 BBSs[ l ] := TBBS.Create( GikoSys.Setting.LogFolder );
3058 BBSs[ l ].Title := '
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é';
3061 if FileExists( GikoSys.GetCustomBoardFileName ) then begin
3062 l := Length( bbsList );
3063 SetLength( bbsList, l + 1 );
3064 bbsList[ l ] := TStringList.Create;
3065 bbsList[ l ].LoadFromFile( GikoSys.GetCustomBoardFileName );
3067 SetLength( BBSs, l + 1 );
3068 BBSs[ l ] := TBBS.Create( GikoSys.Setting.LogFolder );
3069 BBSs[ l ].Title := '
\82»
\82Ì
\91¼';
3072 // Board
\83t
\83H
\83\8b\83_
3073 if DirectoryExists( GikoSys.Setting.GetBoardDir ) then begin
3074 BoardFileList := TStringList.Create;
3076 GikoSys.GetFileList( GikoSys.Setting.GetBoardDir, '*', BoardFileList, True, True );
3077 l := Length( bbsList );
3078 for i := BoardFileList.Count - 1 downto 0 do begin
3079 SetLength( bbsList, l + 1 );
3080 bbsList[ l ] := TStringList.Create;
3081 bbsList[ l ].LoadFromFile( BoardFileList[ i ] );
3083 SetLength( BBSs, l + 1 );
3084 BBSs[ l ] := TBBS.Create( GikoSys.Setting.LogFolder );
3085 BBSs[ l ].Title := ChangeFileExt( ExtractFileName( BoardFileList[ i ] ), '' );
3094 lBound := Length( bbsList ) - 1;
3095 for l := 0 to lBound do begin
3096 ini.SetStrings( bbsList[ l ] );
3097 CategoryList := TStringList.Create;
3098 BoardList := TStringList.Create;
3100 ini.ReadSections( CategoryList );
3102 iBound := CategoryList.Count - 1;
3103 for i := 0 to iBound do begin
3104 ini.ReadSection( CategoryList[i], BoardList );
3105 Category := TCategory.Create;
3106 Category.No := i + 1;
3107 Category.Title := CategoryList[i];
3109 jBound := BoardList.Count - 1;
3110 for j := 0 to jBound do begin
3112 inistr := ini.ReadString(CategoryList[i], BoardList[j], '');
3114 //=====
\83v
\83\89\83O
\83C
\83\93
3116 kBound := Length( BoardPlugIns ) - 1;
3117 for k := 0 to kBound do begin
3118 if Assigned( Pointer( BoardPlugIns[ k ].Module ) ) then begin
3119 if BoardPlugIns[ k ].AcceptURL( inistr ) = atBoard then begin
3120 Board := TBoard.Create( BoardPlugIns[ k ], inistr );
3127 // 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¢
3131 Board := TBoard.Create( nil, inistr );
3134 Board.Title := BoardList[j];
3135 Board.RoundDate := ZERO_DATE;
3137 idx := RoundList.Find(Board);
3138 if idx <> -1 then begin
3139 RoundItem := RoundList.Items[idx, grtBoard];
3140 Board.Round := True;
3141 Board.RoundName := RoundItem.RoundName;
3143 Category.Add(Board);
3148 BBSs[ l ].Add( Category );
3157 lBound := Length( bbsList ) - 1;
3158 for l := 0 to lBound do
3163 function TGikoSys.GetUnknownCategory : TCategory;
3165 UNKNOWN_CATEGORY = '(
\96¼
\8fÌ
\95s
\96¾)';
3168 if Length( BBSs ) < 2 then begin
3173 Result := BBSs[ 1 ].FindCategoryFromTitle( UNKNOWN_CATEGORY );
3174 if Result = nil then begin
3175 Result := TCategory.Create;
3176 Result.Title := UNKNOWN_CATEGORY;
3177 BBSs[ 1 ].Add( Result );
3182 function TGikoSys.GetUnknownBoard( inPlugIn : TBoardPlugIn; inURL : string ) : TBoard;
3184 category : TCategory;
3186 UNKNOWN_BOARD = '(
\96¼
\8fÌ
\95s
\96¾)';
3189 category := GetUnknownCategory;
3190 if category = nil then begin
3193 Result := category.FindBoardFromTitle( UNKNOWN_BOARD );
3194 if Result = nil then begin
3195 Result := TBoard.Create( inPlugIn, inURL );
3196 Result.Title := UNKNOWN_BOARD;
3197 category.Add( Result );
3204 GikoSys := TGikoSys.Create;
3207 if GikoSys <> nil then begin