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 // FExitWrite: TStringList;
92 // function StrToFloatDef(s: string; Default: Double): Double;
97 FSelectResFilter : TAbon;
100 destructor Destroy; override;
103 // function MsgBox(Msg: string; Title: string; Flags: Longint): integer; overload;
104 // function MsgBox(Handle: THandle; Msg: string; Title: string; Flags: Longint): integer; overload;
105 function IsNumeric(s: string): boolean;
106 function IsFloat(s: string): boolean;
107 function DirectoryExistsEx(const Name: string): Boolean;
108 function ForceDirectoriesEx(Dir: string): Boolean;
109 // function GetVersion: string;
111 function GetBoardFileName: string;
112 function GetCustomBoardFileName: string;
113 function GetHtmlTempFileName: string;
114 function GetAppDir: string;
115 function GetTempFolder: string;
116 function GetSentFileName: string;
117 function GetConfigDir: string;
118 function GetSkinDir: string;
119 function GetStyleSheetDir: string;
120 function GetOutBoxFileName: string;
121 function GetURL(BBSID: string; FileName: string): string;
122 function GetUserAgent: string;
124 procedure ReadSubjectFile(Board: TBoard);
125 procedure CreateThreadDat(Board: TBoard);
126 procedure WriteThreadDat(Board: TBoard);
127 function ParseIndexLine(Line: string): TIndexRec;
128 procedure GetFileList(Path: string; Mask: string; List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
129 procedure GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
131 procedure CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
132 function AddAnchorTag(s: string): string;
134 function DivideSubject(Line: string): TSubjectRec;
135 function DivideStrLine(Line: string): TResRec;
137 property Setting: TSetting read FSetting write FSetting;
138 property Dolib: TDolib read FDolib write FDolib;
140 function UrlToID(url: string): string;
141 function UrlToServer(url: string): string;
143 function StrTokFirst(const s:string; const sep:TStrTokSeparator; var Rec:TStrTokRec):string;
144 function StrTokNext(const sep:TStrTokSeparator; var Rec:TStrTokRec): string;
146 function GetFileSize(FileName : string) : longint;
147 function GetFileLineCount(FileName : string): longint;
148 function Get2chDate(aDate: TDateTime): string;
149 function IntToDateTime(val: Int64): TDateTime;
150 function DateTimeToInt(ADate: TDateTime): Integer;
152 function ReadThreadFile(FileName: string; Line: Integer): string;
154 procedure MenuFont(Font: TFont);
156 function RemoveToken(var s:string;delimiter:string):string;
157 function GetTokenIndex(s: string; delimiter: string; index: Integer): string;
159 function DeleteLink(const s: string): string;
161 function GetShortName(const LongName: string; ALength: integer): string;
162 function ConvRes(const Body, Bbs, Key, ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
164 function ZenToHan(const s: string): string;
165 function VaguePos(const Substr, S: string): Integer;
166 function BoolToInt(b: Boolean): Integer;
167 function IntToBool(i: Integer): Boolean;
168 function GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
169 procedure LoadKeySetting(ActionList: TActionList);
170 procedure SaveKeySetting(ActionList: TActionList);
171 procedure CreateProcess(const AppPath: string; const Param: string);
172 procedure OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
173 function HTMLDecode(const AStr: String): String;
174 function GetHRefText(s: string): string;
175 function Is2chHost(Host: string): Boolean;
176 function Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
177 function Parse2chURL2(URL: string): TPathRec;
178 procedure ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
179 function GetVersionBuild: Integer;
185 LENGTH_RESTITLE = 40;
186 ZERO_DATE: Integer = 25569;
187 BETA_VERSION_NAME_E = 'beta';
188 BETA_VERSION_NAME_J = 'ÊÞÀ';
190 BETA_VERSION_BUILD = ''; //debug
\94Å
\82È
\82Ç
198 BOARD_FILE_NAME = 'board.2ch';
199 CUSTOMBOARD_FILE_NAME = 'custom.2ch';
200 KEY_SETTING_FILE_NAME = 'key.ini';
201 TEMP_FOLDER = 'Temp';
202 OUTBOX_FILE_NAME = 'outbox.ini';
203 SENT_FILE_NAME = 'sent.ini';
204 CONFIG_DIR_NAME = 'config';
205 CSS_DIR_NAME = 'css';
206 SKIN_DIR_NAME = 'skin';
207 SKIN_HEADER_FILE_NAME = 'Header.html';
208 SKIN_FOOTER_FILE_NAME = 'Footer.html';
209 SKIN_NEWRES_FILE_NAME = 'NewRes.html';
210 SKIN_RES_FILE_NAME = 'Res.html';
211 FOLDER_INDEX_VERSION = '1.01';
212 USER_AGENT = 'Monazilla';
213 APP_NAME = 'gikoNavi';
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);
230 //FAbon.SetNGwordpath(DEFAULT_NGWORD_FILE_NAME);
232 FSelectResFilter := TAbon.Create;
233 //
\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
234 FSelectResFilter.AbonString := '';
237 (*************************************************************************
238 *GikoSys
\83f
\83X
\83g
\83\89\83N
\83^
239 *************************************************************************)
240 destructor TGikoSys.Destroy;
243 FileList: TStringList;
245 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
253 //
\83e
\83\93\83|
\83\89\83\8aHTML
\82ð
\8dí
\8f\9c
254 FileList := TStringList.Create;
256 GetFileList(GetTempFolder, '*.html', FileList, False, True);
257 for i := 0 to FileList.Count - 1 do begin
258 DeleteFile(FileList[i]);
266 (*************************************************************************
267 *
\95¶
\8e\9a\97ñ
\90\94\8e\9a\83`
\83F
\83b
\83N
268 *************************************************************************)
270 function TGikoSys.IsNumeric(s: string): boolean;
280 (*************************************************************************
281 *
\95¶
\8e\9a\97ñ
\95\82\93®
\8f¬
\90\94\93_
\90\94\8e\9a\83`
\83F
\83b
\83N
282 *************************************************************************)
283 function TGikoSys.IsFloat(s: string): boolean;
287 Result := TextToFloat(PChar(s), v, fvExtended);
290 (*************************************************************************
291 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
292 *************************************************************************)
293 function TGikoSys.GetBoardFileName: string;
295 Result := GetAppDir + CONFIG_DIR_NAME + '\' + BOARD_FILE_NAME;
298 (*************************************************************************
299 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
300 *************************************************************************)
301 function TGikoSys.GetCustomBoardFileName: string;
303 Result := GetAppDir + CONFIG_DIR_NAME + '\' + CUSTOMBOARD_FILE_NAME;
306 (*************************************************************************
307 *
\83e
\83\93\83|
\83\89\83\8a\83t
\83H
\83\8b\83_
\81[
\96¼
\8eæ
\93¾
308 *************************************************************************)
309 function TGikoSys.GetHtmlTempFileName: string;
311 Result := TEMP_FOLDER;
315 (*************************************************************************
316 *
\8eÀ
\8ds
\83t
\83@
\83C
\83\8b\83t
\83H
\83\8b\83_
\8eæ
\93¾
317 *************************************************************************)
318 function TGikoSys.GetAppDir: string;
320 Result := ExtractFilePath(Application.ExeName);
323 (*************************************************************************
324 *TempHtml
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
325 *************************************************************************)
326 function TGikoSys.GetTempFolder: string;
328 Result := GetAppDir + TEMP_FOLDER;
331 (*************************************************************************
332 *sent.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
333 *************************************************************************)
334 function TGikoSys.GetSentFileName: string;
336 Result := GetAppDir + SENT_FILE_NAME;
339 (*************************************************************************
340 *outbox.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
341 *************************************************************************)
342 function TGikoSys.GetOutBoxFileName: string;
344 Result := GetAppDir + OUTBOX_FILE_NAME;
347 (*************************************************************************
348 *Config
\83t
\83H
\83\8b\83_
\8eæ
\93¾
349 *************************************************************************)
350 function TGikoSys.GetConfigDir: string;
352 Result := IncludeTrailingPathDelimiter(GetAppDir + CONFIG_DIR_NAME);
355 function TGikoSys.GetStyleSheetDir: string;
357 Result := IncludeTrailingPathDelimiter(GetConfigDir + CSS_DIR_NAME);
360 function TGikoSys.GetSkinDir: string;
362 Result := IncludeTrailingPathDelimiter(GetConfigDir + SKIN_DIR_NAME);
365 (*************************************************************************
366 *URL
\82ð
\8dì
\90¬(
\83R
\83s
\83y
\97p)
367 *************************************************************************)
368 function TGikoSys.GetURL(BBSID: string; FileName: string): string;
372 Board := BoardGroup.BBS2ch.GetBoardFromBBSID(BBSID);
373 Result := UrlToServer(Board.URL) + 'test/read.cgi/' + UrlToID(Board.URL) + '/' + ChangeFileExt(FileName, '') + '/l50';
374 //http://teri.2ch.net/test/read.cgi?bbs=accuse&key=974619522&ls=50
375 //http://pc.2ch.net/test/read.cgi/tech/1003664165/l50
379 function TGikoSys.GetUserAgent: string;
381 if Dolib.Connected then begin
382 Result := Format('%s %s/%s%d%s', [
389 BETA_VERSION_BUILD]);
391 Result := Format('%s/%s %s/%s%d%s', [
399 BETA_VERSION_BUILD]);
403 (*************************************************************************
404 *
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é
\95û
\8e®
\8e\9e\8d\8f\8eæ
\93¾
405 *************************************************************************)
406 function TGikoSys.Get2chDate(aDate: TDateTime): string;
411 d1 := EncodeDate(1970, 1, 1);
412 d2 := aDate - EncodeTime(9, 0, 0, 0);
413 Result := FloatToStr(Trunc((d2 - d1) * 24 * 60 * 60));
417 function TGikoSys.IntToDateTime(val: Int64): TDateTime;
422 d1 := EncodeDate(1970, 1, 1);
423 d2 := (val * 1000) / (24 * 60 * 60 * 1000);
427 function TGikoSys.DateTimeToInt(ADate: TDateTime): Integer;
432 d := EncodeDate(1970, 1, 1);
433 c := (ADate - d) * 24 * 60 * 60;
438 (*************************************************************************
439 *Subject
\83t
\83@
\83C
\83\8bRead
440 *************************************************************************)
441 procedure TGikoSys.ReadSubjectFile(Board: TBoard);
443 ThreadItem: TThreadItem;
445 FileList: TStringList;
446 TmpFileList: TStringList;
447 // SrchRec: TSearchRec;
454 // TmpUpdate: Boolean;
457 RoundItem: TRoundItem;
462 // TmpUpdate := False;
464 FileName := Board.GetFolderIndexFileName;
465 if not FileExists(FileName) then CreateThreadDat(Board);
466 // if not FileExists(FileName) then Exit;
468 //IsLogFile
\97pDAT
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
469 FileList := TStringList.Create;
470 FileList.Sorted := True;
471 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False, False);
473 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\97pTmp
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
474 TmpFileList := TStringList.Create;
475 TmpFileList.Sorted := True;
476 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, False, False);
478 { R := FindFirst(ExtractFileDir(Board.GetFolderIndexFileName) + '\*.dat', 0, SrchRec);
480 FileList.Add(SrchRec.Name);
481 R := FindNext(SrchRec);
485 sl := TStringList.Create;
487 if FileExists(FileName) then
488 sl.LoadFromFile(FileName);
490 //
\82Q
\8ds
\96Ú
\82©
\82ç
\81i
\82P
\8ds
\96Ú
\82Í
\83o
\81[
\83W
\83\87\83\93\81j
491 for i := 1 to sl.Count - 1 do begin
492 Rec := ParseIndexLine(sl[i]);
494 ThreadItem := TThreadItem.Create;
495 ThreadItem.BeginUpdate;
496 ThreadItem.No := Rec.FNo;
497 ThreadItem.FileName := Rec.FFileName;
498 ThreadItem.Title := Rec.FTitle;
499 ThreadItem.Count := Rec.FCount;
500 ThreadItem.Size := Rec.FSize;
501 // ThreadItem.RoundNo := Rec.FRoundNo;
502 ThreadItem.RoundDate := Rec.FRoundDate;
503 ThreadItem.LastModified := Rec.FLastModified;
504 ThreadItem.Kokomade := Rec.FKokomade;
505 ThreadItem.NewReceive := Rec.FNewReceive;
506 // ThreadItem.Round := Rec.FRound;
507 ThreadItem.UnRead := Rec.FUnRead;
508 ThreadItem.ScrollTop := Rec.FScrollTop;
509 ThreadItem.AllResCount := Rec.FAllResCount;
510 ThreadItem.NewResCount := Rec.FNewResCount;
511 ThreadItem.AgeSage := Rec.FAgeSage;
512 ThreadItem.ParentBoard := Board;
514 //IsLogFile
\83`
\83F
\83b
\83N
515 ThreadItem.IsLogFile := False;
516 if FileList.Count <> 0 then begin
517 if FileList.Find(ThreadItem.FileName, Index) then begin
518 ThreadItem.IsLogFile := True;
519 FileList.Delete(Index);
523 //
\8f\84\89ñ
\83\8a\83X
\83g
\82É
\91¶
\8dÝ
\82µ
\82½
\82ç
\8f\84\89ñ
\83t
\83\89\83O
\83Z
\83b
\83g
524 if ThreadItem.IsLogFile then begin
525 idx := RoundList.Find(ThreadItem);
526 if idx <> -1 then begin
527 RoundItem := RoundList.Items[idx, grtItem];
528 ThreadItem.RoundName := RoundItem.RoundName;
529 ThreadItem.Round := True;
533 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\83`
\83F
\83b
\83N
534 if TmpFileList.Count <> 0 then begin
535 if TmpFileList.Find(ChangeFileExt(ThreadItem.FileName, '.tmp'), Index) then begin
536 ini := TMemIniFile.Create(ChangeFileExt(ThreadItem.GetThreadFileName, '.tmp'));
538 ThreadItem.RoundDate := ini.ReadDateTime('Setting', 'RoundDate', ZERO_DATE);
539 ThreadItem.LastModified := ini.ReadDateTime('Setting', 'LastModified', ZERO_DATE);
540 ThreadItem.Size := ini.ReadInteger('Setting', 'Size', 0);
541 ThreadItem.Count := ini.ReadInteger('Setting', 'Count', 0);
542 ThreadItem.NewReceive := ini.ReadInteger('Setting', 'NewReceive', 0);
543 ThreadItem.Round := ini.ReadBool('Setting', 'Round', False);
544 ThreadItem.UnRead := False;//ini.ReadBool('Setting', 'UnRead', False);
545 ThreadItem.ScrollTop := ini.ReadInteger('Setting', 'ScrollTop', 0);
546 ThreadItem.AllResCount := ini.ReadInteger('Setting', 'AllResCount', 0);
547 ThreadItem.NewResCount := ini.ReadInteger('Setting', 'NewResCount', 0);
548 ThreadItem.AgeSage := TGikoAgeSage(ini.ReadInteger('Setting', 'AgeSage', Ord(gasNone)));
552 TmpFileList.Delete(Index);
556 ThreadItem.EndUpdate;
557 Board.Add(ThreadItem);
559 // if (ThreadItem.IsLogFile) and (ThreadItem.Count > ThreadItem.Kokomade) then
560 if (ThreadItem.IsLogFile) and (ThreadItem.UnRead) then
563 if UnRead <> Board.UnRead then
564 Board.UnRead := UnRead;
566 //
\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
567 for i := 0 to FileList.Count - 1 do begin
568 FileName := ExtractFileDir(Board.GetFolderIndexFileName) + '\' + FileList[i];
570 ResRec := DivideStrLine(ReadThreadFile(FileName, 1));
571 ThreadItem := TThreadItem.Create;
572 ThreadItem.No := Board.Count + 1;
573 ThreadItem.FileName := FileList[i];
574 ThreadItem.Title := ResRec.FTitle;
575 ThreadItem.Count := GetFileLineCount(FileName);
576 ThreadItem.AllResCount := ThreadItem.Count;
577 ThreadItem.NewResCount := 0;
578 ThreadItem.Size := 0;
579 ThreadItem.RoundDate := ZERO_DATE;
580 ThreadItem.LastModified := ZERO_DATE;
581 ThreadItem.Kokomade := -1;
582 ThreadItem.NewReceive := 0;
583 ThreadItem.ParentBoard := Board;
584 ThreadItem.IsLogFile := True;
585 ThreadItem.Round := False;
586 ThreadItem.UnRead := False;
587 ThreadItem.ScrollTop := 0;
588 ThreadItem.AgeSage := gasNone;
589 Board.Add(ThreadItem);
596 Board.IsThreadDatRead := True;
599 (*************************************************************************
600 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X
\83t
\83@
\83C
\83\8b(Folder.idx)
\8dì
\90¬
601 *************************************************************************)
602 procedure TGikoSys.CreateThreadDat(Board: TBoard);
606 SubjectList: TStringList;
612 if not FileExists(Board.GetSubjectFileName) then Exit;
613 FileName := Board.GetFolderIndexFileName;
615 SubjectList := TStringList.Create;
617 SubjectList.LoadFromFile(Board.GetSubjectFileName);
618 sl := TStringList.Create;
621 sl.Add(FOLDER_INDEX_VERSION);
622 for i := 0 to SubjectList.Count - 1 do begin
623 Rec := DivideSubject(SubjectList[i]);
625 if (Trim(Rec.FFileName) = '') or (Trim(Rec.FTitle) = '') then
628 s := Format('%x', [cnt]) + #1 //
\94Ô
\8d\86
629 + Rec.FFileName + #1 //
\83t
\83@
\83C
\83\8b\96¼
630 + Rec.FTitle + #1 //
\83^
\83C
\83g
\83\8b
631 + Format('%x', [Rec.FCount]) + #1 //
\83J
\83E
\83\93\83g
632 + Format('%x', [0]) + #1 //size
633 + Format('%x', [0]) + #1 //RoundDate
634 + Format('%x', [0]) + #1 //LastModified
635 + Format('%x', [0]) + #1 //Kokomade
636 + Format('%x', [0]) + #1 //NewReceive
637 + '0' + #1 //
\96¢
\8eg
\97p
638 + Format('%x', [0]) + #1 //UnRead
639 + Format('%x', [0]) + #1 //ScrollTop
640 + Format('%x', [Rec.FCount]) + #1 //AllResCount
641 + Format('%x', [0]) + #1 //NewResCount
642 + Format('%x', [0]); //AgeSage
647 sl.SaveToFile(FileName);
656 (*************************************************************************
657 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X(Thread.dat)
\8f\91\82«
\8d\9e\82Ý
659 *************************************************************************)
660 procedure TGikoSys.WriteThreadDat(Board: TBoard);
662 // Values: array[Boolean] of string = ('0', '1');
668 FileList: TStringList;
670 if not Board.IsThreadDatRead then
672 FileName := Board.GetFolderIndexFileName;
673 ForceDirectoriesEx(Board.ParentCategory.ParentBBS2ch.GetLogFolder + Board.BBSID);
675 sl := TStringList.Create;
677 sl.Add(FOLDER_INDEX_VERSION);
678 for i := 0 to Board.Count - 1 do begin
679 if Board.Items[i].No = 0 then
680 Board.Items[i].No := i + 1;
682 s := Format('%x', [Board.Items[i].No]) + #1
683 + Board.Items[i].FileName + #1
684 + Board.Items[i].Title + #1
685 + Format('%x', [Board.Items[i].Count]) + #1
686 + Format('%x', [Board.Items[i].Size]) + #1
687 + Format('%x', [DateTimeToInt(Board.Items[i].RoundDate)]) + #1
688 + Format('%x', [DateTimeToInt(Board.Items[i].LastModified)]) + #1
689 + Format('%x', [Board.Items[i].Kokomade]) + #1
690 + Format('%x', [Board.Items[i].NewReceive]) + #1
691 + '0' + #1 //
\96¢
\8eg
\97p
692 + Format('%x', [BoolToInt(Board.Items[i].UnRead)]) + #1
693 + Format('%x', [Board.Items[i].ScrollTop]) + #1
694 + Format('%x', [Board.Items[i].AllResCount]) + #1
695 + Format('%x', [Board.Items[i].NewResCount]) + #1
696 + Format('%x', [Ord(Board.Items[i].AgeSage)]);
701 sl.SaveToFile(FileName);
703 FileList := TStringList.Create;
705 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', FileList, False, True);
706 for i := 0 to FileList.Count - 1 do begin
707 DeleteFile(FileList[i]);
717 function TGikoSys.ParseIndexLine(Line: string): TIndexRec;
722 for i := 0 to 14 do begin
723 s := GetTokenIndex(Line, #1, i);
725 0: Result.FNo := StrToIntDef('$' + s, 0);
726 1: Result.FFileName := s;
727 2: Result.FTitle := s;
728 3: Result.FCount := StrToIntDef('$' + s, 0);
729 4: Result.FSize := StrToIntDef('$' + s, 0);
730 5: Result.FRoundDate := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
731 6: Result.FLastModified := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
732 7: Result.FKokomade := StrToIntDef('$' + s, -1);
733 8: Result.FNewReceive := StrToIntDef('$' + s, 0);
735 10: Result.FUnRead := IntToBool(StrToIntDef('$' + s, 0));
736 11: Result.FScrollTop := StrToIntDef('$' + s, 0);
737 12: Result.FAllResCount := StrToIntDef('$' + s, 0);
738 13: Result.FNewResCount := StrToIntDef('$' + s, 0);
739 14: Result.FAgeSage := TGikoAgeSage(StrToIntDef('$' + s, 0));
744 //
\8ew
\92è
\83t
\83H
\83\8b\83_
\93à
\82Ì
\8ew
\92è
\83t
\83@
\83C
\83\8b\88ê
\97\97\82ð
\8eæ
\93¾
\82·
\82é
745 // ListFiles('c:\', '*.txt', list, True);
746 procedure TGikoSys.GetFileList(Path: string; Mask: string; List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
749 SearchRec : TSearchRec;
752 Path := IncludeTrailingPathDelimiter(Path);
753 rc := FindFirst(Path + '*.*', faAnyfile, SearchRec);
755 while rc = 0 do begin
756 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
757 s := Path + SearchRec.Name;
758 //if (SearchRec.Attr and faDirectory > 0) then
759 // s := IncludeTrailingPathDelimiter(s)
761 if (SearchRec.Attr and faDirectory = 0) and (MatchesMask(s, Mask)) then
765 List.Add(SearchRec.Name);
766 if SubDir and (SearchRec.Attr and faDirectory > 0) then
767 GetFileList(s, Mask, List, True, IsPathAdd);
769 rc := FindNext(SearchRec);
772 SysUtils.FindClose(SearchRec);
776 //
\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é
777 procedure TGikoSys.GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
780 SearchRec : TSearchRec;
783 Path := IncludeTrailingPathDelimiter(Path);
784 rc := FindFirst(Path + '*.*', faDirectory, SearchRec);
786 while rc = 0 do begin
787 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
788 s := Path + SearchRec.Name;
789 //if (SearchRec.Attr and faDirectory > 0) then
790 // s := IncludeTrailingPathDelimiter(s)
792 if (SearchRec.Attr and faDirectory > 0) and (MatchesMask(s, Mask)) then
793 List.Add( IncludeTrailingPathDelimiter( s ) );
794 if SubDir and (SearchRec.Attr and faDirectory > 0) then
795 GetDirectoryList(s, Mask, List, True);
797 rc := FindNext(SearchRec);
800 SysUtils.FindClose(SearchRec);
804 procedure TGikoSys.CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
808 //bufList : TStringList;
809 ReadList: TStringList;
810 SaveList: TStringList;
814 NewReceiveNo: Integer;
817 SkinHeaderFileName: string;
818 SkinNewRes: TStringList;
819 SkinRes: TStringList;
822 ShortDayNames[1] := '
\93ú'; ShortDayNames[2] := '
\8c\8e';
823 ShortDayNames[3] := '
\89Î'; ShortDayNames[4] := '
\90\85';
824 ShortDayNames[5] := '
\96Ø'; ShortDayNames[6] := '
\8bà';
825 ShortDayNames[7] := '
\93y';
826 BBSID := ThreadItem.ParentBoard.BBSID;
827 FileName := ThreadItem.FileName;
828 NewReceiveNo := ThreadItem.NewReceive;
829 FileName := ThreadItem.GetThreadFileName;
830 ReadList := TStringList.Create;
831 FAbon.Deleterlo := FSetting.AbonDeleterlo;
832 FAbon.Replaceul := FSetting.AbonReplaceul;
833 FAbon.AbonPopupRes := FSetting.PopUpAbon;
835 if ThreadItem.IsLogFile then begin
836 ReadList.LoadFromFile(FileName);
837 FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
838 FAbon.Execute(ReadList); //
\82 \82Ú
\81`
\82ñ
\82µ
\82Ä
839 FSelectResFilter.Execute(ReadList); //
\83\8c\83X
\82Ì
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\82·
\82é
840 Res := DivideStrLine(ReadList[0]);
841 Res.FTitle := StringReplace(Res.FTitle, '
\81\97\81M', ',', [rfReplaceAll]);
842 sTitle := Res.FTitle;
845 sTitle := StringReplace(ThreadItem.Title, '
\81\97\81M', ',', [rfReplaceAll]);
847 SaveList := TStringList.Create;
850 doc.charset := 'Shift_JIS';
852 CSSFileName := GetStyleSheetDir + Setting.CSSFileName;
853 SkinHeaderFileName := Setting.CSSFileName + SKIN_HEADER_FILE_NAME;
854 if GikoSys.Setting.UseCSS and
855 (Pos(GetSkinDir, Setting.CSSFileName) > 0) and
856 FileExists( SkinHeaderFileName ) then begin
857 //
\83X
\83L
\83\93\8eg
\97p
859 SaveList.Add('<html><head>');
860 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
861 SaveList.Add('<title>' + sTitle + '</title>');
864 // SaveList.Add('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
866 //
\83X
\83L
\83\93\82Ì
\90Ý
\92è
867 Skin := TStringList.Create;
869 Skin.LoadFromFile( SkinHeaderFileName );
870 Skin.Text := StringReplace( Skin.Text, '&GETRESCOUNT', IntToStr( NewReceiveNo ), [rfReplaceAll] );
871 Skin.Text := StringReplace( Skin.Text, '&SKINPATH', Setting.CSSFileName, [rfReplaceAll] );
872 SaveList.AddStrings( Skin );
876 SkinNewRes := TStringList.Create;
877 SkinRes := TStringList.Create;
879 SkinNewRes.LoadFromFile( Setting.CSSFileName + SKIN_NEWRES_FILE_NAME );
880 SkinRes.LoadFromFile( Setting.CSSFileName + SKIN_RES_FILE_NAME );
884 //SaveList.Add('</head>');
885 //SaveList.Add('<body>');
886 //SaveList.Add('<dl id="dl">');
887 SaveList.Add('<a name="top"></a>');
888 //SaveList.Add('<div class="title">' + sTitle + '</div>');
890 for i := 0 to ReadList.Count - 1 do begin
891 if (Trim(ReadList[i]) <> '') then begin
892 No := IntToStr(i + 1);
893 Skin := TStringList.Create;
894 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then
895 Skin.AddStrings( SkinNewRes )
897 Skin.AddStrings( SkinRes );
899 Res := DivideStrLine(ReadList[i]);
900 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
902 if Res.FType = glt2chOld then begin
903 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
904 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
905 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
908 Res.FBody := AddAnchorTag(Res.FBody);
909 if Res.FName = '' then
910 Res.FName := ' ';
912 Skin.Text := StringReplace( Skin.Text, '&NUMBER', No, [rfReplaceAll] );
913 Skin.Text := StringReplace( Skin.Text, '&NAME', Res.FName, [rfReplaceAll] );
914 Skin.Text := StringReplace( Skin.Text, '&MAIL', Res.FMailTo, [rfReplaceAll] );
915 Skin.Text := StringReplace( Skin.Text, '&DATE', Res.FDateTime, [rfReplaceAll] );
916 Skin.Text := StringReplace( Skin.Text, '&MESSAGE', Res.FBody, [rfReplaceAll] );
917 SaveList.AddStrings( Skin );
922 //if SaveList.Count > 50 then begin
925 //Application.ProcessMessages;
927 doc.Write(SaveList.Text);
928 //while GikoForm.Browser.Busy do begin
930 // Application.ProcessMessages;
932 while (GikoForm.Browser.ReadyState <> READYSTATE_COMPLETE) and
933 (GikoForm.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
935 //Application.ProcessMessages;
941 SaveList.Add('<a name="bottom"></a>');
943 //
\83X
\83L
\83\93(
\83t
\83b
\83^)
944 Skin := TStringList.Create;
946 Skin.LoadFromFile( Setting.CSSFileName + SKIN_FOOTER_FILE_NAME );
947 SizeByte := Length( SaveList.Text );
948 Skin.Text := StringReplace( Skin.Text, '&SIZEKB', IntToStr( Floor( SizeByte / 1024 ) ), [rfReplaceAll] );
949 Skin.Text := StringReplace( Skin.Text, '&SIZE', IntToStr( SizeByte ), [rfReplaceAll] );
950 SaveList.AddStrings( Skin );
955 SaveList.Add('<a name="last"></a>');
956 SaveList.Add('</body></html>');
958 doc.Write(SaveList.Text);
962 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
964 //CSSFileName := GetAppDir + CSS_FILE_NAME;
965 // SaveList.Add('<html lang="ja"><head>');
966 SaveList.Add('<html><head>');
967 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
968 SaveList.Add('<title>' + sTitle + '</title>');
969 SaveList.Add('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
970 SaveList.Add('</head>');
971 SaveList.Add('<body>');
972 SaveList.Add('<a name="top"></a>');
973 SaveList.Add('<div class="title">' + sTitle + '</div>');
974 //doc.Write(SaveList.Text);
976 //Application.ProcessMessages;
977 for i := 0 to ReadList.Count - 1 do begin
978 if (Trim(ReadList[i]) <> '') then begin
979 No := IntToStr(i + 1);
980 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
981 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>');
983 Res := DivideStrLine(ReadList[i]);
984 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
986 if Res.FType = glt2chOld then begin
987 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
988 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
989 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
991 //Res.FBody := StringReplace(Res.FBody, '&hearts;', '♥', [rfReplaceAll]);
992 //Res.FBody := StringReplace(Res.FBody, '&nbsp;', ' ', [rfReplaceAll]);
993 //Res.FBody := StringReplace(Res.FBody, '&#', '&#', [rfReplaceAll]);
994 //Res.FBody := StringReplace(Res.FBody, '&', '&', [rfReplaceAll]);
995 Res.FBody := AddAnchorTag(Res.FBody);
996 if Res.FName = '' then
997 Res.FName := ' ';
998 if Res.FMailTo = '' then
999 SaveList.Add('<a name="' + No + '"></a>'
1000 + '<div class="header"><span class="no"><a href="giko://?no=' + No + '">' + No + '</a></span> '
1001 + '<span class="name_label">
\96¼
\91O
\81F</span> '
1002 + '<span class="name"><b>' + Res.FName + '</b></span> '
1003 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span> '
1004 + '<span class="date">' + Res.FDateTime+ '</span></div>'
1005 + '<div class="mes">' + Res.FBody + ' </div>')
1007 if GikoSys.Setting.ShowMail then
1008 SaveList.Add('<a name="' + No + '"></a>'
1009 + '<div class="header"><span class="no"><a href="giko://?no=' + No + '">' + No + '</a></span>'
1010 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1011 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1012 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
1013 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1014 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1015 + '<div class="mes">' + Res.FBody + ' </div>')
1017 SaveList.Add('<a name="' + No + '"></a>'
1018 + '<div class="header"><span class="no"><a href="giko://?no=' + No + '">' + No + '</a></span>'
1019 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1020 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1021 + '<b>' + Res.FName + '</b></a>'
1022 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1023 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1024 + '<div class="mes">' + Res.FBody + ' </div>');
1025 if ThreadItem.Kokomade = (i + 1) then begin
1026 SaveList.Add('<a name="koko"></a><div class="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</div>');
1029 //if SaveList.Count > 50 then begin
1030 if i = 20 then begin
1032 //Application.ProcessMessages;
1034 doc.Write(SaveList.Text);
1035 //while GikoForm.Browser.Busy do begin
1037 // Application.ProcessMessages;
1039 while (GikoForm.Browser.ReadyState <> READYSTATE_COMPLETE) and
1040 (GikoForm.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
1042 //Application.ProcessMessages;
1047 SaveList.Add('<a name="bottom"></a>');
1048 SaveList.Add('</body></html>');
1049 SaveList.Add('<a name="last"></a>');
1050 SaveList.Add('</body></html>');
1052 doc.Write(SaveList.Text);
1055 // SaveList.Add('<html lang="ja"><head>');
1056 SaveList.Add('<html><head>');
1057 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1058 SaveList.Add('<title>' + sTitle + '</title></head>');
1059 SaveList.Add('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1060 SaveList.Add('<a name="top"></a>');
1061 SaveList.Add('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1062 SaveList.Add('<dl>');
1063 doc.Write(SaveList.Text);
1065 //Application.ProcessMessages;
1066 for i := 0 to ReadList.Count - 1 do begin
1067 if (Trim(ReadList[i]) <> '') then begin
1068 No := IntToStr(i + 1);
1070 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1071 SaveList.Add('</dl>');
1072 SaveList.Add('<a name="new"></a>');
1073 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>');
1074 SaveList.Add('<dl>');
1076 Res := DivideStrLine(ReadList[i]);
1077 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1078 if Res.FType = glt2chOld then begin
1079 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
1080 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
1081 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
1083 //Res.FBody := StringReplace(Res.FBody, '&hearts;', '♥', [rfReplaceAll]);
1084 //Res.FBody := StringReplace(Res.FBody, '&nbsp;', ' ', [rfReplaceAll]);
1085 //Res.FBody := StringReplace(Res.FBody, '&#', '&#', [rfReplaceAll]);
1086 //Res.FBody := StringReplace(Res.FBody, '&', '&', [rfReplaceAll]);
1087 Res.FBody := AddAnchorTag(Res.FBody);
1088 if Res.FMailTo = '' then
1089 SaveList.Add('<a name="' + No + '"></a><dt><a href="giko://?no=' + 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>')
1091 if GikoSys.Setting.ShowMail then
1092 SaveList.Add('<a name="' + No + '"></a><dt><a href="giko://?no=' + 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>')
1094 SaveList.Add('<a name="' + No + '"></a><dt><a href="giko://?no=' + 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>');
1095 if ThreadItem.Kokomade = (i + 1) then begin
1096 SaveList.Add('</dl>');
1097 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>');
1098 SaveList.Add('<dl>');
1101 if SaveList.Count > 50 then begin
1102 doc.Write(SaveList.Text);
1104 //Application.ProcessMessages;
1107 SaveList.Add('</dl>');
1108 SaveList.Add('<a name="bottom"></a>');
1109 SaveList.Add('</body></html>');
1110 doc.Write(SaveList.Text);
1121 (*************************************************************************
1122 *http://
\82Ì
\95¶
\8e\9a\97ñ
\82ðanchor
\83^
\83O
\95t
\82«
\82É
\82·
\82é
\81B
1123 *************************************************************************)
1124 function TGikoSys.AddAnchorTag(s: string): string;
1126 URL_CHAR: string = '0123456789'
1127 + 'abcdefghijklmnopqrstuvwxyz'
1128 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1129 + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
1131 wkIdx: array[0..9] of Integer;
1140 wkIdx[0] := AnsiPos('http://', s);
1141 wkIdx[1] := AnsiPos('ttp://', s);
1142 wkIdx[2] := AnsiPos('tp://', s);
1143 wkIdx[3] := AnsiPos('ms-help://', s);
1144 wkIdx[4] := AnsiPos('p://', s);
1145 wkIdx[5] := AnsiPos('https://', s);
1146 wkIdx[6] := AnsiPos('www.', s);
1147 wkIdx[7] := AnsiPos('ftp://', s);
1148 wkIdx[8] := AnsiPos('news://', s);
1149 wkIdx[9] := AnsiPos('rtsp://', s);
1153 if wkIdx[i] <> 0 then idx := Min(wkIdx[i], idx);
1155 if idx = MaxInt then begin
1156 //
\83\8a\83\93\83N
\82ª
\96³
\82¢
\82æ
\81B
1157 Result := Result + s;
1161 if (idx > 1) and (Copy(s, idx - 1, 1) = '"') then begin
1162 //
\8aù
\82É
\83\8a\83\93\83N
\83^
\83O
\82ª
\82Â
\82¢
\82Ä
\82¢
\82é
\82Á
\82Û
\82¢
\82Æ
\82«
\82Í
\83\80\83V
1163 Result := Result + Copy(s, 0, idx + Length('http://') - 1);
1164 s := Copy(s, idx + Length('http://'), length(s));
1168 Result := Result + Copy(s, 0, idx - 1);
1170 s := Copy(s, idx, length(s));
1172 for i := 0 to Length(s) do begin
1173 idx := AnsiPos(s[i + 1], URL_CHAR);
1174 if (idx = 0) or (i = (Length(s))) then begin
1175 //URL
\82¶
\82á
\82È
\82¢
\95¶
\8e\9a\94
\8c©
\81I
\82Æ
\82©
\81A
\95¶
\8e\9a\82ª
\82È
\82
\82È
\82Á
\82½
\81B
1176 url := Copy(s, 0, i);
1178 if AnsiPos('ttp://', url) = 1 then
1180 else if AnsiPos('tp://', url) = 1 then
1182 else if AnsiPos('p://', url) = 1 then
1184 else if AnsiPos('www.', url) = 1 then
1185 href := 'http://' + url
1188 Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
1189 s := Copy(s, i + 1, Length(s));
1196 (*************************************************************************
1197 *
\83T
\83u
\83W
\83F
\83N
\83g
\88ê
\8ds
\82ð
\95ª
\8a\84
1198 *************************************************************************)
1199 function TGikoSys.DivideSubject(Line: string): TSubjectRec;
1209 if Pos('<>', Line) = 0 then
1214 Result.FFileName := GetTokenIndex(Line, Delim, 0);
1215 Result.FTitle := GetTokenIndex(Line, Delim, 1);
1217 ws := Trim(Result.FTitle);
1219 if Copy(ws, Length(ws), 1) = ')' then begin
1222 end else if Copy(ws, Length(ws), 1) = '
\81j' then begin
1225 end else if Copy(ws, Length(ws), 1) = '<' then begin
1230 for i := Length(ws) - 1 downto 1 do begin
1231 if ws[i] = LeftK then begin
1232 ws := Copy(ws, i + 1, Length(ws) - i - 1);
1233 if IsNumeric(ws) then
1234 Result.FCount := StrToInt(ws);
1235 Result.FTitle := Trim(StringReplace(Result.FTitle, LeftK + ws + RightK, '', [rfReplaceAll]));
1241 (*************************************************************************
1242 * dat
\83t
\83@
\83C
\83\8b\82Ì
\88ê
\83\89\83C
\83\93\82ð
\95ª
\89ð
1243 *************************************************************************)
1244 function TGikoSys.DivideStrLine(Line: string): TResRec;
1249 if Pos('<>', Line) = 0 then begin
1251 Result.FType := glt2chOld;
1254 Result.FType := glt2chNew;
1256 Result.FName := Trim(GetTokenIndex(Line, Delim, 0));
1257 Result.FMailTo := Trim(GetTokenIndex(Line, Delim, 1));
1258 Result.FDateTime := Trim(GetTokenIndex(Line, Delim, 2));
1259 bufBody := Trim(GetTokenIndex(Line, Delim, 3));
1260 if bufbody = '' then begin
1261 Insert(' ',bufbody, 1);
1263 Result.FBody := bufBody;
1264 Result.FTitle := Trim(GetTokenIndex(Line, Delim, 4));
1268 (*************************************************************************
1269 * URL
\82©
\82çBBSID
\82ð
\8eæ
\93¾
1270 *************************************************************************)
1271 function TGikoSys.UrlToID(url: string): string;
1278 if url = '' then Exit;
1280 url := Copy(url, 0, Length(url) - 1);
1281 for i := Length(url) downto 0 do begin
1282 if url[i] = '/' then begin
1283 Result := Copy(url, i + 1, Length(url));
1289 (*************************************************************************
1290 *URL
\82©
\82çBBSID
\88È
\8aO
\82Ì
\95\94\95ª(http://teri.2ch.net/)
\82ð
\8eæ
\93¾
1291 *************************************************************************)
1292 function TGikoSys.UrlToServer(url: string): string;
1299 wsURL := Trim(wsURL);
1301 if wsURL = '' then exit;
1303 if Copy(wsURL, Length(wsURL), 1) = '/' then
1304 wsURL := Copy(wsURL, 0, Length(wsURL) - 1);
1306 for i := Length(wsURL) downto 0 do begin
1307 if wsURL[i] = '/' then begin
1308 Result := Copy(wsURL, 0, i);
1314 (*************************************************************************
1315 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ª
\91¶
\8dÝ
\82·
\82é
\82©
\83`
\83F
\83b
\83N
1316 *************************************************************************)
1317 function TGikoSys.DirectoryExistsEx(const Name: string): Boolean;
1321 Code := GetFileAttributes(PChar(Name));
1322 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
1325 (*************************************************************************
1326 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\8dì
\90¬
\81i
\95¡
\90\94\8aK
\91w
\91Î
\89\9e\81j
1327 *************************************************************************)
1328 function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean;
1331 if Length(Dir) = 0 then
1332 raise Exception.Create('
\83t
\83H
\83\8b\83_
\82ª
\8dì
\90¬
\8fo
\97\88\82Ü
\82¹
\82ñ');
1333 Dir := ExcludeTrailingPathDelimiter(Dir);
1334 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
1335 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
1336 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
1339 (*************************************************************************
1340 *
\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
1341 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1342 *************************************************************************)
1343 function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1347 Result := StrTokNext(sep, Rec);
1350 (*************************************************************************
1351 *
\95¶
\8e\9a\97ñ
\82©
\82ç
\83g
\81[
\83N
\83\93\82Ì
\90Ø
\82è
\8fo
\82µ
1352 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1353 *************************************************************************)
1354 function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1361 if Len >= Pos then begin
1362 while (Pos <= Len) and (Str[Pos] in sep) do begin
1366 while (Pos<= Len) and not (Str[Pos] in sep) do begin
1367 if IsDBCSLeadByte(Byte(Str[Pos])) then begin
1372 Result := Copy(Str, I, Pos - I);
1373 while (Pos <= Len) and (Str[Pos] in sep) do begin//
\82±
\82ê
\82Í
\82¨
\8dD
\82Ý
1380 (*************************************************************************
1381 *
\83t
\83@
\83C
\83\8b\83T
\83C
\83Y
\8eæ
\93¾
1382 *************************************************************************)
1383 function TGikoSys.GetFileSize(FileName : string): longint;
1388 if not FileExists(FileName) then begin
1392 Assign(F, FileName);
1394 Result := FileSize(F);
1401 (*************************************************************************
1402 *
\83t
\83@
\83C
\83\8b\8ds
\90\94\8eæ
\93¾
1403 *************************************************************************)
1404 function TGikoSys.GetFileLineCount(FileName : string): longint;
1408 sl := TStringList.Create;
1411 sl.LoadFromFile(FileName);
1422 (*************************************************************************
1423 *
\83X
\83\8c\83b
\83h
\83t
\83@
\83C
\83\8b\82©
\82ç
\8ew
\92è
\8ds
\82ð
\8eæ
\93¾
1424 *************************************************************************)
1425 function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string;
1432 ArrBuff: array [1..BUFFER_SIZE] of Char;
1435 if FileExists(FileName) then begin
1436 AssignFile(f, FileName);
1437 System.SetTextBuf(f, ArrBuff);
1441 while not Eof(f) do begin
1443 if Line = num then begin
1456 (*************************************************************************
1457 *
\83V
\83X
\83e
\83\80\83\81\83j
\83\85\81[
\83t
\83H
\83\93\83g
\82Ì
\91®
\90«
\82ð
\8eæ
\93¾
1458 *************************************************************************)
1459 procedure TGikoSys.MenuFont(Font: TFont);
1462 nm: NONCLIENTMETRICS;
1464 nm.cbSize := sizeof(NONCLIENTMETRICS);
1466 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0);
1467 lf := nm.lfMenuFont;
1469 Font.Name := lf.lfFaceName;
1470 Font.Height := lf.lfHeight;
1472 if lf.lfWeight >= 700 then
1473 Font.Style := Font.Style + [fsBold];
1474 if lf.lfItalic = 1 then
1475 Font.Style := Font.Style + [fsItalic];
1478 (*************************************************************************
1480 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1481 *************************************************************************)
1482 function TGikoSys.RemoveToken(var s: string; delimiter: string): string;
1486 p := AnsiPos(delimiter, s);
1490 Result := Copy(s, 1, p - 1);
1491 s := Copy(s, Length(Result) + Length(delimiter) + 1, Length(s));
1494 (*************************************************************************
1496 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1497 *************************************************************************)
1498 function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string;
1503 for i := 0 to index do
1504 Result := RemoveToken(s, delimiter);
1507 (*************************************************************************
1509 *************************************************************************)
1510 function TGikoSys.DeleteLink(const s: string): string;
1520 s1 := GetTokenIndex(s, '<a href="', i);
1521 s2 := GetTokenIndex(s, '<a href="', i + 1);
1523 idx := Pos('">', s1);
1525 Delete(s1, 1, idx + 1);
1526 idx := Pos('">', s2);
1528 Delete(s2, 1, idx + 1);
1530 Result := Result + s1 + s2;
1539 //
\83C
\83\93\83f
\83b
\83N
\83X
\96¢
\8dX
\90V
\83o
\83b
\83t
\83@
\82ð
\83t
\83\89\83b
\83V
\83\85\81I
1540 {procedure TGikoSys.FlashExitWrite;
1544 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
1545 for i := 0 to FExitWrite.Count - 1 do
1546 WriteThreadDat(FExitWrite[i]);
1550 (*************************************************************************
1551 *
\83X
\83\8c\96¼
\82È
\82Ç
\82ð
\92Z
\82¢
\96¼
\91O
\82É
\95Ï
\8a·
\82·
\82é
1553 *************************************************************************)
1554 function TGikoSys.GetShortName(const LongName: string; ALength: integer): string;
1556 ERASECHAR : array [1..39] of string =
1557 ('
\81\99','
\81\9a','
\81¡','
\81 ','
\81\9f','
\81\9e','
\81Q','
\81\94','
\81£','
\81¥',
1558 '
\81¢','
\81¤','
\81\9c','
\81\9b','
\81\9d','
\81y','
\81z','
\81ô','
\81s','
\81t',
1559 '
\81g','
\81h','
\81k','
\81l','
\81e','
\81f','
\81\83','
\81\84','
\81á','
\81â',
1560 '
\81o','
\81p','
\81q','
\81r','
\81w','
\81x','
\81¬','
\81c', '
\81@');
1562 Chr : array [0..255] of char;
1566 s := Trim(LongName);
1567 if (Length(s) <= ALength) then begin
1571 for i := Low(ERASECHAR) to High(ERASECHAR) do begin
1572 S := StringReplace(S, ERASECHAR[i], '', [rfReplaceAll]);
1574 if (Length(S) <= ALength) then begin
1577 Windows.LCMapString(
1578 GetUserDefaultLCID(),
1586 S := Copy(S,1,ALength);
1588 if (ByteType(S, Length(S)) = mbLeadByte ) then begin
1589 S := Copy(S, 1, Length(S) - 1);
1599 (*************************************************************************
1602 *************************************************************************)
1603 function TGikoSys.ConvRes(const Body, Bbs, Key,
1604 ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
1608 FIndexFrom : integer;
1615 ZN = '
\82O
\82P
\82Q
\82R
\82S
\82T
\82U
\82V
\82W
\82X
\81|';
1629 procedure Add(IndexFrom, IndexTo: integer; const No: string);
1634 FIndex.FIndexFrom := IndexFrom;
1635 FIndex.FIndexTo := IndexTo;
1639 function ChooseString(const Text, Separator: string; Index: integer): string;
1645 for i := 0 to Index - 1 do begin
1646 if (AnsiPos(Separator, S) = 0) then S := ''
1647 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
1649 p := AnsiPos(Separator, S);
1650 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
1659 List:= TList.Create;
1665 b := ByteType(s, i);
1667 mbSingleByte : begin
1668 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1669 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1677 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1678 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
1684 if (not sw) and (Copy(s,i,4) = GT) then begin
1685 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1693 if ((not sw) and (Copy(s,i,1) = ',')) or
1694 ((not sw) and (Copy(s,i,1) = '=')) then begin
1695 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
1696 ((Chk) and (oc = '')) or
1697 ((not Chk) and (al)) then
1707 if (AnsiPos(sx, SN) > 0) then begin
1710 if (No <> '') and (No <> '-') then begin
1723 if Copy(s,i,1) = '<' then oc := '';
1724 oc := oc + Copy(s,i,1);
1730 if (not sw) and (Copy(s,i,4) = '
\81\84\81\84') then begin
1736 if (not sw) and (Copy(s,i,2) = '
\81\84') then begin
1744 if (AnsiPos(sx, ZN) > 0) then begin
1745 No := No + ZenToHan(sx);
1747 if (No <> '') and (No <> '-') and (No <> '
\81|') then begin
1762 if (i > Length(Body)) then begin
1764 if (No <> '') then Add(sp, i, No);
1769 for i := List.Count - 1 downto 0 do begin
1770 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
1771 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
1772 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
1774 st := PIndex(List[i]).FNo;
1775 et := PIndex(List[i]).FNo;
1777 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
1778 Format('<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">',
1779 [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
1780 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
1781 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
1782 Dispose(PIndex(List[i]));
1788 (*************************************************************************
1789 *
\91S
\8ap
\81¨
\94¼
\8ap
1791 *************************************************************************)
1792 function TGikoSys.ZenToHan(const s: string): string;
1794 Chr: array [0..255] of char;
1796 Windows.LCMapString(
1797 GetUserDefaultLCID(),
1799 LCMAP_HALFWIDTH or LCMAP_KATAKANA or LCMAP_LOWERCASE,
1808 (*************************************************************************
1809 *
\91S
\8ap
\94¼
\8ap
\82Ð
\82ç
\82ª
\82È
\82©
\82½
\82©
\82È
\82ð
\8bæ
\95Ê
\82µ
\82È
\82¢
\90¦
\82¢Pos
1810 *************************************************************************)
1811 function TGikoSys.VaguePos(const Substr, S: string): Integer;
1813 Result := Pos(ZenToHan(Substr), ZenToHan(S));
1816 function TGikoSys.BoolToInt(b: Boolean): Integer;
1818 Result := IfThen(b, 1, 0);
1821 function TGikoSys.IntToBool(i: Integer): Boolean;
1826 //gzip
\82Å
\88³
\8fk
\82³
\82ê
\82½
\82Ì
\82ð
\96ß
\82·
1827 function TGikoSys.GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
1831 GZipStream: TGzipDecompressStream;
1832 TextStream: TStringStream;
1833 buf: array[0..BUF_SIZE - 1] of Byte;
1839 TextStream := TStringStream.Create('');
1841 //
\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¢)
1842 // if LowerCase(Trim(ContentEncoding)) = 'gzip' then begin
1843 if AnsiPos('gzip', LowerCase(Trim(ContentEncoding))) > 0 then begin
1844 ResStream.Position := 0;
1845 GZipStream := TGzipDecompressStream.Create(TextStream);
1848 FillChar(buf, BUF_SIZE, 0);
1849 cnt := ResStream.Read(buf, BUF_SIZE);
1851 GZipStream.Write(buf, BUF_SIZE);
1857 ResStream.Position := 0;
1859 FillChar(buf, BUF_SIZE, 0);
1860 cnt := ResStream.Read(buf, BUF_SIZE);
1862 TextStream.Write(buf, BUF_SIZE);
1866 //NULL
\95¶
\8e\9a\82ð"*"
\82É
\82·
\82é
1867 s := TextStream.DataString;
1869 while (i > 0) and (s[i] = #0) do
1874 while i <> 0 do begin
1884 procedure TGikoSys.LoadKeySetting(ActionList: TActionList);
1886 STD_SEC = 'KeySetting';
1892 SecList: TStringList;
1893 Component: TComponent;
1895 if not FileExists(GetConfigDir + KEY_SETTING_FILE_NAME) then
1897 SecList := TStringList.Create;
1898 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
1900 ini.ReadSection(STD_SEC, SecList);
1901 for i := 0 to SecList.Count - 1 do begin
1902 ActionName := SecList[i];
1903 ActionKey := ini.ReadInteger(STD_SEC, ActionName, -1);
1904 if ActionKey <> -1 then begin
1905 Component := ActionList.Owner.FindComponent(ActionName);
1906 if TObject(Component) is TAction then begin
1907 TAction(Component).ShortCut := ActionKey;
1917 procedure TGikoSys.SaveKeySetting(ActionList: TActionList);
1919 STD_SEC = 'KeySetting';
1924 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
1926 for i := 0 to ActionList.ActionCount - 1 do begin
1927 if ActionList.Actions[i].Tag = -1 then
1929 ini.WriteInteger(STD_SEC, ActionList.Actions[i].Name, TAction(ActionList.Actions[i]).ShortCut);
1938 procedure TGikoSys.CreateProcess(const AppPath: string; const Param: string);
1940 PI: TProcessInformation;
1944 Path := '"' + AppPath + '"';
1946 Path := Path + ' ' + Param;
1948 SI.Cb := SizeOf(Si);
1949 SI.lpReserved := nil;
1950 SI.lpDesktop := nil;
1953 SI.cbReserved2 := 0;
1954 SI.lpReserved2 := nil;
1956 Windows.CreateProcess(nil,
1968 procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
1972 HlinkNavigateString(nil, PWideChar(WideString(URL)));
1973 gbtUserApp, gbtAuto:
1974 if (Setting.URLApp) and (FileExists(Setting.URLAppFile)) then
1975 GikoSys.CreateProcess(Setting.URLAppFile, URL)
1977 HlinkNavigateString(nil, PWideChar(WideString(URL)));
1981 function TGikoSys.HTMLDecode(const AStr: String): String;
1983 Sp, Rp, Cp, Tp: PChar;
1988 SetLength(Result, Length(AStr));
1990 Rp := PChar(Result);
1993 while Sp^ <> #0 do begin
1999 'a': if AnsiStrPos(Sp, 'amp;') = Sp then
2005 'g': if (AnsiStrPos(Sp, 'lt;') = Sp) or (AnsiStrPos(Sp, 'gt;') = Sp) then
2009 while (Sp^ <> ';') and (Sp^ <> #0) do
2016 'q': if AnsiStrPos(Sp, 'quot;') = Sp then
2024 Num := IsNumeric(Copy(Tp, 1, 1));
2025 while (Sp^ <> ';') and (Sp^ <> #0) do begin
2026 if (Num) and (not IsNumeric(Copy(Sp, 1, 1))) then
2030 SetString(S, Tp, Sp - Tp);
2035 //raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2036 //[Cp^ + Sp^, Cp - PChar(AStr)])
2046 // on E:EConvertError do
2047 // raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2048 // [Cp^ + Sp^, Cp - PChar(AStr)])
2050 SetLength(Result, Rp - PChar(Result));
2053 function TGikoSys.GetHRefText(s: string): string;
2063 Index := AnsiPos('href', LowerCase(s));
2066 s := Trim(Copy(s, Index + 4, Length(s)));
2067 s := Trim(Copy(s, 2, Length(s)));
2069 //
\8en
\82ß
\82Ì
\95¶
\8e\9a\82ª'"'
\82È
\82ç
\8eæ
\82è
\8f\9c\82
2070 if Copy(s, 1, 1) = '"' then begin
2071 s := Trim(Copy(s, 2, Length(s)));
2074 Index := AnsiPos('"', s);
2075 if Index <> 0 then begin
2076 //'"'
\82Ü
\82ÅURL
\82Æ
\82·
\82é
2077 s := Copy(s, 1, Index - 1);
2079 //'"'
\82ª
\96³
\82¯
\82ê
\82Î
\83X
\83y
\81[
\83X
\82©">"
\82Ì
\91\81\82¢
\95û
\82Ü
\82Å
\82ðURL
\82Æ
\82·
\82é
2080 Index := AnsiPos(' ', s);
2081 Index2 := AnsiPos('>', s);
2084 if Index > Index2 then
2087 s := Copy(s, 1, Index - 1)
2089 //
\82±
\82ê
\88È
\8fã
\82à
\82¤
\92m
\82ç
\82ñ
\82Ê
2095 //
\83z
\83X
\83g
\96¼
\82ª
\82Q
\82\83\82\88\82©
\82Ç
\82¤
\82©
\83`
\83F
\83b
\83N
\82·
\82é
2096 function TGikoSys.Is2chHost(Host: string): Boolean;
2098 HOST_NAME: array[0..1] of string = ('2ch.net', 'bbspink.com');
2104 OutputDebugString(pchar(HOST_NAME[0]));
2105 for i := 0 to Length(HOST_NAME) - 1 do begin
2106 // Len := Length(HOST_NAME[i]);
2107 if AnsiPos(HOST_NAME[i], Host) = (Length(Host) - Length(HOST_NAME[i]) + 1) then begin
2114 function TGikoSys.Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
2116 READ_PATH: string = '/test/read.cgi/';
2117 OLD_READ_PATH: string = '/test/read.cgi?';
2118 KAKO_PATH: string = '/kako/';
2128 Index := AnsiPos(READ_PATH, path);
2129 if Index <> 0 then begin
2130 s := Copy(path, Length(READ_PATH) + 1, Length(path));
2131 BBSID := GetTokenIndex(s, '/', 0);
2132 BBSKey := GetTokenIndex(s, '/', 1);
2135 Result := (BBSID <> '') or (BBSKey <> '');
2138 Index := AnsiPos(KAKO_PATH, path);
2139 if Index <> 0 then begin
2140 s := Copy(path, 2, Length(path));
2141 BBSID := GetTokenIndex(s, '/', 0);
2142 if (BBSID = 'log') and (GetTokenIndex(s, '/', 2) = 'kako') then
2143 BBSID := GetTokenIndex(s, '/', 1);
2144 BBSKey := ChangeFileExt(Document, '');
2145 Result := (BBSID <> '') or (BBSKey <> '');
2148 Index := AnsiPos('read.cgi?', URL);
2149 if Index <> 0 then begin
2150 SList := TStringList.Create;
2153 // s := HTMLDecode(Document);
2154 ExtractHTTPFields(['?', '&'], [], PChar(URL), SList, False);
2155 BBSID := SList.Values['bbs'];
2156 BBSKey := SList.Values['key'];
2157 Result := (BBSID <> '') or (BBSKey <> '');
2168 function TGikoSys.Parse2chURL2(URL: string): TPathRec;
2180 URL := Trim(LowerCase(URL));
2185 Result.FFirst := False;
2186 Result.FStBegin := False;
2187 Result.FToEnd := False;
2188 Result.FDone := False;
2193 FAWKStr.RegExp := 'http://.+\.(2ch\.net|bbspink\.com)/';
2194 if FAWKStr.Match(FAWKStr.ProcessEscSeq(URL), RStart, RLength) = 0 then
2196 s := Copy(URL, RStart + RLength - 1, Length(URL));
2198 //
\95W
\8f\80\8f\91\8e®
2199 //
\8dÅ
\8cã
\82Íl50, 10, 10-20, 10n, 10-20n, -10, 10-, 10n-
\82È
\82Ç
2200 //http://xxx.2ch.net/test/read.cgi/bbsid/1000000000/
2201 FAWKStr.RegExp := '/test/read.cgi/.+/[0-9]+/.*';
2202 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2203 s := Copy(s, 15, Length(s));
2205 SList := TStringList.Create;
2208 FAWKStr.RegExp := '/';
2209 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2210 Result.FBBS := SList[1];
2211 Result.FKey := SList[2];
2212 if SList.Count >= 3 then
2220 FAWKStr.LineSeparator := mcls_CRLF;
2221 FAWKStr.RegExp := '-';
2222 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) = 0 then begin
2223 Result.FFirst := True;
2225 FAWKStr.RegExp := 'l[0-9]+';
2226 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2227 Result.FFirst := True;
2229 for i := 0 to SList.Count - 1 do begin
2230 if Trim(SList[i]) = '' then begin
2232 Result.FStBegin := True;
2233 if i = (SList.Count - 1) then
2234 Result.FToEnd := True;
2235 end else if IsNumeric(SList[i]) then begin
2236 wkInt := StrToInt(SList[i]);
2237 wkMax := Max(wkMax, wkInt);
2241 wkMin := Min(wkMin, wkInt);
2242 end else if Trim(SList[i]) = 'n' then begin
2243 Result.FFirst := True;
2245 FAWKStr.RegExp := '^n[0-9]+$|^[0-9]+n$';
2246 if FAWKStr.Match(FAWKStr.ProcessEscSeq(SList[i]), RStart, RLength) > 0 then begin
2247 if Copy(SList[i], 1, 1) = 'n' then
2248 wkInt := StrToInt(Copy(SList[i], 2, Length(SList[i])))
2250 wkInt := StrToInt(Copy(SList[i], 1, Length(SList[i]) - 1));
2251 Result.FFirst := True;
2252 wkMax := Max(wkMax, wkInt);
2256 wkMin := Min(wkMin, wkInt);
2260 if Result.FStBegin and (not Result.FToEnd) then
2262 else if (not Result.FStBegin) and Result.FToEnd then
2264 else if (not Result.FStBegin) and (not Result.FToEnd) then begin
2265 Result.FSt := wkMin;
2266 Result.FTo := wkMax;
2268 //Result.FSt := wkMin;
2269 //Result.FTo := wkMax;
2275 Result.FDone := True;
2279 //
\90Vkako
\8f\91\8e®
2280 //http://server.2ch.net/ITA_NAME/kako/1000/10000/1000000000.html
2281 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+/[0-9]+\.html';
2282 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2283 SList := TStringList.Create;
2286 FAWKStr.RegExp := '/';
2287 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2288 Result.FBBS := SList[1];
2289 Result.FKey := ChangeFileExt(SList[5], '');
2290 Result.FFirst := True;
2296 Result.FDone := True;
2300 //
\8b\8ckako
\8f\91\8e®
2301 //http://server.2ch.net/ITA_NAME/kako/999/999999999.html
2302 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+\.html';
2303 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2304 SList := TStringList.Create;
2307 FAWKStr.RegExp := '/';
2308 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 5 then begin
2309 Result.FBBS := SList[1];
2310 Result.FKey := ChangeFileExt(SList[4], '');
2311 Result.FFirst := True;
2317 Result.FDone := True;
2321 //log
\8by
\82Ñlog2
\8f\91\8e®
2322 //http://server.2ch.net/log/ITA_NAME/kako/999/999999999.html
2323 //http://server.2ch.net/log2/ITA_NAME/kako/999/999999999.html
2324 FAWKStr.RegExp := '/log2?/.+/kako/[0-9]+/[0-9]+\.html';
2325 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2326 SList := TStringList.Create;
2329 FAWKStr.RegExp := '/';
2330 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2331 Result.FBBS := SList[2];
2332 Result.FKey := ChangeFileExt(SList[5], '');
2333 Result.FFirst := True;
2339 Result.FDone := True;
2344 //
\8b\8cURL
\8f\91\8e®
2345 //http://server.2ch.net/test/read.cgi?bbs=ITA_NAME&key=1000000000&st=1&to=5&nofirst=true
2346 FAWKStr.RegExp := '/test/read\.cgi\?';
2347 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2348 s := Copy(s, 16, Length(s));
2349 SList := TStringList.Create;
2352 FAWKStr.RegExp := '&';
2353 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2354 Result.FFirst := True;
2355 for i := 0 to SList.Count - 1 do begin
2356 if Pos('bbs=', SList[i]) = 1 then begin
2357 Result.FBBS := Copy(SList[i], 5, Length(SList[i]));
2358 end else if Pos('key=', SList[i]) = 1 then begin
2359 Result.FKey := Copy(SList[i], 5, Length(SList[i]));
2360 end else if Pos('st=', SList[i]) = 1 then begin
2361 wk := Copy(SList[i], 4, Length(SList[i]));
2362 if IsNumeric(wk) then
2363 Result.FSt := StrToInt(wk)
2364 else if wk = '' then
2365 Result.FStBegin := True;
2366 end else if Pos('to=', SList[i]) = 1 then begin
2367 wk := Copy(SList[i], 4, Length(SList[i]));
2368 if IsNumeric(wk) then
2369 Result.FTo := StrToInt(wk)
2370 else if wk = '' then
2371 Result.FToEnd := True;
2372 end else if Pos('nofirst=', SList[i]) = 1 then begin
2373 Result.FFirst := False;
2382 if (Result.FBBS <> '') and (Result.FKey <> '') then begin
2383 Result.FDone := True;
2389 procedure TGikoSys.ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
2399 URI := TIdURI.Create(URL);
2401 Protocol := URI.Protocol;
2404 Document := URI.Document;
2406 Bookmark := URI.Bookmark;
2412 function TGikoSys.GetVersionBuild: Integer;
2414 FixedFileInfo: PVSFixedFileInfo;
2415 VersionHandle, VersionSize: DWORD;
2416 pVersionInfo: Pointer;
2421 AppFile := Application.ExeName;
2422 VersionSize := GetFileVersionInfoSize(pChar(AppFile), VersionHandle);
2423 if VersionSize = 0 then
2425 GetMem(pVersionInfo, VersionSize);
2427 if GetFileVersionInfo(PChar(AppFile),VersionHandle,VersionSize, pVersionInfo) then
2428 if VerQueryValue(pVersionInfo, '\', Pointer(FixedFileInfo), ItemLen) then
2429 Result := LOWORD(FixedFileInfo^.dwFileVersionLS);
2431 FreeMem(pVersionInfo, VersionSize);
2436 GikoSys := TGikoSys.Create;
2439 if GikoSys <> nil then begin