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;
895 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then
896 SaveList.Add('<a name="new"></a>');
898 if NewReceiveNo <= (i + 1) then
899 Skin.AddStrings( SkinNewRes )
901 Skin.AddStrings( SkinRes );
903 Res := DivideStrLine(ReadList[i]);
904 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
906 if Res.FType = glt2chOld then begin
907 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
908 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
909 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
912 Res.FBody := AddAnchorTag(Res.FBody);
913 if Res.FName = '' then
914 Res.FName := ' ';
916 Skin.Text := StringReplace( Skin.Text, '&NUMBER', No, [rfReplaceAll] );
917 Skin.Text := StringReplace( Skin.Text, '&NAME', Res.FName, [rfReplaceAll] );
918 Skin.Text := StringReplace( Skin.Text, '&MAIL', Res.FMailTo, [rfReplaceAll] );
919 Skin.Text := StringReplace( Skin.Text, '&DATE', Res.FDateTime, [rfReplaceAll] );
920 Skin.Text := StringReplace( Skin.Text, '&MESSAGE', Res.FBody, [rfReplaceAll] );
921 SaveList.AddStrings( Skin );
925 if ThreadItem.Kokomade = (i + 1) then
926 SaveList.Add('<dt><a name="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</a></dt>');
929 //if SaveList.Count > 50 then begin
932 //Application.ProcessMessages;
934 doc.Write(SaveList.Text);
935 //while GikoForm.Browser.Busy do begin
937 // Application.ProcessMessages;
939 while (GikoForm.Browser.ReadyState <> READYSTATE_COMPLETE) and
940 (GikoForm.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
942 //Application.ProcessMessages;
948 SaveList.Add('<a name="bottom"></a>');
950 //
\83X
\83L
\83\93(
\83t
\83b
\83^)
951 Skin := TStringList.Create;
953 Skin.LoadFromFile( Setting.CSSFileName + SKIN_FOOTER_FILE_NAME );
954 SizeByte := Length( SaveList.Text );
955 Skin.Text := StringReplace( Skin.Text, '&SIZEKB', IntToStr( Floor( SizeByte / 1024 ) ), [rfReplaceAll] );
956 Skin.Text := StringReplace( Skin.Text, '&SIZE', IntToStr( SizeByte ), [rfReplaceAll] );
957 SaveList.AddStrings( Skin );
962 SaveList.Add('<a name="last"></a>');
963 SaveList.Add('</body></html>');
965 doc.Write(SaveList.Text);
969 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
971 //CSSFileName := GetAppDir + CSS_FILE_NAME;
972 // SaveList.Add('<html lang="ja"><head>');
973 SaveList.Add('<html><head>');
974 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
975 SaveList.Add('<title>' + sTitle + '</title>');
976 SaveList.Add('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
977 SaveList.Add('</head>');
978 SaveList.Add('<body>');
979 SaveList.Add('<a name="top"></a>');
980 SaveList.Add('<div class="title">' + sTitle + '</div>');
981 //doc.Write(SaveList.Text);
983 //Application.ProcessMessages;
984 for i := 0 to ReadList.Count - 1 do begin
985 if (Trim(ReadList[i]) <> '') then begin
986 No := IntToStr(i + 1);
987 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
988 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>');
990 Res := DivideStrLine(ReadList[i]);
991 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
993 if Res.FType = glt2chOld then begin
994 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
995 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
996 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
998 //Res.FBody := StringReplace(Res.FBody, '&hearts;', '♥', [rfReplaceAll]);
999 //Res.FBody := StringReplace(Res.FBody, '&nbsp;', ' ', [rfReplaceAll]);
1000 //Res.FBody := StringReplace(Res.FBody, '&#', '&#', [rfReplaceAll]);
1001 //Res.FBody := StringReplace(Res.FBody, '&', '&', [rfReplaceAll]);
1002 Res.FBody := AddAnchorTag(Res.FBody);
1003 if Res.FName = '' then
1004 Res.FName := ' ';
1005 if Res.FMailTo = '' then
1006 SaveList.Add('<a name="' + No + '"></a>'
1007 + '<div class="header"><span class="no"><a href="giko://?no=' + No + '">' + No + '</a></span> '
1008 + '<span class="name_label">
\96¼
\91O
\81F</span> '
1009 + '<span class="name"><b>' + Res.FName + '</b></span> '
1010 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span> '
1011 + '<span class="date">' + Res.FDateTime+ '</span></div>'
1012 + '<div class="mes">' + Res.FBody + ' </div>')
1014 if GikoSys.Setting.ShowMail then
1015 SaveList.Add('<a name="' + No + '"></a>'
1016 + '<div class="header"><span class="no"><a href="giko://?no=' + No + '">' + No + '</a></span>'
1017 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1018 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1019 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
1020 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1021 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1022 + '<div class="mes">' + Res.FBody + ' </div>')
1024 SaveList.Add('<a name="' + No + '"></a>'
1025 + '<div class="header"><span class="no"><a href="giko://?no=' + No + '">' + No + '</a></span>'
1026 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1027 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1028 + '<b>' + Res.FName + '</b></a>'
1029 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1030 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1031 + '<div class="mes">' + Res.FBody + ' </div>');
1032 if ThreadItem.Kokomade = (i + 1) then begin
1033 SaveList.Add('<a name="koko"></a><div class="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</div>');
1036 //if SaveList.Count > 50 then begin
1037 if i = 20 then begin
1039 //Application.ProcessMessages;
1041 doc.Write(SaveList.Text);
1042 //while GikoForm.Browser.Busy do begin
1044 // Application.ProcessMessages;
1046 while (GikoForm.Browser.ReadyState <> READYSTATE_COMPLETE) and
1047 (GikoForm.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
1049 //Application.ProcessMessages;
1054 SaveList.Add('<a name="bottom"></a>');
1055 SaveList.Add('</body></html>');
1056 SaveList.Add('<a name="last"></a>');
1057 SaveList.Add('</body></html>');
1059 doc.Write(SaveList.Text);
1062 // SaveList.Add('<html lang="ja"><head>');
1063 SaveList.Add('<html><head>');
1064 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1065 SaveList.Add('<title>' + sTitle + '</title></head>');
1066 SaveList.Add('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1067 SaveList.Add('<a name="top"></a>');
1068 SaveList.Add('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1069 SaveList.Add('<dl>');
1070 doc.Write(SaveList.Text);
1072 //Application.ProcessMessages;
1073 for i := 0 to ReadList.Count - 1 do begin
1074 if (Trim(ReadList[i]) <> '') then begin
1075 No := IntToStr(i + 1);
1077 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1078 SaveList.Add('</dl>');
1079 SaveList.Add('<a name="new"></a>');
1080 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>');
1081 SaveList.Add('<dl>');
1083 Res := DivideStrLine(ReadList[i]);
1084 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1085 if Res.FType = glt2chOld then begin
1086 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
1087 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
1088 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
1090 //Res.FBody := StringReplace(Res.FBody, '&hearts;', '♥', [rfReplaceAll]);
1091 //Res.FBody := StringReplace(Res.FBody, '&nbsp;', ' ', [rfReplaceAll]);
1092 //Res.FBody := StringReplace(Res.FBody, '&#', '&#', [rfReplaceAll]);
1093 //Res.FBody := StringReplace(Res.FBody, '&', '&', [rfReplaceAll]);
1094 Res.FBody := AddAnchorTag(Res.FBody);
1095 if Res.FMailTo = '' then
1096 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>')
1098 if GikoSys.Setting.ShowMail then
1099 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>')
1101 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>');
1102 if ThreadItem.Kokomade = (i + 1) then begin
1103 SaveList.Add('</dl>');
1104 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>');
1105 SaveList.Add('<dl>');
1108 if SaveList.Count > 50 then begin
1109 doc.Write(SaveList.Text);
1111 //Application.ProcessMessages;
1114 SaveList.Add('</dl>');
1115 SaveList.Add('<a name="bottom"></a>');
1116 SaveList.Add('</body></html>');
1117 doc.Write(SaveList.Text);
1128 (*************************************************************************
1129 *http://
\82Ì
\95¶
\8e\9a\97ñ
\82ðanchor
\83^
\83O
\95t
\82«
\82É
\82·
\82é
\81B
1130 *************************************************************************)
1131 function TGikoSys.AddAnchorTag(s: string): string;
1133 URL_CHAR: string = '0123456789'
1134 + 'abcdefghijklmnopqrstuvwxyz'
1135 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1136 + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
1138 wkIdx: array[0..9] of Integer;
1147 wkIdx[0] := AnsiPos('http://', s);
1148 wkIdx[1] := AnsiPos('ttp://', s);
1149 wkIdx[2] := AnsiPos('tp://', s);
1150 wkIdx[3] := AnsiPos('ms-help://', s);
1151 wkIdx[4] := AnsiPos('p://', s);
1152 wkIdx[5] := AnsiPos('https://', s);
1153 wkIdx[6] := AnsiPos('www.', s);
1154 wkIdx[7] := AnsiPos('ftp://', s);
1155 wkIdx[8] := AnsiPos('news://', s);
1156 wkIdx[9] := AnsiPos('rtsp://', s);
1160 if wkIdx[i] <> 0 then idx := Min(wkIdx[i], idx);
1162 if idx = MaxInt then begin
1163 //
\83\8a\83\93\83N
\82ª
\96³
\82¢
\82æ
\81B
1164 Result := Result + s;
1168 if (idx > 1) and (Copy(s, idx - 1, 1) = '"') then begin
1169 //
\8aù
\82É
\83\8a\83\93\83N
\83^
\83O
\82ª
\82Â
\82¢
\82Ä
\82¢
\82é
\82Á
\82Û
\82¢
\82Æ
\82«
\82Í
\83\80\83V
1170 Result := Result + Copy(s, 0, idx + Length('http://') - 1);
1171 s := Copy(s, idx + Length('http://'), length(s));
1175 Result := Result + Copy(s, 0, idx - 1);
1177 s := Copy(s, idx, length(s));
1179 for i := 0 to Length(s) do begin
1180 idx := AnsiPos(s[i + 1], URL_CHAR);
1181 if (idx = 0) or (i = (Length(s))) then begin
1182 //URL
\82¶
\82á
\82È
\82¢
\95¶
\8e\9a\94
\8c©
\81I
\82Æ
\82©
\81A
\95¶
\8e\9a\82ª
\82È
\82
\82È
\82Á
\82½
\81B
1183 url := Copy(s, 0, i);
1185 if AnsiPos('ttp://', url) = 1 then
1187 else if AnsiPos('tp://', url) = 1 then
1189 else if AnsiPos('p://', url) = 1 then
1191 else if AnsiPos('www.', url) = 1 then
1192 href := 'http://' + url
1195 Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
1196 s := Copy(s, i + 1, Length(s));
1203 (*************************************************************************
1204 *
\83T
\83u
\83W
\83F
\83N
\83g
\88ê
\8ds
\82ð
\95ª
\8a\84
1205 *************************************************************************)
1206 function TGikoSys.DivideSubject(Line: string): TSubjectRec;
1216 if Pos('<>', Line) = 0 then
1221 Result.FFileName := GetTokenIndex(Line, Delim, 0);
1222 Result.FTitle := GetTokenIndex(Line, Delim, 1);
1224 ws := Trim(Result.FTitle);
1226 if Copy(ws, Length(ws), 1) = ')' then begin
1229 end else if Copy(ws, Length(ws), 1) = '
\81j' then begin
1232 end else if Copy(ws, Length(ws), 1) = '<' then begin
1237 for i := Length(ws) - 1 downto 1 do begin
1238 if ws[i] = LeftK then begin
1239 ws := Copy(ws, i + 1, Length(ws) - i - 1);
1240 if IsNumeric(ws) then
1241 Result.FCount := StrToInt(ws);
1242 Result.FTitle := Trim(StringReplace(Result.FTitle, LeftK + ws + RightK, '', [rfReplaceAll]));
1248 (*************************************************************************
1249 * dat
\83t
\83@
\83C
\83\8b\82Ì
\88ê
\83\89\83C
\83\93\82ð
\95ª
\89ð
1250 *************************************************************************)
1251 function TGikoSys.DivideStrLine(Line: string): TResRec;
1256 if Pos('<>', Line) = 0 then begin
1258 Result.FType := glt2chOld;
1261 Result.FType := glt2chNew;
1263 Result.FName := Trim(GetTokenIndex(Line, Delim, 0));
1264 Result.FMailTo := Trim(GetTokenIndex(Line, Delim, 1));
1265 Result.FDateTime := Trim(GetTokenIndex(Line, Delim, 2));
1266 bufBody := Trim(GetTokenIndex(Line, Delim, 3));
1267 if bufbody = '' then begin
1268 Insert(' ',bufbody, 1);
1270 Result.FBody := bufBody;
1271 Result.FTitle := Trim(GetTokenIndex(Line, Delim, 4));
1275 (*************************************************************************
1276 * URL
\82©
\82çBBSID
\82ð
\8eæ
\93¾
1277 *************************************************************************)
1278 function TGikoSys.UrlToID(url: string): string;
1285 if url = '' then Exit;
1287 url := Copy(url, 0, Length(url) - 1);
1288 for i := Length(url) downto 0 do begin
1289 if url[i] = '/' then begin
1290 Result := Copy(url, i + 1, Length(url));
1296 (*************************************************************************
1297 *URL
\82©
\82çBBSID
\88È
\8aO
\82Ì
\95\94\95ª(http://teri.2ch.net/)
\82ð
\8eæ
\93¾
1298 *************************************************************************)
1299 function TGikoSys.UrlToServer(url: string): string;
1306 wsURL := Trim(wsURL);
1308 if wsURL = '' then exit;
1310 if Copy(wsURL, Length(wsURL), 1) = '/' then
1311 wsURL := Copy(wsURL, 0, Length(wsURL) - 1);
1313 for i := Length(wsURL) downto 0 do begin
1314 if wsURL[i] = '/' then begin
1315 Result := Copy(wsURL, 0, i);
1321 (*************************************************************************
1322 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ª
\91¶
\8dÝ
\82·
\82é
\82©
\83`
\83F
\83b
\83N
1323 *************************************************************************)
1324 function TGikoSys.DirectoryExistsEx(const Name: string): Boolean;
1328 Code := GetFileAttributes(PChar(Name));
1329 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
1332 (*************************************************************************
1333 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\8dì
\90¬
\81i
\95¡
\90\94\8aK
\91w
\91Î
\89\9e\81j
1334 *************************************************************************)
1335 function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean;
1338 if Length(Dir) = 0 then
1339 raise Exception.Create('
\83t
\83H
\83\8b\83_
\82ª
\8dì
\90¬
\8fo
\97\88\82Ü
\82¹
\82ñ');
1340 Dir := ExcludeTrailingPathDelimiter(Dir);
1341 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
1342 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
1343 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
1346 (*************************************************************************
1347 *
\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
1348 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1349 *************************************************************************)
1350 function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1354 Result := StrTokNext(sep, Rec);
1357 (*************************************************************************
1358 *
\95¶
\8e\9a\97ñ
\82©
\82ç
\83g
\81[
\83N
\83\93\82Ì
\90Ø
\82è
\8fo
\82µ
1359 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1360 *************************************************************************)
1361 function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1368 if Len >= Pos then begin
1369 while (Pos <= Len) and (Str[Pos] in sep) do begin
1373 while (Pos<= Len) and not (Str[Pos] in sep) do begin
1374 if IsDBCSLeadByte(Byte(Str[Pos])) then begin
1379 Result := Copy(Str, I, Pos - I);
1380 while (Pos <= Len) and (Str[Pos] in sep) do begin//
\82±
\82ê
\82Í
\82¨
\8dD
\82Ý
1387 (*************************************************************************
1388 *
\83t
\83@
\83C
\83\8b\83T
\83C
\83Y
\8eæ
\93¾
1389 *************************************************************************)
1390 function TGikoSys.GetFileSize(FileName : string): longint;
1395 if not FileExists(FileName) then begin
1399 Assign(F, FileName);
1401 Result := FileSize(F);
1408 (*************************************************************************
1409 *
\83t
\83@
\83C
\83\8b\8ds
\90\94\8eæ
\93¾
1410 *************************************************************************)
1411 function TGikoSys.GetFileLineCount(FileName : string): longint;
1415 sl := TStringList.Create;
1418 sl.LoadFromFile(FileName);
1429 (*************************************************************************
1430 *
\83X
\83\8c\83b
\83h
\83t
\83@
\83C
\83\8b\82©
\82ç
\8ew
\92è
\8ds
\82ð
\8eæ
\93¾
1431 *************************************************************************)
1432 function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string;
1439 ArrBuff: array [1..BUFFER_SIZE] of Char;
1442 if FileExists(FileName) then begin
1443 AssignFile(f, FileName);
1444 System.SetTextBuf(f, ArrBuff);
1448 while not Eof(f) do begin
1450 if Line = num then begin
1463 (*************************************************************************
1464 *
\83V
\83X
\83e
\83\80\83\81\83j
\83\85\81[
\83t
\83H
\83\93\83g
\82Ì
\91®
\90«
\82ð
\8eæ
\93¾
1465 *************************************************************************)
1466 procedure TGikoSys.MenuFont(Font: TFont);
1469 nm: NONCLIENTMETRICS;
1471 nm.cbSize := sizeof(NONCLIENTMETRICS);
1473 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0);
1474 lf := nm.lfMenuFont;
1476 Font.Name := lf.lfFaceName;
1477 Font.Height := lf.lfHeight;
1479 if lf.lfWeight >= 700 then
1480 Font.Style := Font.Style + [fsBold];
1481 if lf.lfItalic = 1 then
1482 Font.Style := Font.Style + [fsItalic];
1485 (*************************************************************************
1487 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1488 *************************************************************************)
1489 function TGikoSys.RemoveToken(var s: string; delimiter: string): string;
1493 p := AnsiPos(delimiter, s);
1497 Result := Copy(s, 1, p - 1);
1498 s := Copy(s, Length(Result) + Length(delimiter) + 1, Length(s));
1501 (*************************************************************************
1503 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1504 *************************************************************************)
1505 function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string;
1510 for i := 0 to index do
1511 Result := RemoveToken(s, delimiter);
1514 (*************************************************************************
1516 *************************************************************************)
1517 function TGikoSys.DeleteLink(const s: string): string;
1527 s1 := GetTokenIndex(s, '<a href="', i);
1528 s2 := GetTokenIndex(s, '<a href="', i + 1);
1530 idx := Pos('">', s1);
1532 Delete(s1, 1, idx + 1);
1533 idx := Pos('">', s2);
1535 Delete(s2, 1, idx + 1);
1537 Result := Result + s1 + s2;
1546 //
\83C
\83\93\83f
\83b
\83N
\83X
\96¢
\8dX
\90V
\83o
\83b
\83t
\83@
\82ð
\83t
\83\89\83b
\83V
\83\85\81I
1547 {procedure TGikoSys.FlashExitWrite;
1551 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
1552 for i := 0 to FExitWrite.Count - 1 do
1553 WriteThreadDat(FExitWrite[i]);
1557 (*************************************************************************
1558 *
\83X
\83\8c\96¼
\82È
\82Ç
\82ð
\92Z
\82¢
\96¼
\91O
\82É
\95Ï
\8a·
\82·
\82é
1560 *************************************************************************)
1561 function TGikoSys.GetShortName(const LongName: string; ALength: integer): string;
1563 ERASECHAR : array [1..39] of string =
1564 ('
\81\99','
\81\9a','
\81¡','
\81 ','
\81\9f','
\81\9e','
\81Q','
\81\94','
\81£','
\81¥',
1565 '
\81¢','
\81¤','
\81\9c','
\81\9b','
\81\9d','
\81y','
\81z','
\81ô','
\81s','
\81t',
1566 '
\81g','
\81h','
\81k','
\81l','
\81e','
\81f','
\81\83','
\81\84','
\81á','
\81â',
1567 '
\81o','
\81p','
\81q','
\81r','
\81w','
\81x','
\81¬','
\81c', '
\81@');
1569 Chr : array [0..255] of char;
1573 s := Trim(LongName);
1574 if (Length(s) <= ALength) then begin
1578 for i := Low(ERASECHAR) to High(ERASECHAR) do begin
1579 S := StringReplace(S, ERASECHAR[i], '', [rfReplaceAll]);
1581 if (Length(S) <= ALength) then begin
1584 Windows.LCMapString(
1585 GetUserDefaultLCID(),
1593 S := Copy(S,1,ALength);
1595 if (ByteType(S, Length(S)) = mbLeadByte ) then begin
1596 S := Copy(S, 1, Length(S) - 1);
1606 (*************************************************************************
1609 *************************************************************************)
1610 function TGikoSys.ConvRes(const Body, Bbs, Key,
1611 ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
1615 FIndexFrom : integer;
1622 ZN = '
\82O
\82P
\82Q
\82R
\82S
\82T
\82U
\82V
\82W
\82X
\81|';
1636 procedure Add(IndexFrom, IndexTo: integer; const No: string);
1641 FIndex.FIndexFrom := IndexFrom;
1642 FIndex.FIndexTo := IndexTo;
1646 function ChooseString(const Text, Separator: string; Index: integer): string;
1652 for i := 0 to Index - 1 do begin
1653 if (AnsiPos(Separator, S) = 0) then S := ''
1654 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
1656 p := AnsiPos(Separator, S);
1657 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
1666 List:= TList.Create;
1672 b := ByteType(s, i);
1674 mbSingleByte : begin
1675 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1676 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1684 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1685 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
1691 if (not sw) and (Copy(s,i,4) = GT) then begin
1692 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1700 if ((not sw) and (Copy(s,i,1) = ',')) or
1701 ((not sw) and (Copy(s,i,1) = '=')) then begin
1702 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
1703 ((Chk) and (oc = '')) or
1704 ((not Chk) and (al)) then
1714 if (AnsiPos(sx, SN) > 0) then begin
1717 if (No <> '') and (No <> '-') then begin
1730 if Copy(s,i,1) = '<' then oc := '';
1731 oc := oc + Copy(s,i,1);
1737 if (not sw) and (Copy(s,i,4) = '
\81\84\81\84') then begin
1743 if (not sw) and (Copy(s,i,2) = '
\81\84') then begin
1751 if (AnsiPos(sx, ZN) > 0) then begin
1752 No := No + ZenToHan(sx);
1754 if (No <> '') and (No <> '-') and (No <> '
\81|') then begin
1769 if (i > Length(Body)) then begin
1771 if (No <> '') then Add(sp, i, No);
1776 for i := List.Count - 1 downto 0 do begin
1777 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
1778 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
1779 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
1781 st := PIndex(List[i]).FNo;
1782 et := PIndex(List[i]).FNo;
1784 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
1785 Format('<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">',
1786 [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
1787 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
1788 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
1789 Dispose(PIndex(List[i]));
1795 (*************************************************************************
1796 *
\91S
\8ap
\81¨
\94¼
\8ap
1798 *************************************************************************)
1799 function TGikoSys.ZenToHan(const s: string): string;
1801 Chr: array [0..255] of char;
1803 Windows.LCMapString(
1804 GetUserDefaultLCID(),
1806 LCMAP_HALFWIDTH or LCMAP_KATAKANA or LCMAP_LOWERCASE,
1815 (*************************************************************************
1816 *
\91S
\8ap
\94¼
\8ap
\82Ð
\82ç
\82ª
\82È
\82©
\82½
\82©
\82È
\82ð
\8bæ
\95Ê
\82µ
\82È
\82¢
\90¦
\82¢Pos
1817 *************************************************************************)
1818 function TGikoSys.VaguePos(const Substr, S: string): Integer;
1820 Result := Pos(ZenToHan(Substr), ZenToHan(S));
1823 function TGikoSys.BoolToInt(b: Boolean): Integer;
1825 Result := IfThen(b, 1, 0);
1828 function TGikoSys.IntToBool(i: Integer): Boolean;
1833 //gzip
\82Å
\88³
\8fk
\82³
\82ê
\82½
\82Ì
\82ð
\96ß
\82·
1834 function TGikoSys.GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
1838 GZipStream: TGzipDecompressStream;
1839 TextStream: TStringStream;
1840 buf: array[0..BUF_SIZE - 1] of Byte;
1846 TextStream := TStringStream.Create('');
1848 //
\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¢)
1849 // if LowerCase(Trim(ContentEncoding)) = 'gzip' then begin
1850 if AnsiPos('gzip', LowerCase(Trim(ContentEncoding))) > 0 then begin
1851 ResStream.Position := 0;
1852 GZipStream := TGzipDecompressStream.Create(TextStream);
1855 FillChar(buf, BUF_SIZE, 0);
1856 cnt := ResStream.Read(buf, BUF_SIZE);
1858 GZipStream.Write(buf, BUF_SIZE);
1864 ResStream.Position := 0;
1866 FillChar(buf, BUF_SIZE, 0);
1867 cnt := ResStream.Read(buf, BUF_SIZE);
1869 TextStream.Write(buf, BUF_SIZE);
1873 //NULL
\95¶
\8e\9a\82ð"*"
\82É
\82·
\82é
1874 s := TextStream.DataString;
1876 while (i > 0) and (s[i] = #0) do
1881 while i <> 0 do begin
1891 procedure TGikoSys.LoadKeySetting(ActionList: TActionList);
1893 STD_SEC = 'KeySetting';
1899 SecList: TStringList;
1900 Component: TComponent;
1902 if not FileExists(GetConfigDir + KEY_SETTING_FILE_NAME) then
1904 SecList := TStringList.Create;
1905 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
1907 ini.ReadSection(STD_SEC, SecList);
1908 for i := 0 to SecList.Count - 1 do begin
1909 ActionName := SecList[i];
1910 ActionKey := ini.ReadInteger(STD_SEC, ActionName, -1);
1911 if ActionKey <> -1 then begin
1912 Component := ActionList.Owner.FindComponent(ActionName);
1913 if TObject(Component) is TAction then begin
1914 TAction(Component).ShortCut := ActionKey;
1924 procedure TGikoSys.SaveKeySetting(ActionList: TActionList);
1926 STD_SEC = 'KeySetting';
1931 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
1933 for i := 0 to ActionList.ActionCount - 1 do begin
1934 if ActionList.Actions[i].Tag = -1 then
1936 ini.WriteInteger(STD_SEC, ActionList.Actions[i].Name, TAction(ActionList.Actions[i]).ShortCut);
1945 procedure TGikoSys.CreateProcess(const AppPath: string; const Param: string);
1947 PI: TProcessInformation;
1951 Path := '"' + AppPath + '"';
1953 Path := Path + ' ' + Param;
1955 SI.Cb := SizeOf(Si);
1956 SI.lpReserved := nil;
1957 SI.lpDesktop := nil;
1960 SI.cbReserved2 := 0;
1961 SI.lpReserved2 := nil;
1963 Windows.CreateProcess(nil,
1975 procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
1979 HlinkNavigateString(nil, PWideChar(WideString(URL)));
1980 gbtUserApp, gbtAuto:
1981 if (Setting.URLApp) and (FileExists(Setting.URLAppFile)) then
1982 GikoSys.CreateProcess(Setting.URLAppFile, URL)
1984 HlinkNavigateString(nil, PWideChar(WideString(URL)));
1988 function TGikoSys.HTMLDecode(const AStr: String): String;
1990 Sp, Rp, Cp, Tp: PChar;
1995 SetLength(Result, Length(AStr));
1997 Rp := PChar(Result);
2000 while Sp^ <> #0 do begin
2006 'a': if AnsiStrPos(Sp, 'amp;') = Sp then
2012 'g': if (AnsiStrPos(Sp, 'lt;') = Sp) or (AnsiStrPos(Sp, 'gt;') = Sp) then
2016 while (Sp^ <> ';') and (Sp^ <> #0) do
2023 'q': if AnsiStrPos(Sp, 'quot;') = Sp then
2031 Num := IsNumeric(Copy(Tp, 1, 1));
2032 while (Sp^ <> ';') and (Sp^ <> #0) do begin
2033 if (Num) and (not IsNumeric(Copy(Sp, 1, 1))) then
2037 SetString(S, Tp, Sp - Tp);
2042 //raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2043 //[Cp^ + Sp^, Cp - PChar(AStr)])
2053 // on E:EConvertError do
2054 // raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2055 // [Cp^ + Sp^, Cp - PChar(AStr)])
2057 SetLength(Result, Rp - PChar(Result));
2060 function TGikoSys.GetHRefText(s: string): string;
2070 Index := AnsiPos('href', LowerCase(s));
2073 s := Trim(Copy(s, Index + 4, Length(s)));
2074 s := Trim(Copy(s, 2, Length(s)));
2076 //
\8en
\82ß
\82Ì
\95¶
\8e\9a\82ª'"'
\82È
\82ç
\8eæ
\82è
\8f\9c\82
2077 if Copy(s, 1, 1) = '"' then begin
2078 s := Trim(Copy(s, 2, Length(s)));
2081 Index := AnsiPos('"', s);
2082 if Index <> 0 then begin
2083 //'"'
\82Ü
\82ÅURL
\82Æ
\82·
\82é
2084 s := Copy(s, 1, Index - 1);
2086 //'"'
\82ª
\96³
\82¯
\82ê
\82Î
\83X
\83y
\81[
\83X
\82©">"
\82Ì
\91\81\82¢
\95û
\82Ü
\82Å
\82ðURL
\82Æ
\82·
\82é
2087 Index := AnsiPos(' ', s);
2088 Index2 := AnsiPos('>', s);
2091 if Index > Index2 then
2094 s := Copy(s, 1, Index - 1)
2096 //
\82±
\82ê
\88È
\8fã
\82à
\82¤
\92m
\82ç
\82ñ
\82Ê
2102 //
\83z
\83X
\83g
\96¼
\82ª
\82Q
\82\83\82\88\82©
\82Ç
\82¤
\82©
\83`
\83F
\83b
\83N
\82·
\82é
2103 function TGikoSys.Is2chHost(Host: string): Boolean;
2105 HOST_NAME: array[0..1] of string = ('2ch.net', 'bbspink.com');
2111 OutputDebugString(pchar(HOST_NAME[0]));
2112 for i := 0 to Length(HOST_NAME) - 1 do begin
2113 // Len := Length(HOST_NAME[i]);
2114 if AnsiPos(HOST_NAME[i], Host) = (Length(Host) - Length(HOST_NAME[i]) + 1) then begin
2121 function TGikoSys.Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
2123 READ_PATH: string = '/test/read.cgi/';
2124 OLD_READ_PATH: string = '/test/read.cgi?';
2125 KAKO_PATH: string = '/kako/';
2135 Index := AnsiPos(READ_PATH, path);
2136 if Index <> 0 then begin
2137 s := Copy(path, Length(READ_PATH) + 1, Length(path));
2138 BBSID := GetTokenIndex(s, '/', 0);
2139 BBSKey := GetTokenIndex(s, '/', 1);
2142 Result := (BBSID <> '') or (BBSKey <> '');
2145 Index := AnsiPos(KAKO_PATH, path);
2146 if Index <> 0 then begin
2147 s := Copy(path, 2, Length(path));
2148 BBSID := GetTokenIndex(s, '/', 0);
2149 if (BBSID = 'log') and (GetTokenIndex(s, '/', 2) = 'kako') then
2150 BBSID := GetTokenIndex(s, '/', 1);
2151 BBSKey := ChangeFileExt(Document, '');
2152 Result := (BBSID <> '') or (BBSKey <> '');
2155 Index := AnsiPos('read.cgi?', URL);
2156 if Index <> 0 then begin
2157 SList := TStringList.Create;
2160 // s := HTMLDecode(Document);
2161 ExtractHTTPFields(['?', '&'], [], PChar(URL), SList, False);
2162 BBSID := SList.Values['bbs'];
2163 BBSKey := SList.Values['key'];
2164 Result := (BBSID <> '') or (BBSKey <> '');
2175 function TGikoSys.Parse2chURL2(URL: string): TPathRec;
2187 URL := Trim(LowerCase(URL));
2192 Result.FFirst := False;
2193 Result.FStBegin := False;
2194 Result.FToEnd := False;
2195 Result.FDone := False;
2200 FAWKStr.RegExp := 'http://.+\.(2ch\.net|bbspink\.com)/';
2201 if FAWKStr.Match(FAWKStr.ProcessEscSeq(URL), RStart, RLength) = 0 then
2203 s := Copy(URL, RStart + RLength - 1, Length(URL));
2205 //
\95W
\8f\80\8f\91\8e®
2206 //
\8dÅ
\8cã
\82Íl50, 10, 10-20, 10n, 10-20n, -10, 10-, 10n-
\82È
\82Ç
2207 //http://xxx.2ch.net/test/read.cgi/bbsid/1000000000/
2208 FAWKStr.RegExp := '/test/read.cgi/.+/[0-9]+/.*';
2209 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2210 s := Copy(s, 15, Length(s));
2212 SList := TStringList.Create;
2215 FAWKStr.RegExp := '/';
2216 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2217 Result.FBBS := SList[1];
2218 Result.FKey := SList[2];
2219 if SList.Count >= 3 then
2227 FAWKStr.LineSeparator := mcls_CRLF;
2228 FAWKStr.RegExp := '-';
2229 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) = 0 then begin
2230 Result.FFirst := True;
2232 FAWKStr.RegExp := 'l[0-9]+';
2233 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2234 Result.FFirst := True;
2236 for i := 0 to SList.Count - 1 do begin
2237 if Trim(SList[i]) = '' then begin
2239 Result.FStBegin := True;
2240 if i = (SList.Count - 1) then
2241 Result.FToEnd := True;
2242 end else if IsNumeric(SList[i]) then begin
2243 wkInt := StrToInt(SList[i]);
2244 wkMax := Max(wkMax, wkInt);
2248 wkMin := Min(wkMin, wkInt);
2249 end else if Trim(SList[i]) = 'n' then begin
2250 Result.FFirst := True;
2252 FAWKStr.RegExp := '^n[0-9]+$|^[0-9]+n$';
2253 if FAWKStr.Match(FAWKStr.ProcessEscSeq(SList[i]), RStart, RLength) > 0 then begin
2254 if Copy(SList[i], 1, 1) = 'n' then
2255 wkInt := StrToInt(Copy(SList[i], 2, Length(SList[i])))
2257 wkInt := StrToInt(Copy(SList[i], 1, Length(SList[i]) - 1));
2258 Result.FFirst := True;
2259 wkMax := Max(wkMax, wkInt);
2263 wkMin := Min(wkMin, wkInt);
2267 if Result.FStBegin and (not Result.FToEnd) then
2269 else if (not Result.FStBegin) and Result.FToEnd then
2271 else if (not Result.FStBegin) and (not Result.FToEnd) then begin
2272 Result.FSt := wkMin;
2273 Result.FTo := wkMax;
2275 //Result.FSt := wkMin;
2276 //Result.FTo := wkMax;
2282 Result.FDone := True;
2286 //
\90Vkako
\8f\91\8e®
2287 //http://server.2ch.net/ITA_NAME/kako/1000/10000/1000000000.html
2288 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+/[0-9]+\.html';
2289 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2290 SList := TStringList.Create;
2293 FAWKStr.RegExp := '/';
2294 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2295 Result.FBBS := SList[1];
2296 Result.FKey := ChangeFileExt(SList[5], '');
2297 Result.FFirst := True;
2303 Result.FDone := True;
2307 //
\8b\8ckako
\8f\91\8e®
2308 //http://server.2ch.net/ITA_NAME/kako/999/999999999.html
2309 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+\.html';
2310 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2311 SList := TStringList.Create;
2314 FAWKStr.RegExp := '/';
2315 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 5 then begin
2316 Result.FBBS := SList[1];
2317 Result.FKey := ChangeFileExt(SList[4], '');
2318 Result.FFirst := True;
2324 Result.FDone := True;
2328 //log
\8by
\82Ñlog2
\8f\91\8e®
2329 //http://server.2ch.net/log/ITA_NAME/kako/999/999999999.html
2330 //http://server.2ch.net/log2/ITA_NAME/kako/999/999999999.html
2331 FAWKStr.RegExp := '/log2?/.+/kako/[0-9]+/[0-9]+\.html';
2332 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2333 SList := TStringList.Create;
2336 FAWKStr.RegExp := '/';
2337 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2338 Result.FBBS := SList[2];
2339 Result.FKey := ChangeFileExt(SList[5], '');
2340 Result.FFirst := True;
2346 Result.FDone := True;
2351 //
\8b\8cURL
\8f\91\8e®
2352 //http://server.2ch.net/test/read.cgi?bbs=ITA_NAME&key=1000000000&st=1&to=5&nofirst=true
2353 FAWKStr.RegExp := '/test/read\.cgi\?';
2354 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2355 s := Copy(s, 16, Length(s));
2356 SList := TStringList.Create;
2359 FAWKStr.RegExp := '&';
2360 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2361 Result.FFirst := True;
2362 for i := 0 to SList.Count - 1 do begin
2363 if Pos('bbs=', SList[i]) = 1 then begin
2364 Result.FBBS := Copy(SList[i], 5, Length(SList[i]));
2365 end else if Pos('key=', SList[i]) = 1 then begin
2366 Result.FKey := Copy(SList[i], 5, Length(SList[i]));
2367 end else if Pos('st=', SList[i]) = 1 then begin
2368 wk := Copy(SList[i], 4, Length(SList[i]));
2369 if IsNumeric(wk) then
2370 Result.FSt := StrToInt(wk)
2371 else if wk = '' then
2372 Result.FStBegin := True;
2373 end else if Pos('to=', SList[i]) = 1 then begin
2374 wk := Copy(SList[i], 4, Length(SList[i]));
2375 if IsNumeric(wk) then
2376 Result.FTo := StrToInt(wk)
2377 else if wk = '' then
2378 Result.FToEnd := True;
2379 end else if Pos('nofirst=', SList[i]) = 1 then begin
2380 Result.FFirst := False;
2389 if (Result.FBBS <> '') and (Result.FKey <> '') then begin
2390 Result.FDone := True;
2396 procedure TGikoSys.ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
2406 URI := TIdURI.Create(URL);
2408 Protocol := URI.Protocol;
2411 Document := URI.Document;
2413 Bookmark := URI.Bookmark;
2419 function TGikoSys.GetVersionBuild: Integer;
2421 FixedFileInfo: PVSFixedFileInfo;
2422 VersionHandle, VersionSize: DWORD;
2423 pVersionInfo: Pointer;
2428 AppFile := Application.ExeName;
2429 VersionSize := GetFileVersionInfoSize(pChar(AppFile), VersionHandle);
2430 if VersionSize = 0 then
2432 GetMem(pVersionInfo, VersionSize);
2434 if GetFileVersionInfo(PChar(AppFile),VersionHandle,VersionSize, pVersionInfo) then
2435 if VerQueryValue(pVersionInfo, '\', Pointer(FixedFileInfo), ItemLen) then
2436 Result := LOWORD(FixedFileInfo^.dwFileVersionLS);
2438 FreeMem(pVersionInfo, VersionSize);
2443 GikoSys := TGikoSys.Create;
2446 if GikoSys <> nil then begin