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; sTitle: string; 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Ç
211 BOARD_FILE_NAME = 'board.2ch';
212 CUSTOMBOARD_FILE_NAME = 'custom.2ch';
213 KEY_SETTING_FILE_NAME = 'key.ini';
214 TEMP_FOLDER = 'Temp';
215 OUTBOX_FILE_NAME = 'outbox.ini';
216 SENT_FILE_NAME = 'sent.ini';
217 CONFIG_DIR_NAME = 'config';
218 CSS_DIR_NAME = 'css';
219 SKIN_DIR_NAME = 'skin';
220 SKIN_HEADER_FILE_NAME = 'Header.html';
221 SKIN_FOOTER_FILE_NAME = 'Footer.html';
222 SKIN_NEWRES_FILE_NAME = 'NewRes.html';
223 SKIN_RES_FILE_NAME = 'Res.html';
224 SKIN_BOOKMARK_FILE_NAME = 'Bookmark.html';
225 SKIN_NEWMARK_FILE_NAME = 'Newmark.html';
226 FOLDER_INDEX_VERSION = '1.01';
227 USER_AGENT = 'Monazilla';
228 APP_NAME = 'gikoNavi';
229 DEFAULT_NGWORD_FILE_NAME : String = 'NGword.txt';
230 NGWORDs_DIR_NAME : String = 'NGwords';
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 //
\83e
\83\93\83|
\83\89\83\8aHTML
\82ð
\8dí
\8f\9c
276 FileList := TStringList.Create;
278 GetFileList(GetTempFolder, '*.html', FileList, False, True);
279 for i := 0 to FileList.Count - 1 do begin
280 DeleteFile(FileList[i]);
288 (*************************************************************************
289 *
\95¶
\8e\9a\97ñ
\90\94\8e\9a\83`
\83F
\83b
\83N
290 *************************************************************************)
292 function TGikoSys.IsNumeric(s: string): boolean;
302 (*************************************************************************
303 *
\95¶
\8e\9a\97ñ
\95\82\93®
\8f¬
\90\94\93_
\90\94\8e\9a\83`
\83F
\83b
\83N
304 *************************************************************************)
305 function TGikoSys.IsFloat(s: string): boolean;
309 Result := TextToFloat(PChar(s), v, fvExtended);
312 (*************************************************************************
313 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
314 *************************************************************************)
315 function TGikoSys.GetBoardFileName: string;
317 Result := GetAppDir + CONFIG_DIR_NAME + '\' + BOARD_FILE_NAME;
320 (*************************************************************************
321 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
322 *************************************************************************)
323 function TGikoSys.GetCustomBoardFileName: string;
325 Result := GetAppDir + CONFIG_DIR_NAME + '\' + CUSTOMBOARD_FILE_NAME;
328 (*************************************************************************
329 *
\83e
\83\93\83|
\83\89\83\8a\83t
\83H
\83\8b\83_
\81[
\96¼
\8eæ
\93¾
330 *************************************************************************)
331 function TGikoSys.GetHtmlTempFileName: string;
333 Result := TEMP_FOLDER;
337 (*************************************************************************
338 *
\8eÀ
\8ds
\83t
\83@
\83C
\83\8b\83t
\83H
\83\8b\83_
\8eæ
\93¾
339 *************************************************************************)
340 function TGikoSys.GetAppDir: string;
342 Result := ExtractFilePath(Application.ExeName);
345 (*************************************************************************
346 *TempHtml
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
347 *************************************************************************)
348 function TGikoSys.GetTempFolder: string;
350 Result := GetAppDir + TEMP_FOLDER;
353 (*************************************************************************
354 *sent.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
355 *************************************************************************)
356 function TGikoSys.GetSentFileName: string;
358 Result := GetAppDir + SENT_FILE_NAME;
361 (*************************************************************************
362 *outbox.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
363 *************************************************************************)
364 function TGikoSys.GetOutBoxFileName: string;
366 Result := GetAppDir + OUTBOX_FILE_NAME;
369 (*************************************************************************
370 *Config
\83t
\83H
\83\8b\83_
\8eæ
\93¾
371 *************************************************************************)
372 function TGikoSys.GetConfigDir: string;
374 Result := IncludeTrailingPathDelimiter(GetAppDir + CONFIG_DIR_NAME);
377 function TGikoSys.GetStyleSheetDir: string;
379 Result := IncludeTrailingPathDelimiter(GetConfigDir + CSS_DIR_NAME);
382 function TGikoSys.GetSkinDir: string;
384 Result := IncludeTrailingPathDelimiter(GetConfigDir + SKIN_DIR_NAME);
387 function TGikoSys.GetSkinHeaderFileName: string;
389 Result := Setting.CSSFileName + SKIN_HEADER_FILE_NAME;
392 function TGikoSys.GetSkinFooterFileName: string;
394 Result := Setting.CSSFileName + SKIN_FOOTER_FILE_NAME;
397 function TGikoSys.GetSkinNewResFileName: string;
399 Result := Setting.CSSFileName + SKIN_NEWRES_FILE_NAME;
402 function TGikoSys.GetSkinResFileName: string;
404 Result := Setting.CSSFileName + SKIN_RES_FILE_NAME;
407 function TGikoSys.GetSkinBookmarkFileName: string;
409 Result := Setting.CSSFileName + SKIN_BOOKMARK_FILE_NAME;
412 function TGikoSys.GetSkinNewmarkFileName: string;
414 Result := Setting.CSSFileName + SKIN_NEWMARK_FILE_NAME;
417 (*************************************************************************
418 *URL
\82ð
\8dì
\90¬(
\83R
\83s
\83y
\97p)
419 *************************************************************************)
420 function TGikoSys.GetURL(BBSID: string; FileName: string): string;
424 Board := BoardGroup.BBS2ch.GetBoardFromBBSID(BBSID);
425 Result := UrlToServer(Board.URL) + 'test/read.cgi/' + UrlToID(Board.URL) + '/' + ChangeFileExt(FileName, '') + '/l50';
426 //http://teri.2ch.net/test/read.cgi?bbs=accuse&key=974619522&ls=50
427 //http://pc.2ch.net/test/read.cgi/tech/1003664165/l50
431 function TGikoSys.GetUserAgent: string;
433 if Dolib.Connected then begin
434 Result := Format('%s %s/%s%d%s', [
441 BETA_VERSION_BUILD]);
443 Result := Format('%s/%s %s/%s%d%s', [
451 BETA_VERSION_BUILD]);
455 (*************************************************************************
456 *
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é
\95û
\8e®
\8e\9e\8d\8f\8eæ
\93¾
457 *************************************************************************)
458 function TGikoSys.Get2chDate(aDate: TDateTime): string;
463 d1 := EncodeDate(1970, 1, 1);
464 d2 := aDate - EncodeTime(9, 0, 0, 0);
465 Result := FloatToStr(Trunc((d2 - d1) * 24 * 60 * 60));
469 function TGikoSys.IntToDateTime(val: Int64): TDateTime;
474 d1 := EncodeDate(1970, 1, 1);
475 d2 := (val * 1000) / (24 * 60 * 60 * 1000);
479 function TGikoSys.DateTimeToInt(ADate: TDateTime): Integer;
484 d := EncodeDate(1970, 1, 1);
485 c := (ADate - d) * 24 * 60 * 60;
490 (*************************************************************************
491 *Subject
\83t
\83@
\83C
\83\8bRead
492 *************************************************************************)
493 procedure TGikoSys.ReadSubjectFile(Board: TBoard);
495 ThreadItem: TThreadItem;
497 FileList: TStringList;
498 TmpFileList: TStringList;
499 // SrchRec: TSearchRec;
506 // TmpUpdate: Boolean;
509 RoundItem: TRoundItem;
514 // TmpUpdate := False;
516 FileName := Board.GetFolderIndexFileName;
517 if not FileExists(FileName) then CreateThreadDat(Board);
518 // if not FileExists(FileName) then Exit;
520 //IsLogFile
\97pDAT
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
521 FileList := TStringList.Create;
522 FileList.Sorted := True;
523 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False, False);
525 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\97pTmp
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
526 TmpFileList := TStringList.Create;
527 TmpFileList.Sorted := True;
528 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, False, False);
530 { R := FindFirst(ExtractFileDir(Board.GetFolderIndexFileName) + '\*.dat', 0, SrchRec);
532 FileList.Add(SrchRec.Name);
533 R := FindNext(SrchRec);
537 sl := TStringList.Create;
539 if FileExists(FileName) then
540 sl.LoadFromFile(FileName);
542 //
\82Q
\8ds
\96Ú
\82©
\82ç
\81i
\82P
\8ds
\96Ú
\82Í
\83o
\81[
\83W
\83\87\83\93\81j
543 for i := 1 to sl.Count - 1 do begin
544 Rec := ParseIndexLine(sl[i]);
546 ThreadItem := TThreadItem.Create;
547 ThreadItem.BeginUpdate;
548 ThreadItem.No := Rec.FNo;
549 ThreadItem.FileName := Rec.FFileName;
550 ThreadItem.Title := Rec.FTitle;
551 ThreadItem.Count := Rec.FCount;
552 ThreadItem.Size := Rec.FSize;
553 // ThreadItem.RoundNo := Rec.FRoundNo;
554 ThreadItem.RoundDate := Rec.FRoundDate;
555 ThreadItem.LastModified := Rec.FLastModified;
556 ThreadItem.Kokomade := Rec.FKokomade;
557 ThreadItem.NewReceive := Rec.FNewReceive;
558 // ThreadItem.Round := Rec.FRound;
559 ThreadItem.UnRead := Rec.FUnRead;
560 ThreadItem.ScrollTop := Rec.FScrollTop;
561 ThreadItem.AllResCount := Rec.FAllResCount;
562 ThreadItem.NewResCount := Rec.FNewResCount;
563 ThreadItem.AgeSage := Rec.FAgeSage;
564 ThreadItem.ParentBoard := Board;
566 //IsLogFile
\83`
\83F
\83b
\83N
567 ThreadItem.IsLogFile := False;
568 if FileList.Count <> 0 then begin
569 if FileList.Find(ThreadItem.FileName, Index) then begin
570 ThreadItem.IsLogFile := True;
571 FileList.Delete(Index);
575 //
\8f\84\89ñ
\83\8a\83X
\83g
\82É
\91¶
\8dÝ
\82µ
\82½
\82ç
\8f\84\89ñ
\83t
\83\89\83O
\83Z
\83b
\83g
576 if ThreadItem.IsLogFile then begin
577 idx := RoundList.Find(ThreadItem);
578 if idx <> -1 then begin
579 RoundItem := RoundList.Items[idx, grtItem];
580 ThreadItem.RoundName := RoundItem.RoundName;
581 ThreadItem.Round := True;
585 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\83`
\83F
\83b
\83N
586 if TmpFileList.Count <> 0 then begin
587 if TmpFileList.Find(ChangeFileExt(ThreadItem.FileName, '.tmp'), Index) then begin
588 ini := TMemIniFile.Create(ChangeFileExt(ThreadItem.GetThreadFileName, '.tmp'));
590 ThreadItem.RoundDate := ini.ReadDateTime('Setting', 'RoundDate', ZERO_DATE);
591 ThreadItem.LastModified := ini.ReadDateTime('Setting', 'LastModified', ZERO_DATE);
592 ThreadItem.Size := ini.ReadInteger('Setting', 'Size', 0);
593 ThreadItem.Count := ini.ReadInteger('Setting', 'Count', 0);
594 ThreadItem.NewReceive := ini.ReadInteger('Setting', 'NewReceive', 0);
595 ThreadItem.Round := ini.ReadBool('Setting', 'Round', False);
596 ThreadItem.UnRead := False;//ini.ReadBool('Setting', 'UnRead', False);
597 ThreadItem.ScrollTop := ini.ReadInteger('Setting', 'ScrollTop', 0);
598 ThreadItem.AllResCount := ini.ReadInteger('Setting', 'AllResCount', 0);
599 ThreadItem.NewResCount := ini.ReadInteger('Setting', 'NewResCount', 0);
600 ThreadItem.AgeSage := TGikoAgeSage(ini.ReadInteger('Setting', 'AgeSage', Ord(gasNone)));
604 TmpFileList.Delete(Index);
608 ThreadItem.EndUpdate;
609 Board.Add(ThreadItem);
611 // if (ThreadItem.IsLogFile) and (ThreadItem.Count > ThreadItem.Kokomade) then
612 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));
623 ThreadItem := TThreadItem.Create;
624 ThreadItem.No := Board.Count + 1;
625 ThreadItem.FileName := FileList[i];
626 ThreadItem.Title := ResRec.FTitle;
627 ThreadItem.Count := GetFileLineCount(FileName);
628 ThreadItem.AllResCount := ThreadItem.Count;
629 ThreadItem.NewResCount := 0;
630 ThreadItem.Size := 0;
631 ThreadItem.RoundDate := ZERO_DATE;
632 ThreadItem.LastModified := ZERO_DATE;
633 ThreadItem.Kokomade := -1;
634 ThreadItem.NewReceive := 0;
635 ThreadItem.ParentBoard := Board;
636 ThreadItem.IsLogFile := True;
637 ThreadItem.Round := False;
638 ThreadItem.UnRead := False;
639 ThreadItem.ScrollTop := 0;
640 ThreadItem.AgeSage := gasNone;
641 Board.Add(ThreadItem);
648 Board.IsThreadDatRead := True;
651 (*************************************************************************
652 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X
\83t
\83@
\83C
\83\8b(Folder.idx)
\8dì
\90¬
653 *************************************************************************)
654 procedure TGikoSys.CreateThreadDat(Board: TBoard);
658 SubjectList: TStringList;
664 if not FileExists(Board.GetSubjectFileName) then Exit;
665 FileName := Board.GetFolderIndexFileName;
667 SubjectList := TStringList.Create;
669 SubjectList.LoadFromFile(Board.GetSubjectFileName);
670 sl := TStringList.Create;
673 sl.Add(FOLDER_INDEX_VERSION);
674 for i := 0 to SubjectList.Count - 1 do begin
675 Rec := DivideSubject(SubjectList[i]);
677 if (Trim(Rec.FFileName) = '') or (Trim(Rec.FTitle) = '') then
680 s := Format('%x', [cnt]) + #1 //
\94Ô
\8d\86
681 + Rec.FFileName + #1 //
\83t
\83@
\83C
\83\8b\96¼
682 + Rec.FTitle + #1 //
\83^
\83C
\83g
\83\8b
683 + Format('%x', [Rec.FCount]) + #1 //
\83J
\83E
\83\93\83g
684 + Format('%x', [0]) + #1 //size
685 + Format('%x', [0]) + #1 //RoundDate
686 + Format('%x', [0]) + #1 //LastModified
687 + Format('%x', [0]) + #1 //Kokomade
688 + Format('%x', [0]) + #1 //NewReceive
689 + '0' + #1 //
\96¢
\8eg
\97p
690 + Format('%x', [0]) + #1 //UnRead
691 + Format('%x', [0]) + #1 //ScrollTop
692 + Format('%x', [Rec.FCount]) + #1 //AllResCount
693 + Format('%x', [0]) + #1 //NewResCount
694 + Format('%x', [0]); //AgeSage
699 sl.SaveToFile(FileName);
708 (*************************************************************************
709 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X(Thread.dat)
\8f\91\82«
\8d\9e\82Ý
711 *************************************************************************)
712 procedure TGikoSys.WriteThreadDat(Board: TBoard);
714 // Values: array[Boolean] of string = ('0', '1');
720 FileList: TStringList;
722 if not Board.IsThreadDatRead then
724 FileName := Board.GetFolderIndexFileName;
725 ForceDirectoriesEx(Board.ParentCategory.ParentBBS2ch.GetLogFolder + Board.BBSID);
727 sl := TStringList.Create;
729 sl.Add(FOLDER_INDEX_VERSION);
730 for i := 0 to Board.Count - 1 do begin
731 if Board.Items[i].No = 0 then
732 Board.Items[i].No := i + 1;
734 s := Format('%x', [Board.Items[i].No]) + #1
735 + Board.Items[i].FileName + #1
736 + Board.Items[i].Title + #1
737 + Format('%x', [Board.Items[i].Count]) + #1
738 + Format('%x', [Board.Items[i].Size]) + #1
739 + Format('%x', [DateTimeToInt(Board.Items[i].RoundDate)]) + #1
740 + Format('%x', [DateTimeToInt(Board.Items[i].LastModified)]) + #1
741 + Format('%x', [Board.Items[i].Kokomade]) + #1
742 + Format('%x', [Board.Items[i].NewReceive]) + #1
743 + '0' + #1 //
\96¢
\8eg
\97p
744 + Format('%x', [BoolToInt(Board.Items[i].UnRead)]) + #1
745 + Format('%x', [Board.Items[i].ScrollTop]) + #1
746 + Format('%x', [Board.Items[i].AllResCount]) + #1
747 + Format('%x', [Board.Items[i].NewResCount]) + #1
748 + Format('%x', [Ord(Board.Items[i].AgeSage)]);
753 sl.SaveToFile(FileName);
755 FileList := TStringList.Create;
757 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', FileList, False, True);
758 for i := 0 to FileList.Count - 1 do begin
759 DeleteFile(FileList[i]);
769 function TGikoSys.ParseIndexLine(Line: string): TIndexRec;
774 for i := 0 to 14 do begin
775 s := GetTokenIndex(Line, #1, i);
777 0: Result.FNo := StrToIntDef('$' + s, 0);
778 1: Result.FFileName := s;
779 2: Result.FTitle := s;
780 3: Result.FCount := StrToIntDef('$' + s, 0);
781 4: Result.FSize := StrToIntDef('$' + s, 0);
782 5: Result.FRoundDate := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
783 6: Result.FLastModified := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
784 7: Result.FKokomade := StrToIntDef('$' + s, -1);
785 8: Result.FNewReceive := StrToIntDef('$' + s, 0);
787 10: Result.FUnRead := IntToBool(StrToIntDef('$' + s, 0));
788 11: Result.FScrollTop := StrToIntDef('$' + s, 0);
789 12: Result.FAllResCount := StrToIntDef('$' + s, 0);
790 13: Result.FNewResCount := StrToIntDef('$' + s, 0);
791 14: Result.FAgeSage := TGikoAgeSage(StrToIntDef('$' + s, 0));
796 //
\8ew
\92è
\83t
\83H
\83\8b\83_
\93à
\82Ì
\8ew
\92è
\83t
\83@
\83C
\83\8b\88ê
\97\97\82ð
\8eæ
\93¾
\82·
\82é
797 // ListFiles('c:\', '*.txt', list, True);
798 procedure TGikoSys.GetFileList(Path: string; Mask: string; List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
801 SearchRec : TSearchRec;
804 Path := IncludeTrailingPathDelimiter(Path);
805 rc := FindFirst(Path + '*.*', faAnyfile, SearchRec);
807 while rc = 0 do begin
808 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
809 s := Path + SearchRec.Name;
810 //if (SearchRec.Attr and faDirectory > 0) then
811 // s := IncludeTrailingPathDelimiter(s)
813 if (SearchRec.Attr and faDirectory = 0) and (MatchesMask(s, Mask)) then
817 List.Add(SearchRec.Name);
818 if SubDir and (SearchRec.Attr and faDirectory > 0) then
819 GetFileList(s, Mask, List, True, IsPathAdd);
821 rc := FindNext(SearchRec);
824 SysUtils.FindClose(SearchRec);
828 //
\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é
829 procedure TGikoSys.GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
832 SearchRec : TSearchRec;
835 Path := IncludeTrailingPathDelimiter(Path);
836 rc := FindFirst(Path + '*.*', faDirectory, SearchRec);
838 while rc = 0 do begin
839 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
840 s := Path + SearchRec.Name;
841 //if (SearchRec.Attr and faDirectory > 0) then
842 // s := IncludeTrailingPathDelimiter(s)
844 if (SearchRec.Attr and faDirectory > 0) and (MatchesMask(s, Mask)) then
845 List.Add( IncludeTrailingPathDelimiter( s ) );
846 if SubDir and (SearchRec.Attr and faDirectory > 0) then
847 GetDirectoryList(s, Mask, List, True);
849 rc := FindNext(SearchRec);
852 SysUtils.FindClose(SearchRec);
856 //
\83X
\83L
\83\93\82ð
\93Ç
\82Ý
\8d\9e\82Ý
\81A
\92l
\82ð
\92u
\8a·
\82·
\82é
857 function TGikoSys.LoadFromSkin(
859 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.ParentCategory <> nil then
875 Skin.Text := StringReplace( Skin.Text, '<BBSNAME/>', ThreadItem.ParentBoard.ParentCategory.ParentBBS2ch.Title, [rfReplaceAll] );
876 if ThreadItem.ParentBoard.BBSID <> '' then
877 Skin.Text := StringReplace( Skin.Text, '<THREADURL/>', GikoSys.GetURL(ThreadItem.ParentBoard.BBSID, ThreadItem.FileName), [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/>', sTitle, [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.ParentCategory <> nil then
896 Skin.Text := StringReplace( Skin.Text, '&BBSNAME', ThreadItem.ParentBoard.ParentCategory.ParentBBS2ch.Title, [rfReplaceAll] );
897 if ThreadItem.ParentBoard.BBSID <> '' then
898 Skin.Text := StringReplace( Skin.Text, '&THREADURL', GikoSys.GetURL(ThreadItem.ParentBoard.BBSID, ThreadItem.FileName), [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', sTitle, [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;
970 UserOptionalStyle: string;
976 function LoadSkin( fileName: string ): string;
978 Result := LoadFromSkin( fileName, ThreadItem, sTitle, SizeByte );
980 function ReplaceRes( skin: string ): string;
982 Result := SkinedRes( skin, Res, No );
985 ShortDayNames[1] := '
\93ú'; ShortDayNames[2] := '
\8c\8e';
986 ShortDayNames[3] := '
\89Î'; ShortDayNames[4] := '
\90\85';
987 ShortDayNames[5] := '
\96Ø'; ShortDayNames[6] := '
\8bà';
988 ShortDayNames[7] := '
\93y';
990 BBSID := ThreadItem.ParentBoard.BBSID;
991 NewReceiveNo := ThreadItem.NewReceive;
992 ReadList := TStringList.Create;
994 if ThreadItem.IsLogFile then begin
995 FileName := ThreadItem.GetThreadFileName;
996 ReadList.LoadFromFile(FileName);
997 FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
998 FAbon.Execute(ReadList); //
\82 \82Ú
\81`
\82ñ
\82µ
\82Ä
999 FSelectResFilter.Execute(ReadList); //
\83\8c\83X
\82Ì
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\82·
\82é
1000 Res := DivideStrLine(ReadList[0]);
1001 Res.FTitle := StringReplace(Res.FTitle, '
\81\97\81M', ',', [rfReplaceAll]);
1002 sTitle := Res.FTitle;
1004 sTitle := StringReplace(ThreadItem.Title, '
\81\97\81M', ',', [rfReplaceAll]);
1006 SaveList := TStringList.Create;
1009 doc.charset := 'Shift_JIS';
1011 //
\83t
\83H
\83\93\83g
\82â
\83T
\83C
\83Y
\82Ì
\90Ý
\92è
1012 if Length( GikoSys.Setting.BrowserFontName ) > 0 then
1013 UserOptionalStyle := UserOptionalStyle +
1014 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
1015 if GikoSys.Setting.BrowserFontSize <> 0 then
1016 UserOptionalStyle := UserOptionalStyle +
1017 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
1018 if GikoSys.Setting.BrowserFontColor <> -1 then
1019 UserOptionalStyle := UserOptionalStyle +
1020 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
1021 if GikoSys.Setting.BrowserBackColor <> -1 then
1022 UserOptionalStyle := UserOptionalStyle +
1023 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
1024 case GikoSys.Setting.BrowserFontBold of
1025 -1: UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
1026 1: UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;';
1028 case GikoSys.Setting.BrowserFontItalic of
1029 -1: UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
1030 1: UserOptionalStyle := UserOptionalStyle + 'font-style:italic;';
1033 CSSFileName := GetStyleSheetDir + Setting.CSSFileName;
1034 if GikoSys.Setting.UseCSS and
1035 (Pos(GetSkinDir, Setting.CSSFileName) > 0) and
1036 FileExists( GetSkinHeaderFileName ) then begin
1037 //
\83X
\83L
\83\93\8eg
\97p
1038 //
\83X
\83L
\83\93\82Ì
\90Ý
\92è
1040 SkinHeader := LoadSkin( GetSkinHeaderFileName );
1041 if Length( UserOptionalStyle ) > 0 then
1042 SkinHeader := StringReplace( SkinHeader, '</head>',
1043 '<style type="text/css">body {' + UserOptionalStyle + '}</style></head>', [rfReplaceAll] );
1044 SaveList.Add( SkinHeader );
1048 SkinNewRes := LoadSkin( GetSkinNewResFileName );
1052 SkinRes := LoadSkin( GetSkinResFileName );
1056 SaveList.Add('<a name="top"></a>');
1058 for i := 0 to ReadList.Count - 1 do begin
1059 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1062 if (Trim(ReadList[i]) <> '') then begin
1063 No := IntToStr(i + 1);
1065 Res := DivideStrLine(ReadList[i]);
1066 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1068 if Res.FType = glt2chOld then begin
1069 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
1070 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
1071 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
1074 Res.FBody := AddAnchorTag(Res.FBody);
1075 if Res.FName = '' then
1076 Res.FName := ' ';
1078 //
\90V
\92\85\83}
\81[
\83N
1079 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1081 SaveList.Add( LoadSkin( GetSkinNewmarkFileName ) );
1083 SaveList.Add( '<a name="new"></a>' );
1087 if NewReceiveNo <= (i + 1) then
1088 //
\90V
\92\85\83\8c\83X
1089 SaveList.Add( ReplaceRes( SkinNewRes ) )
1091 //
\92Ê
\8fí
\82Ì
\83\8c\83X
1092 SaveList.Add( ReplaceRes( SkinRes ) );
1095 if ThreadItem.Kokomade = (i + 1) then begin
1096 //
\82±
\82±
\82Ü
\82Å
\93Ç
\82ñ
\82¾
1098 SaveList.Add( LoadSkin( GetSkinBookmarkFileName ) );
1100 SaveList.Add( '<a name="koko"></a>' );
1104 SizeByte := SizeByte + Length( SaveList.Text );
1105 doc.Write(SaveList.Text);
1108 SaveList.Add('<a name="bottom"></a>');
1109 SizeByte := SizeByte + Length( SaveList.Text );
1110 //
\83X
\83L
\83\93(
\83t
\83b
\83^)
1112 SaveList.Add( LoadSkin( GetSkinFooterFileName ) );
1115 doc.Write(SaveList.Text);
1117 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
1119 //CSSFileName := GetAppDir + CSS_FILE_NAME;
1120 // SaveList.Add('<html lang="ja"><head>');
1121 SaveList.Add('<html><head>');
1122 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1123 SaveList.Add('<title>' + sTitle + '</title>');
1124 SaveList.Add('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
1125 if Length( UserOptionalStyle ) > 0 then
1126 SaveList.Add('<style type="text/css">body {' + UserOptionalStyle + '}</style>');
1127 SaveList.Add('</head>');
1128 SaveList.Add('<body>');
1129 SaveList.Add('<a name="top"></a>');
1130 SaveList.Add('<div class="title">' + sTitle + '</div>');
1131 doc.Write(SaveList.Text);
1133 //Application.ProcessMessages;
1134 for i := 0 to ReadList.Count - 1 do begin
1135 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1138 if (Trim(ReadList[i]) <> '') then begin
1139 No := IntToStr(i + 1);
1140 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1141 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>');
1143 Res := DivideStrLine(ReadList[i]);
1144 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1145 Res.FBody := AddAnchorTag(Res.FBody);
1146 if Res.FName = '' then
1147 Res.FName := ' ';
1148 if Res.FMailTo = '' then
1149 SaveList.Add('<a name="' + No + '"></a>'
1150 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span> '
1151 + '<span class="name_label">
\96¼
\91O
\81F</span> '
1152 + '<span class="name"><b>' + Res.FName + '</b></span> '
1153 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span> '
1154 + '<span class="date">' + Res.FDateTime+ '</span></div>'
1155 + '<div class="mes">' + Res.FBody + ' </div>')
1156 else if GikoSys.Setting.ShowMail then
1157 SaveList.Add('<a name="' + No + '"></a>'
1158 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1159 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1160 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1161 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
1162 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1163 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1164 + '<div class="mes">' + Res.FBody + ' </div>')
1166 SaveList.Add('<a name="' + No + '"></a>'
1167 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1168 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1169 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1170 + '<b>' + Res.FName + '</b></a>'
1171 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1172 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1173 + '<div class="mes">' + Res.FBody + ' </div>');
1174 if ThreadItem.Kokomade = (i + 1) then begin
1175 SaveList.Add('<a name="koko"></a><div class="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</div>');
1179 doc.Write(SaveList.Text);
1183 SaveList.Add('<a name="bottom"></a>');
1184 SaveList.Add('</body></html>');
1185 SaveList.Add('<a name="last"></a>');
1186 SaveList.Add('</body></html>');
1188 doc.Write(SaveList.Text);
1191 // SaveList.Add('<html lang="ja"><head>');
1192 SaveList.Add('<html><head>');
1193 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1194 SaveList.Add('<title>' + sTitle + '</title></head>');
1195 SaveList.Add('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1196 SaveList.Add('<a name="top"></a>');
1197 SaveList.Add('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1198 SaveList.Add('<dl>');
1199 doc.Write(SaveList.Text);
1201 //Application.ProcessMessages;
1202 for i := 0 to ReadList.Count - 1 do begin
1203 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1206 if (Trim(ReadList[i]) <> '') then begin
1207 No := IntToStr(i + 1);
1209 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1210 SaveList.Add('</dl>');
1211 SaveList.Add('<a name="new"></a>');
1212 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>');
1213 SaveList.Add('<dl>');
1215 Res := DivideStrLine(ReadList[i]);
1216 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1217 if Res.FType = glt2chOld then begin
1218 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
1219 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
1220 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
1222 Res.FBody := AddAnchorTag(Res.FBody);
1223 if Res.FMailTo = '' then
1224 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>')
1225 else if GikoSys.Setting.ShowMail then
1226 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>')
1228 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>');
1229 if ThreadItem.Kokomade = (i + 1) then begin
1230 SaveList.Add('</dl>');
1231 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>');
1232 SaveList.Add('<dl>');
1235 //if SaveList.Count > 50 then begin
1236 doc.Write(SaveList.Text);
1238 //Application.ProcessMessages;
1241 SaveList.Add('</dl>');
1242 SaveList.Add('<a name="bottom"></a>');
1243 SaveList.Add('</body></html>');
1244 doc.Write(SaveList.Text);
1254 (*************************************************************************
1255 *http://
\82Ì
\95¶
\8e\9a\97ñ
\82ðanchor
\83^
\83O
\95t
\82«
\82É
\82·
\82é
\81B
1256 *************************************************************************)
1257 function TGikoSys.AddAnchorTag(s: string): string;
1259 URL_CHAR: string = '0123456789'
1260 + 'abcdefghijklmnopqrstuvwxyz'
1261 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1262 + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
1264 wkIdx: array[0..9] of Integer;
1273 wkIdx[0] := AnsiPos('http://', s);
1274 wkIdx[1] := AnsiPos('ttp://', s);
1275 wkIdx[2] := AnsiPos('tp://', s);
1276 wkIdx[3] := AnsiPos('ms-help://', s);
1277 wkIdx[4] := AnsiPos('p://', s);
1278 wkIdx[5] := AnsiPos('https://', s);
1279 wkIdx[6] := AnsiPos('www.', s);
1280 wkIdx[7] := AnsiPos('ftp://', s);
1281 wkIdx[8] := AnsiPos('news://', s);
1282 wkIdx[9] := AnsiPos('rtsp://', s);
1286 if wkIdx[i] <> 0 then idx := Min(wkIdx[i], idx);
1288 if idx = MaxInt then begin
1289 //
\83\8a\83\93\83N
\82ª
\96³
\82¢
\82æ
\81B
1290 Result := Result + s;
1294 if (idx > 1) and (Copy(s, idx - 1, 1) = '"') then begin
1295 //
\8aù
\82É
\83\8a\83\93\83N
\83^
\83O
\82ª
\82Â
\82¢
\82Ä
\82¢
\82é
\82Á
\82Û
\82¢
\82Æ
\82«
\82Í
\83\80\83V
1296 Result := Result + Copy(s, 0, idx + Length('http://') - 1);
1297 s := Copy(s, idx + Length('http://'), length(s));
1301 Result := Result + Copy(s, 0, idx - 1);
1303 s := Copy(s, idx, length(s));
1305 for i := 0 to Length(s) do begin
1306 idx := AnsiPos(s[i + 1], URL_CHAR);
1307 if (idx = 0) or (i = (Length(s))) then begin
1308 //URL
\82¶
\82á
\82È
\82¢
\95¶
\8e\9a\94
\8c©
\81I
\82Æ
\82©
\81A
\95¶
\8e\9a\82ª
\82È
\82
\82È
\82Á
\82½
\81B
1309 url := Copy(s, 0, i);
1311 if AnsiPos('ttp://', url) = 1 then
1313 else if AnsiPos('tp://', url) = 1 then
1315 else if AnsiPos('p://', url) = 1 then
1317 else if AnsiPos('www.', url) = 1 then
1318 href := 'http://' + url
1321 Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
1322 s := Copy(s, i + 1, Length(s));
1329 (*************************************************************************
1330 *
\83T
\83u
\83W
\83F
\83N
\83g
\88ê
\8ds
\82ð
\95ª
\8a\84
1331 *************************************************************************)
1332 function TGikoSys.DivideSubject(Line: string): TSubjectRec;
1342 if Pos('<>', Line) = 0 then
1347 Result.FFileName := GetTokenIndex(Line, Delim, 0);
1348 Result.FTitle := GetTokenIndex(Line, Delim, 1);
1350 ws := Trim(Result.FTitle);
1352 if Copy(ws, Length(ws), 1) = ')' then begin
1355 end else if Copy(ws, Length(ws), 1) = '
\81j' then begin
1358 end else if Copy(ws, Length(ws), 1) = '<' then begin
1363 for i := Length(ws) - 1 downto 1 do begin
1364 if ws[i] = LeftK then begin
1365 ws := Copy(ws, i + 1, Length(ws) - i - 1);
1366 if IsNumeric(ws) then
1367 Result.FCount := StrToInt(ws);
1368 Result.FTitle := Trim(StringReplace(Result.FTitle, LeftK + ws + RightK, '', [rfReplaceAll]));
1374 (*************************************************************************
1375 * dat
\83t
\83@
\83C
\83\8b\82Ì
\88ê
\83\89\83C
\83\93\82ð
\95ª
\89ð
1376 *************************************************************************)
1377 function TGikoSys.DivideStrLine(Line: string): TResRec;
1382 if Pos('<>', Line) = 0 then begin
1384 Result.FType := glt2chOld;
1387 Result.FType := glt2chNew;
1389 Result.FName := Trim(GetTokenIndex(Line, Delim, 0));
1390 Result.FMailTo := Trim(GetTokenIndex(Line, Delim, 1));
1391 Result.FDateTime := Trim(GetTokenIndex(Line, Delim, 2));
1392 bufBody := Trim(GetTokenIndex(Line, Delim, 3));
1393 if bufbody = '' then begin
1394 Insert(' ',bufbody, 1);
1396 Result.FBody := bufBody;
1397 Result.FTitle := Trim(GetTokenIndex(Line, Delim, 4));
1401 (*************************************************************************
1402 * URL
\82©
\82çBBSID
\82ð
\8eæ
\93¾
1403 *************************************************************************)
1404 function TGikoSys.UrlToID(url: string): string;
1411 if url = '' then Exit;
1413 url := Copy(url, 0, Length(url) - 1);
1414 for i := Length(url) downto 0 do begin
1415 if url[i] = '/' then begin
1416 Result := Copy(url, i + 1, Length(url));
1422 (*************************************************************************
1423 *URL
\82©
\82çBBSID
\88È
\8aO
\82Ì
\95\94\95ª(http://teri.2ch.net/)
\82ð
\8eæ
\93¾
1424 *************************************************************************)
1425 function TGikoSys.UrlToServer(url: string): string;
1432 wsURL := Trim(wsURL);
1434 if wsURL = '' then exit;
1436 if Copy(wsURL, Length(wsURL), 1) = '/' then
1437 wsURL := Copy(wsURL, 0, Length(wsURL) - 1);
1439 for i := Length(wsURL) downto 0 do begin
1440 if wsURL[i] = '/' then begin
1441 Result := Copy(wsURL, 0, i);
1447 (*************************************************************************
1448 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ª
\91¶
\8dÝ
\82·
\82é
\82©
\83`
\83F
\83b
\83N
1449 *************************************************************************)
1450 function TGikoSys.DirectoryExistsEx(const Name: string): Boolean;
1454 Code := GetFileAttributes(PChar(Name));
1455 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
1458 (*************************************************************************
1459 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\8dì
\90¬
\81i
\95¡
\90\94\8aK
\91w
\91Î
\89\9e\81j
1460 *************************************************************************)
1461 function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean;
1464 if Length(Dir) = 0 then
1465 raise Exception.Create('
\83t
\83H
\83\8b\83_
\82ª
\8dì
\90¬
\8fo
\97\88\82Ü
\82¹
\82ñ');
1466 Dir := ExcludeTrailingPathDelimiter(Dir);
1467 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
1468 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
1469 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
1472 (*************************************************************************
1473 *
\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
1474 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1475 *************************************************************************)
1476 function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1480 Result := StrTokNext(sep, Rec);
1483 (*************************************************************************
1484 *
\95¶
\8e\9a\97ñ
\82©
\82ç
\83g
\81[
\83N
\83\93\82Ì
\90Ø
\82è
\8fo
\82µ
1485 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1486 *************************************************************************)
1487 function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1494 if Len >= Pos then begin
1495 while (Pos <= Len) and (Str[Pos] in sep) do begin
1499 while (Pos<= Len) and not (Str[Pos] in sep) do begin
1500 if IsDBCSLeadByte(Byte(Str[Pos])) then begin
1505 Result := Copy(Str, I, Pos - I);
1506 while (Pos <= Len) and (Str[Pos] in sep) do begin//
\82±
\82ê
\82Í
\82¨
\8dD
\82Ý
1513 (*************************************************************************
1514 *
\83t
\83@
\83C
\83\8b\83T
\83C
\83Y
\8eæ
\93¾
1515 *************************************************************************)
1516 function TGikoSys.GetFileSize(FileName : string): longint;
1521 if not FileExists(FileName) then begin
1525 Assign(F, FileName);
1527 Result := FileSize(F);
1534 (*************************************************************************
1535 *
\83t
\83@
\83C
\83\8b\8ds
\90\94\8eæ
\93¾
1536 *************************************************************************)
1537 function TGikoSys.GetFileLineCount(FileName : string): longint;
1541 sl := TStringList.Create;
1544 sl.LoadFromFile(FileName);
1555 (*************************************************************************
1556 *
\83X
\83\8c\83b
\83h
\83t
\83@
\83C
\83\8b\82©
\82ç
\8ew
\92è
\8ds
\82ð
\8eæ
\93¾
1557 *************************************************************************)
1558 function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string;
1565 ArrBuff: array [1..BUFFER_SIZE] of Char;
1568 if FileExists(FileName) then begin
1569 AssignFile(f, FileName);
1570 System.SetTextBuf(f, ArrBuff);
1574 while not Eof(f) do begin
1576 if Line = num then begin
1589 (*************************************************************************
1590 *
\83V
\83X
\83e
\83\80\83\81\83j
\83\85\81[
\83t
\83H
\83\93\83g
\82Ì
\91®
\90«
\82ð
\8eæ
\93¾
1591 *************************************************************************)
1592 procedure TGikoSys.MenuFont(Font: TFont);
1595 nm: NONCLIENTMETRICS;
1597 nm.cbSize := sizeof(NONCLIENTMETRICS);
1599 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0);
1600 lf := nm.lfMenuFont;
1602 Font.Name := lf.lfFaceName;
1603 Font.Height := lf.lfHeight;
1605 if lf.lfWeight >= 700 then
1606 Font.Style := Font.Style + [fsBold];
1607 if lf.lfItalic = 1 then
1608 Font.Style := Font.Style + [fsItalic];
1611 (*************************************************************************
1613 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1614 *************************************************************************)
1615 function TGikoSys.RemoveToken(var s: string; delimiter: string): string;
1619 p := AnsiPos(delimiter, s);
1623 Result := Copy(s, 1, p - 1);
1624 s := Copy(s, Length(Result) + Length(delimiter) + 1, Length(s));
1627 (*************************************************************************
1629 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1630 *************************************************************************)
1631 function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string;
1636 for i := 0 to index do
1637 Result := RemoveToken(s, delimiter);
1640 (*************************************************************************
1642 *************************************************************************)
1643 function TGikoSys.DeleteLink(const s: string): string;
1653 s1 := GetTokenIndex(s, '<a href="', i);
1654 s2 := GetTokenIndex(s, '<a href="', i + 1);
1656 idx := Pos('">', s1);
1658 Delete(s1, 1, idx + 1);
1659 idx := Pos('">', s2);
1661 Delete(s2, 1, idx + 1);
1663 Result := Result + s1 + s2;
1672 //
\83C
\83\93\83f
\83b
\83N
\83X
\96¢
\8dX
\90V
\83o
\83b
\83t
\83@
\82ð
\83t
\83\89\83b
\83V
\83\85\81I
1673 {procedure TGikoSys.FlashExitWrite;
1677 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
1678 for i := 0 to FExitWrite.Count - 1 do
1679 WriteThreadDat(FExitWrite[i]);
1683 (*************************************************************************
1684 *
\83X
\83\8c\96¼
\82È
\82Ç
\82ð
\92Z
\82¢
\96¼
\91O
\82É
\95Ï
\8a·
\82·
\82é
1686 *************************************************************************)
1687 function TGikoSys.GetShortName(const LongName: string; ALength: integer): string;
1689 ERASECHAR : array [1..39] of string =
1690 ('
\81\99','
\81\9a','
\81¡','
\81 ','
\81\9f','
\81\9e','
\81Q','
\81\94','
\81£','
\81¥',
1691 '
\81¢','
\81¤','
\81\9c','
\81\9b','
\81\9d','
\81y','
\81z','
\81ô','
\81s','
\81t',
1692 '
\81g','
\81h','
\81k','
\81l','
\81e','
\81f','
\81\83','
\81\84','
\81á','
\81â',
1693 '
\81o','
\81p','
\81q','
\81r','
\81w','
\81x','
\81¬','
\81c', '
\81@');
1695 Chr : array [0..255] of char;
1699 s := Trim(LongName);
1700 if (Length(s) <= ALength) then begin
1704 for i := Low(ERASECHAR) to High(ERASECHAR) do begin
1705 S := StringReplace(S, ERASECHAR[i], '', [rfReplaceAll]);
1707 if (Length(S) <= ALength) then begin
1710 Windows.LCMapString(
1711 GetUserDefaultLCID(),
1719 S := Copy(S,1,ALength);
1721 if (ByteType(S, Length(S)) = mbLeadByte ) then begin
1722 S := Copy(S, 1, Length(S) - 1);
1732 (*************************************************************************
1735 *************************************************************************)
1736 function TGikoSys.ConvRes(const Body, Bbs, Key,
1737 ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
1741 FIndexFrom : integer;
1748 ZN = '
\82O
\82P
\82Q
\82R
\82S
\82T
\82U
\82V
\82W
\82X
\81|';
1762 procedure Add(IndexFrom, IndexTo: integer; const No: string);
1767 FIndex.FIndexFrom := IndexFrom;
1768 FIndex.FIndexTo := IndexTo;
1772 function ChooseString(const Text, Separator: string; Index: integer): string;
1778 for i := 0 to Index - 1 do begin
1779 if (AnsiPos(Separator, S) = 0) then S := ''
1780 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
1782 p := AnsiPos(Separator, S);
1783 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
1792 List:= TList.Create;
1798 b := ByteType(s, i);
1800 mbSingleByte : begin
1801 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1802 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1810 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1811 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
1817 if (not sw) and (Copy(s,i,4) = GT) then begin
1818 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1826 if ((not sw) and (Copy(s,i,1) = ',')) or
1827 ((not sw) and (Copy(s,i,1) = '=')) then begin
1828 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
1829 ((Chk) and (oc = '')) or
1830 ((not Chk) and (al)) then
1840 if (AnsiPos(sx, SN) > 0) then begin
1843 if (No <> '') and (No <> '-') then begin
1856 if Copy(s,i,1) = '<' then oc := '';
1857 oc := oc + Copy(s,i,1);
1863 if (not sw) and (Copy(s,i,4) = '
\81\84\81\84') then begin
1869 if (not sw) and (Copy(s,i,2) = '
\81\84') then begin
1877 if (AnsiPos(sx, ZN) > 0) then begin
1878 No := No + ZenToHan(sx);
1880 if (No <> '') and (No <> '-') and (No <> '
\81|') then begin
1895 if (i > Length(Body)) then begin
1897 if (No <> '') then Add(sp, i, No);
1902 for i := List.Count - 1 downto 0 do begin
1903 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
1904 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
1905 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
1907 st := PIndex(List[i]).FNo;
1908 et := PIndex(List[i]).FNo;
1910 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
1911 Format('<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">',
1912 [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
1913 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
1914 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
1915 Dispose(PIndex(List[i]));
1921 (*************************************************************************
1922 *
\91S
\8ap
\81¨
\94¼
\8ap
1924 *************************************************************************)
1925 function TGikoSys.ZenToHan(const s: string): string;
1927 Chr: array [0..255] of char;
1929 Windows.LCMapString(
1930 GetUserDefaultLCID(),
1932 LCMAP_HALFWIDTH or LCMAP_KATAKANA or LCMAP_LOWERCASE,
1941 (*************************************************************************
1942 *
\91S
\8ap
\94¼
\8ap
\82Ð
\82ç
\82ª
\82È
\82©
\82½
\82©
\82È
\82ð
\8bæ
\95Ê
\82µ
\82È
\82¢
\90¦
\82¢Pos
1943 *************************************************************************)
1944 function TGikoSys.VaguePos(const Substr, S: string): Integer;
1946 Result := Pos(ZenToHan(Substr), ZenToHan(S));
1949 function TGikoSys.BoolToInt(b: Boolean): Integer;
1951 Result := IfThen(b, 1, 0);
1954 function TGikoSys.IntToBool(i: Integer): Boolean;
1959 //gzip
\82Å
\88³
\8fk
\82³
\82ê
\82½
\82Ì
\82ð
\96ß
\82·
1960 function TGikoSys.GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
1964 GZipStream: TGzipDecompressStream;
1965 TextStream: TStringStream;
1966 buf: array[0..BUF_SIZE - 1] of Byte;
1972 TextStream := TStringStream.Create('');
1974 //
\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¢)
1975 // if LowerCase(Trim(ContentEncoding)) = 'gzip' then begin
1976 if AnsiPos('gzip', LowerCase(Trim(ContentEncoding))) > 0 then begin
1977 ResStream.Position := 0;
1978 GZipStream := TGzipDecompressStream.Create(TextStream);
1981 FillChar(buf, BUF_SIZE, 0);
1982 cnt := ResStream.Read(buf, BUF_SIZE);
1984 GZipStream.Write(buf, BUF_SIZE);
1990 ResStream.Position := 0;
1992 FillChar(buf, BUF_SIZE, 0);
1993 cnt := ResStream.Read(buf, BUF_SIZE);
1995 TextStream.Write(buf, BUF_SIZE);
1999 //NULL
\95¶
\8e\9a\82ð"*"
\82É
\82·
\82é
2000 s := TextStream.DataString;
2002 while (i > 0) and (s[i] = #0) do
2007 while i <> 0 do begin
2017 procedure TGikoSys.LoadKeySetting(ActionList: TActionList);
2019 STD_SEC = 'KeySetting';
2025 SecList: TStringList;
2026 Component: TComponent;
2028 if not FileExists(GetConfigDir + KEY_SETTING_FILE_NAME) then
2030 SecList := TStringList.Create;
2031 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
2033 ini.ReadSection(STD_SEC, SecList);
2034 for i := 0 to SecList.Count - 1 do begin
2035 ActionName := SecList[i];
2036 ActionKey := ini.ReadInteger(STD_SEC, ActionName, -1);
2037 if ActionKey <> -1 then begin
2038 Component := ActionList.Owner.FindComponent(ActionName);
2039 if TObject(Component) is TAction then begin
2040 TAction(Component).ShortCut := ActionKey;
2050 procedure TGikoSys.SaveKeySetting(ActionList: TActionList);
2052 STD_SEC = 'KeySetting';
2057 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
2059 for i := 0 to ActionList.ActionCount - 1 do begin
2060 if ActionList.Actions[i].Tag = -1 then
2062 ini.WriteInteger(STD_SEC, ActionList.Actions[i].Name, TAction(ActionList.Actions[i]).ShortCut);
2071 procedure TGikoSys.CreateProcess(const AppPath: string; const Param: string);
2073 PI: TProcessInformation;
2077 Path := '"' + AppPath + '"';
2079 Path := Path + ' ' + Param;
2081 SI.Cb := SizeOf(Si);
2082 SI.lpReserved := nil;
2083 SI.lpDesktop := nil;
2086 SI.cbReserved2 := 0;
2087 SI.lpReserved2 := nil;
2089 Windows.CreateProcess(nil,
2101 procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
2105 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2106 gbtUserApp, gbtAuto:
2107 if (Setting.URLApp) and (FileExists(Setting.URLAppFile)) then
2108 GikoSys.CreateProcess(Setting.URLAppFile, URL)
2110 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2114 function TGikoSys.HTMLDecode(const AStr: String): String;
2116 Sp, Rp, Cp, Tp: PChar;
2121 SetLength(Result, Length(AStr));
2123 Rp := PChar(Result);
2126 while Sp^ <> #0 do begin
2132 'a': if AnsiStrPos(Sp, 'amp;') = Sp then
2138 'g': if (AnsiStrPos(Sp, 'lt;') = Sp) or (AnsiStrPos(Sp, 'gt;') = Sp) then
2142 while (Sp^ <> ';') and (Sp^ <> #0) do
2149 'q': if AnsiStrPos(Sp, 'quot;') = Sp then
2157 Num := IsNumeric(Copy(Tp, 1, 1));
2158 while (Sp^ <> ';') and (Sp^ <> #0) do begin
2159 if (Num) and (not IsNumeric(Copy(Sp, 1, 1))) then
2163 SetString(S, Tp, Sp - Tp);
2168 //raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2169 //[Cp^ + Sp^, Cp - PChar(AStr)])
2179 // on E:EConvertError do
2180 // raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2181 // [Cp^ + Sp^, Cp - PChar(AStr)])
2183 SetLength(Result, Rp - PChar(Result));
2186 function TGikoSys.GetHRefText(s: string): string;
2196 Index := AnsiPos('href', LowerCase(s));
2199 s := Trim(Copy(s, Index + 4, Length(s)));
2200 s := Trim(Copy(s, 2, Length(s)));
2202 //
\8en
\82ß
\82Ì
\95¶
\8e\9a\82ª'"'
\82È
\82ç
\8eæ
\82è
\8f\9c\82
2203 if Copy(s, 1, 1) = '"' then begin
2204 s := Trim(Copy(s, 2, Length(s)));
2207 Index := AnsiPos('"', s);
2208 if Index <> 0 then begin
2209 //'"'
\82Ü
\82ÅURL
\82Æ
\82·
\82é
2210 s := Copy(s, 1, Index - 1);
2212 //'"'
\82ª
\96³
\82¯
\82ê
\82Î
\83X
\83y
\81[
\83X
\82©">"
\82Ì
\91\81\82¢
\95û
\82Ü
\82Å
\82ðURL
\82Æ
\82·
\82é
2213 Index := AnsiPos(' ', s);
2214 Index2 := AnsiPos('>', s);
2217 if Index > Index2 then
2220 s := Copy(s, 1, Index - 1)
2222 //
\82±
\82ê
\88È
\8fã
\82à
\82¤
\92m
\82ç
\82ñ
\82Ê
2228 //
\83z
\83X
\83g
\96¼
\82ª
\82Q
\82\83\82\88\82©
\82Ç
\82¤
\82©
\83`
\83F
\83b
\83N
\82·
\82é
2229 function TGikoSys.Is2chHost(Host: string): Boolean;
2231 HOST_NAME: array[0..1] of string = ('2ch.net', 'bbspink.com');
2237 OutputDebugString(pchar(HOST_NAME[0]));
2238 for i := 0 to Length(HOST_NAME) - 1 do begin
2239 // Len := Length(HOST_NAME[i]);
2240 if AnsiPos(HOST_NAME[i], Host) = (Length(Host) - Length(HOST_NAME[i]) + 1) then begin
2247 function TGikoSys.Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
2249 READ_PATH: string = '/test/read.cgi/';
2250 OLD_READ_PATH: string = '/test/read.cgi?';
2251 KAKO_PATH: string = '/kako/';
2261 Index := AnsiPos(READ_PATH, path);
2262 if Index <> 0 then begin
2263 s := Copy(path, Length(READ_PATH) + 1, Length(path));
2264 BBSID := GetTokenIndex(s, '/', 0);
2265 BBSKey := GetTokenIndex(s, '/', 1);
2268 Result := (BBSID <> '') or (BBSKey <> '');
2271 Index := AnsiPos(KAKO_PATH, path);
2272 if Index <> 0 then begin
2273 s := Copy(path, 2, Length(path));
2274 BBSID := GetTokenIndex(s, '/', 0);
2275 if (BBSID = 'log') and (GetTokenIndex(s, '/', 2) = 'kako') then
2276 BBSID := GetTokenIndex(s, '/', 1);
2277 BBSKey := ChangeFileExt(Document, '');
2278 Result := (BBSID <> '') or (BBSKey <> '');
2281 Index := AnsiPos('read.cgi?', URL);
2282 if Index <> 0 then begin
2283 SList := TStringList.Create;
2286 // s := HTMLDecode(Document);
2287 ExtractHTTPFields(['?', '&'], [], PChar(URL), SList, False);
2288 BBSID := SList.Values['bbs'];
2289 BBSKey := SList.Values['key'];
2290 Result := (BBSID <> '') or (BBSKey <> '');
2301 function TGikoSys.Parse2chURL2(URL: string): TPathRec;
2313 URL := Trim(LowerCase(URL));
2318 Result.FFirst := False;
2319 Result.FStBegin := False;
2320 Result.FToEnd := False;
2321 Result.FDone := False;
2326 FAWKStr.RegExp := 'http://.+\.(2ch\.net|bbspink\.com)/';
2327 if FAWKStr.Match(FAWKStr.ProcessEscSeq(URL), RStart, RLength) = 0 then
2329 s := Copy(URL, RStart + RLength - 1, Length(URL));
2331 //
\95W
\8f\80\8f\91\8e®
2332 //
\8dÅ
\8cã
\82Íl50, 10, 10-20, 10n, 10-20n, -10, 10-, 10n-
\82È
\82Ç
2333 //http://xxx.2ch.net/test/read.cgi/bbsid/1000000000/
2334 FAWKStr.RegExp := '/test/read.cgi/.+/[0-9]+/.*';
2335 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2336 s := Copy(s, 15, Length(s));
2338 SList := TStringList.Create;
2341 FAWKStr.RegExp := '/';
2342 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2343 Result.FBBS := SList[1];
2344 Result.FKey := SList[2];
2345 if SList.Count >= 3 then
2353 FAWKStr.LineSeparator := mcls_CRLF;
2354 FAWKStr.RegExp := '-';
2355 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) = 0 then begin
2356 Result.FFirst := True;
2358 FAWKStr.RegExp := 'l[0-9]+';
2359 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2360 Result.FFirst := True;
2362 for i := 0 to SList.Count - 1 do begin
2363 if Trim(SList[i]) = '' then begin
2365 Result.FStBegin := True;
2366 if i = (SList.Count - 1) then
2367 Result.FToEnd := True;
2368 end else if IsNumeric(SList[i]) then begin
2369 wkInt := StrToInt(SList[i]);
2370 wkMax := Max(wkMax, wkInt);
2374 wkMin := Min(wkMin, wkInt);
2375 end else if Trim(SList[i]) = 'n' then begin
2376 Result.FFirst := True;
2378 FAWKStr.RegExp := '^n[0-9]+$|^[0-9]+n$';
2379 if FAWKStr.Match(FAWKStr.ProcessEscSeq(SList[i]), RStart, RLength) > 0 then begin
2380 if Copy(SList[i], 1, 1) = 'n' then
2381 wkInt := StrToInt(Copy(SList[i], 2, Length(SList[i])))
2383 wkInt := StrToInt(Copy(SList[i], 1, Length(SList[i]) - 1));
2384 Result.FFirst := True;
2385 wkMax := Max(wkMax, wkInt);
2389 wkMin := Min(wkMin, wkInt);
2393 if Result.FStBegin and (not Result.FToEnd) then
2395 else if (not Result.FStBegin) and Result.FToEnd then
2397 else if (not Result.FStBegin) and (not Result.FToEnd) then begin
2398 Result.FSt := wkMin;
2399 Result.FTo := wkMax;
2401 //Result.FSt := wkMin;
2402 //Result.FTo := wkMax;
2408 Result.FDone := True;
2412 //
\90Vkako
\8f\91\8e®
2413 //http://server.2ch.net/ITA_NAME/kako/1000/10000/1000000000.html
2414 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+/[0-9]+\.html';
2415 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2416 SList := TStringList.Create;
2419 FAWKStr.RegExp := '/';
2420 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2421 Result.FBBS := SList[1];
2422 Result.FKey := ChangeFileExt(SList[5], '');
2423 Result.FFirst := True;
2429 Result.FDone := True;
2433 //
\8b\8ckako
\8f\91\8e®
2434 //http://server.2ch.net/ITA_NAME/kako/999/999999999.html
2435 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+\.html';
2436 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2437 SList := TStringList.Create;
2440 FAWKStr.RegExp := '/';
2441 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 5 then begin
2442 Result.FBBS := SList[1];
2443 Result.FKey := ChangeFileExt(SList[4], '');
2444 Result.FFirst := True;
2450 Result.FDone := True;
2454 //log
\8by
\82Ñlog2
\8f\91\8e®
2455 //http://server.2ch.net/log/ITA_NAME/kako/999/999999999.html
2456 //http://server.2ch.net/log2/ITA_NAME/kako/999/999999999.html
2457 FAWKStr.RegExp := '/log2?/.+/kako/[0-9]+/[0-9]+\.html';
2458 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2459 SList := TStringList.Create;
2462 FAWKStr.RegExp := '/';
2463 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2464 Result.FBBS := SList[2];
2465 Result.FKey := ChangeFileExt(SList[5], '');
2466 Result.FFirst := True;
2472 Result.FDone := True;
2477 //
\8b\8cURL
\8f\91\8e®
2478 //http://server.2ch.net/test/read.cgi?bbs=ITA_NAME&key=1000000000&st=1&to=5&nofirst=true
2479 FAWKStr.RegExp := '/test/read\.cgi\?';
2480 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2481 s := Copy(s, 16, Length(s));
2482 SList := TStringList.Create;
2485 FAWKStr.RegExp := '&';
2486 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2487 Result.FFirst := True;
2488 for i := 0 to SList.Count - 1 do begin
2489 if Pos('bbs=', SList[i]) = 1 then begin
2490 Result.FBBS := Copy(SList[i], 5, Length(SList[i]));
2491 end else if Pos('key=', SList[i]) = 1 then begin
2492 Result.FKey := Copy(SList[i], 5, Length(SList[i]));
2493 end else if Pos('st=', SList[i]) = 1 then begin
2494 wk := Copy(SList[i], 4, Length(SList[i]));
2495 if IsNumeric(wk) then
2496 Result.FSt := StrToInt(wk)
2497 else if wk = '' then
2498 Result.FStBegin := True;
2499 end else if Pos('to=', SList[i]) = 1 then begin
2500 wk := Copy(SList[i], 4, Length(SList[i]));
2501 if IsNumeric(wk) then
2502 Result.FTo := StrToInt(wk)
2503 else if wk = '' then
2504 Result.FToEnd := True;
2505 end else if Pos('nofirst=', SList[i]) = 1 then begin
2506 Result.FFirst := False;
2515 if (Result.FBBS <> '') and (Result.FKey <> '') then begin
2516 Result.FDone := True;
2522 procedure TGikoSys.ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
2532 URI := TIdURI.Create(URL);
2534 Protocol := URI.Protocol;
2537 Document := URI.Document;
2539 Bookmark := URI.Bookmark;
2545 function TGikoSys.GetVersionBuild: Integer;
2547 FixedFileInfo: PVSFixedFileInfo;
2548 VersionHandle, VersionSize: DWORD;
2549 pVersionInfo: Pointer;
2554 AppFile := Application.ExeName;
2555 VersionSize := GetFileVersionInfoSize(pChar(AppFile), VersionHandle);
2556 if VersionSize = 0 then
2558 GetMem(pVersionInfo, VersionSize);
2560 if GetFileVersionInfo(PChar(AppFile),VersionHandle,VersionSize, pVersionInfo) then
2561 if VerQueryValue(pVersionInfo, '\', Pointer(FixedFileInfo), ItemLen) then
2562 Result := LOWORD(FixedFileInfo^.dwFileVersionLS);
2564 FreeMem(pVersionInfo, VersionSize);
2569 GikoSys := TGikoSys.Create;
2572 if GikoSys <> nil then begin