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_NEWRES_FILE_NAME = 'NewRes.html';
209 SKIN_RES_FILE_NAME = 'Res.html';
210 FOLDER_INDEX_VERSION = '1.01';
211 USER_AGENT = 'Monazilla';
212 APP_NAME = 'gikoNavi';
213 DEFAULT_NGWORD_FILE_NAME : String = 'NGword.txt';
214 NGWORDs_DIR_NAME : String = 'NGwords';
216 (*************************************************************************
217 *GikoSys
\83R
\83\93\83X
\83g
\83\89\83N
\83^
218 *************************************************************************)
219 constructor TGikoSys.Create;
221 FSetting := TSetting.Create;
222 FDolib := TDolib.Create;
223 FAWKStr := TAWKStr.Create(nil);
224 if DirectoryExists(GetConfigDir) = false then begin
225 CreateDir(GetConfigDir);
227 FAbon := TAbon.Create;
228 FAbon.Setroot(GetConfigDir+NGWORDs_DIR_NAME);
229 //FAbon.SetNGwordpath(DEFAULT_NGWORD_FILE_NAME);
231 FSelectResFilter := TAbon.Create;
232 //
\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
233 FSelectResFilter.AbonString := '';
236 (*************************************************************************
237 *GikoSys
\83f
\83X
\83g
\83\89\83N
\83^
238 *************************************************************************)
239 destructor TGikoSys.Destroy;
242 FileList: TStringList;
244 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
252 //
\83e
\83\93\83|
\83\89\83\8aHTML
\82ð
\8dí
\8f\9c
253 FileList := TStringList.Create;
255 GetFileList(GetTempFolder, '*.html', FileList, False, True);
256 for i := 0 to FileList.Count - 1 do begin
257 DeleteFile(FileList[i]);
265 (*************************************************************************
266 *
\95¶
\8e\9a\97ñ
\90\94\8e\9a\83`
\83F
\83b
\83N
267 *************************************************************************)
269 function TGikoSys.IsNumeric(s: string): boolean;
279 (*************************************************************************
280 *
\95¶
\8e\9a\97ñ
\95\82\93®
\8f¬
\90\94\93_
\90\94\8e\9a\83`
\83F
\83b
\83N
281 *************************************************************************)
282 function TGikoSys.IsFloat(s: string): boolean;
286 Result := TextToFloat(PChar(s), v, fvExtended);
289 (*************************************************************************
290 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
291 *************************************************************************)
292 function TGikoSys.GetBoardFileName: string;
294 Result := GetAppDir + CONFIG_DIR_NAME + '\' + BOARD_FILE_NAME;
297 (*************************************************************************
298 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
299 *************************************************************************)
300 function TGikoSys.GetCustomBoardFileName: string;
302 Result := GetAppDir + CONFIG_DIR_NAME + '\' + CUSTOMBOARD_FILE_NAME;
305 (*************************************************************************
306 *
\83e
\83\93\83|
\83\89\83\8a\83t
\83H
\83\8b\83_
\81[
\96¼
\8eæ
\93¾
307 *************************************************************************)
308 function TGikoSys.GetHtmlTempFileName: string;
310 Result := TEMP_FOLDER;
314 (*************************************************************************
315 *
\8eÀ
\8ds
\83t
\83@
\83C
\83\8b\83t
\83H
\83\8b\83_
\8eæ
\93¾
316 *************************************************************************)
317 function TGikoSys.GetAppDir: string;
319 Result := ExtractFilePath(Application.ExeName);
322 (*************************************************************************
323 *TempHtml
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
324 *************************************************************************)
325 function TGikoSys.GetTempFolder: string;
327 Result := GetAppDir + TEMP_FOLDER;
330 (*************************************************************************
331 *sent.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
332 *************************************************************************)
333 function TGikoSys.GetSentFileName: string;
335 Result := GetAppDir + SENT_FILE_NAME;
338 (*************************************************************************
339 *outbox.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
340 *************************************************************************)
341 function TGikoSys.GetOutBoxFileName: string;
343 Result := GetAppDir + OUTBOX_FILE_NAME;
346 (*************************************************************************
347 *Config
\83t
\83H
\83\8b\83_
\8eæ
\93¾
348 *************************************************************************)
349 function TGikoSys.GetConfigDir: string;
351 Result := IncludeTrailingPathDelimiter(GetAppDir + CONFIG_DIR_NAME);
354 function TGikoSys.GetStyleSheetDir: string;
356 Result := IncludeTrailingPathDelimiter(GetConfigDir + CSS_DIR_NAME);
359 function TGikoSys.GetSkinDir: string;
361 Result := IncludeTrailingPathDelimiter(GetConfigDir + SKIN_DIR_NAME);
364 (*************************************************************************
365 *URL
\82ð
\8dì
\90¬(
\83R
\83s
\83y
\97p)
366 *************************************************************************)
367 function TGikoSys.GetURL(BBSID: string; FileName: string): string;
371 Board := BoardGroup.BBS2ch.GetBoardFromBBSID(BBSID);
372 Result := UrlToServer(Board.URL) + 'test/read.cgi/' + UrlToID(Board.URL) + '/' + ChangeFileExt(FileName, '') + '/l50';
373 //http://teri.2ch.net/test/read.cgi?bbs=accuse&key=974619522&ls=50
374 //http://pc.2ch.net/test/read.cgi/tech/1003664165/l50
378 function TGikoSys.GetUserAgent: string;
380 if Dolib.Connected then begin
381 Result := Format('%s %s/%s%d%s', [
388 BETA_VERSION_BUILD]);
390 Result := Format('%s/%s %s/%s%d%s', [
398 BETA_VERSION_BUILD]);
402 (*************************************************************************
403 *
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é
\95û
\8e®
\8e\9e\8d\8f\8eæ
\93¾
404 *************************************************************************)
405 function TGikoSys.Get2chDate(aDate: TDateTime): string;
410 d1 := EncodeDate(1970, 1, 1);
411 d2 := aDate - EncodeTime(9, 0, 0, 0);
412 Result := FloatToStr(Trunc((d2 - d1) * 24 * 60 * 60));
416 function TGikoSys.IntToDateTime(val: Int64): TDateTime;
421 d1 := EncodeDate(1970, 1, 1);
422 d2 := (val * 1000) / (24 * 60 * 60 * 1000);
426 function TGikoSys.DateTimeToInt(ADate: TDateTime): Integer;
431 d := EncodeDate(1970, 1, 1);
432 c := (ADate - d) * 24 * 60 * 60;
437 (*************************************************************************
438 *Subject
\83t
\83@
\83C
\83\8bRead
439 *************************************************************************)
440 procedure TGikoSys.ReadSubjectFile(Board: TBoard);
442 ThreadItem: TThreadItem;
444 FileList: TStringList;
445 TmpFileList: TStringList;
446 // SrchRec: TSearchRec;
453 // TmpUpdate: Boolean;
456 RoundItem: TRoundItem;
461 // TmpUpdate := False;
463 FileName := Board.GetFolderIndexFileName;
464 if not FileExists(FileName) then CreateThreadDat(Board);
465 // if not FileExists(FileName) then Exit;
467 //IsLogFile
\97pDAT
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
468 FileList := TStringList.Create;
469 FileList.Sorted := True;
470 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False, False);
472 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\97pTmp
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
473 TmpFileList := TStringList.Create;
474 TmpFileList.Sorted := True;
475 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, False, False);
477 { R := FindFirst(ExtractFileDir(Board.GetFolderIndexFileName) + '\*.dat', 0, SrchRec);
479 FileList.Add(SrchRec.Name);
480 R := FindNext(SrchRec);
484 sl := TStringList.Create;
486 if FileExists(FileName) then
487 sl.LoadFromFile(FileName);
489 //
\82Q
\8ds
\96Ú
\82©
\82ç
\81i
\82P
\8ds
\96Ú
\82Í
\83o
\81[
\83W
\83\87\83\93\81j
490 for i := 1 to sl.Count - 1 do begin
491 Rec := ParseIndexLine(sl[i]);
493 ThreadItem := TThreadItem.Create;
494 ThreadItem.BeginUpdate;
495 ThreadItem.No := Rec.FNo;
496 ThreadItem.FileName := Rec.FFileName;
497 ThreadItem.Title := Rec.FTitle;
498 ThreadItem.Count := Rec.FCount;
499 ThreadItem.Size := Rec.FSize;
500 // ThreadItem.RoundNo := Rec.FRoundNo;
501 ThreadItem.RoundDate := Rec.FRoundDate;
502 ThreadItem.LastModified := Rec.FLastModified;
503 ThreadItem.Kokomade := Rec.FKokomade;
504 ThreadItem.NewReceive := Rec.FNewReceive;
505 // ThreadItem.Round := Rec.FRound;
506 ThreadItem.UnRead := Rec.FUnRead;
507 ThreadItem.ScrollTop := Rec.FScrollTop;
508 ThreadItem.AllResCount := Rec.FAllResCount;
509 ThreadItem.NewResCount := Rec.FNewResCount;
510 ThreadItem.AgeSage := Rec.FAgeSage;
511 ThreadItem.ParentBoard := Board;
513 //IsLogFile
\83`
\83F
\83b
\83N
514 ThreadItem.IsLogFile := False;
515 if FileList.Count <> 0 then begin
516 if FileList.Find(ThreadItem.FileName, Index) then begin
517 ThreadItem.IsLogFile := True;
518 FileList.Delete(Index);
522 //
\8f\84\89ñ
\83\8a\83X
\83g
\82É
\91¶
\8dÝ
\82µ
\82½
\82ç
\8f\84\89ñ
\83t
\83\89\83O
\83Z
\83b
\83g
523 if ThreadItem.IsLogFile then begin
524 idx := RoundList.Find(ThreadItem);
525 if idx <> -1 then begin
526 RoundItem := RoundList.Items[idx, grtItem];
527 ThreadItem.RoundName := RoundItem.RoundName;
528 ThreadItem.Round := True;
532 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\83`
\83F
\83b
\83N
533 if TmpFileList.Count <> 0 then begin
534 if TmpFileList.Find(ChangeFileExt(ThreadItem.FileName, '.tmp'), Index) then begin
535 ini := TMemIniFile.Create(ChangeFileExt(ThreadItem.GetThreadFileName, '.tmp'));
537 ThreadItem.RoundDate := ini.ReadDateTime('Setting', 'RoundDate', ZERO_DATE);
538 ThreadItem.LastModified := ini.ReadDateTime('Setting', 'LastModified', ZERO_DATE);
539 ThreadItem.Size := ini.ReadInteger('Setting', 'Size', 0);
540 ThreadItem.Count := ini.ReadInteger('Setting', 'Count', 0);
541 ThreadItem.NewReceive := ini.ReadInteger('Setting', 'NewReceive', 0);
542 ThreadItem.Round := ini.ReadBool('Setting', 'Round', False);
543 ThreadItem.UnRead := False;//ini.ReadBool('Setting', 'UnRead', False);
544 ThreadItem.ScrollTop := ini.ReadInteger('Setting', 'ScrollTop', 0);
545 ThreadItem.AllResCount := ini.ReadInteger('Setting', 'AllResCount', 0);
546 ThreadItem.NewResCount := ini.ReadInteger('Setting', 'NewResCount', 0);
547 ThreadItem.AgeSage := TGikoAgeSage(ini.ReadInteger('Setting', 'AgeSage', Ord(gasNone)));
551 TmpFileList.Delete(Index);
555 ThreadItem.EndUpdate;
556 Board.Add(ThreadItem);
558 // if (ThreadItem.IsLogFile) and (ThreadItem.Count > ThreadItem.Kokomade) then
559 if (ThreadItem.IsLogFile) and (ThreadItem.UnRead) then
562 if UnRead <> Board.UnRead then
563 Board.UnRead := UnRead;
565 //
\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
566 for i := 0 to FileList.Count - 1 do begin
567 FileName := ExtractFileDir(Board.GetFolderIndexFileName) + '\' + FileList[i];
569 ResRec := DivideStrLine(ReadThreadFile(FileName, 1));
570 ThreadItem := TThreadItem.Create;
571 ThreadItem.No := Board.Count + 1;
572 ThreadItem.FileName := FileList[i];
573 ThreadItem.Title := ResRec.FTitle;
574 ThreadItem.Count := GetFileLineCount(FileName);
575 ThreadItem.AllResCount := ThreadItem.Count;
576 ThreadItem.NewResCount := 0;
577 ThreadItem.Size := 0;
578 ThreadItem.RoundDate := ZERO_DATE;
579 ThreadItem.LastModified := ZERO_DATE;
580 ThreadItem.Kokomade := -1;
581 ThreadItem.NewReceive := 0;
582 ThreadItem.ParentBoard := Board;
583 ThreadItem.IsLogFile := True;
584 ThreadItem.Round := False;
585 ThreadItem.UnRead := False;
586 ThreadItem.ScrollTop := 0;
587 ThreadItem.AgeSage := gasNone;
588 Board.Add(ThreadItem);
595 Board.IsThreadDatRead := True;
598 (*************************************************************************
599 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X
\83t
\83@
\83C
\83\8b(Folder.idx)
\8dì
\90¬
600 *************************************************************************)
601 procedure TGikoSys.CreateThreadDat(Board: TBoard);
605 SubjectList: TStringList;
611 if not FileExists(Board.GetSubjectFileName) then Exit;
612 FileName := Board.GetFolderIndexFileName;
614 SubjectList := TStringList.Create;
616 SubjectList.LoadFromFile(Board.GetSubjectFileName);
617 sl := TStringList.Create;
620 sl.Add(FOLDER_INDEX_VERSION);
621 for i := 0 to SubjectList.Count - 1 do begin
622 Rec := DivideSubject(SubjectList[i]);
624 if (Trim(Rec.FFileName) = '') or (Trim(Rec.FTitle) = '') then
627 s := Format('%x', [cnt]) + #1 //
\94Ô
\8d\86
628 + Rec.FFileName + #1 //
\83t
\83@
\83C
\83\8b\96¼
629 + Rec.FTitle + #1 //
\83^
\83C
\83g
\83\8b
630 + Format('%x', [Rec.FCount]) + #1 //
\83J
\83E
\83\93\83g
631 + Format('%x', [0]) + #1 //size
632 + Format('%x', [0]) + #1 //RoundDate
633 + Format('%x', [0]) + #1 //LastModified
634 + Format('%x', [0]) + #1 //Kokomade
635 + Format('%x', [0]) + #1 //NewReceive
636 + '0' + #1 //
\96¢
\8eg
\97p
637 + Format('%x', [0]) + #1 //UnRead
638 + Format('%x', [0]) + #1 //ScrollTop
639 + Format('%x', [Rec.FCount]) + #1 //AllResCount
640 + Format('%x', [0]) + #1 //NewResCount
641 + Format('%x', [0]); //AgeSage
646 sl.SaveToFile(FileName);
655 (*************************************************************************
656 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X(Thread.dat)
\8f\91\82«
\8d\9e\82Ý
658 *************************************************************************)
659 procedure TGikoSys.WriteThreadDat(Board: TBoard);
661 // Values: array[Boolean] of string = ('0', '1');
667 FileList: TStringList;
669 if not Board.IsThreadDatRead then
671 FileName := Board.GetFolderIndexFileName;
672 ForceDirectoriesEx(Board.ParentCategory.ParentBBS2ch.GetLogFolder + Board.BBSID);
674 sl := TStringList.Create;
676 sl.Add(FOLDER_INDEX_VERSION);
677 for i := 0 to Board.Count - 1 do begin
678 if Board.Items[i].No = 0 then
679 Board.Items[i].No := i + 1;
681 s := Format('%x', [Board.Items[i].No]) + #1
682 + Board.Items[i].FileName + #1
683 + Board.Items[i].Title + #1
684 + Format('%x', [Board.Items[i].Count]) + #1
685 + Format('%x', [Board.Items[i].Size]) + #1
686 + Format('%x', [DateTimeToInt(Board.Items[i].RoundDate)]) + #1
687 + Format('%x', [DateTimeToInt(Board.Items[i].LastModified)]) + #1
688 + Format('%x', [Board.Items[i].Kokomade]) + #1
689 + Format('%x', [Board.Items[i].NewReceive]) + #1
690 + '0' + #1 //
\96¢
\8eg
\97p
691 + Format('%x', [BoolToInt(Board.Items[i].UnRead)]) + #1
692 + Format('%x', [Board.Items[i].ScrollTop]) + #1
693 + Format('%x', [Board.Items[i].AllResCount]) + #1
694 + Format('%x', [Board.Items[i].NewResCount]) + #1
695 + Format('%x', [Ord(Board.Items[i].AgeSage)]);
700 sl.SaveToFile(FileName);
702 FileList := TStringList.Create;
704 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', FileList, False, True);
705 for i := 0 to FileList.Count - 1 do begin
706 DeleteFile(FileList[i]);
716 function TGikoSys.ParseIndexLine(Line: string): TIndexRec;
721 for i := 0 to 14 do begin
722 s := GetTokenIndex(Line, #1, i);
724 0: Result.FNo := StrToIntDef('$' + s, 0);
725 1: Result.FFileName := s;
726 2: Result.FTitle := s;
727 3: Result.FCount := StrToIntDef('$' + s, 0);
728 4: Result.FSize := StrToIntDef('$' + s, 0);
729 5: Result.FRoundDate := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
730 6: Result.FLastModified := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
731 7: Result.FKokomade := StrToIntDef('$' + s, -1);
732 8: Result.FNewReceive := StrToIntDef('$' + s, 0);
734 10: Result.FUnRead := IntToBool(StrToIntDef('$' + s, 0));
735 11: Result.FScrollTop := StrToIntDef('$' + s, 0);
736 12: Result.FAllResCount := StrToIntDef('$' + s, 0);
737 13: Result.FNewResCount := StrToIntDef('$' + s, 0);
738 14: Result.FAgeSage := TGikoAgeSage(StrToIntDef('$' + s, 0));
743 //
\8ew
\92è
\83t
\83H
\83\8b\83_
\93à
\82Ì
\8ew
\92è
\83t
\83@
\83C
\83\8b\88ê
\97\97\82ð
\8eæ
\93¾
\82·
\82é
744 // ListFiles('c:\', '*.txt', list, True);
745 procedure TGikoSys.GetFileList(Path: string; Mask: string; List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
748 SearchRec : TSearchRec;
751 Path := IncludeTrailingPathDelimiter(Path);
752 rc := FindFirst(Path + '*.*', faAnyfile, SearchRec);
754 while rc = 0 do begin
755 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
756 s := Path + SearchRec.Name;
757 //if (SearchRec.Attr and faDirectory > 0) then
758 // s := IncludeTrailingPathDelimiter(s)
760 if (SearchRec.Attr and faDirectory = 0) and (MatchesMask(s, Mask)) then
764 List.Add(SearchRec.Name);
765 if SubDir and (SearchRec.Attr and faDirectory > 0) then
766 GetFileList(s, Mask, List, True, IsPathAdd);
768 rc := FindNext(SearchRec);
771 SysUtils.FindClose(SearchRec);
775 //
\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é
776 procedure TGikoSys.GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
779 SearchRec : TSearchRec;
782 Path := IncludeTrailingPathDelimiter(Path);
783 rc := FindFirst(Path + '*.*', faDirectory, SearchRec);
785 while rc = 0 do begin
786 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
787 s := Path + SearchRec.Name;
788 //if (SearchRec.Attr and faDirectory > 0) then
789 // s := IncludeTrailingPathDelimiter(s)
791 if (SearchRec.Attr and faDirectory > 0) and (MatchesMask(s, Mask)) then
792 List.Add( IncludeTrailingPathDelimiter( s ) );
793 if SubDir and (SearchRec.Attr and faDirectory > 0) then
794 GetDirectoryList(s, Mask, List, True);
796 rc := FindNext(SearchRec);
799 SysUtils.FindClose(SearchRec);
803 procedure TGikoSys.CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
807 //bufList : TStringList;
808 ReadList: TStringList;
809 SaveList: TStringList;
813 NewReceiveNo: Integer;
816 SkinHeaderFileName: string;
817 SkinNewRes: TStringList;
818 SkinRes: TStringList;
820 ShortDayNames[1] := '
\93ú'; ShortDayNames[2] := '
\8c\8e';
821 ShortDayNames[3] := '
\89Î'; ShortDayNames[4] := '
\90\85';
822 ShortDayNames[5] := '
\96Ø'; ShortDayNames[6] := '
\8bà';
823 ShortDayNames[7] := '
\93y';
824 BBSID := ThreadItem.ParentBoard.BBSID;
825 FileName := ThreadItem.FileName;
826 NewReceiveNo := ThreadItem.NewReceive;
827 FileName := ThreadItem.GetThreadFileName;
828 ReadList := TStringList.Create;
829 FAbon.Deleterlo := FSetting.AbonDeleterlo;
830 FAbon.Replaceul := FSetting.AbonReplaceul;
831 FAbon.AbonPopupRes := FSetting.PopUpAbon;
833 if ThreadItem.IsLogFile then begin
834 ReadList.LoadFromFile(FileName);
835 FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
836 FAbon.Execute(ReadList); //
\82 \82Ú
\81`
\82ñ
\82µ
\82Ä
837 FSelectResFilter.Execute(ReadList); //
\83\8c\83X
\82Ì
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\82·
\82é
838 Res := DivideStrLine(ReadList[0]);
839 Res.FTitle := StringReplace(Res.FTitle, '
\81\97\81M', ',', [rfReplaceAll]);
840 sTitle := Res.FTitle;
843 sTitle := StringReplace(ThreadItem.Title, '
\81\97\81M', ',', [rfReplaceAll]);
845 SaveList := TStringList.Create;
848 doc.charset := 'Shift_JIS';
850 CSSFileName := GetStyleSheetDir + Setting.CSSFileName;
851 SkinHeaderFileName := Setting.CSSFileName + SKIN_HEADER_FILE_NAME;
852 if GikoSys.Setting.UseCSS and
853 (Pos(GetSkinDir, Setting.CSSFileName) > 0) and
854 FileExists( SkinHeaderFileName ) then begin
855 //
\83X
\83L
\83\93\8eg
\97p
857 SaveList.Add('<html><head>');
858 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
859 SaveList.Add('<title>' + sTitle + '</title>');
862 // SaveList.Add('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
864 //
\83X
\83L
\83\93\82Ì
\90Ý
\92è
865 Skin := TStringList.Create;
867 Skin.LoadFromFile( SkinHeaderFileName );
868 Skin.Text := StringReplace( Skin.Text, '$THISSKINPATH', Setting.CSSFileName, [rfReplaceAll] );
869 SaveList.AddStrings( Skin );
873 SkinNewRes := TStringList.Create;
874 SkinRes := TStringList.Create;
876 SkinNewRes.LoadFromFile( Setting.CSSFileName + SKIN_NEWRES_FILE_NAME );
877 SkinRes.LoadFromFile( Setting.CSSFileName + SKIN_RES_FILE_NAME );
881 //SaveList.Add('</head>');
882 //SaveList.Add('<body>');
883 //SaveList.Add('<dl id="dl">');
884 SaveList.Add('<a name="top"></a>');
885 //SaveList.Add('<div class="title">' + sTitle + '</div>');
887 for i := 0 to ReadList.Count - 1 do begin
888 if (Trim(ReadList[i]) <> '') then begin
889 No := IntToStr(i + 1);
890 Skin := TStringList.Create;
891 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then
892 Skin.AddStrings( SkinNewRes )
894 Skin.AddStrings( SkinRes );
896 Res := DivideStrLine(ReadList[i]);
897 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
899 if Res.FType = glt2chOld then begin
900 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
901 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
902 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
905 Res.FBody := AddAnchorTag(Res.FBody);
906 if Res.FName = '' then
907 Res.FName := ' ';
909 Skin.Text := StringReplace( Skin.Text, '&NUMBER', No, [rfReplaceAll] );
910 Skin.Text := StringReplace( Skin.Text, '&NAME', Res.FName, [rfReplaceAll] );
911 Skin.Text := StringReplace( Skin.Text, '&MAIL', Res.FMailTo, [rfReplaceAll] );
912 Skin.Text := StringReplace( Skin.Text, '&DATE', Res.FDateTime, [rfReplaceAll] );
913 Skin.Text := StringReplace( Skin.Text, '&MESSAGE', Res.FBody, [rfReplaceAll] );
914 SaveList.AddStrings( Skin );
918 No := IntToStr(i + 1);
919 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
920 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>');
922 Res := DivideStrLine(ReadList[i]);
923 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
925 if Res.FType = glt2chOld then begin
926 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
927 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
928 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
931 Res.FBody := AddAnchorTag(Res.FBody);
932 if Res.FName = '' then
933 Res.FName := ' ';
934 if Res.FMailTo = '' then
935 SaveList.Add('<a name="' + No + '"></a>'
936 + '<dt><a href="giko://?no=' + No + '" name="Res' + No + '">' + No + '</a>'
937 + '<u><b> ' + Res.FName + '</b></u>'
938 + '<span> ' + Res.FDateTime+ '</span></dt>'
939 + '<dd>' + Res.FBody + '</dd>')
941 if GikoSys.Setting.ShowMail then
942 SaveList.Add('<a name="' + No + '"></a>'
943 + '<dt><a href="giko://?no=' + No + '" name="Res' + No + '">' + No + '</a>'
944 + '<a href="mailto:' + Res.FMailTo + '">'
945 + '<u><b> ' + Res.FName + '</b></u></a> [' + Res.FMailTo + ']'
946 + '<span> ' + Res.FDateTime+ '</span></dt>'
947 + '<dd>' + Res.FBody + '</dd>')
949 SaveList.Add('<a name="' + No + '"></a>'
950 + '<dt><a href="giko://?no=' + No + '" name="Res' + No + '">' + No + '</a>'
951 + '<a href="mailto:' + Res.FMailTo + '">'
952 + '<u><b> ' + Res.FName + '</b></u></a>'
953 + '<spa> ' + Res.FDateTime+ '</span></dt>'
954 + '<dd>' + Res.FBody + '</dd>');
955 if ThreadItem.Kokomade = (i + 1) then begin
956 SaveList.Add('<a name="koko"></a><div class="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</div>');
961 //if SaveList.Count > 50 then begin
964 //Application.ProcessMessages;
966 doc.Write(SaveList.Text);
967 //while GikoForm.Browser.Busy do begin
969 // Application.ProcessMessages;
971 while (GikoForm.Browser.ReadyState <> READYSTATE_COMPLETE) and
972 (GikoForm.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
974 //Application.ProcessMessages;
979 SaveList.Add('<a name="bottom"></a>');
980 SaveList.Add('</dl>');
981 SaveList.Add('<a name="last"></a>');
982 SaveList.Add('</body></html>');
984 doc.Write(SaveList.Text);
988 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
990 //CSSFileName := GetAppDir + CSS_FILE_NAME;
991 // SaveList.Add('<html lang="ja"><head>');
992 SaveList.Add('<html><head>');
993 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
994 SaveList.Add('<title>' + sTitle + '</title>');
995 SaveList.Add('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
996 SaveList.Add('</head>');
997 SaveList.Add('<body>');
998 SaveList.Add('<a name="top"></a>');
999 SaveList.Add('<div class="title">' + sTitle + '</div>');
1000 //doc.Write(SaveList.Text);
1002 //Application.ProcessMessages;
1003 for i := 0 to ReadList.Count - 1 do begin
1004 if (Trim(ReadList[i]) <> '') then begin
1005 No := IntToStr(i + 1);
1006 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1007 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>');
1009 Res := DivideStrLine(ReadList[i]);
1010 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1012 if Res.FType = glt2chOld then begin
1013 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
1014 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
1015 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
1017 //Res.FBody := StringReplace(Res.FBody, '&hearts;', '♥', [rfReplaceAll]);
1018 //Res.FBody := StringReplace(Res.FBody, '&nbsp;', ' ', [rfReplaceAll]);
1019 //Res.FBody := StringReplace(Res.FBody, '&#', '&#', [rfReplaceAll]);
1020 //Res.FBody := StringReplace(Res.FBody, '&', '&', [rfReplaceAll]);
1021 Res.FBody := AddAnchorTag(Res.FBody);
1022 if Res.FName = '' then
1023 Res.FName := ' ';
1024 if Res.FMailTo = '' then
1025 SaveList.Add('<a name="' + No + '"></a>'
1026 + '<div class="header"><span class="no"><a href="giko://?no=' + No + '">' + No + '</a></span> '
1027 + '<span class="name_label">
\96¼
\91O
\81F</span> '
1028 + '<span class="name"><b>' + Res.FName + '</b></span> '
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>')
1033 if GikoSys.Setting.ShowMail then
1034 SaveList.Add('<a name="' + No + '"></a>'
1035 + '<div class="header"><span class="no"><a href="giko://?no=' + No + '">' + No + '</a></span>'
1036 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1037 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1038 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
1039 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1040 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1041 + '<div class="mes">' + Res.FBody + ' </div>')
1043 SaveList.Add('<a name="' + No + '"></a>'
1044 + '<div class="header"><span class="no"><a href="giko://?no=' + No + '">' + No + '</a></span>'
1045 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1046 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1047 + '<b>' + Res.FName + '</b></a>'
1048 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1049 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1050 + '<div class="mes">' + Res.FBody + ' </div>');
1051 if ThreadItem.Kokomade = (i + 1) then begin
1052 SaveList.Add('<a name="koko"></a><div class="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</div>');
1055 //if SaveList.Count > 50 then begin
1056 if i = 20 then begin
1058 //Application.ProcessMessages;
1060 doc.Write(SaveList.Text);
1061 //while GikoForm.Browser.Busy do begin
1063 // Application.ProcessMessages;
1065 while (GikoForm.Browser.ReadyState <> READYSTATE_COMPLETE) and
1066 (GikoForm.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
1068 //Application.ProcessMessages;
1073 SaveList.Add('<a name="bottom"></a>');
1074 SaveList.Add('</body></html>');
1075 SaveList.Add('<a name="last"></a>');
1076 SaveList.Add('</body></html>');
1078 doc.Write(SaveList.Text);
1081 // SaveList.Add('<html lang="ja"><head>');
1082 SaveList.Add('<html><head>');
1083 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1084 SaveList.Add('<title>' + sTitle + '</title></head>');
1085 SaveList.Add('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1086 SaveList.Add('<a name="top"></a>');
1087 SaveList.Add('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1088 SaveList.Add('<dl>');
1089 doc.Write(SaveList.Text);
1091 //Application.ProcessMessages;
1092 for i := 0 to ReadList.Count - 1 do begin
1093 if (Trim(ReadList[i]) <> '') then begin
1094 No := IntToStr(i + 1);
1096 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1097 SaveList.Add('</dl>');
1098 SaveList.Add('<a name="new"></a>');
1099 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>');
1100 SaveList.Add('<dl>');
1102 Res := DivideStrLine(ReadList[i]);
1103 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1104 if Res.FType = glt2chOld then begin
1105 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
1106 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
1107 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
1109 //Res.FBody := StringReplace(Res.FBody, '&hearts;', '♥', [rfReplaceAll]);
1110 //Res.FBody := StringReplace(Res.FBody, '&nbsp;', ' ', [rfReplaceAll]);
1111 //Res.FBody := StringReplace(Res.FBody, '&#', '&#', [rfReplaceAll]);
1112 //Res.FBody := StringReplace(Res.FBody, '&', '&', [rfReplaceAll]);
1113 Res.FBody := AddAnchorTag(Res.FBody);
1114 if Res.FMailTo = '' then
1115 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>')
1117 if GikoSys.Setting.ShowMail then
1118 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>')
1120 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>');
1121 if ThreadItem.Kokomade = (i + 1) then begin
1122 SaveList.Add('</dl>');
1123 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>');
1124 SaveList.Add('<dl>');
1127 if SaveList.Count > 50 then begin
1128 doc.Write(SaveList.Text);
1130 //Application.ProcessMessages;
1133 SaveList.Add('</dl>');
1134 SaveList.Add('<a name="bottom"></a>');
1135 SaveList.Add('</body></html>');
1136 doc.Write(SaveList.Text);
1147 (*************************************************************************
1148 *http://
\82Ì
\95¶
\8e\9a\97ñ
\82ðanchor
\83^
\83O
\95t
\82«
\82É
\82·
\82é
\81B
1149 *************************************************************************)
1150 function TGikoSys.AddAnchorTag(s: string): string;
1152 URL_CHAR: string = '0123456789'
1153 + 'abcdefghijklmnopqrstuvwxyz'
1154 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1155 + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
1157 wkIdx: array[0..9] of Integer;
1166 wkIdx[0] := AnsiPos('http://', s);
1167 wkIdx[1] := AnsiPos('ttp://', s);
1168 wkIdx[2] := AnsiPos('tp://', s);
1169 wkIdx[3] := AnsiPos('ms-help://', s);
1170 wkIdx[4] := AnsiPos('p://', s);
1171 wkIdx[5] := AnsiPos('https://', s);
1172 wkIdx[6] := AnsiPos('www.', s);
1173 wkIdx[7] := AnsiPos('ftp://', s);
1174 wkIdx[8] := AnsiPos('news://', s);
1175 wkIdx[9] := AnsiPos('rtsp://', s);
1179 if wkIdx[i] <> 0 then idx := Min(wkIdx[i], idx);
1181 if idx = MaxInt then begin
1182 //
\83\8a\83\93\83N
\82ª
\96³
\82¢
\82æ
\81B
1183 Result := Result + s;
1187 if (idx > 1) and (Copy(s, idx - 1, 1) = '"') then begin
1188 //
\8aù
\82É
\83\8a\83\93\83N
\83^
\83O
\82ª
\82Â
\82¢
\82Ä
\82¢
\82é
\82Á
\82Û
\82¢
\82Æ
\82«
\82Í
\83\80\83V
1189 Result := Result + Copy(s, 0, idx + Length('http://') - 1);
1190 s := Copy(s, idx + Length('http://'), length(s));
1194 Result := Result + Copy(s, 0, idx - 1);
1196 s := Copy(s, idx, length(s));
1198 for i := 0 to Length(s) do begin
1199 idx := AnsiPos(s[i + 1], URL_CHAR);
1200 if (idx = 0) or (i = (Length(s))) then begin
1201 //URL
\82¶
\82á
\82È
\82¢
\95¶
\8e\9a\94
\8c©
\81I
\82Æ
\82©
\81A
\95¶
\8e\9a\82ª
\82È
\82
\82È
\82Á
\82½
\81B
1202 url := Copy(s, 0, i);
1204 if AnsiPos('ttp://', url) = 1 then
1206 else if AnsiPos('tp://', url) = 1 then
1208 else if AnsiPos('p://', url) = 1 then
1210 else if AnsiPos('www.', url) = 1 then
1211 href := 'http://' + url
1214 Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
1215 s := Copy(s, i + 1, Length(s));
1222 (*************************************************************************
1223 *
\83T
\83u
\83W
\83F
\83N
\83g
\88ê
\8ds
\82ð
\95ª
\8a\84
1224 *************************************************************************)
1225 function TGikoSys.DivideSubject(Line: string): TSubjectRec;
1235 if Pos('<>', Line) = 0 then
1240 Result.FFileName := GetTokenIndex(Line, Delim, 0);
1241 Result.FTitle := GetTokenIndex(Line, Delim, 1);
1243 ws := Trim(Result.FTitle);
1245 if Copy(ws, Length(ws), 1) = ')' then begin
1248 end else if Copy(ws, Length(ws), 1) = '
\81j' then begin
1251 end else if Copy(ws, Length(ws), 1) = '<' then begin
1256 for i := Length(ws) - 1 downto 1 do begin
1257 if ws[i] = LeftK then begin
1258 ws := Copy(ws, i + 1, Length(ws) - i - 1);
1259 if IsNumeric(ws) then
1260 Result.FCount := StrToInt(ws);
1261 Result.FTitle := Trim(StringReplace(Result.FTitle, LeftK + ws + RightK, '', [rfReplaceAll]));
1267 (*************************************************************************
1268 * dat
\83t
\83@
\83C
\83\8b\82Ì
\88ê
\83\89\83C
\83\93\82ð
\95ª
\89ð
1269 *************************************************************************)
1270 function TGikoSys.DivideStrLine(Line: string): TResRec;
1275 if Pos('<>', Line) = 0 then begin
1277 Result.FType := glt2chOld;
1280 Result.FType := glt2chNew;
1282 Result.FName := Trim(GetTokenIndex(Line, Delim, 0));
1283 Result.FMailTo := Trim(GetTokenIndex(Line, Delim, 1));
1284 Result.FDateTime := Trim(GetTokenIndex(Line, Delim, 2));
1285 bufBody := Trim(GetTokenIndex(Line, Delim, 3));
1286 if bufbody = '' then begin
1287 Insert(' ',bufbody, 1);
1289 Result.FBody := bufBody;
1290 Result.FTitle := Trim(GetTokenIndex(Line, Delim, 4));
1294 (*************************************************************************
1295 * URL
\82©
\82çBBSID
\82ð
\8eæ
\93¾
1296 *************************************************************************)
1297 function TGikoSys.UrlToID(url: string): string;
1304 if url = '' then Exit;
1306 url := Copy(url, 0, Length(url) - 1);
1307 for i := Length(url) downto 0 do begin
1308 if url[i] = '/' then begin
1309 Result := Copy(url, i + 1, Length(url));
1315 (*************************************************************************
1316 *URL
\82©
\82çBBSID
\88È
\8aO
\82Ì
\95\94\95ª(http://teri.2ch.net/)
\82ð
\8eæ
\93¾
1317 *************************************************************************)
1318 function TGikoSys.UrlToServer(url: string): string;
1325 wsURL := Trim(wsURL);
1327 if wsURL = '' then exit;
1329 if Copy(wsURL, Length(wsURL), 1) = '/' then
1330 wsURL := Copy(wsURL, 0, Length(wsURL) - 1);
1332 for i := Length(wsURL) downto 0 do begin
1333 if wsURL[i] = '/' then begin
1334 Result := Copy(wsURL, 0, i);
1340 (*************************************************************************
1341 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ª
\91¶
\8dÝ
\82·
\82é
\82©
\83`
\83F
\83b
\83N
1342 *************************************************************************)
1343 function TGikoSys.DirectoryExistsEx(const Name: string): Boolean;
1347 Code := GetFileAttributes(PChar(Name));
1348 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
1351 (*************************************************************************
1352 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\8dì
\90¬
\81i
\95¡
\90\94\8aK
\91w
\91Î
\89\9e\81j
1353 *************************************************************************)
1354 function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean;
1357 if Length(Dir) = 0 then
1358 raise Exception.Create('
\83t
\83H
\83\8b\83_
\82ª
\8dì
\90¬
\8fo
\97\88\82Ü
\82¹
\82ñ');
1359 Dir := ExcludeTrailingPathDelimiter(Dir);
1360 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
1361 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
1362 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
1365 (*************************************************************************
1366 *
\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
1367 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1368 *************************************************************************)
1369 function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1373 Result := StrTokNext(sep, Rec);
1376 (*************************************************************************
1377 *
\95¶
\8e\9a\97ñ
\82©
\82ç
\83g
\81[
\83N
\83\93\82Ì
\90Ø
\82è
\8fo
\82µ
1378 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1379 *************************************************************************)
1380 function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1387 if Len >= Pos then begin
1388 while (Pos <= Len) and (Str[Pos] in sep) do begin
1392 while (Pos<= Len) and not (Str[Pos] in sep) do begin
1393 if IsDBCSLeadByte(Byte(Str[Pos])) then begin
1398 Result := Copy(Str, I, Pos - I);
1399 while (Pos <= Len) and (Str[Pos] in sep) do begin//
\82±
\82ê
\82Í
\82¨
\8dD
\82Ý
1406 (*************************************************************************
1407 *
\83t
\83@
\83C
\83\8b\83T
\83C
\83Y
\8eæ
\93¾
1408 *************************************************************************)
1409 function TGikoSys.GetFileSize(FileName : string): longint;
1414 if not FileExists(FileName) then begin
1418 Assign(F, FileName);
1420 Result := FileSize(F);
1427 (*************************************************************************
1428 *
\83t
\83@
\83C
\83\8b\8ds
\90\94\8eæ
\93¾
1429 *************************************************************************)
1430 function TGikoSys.GetFileLineCount(FileName : string): longint;
1434 sl := TStringList.Create;
1437 sl.LoadFromFile(FileName);
1448 (*************************************************************************
1449 *
\83X
\83\8c\83b
\83h
\83t
\83@
\83C
\83\8b\82©
\82ç
\8ew
\92è
\8ds
\82ð
\8eæ
\93¾
1450 *************************************************************************)
1451 function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string;
1458 ArrBuff: array [1..BUFFER_SIZE] of Char;
1461 if FileExists(FileName) then begin
1462 AssignFile(f, FileName);
1463 System.SetTextBuf(f, ArrBuff);
1467 while not Eof(f) do begin
1469 if Line = num then begin
1482 (*************************************************************************
1483 *
\83V
\83X
\83e
\83\80\83\81\83j
\83\85\81[
\83t
\83H
\83\93\83g
\82Ì
\91®
\90«
\82ð
\8eæ
\93¾
1484 *************************************************************************)
1485 procedure TGikoSys.MenuFont(Font: TFont);
1488 nm: NONCLIENTMETRICS;
1490 nm.cbSize := sizeof(NONCLIENTMETRICS);
1492 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0);
1493 lf := nm.lfMenuFont;
1495 Font.Name := lf.lfFaceName;
1496 Font.Height := lf.lfHeight;
1498 if lf.lfWeight >= 700 then
1499 Font.Style := Font.Style + [fsBold];
1500 if lf.lfItalic = 1 then
1501 Font.Style := Font.Style + [fsItalic];
1504 (*************************************************************************
1506 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1507 *************************************************************************)
1508 function TGikoSys.RemoveToken(var s: string; delimiter: string): string;
1512 p := AnsiPos(delimiter, s);
1516 Result := Copy(s, 1, p - 1);
1517 s := Copy(s, Length(Result) + Length(delimiter) + 1, Length(s));
1520 (*************************************************************************
1522 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1523 *************************************************************************)
1524 function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string;
1529 for i := 0 to index do
1530 Result := RemoveToken(s, delimiter);
1533 (*************************************************************************
1535 *************************************************************************)
1536 function TGikoSys.DeleteLink(const s: string): string;
1546 s1 := GetTokenIndex(s, '<a href="', i);
1547 s2 := GetTokenIndex(s, '<a href="', i + 1);
1549 idx := Pos('">', s1);
1551 Delete(s1, 1, idx + 1);
1552 idx := Pos('">', s2);
1554 Delete(s2, 1, idx + 1);
1556 Result := Result + s1 + s2;
1565 //
\83C
\83\93\83f
\83b
\83N
\83X
\96¢
\8dX
\90V
\83o
\83b
\83t
\83@
\82ð
\83t
\83\89\83b
\83V
\83\85\81I
1566 {procedure TGikoSys.FlashExitWrite;
1570 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
1571 for i := 0 to FExitWrite.Count - 1 do
1572 WriteThreadDat(FExitWrite[i]);
1576 (*************************************************************************
1577 *
\83X
\83\8c\96¼
\82È
\82Ç
\82ð
\92Z
\82¢
\96¼
\91O
\82É
\95Ï
\8a·
\82·
\82é
1579 *************************************************************************)
1580 function TGikoSys.GetShortName(const LongName: string; ALength: integer): string;
1582 ERASECHAR : array [1..39] of string =
1583 ('
\81\99','
\81\9a','
\81¡','
\81 ','
\81\9f','
\81\9e','
\81Q','
\81\94','
\81£','
\81¥',
1584 '
\81¢','
\81¤','
\81\9c','
\81\9b','
\81\9d','
\81y','
\81z','
\81ô','
\81s','
\81t',
1585 '
\81g','
\81h','
\81k','
\81l','
\81e','
\81f','
\81\83','
\81\84','
\81á','
\81â',
1586 '
\81o','
\81p','
\81q','
\81r','
\81w','
\81x','
\81¬','
\81c', '
\81@');
1588 Chr : array [0..255] of char;
1592 s := Trim(LongName);
1593 if (Length(s) <= ALength) then begin
1597 for i := Low(ERASECHAR) to High(ERASECHAR) do begin
1598 S := StringReplace(S, ERASECHAR[i], '', [rfReplaceAll]);
1600 if (Length(S) <= ALength) then begin
1603 Windows.LCMapString(
1604 GetUserDefaultLCID(),
1612 S := Copy(S,1,ALength);
1614 if (ByteType(S, Length(S)) = mbLeadByte ) then begin
1615 S := Copy(S, 1, Length(S) - 1);
1625 (*************************************************************************
1628 *************************************************************************)
1629 function TGikoSys.ConvRes(const Body, Bbs, Key,
1630 ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
1634 FIndexFrom : integer;
1641 ZN = '
\82O
\82P
\82Q
\82R
\82S
\82T
\82U
\82V
\82W
\82X
\81|';
1655 procedure Add(IndexFrom, IndexTo: integer; const No: string);
1660 FIndex.FIndexFrom := IndexFrom;
1661 FIndex.FIndexTo := IndexTo;
1665 function ChooseString(const Text, Separator: string; Index: integer): string;
1671 for i := 0 to Index - 1 do begin
1672 if (AnsiPos(Separator, S) = 0) then S := ''
1673 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
1675 p := AnsiPos(Separator, S);
1676 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
1685 List:= TList.Create;
1691 b := ByteType(s, i);
1693 mbSingleByte : begin
1694 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1695 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1703 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1704 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
1710 if (not sw) and (Copy(s,i,4) = GT) then begin
1711 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1719 if ((not sw) and (Copy(s,i,1) = ',')) or
1720 ((not sw) and (Copy(s,i,1) = '=')) then begin
1721 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
1722 ((Chk) and (oc = '')) or
1723 ((not Chk) and (al)) then
1733 if (AnsiPos(sx, SN) > 0) then begin
1736 if (No <> '') and (No <> '-') then begin
1749 if Copy(s,i,1) = '<' then oc := '';
1750 oc := oc + Copy(s,i,1);
1756 if (not sw) and (Copy(s,i,4) = '
\81\84\81\84') then begin
1762 if (not sw) and (Copy(s,i,2) = '
\81\84') then begin
1770 if (AnsiPos(sx, ZN) > 0) then begin
1771 No := No + ZenToHan(sx);
1773 if (No <> '') and (No <> '-') and (No <> '
\81|') then begin
1788 if (i > Length(Body)) then begin
1790 if (No <> '') then Add(sp, i, No);
1795 for i := List.Count - 1 downto 0 do begin
1796 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
1797 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
1798 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
1800 st := PIndex(List[i]).FNo;
1801 et := PIndex(List[i]).FNo;
1803 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
1804 Format('<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">',
1805 [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
1806 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
1807 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
1808 Dispose(PIndex(List[i]));
1814 (*************************************************************************
1815 *
\91S
\8ap
\81¨
\94¼
\8ap
1817 *************************************************************************)
1818 function TGikoSys.ZenToHan(const s: string): string;
1820 Chr: array [0..255] of char;
1822 Windows.LCMapString(
1823 GetUserDefaultLCID(),
1825 LCMAP_HALFWIDTH or LCMAP_KATAKANA or LCMAP_LOWERCASE,
1834 (*************************************************************************
1835 *
\91S
\8ap
\94¼
\8ap
\82Ð
\82ç
\82ª
\82È
\82©
\82½
\82©
\82È
\82ð
\8bæ
\95Ê
\82µ
\82È
\82¢
\90¦
\82¢Pos
1836 *************************************************************************)
1837 function TGikoSys.VaguePos(const Substr, S: string): Integer;
1839 Result := Pos(ZenToHan(Substr), ZenToHan(S));
1842 function TGikoSys.BoolToInt(b: Boolean): Integer;
1844 Result := IfThen(b, 1, 0);
1847 function TGikoSys.IntToBool(i: Integer): Boolean;
1852 //gzip
\82Å
\88³
\8fk
\82³
\82ê
\82½
\82Ì
\82ð
\96ß
\82·
1853 function TGikoSys.GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
1857 GZipStream: TGzipDecompressStream;
1858 TextStream: TStringStream;
1859 buf: array[0..BUF_SIZE - 1] of Byte;
1865 TextStream := TStringStream.Create('');
1867 //
\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¢)
1868 // if LowerCase(Trim(ContentEncoding)) = 'gzip' then begin
1869 if AnsiPos('gzip', LowerCase(Trim(ContentEncoding))) > 0 then begin
1870 ResStream.Position := 0;
1871 GZipStream := TGzipDecompressStream.Create(TextStream);
1874 FillChar(buf, BUF_SIZE, 0);
1875 cnt := ResStream.Read(buf, BUF_SIZE);
1877 GZipStream.Write(buf, BUF_SIZE);
1883 ResStream.Position := 0;
1885 FillChar(buf, BUF_SIZE, 0);
1886 cnt := ResStream.Read(buf, BUF_SIZE);
1888 TextStream.Write(buf, BUF_SIZE);
1892 //NULL
\95¶
\8e\9a\82ð"*"
\82É
\82·
\82é
1893 s := TextStream.DataString;
1895 while (i > 0) and (s[i] = #0) do
1900 while i <> 0 do begin
1910 procedure TGikoSys.LoadKeySetting(ActionList: TActionList);
1912 STD_SEC = 'KeySetting';
1918 SecList: TStringList;
1919 Component: TComponent;
1921 if not FileExists(GetConfigDir + KEY_SETTING_FILE_NAME) then
1923 SecList := TStringList.Create;
1924 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
1926 ini.ReadSection(STD_SEC, SecList);
1927 for i := 0 to SecList.Count - 1 do begin
1928 ActionName := SecList[i];
1929 ActionKey := ini.ReadInteger(STD_SEC, ActionName, -1);
1930 if ActionKey <> -1 then begin
1931 Component := ActionList.Owner.FindComponent(ActionName);
1932 if TObject(Component) is TAction then begin
1933 TAction(Component).ShortCut := ActionKey;
1943 procedure TGikoSys.SaveKeySetting(ActionList: TActionList);
1945 STD_SEC = 'KeySetting';
1950 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
1952 for i := 0 to ActionList.ActionCount - 1 do begin
1953 if ActionList.Actions[i].Tag = -1 then
1955 ini.WriteInteger(STD_SEC, ActionList.Actions[i].Name, TAction(ActionList.Actions[i]).ShortCut);
1964 procedure TGikoSys.CreateProcess(const AppPath: string; const Param: string);
1966 PI: TProcessInformation;
1970 Path := '"' + AppPath + '"';
1972 Path := Path + ' ' + Param;
1974 SI.Cb := SizeOf(Si);
1975 SI.lpReserved := nil;
1976 SI.lpDesktop := nil;
1979 SI.cbReserved2 := 0;
1980 SI.lpReserved2 := nil;
1982 Windows.CreateProcess(nil,
1994 procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
1998 HlinkNavigateString(nil, PWideChar(WideString(URL)));
1999 gbtUserApp, gbtAuto:
2000 if (Setting.URLApp) and (FileExists(Setting.URLAppFile)) then
2001 GikoSys.CreateProcess(Setting.URLAppFile, URL)
2003 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2007 function TGikoSys.HTMLDecode(const AStr: String): String;
2009 Sp, Rp, Cp, Tp: PChar;
2014 SetLength(Result, Length(AStr));
2016 Rp := PChar(Result);
2019 while Sp^ <> #0 do begin
2025 'a': if AnsiStrPos(Sp, 'amp;') = Sp then
2031 'g': if (AnsiStrPos(Sp, 'lt;') = Sp) or (AnsiStrPos(Sp, 'gt;') = Sp) then
2035 while (Sp^ <> ';') and (Sp^ <> #0) do
2042 'q': if AnsiStrPos(Sp, 'quot;') = Sp then
2050 Num := IsNumeric(Copy(Tp, 1, 1));
2051 while (Sp^ <> ';') and (Sp^ <> #0) do begin
2052 if (Num) and (not IsNumeric(Copy(Sp, 1, 1))) then
2056 SetString(S, Tp, Sp - Tp);
2061 //raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2062 //[Cp^ + Sp^, Cp - PChar(AStr)])
2072 // on E:EConvertError do
2073 // raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2074 // [Cp^ + Sp^, Cp - PChar(AStr)])
2076 SetLength(Result, Rp - PChar(Result));
2079 function TGikoSys.GetHRefText(s: string): string;
2089 Index := AnsiPos('href', LowerCase(s));
2092 s := Trim(Copy(s, Index + 4, Length(s)));
2093 s := Trim(Copy(s, 2, Length(s)));
2095 //
\8en
\82ß
\82Ì
\95¶
\8e\9a\82ª'"'
\82È
\82ç
\8eæ
\82è
\8f\9c\82
2096 if Copy(s, 1, 1) = '"' then begin
2097 s := Trim(Copy(s, 2, Length(s)));
2100 Index := AnsiPos('"', s);
2101 if Index <> 0 then begin
2102 //'"'
\82Ü
\82ÅURL
\82Æ
\82·
\82é
2103 s := Copy(s, 1, Index - 1);
2105 //'"'
\82ª
\96³
\82¯
\82ê
\82Î
\83X
\83y
\81[
\83X
\82©">"
\82Ì
\91\81\82¢
\95û
\82Ü
\82Å
\82ðURL
\82Æ
\82·
\82é
2106 Index := AnsiPos(' ', s);
2107 Index2 := AnsiPos('>', s);
2110 if Index > Index2 then
2113 s := Copy(s, 1, Index - 1)
2115 //
\82±
\82ê
\88È
\8fã
\82à
\82¤
\92m
\82ç
\82ñ
\82Ê
2121 //
\83z
\83X
\83g
\96¼
\82ª
\82Q
\82\83\82\88\82©
\82Ç
\82¤
\82©
\83`
\83F
\83b
\83N
\82·
\82é
2122 function TGikoSys.Is2chHost(Host: string): Boolean;
2124 HOST_NAME: array[0..1] of string = ('2ch.net', 'bbspink.com');
2130 OutputDebugString(pchar(HOST_NAME[0]));
2131 for i := 0 to Length(HOST_NAME) - 1 do begin
2132 // Len := Length(HOST_NAME[i]);
2133 if AnsiPos(HOST_NAME[i], Host) = (Length(Host) - Length(HOST_NAME[i]) + 1) then begin
2140 function TGikoSys.Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
2142 READ_PATH: string = '/test/read.cgi/';
2143 OLD_READ_PATH: string = '/test/read.cgi?';
2144 KAKO_PATH: string = '/kako/';
2154 Index := AnsiPos(READ_PATH, path);
2155 if Index <> 0 then begin
2156 s := Copy(path, Length(READ_PATH) + 1, Length(path));
2157 BBSID := GetTokenIndex(s, '/', 0);
2158 BBSKey := GetTokenIndex(s, '/', 1);
2161 Result := (BBSID <> '') or (BBSKey <> '');
2164 Index := AnsiPos(KAKO_PATH, path);
2165 if Index <> 0 then begin
2166 s := Copy(path, 2, Length(path));
2167 BBSID := GetTokenIndex(s, '/', 0);
2168 if (BBSID = 'log') and (GetTokenIndex(s, '/', 2) = 'kako') then
2169 BBSID := GetTokenIndex(s, '/', 1);
2170 BBSKey := ChangeFileExt(Document, '');
2171 Result := (BBSID <> '') or (BBSKey <> '');
2174 Index := AnsiPos('read.cgi?', URL);
2175 if Index <> 0 then begin
2176 SList := TStringList.Create;
2179 // s := HTMLDecode(Document);
2180 ExtractHTTPFields(['?', '&'], [], PChar(URL), SList, False);
2181 BBSID := SList.Values['bbs'];
2182 BBSKey := SList.Values['key'];
2183 Result := (BBSID <> '') or (BBSKey <> '');
2194 function TGikoSys.Parse2chURL2(URL: string): TPathRec;
2206 URL := Trim(LowerCase(URL));
2211 Result.FFirst := False;
2212 Result.FStBegin := False;
2213 Result.FToEnd := False;
2214 Result.FDone := False;
2219 FAWKStr.RegExp := 'http://.+\.(2ch\.net|bbspink\.com)/';
2220 if FAWKStr.Match(FAWKStr.ProcessEscSeq(URL), RStart, RLength) = 0 then
2222 s := Copy(URL, RStart + RLength - 1, Length(URL));
2224 //
\95W
\8f\80\8f\91\8e®
2225 //
\8dÅ
\8cã
\82Íl50, 10, 10-20, 10n, 10-20n, -10, 10-, 10n-
\82È
\82Ç
2226 //http://xxx.2ch.net/test/read.cgi/bbsid/1000000000/
2227 FAWKStr.RegExp := '/test/read.cgi/.+/[0-9]+/.*';
2228 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2229 s := Copy(s, 15, Length(s));
2231 SList := TStringList.Create;
2234 FAWKStr.RegExp := '/';
2235 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2236 Result.FBBS := SList[1];
2237 Result.FKey := SList[2];
2238 if SList.Count >= 3 then
2246 FAWKStr.LineSeparator := mcls_CRLF;
2247 FAWKStr.RegExp := '-';
2248 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) = 0 then begin
2249 Result.FFirst := True;
2251 FAWKStr.RegExp := 'l[0-9]+';
2252 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2253 Result.FFirst := True;
2255 for i := 0 to SList.Count - 1 do begin
2256 if Trim(SList[i]) = '' then begin
2258 Result.FStBegin := True;
2259 if i = (SList.Count - 1) then
2260 Result.FToEnd := True;
2261 end else if IsNumeric(SList[i]) then begin
2262 wkInt := StrToInt(SList[i]);
2263 wkMax := Max(wkMax, wkInt);
2267 wkMin := Min(wkMin, wkInt);
2268 end else if Trim(SList[i]) = 'n' then begin
2269 Result.FFirst := True;
2271 FAWKStr.RegExp := '^n[0-9]+$|^[0-9]+n$';
2272 if FAWKStr.Match(FAWKStr.ProcessEscSeq(SList[i]), RStart, RLength) > 0 then begin
2273 if Copy(SList[i], 1, 1) = 'n' then
2274 wkInt := StrToInt(Copy(SList[i], 2, Length(SList[i])))
2276 wkInt := StrToInt(Copy(SList[i], 1, Length(SList[i]) - 1));
2277 Result.FFirst := True;
2278 wkMax := Max(wkMax, wkInt);
2282 wkMin := Min(wkMin, wkInt);
2286 if Result.FStBegin and (not Result.FToEnd) then
2288 else if (not Result.FStBegin) and Result.FToEnd then
2290 else if (not Result.FStBegin) and (not Result.FToEnd) then begin
2291 Result.FSt := wkMin;
2292 Result.FTo := wkMax;
2294 //Result.FSt := wkMin;
2295 //Result.FTo := wkMax;
2301 Result.FDone := True;
2305 //
\90Vkako
\8f\91\8e®
2306 //http://server.2ch.net/ITA_NAME/kako/1000/10000/1000000000.html
2307 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+/[0-9]+\.html';
2308 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2309 SList := TStringList.Create;
2312 FAWKStr.RegExp := '/';
2313 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2314 Result.FBBS := SList[1];
2315 Result.FKey := ChangeFileExt(SList[5], '');
2316 Result.FFirst := True;
2322 Result.FDone := True;
2326 //
\8b\8ckako
\8f\91\8e®
2327 //http://server.2ch.net/ITA_NAME/kako/999/999999999.html
2328 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+\.html';
2329 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2330 SList := TStringList.Create;
2333 FAWKStr.RegExp := '/';
2334 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 5 then begin
2335 Result.FBBS := SList[1];
2336 Result.FKey := ChangeFileExt(SList[4], '');
2337 Result.FFirst := True;
2343 Result.FDone := True;
2347 //log
\8by
\82Ñlog2
\8f\91\8e®
2348 //http://server.2ch.net/log/ITA_NAME/kako/999/999999999.html
2349 //http://server.2ch.net/log2/ITA_NAME/kako/999/999999999.html
2350 FAWKStr.RegExp := '/log2?/.+/kako/[0-9]+/[0-9]+\.html';
2351 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2352 SList := TStringList.Create;
2355 FAWKStr.RegExp := '/';
2356 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2357 Result.FBBS := SList[2];
2358 Result.FKey := ChangeFileExt(SList[5], '');
2359 Result.FFirst := True;
2365 Result.FDone := True;
2370 //
\8b\8cURL
\8f\91\8e®
2371 //http://server.2ch.net/test/read.cgi?bbs=ITA_NAME&key=1000000000&st=1&to=5&nofirst=true
2372 FAWKStr.RegExp := '/test/read\.cgi\?';
2373 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2374 s := Copy(s, 16, Length(s));
2375 SList := TStringList.Create;
2378 FAWKStr.RegExp := '&';
2379 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2380 Result.FFirst := True;
2381 for i := 0 to SList.Count - 1 do begin
2382 if Pos('bbs=', SList[i]) = 1 then begin
2383 Result.FBBS := Copy(SList[i], 5, Length(SList[i]));
2384 end else if Pos('key=', SList[i]) = 1 then begin
2385 Result.FKey := Copy(SList[i], 5, Length(SList[i]));
2386 end else if Pos('st=', SList[i]) = 1 then begin
2387 wk := Copy(SList[i], 4, Length(SList[i]));
2388 if IsNumeric(wk) then
2389 Result.FSt := StrToInt(wk)
2390 else if wk = '' then
2391 Result.FStBegin := True;
2392 end else if Pos('to=', SList[i]) = 1 then begin
2393 wk := Copy(SList[i], 4, Length(SList[i]));
2394 if IsNumeric(wk) then
2395 Result.FTo := StrToInt(wk)
2396 else if wk = '' then
2397 Result.FToEnd := True;
2398 end else if Pos('nofirst=', SList[i]) = 1 then begin
2399 Result.FFirst := False;
2408 if (Result.FBBS <> '') and (Result.FKey <> '') then begin
2409 Result.FDone := True;
2415 procedure TGikoSys.ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
2425 URI := TIdURI.Create(URL);
2427 Protocol := URI.Protocol;
2430 Document := URI.Document;
2432 Bookmark := URI.Bookmark;
2438 function TGikoSys.GetVersionBuild: Integer;
2440 FixedFileInfo: PVSFixedFileInfo;
2441 VersionHandle, VersionSize: DWORD;
2442 pVersionInfo: Pointer;
2447 AppFile := Application.ExeName;
2448 VersionSize := GetFileVersionInfoSize(pChar(AppFile), VersionHandle);
2449 if VersionSize = 0 then
2451 GetMem(pVersionInfo, VersionSize);
2453 if GetFileVersionInfo(PChar(AppFile),VersionHandle,VersionSize, pVersionInfo) then
2454 if VerQueryValue(pVersionInfo, '\', Pointer(FixedFileInfo), ItemLen) then
2455 Result := LOWORD(FixedFileInfo^.dwFileVersionLS);
2457 FreeMem(pVersionInfo, VersionSize);
2462 GikoSys := TGikoSys.Create;
2465 if GikoSys <> nil then begin