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;
94 // FExitWrite: TStringList;
95 // function StrToFloatDef(s: string; Default: Double): Double;
99 FSelectResFilter : TAbon;
102 destructor Destroy; override;
103 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; var 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 procedure GetPopupResNumber(URL : string; var stRes, endRes : Integer);
199 //
\83X
\83L
\83\93\82ð
\93Ç
\82Ý
\8d\9e\82Ý
\81A
\92l
\82ð
\92u
\8a·
\82·
\82é
200 function LoadFromSkin( fileName: string; ThreadItem: TThreadItem; SizeByte: Integer ): string;
201 //
\83\8c\83X
\82Ì
\92l
\82ð
\92u
\8a·
\82·
\82é
202 function SkinedRes( skin: string; Res: TResRec; No: string ): string;
209 LENGTH_RESTITLE = 40;
210 ZERO_DATE: Integer = 25569;
211 BETA_VERSION_NAME_E = 'beta';
212 BETA_VERSION_NAME_J = 'ÊÞÀ';
214 BETA_VERSION_BUILD = ''; //debug
\94Å
\82È
\82Ç
215 APP_NAME = 'gikoNavi';
223 FOLDER_INDEX_VERSION = '1.01';
224 USER_AGENT = 'Monazilla';
225 DEFAULT_NGWORD_FILE_NAME : String = 'NGword.txt';
226 NGWORDs_DIR_NAME : String = 'NGwords';
228 READ_PATH: string = '/test/read.cgi/';
229 OLD_READ_PATH: string = '/test/read.cgi?';
230 KAKO_PATH: string = '/kako/';
232 (*************************************************************************
233 *GikoSys
\83R
\83\93\83X
\83g
\83\89\83N
\83^
234 *************************************************************************)
235 constructor TGikoSys.Create;
237 FSetting := TSetting.Create;
238 FDolib := TDolib.Create;
239 FAWKStr := TAWKStr.Create(nil);
240 if DirectoryExists(GetConfigDir) = false then begin
241 CreateDir(GetConfigDir);
243 FAbon := TAbon.Create;
244 FAbon.Setroot(GetConfigDir+NGWORDs_DIR_NAME);
246 FAbon.ReturnNGwordLineNum := FSetting.ShowNGLinesNum;
247 FAbon.SetNGResAnchor := FSetting.AddResAnchor;
248 FAbon.Deleterlo := FSetting.AbonDeleterlo;
249 FAbon.Replaceul := FSetting.AbonReplaceul;
250 FAbon.AbonPopupRes := FSetting.PopUpAbon;
252 FSelectResFilter := TAbon.Create;
253 //
\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
254 FSelectResFilter.AbonString := '';
256 OnlyAHundredRes := FSetting.OnlyAHundredRes;
259 (*************************************************************************
260 *GikoSys
\83f
\83X
\83g
\83\89\83N
\83^
261 *************************************************************************)
262 destructor TGikoSys.Destroy;
265 FileList: TStringList;
267 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
275 FSelectResFilter.Free;
276 //
\83e
\83\93\83|
\83\89\83\8aHTML
\82ð
\8dí
\8f\9c
277 FileList := TStringList.Create;
279 GetFileList(GetTempFolder, '*.html', FileList, False, True);
280 for i := 0 to FileList.Count - 1 do begin
281 DeleteFile(FileList[i]);
289 (*************************************************************************
290 *
\95¶
\8e\9a\97ñ
\90\94\8e\9a\83`
\83F
\83b
\83N
291 *************************************************************************)
293 function TGikoSys.IsNumeric(s: string): boolean;
303 (*************************************************************************
304 *
\95¶
\8e\9a\97ñ
\95\82\93®
\8f¬
\90\94\93_
\90\94\8e\9a\83`
\83F
\83b
\83N
305 *************************************************************************)
306 function TGikoSys.IsFloat(s: string): boolean;
310 Result := TextToFloat(PChar(s), v, fvExtended);
313 (*************************************************************************
314 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
315 *************************************************************************)
316 function TGikoSys.GetBoardFileName: string;
318 Result := Setting.GetBoardFileName;
321 (*************************************************************************
322 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
323 *************************************************************************)
324 function TGikoSys.GetCustomBoardFileName: string;
326 Result := Setting.GetCustomBoardFileName;
329 (*************************************************************************
330 *
\83e
\83\93\83|
\83\89\83\8a\83t
\83H
\83\8b\83_
\81[
\96¼
\8eæ
\93¾
331 *************************************************************************)
332 function TGikoSys.GetHtmlTempFileName: string;
334 Result := Setting.GetHtmlTempFileName;
338 (*************************************************************************
339 *
\8eÀ
\8ds
\83t
\83@
\83C
\83\8b\83t
\83H
\83\8b\83_
\8eæ
\93¾
340 *************************************************************************)
341 function TGikoSys.GetAppDir: string;
343 Result := Setting.GetAppDir;
346 (*************************************************************************
347 *TempHtml
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
348 *************************************************************************)
349 function TGikoSys.GetTempFolder: string;
351 Result := Setting.GetTempFolder;
354 (*************************************************************************
355 *sent.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
356 *************************************************************************)
357 function TGikoSys.GetSentFileName: string;
359 Result := Setting.GetSentFileName;
362 (*************************************************************************
363 *outbox.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
364 *************************************************************************)
365 function TGikoSys.GetOutBoxFileName: string;
367 Result := Setting.GetOutBoxFileName;
370 (*************************************************************************
371 *Config
\83t
\83H
\83\8b\83_
\8eæ
\93¾
372 *************************************************************************)
373 function TGikoSys.GetConfigDir: string;
375 Result := Setting.GetConfigDir;
378 function TGikoSys.GetStyleSheetDir: string;
380 Result := Setting.GetStyleSheetDir;
383 function TGikoSys.GetSkinDir: string;
385 Result := Setting.GetSkinDir;
388 function TGikoSys.GetSkinHeaderFileName: string;
390 Result := Setting.GetSkinHeaderFileName;
393 function TGikoSys.GetSkinFooterFileName: string;
395 Result := Setting.GetSkinFooterFileName;
398 function TGikoSys.GetSkinNewResFileName: string;
400 Result := Setting.GetSkinNewResFileName;
403 function TGikoSys.GetSkinResFileName: string;
405 Result := Setting.GetSkinResFileName;
408 function TGikoSys.GetSkinBookmarkFileName: string;
410 Result := Setting.GetSkinBookmarkFileName;
413 function TGikoSys.GetSkinNewmarkFileName: string;
415 Result := Setting.GetSkinNewmarkFileName;
419 function TGikoSys.GetUserAgent: string;
421 if Dolib.Connected then begin
422 Result := Format('%s %s/%s%d%s', [
429 BETA_VERSION_BUILD]);
431 Result := Format('%s/%s %s/%s%d%s', [
439 BETA_VERSION_BUILD]);
443 (*************************************************************************
444 *
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é
\95û
\8e®
\8e\9e\8d\8f\8eæ
\93¾
445 *************************************************************************)
446 function TGikoSys.Get2chDate(aDate: TDateTime): string;
451 d1 := EncodeDate(1970, 1, 1);
452 d2 := aDate - EncodeTime(9, 0, 0, 0);
453 Result := FloatToStr(Trunc((d2 - d1) * 24 * 60 * 60));
457 function TGikoSys.IntToDateTime(val: Int64): TDateTime;
462 d1 := EncodeDate(1970, 1, 1);
463 d2 := (val * 1000) / (24 * 60 * 60 * 1000);
467 function TGikoSys.DateTimeToInt(ADate: TDateTime): Integer;
472 d := EncodeDate(1970, 1, 1);
473 c := (ADate - d) * 24 * 60 * 60;
478 (*************************************************************************
479 *Subject
\83t
\83@
\83C
\83\8bRead
480 *************************************************************************)
481 procedure TGikoSys.ReadSubjectFile(Board: TBoard);
483 ThreadItem: TThreadItem;
485 FileList: TStringList;
486 TmpFileList: TStringList;
487 // SrchRec: TSearchRec;
494 // TmpUpdate: Boolean;
497 RoundItem: TRoundItem;
503 // TmpUpdate := False;
505 usePlugIn := Board.IsBoardPlugInAvailable;
507 FileName := Board.GetFolderIndexFileName;
508 if not FileExists(FileName) then CreateThreadDat(Board);
509 // if not FileExists(FileName) then Exit;
511 { R := FindFirst(ExtractFileDir(Board.GetFolderIndexFileName) + '\*.dat', 0, SrchRec);
513 FileList.Add(SrchRec.Name);
514 R := FindNext(SrchRec);
518 FileList := TStringList.Create;
519 FileList.Sorted := True;
520 TmpFileList := TStringList.Create;
521 TmpFileList.Sorted := True;
523 //IsLogFile
\97pDAT
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
524 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False, False);
526 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\97pTmp
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
527 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, False, False);
529 sl := TStringList.Create;
531 if FileExists(FileName) then
532 sl.LoadFromFile(FileName);
534 //
\82Q
\8ds
\96Ú
\82©
\82ç
\81i
\82P
\8ds
\96Ú
\82Í
\83o
\81[
\83W
\83\87\83\93\81j
535 for i := sl.Count - 1 downto 1 do begin
536 Rec := ParseIndexLine(sl[i]);
539 ThreadItem := TThreadItem.Create(
541 Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), Rec.FFileName ) )
543 ThreadItem := TThreadItem.Create(
545 Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) );
547 if FileList.Count <> 0 then
548 if FileList.Find( ThreadItem.FileName, Index ) then
549 //ThreadItem.IsLogFile := True;
550 FileList.Delete( Index );
552 ThreadItem.BeginUpdate;
553 ThreadItem.No := Rec.FNo;
554 ThreadItem.FileName := Rec.FFileName;
555 ThreadItem.Title := Rec.FTitle;
556 ThreadItem.Count := Rec.FCount;
557 ThreadItem.Size := Rec.FSize;
558 // ThreadItem.RoundNo := Rec.FRoundNo;
559 ThreadItem.RoundDate := Rec.FRoundDate;
560 ThreadItem.LastModified := Rec.FLastModified;
561 ThreadItem.Kokomade := Rec.FKokomade;
562 ThreadItem.NewReceive := Rec.FNewReceive;
563 // ThreadItem.Round := Rec.FRound;
564 ThreadItem.UnRead := Rec.FUnRead;
565 ThreadItem.ScrollTop := Rec.FScrollTop;
566 ThreadItem.AllResCount := Rec.FAllResCount;
567 ThreadItem.NewResCount := Rec.FNewResCount;
568 ThreadItem.AgeSage := Rec.FAgeSage;
569 ThreadItem.ParentBoard := Board;
571 //
\8f\84\89ñ
\83\8a\83X
\83g
\82É
\91¶
\8dÝ
\82µ
\82½
\82ç
\8f\84\89ñ
\83t
\83\89\83O
\83Z
\83b
\83g
572 if ThreadItem.IsLogFile then begin
573 idx := RoundList.Find(ThreadItem);
574 if idx <> -1 then begin
575 RoundItem := RoundList.Items[idx, grtItem];
576 ThreadItem.RoundName := RoundItem.RoundName;
577 ThreadItem.Round := True;
581 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\83`
\83F
\83b
\83N
582 if TmpFileList.Count <> 0 then begin
583 if TmpFileList.Find(ChangeFileExt(ThreadItem.FileName, '.tmp'), Index) then begin
584 ini := TMemIniFile.Create(ChangeFileExt(ThreadItem.GetThreadFileName, '.tmp'));
586 ThreadItem.RoundDate := ini.ReadDateTime('Setting', 'RoundDate', ZERO_DATE);
587 ThreadItem.LastModified := ini.ReadDateTime('Setting', 'LastModified', ZERO_DATE);
588 ThreadItem.Size := ini.ReadInteger('Setting', 'Size', 0);
589 if ThreadItem.Size = 0 then begin
590 ThreadItem.Size := FileSizeByName(ThreadItem.FileName) - ThreadItem.Count;
592 ThreadItem.Count := ini.ReadInteger('Setting', 'Count', 0);
593 ThreadItem.NewReceive := ini.ReadInteger('Setting', 'NewReceive', 0);
594 ThreadItem.Round := ini.ReadBool('Setting', 'Round', False);
595 ThreadItem.UnRead := False;//ini.ReadBool('Setting', 'UnRead', False);
596 ThreadItem.ScrollTop := ini.ReadInteger('Setting', 'ScrollTop', 0);
597 ThreadItem.AllResCount := ini.ReadInteger('Setting', 'AllResCount', ThreadItem.Count);
598 ThreadItem.NewResCount := ini.ReadInteger('Setting', 'NewResCount', 0);
599 ThreadItem.AgeSage := TGikoAgeSage(ini.ReadInteger('Setting', 'AgeSage', Ord(gasNone)));
603 TmpFileList.Delete(Index);
607 ThreadItem.EndUpdate;
608 Board.Add(ThreadItem);
610 // if (ThreadItem.IsLogFile) and (ThreadItem.Count > ThreadItem.Kokomade) then
611 if (ThreadItem.IsLogFile) and (ThreadItem.UnRead) then
615 if UnRead <> Board.UnRead then
616 Board.UnRead := UnRead;
618 //
\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
619 for i := 0 to FileList.Count - 1 do begin
620 FileName := ExtractFileDir(Board.GetFolderIndexFileName) + '\' + FileList[i];
622 ResRec := DivideStrLine(ReadThreadFile(FileName, 1));
624 ThreadItem := TThreadItem.Create(
626 Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), FileList[i] ) )
628 ThreadItem := TThreadItem.Create(
629 nil, Get2chBoard2ThreadURL( Board, ChangeFileExt( FileList[i], '' ) ) );
630 ThreadItem.BeginUpdate;
631 ThreadItem.FilePath := FileName;
632 ThreadItem.No := Board.Count + 1;
633 ThreadItem.FileName := FileList[i];
634 ThreadItem.Title := ResRec.FTitle;
635 ThreadItem.Count := GetFileLineCount(FileName);
636 ThreadItem.AllResCount := ThreadItem.Count;
637 ThreadItem.NewResCount := ThreadItem.Count;
638 ThreadItem.Size := FileSizeByName(FileName) - ThreadItem.Count;//1byte
\82¸
\82ê
\82é
\82Æ
\82«
\82ª
\82 \82é
\82¯
\82Ç
\82»
\82ê
\82Í
\82 \82«
\82ç
\82ß
\82é
639 ThreadItem.RoundDate := ZERO_DATE;
640 ThreadItem.LastModified := ZERO_DATE;
641 ThreadItem.Kokomade := -1;
642 ThreadItem.NewReceive := ThreadItem.Count;
643 ThreadItem.ParentBoard := Board;
644 ThreadItem.IsLogFile := True;
645 ThreadItem.Round := False;
646 ThreadItem.UnRead := False;
647 ThreadItem.ScrollTop := 0;
648 ThreadItem.AgeSage := gasNone;
649 ThreadItem.EndUpdate;
650 Board.Add(ThreadItem);
657 Board.IsThreadDatRead := True;
660 (*************************************************************************
661 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X
\83t
\83@
\83C
\83\8b(Folder.idx)
\8dì
\90¬
662 *************************************************************************)
663 procedure TGikoSys.CreateThreadDat(Board: TBoard);
667 SubjectList: TStringList;
673 if not FileExists(Board.GetSubjectFileName) then Exit;
674 FileName := Board.GetFolderIndexFileName;
676 SubjectList := TStringList.Create;
678 SubjectList.LoadFromFile(Board.GetSubjectFileName);
679 sl := TStringList.Create;
682 sl.Add(FOLDER_INDEX_VERSION);
683 for i := 0 to SubjectList.Count - 1 do begin
684 Rec := DivideSubject(SubjectList[i]);
686 if (Trim(Rec.FFileName) = '') or (Trim(Rec.FTitle) = '') then
689 s := Format('%x', [cnt]) + #1 //
\94Ô
\8d\86
690 + Rec.FFileName + #1 //
\83t
\83@
\83C
\83\8b\96¼
691 + Rec.FTitle + #1 //
\83^
\83C
\83g
\83\8b
692 + Format('%x', [Rec.FCount]) + #1 //
\83J
\83E
\83\93\83g
693 + Format('%x', [0]) + #1 //size
694 + Format('%x', [0]) + #1 //RoundDate
695 + Format('%x', [0]) + #1 //LastModified
696 + Format('%x', [0]) + #1 //Kokomade
697 + Format('%x', [0]) + #1 //NewReceive
698 + '0' + #1 //
\96¢
\8eg
\97p
699 + Format('%x', [0]) + #1 //UnRead
700 + Format('%x', [0]) + #1 //ScrollTop
701 + Format('%x', [Rec.FCount]) + #1 //AllResCount
702 + Format('%x', [0]) + #1 //NewResCount
703 + Format('%x', [0]); //AgeSage
708 sl.SaveToFile(FileName);
717 (*************************************************************************
718 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X(Thread.dat)
\8f\91\82«
\8d\9e\82Ý
720 *************************************************************************)
721 procedure TGikoSys.WriteThreadDat(Board: TBoard);
723 // Values: array[Boolean] of string = ('0', '1');
731 TmpFileList: TStringList;
734 if not Board.IsThreadDatRead then
736 FileName := Board.GetFolderIndexFileName;
737 ForceDirectoriesEx( ExtractFilePath( FileName ) );
739 sl := TStringList.Create;
740 TmpFileList := TStringList.Create;
742 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, False, true);
745 sl.Add(FOLDER_INDEX_VERSION);
746 for i := 0 to Board.Count - 1 do begin
747 if Board.Items[i].No = 0 then
748 Board.Items[i].No := i + 1;
750 if TmpFileList.Count <> 0 then begin
751 if TmpFileList.Find(ChangeFileExt(Board.Items[i].FileName, '.tmp'), Index) then begin
752 ini := TMemIniFile.Create(ChangeFileExt(Board.Items[i].GetThreadFileName, '.tmp'));
754 tmpSize := ini.ReadInteger('Setting', 'Size', 0);
755 if Board.Items[i].Size < tmpSize then begin
756 //Board.Items[i].RoundDate := ini.ReadDateTime('Setting', 'RoundDate', ZERO_DATE);
757 //Board.Items[i].LastModified := ini.ReadDateTime('Setting', 'LastModified', ZERO_DATE);
758 Board.Items[i].Size := tmpSize;
759 Board.Items[i].Count := ini.ReadInteger('Setting', 'Count', 0);
760 Board.Items[i].NewReceive := ini.ReadInteger('Setting', 'NewReceive', 0);
761 //Board.Items[i].Round := ini.ReadBool('Setting', 'Round', False);
762 //Board.Items[i].UnRead := False;//ini.ReadBool('Setting', 'UnRead', False);
763 //Board.Items[i].ScrollTop := ini.ReadInteger('Setting', 'ScrollTop', 0);
764 Board.Items[i].AllResCount := ini.ReadInteger('Setting', 'AllResCount', Board.Items[i].Count);
765 Board.Items[i].NewResCount := ini.ReadInteger('Setting', 'NewResCount', 0);
766 //Board.Items[i].AgeSage := TGikoAgeSage(ini.ReadInteger('Setting', 'AgeSage', Ord(gasNone)));
771 DeleteFile(TmpFileList.Strings[Index]);
772 TmpFileList.Delete(Index);
776 s := Format('%x', [Board.Items[i].No]) + #1
777 + Board.Items[i].FileName + #1
778 + Board.Items[i].Title + #1
779 + Format('%x', [Board.Items[i].Count]) + #1
780 + Format('%x', [Board.Items[i].Size]) + #1
781 + Format('%x', [DateTimeToInt(Board.Items[i].RoundDate)]) + #1
782 + Format('%x', [DateTimeToInt(Board.Items[i].LastModified)]) + #1
783 + Format('%x', [Board.Items[i].Kokomade]) + #1
784 + Format('%x', [Board.Items[i].NewReceive]) + #1
785 + '0' + #1 //
\96¢
\8eg
\97p
786 + Format('%x', [BoolToInt(Board.Items[i].UnRead)]) + #1
787 + Format('%x', [Board.Items[i].ScrollTop]) + #1
788 + Format('%x', [Board.Items[i].AllResCount]) + #1
789 + Format('%x', [Board.Items[i].NewResCount]) + #1
790 + Format('%x', [Ord(Board.Items[i].AgeSage)]);
795 sl.SaveToFile(FileName);
797 for i := 0 to TmpFileList.Count - 1 do begin
798 DeleteFile(TmpFileList[i]);
807 function TGikoSys.ParseIndexLine(Line: string): TIndexRec;
812 for i := 0 to 14 do begin
813 s := GetTokenIndex(Line, #1, i);
815 0: Result.FNo := StrToIntDef('$' + s, 0);
816 1: Result.FFileName := s;
817 2: Result.FTitle := s;
818 3: Result.FCount := StrToIntDef('$' + s, 0);
819 4: Result.FSize := StrToIntDef('$' + s, 0);
820 5: Result.FRoundDate := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
821 6: Result.FLastModified := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
822 7: Result.FKokomade := StrToIntDef('$' + s, -1);
823 8: Result.FNewReceive := StrToIntDef('$' + s, 0);
825 10: Result.FUnRead := IntToBool(StrToIntDef('$' + s, 0));
826 11: Result.FScrollTop := StrToIntDef('$' + s, 0);
827 12: Result.FAllResCount := StrToIntDef('$' + s, 0);
828 13: Result.FNewResCount := StrToIntDef('$' + s, 0);
829 14: Result.FAgeSage := TGikoAgeSage(StrToIntDef('$' + s, 0));
834 //
\8ew
\92è
\83t
\83H
\83\8b\83_
\93à
\82Ì
\8ew
\92è
\83t
\83@
\83C
\83\8b\88ê
\97\97\82ð
\8eæ
\93¾
\82·
\82é
835 // ListFiles('c:\', '*.txt', list, True);
836 procedure TGikoSys.GetFileList(Path: string; Mask: string; var List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
839 SearchRec : TSearchRec;
842 Path := IncludeTrailingPathDelimiter(Path);
843 rc := FindFirst(Path + '*.*', faAnyfile, SearchRec);
845 while rc = 0 do begin
846 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
847 s := Path + SearchRec.Name;
848 //if (SearchRec.Attr and faDirectory > 0) then
849 // s := IncludeTrailingPathDelimiter(s)
851 if (SearchRec.Attr and faDirectory = 0) and (MatchesMask(s, Mask)) then
855 List.Add(SearchRec.Name);
856 if SubDir and (SearchRec.Attr and faDirectory > 0) then
857 GetFileList(s, Mask, List, True, IsPathAdd);
859 rc := FindNext(SearchRec);
862 SysUtils.FindClose(SearchRec);
867 //
\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é
868 procedure TGikoSys.GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
871 SearchRec : TSearchRec;
874 Path := IncludeTrailingPathDelimiter(Path);
875 rc := FindFirst(Path + '*.*', faDirectory, SearchRec);
877 while rc = 0 do begin
878 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
879 s := Path + SearchRec.Name;
880 //if (SearchRec.Attr and faDirectory > 0) then
881 // s := IncludeTrailingPathDelimiter(s)
883 if (SearchRec.Attr and faDirectory > 0) and (MatchesMask(s, Mask)) then
884 List.Add( IncludeTrailingPathDelimiter( s ) );
885 if SubDir and (SearchRec.Attr and faDirectory > 0) then
886 GetDirectoryList(s, Mask, List, True);
888 rc := FindNext(SearchRec);
891 SysUtils.FindClose(SearchRec);
895 //
\83X
\83L
\83\93\82ð
\93Ç
\82Ý
\8d\9e\82Ý
\81A
\92l
\82ð
\92u
\8a·
\82·
\82é
896 function TGikoSys.LoadFromSkin(
898 ThreadItem: TThreadItem;
905 Skin := TStringList.Create;
907 if FileExists( fileName ) then begin
908 Skin.LoadFromFile( fileName );
910 //
\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
912 if ThreadItem.ParentBoard <> nil then
913 if ThreadItem.ParentBoard.ParentCategory <> nil then
914 CustomStringReplace( Skin, '<BBSNAME/>', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title);
915 CustomStringReplace( Skin, '<THREADURL/>', ThreadItem.URL);
917 CustomStringReplace( Skin, '<BOARDNAME/>', ThreadItem.ParentBoard.Title);
918 CustomStringReplace( Skin, '<BOARDURL/>', ThreadItem.ParentBoard.URL);
919 CustomStringReplace( Skin, '<THREADNAME/>', ThreadItem.Title);
920 CustomStringReplace( Skin, '<SKINPATH/>', Setting.CSSFileName);
921 CustomStringReplace( Skin, '<GETRESCOUNT/>', IntToStr( ThreadItem.NewReceive - 1 ));
922 CustomStringReplace( Skin, '<NEWRESCOUNT/>', IntToStr( ThreadItem.NewResCount ));
923 CustomStringReplace( Skin, '<ALLRESCOUNT/>', IntToStr( ThreadItem.AllResCount ));
925 CustomStringReplace( Skin, '<NEWDATE/>',FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate));
926 CustomStringReplace( Skin, '<SIZEKB/>', IntToStr( Floor( SizeByte / 1024 ) ));
927 CustomStringReplace( Skin, '<SIZE/>', IntToStr( SizeByte ));
929 //-----
\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µ
930 //
\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
932 if ThreadItem.ParentBoard <> nil then
933 if ThreadItem.ParentBoard.ParentCategory <> nil then
934 CustomStringReplace( Skin, '&BBSNAME', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title);
935 CustomStringReplace( Skin, '&THREADURL', ThreadItem.URL);
937 CustomStringReplace( Skin, '&BOARDNAME', ThreadItem.ParentBoard.Title);
938 CustomStringReplace( Skin, '&BOARDURL', ThreadItem.ParentBoard.URL);
939 CustomStringReplace( Skin, '&THREADNAME', ThreadItem.Title);
940 CustomStringReplace( Skin, '&SKINPATH', Setting.CSSFileName);
941 CustomStringReplace( Skin, '&GETRESCOUNT', IntToStr( ThreadItem.NewReceive - 1 ));
942 CustomStringReplace( Skin, '&NEWRESCOUNT', IntToStr( ThreadItem.NewResCount ));
943 CustomStringReplace( Skin, '&ALLRESCOUNT', IntToStr( ThreadItem.AllResCount ));
945 CustomStringReplace( Skin, '&NEWDATE', FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate));
946 CustomStringReplace( Skin, '&SIZEKB', IntToStr( Floor( SizeByte / 1024 ) ));
947 CustomStringReplace( Skin, '&SIZE', IntToStr( SizeByte ));
948 //-----
\82±
\82±
\82Ü
\82Å
956 //
\83\8c\83X
\82Ì
\92l
\82ð
\92u
\8a·
\82·
\82é
957 function TGikoSys.SkinedRes(
965 Skin := CustomStringReplace( Skin, '<NUMBER/>',
966 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>');
967 Skin := CustomStringReplace( Skin, '<PLAINNUMBER/>', No);
968 Skin := CustomStringReplace( Skin, '<NAME/>', '<b>' + Res.FName + '</b>');
969 Skin := CustomStringReplace( Skin, '<MAILNAME/>',
970 '<a href="mailto:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>');
971 Skin := CustomStringReplace( Skin, '<MAIL/>', Res.FMailTo);
972 Skin := CustomStringReplace( Skin, '<DATE/>', Res.FDateTime);
973 Skin := CustomStringReplace( Skin, '<MESSAGE/>', Res.FBody);
975 //-----
\82©
\82¿
\82ã
\81`
\82µ
\82á
\8cÝ
\8a·
\97p
\81B
\83R
\83\81\83\93\83g
\83A
\83E
\83g
\82µ
\82Ä
\82à
\82æ
\82µ
976 Skin := CustomStringReplace( Skin, '&NUMBER',
977 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>');
978 Skin := CustomStringReplace( Skin, '&PLAINNUMBER', No);
979 Skin := CustomStringReplace( Skin, '&NAME', '<b>' + Res.FName + '</b>');
980 Skin := CustomStringReplace( Skin, '&MAILNAME',
981 '<a href="mailto:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>');
982 Skin := CustomStringReplace( Skin, '&MAIL', Res.FMailTo);
983 Skin := CustomStringReplace( Skin, '&DATE', Res.FDateTime);
984 Skin := CustomStringReplace( Skin, '&MESSAGE', Res.FBody);
985 //-----
\82±
\82±
\82Ü
\82Å
993 procedure TGikoSys.CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
997 //bufList : TStringList;
998 ReadList: TStringList;
999 SaveList: TStringList;
1000 CSSFileName: string;
1003 NewReceiveNo: Integer;
1005 boardPlugIn : TBoardPlugIn;
1007 UserOptionalStyle: string;
1011 // SizeByte: Integer;
1013 function LoadSkin( fileName: string ): string;
1015 Result := LoadFromSkin( fileName, ThreadItem, ThreadItem.Size );
1017 function ReplaceRes( skin: string ): string;
1019 Result := SkinedRes( skin, Res, No );
1022 if ThreadItem <> nil then begin
1023 if ThreadItem.IsBoardPlugInAvailable then begin
1024 //=====
\83v
\83\89\83O
\83C
\83\93\82É
\82æ
\82é
\95\
\8e¦
1025 boardPlugIn := ThreadItem.BoardPlugIn;
1026 NewReceiveNo := ThreadItem.NewReceive;
1028 //
\83t
\83H
\83\93\83g
\82â
\83T
\83C
\83Y
\82Ì
\90Ý
\92è
1029 if Length( GikoSys.Setting.BrowserFontName ) > 0 then
1030 UserOptionalStyle := UserOptionalStyle +
1031 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
1032 if GikoSys.Setting.BrowserFontSize <> 0 then
1033 UserOptionalStyle := UserOptionalStyle +
1034 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
1035 if GikoSys.Setting.BrowserFontColor <> -1 then
1036 UserOptionalStyle := UserOptionalStyle +
1037 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
1038 if GikoSys.Setting.BrowserBackColor <> -1 then
1039 UserOptionalStyle := UserOptionalStyle +
1040 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
1041 case GikoSys.Setting.BrowserFontBold of
1042 -1: UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
1043 1: UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;';
1045 case GikoSys.Setting.BrowserFontItalic of
1046 -1: UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
1047 1: UserOptionalStyle := UserOptionalStyle + 'font-style:italic;';
1050 SaveList := TStringList.Create;
1053 //
\95¶
\8e\9a\83R
\81[
\83h
\82Í
\83v
\83\89\83O
\83C
\83\93\82É
\94C
\82¹
\82é
1054 // doc.charset := 'Shift_JIS';
1055 threadItem.SizeByte := 0;
1058 SaveList.Add( boardPlugIn.GetHeader( DWORD( threadItem ),
1059 '<style type="text/css">body {' + UserOptionalStyle + '}</style>' ) );
1061 for i := 0 to threadItem.Count - 1 do begin
1062 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (threadItem.Count-i) > 101 ) then begin
1066 //
\90V
\92\85\83}
\81[
\83N
1067 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1069 if GikoSys.Setting.UseSkin then begin
1070 if FileExists( GetSkinNewmarkFileName ) then
1071 SaveList.Add( LoadSkin( GetSkinNewmarkFileName ) )
1073 SaveList.Add( '<a name="new"></a>' );
1074 end else if GikoSys.Setting.UseCSS then begin
1075 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>');
1077 SaveList.Add('</dl>');
1078 SaveList.Add('<a name="new"></a>');
1079 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>');
1080 SaveList.Add('<dl>');
1083 SaveList.Add( '<a name="new"></a>' );
1088 SaveList.Add( boardPlugIn.GetRes( DWORD( threadItem ), i + 1 ) );
1090 if ThreadItem.Kokomade = (i + 1) then begin
1091 //
\82±
\82±
\82Ü
\82Å
\93Ç
\82ñ
\82¾
1093 if GikoSys.Setting.UseSkin then begin
1094 if FileExists( GetSkinBookmarkFileName ) then
1095 SaveList.Add( LoadSkin( GetSkinBookmarkFileName ) )
1097 SaveList.Add( '<a name="koko"></a>' );
1098 end else if GikoSys.Setting.UseCSS then begin
1099 SaveList.Add('<a name="koko"></a><div class="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</div>');
1101 SaveList.Add('</dl>');
1102 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>');
1103 SaveList.Add('<dl>');
1106 SaveList.Add( '<a name="koko"></a>' );
1110 threadItem.SizeByte := threadItem.SizeByte + Length( SaveList.Text );
1111 doc.Write(SaveList.Text);
1115 threadItem.SizeByte := threadItem.SizeByte + Length( SaveList.Text );
1117 //
\83X
\83L
\83\93(
\83t
\83b
\83^)
1118 SaveList.Add( boardPlugIn.GetFooter( DWORD( threadItem ), '<a name="bottom"></a>' ) );
1120 doc.Write(SaveList.Text);
1129 ShortDayNames[1] := '
\93ú'; ShortDayNames[2] := '
\8c\8e';
1130 ShortDayNames[3] := '
\89Î'; ShortDayNames[4] := '
\90\85';
1131 ShortDayNames[5] := '
\96Ø'; ShortDayNames[6] := '
\8bà';
1132 ShortDayNames[7] := '
\93y';
1134 BBSID := ThreadItem.ParentBoard.BBSID;
1135 NewReceiveNo := ThreadItem.NewReceive;
1136 ReadList := TStringList.Create;
1138 if ThreadItem.IsLogFile then begin
1139 FileName := ThreadItem.GetThreadFileName;
1140 ReadList.LoadFromFile(FileName);
1141 FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
1142 FAbon.Execute(ReadList); //
\82 \82Ú
\81`
\82ñ
\82µ
\82Ä
1143 FSelectResFilter.Execute(ReadList); //
\83\8c\83X
\82Ì
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\82·
\82é
1144 Res := DivideStrLine(ReadList[0]);
1145 Res.FTitle := CustomStringReplace(Res.FTitle, '
\81\97\81M', ',');
1146 sTitle := Res.FTitle;
1148 sTitle := CustomStringReplace(ThreadItem.Title, '
\81\97\81M', ',');
1150 SaveList := TStringList.Create;
1153 doc.charset := 'Shift_JIS';
1155 //
\83t
\83H
\83\93\83g
\82â
\83T
\83C
\83Y
\82Ì
\90Ý
\92è
1156 if Length( GikoSys.Setting.BrowserFontName ) > 0 then
1157 UserOptionalStyle := UserOptionalStyle +
1158 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
1159 if GikoSys.Setting.BrowserFontSize <> 0 then
1160 UserOptionalStyle := UserOptionalStyle +
1161 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
1162 if GikoSys.Setting.BrowserFontColor <> -1 then
1163 UserOptionalStyle := UserOptionalStyle +
1164 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
1165 if GikoSys.Setting.BrowserBackColor <> -1 then
1166 UserOptionalStyle := UserOptionalStyle +
1167 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
1168 case GikoSys.Setting.BrowserFontBold of
1169 -1: UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
1170 1: UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;';
1172 case GikoSys.Setting.BrowserFontItalic of
1173 -1: UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
1174 1: UserOptionalStyle := UserOptionalStyle + 'font-style:italic;';
1177 CSSFileName := GetStyleSheetDir + Setting.CSSFileName;
1178 if GikoSys.Setting.UseSkin then begin
1179 //
\83X
\83L
\83\93\8eg
\97p
1180 //
\83X
\83L
\83\93\82Ì
\90Ý
\92è
1182 SkinHeader := LoadSkin( GetSkinHeaderFileName );
1183 if Length( UserOptionalStyle ) > 0 then
1184 SkinHeader := CustomStringReplace( SkinHeader, '</head>',
1185 '<style type="text/css">body {' + UserOptionalStyle + '}</style></head>');
1186 SaveList.Add( SkinHeader );
1190 SkinNewRes := LoadSkin( GetSkinNewResFileName );
1194 SkinRes := LoadSkin( GetSkinResFileName );
1198 SaveList.Add('<a name="top"></a>');
1200 for i := 0 to ReadList.Count - 1 do begin
1201 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1204 if (Trim(ReadList[i]) <> '') then begin
1205 No := IntToStr(i + 1);
1207 Res := DivideStrLine(ReadList[i]);
1208 if Res.FType = glt2chOld then begin
1209 Res.FMailTo := CustomStringReplace(Res.FMailTo, '
\81\97\81M', ',');
1210 Res.FName := CustomStringReplace(Res.FName, '
\81\97\81M', ',');
1211 Res.FBody := CustomStringReplace(Res.FBody, '
\81\97\81M', ',');
1214 Res.FBody := AddAnchorTag(Res.FBody);
1215 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1217 if Res.FName = '' then
1218 Res.FName := ' ';
1220 //
\90V
\92\85\83}
\81[
\83N
1221 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1223 if FileExists( GetSkinNewmarkFileName ) then
1224 SaveList.Add( LoadSkin( GetSkinNewmarkFileName ) )
1226 SaveList.Add( '<a name="new"></a>' );
1228 SaveList.Add( '<a name="new"></a>' );
1232 if NewReceiveNo <= (i + 1) then
1233 //
\90V
\92\85\83\8c\83X
1234 SaveList.Add( ReplaceRes( SkinNewRes ) )
1236 //
\92Ê
\8fí
\82Ì
\83\8c\83X
1237 SaveList.Add( ReplaceRes( SkinRes ) );
1240 if ThreadItem.Kokomade = (i + 1) then begin
1241 //
\82±
\82±
\82Ü
\82Å
\93Ç
\82ñ
\82¾
1243 if FileExists( GetSkinBookmarkFileName ) then
1244 SaveList.Add( LoadSkin( GetSkinBookmarkFileName ) )
1246 SaveList.Add( '<a name="koko"></a>' );
1248 SaveList.Add( '<a name="koko"></a>' );
1252 // SizeByte := SizeByte + Length( SaveList.Text );
1253 doc.Write(SaveList.Text);
1256 SaveList.Add('<a name="bottom"></a>');
1257 // SizeByte := SizeByte + Length( SaveList.Text );
1258 //
\83X
\83L
\83\93(
\83t
\83b
\83^)
1260 SaveList.Add( LoadSkin( GetSkinFooterFileName ) );
1263 doc.Write(SaveList.Text);
1265 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
1267 //CSSFileName := GetAppDir + CSS_FILE_NAME;
1268 // SaveList.Add('<html lang="ja"><head>');
1269 SaveList.Add('<html><head>');
1270 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1271 SaveList.Add('<title>' + sTitle + '</title>');
1272 SaveList.Add('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
1273 if Length( UserOptionalStyle ) > 0 then
1274 SaveList.Add('<style type="text/css">body {' + UserOptionalStyle + '}</style>');
1275 SaveList.Add('</head>');
1276 SaveList.Add('<body>');
1277 SaveList.Add('<a name="top"></a>');
1278 SaveList.Add('<div class="title">' + sTitle + '</div>');
1279 doc.Write(SaveList.Text);
1281 //Application.ProcessMessages;
1282 for i := 0 to ReadList.Count - 1 do begin
1283 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1286 if (Trim(ReadList[i]) <> '') then begin
1287 No := IntToStr(i + 1);
1288 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1289 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>');
1291 Res := DivideStrLine(ReadList[i]);
1292 Res.FBody := AddAnchorTag(Res.FBody);
1293 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1295 if Res.FName = '' then
1296 Res.FName := ' ';
1297 if Res.FMailTo = '' then
1298 SaveList.Add('<a name="' + No + '"></a>'
1299 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span> '
1300 + '<span class="name_label">
\96¼
\91O
\81F</span> '
1301 + '<span class="name"><b>' + Res.FName + '</b></span> '
1302 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span> '
1303 + '<span class="date">' + Res.FDateTime+ '</span></div>'
1304 + '<div class="mes">' + Res.FBody + ' </div>')
1305 else if GikoSys.Setting.ShowMail then
1306 SaveList.Add('<a name="' + No + '"></a>'
1307 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1308 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1309 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1310 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
1311 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1312 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1313 + '<div class="mes">' + Res.FBody + ' </div>')
1315 SaveList.Add('<a name="' + No + '"></a>'
1316 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1317 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1318 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1319 + '<b>' + Res.FName + '</b></a>'
1320 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1321 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1322 + '<div class="mes">' + Res.FBody + ' </div>');
1323 if ThreadItem.Kokomade = (i + 1) then begin
1324 SaveList.Add('<a name="koko"></a><div class="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</div>');
1328 doc.Write(SaveList.Text);
1332 SaveList.Add('<a name="bottom"></a>');
1333 SaveList.Add('</body></html>');
1334 SaveList.Add('<a name="last"></a>');
1335 SaveList.Add('</body></html>');
1337 doc.Write(SaveList.Text);
1340 // SaveList.Add('<html lang="ja"><head>');
1341 SaveList.Add('<html><head>');
1342 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1343 SaveList.Add('<title>' + sTitle + '</title></head>');
1344 SaveList.Add('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1345 SaveList.Add('<a name="top"></a>');
1346 SaveList.Add('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1347 SaveList.Add('<dl>');
1348 doc.Write(SaveList.Text);
1350 //Application.ProcessMessages;
1351 for i := 0 to ReadList.Count - 1 do begin
1352 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1355 if (Trim(ReadList[i]) <> '') then begin
1356 No := IntToStr(i + 1);
1358 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1359 SaveList.Add('</dl>');
1360 SaveList.Add('<a name="new"></a>');
1361 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>');
1362 SaveList.Add('<dl>');
1364 Res := DivideStrLine(ReadList[i]);
1365 if Res.FType = glt2chOld then begin
1366 Res.FMailTo := CustomStringReplace(Res.FMailTo, '
\81\97\81M', ',');
1367 Res.FName := CustomStringReplace(Res.FName, '
\81\97\81M', ',');
1368 Res.FBody := CustomStringReplace(Res.FBody, '
\81\97\81M', ',');
1370 Res.FBody := AddAnchorTag(Res.FBody);
1371 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1372 if Res.FMailTo = '' then
1373 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>')
1374 else if GikoSys.Setting.ShowMail then
1375 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>')
1377 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>');
1378 if ThreadItem.Kokomade = (i + 1) then begin
1379 SaveList.Add('</dl>');
1380 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>');
1381 SaveList.Add('<dl>');
1384 //if SaveList.Count > 50 then begin
1385 doc.Write(SaveList.Text);
1387 //Application.ProcessMessages;
1390 SaveList.Add('</dl>');
1391 SaveList.Add('<a name="bottom"></a>');
1392 SaveList.Add('</body></html>');
1393 doc.Write(SaveList.Text);
1403 (*************************************************************************
1404 *http://
\82Ì
\95¶
\8e\9a\97ñ
\82ðanchor
\83^
\83O
\95t
\82«
\82É
\82·
\82é
\81B
1405 *************************************************************************)
1406 function TGikoSys.AddAnchorTag(s: string): string;
1408 URL_CHAR: string = '0123456789'
1409 + 'abcdefghijklmnopqrstuvwxyz'
1410 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1411 + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
1412 ANCHOR_REF = 'href=';
1413 RES_REF = '>>';
1415 wkIdx: array[0..9] of Integer;
1420 anchorLen : Integer;
1423 // + 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ß
1424 anchorLen := Length( ANCHOR_REF ) + 3;
1427 wkIdx[0] := AnsiPos('http://', s);
1428 wkIdx[1] := AnsiPos('ttp://', s);
1429 wkIdx[2] := AnsiPos('tp://', s);
1430 wkIdx[3] := AnsiPos('ms-help://', s);
1431 wkIdx[4] := AnsiPos('p://', s);
1432 wkIdx[5] := AnsiPos('https://', s);
1433 wkIdx[6] := AnsiPos('www.', s);
1434 wkIdx[7] := AnsiPos('ftp://', s);
1435 wkIdx[8] := AnsiPos('news://', s);
1436 wkIdx[9] := AnsiPos('rtsp://', s);
1440 if wkIdx[i] <> 0 then idx := Min(wkIdx[i], idx);
1442 if idx = MaxInt then begin
1443 //
\83\8a\83\93\83N
\82ª
\96³
\82¢
\82æ
\81B
1444 Result := Result + s;
1449 (Pos( ANCHOR_REF, Copy(s, idx - anchorLen, anchorLen ) ) > 0) then begin
1450 //
\8aù
\82É
\83\8a\83\93\83N
\83^
\83O
\82ª
\82Â
\82¢
\82Ä
\82¢
\82é
\82Á
\82Û
\82¢
\82Æ
\82«
\82Í
\83\80\83V
1451 href := Copy( s, idx, Length( s ) );
1452 Result := Result + Copy( s, 1, idx + Pos( '</a>', href ) + Length( '</a>' ) - 2 );
1454 s := Copy( s, Pos( '</a>', s ) + Length( '</a>' ), Length( s ) );
1459 Result := Result + Copy(s, 0, idx - 1);
1461 s := Copy(s, idx, length(s));
1463 for i := 0 to Length(s) do begin
1464 idx := AnsiPos(s[i + 1], URL_CHAR);
1465 if (idx = 0) or (i = (Length(s))) then begin
1466 //URL
\82¶
\82á
\82È
\82¢
\95¶
\8e\9a\94
\8c©
\81I
\82Æ
\82©
\81A
\95¶
\8e\9a\82ª
\82È
\82
\82È
\82Á
\82½
\81B
1467 url := Copy(s, 0, i);
1469 if AnsiPos('ttp://', url) = 1 then
1471 else if AnsiPos('tp://', url) = 1 then
1473 else if AnsiPos('p://', url) = 1 then
1475 else if AnsiPos('www.', url) = 1 then
1476 href := 'http://' + url
1479 Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
1480 s := Copy(s, i + 1, Length(s));
1487 (*************************************************************************
1488 *
\83T
\83u
\83W
\83F
\83N
\83g
\88ê
\8ds
\82ð
\95ª
\8a\84
1489 *************************************************************************)
1490 function TGikoSys.DivideSubject(Line: string): TSubjectRec;
1500 if AnsiPos('<>', Line) = 0 then
1505 Result.FFileName := GetTokenIndex(Line, Delim, 0);
1506 Result.FTitle := GetTokenIndex(Line, Delim, 1);
1508 ws := Trim(Result.FTitle);
1510 if Copy(ws, Length(ws), 1) = ')' then begin
1513 end else if Copy(ws, Length(ws), 1) = '
\81j' then begin
1516 end else if Copy(ws, Length(ws), 1) = '<' then begin
1521 for i := Length(ws) - 1 downto 1 do begin
1522 if ws[i] = LeftK then begin
1523 ws := Copy(ws, i + 1, Length(ws) - i - 1);
1524 if IsNumeric(ws) then
1525 Result.FCount := StrToInt(ws);
1526 Result.FTitle := Trim(CustomStringReplace(Result.FTitle, LeftK + ws + RightK, ''));
1532 (*************************************************************************
1533 * dat
\83t
\83@
\83C
\83\8b\82Ì
\88ê
\83\89\83C
\83\93\82ð
\95ª
\89ð
1534 *************************************************************************)
1535 function TGikoSys.DivideStrLine(Line: string): TResRec;
1540 if AnsiPos('<>', Line) = 0 then begin
1542 Result.FType := glt2chOld;
1545 Result.FType := glt2chNew;
1547 Result.FName := Trim(GetTokenIndex(Line, Delim, 0));
1548 Result.FMailTo := Trim(GetTokenIndex(Line, Delim, 1));
1549 Result.FDateTime := Trim(GetTokenIndex(Line, Delim, 2));
1550 bufBody := Trim(GetTokenIndex(Line, Delim, 3));
1551 if bufbody = '' then begin
1552 Insert(' ',bufbody, 1);
1554 Result.FBody := bufBody;
1555 Result.FTitle := Trim(GetTokenIndex(Line, Delim, 4));
1559 (*************************************************************************
1560 * URL
\82©
\82çBBSID
\82ð
\8eæ
\93¾
1561 *************************************************************************)
1562 function TGikoSys.UrlToID(url: string): string;
1569 if url = '' then Exit;
1571 url := Copy(url, 0, Length(url) - 1);
1572 for i := Length(url) downto 0 do begin
1573 if url[i] = '/' then begin
1574 Result := Copy(url, i + 1, Length(url));
1580 (*************************************************************************
1581 *URL
\82©
\82çBBSID
\88È
\8aO
\82Ì
\95\94\95ª(http://teri.2ch.net/)
\82ð
\8eæ
\93¾
1582 *************************************************************************)
1583 function TGikoSys.UrlToServer(url: string): string;
1590 wsURL := Trim(wsURL);
1592 if wsURL = '' then exit;
1594 if Copy(wsURL, Length(wsURL), 1) = '/' then
1595 wsURL := Copy(wsURL, 0, Length(wsURL) - 1);
1597 for i := Length(wsURL) downto 0 do begin
1598 if wsURL[i] = '/' then begin
1599 Result := Copy(wsURL, 0, i);
1605 (*************************************************************************
1606 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ª
\91¶
\8dÝ
\82·
\82é
\82©
\83`
\83F
\83b
\83N
1607 *************************************************************************)
1608 function TGikoSys.DirectoryExistsEx(const Name: string): Boolean;
1612 Code := GetFileAttributes(PChar(Name));
1613 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
1616 (*************************************************************************
1617 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\8dì
\90¬
\81i
\95¡
\90\94\8aK
\91w
\91Î
\89\9e\81j
1618 *************************************************************************)
1619 function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean;
1622 if Length(Dir) = 0 then
1623 raise Exception.Create('
\83t
\83H
\83\8b\83_
\82ª
\8dì
\90¬
\8fo
\97\88\82Ü
\82¹
\82ñ');
1624 Dir := ExcludeTrailingPathDelimiter(Dir);
1625 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
1626 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
1627 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
1630 (*************************************************************************
1631 *
\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
1632 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1633 *************************************************************************)
1634 function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1638 Result := StrTokNext(sep, Rec);
1641 (*************************************************************************
1642 *
\95¶
\8e\9a\97ñ
\82©
\82ç
\83g
\81[
\83N
\83\93\82Ì
\90Ø
\82è
\8fo
\82µ
1643 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1644 *************************************************************************)
1645 function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1652 if Len >= Pos then begin
1653 while (Pos <= Len) and (Str[Pos] in sep) do begin
1657 while (Pos<= Len) and not (Str[Pos] in sep) do begin
1658 if IsDBCSLeadByte(Byte(Str[Pos])) then begin
1663 Result := Copy(Str, I, Pos - I);
1664 while (Pos <= Len) and (Str[Pos] in sep) do begin//
\82±
\82ê
\82Í
\82¨
\8dD
\82Ý
1671 (*************************************************************************
1672 *
\83t
\83@
\83C
\83\8b\83T
\83C
\83Y
\8eæ
\93¾
1673 *************************************************************************)
1674 function TGikoSys.GetFileSize(FileName : string): longint;
1679 if not FileExists(FileName) then begin
1683 Assign(F, FileName);
1685 Result := FileSize(F);
1692 (*************************************************************************
1693 *
\83t
\83@
\83C
\83\8b\8ds
\90\94\8eæ
\93¾
1694 *************************************************************************)
1695 function TGikoSys.GetFileLineCount(FileName : string): longint;
1699 sl := TStringList.Create;
1702 sl.LoadFromFile(FileName);
1713 (*************************************************************************
1714 *
\83X
\83\8c\83b
\83h
\83t
\83@
\83C
\83\8b\82©
\82ç
\8ew
\92è
\8ds
\82ð
\8eæ
\93¾
1715 *************************************************************************)
1716 function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string;
1718 fileTmp : TStringList;
1721 if FileExists(FileName) then begin
1722 fileTmp := TStringList.Create;
1725 fileTmp.LoadFromFile( FileName );
1726 if ( Line >= 1 ) and ( Line < fileTmp.Count + 1 ) then begin
1727 Result := fileTmp.Strings[ Line-1 ];
1730 //on EFOpenError do Result := '';
1738 (*************************************************************************
1739 *
\83V
\83X
\83e
\83\80\83\81\83j
\83\85\81[
\83t
\83H
\83\93\83g
\82Ì
\91®
\90«
\82ð
\8eæ
\93¾
1740 *************************************************************************)
1741 procedure TGikoSys.MenuFont(Font: TFont);
1744 nm: NONCLIENTMETRICS;
1746 nm.cbSize := sizeof(NONCLIENTMETRICS);
1748 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0);
1749 lf := nm.lfMenuFont;
1751 Font.Name := lf.lfFaceName;
1752 Font.Height := lf.lfHeight;
1754 if lf.lfWeight >= 700 then
1755 Font.Style := Font.Style + [fsBold];
1756 if lf.lfItalic = 1 then
1757 Font.Style := Font.Style + [fsItalic];
1760 (*************************************************************************
1762 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1763 *************************************************************************)
1764 function TGikoSys.RemoveToken(var s: string; delimiter: string): string;
1768 p := AnsiPos(delimiter, s);
1772 Result := Copy(s, 1, p - 1);
1773 s := Copy(s, Length(Result) + Length(delimiter) + 1, Length(s));
1776 (*************************************************************************
1778 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1779 *************************************************************************)
1780 function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string;
1785 for i := 0 to index do
1786 Result := RemoveToken(s, delimiter);
1789 (*************************************************************************
1791 *************************************************************************)
1792 function TGikoSys.DeleteLink(const s: string): string;
1802 s1 := GetTokenIndex(s, '<a href="', i);
1803 s2 := GetTokenIndex(s, '<a href="', i + 1);
1805 idx := Pos('">', s1);
1807 Delete(s1, 1, idx + 1);
1808 idx := Pos('">', s2);
1810 Delete(s2, 1, idx + 1);
1812 Result := Result + s1 + s2;
1821 //
\83C
\83\93\83f
\83b
\83N
\83X
\96¢
\8dX
\90V
\83o
\83b
\83t
\83@
\82ð
\83t
\83\89\83b
\83V
\83\85\81I
1822 {procedure TGikoSys.FlashExitWrite;
1826 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
1827 for i := 0 to FExitWrite.Count - 1 do
1828 WriteThreadDat(FExitWrite[i]);
1832 (*************************************************************************
1833 *
\83X
\83\8c\96¼
\82È
\82Ç
\82ð
\92Z
\82¢
\96¼
\91O
\82É
\95Ï
\8a·
\82·
\82é
1835 *************************************************************************)
1836 function TGikoSys.GetShortName(const LongName: string; ALength: integer): string;
1838 ERASECHAR : array [1..39] of string =
1839 ('
\81\99','
\81\9a','
\81¡','
\81 ','
\81\9f','
\81\9e','
\81Q','
\81\94','
\81£','
\81¥',
1840 '
\81¢','
\81¤','
\81\9c','
\81\9b','
\81\9d','
\81y','
\81z','
\81ô','
\81s','
\81t',
1841 '
\81g','
\81h','
\81k','
\81l','
\81e','
\81f','
\81\83','
\81\84','
\81á','
\81â',
1842 '
\81o','
\81p','
\81q','
\81r','
\81w','
\81x','
\81¬','
\81c', '
\81@');
1844 Chr : array [0..255] of char;
1848 s := Trim(LongName);
1849 if (Length(s) <= ALength) then begin
1853 for i := Low(ERASECHAR) to High(ERASECHAR) do begin
1854 S := CustomStringReplace(S, ERASECHAR[i], '');
1856 if (Length(S) <= ALength) then begin
1859 Windows.LCMapString(
1860 GetUserDefaultLCID(),
1868 S := Copy(S,1,ALength);
1870 if (ByteType(S, Length(S)) = mbLeadByte ) then begin
1871 S := Copy(S, 1, Length(S) - 1);
1881 (*************************************************************************
1884 *************************************************************************)
1885 function TGikoSys.ConvRes(const Body, Bbs, Key,
1886 ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
1890 FIndexFrom : integer;
1897 ZN = '
\82O
\82P
\82Q
\82R
\82S
\82T
\82U
\82V
\82W
\82X
\81|';
1911 procedure Add(IndexFrom, IndexTo: integer; const No: string);
1916 FIndex.FIndexFrom := IndexFrom;
1917 FIndex.FIndexTo := IndexTo;
1921 function ChooseString(const Text, Separator: string; Index: integer): string;
1927 for i := 0 to Index - 1 do begin
1928 if (AnsiPos(Separator, S) = 0) then S := ''
1929 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
1931 p := AnsiPos(Separator, S);
1932 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
1941 List:= TList.Create;
1947 b := ByteType(s, i);
1949 mbSingleByte : begin
1950 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1951 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1959 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1960 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
1966 if (not sw) and (Copy(s,i,4) = GT) then begin
1967 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1975 if ((not sw) and (Copy(s,i,1) = ',')) or
1976 ((not sw) and (Copy(s,i,1) = '=')) then begin
1977 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
1978 ((Chk) and (oc = '')) or
1979 ((not Chk) and (al)) then
1989 if (AnsiPos(sx, SN) > 0) then begin
1992 if (No <> '') and (No <> '-') then begin
2005 if Copy(s,i,1) = '<' then oc := '';
2006 oc := oc + Copy(s,i,1);
2012 if (not sw) and (Copy(s,i,4) = '
\81\84\81\84') then begin
2018 if (not sw) and (Copy(s,i,2) = '
\81\84') then begin
2026 if (AnsiPos(sx, ZN) > 0) then begin
2027 No := No + ZenToHan(sx);
2029 if (No <> '') and (No <> '-') and (No <> '
\81|') then begin
2044 if (i > Length(Body)) then begin
2046 if (No <> '') then Add(sp, i, No);
2051 for i := List.Count - 1 downto 0 do begin
2052 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
2053 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
2054 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
2056 st := PIndex(List[i]).FNo;
2057 et := PIndex(List[i]).FNo;
2059 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
2060 Format('<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">',
2061 [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
2062 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
2063 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
2064 Dispose(PIndex(List[i]));
2070 function TGikoSys.ConvRes(
2071 const Body, Bbs, Key, ParamBBS, ParamKey,
2072 ParamStart, ParamTo, ParamNoFirst,
2073 ParamTrue, FullURL : string
2078 FIndexFrom : integer;
2085 ZN = '
\82O
\82P
\82Q
\82R
\82S
\82T
\82U
\82V
\82W
\82X
\81|';
2099 procedure Add(IndexFrom, IndexTo: integer; const No: string);
2104 FIndex.FIndexFrom := IndexFrom;
2105 FIndex.FIndexTo := IndexTo;
2109 function ChooseString(const Text, Separator: string; Index: integer): string;
2115 for i := 0 to Index - 1 do begin
2116 if (AnsiPos(Separator, S) = 0) then S := ''
2117 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
2119 p := AnsiPos(Separator, S);
2120 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
2129 List:= TList.Create;
2135 b := ByteType(s, i);
2137 mbSingleByte : begin
2138 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
2139 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
2147 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
2148 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
2154 if (not sw) and (Copy(s,i,4) = GT) then begin
2155 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
2163 if ((not sw) and (Copy(s,i,1) = ',')) or
2164 ((not sw) and (Copy(s,i,1) = '=')) then begin
2165 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
2166 ((Chk) and (oc = '')) or
2167 ((not Chk) and (al)) then
2177 if (AnsiPos(sx, SN) > 0) then begin
2180 if (No <> '') and (No <> '-') then begin
2193 if Copy(s,i,1) = '<' then oc := '';
2194 oc := oc + Copy(s,i,1);
2200 if (not sw) and (Copy(s,i,4) = '
\81\84\81\84') then begin
2206 if (not sw) and (Copy(s,i,2) = '
\81\84') then begin
2214 if (AnsiPos(sx, ZN) > 0) then begin
2215 No := No + ZenToHan(sx);
2217 if (No <> '') and (No <> '-') and (No <> '
\81|') then begin
2232 if (i > Length(Body)) then begin
2234 if (No <> '') then Add(sp, i, No);
2239 for i := List.Count - 1 downto 0 do begin
2240 //plName := Copy(PluginName, LastDelimiter('\',PluginName) + 1, Length(PluginName) - LastDelimiter('/',PluginName) -1 );
2241 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
2242 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
2243 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
2245 st := PIndex(List[i]).FNo;
2246 et := PIndex(List[i]).FNo;
2248 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
2249 Format('<a href="%s&%s=%s&%s=%s&%s=%s" target="_blank">',
2250 [FullURL, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
2251 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
2252 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
2253 Dispose(PIndex(List[i]));
2259 (*************************************************************************
2260 *
\91S
\8ap
\81¨
\94¼
\8ap
2262 *************************************************************************)
2263 function TGikoSys.ZenToHan(const s: string): string;
2265 Chr: array [0..255] of char;
2267 Windows.LCMapString(
2268 GetUserDefaultLCID(),
2270 LCMAP_HALFWIDTH or LCMAP_KATAKANA or LCMAP_LOWERCASE,
2279 (*************************************************************************
2280 *
\91S
\8ap
\94¼
\8ap
\82Ð
\82ç
\82ª
\82È
\82©
\82½
\82©
\82È
\82ð
\8bæ
\95Ê
\82µ
\82È
\82¢
\90¦
\82¢Pos
2281 *************************************************************************)
2282 function TGikoSys.VaguePos(const Substr, S: string): Integer;
2284 Result := AnsiPos(ZenToHan(Substr), ZenToHan(S));
2287 function TGikoSys.BoolToInt(b: Boolean): Integer;
2289 Result := IfThen(b, 1, 0);
2292 function TGikoSys.IntToBool(i: Integer): Boolean;
2297 //gzip
\82Å
\88³
\8fk
\82³
\82ê
\82½
\82Ì
\82ð
\96ß
\82·
2298 function TGikoSys.GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
2302 GZipStream: TGzipDecompressStream;
2303 TextStream: TStringStream;
2304 buf: array[0..BUF_SIZE - 1] of Byte;
2310 TextStream := TStringStream.Create('');
2312 //
\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¢)
2313 // if LowerCase(Trim(ContentEncoding)) = 'gzip' then begin
2314 if AnsiPos('gzip', LowerCase(Trim(ContentEncoding))) > 0 then begin
2315 ResStream.Position := 0;
2316 GZipStream := TGzipDecompressStream.Create(TextStream);
2319 FillChar(buf, BUF_SIZE, 0);
2320 cnt := ResStream.Read(buf, BUF_SIZE);
2322 GZipStream.Write(buf, BUF_SIZE);
2328 ResStream.Position := 0;
2330 FillChar(buf, BUF_SIZE, 0);
2331 cnt := ResStream.Read(buf, BUF_SIZE);
2333 TextStream.Write(buf, BUF_SIZE);
2337 //NULL
\95¶
\8e\9a\82ð"*"
\82É
\82·
\82é
2338 s := TextStream.DataString;
2340 while (i > 0) and (s[i] = #0) do
2345 while i <> 0 do begin
2355 procedure TGikoSys.LoadKeySetting(ActionList: TActionList);
2357 STD_SEC = 'KeySetting';
2363 SecList: TStringList;
2364 Component: TComponent;
2366 if not FileExists(GetConfigDir + KEY_SETTING_FILE_NAME) then
2368 SecList := TStringList.Create;
2369 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
2371 ini.ReadSection(STD_SEC, SecList);
2372 for i := 0 to SecList.Count - 1 do begin
2373 ActionName := SecList[i];
2374 ActionKey := ini.ReadInteger(STD_SEC, ActionName, -1);
2375 if ActionKey <> -1 then begin
2376 Component := ActionList.Owner.FindComponent(ActionName);
2377 if TObject(Component) is TAction then begin
2378 TAction(Component).ShortCut := ActionKey;
2388 procedure TGikoSys.SaveKeySetting(ActionList: TActionList);
2390 STD_SEC = 'KeySetting';
2395 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
2397 for i := 0 to ActionList.ActionCount - 1 do begin
2398 if ActionList.Actions[i].Tag = -1 then
2400 ini.WriteInteger(STD_SEC, ActionList.Actions[i].Name, TAction(ActionList.Actions[i]).ShortCut);
2409 procedure TGikoSys.CreateProcess(const AppPath: string; const Param: string);
2411 PI: TProcessInformation;
2415 Path := '"' + AppPath + '"';
2417 Path := Path + ' ' + Param;
2419 SI.Cb := SizeOf(Si);
2420 SI.lpReserved := nil;
2421 SI.lpDesktop := nil;
2424 SI.cbReserved2 := 0;
2425 SI.lpReserved2 := nil;
2427 Windows.CreateProcess(nil,
2439 procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
2443 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2444 gbtUserApp, gbtAuto:
2445 if (Setting.URLApp) and (FileExists(Setting.URLAppFile)) then
2446 GikoSys.CreateProcess(Setting.URLAppFile, URL)
2448 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2452 function TGikoSys.HTMLDecode(const AStr: String): String;
2454 Sp, Rp, Cp, Tp: PChar;
2459 SetLength(Result, Length(AStr));
2461 Rp := PChar(Result);
2464 while Sp^ <> #0 do begin
2470 'a': if AnsiStrPos(Sp, 'amp;') = Sp then
2476 'g': if (AnsiStrPos(Sp, 'lt;') = Sp) or (AnsiStrPos(Sp, 'gt;') = Sp) then
2480 while (Sp^ <> ';') and (Sp^ <> #0) do
2487 'q': if AnsiStrPos(Sp, 'quot;') = Sp then
2495 Num := IsNumeric(Copy(Tp, 1, 1));
2496 while (Sp^ <> ';') and (Sp^ <> #0) do begin
2497 if (Num) and (not IsNumeric(Copy(Sp, 1, 1))) then
2501 SetString(S, Tp, Sp - Tp);
2506 //raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2507 //[Cp^ + Sp^, Cp - PChar(AStr)])
2517 // on E:EConvertError do
2518 // raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2519 // [Cp^ + Sp^, Cp - PChar(AStr)])
2521 SetLength(Result, Rp - PChar(Result));
2524 function TGikoSys.GetHRefText(s: string): string;
2534 Index := AnsiPos('href', LowerCase(s));
2537 s := Trim(Copy(s, Index + 4, Length(s)));
2538 s := Trim(Copy(s, 2, Length(s)));
2540 //
\8en
\82ß
\82Ì
\95¶
\8e\9a\82ª'"'
\82È
\82ç
\8eæ
\82è
\8f\9c\82
2541 //if Copy(s, 1, 1) = '"' then begin
2542 if s[1] = '"' then begin
2543 s := Trim(Copy(s, 2, Length(s)));
2546 Index := AnsiPos('"', s);
2547 if Index <> 0 then begin
2548 //'"'
\82Ü
\82ÅURL
\82Æ
\82·
\82é
2549 s := Copy(s, 1, Index - 1);
2551 //'"'
\82ª
\96³
\82¯
\82ê
\82Î
\83X
\83y
\81[
\83X
\82©">"
\82Ì
\91\81\82¢
\95û
\82Ü
\82Å
\82ðURL
\82Æ
\82·
\82é
2552 Index := AnsiPos(' ', s);
2553 Index2 := AnsiPos('>', s);
2556 if Index > Index2 then
2559 s := Copy(s, 1, Index - 1)
2561 //
\82±
\82ê
\88È
\8fã
\82à
\82¤
\92m
\82ç
\82ñ
\82Ê
2567 //
\83z
\83X
\83g
\96¼
\82ª
\82Q
\82\83\82\88\82©
\82Ç
\82¤
\82©
\83`
\83F
\83b
\83N
\82·
\82é
2568 function TGikoSys.Is2chHost(Host: string): Boolean;
2570 HOST_NAME: array[0..1] of string = ('2ch.net', 'bbspink.com');
2576 if RightStr( Host, 1 ) = '/' then
2577 Host := Copy( Host, 1, Length( Host ) - 1 );
2578 OutputDebugString(pchar(HOST_NAME[0]));
2579 for i := 0 to Length(HOST_NAME) - 1 do begin
2580 // Len := Length(HOST_NAME[i]);
2581 if AnsiPos(HOST_NAME[i], Host) = (Length(Host) - Length(HOST_NAME[i]) + 1) then begin
2588 function TGikoSys.Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
2598 Index := AnsiPos(READ_PATH, path);
2599 if Index <> 0 then begin
2600 s := Copy(path, Length(READ_PATH) + 1, Length(path));
2601 BBSID := GetTokenIndex(s, '/', 0);
2602 BBSKey := GetTokenIndex(s, '/', 1);
2605 Result := (BBSID <> '') or (BBSKey <> '');
2608 Index := AnsiPos(KAKO_PATH, path);
2609 if Index <> 0 then begin
2610 s := Copy(path, 2, Length(path));
2611 BBSID := GetTokenIndex(s, '/', 0);
2612 if (BBSID = 'log') and (GetTokenIndex(s, '/', 2) = 'kako') then
2613 BBSID := GetTokenIndex(s, '/', 1);
2614 BBSKey := ChangeFileExt(Document, '');
2615 Result := (BBSID <> '') or (BBSKey <> '');
2618 Index := AnsiPos('read.cgi?', URL);
2619 if Index <> 0 then begin
2620 SList := TStringList.Create;
2623 // s := HTMLDecode(Document);
2624 ExtractHTTPFields(['?', '&'], [], PChar(URL), SList, False);
2625 BBSID := SList.Values['bbs'];
2626 BBSKey := SList.Values['key'];
2627 Result := (BBSID <> '') or (BBSKey <> '');
2637 procedure TGikoSys.GetPopupResNumber(URL : string; var stRes, endRes : integer);
2644 URL := Trim(LowerCase(URL));
2645 if (AnsiPos('&st=', URL ) <> 0) and ( AnsiPos( '&to=',URL) <> 0 ) then begin
2647 stRes := StrToInt( Copy( URL, AnsiPos('&st=', URL ) + 4, AnsiPos( '&to=',URL) - AnsiPos('&st=', URL ) - 4 ) );
2648 if AnsiPos( '&nofirst=',URL) <> 0 then begin
2649 buf := Copy( URL, AnsiPos('&to=', URL ) + 4, AnsiPos( '&nofirst=',URL) - AnsiPos('&to=', URL ) - 4);
2651 buf := Copy( URL, AnsiPos('&to=', URL ) + 4, Length( URL ) - AnsiPos('&to=', URL ) - 4 + 1 );
2654 while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
2655 buf := Copy( buf, 1, ps );
2659 endRes := StrToInt(buf);
2666 GikoSys.GetBrowsableThreadURL( URL );
2667 end else if( AnsiPos('&res=', URL ) <> 0 ) then begin
2669 buf := Copy( URL, AnsiPos('&res=', URL ) + 5, Length( URL ) - AnsiPos('&res=', URL ) - 5 + 1 );
2672 while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
2673 buf := Copy( buf, 1, ps );
2676 stRes := StrToInt(buf)
2683 end else if (AnsiPos('&start=', URL ) <> 0) and ( AnsiPos( '&end=',URL) <> 0 ) then begin
2685 stRes := StrToInt( Copy( URL, AnsiPos('&start=', URL ) + 7, AnsiPos( '&end=',URL) - AnsiPos('&start=', URL ) - 7 ) );
2686 if AnsiPos( '&nofirst=',URL) <> 0 then begin
2687 buf := Copy( URL, AnsiPos('&end=', URL ) + 5, AnsiPos( '&nofirst=',URL) - AnsiPos('&end=', URL ) - 5);
2689 buf := Copy( URL, AnsiPos('&end=', URL ) + 5, Length( URL ) - AnsiPos('&to=', URL ) - 5 + 1 );
2692 while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
2693 buf := Copy( buf, 1, ps );
2697 endRes := StrToInt(buf);
2704 end else if ( AnsiPos('.htm',URL) <> Length(URL) -4 ) and ( AnsiPos('.htm',URL) <> Length(URL) -3 ) then begin
2705 buf := Copy(URL, LastDelimiter('/',URL)+1,Length(URL)-LastDelimiter('/',URL)+1);
2706 if Length(buf) > 0 then begin
2709 while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
2711 convBuf := Copy( buf, 1, ps );
2712 if convBuf <> '' then begin
2713 stRes := StrToInt(convBuf);
2717 while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
2719 convBuf := Copy( buf, 1, ps );
2720 if convBuf <> '' then
2721 endRes := StrToInt(convBuf)
2743 function TGikoSys.Parse2chURL2(URL: string): TPathRec;
2748 // convBuf : String;
2759 URL := Trim(LowerCase(URL));
2764 Result.FFirst := False;
2765 Result.FStBegin := False;
2766 Result.FToEnd := False;
2767 Result.FDone := False;
2772 FAWKStr.RegExp := 'http://.+\.(2ch\.net|bbspink\.com)/';
2773 if FAWKStr.Match(FAWKStr.ProcessEscSeq(URL), RStart, RLength) <> 0 then begin
2774 s := Copy(URL, RStart + RLength - 1, Length(URL));
2776 //
\95W
\8f\80\8f\91\8e®
2777 //
\8dÅ
\8cã
\82Íl50, 10, 10-20, 10n, 10-20n, -10, 10-, 10n-
\82È
\82Ç
2778 //http://xxx.2ch.net/test/read.cgi/bbsid/1000000000/
2779 FAWKStr.RegExp := '/test/read.cgi/.+/[0-9]+/.*';
2780 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2781 s := Copy(s, 15, Length(s));
2783 SList := TStringList.Create;
2786 FAWKStr.RegExp := '/';
2787 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2788 Result.FBBS := SList[1];
2789 Result.FKey := SList[2];
2790 if SList.Count >= 3 then
2798 FAWKStr.LineSeparator := mcls_CRLF;
2799 FAWKStr.RegExp := '-';
2800 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) = 0 then begin
2801 Result.FFirst := True;
2803 FAWKStr.RegExp := 'l[0-9]+';
2804 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2805 Result.FFirst := True;
2807 for i := 0 to SList.Count - 1 do begin
2808 if Trim(SList[i]) = '' then begin
2810 Result.FStBegin := True;
2811 if i = (SList.Count - 1) then
2812 Result.FToEnd := True;
2813 end else if IsNumeric(SList[i]) then begin
2814 wkInt := StrToInt(SList[i]);
2815 wkMax := Max(wkMax, wkInt);
2819 wkMin := Min(wkMin, wkInt);
2820 end else if Trim(SList[i]) = 'n' then begin
2821 Result.FFirst := True;
2823 FAWKStr.RegExp := '^n[0-9]+$|^[0-9]+n$';
2824 if FAWKStr.Match(FAWKStr.ProcessEscSeq(SList[i]), RStart, RLength) > 0 then begin
2825 if Copy(SList[i], 1, 1) = 'n' then
2826 wkInt := StrToInt(Copy(SList[i], 2, Length(SList[i])))
2828 wkInt := StrToInt(Copy(SList[i], 1, Length(SList[i]) - 1));
2829 Result.FFirst := True;
2830 wkMax := Max(wkMax, wkInt);
2834 wkMin := Min(wkMin, wkInt);
2838 if Result.FStBegin and (not Result.FToEnd) then
2840 else if (not Result.FStBegin) and Result.FToEnd then
2842 else if (not Result.FStBegin) and (not Result.FToEnd) then begin
2843 Result.FSt := wkMin;
2844 Result.FTo := wkMax;
2846 //Result.FSt := wkMin;
2847 //Result.FTo := wkMax;
2853 Result.FDone := True;
2857 //
\90Vkako
\8f\91\8e®
2858 //http://server.2ch.net/ITA_NAME/kako/1000/10000/1000000000.html
2859 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+/[0-9]+\.html';
2860 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2861 SList := TStringList.Create;
2864 FAWKStr.RegExp := '/';
2865 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2866 Result.FBBS := SList[1];
2867 Result.FKey := ChangeFileExt(SList[5], '');
2868 Result.FFirst := True;
2874 Result.FDone := True;
2878 //
\8b\8ckako
\8f\91\8e®
2879 //http://server.2ch.net/ITA_NAME/kako/999/999999999.html
2880 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+\.html';
2881 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2882 SList := TStringList.Create;
2885 FAWKStr.RegExp := '/';
2886 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 5 then begin
2887 Result.FBBS := SList[1];
2888 Result.FKey := ChangeFileExt(SList[4], '');
2889 Result.FFirst := True;
2895 Result.FDone := True;
2899 //log
\8by
\82Ñlog2
\8f\91\8e®
2900 //http://server.2ch.net/log/ITA_NAME/kako/999/999999999.html
2901 //http://server.2ch.net/log2/ITA_NAME/kako/999/999999999.html
2902 FAWKStr.RegExp := '/log2?/.+/kako/[0-9]+/[0-9]+\.html';
2903 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2904 SList := TStringList.Create;
2907 FAWKStr.RegExp := '/';
2908 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2909 Result.FBBS := SList[2];
2910 Result.FKey := ChangeFileExt(SList[5], '');
2911 Result.FFirst := True;
2917 Result.FDone := True;
2922 //
\8b\8cURL
\8f\91\8e®
2923 //http://server.2ch.net/test/read.cgi?bbs=ITA_NAME&key=1000000000&st=1&to=5&nofirst=true
2924 FAWKStr.RegExp := '/test/read\.cgi\?';
2925 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2926 s := Copy(s, 16, Length(s));
2927 SList := TStringList.Create;
2930 FAWKStr.RegExp := '&';
2931 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2932 Result.FFirst := True;
2933 for i := 0 to SList.Count - 1 do begin
2934 if Pos('bbs=', SList[i]) = 1 then begin
2935 Result.FBBS := Copy(SList[i], 5, Length(SList[i]));
2936 end else if Pos('key=', SList[i]) = 1 then begin
2937 Result.FKey := Copy(SList[i], 5, Length(SList[i]));
2938 end else if Pos('st=', SList[i]) = 1 then begin
2939 wk := Copy(SList[i], 4, Length(SList[i]));
2940 if IsNumeric(wk) then
2941 Result.FSt := StrToInt(wk)
2942 else if wk = '' then
2943 Result.FStBegin := True;
2944 end else if Pos('to=', SList[i]) = 1 then begin
2945 wk := Copy(SList[i], 4, Length(SList[i]));
2946 if IsNumeric(wk) then
2947 Result.FTo := StrToInt(wk)
2948 else if wk = '' then
2949 Result.FToEnd := True;
2950 end else if Pos('nofirst=', SList[i]) = 1 then begin
2951 Result.FFirst := False;
2960 if (Result.FBBS <> '') and (Result.FKey <> '') then begin
2961 Result.FDone := True;
2968 procedure TGikoSys.ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
2978 URI := TIdURI.Create(URL);
2980 Protocol := URI.Protocol;
2983 Document := URI.Document;
2985 Bookmark := URI.Bookmark;
2991 function TGikoSys.GetVersionBuild: Integer;
2993 FixedFileInfo: PVSFixedFileInfo;
2994 VersionHandle, VersionSize: DWORD;
2995 pVersionInfo: Pointer;
3000 AppFile := Application.ExeName;
3001 VersionSize := GetFileVersionInfoSize(pChar(AppFile), VersionHandle);
3002 if VersionSize = 0 then
3004 GetMem(pVersionInfo, VersionSize);
3006 if GetFileVersionInfo(PChar(AppFile),VersionHandle,VersionSize, pVersionInfo) then
3007 if VerQueryValue(pVersionInfo, '\', Pointer(FixedFileInfo), ItemLen) then
3008 Result := LOWORD(FixedFileInfo^.dwFileVersionLS);
3010 FreeMem(pVersionInfo, VersionSize);
3014 function TGikoSys.GetBrowsableThreadURL(
3018 threadItem : TThreadItem;
3019 boardPlugIn : TBoardPlugIn;
3023 //=====
\83v
\83\89\83O
\83C
\83\93
3025 for i := Length( BoardPlugIns ) - 1 downto 0 do begin
3026 if Assigned( Pointer( BoardPlugIns[ i ].Module ) ) then begin
3027 if BoardPlugIns[ i ].AcceptURL( inURL ) = atThread then begin
3028 boardPlugIn := BoardPlugIns[ i ];
3029 threadItem := TThreadItem.Create( boardPlugIn, inURL );
3030 Result := threadItem.URL;
3038 // 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¢
3041 if Length( Result ) = 0 then
3042 Result := GikoSys.Get2chBrowsableThreadURL( inURL );
3046 function TGikoSys.GetThreadURL2BoardURL(
3050 threadItem : TThreadItem;
3051 boardPlugIn : TBoardPlugIn;
3055 //=====
\83v
\83\89\83O
\83C
\83\93
3057 for i := Length( BoardPlugIns ) - 1 downto 0 do begin
3058 if Assigned( Pointer( BoardPlugIns[ i ].Module ) ) then begin
3059 if BoardPlugIns[ i ].AcceptURL( inURL ) = atThread then begin
3060 boardPlugIn := BoardPlugIns[ i ];
3061 threadItem := TThreadItem.Create( boardPlugIn, inURL );
3062 Result := BoardPlugIns[ i ].GetBoardURL( Longword( threadItem ) );
3070 // 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¢
3073 if Length( Result ) = 0 then
3074 Result := GikoSys.Get2chThreadURL2BoardURL( inURL );
3078 function TGikoSys.Get2chThreadURL2BoardURL(
3082 Protocol, Host, Path, Document, Port, Bookmark : string;
3083 BBSID, BBSKey : string;
3086 ParseURI( inURL, Protocol, Host, Path, Document, Port, Bookmark );
3087 Parse2chURL( inURL, Path, Document, BBSID, BBSKey );
3089 Result := Copy( inURL, 1, Pos( '/test/read.cgi', inURL ) ) + BBSID + '/';
3093 function TGikoSys.Get2chBrowsableThreadURL(
3097 Protocol, Host, Path, Document, Port, Bookmark : string;
3098 BBSID, BBSKey : string;
3102 if Pos( KAKO_PATH, inURL ) > 0 then begin
3105 ParseURI( inURL, Protocol, Host, Path, Document, Port, Bookmark );
3106 Parse2chURL( inURL, Path, Document, BBSID, BBSKey );
3107 foundPos := Pos( '/test/read.cgi', inURL ) - 1;
3109 if Is2chHost( Host ) then begin
3110 Result := Copy( inURL, 1, foundPos ) +
3111 READ_PATH + BBSID + '/' + BBSKey + '/l50';
3113 Result := Copy( inURL, 1, foundPos ) +
3114 OLD_READ_PATH + 'bbs=' + BBSID + '&key=' + BBSKey + '&ls=50';
3120 function TGikoSys.Get2chBoard2ThreadURL(
3128 server := UrlToServer( inBoard.URL );
3129 if Is2chHost( server ) then
3130 Result := server + 'test/read.cgi/' + inBoard.BBSID + '/' + inKey + '/l50'
3132 Result := server + 'test/read.cgi?bbs=' + inBoard.BBSID + '&key=' + inKey + '&ls=50';
3136 (*************************************************************************
3137 *
\8b@
\94\
\96¼
\81@
\81@
\81F
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\93Ç
\82Ý
\8d\9e\82Ý
3138 *
\89Â
\8e\8b\81@
\81@
\81@
\81FPublic
3139 *
\97\9a\97ð
\82P
\81@
\81@
\81F
\90V
\8bK
\8dì
\90¬
3140 *************************************************************************)
3141 procedure TGikoSys.ReadBoardFile;
3145 CategoryList: TStringList;
3146 BoardList: TStringList;
3147 Category: TCategory;
3150 RoundItem: TRoundItem;
3152 // BBS
\94z
\97ñ(1
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\82É
\82Â
\82« 1
\8d\80\96Ú)
3153 bbsList : array of TStringList;
3154 boardFileList : TStringList;
3156 i, iBound : Integer;
3157 j, jBound : Integer;
3158 k, kBound : Integer;
3159 l, lBound : Integer;
3161 ini := TMemIniFile.Create('');
3165 for i := 0 to Length( BBSs ) - 1 do
3169 SetLength( BBSs, 0 );
3171 //
\94Â
\83\8a\83X
\83g
\82Ì
\97ñ
\8b\93
3172 if FileExists( GikoSys.GetBoardFileName ) then begin
3173 l := Length( bbsList );
3174 SetLength( bbsList, l + 1 );
3175 bbsList[ l ] := TStringList.Create;
3176 bbsList[ l ].LoadFromFile( GikoSys.GetBoardFileName );
3178 SetLength( BBSs, l + 1 );
3179 BBSs[ l ] := TBBS.Create( GikoSys.Setting.LogFolder );
3180 BBSs[ l ].Title := '
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é';
3183 if FileExists( GikoSys.GetCustomBoardFileName ) then begin
3184 l := Length( bbsList );
3185 SetLength( bbsList, l + 1 );
3186 bbsList[ l ] := TStringList.Create;
3187 bbsList[ l ].LoadFromFile( GikoSys.GetCustomBoardFileName );
3189 SetLength( BBSs, l + 1 );
3190 BBSs[ l ] := TBBS.Create( GikoSys.Setting.LogFolder );
3191 BBSs[ l ].Title := '
\82»
\82Ì
\91¼';
3194 // Board
\83t
\83H
\83\8b\83_
3195 if DirectoryExists( GikoSys.Setting.GetBoardDir ) then begin
3196 BoardFileList := TStringList.Create;
3198 GikoSys.GetFileList( GikoSys.Setting.GetBoardDir, '*', BoardFileList, True, True );
3199 l := Length( bbsList );
3200 for i := BoardFileList.Count - 1 downto 0 do begin
3201 SetLength( bbsList, l + 1 );
3202 bbsList[ l ] := TStringList.Create;
3203 bbsList[ l ].LoadFromFile( BoardFileList[ i ] );
3205 SetLength( BBSs, l + 1 );
3206 BBSs[ l ] := TBBS.Create( GikoSys.Setting.LogFolder );
3207 BBSs[ l ].Title := ChangeFileExt( ExtractFileName( BoardFileList[ i ] ), '' );
3216 lBound := Length( bbsList ) - 1;
3217 for l := 0 to lBound do begin
3218 ini.SetStrings( bbsList[ l ] );
3219 CategoryList := TStringList.Create;
3220 BoardList := TStringList.Create;
3222 ini.ReadSections( CategoryList );
3224 iBound := CategoryList.Count - 1;
3225 for i := 0 to iBound do begin
3226 ini.ReadSection( CategoryList[i], BoardList );
3227 Category := TCategory.Create;
3228 Category.No := i + 1;
3229 Category.Title := CategoryList[i];
3231 jBound := BoardList.Count - 1;
3232 for j := 0 to jBound do begin
3234 inistr := ini.ReadString(CategoryList[i], BoardList[j], '');
3236 //=====
\83v
\83\89\83O
\83C
\83\93
3238 kBound := Length( BoardPlugIns ) - 1;
3239 for k := 0 to kBound do begin
3240 if Assigned( Pointer( BoardPlugIns[ k ].Module ) ) then begin
3241 if BoardPlugIns[ k ].AcceptURL( inistr ) = atBoard then begin
3242 Board := TBoard.Create( BoardPlugIns[ k ], inistr );
3249 // 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¢
3253 Board := TBoard.Create( nil, inistr );
3256 Board.Title := BoardList[j];
3257 Board.RoundDate := ZERO_DATE;
3259 idx := RoundList.Find(Board);
3260 if idx <> -1 then begin
3261 RoundItem := RoundList.Items[idx, grtBoard];
3262 Board.Round := True;
3263 Board.RoundName := RoundItem.RoundName;
3266 Category.Add(Board);
3271 BBSs[ l ].Add( Category );
3280 lBound := Length( bbsList ) - 1;
3281 for l := 0 to lBound do
3286 function TGikoSys.GetUnknownCategory : TCategory;
3288 UNKNOWN_CATEGORY = '(
\96¼
\8fÌ
\95s
\96¾)';
3291 if Length( BBSs ) < 2 then begin
3296 Result := BBSs[ 1 ].FindCategoryFromTitle( UNKNOWN_CATEGORY );
3297 if Result = nil then begin
3298 Result := TCategory.Create;
3299 Result.Title := UNKNOWN_CATEGORY;
3300 BBSs[ 1 ].Add( Result );
3305 function TGikoSys.GetUnknownBoard( inPlugIn : TBoardPlugIn; inURL : string ) : TBoard;
3307 category : TCategory;
3309 UNKNOWN_BOARD = '(
\96¼
\8fÌ
\95s
\96¾)';
3312 category := GetUnknownCategory;
3313 if category = nil then begin
3316 Result := category.FindBoardFromTitle( UNKNOWN_BOARD );
3317 if Result = nil then begin
3318 Result := TBoard.Create( inPlugIn, inURL );
3319 Result.Title := UNKNOWN_BOARD;
3320 category.Add( Result );
3328 GikoSys := TGikoSys.Create;
3331 if GikoSys <> nil then begin