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;
20 TGikoBBSType = (gbt2ch);
21 //
\83\8d\83O
\83^
\83C
\83v
22 TGikoLogType = (glt2chNew, glt2chOld);
23 //
\83\81\83b
\83Z
\81[
\83W
\83A
\83C
\83R
\83\93
24 TGikoMessageIcon = (gmiOK, gmiSAD, gmiNG, gmiWhat, gmiNone);
25 //URL
\83I
\81[
\83v
\83\93\83u
\83\89\83E
\83U
\83^
\83C
\83v
26 TGikoBrowserType = (gbtIE, gbtUserApp, gbtAuto);
29 TStrTokSeparator = set of Char;
35 //
\83C
\83\93\83f
\83b
\83N
\83X
\83t
\83@
\83C
\83\8b\83\8c\83R
\81[
\83h
43 FRoundDate: TDateTime;
44 FLastModified: TDateTime;
47 FMishiyou: Boolean; //
\96¢
\8eg
\97p
51 FAllResCount: Integer;
52 FNewResCount: Integer;
53 FAgeSage: TGikoAgeSage;
56 //
\83T
\83u
\83W
\83F
\83N
\83g
\83\8c\83R
\81[
\83h
63 //
\83\8c\83X
\83\8c\83R
\81[
\83h
73 //URLPath
\83\8c\83R
\81[
\83h
76 FKey: string; //ThreadID
77 FSt: Integer; //
\8aJ
\8en
\83\8c\83X
\94Ô
78 FTo: Integer; //
\8fI
\97¹
\83\8c\83X
\94Ô
79 FFirst: Boolean; //>>1
\82Ì
\95\
\8e¦
80 FStBegin: Boolean; //1
\81`
\95\
\8e¦
81 FToEnd: Boolean; //
\81`
\8dÅ
\8cã
\82Ü
\82Å
\95\
\8e¦
82 FDone: Boolean; //
\90¬
\8c÷
85 TGikoSys = class(TObject)
91 FOnlyAHundredRes : Boolean;
92 // FExitWrite: TStringList;
93 // 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 GetURL(BBSID: string; FileName: string): string;
129 function GetUserAgent: string;
131 procedure ReadSubjectFile(Board: TBoard);
132 procedure CreateThreadDat(Board: TBoard);
133 procedure WriteThreadDat(Board: TBoard);
134 function ParseIndexLine(Line: string): TIndexRec;
135 procedure GetFileList(Path: string; Mask: string; List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
136 procedure GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
138 procedure CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
139 function AddAnchorTag(s: string): string;
141 function DivideSubject(Line: string): TSubjectRec;
142 function DivideStrLine(Line: string): TResRec;
144 property Setting: TSetting read FSetting write FSetting;
145 property Dolib: TDolib read FDolib write FDolib;
147 function UrlToID(url: string): string;
148 function UrlToServer(url: string): string;
150 function StrTokFirst(const s:string; const sep:TStrTokSeparator; var Rec:TStrTokRec):string;
151 function StrTokNext(const sep:TStrTokSeparator; var Rec:TStrTokRec): string;
153 function GetFileSize(FileName : string) : longint;
154 function GetFileLineCount(FileName : string): longint;
155 function Get2chDate(aDate: TDateTime): string;
156 function IntToDateTime(val: Int64): TDateTime;
157 function DateTimeToInt(ADate: TDateTime): Integer;
159 function ReadThreadFile(FileName: string; Line: Integer): string;
161 procedure MenuFont(Font: TFont);
163 function RemoveToken(var s:string;delimiter:string):string;
164 function GetTokenIndex(s: string; delimiter: string; index: Integer): string;
166 function DeleteLink(const s: string): string;
168 function GetShortName(const LongName: string; ALength: integer): string;
169 function ConvRes(const Body, Bbs, Key, ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
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;
188 //
\83X
\83L
\83\93\82ð
\93Ç
\82Ý
\8d\9e\82Ý
\81A
\92l
\82ð
\92u
\8a·
\82·
\82é
189 function LoadFromSkin( fileName: string; ThreadItem: TThreadItem; SizeByte: Integer ): string;
190 //
\83\8c\83X
\82Ì
\92l
\82ð
\92u
\8a·
\82·
\82é
191 function SkinedRes( skin: string; Res: TResRec; No: string ): string;
198 LENGTH_RESTITLE = 40;
199 ZERO_DATE: Integer = 25569;
200 BETA_VERSION_NAME_E = 'beta';
201 BETA_VERSION_NAME_J = 'ÊÞÀ';
203 BETA_VERSION_BUILD = ''; //debug
\94Å
\82È
\82Ç
204 APP_NAME = 'gikoNavi';
209 Giko, RoundData, ExternalBoardManager;
212 FOLDER_INDEX_VERSION = '1.01';
213 USER_AGENT = 'Monazilla';
214 DEFAULT_NGWORD_FILE_NAME : String = 'NGword.txt';
215 NGWORDs_DIR_NAME : String = 'NGwords';
217 (*************************************************************************
218 *GikoSys
\83R
\83\93\83X
\83g
\83\89\83N
\83^
219 *************************************************************************)
220 constructor TGikoSys.Create;
222 FSetting := TSetting.Create;
223 FDolib := TDolib.Create;
224 FAWKStr := TAWKStr.Create(nil);
225 if DirectoryExists(GetConfigDir) = false then begin
226 CreateDir(GetConfigDir);
228 FAbon := TAbon.Create;
229 FAbon.Setroot(GetConfigDir+NGWORDs_DIR_NAME);
231 FAbon.ReturnNGwordLineNum := FSetting.ShowNGLinesNum;
232 FAbon.SetNGResAnchor := FSetting.AddResAnchor;
233 FAbon.Deleterlo := FSetting.AbonDeleterlo;
234 FAbon.Replaceul := FSetting.AbonReplaceul;
235 FAbon.AbonPopupRes := FSetting.PopUpAbon;
237 FSelectResFilter := TAbon.Create;
238 //
\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
239 FSelectResFilter.AbonString := '';
241 OnlyAHundredRes := FSetting.OnlyAHundredRes;
244 (*************************************************************************
245 *GikoSys
\83f
\83X
\83g
\83\89\83N
\83^
246 *************************************************************************)
247 destructor TGikoSys.Destroy;
250 FileList: TStringList;
252 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
260 //
\83e
\83\93\83|
\83\89\83\8aHTML
\82ð
\8dí
\8f\9c
261 FileList := TStringList.Create;
263 GetFileList(GetTempFolder, '*.html', FileList, False, True);
264 for i := 0 to FileList.Count - 1 do begin
265 DeleteFile(FileList[i]);
273 (*************************************************************************
274 *
\95¶
\8e\9a\97ñ
\90\94\8e\9a\83`
\83F
\83b
\83N
275 *************************************************************************)
277 function TGikoSys.IsNumeric(s: string): boolean;
287 (*************************************************************************
288 *
\95¶
\8e\9a\97ñ
\95\82\93®
\8f¬
\90\94\93_
\90\94\8e\9a\83`
\83F
\83b
\83N
289 *************************************************************************)
290 function TGikoSys.IsFloat(s: string): boolean;
294 Result := TextToFloat(PChar(s), v, fvExtended);
297 (*************************************************************************
298 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
299 *************************************************************************)
300 function TGikoSys.GetBoardFileName: string;
302 Result := Setting.GetBoardFileName;
305 (*************************************************************************
306 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
307 *************************************************************************)
308 function TGikoSys.GetCustomBoardFileName: string;
310 Result := Setting.GetCustomBoardFileName;
313 (*************************************************************************
314 *
\83e
\83\93\83|
\83\89\83\8a\83t
\83H
\83\8b\83_
\81[
\96¼
\8eæ
\93¾
315 *************************************************************************)
316 function TGikoSys.GetHtmlTempFileName: string;
318 Result := Setting.GetHtmlTempFileName;
322 (*************************************************************************
323 *
\8eÀ
\8ds
\83t
\83@
\83C
\83\8b\83t
\83H
\83\8b\83_
\8eæ
\93¾
324 *************************************************************************)
325 function TGikoSys.GetAppDir: string;
327 Result := Setting.GetAppDir;
330 (*************************************************************************
331 *TempHtml
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
332 *************************************************************************)
333 function TGikoSys.GetTempFolder: string;
335 Result := Setting.GetTempFolder;
338 (*************************************************************************
339 *sent.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
340 *************************************************************************)
341 function TGikoSys.GetSentFileName: string;
343 Result := Setting.GetSentFileName;
346 (*************************************************************************
347 *outbox.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
348 *************************************************************************)
349 function TGikoSys.GetOutBoxFileName: string;
351 Result := Setting.GetOutBoxFileName;
354 (*************************************************************************
355 *Config
\83t
\83H
\83\8b\83_
\8eæ
\93¾
356 *************************************************************************)
357 function TGikoSys.GetConfigDir: string;
359 Result := Setting.GetConfigDir;
362 function TGikoSys.GetStyleSheetDir: string;
364 Result := Setting.GetStyleSheetDir;
367 function TGikoSys.GetSkinDir: string;
369 Result := Setting.GetSkinDir;
372 function TGikoSys.GetSkinHeaderFileName: string;
374 Result := Setting.GetSkinHeaderFileName;
377 function TGikoSys.GetSkinFooterFileName: string;
379 Result := Setting.GetSkinFooterFileName;
382 function TGikoSys.GetSkinNewResFileName: string;
384 Result := Setting.GetSkinNewResFileName;
387 function TGikoSys.GetSkinResFileName: string;
389 Result := Setting.GetSkinResFileName;
392 function TGikoSys.GetSkinBookmarkFileName: string;
394 Result := Setting.GetSkinBookmarkFileName;
397 function TGikoSys.GetSkinNewmarkFileName: string;
399 Result := Setting.GetSkinNewmarkFileName;
402 (*************************************************************************
403 *URL
\82ð
\8dì
\90¬(
\83R
\83s
\83y
\97p)
404 *************************************************************************)
405 function TGikoSys.GetURL(BBSID: string; FileName: string): string;
409 Board := BoardGroup.BBS2ch.GetBoardFromBBSID(BBSID);
410 Result := UrlToServer(Board.URL) + 'test/read.cgi/' + UrlToID(Board.URL) + '/' + ChangeFileExt(FileName, '') + '/l50';
411 //http://teri.2ch.net/test/read.cgi?bbs=accuse&key=974619522&ls=50
412 //http://pc.2ch.net/test/read.cgi/tech/1003664165/l50
416 function TGikoSys.GetUserAgent: string;
418 if Dolib.Connected then begin
419 Result := Format('%s %s/%s%d%s', [
426 BETA_VERSION_BUILD]);
428 Result := Format('%s/%s %s/%s%d%s', [
436 BETA_VERSION_BUILD]);
440 (*************************************************************************
441 *
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é
\95û
\8e®
\8e\9e\8d\8f\8eæ
\93¾
442 *************************************************************************)
443 function TGikoSys.Get2chDate(aDate: TDateTime): string;
448 d1 := EncodeDate(1970, 1, 1);
449 d2 := aDate - EncodeTime(9, 0, 0, 0);
450 Result := FloatToStr(Trunc((d2 - d1) * 24 * 60 * 60));
454 function TGikoSys.IntToDateTime(val: Int64): TDateTime;
459 d1 := EncodeDate(1970, 1, 1);
460 d2 := (val * 1000) / (24 * 60 * 60 * 1000);
464 function TGikoSys.DateTimeToInt(ADate: TDateTime): Integer;
469 d := EncodeDate(1970, 1, 1);
470 c := (ADate - d) * 24 * 60 * 60;
475 (*************************************************************************
476 *Subject
\83t
\83@
\83C
\83\8bRead
477 *************************************************************************)
478 procedure TGikoSys.ReadSubjectFile(Board: TBoard);
480 ThreadItem: TThreadItem;
482 FileList: TStringList;
483 TmpFileList: TStringList;
484 // SrchRec: TSearchRec;
491 // TmpUpdate: Boolean;
494 RoundItem: TRoundItem;
500 // TmpUpdate := False;
502 usePlugIn := Board.IsBoardPlugInAvailable;
504 FileName := Board.GetFolderIndexFileName;
505 if not FileExists(FileName) then CreateThreadDat(Board);
506 // if not FileExists(FileName) then Exit;
508 { R := FindFirst(ExtractFileDir(Board.GetFolderIndexFileName) + '\*.dat', 0, SrchRec);
510 FileList.Add(SrchRec.Name);
511 R := FindNext(SrchRec);
515 FileList := TStringList.Create;
516 FileList.Sorted := True;
517 TmpFileList := TStringList.Create;
518 TmpFileList.Sorted := True;
520 //IsLogFile
\97pDAT
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
521 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False, False);
523 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\97pTmp
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
524 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 := 1 to sl.Count - 1 do begin
534 Rec := ParseIndexLine(sl[i]);
537 ThreadItem := TThreadItem.Create(
539 Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), Rec.FFileName ) )
541 ThreadItem := TThreadItem.Create;
542 ThreadItem.BeginUpdate;
543 ThreadItem.No := Rec.FNo;
544 ThreadItem.FileName := Rec.FFileName;
545 ThreadItem.Title := Rec.FTitle;
546 ThreadItem.Count := Rec.FCount;
547 ThreadItem.Size := Rec.FSize;
548 // ThreadItem.RoundNo := Rec.FRoundNo;
549 ThreadItem.RoundDate := Rec.FRoundDate;
550 ThreadItem.LastModified := Rec.FLastModified;
551 ThreadItem.Kokomade := Rec.FKokomade;
552 ThreadItem.NewReceive := Rec.FNewReceive;
553 // ThreadItem.Round := Rec.FRound;
554 ThreadItem.UnRead := Rec.FUnRead;
555 ThreadItem.ScrollTop := Rec.FScrollTop;
556 ThreadItem.AllResCount := Rec.FAllResCount;
557 ThreadItem.NewResCount := Rec.FNewResCount;
558 ThreadItem.AgeSage := Rec.FAgeSage;
559 ThreadItem.ParentBoard := Board;
561 //IsLogFile
\83`
\83F
\83b
\83N
562 ThreadItem.IsLogFile := False;
563 if FileList.Count <> 0 then begin
564 if FileList.Find(ThreadItem.FileName, Index) then begin
565 ThreadItem.IsLogFile := True;
566 FileList.Delete(Index);
570 //
\8f\84\89ñ
\83\8a\83X
\83g
\82É
\91¶
\8dÝ
\82µ
\82½
\82ç
\8f\84\89ñ
\83t
\83\89\83O
\83Z
\83b
\83g
571 if ThreadItem.IsLogFile then begin
572 idx := RoundList.Find(ThreadItem);
573 if idx <> -1 then begin
574 RoundItem := RoundList.Items[idx, grtItem];
575 ThreadItem.RoundName := RoundItem.RoundName;
576 ThreadItem.Round := True;
580 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\83`
\83F
\83b
\83N
581 if TmpFileList.Count <> 0 then begin
582 if TmpFileList.Find(ChangeFileExt(ThreadItem.FileName, '.tmp'), Index) then begin
583 ini := TMemIniFile.Create(ChangeFileExt(ThreadItem.GetThreadFileName, '.tmp'));
585 ThreadItem.RoundDate := ini.ReadDateTime('Setting', 'RoundDate', ZERO_DATE);
586 ThreadItem.LastModified := ini.ReadDateTime('Setting', 'LastModified', ZERO_DATE);
587 ThreadItem.Size := ini.ReadInteger('Setting', 'Size', 0);
588 ThreadItem.Count := ini.ReadInteger('Setting', 'Count', 0);
589 ThreadItem.NewReceive := ini.ReadInteger('Setting', 'NewReceive', 0);
590 ThreadItem.Round := ini.ReadBool('Setting', 'Round', False);
591 ThreadItem.UnRead := False;//ini.ReadBool('Setting', 'UnRead', False);
592 ThreadItem.ScrollTop := ini.ReadInteger('Setting', 'ScrollTop', 0);
593 ThreadItem.AllResCount := ini.ReadInteger('Setting', 'AllResCount', 0);
594 ThreadItem.NewResCount := ini.ReadInteger('Setting', 'NewResCount', 0);
595 ThreadItem.AgeSage := TGikoAgeSage(ini.ReadInteger('Setting', 'AgeSage', Ord(gasNone)));
599 TmpFileList.Delete(Index);
603 ThreadItem.EndUpdate;
604 Board.Add(ThreadItem);
606 // if (ThreadItem.IsLogFile) and (ThreadItem.Count > ThreadItem.Kokomade) then
607 if (ThreadItem.IsLogFile) and (ThreadItem.UnRead) then
611 if UnRead <> Board.UnRead then
612 Board.UnRead := UnRead;
614 //
\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
615 for i := 0 to FileList.Count - 1 do begin
616 FileName := ExtractFileDir(Board.GetFolderIndexFileName) + '\' + FileList[i];
618 ResRec := DivideStrLine(ReadThreadFile(FileName, 1));
620 ThreadItem := TThreadItem.Create(
622 Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), Rec.FFileName ) )
624 ThreadItem := TThreadItem.Create;
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(Board.ParentCategory.ParentBBS2ch.GetLogFolder + Board.BBSID);
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 Skin.Text := StringReplace( Skin.Text, '<BBSNAME/>', ThreadItem.ParentBoard.ParentCategory.ParentBBS2ch.Title, [rfReplaceAll] );
877 Skin.Text := StringReplace( Skin.Text, '<THREADURL/>', ThreadItem.URL, [rfReplaceAll] );
879 Skin.Text := StringReplace( Skin.Text, '<BOARDNAME/>', ThreadItem.ParentBoard.Title, [rfReplaceAll] );
880 Skin.Text := StringReplace( Skin.Text, '<BOARDURL/>', ThreadItem.ParentBoard.URL, [rfReplaceAll] );
881 Skin.Text := StringReplace( Skin.Text, '<THREADNAME/>', ThreadItem.Title, [rfReplaceAll] );
882 Skin.Text := StringReplace( Skin.Text, '<SKINPATH/>', Setting.CSSFileName, [rfReplaceAll] );
883 Skin.Text := StringReplace( Skin.Text, '<GETRESCOUNT/>', IntToStr( ThreadItem.NewReceive - 1 ), [rfReplaceAll] );
884 Skin.Text := StringReplace( Skin.Text, '<NEWRESCOUNT/>', IntToStr( ThreadItem.NewResCount ), [rfReplaceAll] );
885 Skin.Text := StringReplace( Skin.Text, '<ALLRESCOUNT/>', IntToStr( ThreadItem.AllResCount ), [rfReplaceAll] );
887 Skin.Text := StringReplace( Skin.Text, '<NEWDATE/>',
888 FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate), [rfReplaceAll] );
889 Skin.Text := StringReplace( Skin.Text, '<SIZEKB/>', IntToStr( Floor( SizeByte / 1024 ) ), [rfReplaceAll] );
890 Skin.Text := StringReplace( Skin.Text, '<SIZE/>', IntToStr( SizeByte ), [rfReplaceAll] );
892 //-----
\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µ
893 //
\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
895 if ThreadItem.ParentBoard <> nil then
896 if ThreadItem.ParentBoard.ParentCategory <> nil then
897 Skin.Text := StringReplace( Skin.Text, '&BBSNAME', ThreadItem.ParentBoard.ParentCategory.ParentBBS2ch.Title, [rfReplaceAll] );
898 Skin.Text := StringReplace( Skin.Text, '&THREADURL', ThreadItem.URL, [rfReplaceAll] );
900 Skin.Text := StringReplace( Skin.Text, '&BOARDNAME', ThreadItem.ParentBoard.Title, [rfReplaceAll] );
901 Skin.Text := StringReplace( Skin.Text, '&BOARDURL', ThreadItem.ParentBoard.URL, [rfReplaceAll] );
902 Skin.Text := StringReplace( Skin.Text, '&THREADNAME', ThreadItem.Title, [rfReplaceAll] );
903 Skin.Text := StringReplace( Skin.Text, '&SKINPATH', Setting.CSSFileName, [rfReplaceAll] );
904 Skin.Text := StringReplace( Skin.Text, '&GETRESCOUNT', IntToStr( ThreadItem.NewReceive - 1 ), [rfReplaceAll] );
905 Skin.Text := StringReplace( Skin.Text, '&NEWRESCOUNT', IntToStr( ThreadItem.NewResCount ), [rfReplaceAll] );
906 Skin.Text := StringReplace( Skin.Text, '&ALLRESCOUNT', IntToStr( ThreadItem.AllResCount ), [rfReplaceAll] );
908 Skin.Text := StringReplace( Skin.Text, '&NEWDATE',
909 FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate), [rfReplaceAll] );
910 Skin.Text := StringReplace( Skin.Text, '&SIZEKB', IntToStr( Floor( SizeByte / 1024 ) ), [rfReplaceAll] );
911 Skin.Text := StringReplace( Skin.Text, '&SIZE', IntToStr( SizeByte ), [rfReplaceAll] );
912 //-----
\82±
\82±
\82Ü
\82Å
920 //
\83\8c\83X
\82Ì
\92l
\82ð
\92u
\8a·
\82·
\82é
921 function TGikoSys.SkinedRes(
929 Skin := StringReplace( Skin, '<NUMBER/>',
930 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>', [rfReplaceAll] );
931 Skin := StringReplace( Skin, '<PLAINNUMBER/>', No, [rfReplaceAll] );
932 Skin := StringReplace( Skin, '<NAME/>', '<b>' + Res.FName + '</b>', [rfReplaceAll] );
933 Skin := StringReplace( Skin, '<MAILNAME/>',
934 '<a href="mailo:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>', [rfReplaceAll] );
935 Skin := StringReplace( Skin, '<MAIL/>', Res.FMailTo, [rfReplaceAll] );
936 Skin := StringReplace( Skin, '<DATE/>', Res.FDateTime, [rfReplaceAll] );
937 Skin := StringReplace( Skin, '<MESSAGE/>', Res.FBody, [rfReplaceAll] );
939 //-----
\82©
\82¿
\82ã
\81`
\82µ
\82á
\8cÝ
\8a·
\97p
\81B
\83R
\83\81\83\93\83g
\83A
\83E
\83g
\82µ
\82Ä
\82à
\82æ
\82µ
940 Skin := StringReplace( Skin, '&NUMBER',
941 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>', [rfReplaceAll] );
942 Skin := StringReplace( Skin, '&PLAINNUMBER', No, [rfReplaceAll] );
943 Skin := StringReplace( Skin, '&NAME', '<b>' + Res.FName + '</b>', [rfReplaceAll] );
944 Skin := StringReplace( Skin, '&MAILNAME',
945 '<a href="mailo:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>', [rfReplaceAll] );
946 Skin := StringReplace( Skin, '&MAIL', Res.FMailTo, [rfReplaceAll] );
947 Skin := StringReplace( Skin, '&DATE', Res.FDateTime, [rfReplaceAll] );
948 Skin := StringReplace( Skin, '&MESSAGE', Res.FBody, [rfReplaceAll] );
949 //-----
\82±
\82±
\82Ü
\82Å
957 procedure TGikoSys.CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
961 //bufList : TStringList;
962 ReadList: TStringList;
963 SaveList: TStringList;
967 NewReceiveNo: Integer;
969 boardPlugIn : TBoardPlugIn;
971 UserOptionalStyle: string;
977 function LoadSkin( fileName: string ): string;
979 Result := LoadFromSkin( fileName, ThreadItem, SizeByte );
981 function ReplaceRes( skin: string ): string;
983 Result := SkinedRes( skin, Res, No );
986 if ThreadItem <> nil then begin
987 if ThreadItem.IsBoardPlugInAvailable then begin
988 //=====
\83v
\83\89\83O
\83C
\83\93\82É
\82æ
\82é
\95\
\8e¦
989 boardPlugIn := ThreadItem.BoardPlugIn;
990 NewReceiveNo := ThreadItem.NewReceive;
992 //
\83t
\83H
\83\93\83g
\82â
\83T
\83C
\83Y
\82Ì
\90Ý
\92è
993 if Length( GikoSys.Setting.BrowserFontName ) > 0 then
994 UserOptionalStyle := UserOptionalStyle +
995 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
996 if GikoSys.Setting.BrowserFontSize <> 0 then
997 UserOptionalStyle := UserOptionalStyle +
998 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
999 if GikoSys.Setting.BrowserFontColor <> -1 then
1000 UserOptionalStyle := UserOptionalStyle +
1001 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
1002 if GikoSys.Setting.BrowserBackColor <> -1 then
1003 UserOptionalStyle := UserOptionalStyle +
1004 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
1005 case GikoSys.Setting.BrowserFontBold of
1006 -1: UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
1007 1: UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;';
1009 case GikoSys.Setting.BrowserFontItalic of
1010 -1: UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
1011 1: UserOptionalStyle := UserOptionalStyle + 'font-style:italic;';
1014 SaveList := TStringList.Create;
1017 //
\95¶
\8e\9a\83R
\81[
\83h
\82Í
\83v
\83\89\83O
\83C
\83\93\82É
\94C
\82¹
\82é
1018 // doc.charset := 'Shift_JIS';
1019 threadItem.SizeByte := 0;
1022 SaveList.Add( boardPlugIn.GetHeader( DWORD( threadItem ),
1023 '<style type="text/css">body {' + UserOptionalStyle + '}</style>' ) );
1025 for i := 0 to threadItem.Count - 1 do begin
1026 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (threadItem.Count-i) > 101 ) then begin
1030 //
\90V
\92\85\83}
\81[
\83N
1031 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1033 if GikoSys.Setting.UseSkin then begin
1034 SaveList.Add( LoadSkin( GetSkinNewmarkFileName ) );
1035 end else if GikoSys.Setting.UseCSS then begin
1036 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>');
1038 SaveList.Add('</dl>');
1039 SaveList.Add('<a name="new"></a>');
1040 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>');
1041 SaveList.Add('<dl>');
1044 SaveList.Add( '<a name="new"></a>' );
1049 SaveList.Add( boardPlugIn.GetRes( DWORD( threadItem ), i + 1 ) );
1051 if ThreadItem.Kokomade = (i + 1) then begin
1052 //
\82±
\82±
\82Ü
\82Å
\93Ç
\82ñ
\82¾
1054 if GikoSys.Setting.UseSkin then begin
1055 SaveList.Add( LoadSkin( GetSkinBookmarkFileName ) );
1056 end else if GikoSys.Setting.UseCSS then begin
1057 SaveList.Add('<a name="koko"></a><div class="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</div>');
1059 SaveList.Add('</dl>');
1060 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>');
1061 SaveList.Add('<dl>');
1064 SaveList.Add( '<a name="koko"></a>' );
1068 threadItem.SizeByte := threadItem.SizeByte + Length( SaveList.Text );
1069 doc.Write(SaveList.Text);
1073 threadItem.SizeByte := threadItem.SizeByte + Length( SaveList.Text );
1075 //
\83X
\83L
\83\93(
\83t
\83b
\83^)
1076 SaveList.Add( boardPlugIn.GetFooter( DWORD( threadItem ), '<a name="bottom"></a>' ) );
1078 doc.Write(SaveList.Text);
1087 ShortDayNames[1] := '
\93ú'; ShortDayNames[2] := '
\8c\8e';
1088 ShortDayNames[3] := '
\89Î'; ShortDayNames[4] := '
\90\85';
1089 ShortDayNames[5] := '
\96Ø'; ShortDayNames[6] := '
\8bà';
1090 ShortDayNames[7] := '
\93y';
1092 BBSID := ThreadItem.ParentBoard.BBSID;
1093 NewReceiveNo := ThreadItem.NewReceive;
1094 ReadList := TStringList.Create;
1096 if ThreadItem.IsLogFile then begin
1097 FileName := ThreadItem.GetThreadFileName;
1098 ReadList.LoadFromFile(FileName);
1099 FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
1100 FAbon.Execute(ReadList); //
\82 \82Ú
\81`
\82ñ
\82µ
\82Ä
1101 FSelectResFilter.Execute(ReadList); //
\83\8c\83X
\82Ì
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\82·
\82é
1102 Res := DivideStrLine(ReadList[0]);
1103 Res.FTitle := StringReplace(Res.FTitle, '
\81\97\81M', ',', [rfReplaceAll]);
1104 sTitle := Res.FTitle;
1106 sTitle := StringReplace(ThreadItem.Title, '
\81\97\81M', ',', [rfReplaceAll]);
1108 SaveList := TStringList.Create;
1111 doc.charset := 'Shift_JIS';
1113 //
\83t
\83H
\83\93\83g
\82â
\83T
\83C
\83Y
\82Ì
\90Ý
\92è
1114 if Length( GikoSys.Setting.BrowserFontName ) > 0 then
1115 UserOptionalStyle := UserOptionalStyle +
1116 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
1117 if GikoSys.Setting.BrowserFontSize <> 0 then
1118 UserOptionalStyle := UserOptionalStyle +
1119 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
1120 if GikoSys.Setting.BrowserFontColor <> -1 then
1121 UserOptionalStyle := UserOptionalStyle +
1122 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
1123 if GikoSys.Setting.BrowserBackColor <> -1 then
1124 UserOptionalStyle := UserOptionalStyle +
1125 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
1126 case GikoSys.Setting.BrowserFontBold of
1127 -1: UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
1128 1: UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;';
1130 case GikoSys.Setting.BrowserFontItalic of
1131 -1: UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
1132 1: UserOptionalStyle := UserOptionalStyle + 'font-style:italic;';
1135 CSSFileName := GetStyleSheetDir + Setting.CSSFileName;
1136 if GikoSys.Setting.UseSkin then begin
1137 //
\83X
\83L
\83\93\8eg
\97p
1138 //
\83X
\83L
\83\93\82Ì
\90Ý
\92è
1140 SkinHeader := LoadSkin( GetSkinHeaderFileName );
1141 if Length( UserOptionalStyle ) > 0 then
1142 SkinHeader := StringReplace( SkinHeader, '</head>',
1143 '<style type="text/css">body {' + UserOptionalStyle + '}</style></head>', [rfReplaceAll] );
1144 SaveList.Add( SkinHeader );
1148 SkinNewRes := LoadSkin( GetSkinNewResFileName );
1152 SkinRes := LoadSkin( GetSkinResFileName );
1156 SaveList.Add('<a name="top"></a>');
1158 for i := 0 to ReadList.Count - 1 do begin
1159 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1162 if (Trim(ReadList[i]) <> '') then begin
1163 No := IntToStr(i + 1);
1165 Res := DivideStrLine(ReadList[i]);
1166 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1168 if Res.FType = glt2chOld then begin
1169 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
1170 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
1171 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
1174 Res.FBody := AddAnchorTag(Res.FBody);
1175 if Res.FName = '' then
1176 Res.FName := ' ';
1178 //
\90V
\92\85\83}
\81[
\83N
1179 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1181 SaveList.Add( LoadSkin( GetSkinNewmarkFileName ) );
1183 SaveList.Add( '<a name="new"></a>' );
1187 if NewReceiveNo <= (i + 1) then
1188 //
\90V
\92\85\83\8c\83X
1189 SaveList.Add( ReplaceRes( SkinNewRes ) )
1191 //
\92Ê
\8fí
\82Ì
\83\8c\83X
1192 SaveList.Add( ReplaceRes( SkinRes ) );
1195 if ThreadItem.Kokomade = (i + 1) then begin
1196 //
\82±
\82±
\82Ü
\82Å
\93Ç
\82ñ
\82¾
1198 SaveList.Add( LoadSkin( GetSkinBookmarkFileName ) );
1200 SaveList.Add( '<a name="koko"></a>' );
1204 SizeByte := SizeByte + Length( SaveList.Text );
1205 doc.Write(SaveList.Text);
1208 SaveList.Add('<a name="bottom"></a>');
1209 SizeByte := SizeByte + Length( SaveList.Text );
1210 //
\83X
\83L
\83\93(
\83t
\83b
\83^)
1212 SaveList.Add( LoadSkin( GetSkinFooterFileName ) );
1215 doc.Write(SaveList.Text);
1217 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
1219 //CSSFileName := GetAppDir + CSS_FILE_NAME;
1220 // SaveList.Add('<html lang="ja"><head>');
1221 SaveList.Add('<html><head>');
1222 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1223 SaveList.Add('<title>' + sTitle + '</title>');
1224 SaveList.Add('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
1225 if Length( UserOptionalStyle ) > 0 then
1226 SaveList.Add('<style type="text/css">body {' + UserOptionalStyle + '}</style>');
1227 SaveList.Add('</head>');
1228 SaveList.Add('<body>');
1229 SaveList.Add('<a name="top"></a>');
1230 SaveList.Add('<div class="title">' + sTitle + '</div>');
1231 doc.Write(SaveList.Text);
1233 //Application.ProcessMessages;
1234 for i := 0 to ReadList.Count - 1 do begin
1235 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1238 if (Trim(ReadList[i]) <> '') then begin
1239 No := IntToStr(i + 1);
1240 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1241 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>');
1243 Res := DivideStrLine(ReadList[i]);
1244 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1245 Res.FBody := AddAnchorTag(Res.FBody);
1246 if Res.FName = '' then
1247 Res.FName := ' ';
1248 if Res.FMailTo = '' then
1249 SaveList.Add('<a name="' + No + '"></a>'
1250 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span> '
1251 + '<span class="name_label">
\96¼
\91O
\81F</span> '
1252 + '<span class="name"><b>' + Res.FName + '</b></span> '
1253 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span> '
1254 + '<span class="date">' + Res.FDateTime+ '</span></div>'
1255 + '<div class="mes">' + Res.FBody + ' </div>')
1256 else if GikoSys.Setting.ShowMail then
1257 SaveList.Add('<a name="' + No + '"></a>'
1258 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1259 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1260 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1261 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
1262 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1263 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1264 + '<div class="mes">' + Res.FBody + ' </div>')
1266 SaveList.Add('<a name="' + No + '"></a>'
1267 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1268 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1269 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1270 + '<b>' + Res.FName + '</b></a>'
1271 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1272 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1273 + '<div class="mes">' + Res.FBody + ' </div>');
1274 if ThreadItem.Kokomade = (i + 1) then begin
1275 SaveList.Add('<a name="koko"></a><div class="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</div>');
1279 doc.Write(SaveList.Text);
1283 SaveList.Add('<a name="bottom"></a>');
1284 SaveList.Add('</body></html>');
1285 SaveList.Add('<a name="last"></a>');
1286 SaveList.Add('</body></html>');
1288 doc.Write(SaveList.Text);
1291 // SaveList.Add('<html lang="ja"><head>');
1292 SaveList.Add('<html><head>');
1293 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1294 SaveList.Add('<title>' + sTitle + '</title></head>');
1295 SaveList.Add('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1296 SaveList.Add('<a name="top"></a>');
1297 SaveList.Add('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1298 SaveList.Add('<dl>');
1299 doc.Write(SaveList.Text);
1301 //Application.ProcessMessages;
1302 for i := 0 to ReadList.Count - 1 do begin
1303 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1306 if (Trim(ReadList[i]) <> '') then begin
1307 No := IntToStr(i + 1);
1309 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1310 SaveList.Add('</dl>');
1311 SaveList.Add('<a name="new"></a>');
1312 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>');
1313 SaveList.Add('<dl>');
1315 Res := DivideStrLine(ReadList[i]);
1316 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1317 if Res.FType = glt2chOld then begin
1318 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
1319 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
1320 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
1322 Res.FBody := AddAnchorTag(Res.FBody);
1323 if Res.FMailTo = '' then
1324 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>')
1325 else if GikoSys.Setting.ShowMail then
1326 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>')
1328 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>');
1329 if ThreadItem.Kokomade = (i + 1) then begin
1330 SaveList.Add('</dl>');
1331 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>');
1332 SaveList.Add('<dl>');
1335 //if SaveList.Count > 50 then begin
1336 doc.Write(SaveList.Text);
1338 //Application.ProcessMessages;
1341 SaveList.Add('</dl>');
1342 SaveList.Add('<a name="bottom"></a>');
1343 SaveList.Add('</body></html>');
1344 doc.Write(SaveList.Text);
1354 (*************************************************************************
1355 *http://
\82Ì
\95¶
\8e\9a\97ñ
\82ðanchor
\83^
\83O
\95t
\82«
\82É
\82·
\82é
\81B
1356 *************************************************************************)
1357 function TGikoSys.AddAnchorTag(s: string): string;
1359 URL_CHAR: string = '0123456789'
1360 + 'abcdefghijklmnopqrstuvwxyz'
1361 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1362 + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
1363 ANCHOR_REF = 'href=';
1364 RES_REF = '>>';
1366 wkIdx: array[0..9] of Integer;
1371 anchorLen : Integer;
1374 // + 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ß
1375 anchorLen := Length( ANCHOR_REF ) + 3;
1378 wkIdx[0] := AnsiPos('http://', s);
1379 wkIdx[1] := AnsiPos('ttp://', s);
1380 wkIdx[2] := AnsiPos('tp://', s);
1381 wkIdx[3] := AnsiPos('ms-help://', s);
1382 wkIdx[4] := AnsiPos('p://', s);
1383 wkIdx[5] := AnsiPos('https://', s);
1384 wkIdx[6] := AnsiPos('www.', s);
1385 wkIdx[7] := AnsiPos('ftp://', s);
1386 wkIdx[8] := AnsiPos('news://', s);
1387 wkIdx[9] := AnsiPos('rtsp://', s);
1391 if wkIdx[i] <> 0 then idx := Min(wkIdx[i], idx);
1393 if idx = MaxInt then begin
1394 //
\83\8a\83\93\83N
\82ª
\96³
\82¢
\82æ
\81B
1395 Result := Result + s;
1400 (Pos( ANCHOR_REF, Copy(s, idx - anchorLen, anchorLen ) ) > 0) then begin
1401 //
\8aù
\82É
\83\8a\83\93\83N
\83^
\83O
\82ª
\82Â
\82¢
\82Ä
\82¢
\82é
\82Á
\82Û
\82¢
\82Æ
\82«
\82Í
\83\80\83V
1402 href := Copy( s, idx, Length( s ) );
1403 Result := Result + Copy( s, 1, idx + Pos( '</a>', href ) + Length( '</a>' ) - 2 );
1405 s := Copy( s, Pos( '</a>', s ) + Length( '</a>' ), Length( s ) );
1410 Result := Result + Copy(s, 0, idx - 1);
1412 s := Copy(s, idx, length(s));
1414 for i := 0 to Length(s) do begin
1415 idx := AnsiPos(s[i + 1], URL_CHAR);
1416 if (idx = 0) or (i = (Length(s))) then begin
1417 //URL
\82¶
\82á
\82È
\82¢
\95¶
\8e\9a\94
\8c©
\81I
\82Æ
\82©
\81A
\95¶
\8e\9a\82ª
\82È
\82
\82È
\82Á
\82½
\81B
1418 url := Copy(s, 0, i);
1420 if AnsiPos('ttp://', url) = 1 then
1422 else if AnsiPos('tp://', url) = 1 then
1424 else if AnsiPos('p://', url) = 1 then
1426 else if AnsiPos('www.', url) = 1 then
1427 href := 'http://' + url
1430 Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
1431 s := Copy(s, i + 1, Length(s));
1438 (*************************************************************************
1439 *
\83T
\83u
\83W
\83F
\83N
\83g
\88ê
\8ds
\82ð
\95ª
\8a\84
1440 *************************************************************************)
1441 function TGikoSys.DivideSubject(Line: string): TSubjectRec;
1451 if Pos('<>', Line) = 0 then
1456 Result.FFileName := GetTokenIndex(Line, Delim, 0);
1457 Result.FTitle := GetTokenIndex(Line, Delim, 1);
1459 ws := Trim(Result.FTitle);
1461 if Copy(ws, Length(ws), 1) = ')' then begin
1464 end else if Copy(ws, Length(ws), 1) = '
\81j' then begin
1467 end else if Copy(ws, Length(ws), 1) = '<' then begin
1472 for i := Length(ws) - 1 downto 1 do begin
1473 if ws[i] = LeftK then begin
1474 ws := Copy(ws, i + 1, Length(ws) - i - 1);
1475 if IsNumeric(ws) then
1476 Result.FCount := StrToInt(ws);
1477 Result.FTitle := Trim(StringReplace(Result.FTitle, LeftK + ws + RightK, '', [rfReplaceAll]));
1483 (*************************************************************************
1484 * dat
\83t
\83@
\83C
\83\8b\82Ì
\88ê
\83\89\83C
\83\93\82ð
\95ª
\89ð
1485 *************************************************************************)
1486 function TGikoSys.DivideStrLine(Line: string): TResRec;
1491 if Pos('<>', Line) = 0 then begin
1493 Result.FType := glt2chOld;
1496 Result.FType := glt2chNew;
1498 Result.FName := Trim(GetTokenIndex(Line, Delim, 0));
1499 Result.FMailTo := Trim(GetTokenIndex(Line, Delim, 1));
1500 Result.FDateTime := Trim(GetTokenIndex(Line, Delim, 2));
1501 bufBody := Trim(GetTokenIndex(Line, Delim, 3));
1502 if bufbody = '' then begin
1503 Insert(' ',bufbody, 1);
1505 Result.FBody := bufBody;
1506 Result.FTitle := Trim(GetTokenIndex(Line, Delim, 4));
1510 (*************************************************************************
1511 * URL
\82©
\82çBBSID
\82ð
\8eæ
\93¾
1512 *************************************************************************)
1513 function TGikoSys.UrlToID(url: string): string;
1520 if url = '' then Exit;
1522 url := Copy(url, 0, Length(url) - 1);
1523 for i := Length(url) downto 0 do begin
1524 if url[i] = '/' then begin
1525 Result := Copy(url, i + 1, Length(url));
1531 (*************************************************************************
1532 *URL
\82©
\82çBBSID
\88È
\8aO
\82Ì
\95\94\95ª(http://teri.2ch.net/)
\82ð
\8eæ
\93¾
1533 *************************************************************************)
1534 function TGikoSys.UrlToServer(url: string): string;
1541 wsURL := Trim(wsURL);
1543 if wsURL = '' then exit;
1545 if Copy(wsURL, Length(wsURL), 1) = '/' then
1546 wsURL := Copy(wsURL, 0, Length(wsURL) - 1);
1548 for i := Length(wsURL) downto 0 do begin
1549 if wsURL[i] = '/' then begin
1550 Result := Copy(wsURL, 0, i);
1556 (*************************************************************************
1557 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ª
\91¶
\8dÝ
\82·
\82é
\82©
\83`
\83F
\83b
\83N
1558 *************************************************************************)
1559 function TGikoSys.DirectoryExistsEx(const Name: string): Boolean;
1563 Code := GetFileAttributes(PChar(Name));
1564 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
1567 (*************************************************************************
1568 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\8dì
\90¬
\81i
\95¡
\90\94\8aK
\91w
\91Î
\89\9e\81j
1569 *************************************************************************)
1570 function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean;
1573 if Length(Dir) = 0 then
1574 raise Exception.Create('
\83t
\83H
\83\8b\83_
\82ª
\8dì
\90¬
\8fo
\97\88\82Ü
\82¹
\82ñ');
1575 Dir := ExcludeTrailingPathDelimiter(Dir);
1576 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
1577 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
1578 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
1581 (*************************************************************************
1582 *
\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
1583 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1584 *************************************************************************)
1585 function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1589 Result := StrTokNext(sep, Rec);
1592 (*************************************************************************
1593 *
\95¶
\8e\9a\97ñ
\82©
\82ç
\83g
\81[
\83N
\83\93\82Ì
\90Ø
\82è
\8fo
\82µ
1594 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1595 *************************************************************************)
1596 function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1603 if Len >= Pos then begin
1604 while (Pos <= Len) and (Str[Pos] in sep) do begin
1608 while (Pos<= Len) and not (Str[Pos] in sep) do begin
1609 if IsDBCSLeadByte(Byte(Str[Pos])) then begin
1614 Result := Copy(Str, I, Pos - I);
1615 while (Pos <= Len) and (Str[Pos] in sep) do begin//
\82±
\82ê
\82Í
\82¨
\8dD
\82Ý
1622 (*************************************************************************
1623 *
\83t
\83@
\83C
\83\8b\83T
\83C
\83Y
\8eæ
\93¾
1624 *************************************************************************)
1625 function TGikoSys.GetFileSize(FileName : string): longint;
1630 if not FileExists(FileName) then begin
1634 Assign(F, FileName);
1636 Result := FileSize(F);
1643 (*************************************************************************
1644 *
\83t
\83@
\83C
\83\8b\8ds
\90\94\8eæ
\93¾
1645 *************************************************************************)
1646 function TGikoSys.GetFileLineCount(FileName : string): longint;
1650 sl := TStringList.Create;
1653 sl.LoadFromFile(FileName);
1664 (*************************************************************************
1665 *
\83X
\83\8c\83b
\83h
\83t
\83@
\83C
\83\8b\82©
\82ç
\8ew
\92è
\8ds
\82ð
\8eæ
\93¾
1666 *************************************************************************)
1667 function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string;
1669 fileTmp : TStringList;
1672 if FileExists(FileName) then begin
1673 fileTmp := TStringList.Create;
1676 fileTmp.LoadFromFile( FileName );
1677 if ( Line >= 1 ) and ( Line < fileTmp.Count + 1 ) then begin
1678 Result := fileTmp.Strings[ Line-1 ];
1681 //on EFOpenError do Result := '';
1689 (*************************************************************************
1690 *
\83V
\83X
\83e
\83\80\83\81\83j
\83\85\81[
\83t
\83H
\83\93\83g
\82Ì
\91®
\90«
\82ð
\8eæ
\93¾
1691 *************************************************************************)
1692 procedure TGikoSys.MenuFont(Font: TFont);
1695 nm: NONCLIENTMETRICS;
1697 nm.cbSize := sizeof(NONCLIENTMETRICS);
1699 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0);
1700 lf := nm.lfMenuFont;
1702 Font.Name := lf.lfFaceName;
1703 Font.Height := lf.lfHeight;
1705 if lf.lfWeight >= 700 then
1706 Font.Style := Font.Style + [fsBold];
1707 if lf.lfItalic = 1 then
1708 Font.Style := Font.Style + [fsItalic];
1711 (*************************************************************************
1713 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1714 *************************************************************************)
1715 function TGikoSys.RemoveToken(var s: string; delimiter: string): string;
1719 p := AnsiPos(delimiter, s);
1723 Result := Copy(s, 1, p - 1);
1724 s := Copy(s, Length(Result) + Length(delimiter) + 1, Length(s));
1727 (*************************************************************************
1729 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1730 *************************************************************************)
1731 function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string;
1736 for i := 0 to index do
1737 Result := RemoveToken(s, delimiter);
1740 (*************************************************************************
1742 *************************************************************************)
1743 function TGikoSys.DeleteLink(const s: string): string;
1753 s1 := GetTokenIndex(s, '<a href="', i);
1754 s2 := GetTokenIndex(s, '<a href="', i + 1);
1756 idx := Pos('">', s1);
1758 Delete(s1, 1, idx + 1);
1759 idx := Pos('">', s2);
1761 Delete(s2, 1, idx + 1);
1763 Result := Result + s1 + s2;
1772 //
\83C
\83\93\83f
\83b
\83N
\83X
\96¢
\8dX
\90V
\83o
\83b
\83t
\83@
\82ð
\83t
\83\89\83b
\83V
\83\85\81I
1773 {procedure TGikoSys.FlashExitWrite;
1777 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
1778 for i := 0 to FExitWrite.Count - 1 do
1779 WriteThreadDat(FExitWrite[i]);
1783 (*************************************************************************
1784 *
\83X
\83\8c\96¼
\82È
\82Ç
\82ð
\92Z
\82¢
\96¼
\91O
\82É
\95Ï
\8a·
\82·
\82é
1786 *************************************************************************)
1787 function TGikoSys.GetShortName(const LongName: string; ALength: integer): string;
1789 ERASECHAR : array [1..39] of string =
1790 ('
\81\99','
\81\9a','
\81¡','
\81 ','
\81\9f','
\81\9e','
\81Q','
\81\94','
\81£','
\81¥',
1791 '
\81¢','
\81¤','
\81\9c','
\81\9b','
\81\9d','
\81y','
\81z','
\81ô','
\81s','
\81t',
1792 '
\81g','
\81h','
\81k','
\81l','
\81e','
\81f','
\81\83','
\81\84','
\81á','
\81â',
1793 '
\81o','
\81p','
\81q','
\81r','
\81w','
\81x','
\81¬','
\81c', '
\81@');
1795 Chr : array [0..255] of char;
1799 s := Trim(LongName);
1800 if (Length(s) <= ALength) then begin
1804 for i := Low(ERASECHAR) to High(ERASECHAR) do begin
1805 S := StringReplace(S, ERASECHAR[i], '', [rfReplaceAll]);
1807 if (Length(S) <= ALength) then begin
1810 Windows.LCMapString(
1811 GetUserDefaultLCID(),
1819 S := Copy(S,1,ALength);
1821 if (ByteType(S, Length(S)) = mbLeadByte ) then begin
1822 S := Copy(S, 1, Length(S) - 1);
1832 (*************************************************************************
1835 *************************************************************************)
1836 function TGikoSys.ConvRes(const Body, Bbs, Key,
1837 ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
1841 FIndexFrom : integer;
1848 ZN = '
\82O
\82P
\82Q
\82R
\82S
\82T
\82U
\82V
\82W
\82X
\81|';
1862 procedure Add(IndexFrom, IndexTo: integer; const No: string);
1867 FIndex.FIndexFrom := IndexFrom;
1868 FIndex.FIndexTo := IndexTo;
1872 function ChooseString(const Text, Separator: string; Index: integer): string;
1878 for i := 0 to Index - 1 do begin
1879 if (AnsiPos(Separator, S) = 0) then S := ''
1880 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
1882 p := AnsiPos(Separator, S);
1883 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
1892 List:= TList.Create;
1898 b := ByteType(s, i);
1900 mbSingleByte : begin
1901 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1902 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1910 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1911 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
1917 if (not sw) and (Copy(s,i,4) = GT) then begin
1918 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1926 if ((not sw) and (Copy(s,i,1) = ',')) or
1927 ((not sw) and (Copy(s,i,1) = '=')) then begin
1928 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
1929 ((Chk) and (oc = '')) or
1930 ((not Chk) and (al)) then
1940 if (AnsiPos(sx, SN) > 0) then begin
1943 if (No <> '') and (No <> '-') then begin
1956 if Copy(s,i,1) = '<' then oc := '';
1957 oc := oc + Copy(s,i,1);
1963 if (not sw) and (Copy(s,i,4) = '
\81\84\81\84') then begin
1969 if (not sw) and (Copy(s,i,2) = '
\81\84') then begin
1977 if (AnsiPos(sx, ZN) > 0) then begin
1978 No := No + ZenToHan(sx);
1980 if (No <> '') and (No <> '-') and (No <> '
\81|') then begin
1995 if (i > Length(Body)) then begin
1997 if (No <> '') then Add(sp, i, No);
2002 for i := List.Count - 1 downto 0 do begin
2003 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
2004 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
2005 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
2007 st := PIndex(List[i]).FNo;
2008 et := PIndex(List[i]).FNo;
2010 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
2011 Format('<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">',
2012 [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
2013 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
2014 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
2015 Dispose(PIndex(List[i]));
2021 (*************************************************************************
2022 *
\91S
\8ap
\81¨
\94¼
\8ap
2024 *************************************************************************)
2025 function TGikoSys.ZenToHan(const s: string): string;
2027 Chr: array [0..255] of char;
2029 Windows.LCMapString(
2030 GetUserDefaultLCID(),
2032 LCMAP_HALFWIDTH or LCMAP_KATAKANA or LCMAP_LOWERCASE,
2041 (*************************************************************************
2042 *
\91S
\8ap
\94¼
\8ap
\82Ð
\82ç
\82ª
\82È
\82©
\82½
\82©
\82È
\82ð
\8bæ
\95Ê
\82µ
\82È
\82¢
\90¦
\82¢Pos
2043 *************************************************************************)
2044 function TGikoSys.VaguePos(const Substr, S: string): Integer;
2046 Result := Pos(ZenToHan(Substr), ZenToHan(S));
2049 function TGikoSys.BoolToInt(b: Boolean): Integer;
2051 Result := IfThen(b, 1, 0);
2054 function TGikoSys.IntToBool(i: Integer): Boolean;
2059 //gzip
\82Å
\88³
\8fk
\82³
\82ê
\82½
\82Ì
\82ð
\96ß
\82·
2060 function TGikoSys.GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
2064 GZipStream: TGzipDecompressStream;
2065 TextStream: TStringStream;
2066 buf: array[0..BUF_SIZE - 1] of Byte;
2072 TextStream := TStringStream.Create('');
2074 //
\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¢)
2075 // if LowerCase(Trim(ContentEncoding)) = 'gzip' then begin
2076 if AnsiPos('gzip', LowerCase(Trim(ContentEncoding))) > 0 then begin
2077 ResStream.Position := 0;
2078 GZipStream := TGzipDecompressStream.Create(TextStream);
2081 FillChar(buf, BUF_SIZE, 0);
2082 cnt := ResStream.Read(buf, BUF_SIZE);
2084 GZipStream.Write(buf, BUF_SIZE);
2090 ResStream.Position := 0;
2092 FillChar(buf, BUF_SIZE, 0);
2093 cnt := ResStream.Read(buf, BUF_SIZE);
2095 TextStream.Write(buf, BUF_SIZE);
2099 //NULL
\95¶
\8e\9a\82ð"*"
\82É
\82·
\82é
2100 s := TextStream.DataString;
2102 while (i > 0) and (s[i] = #0) do
2107 while i <> 0 do begin
2117 procedure TGikoSys.LoadKeySetting(ActionList: TActionList);
2119 STD_SEC = 'KeySetting';
2125 SecList: TStringList;
2126 Component: TComponent;
2128 if not FileExists(GetConfigDir + KEY_SETTING_FILE_NAME) then
2130 SecList := TStringList.Create;
2131 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
2133 ini.ReadSection(STD_SEC, SecList);
2134 for i := 0 to SecList.Count - 1 do begin
2135 ActionName := SecList[i];
2136 ActionKey := ini.ReadInteger(STD_SEC, ActionName, -1);
2137 if ActionKey <> -1 then begin
2138 Component := ActionList.Owner.FindComponent(ActionName);
2139 if TObject(Component) is TAction then begin
2140 TAction(Component).ShortCut := ActionKey;
2150 procedure TGikoSys.SaveKeySetting(ActionList: TActionList);
2152 STD_SEC = 'KeySetting';
2157 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
2159 for i := 0 to ActionList.ActionCount - 1 do begin
2160 if ActionList.Actions[i].Tag = -1 then
2162 ini.WriteInteger(STD_SEC, ActionList.Actions[i].Name, TAction(ActionList.Actions[i]).ShortCut);
2171 procedure TGikoSys.CreateProcess(const AppPath: string; const Param: string);
2173 PI: TProcessInformation;
2177 Path := '"' + AppPath + '"';
2179 Path := Path + ' ' + Param;
2181 SI.Cb := SizeOf(Si);
2182 SI.lpReserved := nil;
2183 SI.lpDesktop := nil;
2186 SI.cbReserved2 := 0;
2187 SI.lpReserved2 := nil;
2189 Windows.CreateProcess(nil,
2201 procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
2205 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2206 gbtUserApp, gbtAuto:
2207 if (Setting.URLApp) and (FileExists(Setting.URLAppFile)) then
2208 GikoSys.CreateProcess(Setting.URLAppFile, URL)
2210 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2214 function TGikoSys.HTMLDecode(const AStr: String): String;
2216 Sp, Rp, Cp, Tp: PChar;
2221 SetLength(Result, Length(AStr));
2223 Rp := PChar(Result);
2226 while Sp^ <> #0 do begin
2232 'a': if AnsiStrPos(Sp, 'amp;') = Sp then
2238 'g': if (AnsiStrPos(Sp, 'lt;') = Sp) or (AnsiStrPos(Sp, 'gt;') = Sp) then
2242 while (Sp^ <> ';') and (Sp^ <> #0) do
2249 'q': if AnsiStrPos(Sp, 'quot;') = Sp then
2257 Num := IsNumeric(Copy(Tp, 1, 1));
2258 while (Sp^ <> ';') and (Sp^ <> #0) do begin
2259 if (Num) and (not IsNumeric(Copy(Sp, 1, 1))) then
2263 SetString(S, Tp, Sp - Tp);
2268 //raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2269 //[Cp^ + Sp^, Cp - PChar(AStr)])
2279 // on E:EConvertError do
2280 // raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2281 // [Cp^ + Sp^, Cp - PChar(AStr)])
2283 SetLength(Result, Rp - PChar(Result));
2286 function TGikoSys.GetHRefText(s: string): string;
2296 Index := AnsiPos('href', LowerCase(s));
2299 s := Trim(Copy(s, Index + 4, Length(s)));
2300 s := Trim(Copy(s, 2, Length(s)));
2302 //
\8en
\82ß
\82Ì
\95¶
\8e\9a\82ª'"'
\82È
\82ç
\8eæ
\82è
\8f\9c\82
2303 if Copy(s, 1, 1) = '"' then begin
2304 s := Trim(Copy(s, 2, Length(s)));
2307 Index := AnsiPos('"', s);
2308 if Index <> 0 then begin
2309 //'"'
\82Ü
\82ÅURL
\82Æ
\82·
\82é
2310 s := Copy(s, 1, Index - 1);
2312 //'"'
\82ª
\96³
\82¯
\82ê
\82Î
\83X
\83y
\81[
\83X
\82©">"
\82Ì
\91\81\82¢
\95û
\82Ü
\82Å
\82ðURL
\82Æ
\82·
\82é
2313 Index := AnsiPos(' ', s);
2314 Index2 := AnsiPos('>', s);
2317 if Index > Index2 then
2320 s := Copy(s, 1, Index - 1)
2322 //
\82±
\82ê
\88È
\8fã
\82à
\82¤
\92m
\82ç
\82ñ
\82Ê
2328 //
\83z
\83X
\83g
\96¼
\82ª
\82Q
\82\83\82\88\82©
\82Ç
\82¤
\82©
\83`
\83F
\83b
\83N
\82·
\82é
2329 function TGikoSys.Is2chHost(Host: string): Boolean;
2331 HOST_NAME: array[0..1] of string = ('2ch.net', 'bbspink.com');
2337 OutputDebugString(pchar(HOST_NAME[0]));
2338 for i := 0 to Length(HOST_NAME) - 1 do begin
2339 // Len := Length(HOST_NAME[i]);
2340 if AnsiPos(HOST_NAME[i], Host) = (Length(Host) - Length(HOST_NAME[i]) + 1) then begin
2347 function TGikoSys.Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
2349 READ_PATH: string = '/test/read.cgi/';
2350 OLD_READ_PATH: string = '/test/read.cgi?';
2351 KAKO_PATH: string = '/kako/';
2361 Index := AnsiPos(READ_PATH, path);
2362 if Index <> 0 then begin
2363 s := Copy(path, Length(READ_PATH) + 1, Length(path));
2364 BBSID := GetTokenIndex(s, '/', 0);
2365 BBSKey := GetTokenIndex(s, '/', 1);
2368 Result := (BBSID <> '') or (BBSKey <> '');
2371 Index := AnsiPos(KAKO_PATH, path);
2372 if Index <> 0 then begin
2373 s := Copy(path, 2, Length(path));
2374 BBSID := GetTokenIndex(s, '/', 0);
2375 if (BBSID = 'log') and (GetTokenIndex(s, '/', 2) = 'kako') then
2376 BBSID := GetTokenIndex(s, '/', 1);
2377 BBSKey := ChangeFileExt(Document, '');
2378 Result := (BBSID <> '') or (BBSKey <> '');
2381 Index := AnsiPos('read.cgi?', URL);
2382 if Index <> 0 then begin
2383 SList := TStringList.Create;
2386 // s := HTMLDecode(Document);
2387 ExtractHTTPFields(['?', '&'], [], PChar(URL), SList, False);
2388 BBSID := SList.Values['bbs'];
2389 BBSKey := SList.Values['key'];
2390 Result := (BBSID <> '') or (BBSKey <> '');
2401 function TGikoSys.Parse2chURL2(URL: string): TPathRec;
2413 URL := Trim(LowerCase(URL));
2418 Result.FFirst := False;
2419 Result.FStBegin := False;
2420 Result.FToEnd := False;
2421 Result.FDone := False;
2426 FAWKStr.RegExp := 'http://.+\.(2ch\.net|bbspink\.com)/';
2427 if FAWKStr.Match(FAWKStr.ProcessEscSeq(URL), RStart, RLength) = 0 then
2429 s := Copy(URL, RStart + RLength - 1, Length(URL));
2431 //
\95W
\8f\80\8f\91\8e®
2432 //
\8dÅ
\8cã
\82Íl50, 10, 10-20, 10n, 10-20n, -10, 10-, 10n-
\82È
\82Ç
2433 //http://xxx.2ch.net/test/read.cgi/bbsid/1000000000/
2434 FAWKStr.RegExp := '/test/read.cgi/.+/[0-9]+/.*';
2435 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2436 s := Copy(s, 15, Length(s));
2438 SList := TStringList.Create;
2441 FAWKStr.RegExp := '/';
2442 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2443 Result.FBBS := SList[1];
2444 Result.FKey := SList[2];
2445 if SList.Count >= 3 then
2453 FAWKStr.LineSeparator := mcls_CRLF;
2454 FAWKStr.RegExp := '-';
2455 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) = 0 then begin
2456 Result.FFirst := True;
2458 FAWKStr.RegExp := 'l[0-9]+';
2459 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2460 Result.FFirst := True;
2462 for i := 0 to SList.Count - 1 do begin
2463 if Trim(SList[i]) = '' then begin
2465 Result.FStBegin := True;
2466 if i = (SList.Count - 1) then
2467 Result.FToEnd := True;
2468 end else if IsNumeric(SList[i]) then begin
2469 wkInt := StrToInt(SList[i]);
2470 wkMax := Max(wkMax, wkInt);
2474 wkMin := Min(wkMin, wkInt);
2475 end else if Trim(SList[i]) = 'n' then begin
2476 Result.FFirst := True;
2478 FAWKStr.RegExp := '^n[0-9]+$|^[0-9]+n$';
2479 if FAWKStr.Match(FAWKStr.ProcessEscSeq(SList[i]), RStart, RLength) > 0 then begin
2480 if Copy(SList[i], 1, 1) = 'n' then
2481 wkInt := StrToInt(Copy(SList[i], 2, Length(SList[i])))
2483 wkInt := StrToInt(Copy(SList[i], 1, Length(SList[i]) - 1));
2484 Result.FFirst := True;
2485 wkMax := Max(wkMax, wkInt);
2489 wkMin := Min(wkMin, wkInt);
2493 if Result.FStBegin and (not Result.FToEnd) then
2495 else if (not Result.FStBegin) and Result.FToEnd then
2497 else if (not Result.FStBegin) and (not Result.FToEnd) then begin
2498 Result.FSt := wkMin;
2499 Result.FTo := wkMax;
2501 //Result.FSt := wkMin;
2502 //Result.FTo := wkMax;
2508 Result.FDone := True;
2512 //
\90Vkako
\8f\91\8e®
2513 //http://server.2ch.net/ITA_NAME/kako/1000/10000/1000000000.html
2514 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+/[0-9]+\.html';
2515 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2516 SList := TStringList.Create;
2519 FAWKStr.RegExp := '/';
2520 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2521 Result.FBBS := SList[1];
2522 Result.FKey := ChangeFileExt(SList[5], '');
2523 Result.FFirst := True;
2529 Result.FDone := True;
2533 //
\8b\8ckako
\8f\91\8e®
2534 //http://server.2ch.net/ITA_NAME/kako/999/999999999.html
2535 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+\.html';
2536 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2537 SList := TStringList.Create;
2540 FAWKStr.RegExp := '/';
2541 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 5 then begin
2542 Result.FBBS := SList[1];
2543 Result.FKey := ChangeFileExt(SList[4], '');
2544 Result.FFirst := True;
2550 Result.FDone := True;
2554 //log
\8by
\82Ñlog2
\8f\91\8e®
2555 //http://server.2ch.net/log/ITA_NAME/kako/999/999999999.html
2556 //http://server.2ch.net/log2/ITA_NAME/kako/999/999999999.html
2557 FAWKStr.RegExp := '/log2?/.+/kako/[0-9]+/[0-9]+\.html';
2558 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2559 SList := TStringList.Create;
2562 FAWKStr.RegExp := '/';
2563 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2564 Result.FBBS := SList[2];
2565 Result.FKey := ChangeFileExt(SList[5], '');
2566 Result.FFirst := True;
2572 Result.FDone := True;
2577 //
\8b\8cURL
\8f\91\8e®
2578 //http://server.2ch.net/test/read.cgi?bbs=ITA_NAME&key=1000000000&st=1&to=5&nofirst=true
2579 FAWKStr.RegExp := '/test/read\.cgi\?';
2580 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2581 s := Copy(s, 16, Length(s));
2582 SList := TStringList.Create;
2585 FAWKStr.RegExp := '&';
2586 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2587 Result.FFirst := True;
2588 for i := 0 to SList.Count - 1 do begin
2589 if Pos('bbs=', SList[i]) = 1 then begin
2590 Result.FBBS := Copy(SList[i], 5, Length(SList[i]));
2591 end else if Pos('key=', SList[i]) = 1 then begin
2592 Result.FKey := Copy(SList[i], 5, Length(SList[i]));
2593 end else if Pos('st=', SList[i]) = 1 then begin
2594 wk := Copy(SList[i], 4, Length(SList[i]));
2595 if IsNumeric(wk) then
2596 Result.FSt := StrToInt(wk)
2597 else if wk = '' then
2598 Result.FStBegin := True;
2599 end else if Pos('to=', SList[i]) = 1 then begin
2600 wk := Copy(SList[i], 4, Length(SList[i]));
2601 if IsNumeric(wk) then
2602 Result.FTo := StrToInt(wk)
2603 else if wk = '' then
2604 Result.FToEnd := True;
2605 end else if Pos('nofirst=', SList[i]) = 1 then begin
2606 Result.FFirst := False;
2615 if (Result.FBBS <> '') and (Result.FKey <> '') then begin
2616 Result.FDone := True;
2622 procedure TGikoSys.ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
2632 URI := TIdURI.Create(URL);
2634 Protocol := URI.Protocol;
2637 Document := URI.Document;
2639 Bookmark := URI.Bookmark;
2645 function TGikoSys.GetVersionBuild: Integer;
2647 FixedFileInfo: PVSFixedFileInfo;
2648 VersionHandle, VersionSize: DWORD;
2649 pVersionInfo: Pointer;
2654 AppFile := Application.ExeName;
2655 VersionSize := GetFileVersionInfoSize(pChar(AppFile), VersionHandle);
2656 if VersionSize = 0 then
2658 GetMem(pVersionInfo, VersionSize);
2660 if GetFileVersionInfo(PChar(AppFile),VersionHandle,VersionSize, pVersionInfo) then
2661 if VerQueryValue(pVersionInfo, '\', Pointer(FixedFileInfo), ItemLen) then
2662 Result := LOWORD(FixedFileInfo^.dwFileVersionLS);
2664 FreeMem(pVersionInfo, VersionSize);
2669 GikoSys := TGikoSys.Create;
2672 if GikoSys <> nil then begin