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 SKIN_BOOKMARK_FILE_NAME = 'Bookmark.html';
212 SKIN_NEWMARK_FILE_NAME = 'Newmark.html';
213 FOLDER_INDEX_VERSION = '1.01';
214 USER_AGENT = 'Monazilla';
215 APP_NAME = 'gikoNavi';
216 DEFAULT_NGWORD_FILE_NAME : String = 'NGword.txt';
217 NGWORDs_DIR_NAME : String = 'NGwords';
219 (*************************************************************************
220 *GikoSys
\83R
\83\93\83X
\83g
\83\89\83N
\83^
221 *************************************************************************)
222 constructor TGikoSys.Create;
224 FSetting := TSetting.Create;
225 FDolib := TDolib.Create;
226 FAWKStr := TAWKStr.Create(nil);
227 if DirectoryExists(GetConfigDir) = false then begin
228 CreateDir(GetConfigDir);
230 FAbon := TAbon.Create;
231 FAbon.Setroot(GetConfigDir+NGWORDs_DIR_NAME);
232 //FAbon.SetNGwordpath(DEFAULT_NGWORD_FILE_NAME);
234 FSelectResFilter := TAbon.Create;
235 //
\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
236 FSelectResFilter.AbonString := '';
239 (*************************************************************************
240 *GikoSys
\83f
\83X
\83g
\83\89\83N
\83^
241 *************************************************************************)
242 destructor TGikoSys.Destroy;
245 FileList: TStringList;
247 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
255 //
\83e
\83\93\83|
\83\89\83\8aHTML
\82ð
\8dí
\8f\9c
256 FileList := TStringList.Create;
258 GetFileList(GetTempFolder, '*.html', FileList, False, True);
259 for i := 0 to FileList.Count - 1 do begin
260 DeleteFile(FileList[i]);
268 (*************************************************************************
269 *
\95¶
\8e\9a\97ñ
\90\94\8e\9a\83`
\83F
\83b
\83N
270 *************************************************************************)
272 function TGikoSys.IsNumeric(s: string): boolean;
282 (*************************************************************************
283 *
\95¶
\8e\9a\97ñ
\95\82\93®
\8f¬
\90\94\93_
\90\94\8e\9a\83`
\83F
\83b
\83N
284 *************************************************************************)
285 function TGikoSys.IsFloat(s: string): boolean;
289 Result := TextToFloat(PChar(s), v, fvExtended);
292 (*************************************************************************
293 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
294 *************************************************************************)
295 function TGikoSys.GetBoardFileName: string;
297 Result := GetAppDir + CONFIG_DIR_NAME + '\' + BOARD_FILE_NAME;
300 (*************************************************************************
301 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
302 *************************************************************************)
303 function TGikoSys.GetCustomBoardFileName: string;
305 Result := GetAppDir + CONFIG_DIR_NAME + '\' + CUSTOMBOARD_FILE_NAME;
308 (*************************************************************************
309 *
\83e
\83\93\83|
\83\89\83\8a\83t
\83H
\83\8b\83_
\81[
\96¼
\8eæ
\93¾
310 *************************************************************************)
311 function TGikoSys.GetHtmlTempFileName: string;
313 Result := TEMP_FOLDER;
317 (*************************************************************************
318 *
\8eÀ
\8ds
\83t
\83@
\83C
\83\8b\83t
\83H
\83\8b\83_
\8eæ
\93¾
319 *************************************************************************)
320 function TGikoSys.GetAppDir: string;
322 Result := ExtractFilePath(Application.ExeName);
325 (*************************************************************************
326 *TempHtml
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
327 *************************************************************************)
328 function TGikoSys.GetTempFolder: string;
330 Result := GetAppDir + TEMP_FOLDER;
333 (*************************************************************************
334 *sent.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
335 *************************************************************************)
336 function TGikoSys.GetSentFileName: string;
338 Result := GetAppDir + SENT_FILE_NAME;
341 (*************************************************************************
342 *outbox.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
343 *************************************************************************)
344 function TGikoSys.GetOutBoxFileName: string;
346 Result := GetAppDir + OUTBOX_FILE_NAME;
349 (*************************************************************************
350 *Config
\83t
\83H
\83\8b\83_
\8eæ
\93¾
351 *************************************************************************)
352 function TGikoSys.GetConfigDir: string;
354 Result := IncludeTrailingPathDelimiter(GetAppDir + CONFIG_DIR_NAME);
357 function TGikoSys.GetStyleSheetDir: string;
359 Result := IncludeTrailingPathDelimiter(GetConfigDir + CSS_DIR_NAME);
362 function TGikoSys.GetSkinDir: string;
364 Result := IncludeTrailingPathDelimiter(GetConfigDir + SKIN_DIR_NAME);
367 (*************************************************************************
368 *URL
\82ð
\8dì
\90¬(
\83R
\83s
\83y
\97p)
369 *************************************************************************)
370 function TGikoSys.GetURL(BBSID: string; FileName: string): string;
374 Board := BoardGroup.BBS2ch.GetBoardFromBBSID(BBSID);
375 Result := UrlToServer(Board.URL) + 'test/read.cgi/' + UrlToID(Board.URL) + '/' + ChangeFileExt(FileName, '') + '/l50';
376 //http://teri.2ch.net/test/read.cgi?bbs=accuse&key=974619522&ls=50
377 //http://pc.2ch.net/test/read.cgi/tech/1003664165/l50
381 function TGikoSys.GetUserAgent: string;
383 if Dolib.Connected then begin
384 Result := Format('%s %s/%s%d%s', [
391 BETA_VERSION_BUILD]);
393 Result := Format('%s/%s %s/%s%d%s', [
401 BETA_VERSION_BUILD]);
405 (*************************************************************************
406 *
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é
\95û
\8e®
\8e\9e\8d\8f\8eæ
\93¾
407 *************************************************************************)
408 function TGikoSys.Get2chDate(aDate: TDateTime): string;
413 d1 := EncodeDate(1970, 1, 1);
414 d2 := aDate - EncodeTime(9, 0, 0, 0);
415 Result := FloatToStr(Trunc((d2 - d1) * 24 * 60 * 60));
419 function TGikoSys.IntToDateTime(val: Int64): TDateTime;
424 d1 := EncodeDate(1970, 1, 1);
425 d2 := (val * 1000) / (24 * 60 * 60 * 1000);
429 function TGikoSys.DateTimeToInt(ADate: TDateTime): Integer;
434 d := EncodeDate(1970, 1, 1);
435 c := (ADate - d) * 24 * 60 * 60;
440 (*************************************************************************
441 *Subject
\83t
\83@
\83C
\83\8bRead
442 *************************************************************************)
443 procedure TGikoSys.ReadSubjectFile(Board: TBoard);
445 ThreadItem: TThreadItem;
447 FileList: TStringList;
448 TmpFileList: TStringList;
449 // SrchRec: TSearchRec;
456 // TmpUpdate: Boolean;
459 RoundItem: TRoundItem;
464 // TmpUpdate := False;
466 FileName := Board.GetFolderIndexFileName;
467 if not FileExists(FileName) then CreateThreadDat(Board);
468 // if not FileExists(FileName) then Exit;
470 //IsLogFile
\97pDAT
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
471 FileList := TStringList.Create;
472 FileList.Sorted := True;
473 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False, False);
475 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\97pTmp
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
476 TmpFileList := TStringList.Create;
477 TmpFileList.Sorted := True;
478 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, False, False);
480 { R := FindFirst(ExtractFileDir(Board.GetFolderIndexFileName) + '\*.dat', 0, SrchRec);
482 FileList.Add(SrchRec.Name);
483 R := FindNext(SrchRec);
487 sl := TStringList.Create;
489 if FileExists(FileName) then
490 sl.LoadFromFile(FileName);
492 //
\82Q
\8ds
\96Ú
\82©
\82ç
\81i
\82P
\8ds
\96Ú
\82Í
\83o
\81[
\83W
\83\87\83\93\81j
493 for i := 1 to sl.Count - 1 do begin
494 Rec := ParseIndexLine(sl[i]);
496 ThreadItem := TThreadItem.Create;
497 ThreadItem.BeginUpdate;
498 ThreadItem.No := Rec.FNo;
499 ThreadItem.FileName := Rec.FFileName;
500 ThreadItem.Title := Rec.FTitle;
501 ThreadItem.Count := Rec.FCount;
502 ThreadItem.Size := Rec.FSize;
503 // ThreadItem.RoundNo := Rec.FRoundNo;
504 ThreadItem.RoundDate := Rec.FRoundDate;
505 ThreadItem.LastModified := Rec.FLastModified;
506 ThreadItem.Kokomade := Rec.FKokomade;
507 ThreadItem.NewReceive := Rec.FNewReceive;
508 // ThreadItem.Round := Rec.FRound;
509 ThreadItem.UnRead := Rec.FUnRead;
510 ThreadItem.ScrollTop := Rec.FScrollTop;
511 ThreadItem.AllResCount := Rec.FAllResCount;
512 ThreadItem.NewResCount := Rec.FNewResCount;
513 ThreadItem.AgeSage := Rec.FAgeSage;
514 ThreadItem.ParentBoard := Board;
516 //IsLogFile
\83`
\83F
\83b
\83N
517 ThreadItem.IsLogFile := False;
518 if FileList.Count <> 0 then begin
519 if FileList.Find(ThreadItem.FileName, Index) then begin
520 ThreadItem.IsLogFile := True;
521 FileList.Delete(Index);
525 //
\8f\84\89ñ
\83\8a\83X
\83g
\82É
\91¶
\8dÝ
\82µ
\82½
\82ç
\8f\84\89ñ
\83t
\83\89\83O
\83Z
\83b
\83g
526 if ThreadItem.IsLogFile then begin
527 idx := RoundList.Find(ThreadItem);
528 if idx <> -1 then begin
529 RoundItem := RoundList.Items[idx, grtItem];
530 ThreadItem.RoundName := RoundItem.RoundName;
531 ThreadItem.Round := True;
535 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\83`
\83F
\83b
\83N
536 if TmpFileList.Count <> 0 then begin
537 if TmpFileList.Find(ChangeFileExt(ThreadItem.FileName, '.tmp'), Index) then begin
538 ini := TMemIniFile.Create(ChangeFileExt(ThreadItem.GetThreadFileName, '.tmp'));
540 ThreadItem.RoundDate := ini.ReadDateTime('Setting', 'RoundDate', ZERO_DATE);
541 ThreadItem.LastModified := ini.ReadDateTime('Setting', 'LastModified', ZERO_DATE);
542 ThreadItem.Size := ini.ReadInteger('Setting', 'Size', 0);
543 ThreadItem.Count := ini.ReadInteger('Setting', 'Count', 0);
544 ThreadItem.NewReceive := ini.ReadInteger('Setting', 'NewReceive', 0);
545 ThreadItem.Round := ini.ReadBool('Setting', 'Round', False);
546 ThreadItem.UnRead := False;//ini.ReadBool('Setting', 'UnRead', False);
547 ThreadItem.ScrollTop := ini.ReadInteger('Setting', 'ScrollTop', 0);
548 ThreadItem.AllResCount := ini.ReadInteger('Setting', 'AllResCount', 0);
549 ThreadItem.NewResCount := ini.ReadInteger('Setting', 'NewResCount', 0);
550 ThreadItem.AgeSage := TGikoAgeSage(ini.ReadInteger('Setting', 'AgeSage', Ord(gasNone)));
554 TmpFileList.Delete(Index);
558 ThreadItem.EndUpdate;
559 Board.Add(ThreadItem);
561 // if (ThreadItem.IsLogFile) and (ThreadItem.Count > ThreadItem.Kokomade) then
562 if (ThreadItem.IsLogFile) and (ThreadItem.UnRead) then
565 if UnRead <> Board.UnRead then
566 Board.UnRead := UnRead;
568 //
\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
569 for i := 0 to FileList.Count - 1 do begin
570 FileName := ExtractFileDir(Board.GetFolderIndexFileName) + '\' + FileList[i];
572 ResRec := DivideStrLine(ReadThreadFile(FileName, 1));
573 ThreadItem := TThreadItem.Create;
574 ThreadItem.No := Board.Count + 1;
575 ThreadItem.FileName := FileList[i];
576 ThreadItem.Title := ResRec.FTitle;
577 ThreadItem.Count := GetFileLineCount(FileName);
578 ThreadItem.AllResCount := ThreadItem.Count;
579 ThreadItem.NewResCount := 0;
580 ThreadItem.Size := 0;
581 ThreadItem.RoundDate := ZERO_DATE;
582 ThreadItem.LastModified := ZERO_DATE;
583 ThreadItem.Kokomade := -1;
584 ThreadItem.NewReceive := 0;
585 ThreadItem.ParentBoard := Board;
586 ThreadItem.IsLogFile := True;
587 ThreadItem.Round := False;
588 ThreadItem.UnRead := False;
589 ThreadItem.ScrollTop := 0;
590 ThreadItem.AgeSage := gasNone;
591 Board.Add(ThreadItem);
598 Board.IsThreadDatRead := True;
601 (*************************************************************************
602 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X
\83t
\83@
\83C
\83\8b(Folder.idx)
\8dì
\90¬
603 *************************************************************************)
604 procedure TGikoSys.CreateThreadDat(Board: TBoard);
608 SubjectList: TStringList;
614 if not FileExists(Board.GetSubjectFileName) then Exit;
615 FileName := Board.GetFolderIndexFileName;
617 SubjectList := TStringList.Create;
619 SubjectList.LoadFromFile(Board.GetSubjectFileName);
620 sl := TStringList.Create;
623 sl.Add(FOLDER_INDEX_VERSION);
624 for i := 0 to SubjectList.Count - 1 do begin
625 Rec := DivideSubject(SubjectList[i]);
627 if (Trim(Rec.FFileName) = '') or (Trim(Rec.FTitle) = '') then
630 s := Format('%x', [cnt]) + #1 //
\94Ô
\8d\86
631 + Rec.FFileName + #1 //
\83t
\83@
\83C
\83\8b\96¼
632 + Rec.FTitle + #1 //
\83^
\83C
\83g
\83\8b
633 + Format('%x', [Rec.FCount]) + #1 //
\83J
\83E
\83\93\83g
634 + Format('%x', [0]) + #1 //size
635 + Format('%x', [0]) + #1 //RoundDate
636 + Format('%x', [0]) + #1 //LastModified
637 + Format('%x', [0]) + #1 //Kokomade
638 + Format('%x', [0]) + #1 //NewReceive
639 + '0' + #1 //
\96¢
\8eg
\97p
640 + Format('%x', [0]) + #1 //UnRead
641 + Format('%x', [0]) + #1 //ScrollTop
642 + Format('%x', [Rec.FCount]) + #1 //AllResCount
643 + Format('%x', [0]) + #1 //NewResCount
644 + Format('%x', [0]); //AgeSage
649 sl.SaveToFile(FileName);
658 (*************************************************************************
659 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X(Thread.dat)
\8f\91\82«
\8d\9e\82Ý
661 *************************************************************************)
662 procedure TGikoSys.WriteThreadDat(Board: TBoard);
664 // Values: array[Boolean] of string = ('0', '1');
670 FileList: TStringList;
672 if not Board.IsThreadDatRead then
674 FileName := Board.GetFolderIndexFileName;
675 ForceDirectoriesEx(Board.ParentCategory.ParentBBS2ch.GetLogFolder + Board.BBSID);
677 sl := TStringList.Create;
679 sl.Add(FOLDER_INDEX_VERSION);
680 for i := 0 to Board.Count - 1 do begin
681 if Board.Items[i].No = 0 then
682 Board.Items[i].No := i + 1;
684 s := Format('%x', [Board.Items[i].No]) + #1
685 + Board.Items[i].FileName + #1
686 + Board.Items[i].Title + #1
687 + Format('%x', [Board.Items[i].Count]) + #1
688 + Format('%x', [Board.Items[i].Size]) + #1
689 + Format('%x', [DateTimeToInt(Board.Items[i].RoundDate)]) + #1
690 + Format('%x', [DateTimeToInt(Board.Items[i].LastModified)]) + #1
691 + Format('%x', [Board.Items[i].Kokomade]) + #1
692 + Format('%x', [Board.Items[i].NewReceive]) + #1
693 + '0' + #1 //
\96¢
\8eg
\97p
694 + Format('%x', [BoolToInt(Board.Items[i].UnRead)]) + #1
695 + Format('%x', [Board.Items[i].ScrollTop]) + #1
696 + Format('%x', [Board.Items[i].AllResCount]) + #1
697 + Format('%x', [Board.Items[i].NewResCount]) + #1
698 + Format('%x', [Ord(Board.Items[i].AgeSage)]);
703 sl.SaveToFile(FileName);
705 FileList := TStringList.Create;
707 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', FileList, False, True);
708 for i := 0 to FileList.Count - 1 do begin
709 DeleteFile(FileList[i]);
719 function TGikoSys.ParseIndexLine(Line: string): TIndexRec;
724 for i := 0 to 14 do begin
725 s := GetTokenIndex(Line, #1, i);
727 0: Result.FNo := StrToIntDef('$' + s, 0);
728 1: Result.FFileName := s;
729 2: Result.FTitle := s;
730 3: Result.FCount := StrToIntDef('$' + s, 0);
731 4: Result.FSize := StrToIntDef('$' + s, 0);
732 5: Result.FRoundDate := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
733 6: Result.FLastModified := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
734 7: Result.FKokomade := StrToIntDef('$' + s, -1);
735 8: Result.FNewReceive := StrToIntDef('$' + s, 0);
737 10: Result.FUnRead := IntToBool(StrToIntDef('$' + s, 0));
738 11: Result.FScrollTop := StrToIntDef('$' + s, 0);
739 12: Result.FAllResCount := StrToIntDef('$' + s, 0);
740 13: Result.FNewResCount := StrToIntDef('$' + s, 0);
741 14: Result.FAgeSage := TGikoAgeSage(StrToIntDef('$' + s, 0));
746 //
\8ew
\92è
\83t
\83H
\83\8b\83_
\93à
\82Ì
\8ew
\92è
\83t
\83@
\83C
\83\8b\88ê
\97\97\82ð
\8eæ
\93¾
\82·
\82é
747 // ListFiles('c:\', '*.txt', list, True);
748 procedure TGikoSys.GetFileList(Path: string; Mask: string; List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
751 SearchRec : TSearchRec;
754 Path := IncludeTrailingPathDelimiter(Path);
755 rc := FindFirst(Path + '*.*', faAnyfile, SearchRec);
757 while rc = 0 do begin
758 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
759 s := Path + SearchRec.Name;
760 //if (SearchRec.Attr and faDirectory > 0) then
761 // s := IncludeTrailingPathDelimiter(s)
763 if (SearchRec.Attr and faDirectory = 0) and (MatchesMask(s, Mask)) then
767 List.Add(SearchRec.Name);
768 if SubDir and (SearchRec.Attr and faDirectory > 0) then
769 GetFileList(s, Mask, List, True, IsPathAdd);
771 rc := FindNext(SearchRec);
774 SysUtils.FindClose(SearchRec);
778 //
\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é
779 procedure TGikoSys.GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
782 SearchRec : TSearchRec;
785 Path := IncludeTrailingPathDelimiter(Path);
786 rc := FindFirst(Path + '*.*', faDirectory, SearchRec);
788 while rc = 0 do begin
789 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
790 s := Path + SearchRec.Name;
791 //if (SearchRec.Attr and faDirectory > 0) then
792 // s := IncludeTrailingPathDelimiter(s)
794 if (SearchRec.Attr and faDirectory > 0) and (MatchesMask(s, Mask)) then
795 List.Add( IncludeTrailingPathDelimiter( s ) );
796 if SubDir and (SearchRec.Attr and faDirectory > 0) then
797 GetDirectoryList(s, Mask, List, True);
799 rc := FindNext(SearchRec);
802 SysUtils.FindClose(SearchRec);
806 procedure TGikoSys.CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
810 //bufList : TStringList;
811 ReadList: TStringList;
812 SaveList: TStringList;
816 NewReceiveNo: Integer;
818 SkinHeaderFileName: string;
819 SkinNewResFileName: string;
820 SkinResFileName: string;
821 SkinFooterFileName: string;
822 SkinBookmarkFileName: string;
823 SkinNewmarkFileName: string;
828 //
\83X
\83L
\83\93\82ð
\93Ç
\82Ý
\8d\9e\82Ý
\81A
\92l
\82ð
\92u
\8a·
\82·
\82é
829 function LoadSkin( fileName: string ): string;
834 Skin := TStringList.Create;
836 Skin.LoadFromFile( fileName );
838 Skin.Text := StringReplace( Skin.Text, '<THREADNAME/>', sTitle, [rfReplaceAll] );
839 Skin.Text := StringReplace( Skin.Text, '<THREADURL/>', ThreadItem.GetSendURL, [rfReplaceAll] );
840 Skin.Text := StringReplace( Skin.Text, '<SKINPATH/>', Setting.CSSFileName, [rfReplaceAll] );
841 Skin.Text := StringReplace( Skin.Text, '<GETRESCOUNT/>', IntToStr( NewReceiveNo ), [rfReplaceAll] );
842 Skin.Text := StringReplace( Skin.Text, '<NEWRESCOUNT/>', IntToStr( ThreadItem.NewResCount ), [rfReplaceAll] );
843 Skin.Text := StringReplace( Skin.Text, '<ALLRESCOUNT/>', IntToStr( ThreadItem.AllResCount ), [rfReplaceAll] );
845 Skin.Text := StringReplace( Skin.Text, '<NEWDATE/>',
846 FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate), [rfReplaceAll] );
847 Skin.Text := StringReplace( Skin.Text, '<SIZEKB/>', IntToStr( Floor( SizeByte / 1024 ) ), [rfReplaceAll] );
848 Skin.Text := StringReplace( Skin.Text, '<SIZE/>', IntToStr( SizeByte ), [rfReplaceAll] );
850 //-----
\82Æ
\82è
\82 \82¦
\82¸
\82©
\82¿
\82ã
\81`
\82µ
\82á
\8cÝ
\8a·
\97p
\81B
\83R
\83\81\83\93\83g
\83A
\83E
\83g
\82µ
\82Ä
\82à
\82æ
\82µ
851 Skin.Text := StringReplace( Skin.Text, '&THREADNAME', sTitle, [rfReplaceAll] );
852 Skin.Text := StringReplace( Skin.Text, '&THREADURL', ThreadItem.GetSendURL, [rfReplaceAll] );
853 Skin.Text := StringReplace( Skin.Text, '&SKINPATH', Setting.CSSFileName, [rfReplaceAll] );
854 Skin.Text := StringReplace( Skin.Text, '&GETRESCOUNT', IntToStr( NewReceiveNo ), [rfReplaceAll] );
855 Skin.Text := StringReplace( Skin.Text, '&NEWRESCOUNT', IntToStr( ThreadItem.NewResCount ), [rfReplaceAll] );
856 Skin.Text := StringReplace( Skin.Text, '&ALLRESCOUNT', IntToStr( ThreadItem.AllResCount ), [rfReplaceAll] );
858 Skin.Text := StringReplace( Skin.Text, '&NEWDATE',
859 FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate), [rfReplaceAll] );
860 Skin.Text := StringReplace( Skin.Text, '&SIZEKB', IntToStr( Floor( SizeByte / 1024 ) ), [rfReplaceAll] );
861 Skin.Text := StringReplace( Skin.Text, '&SIZE', IntToStr( SizeByte ), [rfReplaceAll] );
862 //-----
\82±
\82±
\82Ü
\82Å
871 //
\83\8c\83X
\82Ì
\92l
\82ð
\92u
\8a·
\82·
\82é
872 function ReplaceRes( skin: string ): string;
876 Skin := StringReplace( Skin, '<NUMBER/>',
877 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>', [rfReplaceAll] );
878 Skin := StringReplace( Skin, '<PLAINNUMBER/>', No, [rfReplaceAll] );
879 Skin := StringReplace( Skin, '<NAME/>', Res.FName, [rfReplaceAll] );
880 Skin := StringReplace( Skin, '<MAILNAME/>',
881 '<a href="mailo:' + Res.FMailTo + '">' + Res.FName + '</a>', [rfReplaceAll] );
882 Skin := StringReplace( Skin, '<MAIL/>', Res.FMailTo, [rfReplaceAll] );
883 Skin := StringReplace( Skin, '<DATE/>', Res.FDateTime, [rfReplaceAll] );
884 Skin := StringReplace( Skin, '<MESSAGE/>', Res.FBody, [rfReplaceAll] );
886 //-----
\82©
\82¿
\82ã
\81`
\82µ
\82á
\8cÝ
\8a·
\97p
\81B
\83R
\83\81\83\93\83g
\83A
\83E
\83g
\82µ
\82Ä
\82à
\82æ
\82µ
887 Skin := StringReplace( Skin, '&NUMBER',
888 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>', [rfReplaceAll] );
889 Skin := StringReplace( Skin, '&PLAINNUMBER', No, [rfReplaceAll] );
890 Skin := StringReplace( Skin, '&NAME', Res.FName, [rfReplaceAll] );
891 Skin := StringReplace( Skin, '&MAILNAME',
892 '<a href="mailo:' + Res.FMailTo + '">' + Res.FName + '</a>', [rfReplaceAll] );
893 Skin := StringReplace( Skin, '&MAIL', Res.FMailTo, [rfReplaceAll] );
894 Skin := StringReplace( Skin, '&DATE', Res.FDateTime, [rfReplaceAll] );
895 Skin := StringReplace( Skin, '&MESSAGE', Res.FBody, [rfReplaceAll] );
896 //-----
\82±
\82±
\82Ü
\82Å
905 ShortDayNames[1] := '
\93ú'; ShortDayNames[2] := '
\8c\8e';
906 ShortDayNames[3] := '
\89Î'; ShortDayNames[4] := '
\90\85';
907 ShortDayNames[5] := '
\96Ø'; ShortDayNames[6] := '
\8bà';
908 ShortDayNames[7] := '
\93y';
909 BBSID := ThreadItem.ParentBoard.BBSID;
910 FileName := ThreadItem.FileName;
911 NewReceiveNo := ThreadItem.NewReceive;
912 FileName := ThreadItem.GetThreadFileName;
913 ReadList := TStringList.Create;
914 FAbon.Deleterlo := FSetting.AbonDeleterlo;
915 FAbon.Replaceul := FSetting.AbonReplaceul;
916 FAbon.AbonPopupRes := FSetting.PopUpAbon;
918 if ThreadItem.IsLogFile then begin
919 ReadList.LoadFromFile(FileName);
920 FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
921 FAbon.Execute(ReadList); //
\82 \82Ú
\81`
\82ñ
\82µ
\82Ä
922 FSelectResFilter.Execute(ReadList); //
\83\8c\83X
\82Ì
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\82·
\82é
923 Res := DivideStrLine(ReadList[0]);
924 Res.FTitle := StringReplace(Res.FTitle, '
\81\97\81M', ',', [rfReplaceAll]);
925 sTitle := Res.FTitle;
928 sTitle := StringReplace(ThreadItem.Title, '
\81\97\81M', ',', [rfReplaceAll]);
930 SaveList := TStringList.Create;
933 doc.charset := 'Shift_JIS';
935 CSSFileName := GetStyleSheetDir + Setting.CSSFileName;
936 SkinHeaderFileName := Setting.CSSFileName + SKIN_HEADER_FILE_NAME;
937 SkinNewResFileName := Setting.CSSFileName + SKIN_NEWRES_FILE_NAME;
938 SkinResFileName := Setting.CSSFileName + SKIN_RES_FILE_NAME;
939 SkinFooterFileName := Setting.CSSFileName + SKIN_FOOTER_FILE_NAME;
940 SkinBookmarkFileName := Setting.CSSFileName + SKIN_BOOKMARK_FILE_NAME;
941 SkinNewmarkFileName := Setting.CSSFileName + SKIN_NEWMARK_FILE_NAME;
942 if GikoSys.Setting.UseCSS and
943 (Pos(GetSkinDir, Setting.CSSFileName) > 0) and
944 FileExists( SkinHeaderFileName ) then begin
945 //
\83X
\83L
\83\93\8eg
\97p
947 //
\83X
\83L
\83\93\82Ì
\90Ý
\92è
949 SaveList.Add( LoadSkin( SkinHeaderFileName ) );
950 SkinNewRes := LoadSkin( SkinNewResFileName );
951 SkinRes := LoadSkin( SkinResFileName );
955 SaveList.Add('<div class="title"><a name="top">' + sTitle + '</a></div>');
957 for i := 0 to ReadList.Count - 1 do begin
958 if (Trim(ReadList[i]) <> '') then begin
959 No := IntToStr(i + 1);
961 Res := DivideStrLine(ReadList[i]);
962 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
964 if Res.FType = glt2chOld then begin
965 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
966 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
967 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
970 Res.FBody := AddAnchorTag(Res.FBody);
971 if Res.FName = '' then
972 Res.FName := ' ';
974 //
\90V
\92\85\83}
\81[
\83N
975 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
977 SaveList.Add( LoadSkin( SkinNewmarkFileName ) );
979 SaveList.Add( '<a name="new"></a><dt class="newmark">
\90V
\92\85\83\8c\83X <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></dt><dd style="display:none"></dd>' );
984 if NewReceiveNo <= (i + 1) then
985 //
\90V
\92\85\83\8c\83X
986 SaveList.Add( ReplaceRes( SkinNewRes ) )
988 //
\92Ê
\8fí
\82Ì
\83\8c\83X
989 SaveList.Add( ReplaceRes( SkinRes ) );
993 if ThreadItem.Kokomade = (i + 1) then
994 SaveList.Add( LoadSkin( SkinBookmarkFileName ) );
997 //if SaveList.Count > 50 then begin
1000 //Application.ProcessMessages;
1002 doc.Write(SaveList.Text);
1003 //while GikoForm.Browser.Busy do begin
1005 // Application.ProcessMessages;
1007 while (GikoForm.Browser.ReadyState <> READYSTATE_COMPLETE) and
1008 (GikoForm.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
1010 //Application.ProcessMessages;
1016 SaveList.Add('<a name="bottom"></a>');
1018 //
\83X
\83L
\83\93(
\83t
\83b
\83^)
1019 SaveList.Add( LoadSkin( SkinFooterFileName ) );
1021 doc.Write(SaveList.Text);
1023 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
1025 //CSSFileName := GetAppDir + CSS_FILE_NAME;
1026 // SaveList.Add('<html lang="ja"><head>');
1027 SaveList.Add('<html><head>');
1028 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1029 SaveList.Add('<title>' + sTitle + '</title>');
1030 SaveList.Add('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
1031 SaveList.Add('</head>');
1032 SaveList.Add('<body>');
1033 SaveList.Add('<a name="top"></a>');
1034 SaveList.Add('<div class="title">' + sTitle + '</div>');
1035 //doc.Write(SaveList.Text);
1037 //Application.ProcessMessages;
1038 for i := 0 to ReadList.Count - 1 do begin
1039 if (Trim(ReadList[i]) <> '') then begin
1040 No := IntToStr(i + 1);
1041 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1042 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>');
1044 Res := DivideStrLine(ReadList[i]);
1045 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1047 if Res.FType = glt2chOld then begin
1048 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
1049 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
1050 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
1052 //Res.FBody := StringReplace(Res.FBody, '&hearts;', '♥', [rfReplaceAll]);
1053 //Res.FBody := StringReplace(Res.FBody, '&nbsp;', ' ', [rfReplaceAll]);
1054 //Res.FBody := StringReplace(Res.FBody, '&#', '&#', [rfReplaceAll]);
1055 //Res.FBody := StringReplace(Res.FBody, '&', '&', [rfReplaceAll]);
1056 Res.FBody := AddAnchorTag(Res.FBody);
1057 if Res.FName = '' then
1058 Res.FName := ' ';
1059 if Res.FMailTo = '' then
1060 SaveList.Add('<a name="' + No + '"></a>'
1061 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span> '
1062 + '<span class="name_label">
\96¼
\91O
\81F</span> '
1063 + '<span class="name"><b>' + Res.FName + '</b></span> '
1064 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span> '
1065 + '<span class="date">' + Res.FDateTime+ '</span></div>'
1066 + '<div class="mes">' + Res.FBody + ' </div>')
1068 if GikoSys.Setting.ShowMail then
1069 SaveList.Add('<a name="' + No + '"></a>'
1070 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1071 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1072 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1073 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
1074 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1075 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1076 + '<div class="mes">' + Res.FBody + ' </div>')
1078 SaveList.Add('<a name="' + No + '"></a>'
1079 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1080 + '<span class="name_label">
\96¼
\91O
\81F </span>'
1081 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1082 + '<b>' + Res.FName + '</b></a>'
1083 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
1084 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1085 + '<div class="mes">' + Res.FBody + ' </div>');
1086 if ThreadItem.Kokomade = (i + 1) then begin
1087 SaveList.Add('<a name="koko"></a><div class="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</div>');
1090 //if SaveList.Count > 50 then begin
1091 if i = 20 then begin
1093 //Application.ProcessMessages;
1095 doc.Write(SaveList.Text);
1096 //while GikoForm.Browser.Busy do begin
1098 // Application.ProcessMessages;
1100 while (GikoForm.Browser.ReadyState <> READYSTATE_COMPLETE) and
1101 (GikoForm.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
1103 //Application.ProcessMessages;
1108 SaveList.Add('<a name="bottom"></a>');
1109 SaveList.Add('</body></html>');
1110 SaveList.Add('<a name="last"></a>');
1111 SaveList.Add('</body></html>');
1113 doc.Write(SaveList.Text);
1116 // SaveList.Add('<html lang="ja"><head>');
1117 SaveList.Add('<html><head>');
1118 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1119 SaveList.Add('<title>' + sTitle + '</title></head>');
1120 SaveList.Add('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1121 SaveList.Add('<a name="top"></a>');
1122 SaveList.Add('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1123 SaveList.Add('<dl>');
1124 doc.Write(SaveList.Text);
1126 //Application.ProcessMessages;
1127 for i := 0 to ReadList.Count - 1 do begin
1128 if (Trim(ReadList[i]) <> '') then begin
1129 No := IntToStr(i + 1);
1131 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1132 SaveList.Add('</dl>');
1133 SaveList.Add('<a name="new"></a>');
1134 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>');
1135 SaveList.Add('<dl>');
1137 Res := DivideStrLine(ReadList[i]);
1138 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1139 if Res.FType = glt2chOld then begin
1140 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
1141 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
1142 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
1144 //Res.FBody := StringReplace(Res.FBody, '&hearts;', '♥', [rfReplaceAll]);
1145 //Res.FBody := StringReplace(Res.FBody, '&nbsp;', ' ', [rfReplaceAll]);
1146 //Res.FBody := StringReplace(Res.FBody, '&#', '&#', [rfReplaceAll]);
1147 //Res.FBody := StringReplace(Res.FBody, '&', '&', [rfReplaceAll]);
1148 Res.FBody := AddAnchorTag(Res.FBody);
1149 if Res.FMailTo = '' then
1150 SaveList.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a>
\96¼
\91O
\81F<font color="forestgreen"><b> ' + Res.FName + ' </b></font>
\93\8a\8de
\93ú
\81F ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>')
1152 if GikoSys.Setting.ShowMail then
1153 SaveList.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a>
\96¼
\91O
\81F<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> [' + Res.FMailTo + ']
\93\8a\8de
\93ú
\81F ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>')
1155 SaveList.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a>
\96¼
\91O
\81F<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a>
\93\8a\8de
\93ú
\81F ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>');
1156 if ThreadItem.Kokomade = (i + 1) then begin
1157 SaveList.Add('</dl>');
1158 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>');
1159 SaveList.Add('<dl>');
1162 if SaveList.Count > 50 then begin
1163 doc.Write(SaveList.Text);
1165 //Application.ProcessMessages;
1168 SaveList.Add('</dl>');
1169 SaveList.Add('<a name="bottom"></a>');
1170 SaveList.Add('</body></html>');
1171 doc.Write(SaveList.Text);
1182 (*************************************************************************
1183 *http://
\82Ì
\95¶
\8e\9a\97ñ
\82ðanchor
\83^
\83O
\95t
\82«
\82É
\82·
\82é
\81B
1184 *************************************************************************)
1185 function TGikoSys.AddAnchorTag(s: string): string;
1187 URL_CHAR: string = '0123456789'
1188 + 'abcdefghijklmnopqrstuvwxyz'
1189 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1190 + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
1192 wkIdx: array[0..9] of Integer;
1201 wkIdx[0] := AnsiPos('http://', s);
1202 wkIdx[1] := AnsiPos('ttp://', s);
1203 wkIdx[2] := AnsiPos('tp://', s);
1204 wkIdx[3] := AnsiPos('ms-help://', s);
1205 wkIdx[4] := AnsiPos('p://', s);
1206 wkIdx[5] := AnsiPos('https://', s);
1207 wkIdx[6] := AnsiPos('www.', s);
1208 wkIdx[7] := AnsiPos('ftp://', s);
1209 wkIdx[8] := AnsiPos('news://', s);
1210 wkIdx[9] := AnsiPos('rtsp://', s);
1214 if wkIdx[i] <> 0 then idx := Min(wkIdx[i], idx);
1216 if idx = MaxInt then begin
1217 //
\83\8a\83\93\83N
\82ª
\96³
\82¢
\82æ
\81B
1218 Result := Result + s;
1222 if (idx > 1) and (Copy(s, idx - 1, 1) = '"') then begin
1223 //
\8aù
\82É
\83\8a\83\93\83N
\83^
\83O
\82ª
\82Â
\82¢
\82Ä
\82¢
\82é
\82Á
\82Û
\82¢
\82Æ
\82«
\82Í
\83\80\83V
1224 Result := Result + Copy(s, 0, idx + Length('http://') - 1);
1225 s := Copy(s, idx + Length('http://'), length(s));
1229 Result := Result + Copy(s, 0, idx - 1);
1231 s := Copy(s, idx, length(s));
1233 for i := 0 to Length(s) do begin
1234 idx := AnsiPos(s[i + 1], URL_CHAR);
1235 if (idx = 0) or (i = (Length(s))) then begin
1236 //URL
\82¶
\82á
\82È
\82¢
\95¶
\8e\9a\94
\8c©
\81I
\82Æ
\82©
\81A
\95¶
\8e\9a\82ª
\82È
\82
\82È
\82Á
\82½
\81B
1237 url := Copy(s, 0, i);
1239 if AnsiPos('ttp://', url) = 1 then
1241 else if AnsiPos('tp://', url) = 1 then
1243 else if AnsiPos('p://', url) = 1 then
1245 else if AnsiPos('www.', url) = 1 then
1246 href := 'http://' + url
1249 Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
1250 s := Copy(s, i + 1, Length(s));
1257 (*************************************************************************
1258 *
\83T
\83u
\83W
\83F
\83N
\83g
\88ê
\8ds
\82ð
\95ª
\8a\84
1259 *************************************************************************)
1260 function TGikoSys.DivideSubject(Line: string): TSubjectRec;
1270 if Pos('<>', Line) = 0 then
1275 Result.FFileName := GetTokenIndex(Line, Delim, 0);
1276 Result.FTitle := GetTokenIndex(Line, Delim, 1);
1278 ws := Trim(Result.FTitle);
1280 if Copy(ws, Length(ws), 1) = ')' then begin
1283 end else if Copy(ws, Length(ws), 1) = '
\81j' then begin
1286 end else if Copy(ws, Length(ws), 1) = '<' then begin
1291 for i := Length(ws) - 1 downto 1 do begin
1292 if ws[i] = LeftK then begin
1293 ws := Copy(ws, i + 1, Length(ws) - i - 1);
1294 if IsNumeric(ws) then
1295 Result.FCount := StrToInt(ws);
1296 Result.FTitle := Trim(StringReplace(Result.FTitle, LeftK + ws + RightK, '', [rfReplaceAll]));
1302 (*************************************************************************
1303 * dat
\83t
\83@
\83C
\83\8b\82Ì
\88ê
\83\89\83C
\83\93\82ð
\95ª
\89ð
1304 *************************************************************************)
1305 function TGikoSys.DivideStrLine(Line: string): TResRec;
1310 if Pos('<>', Line) = 0 then begin
1312 Result.FType := glt2chOld;
1315 Result.FType := glt2chNew;
1317 Result.FName := Trim(GetTokenIndex(Line, Delim, 0));
1318 Result.FMailTo := Trim(GetTokenIndex(Line, Delim, 1));
1319 Result.FDateTime := Trim(GetTokenIndex(Line, Delim, 2));
1320 bufBody := Trim(GetTokenIndex(Line, Delim, 3));
1321 if bufbody = '' then begin
1322 Insert(' ',bufbody, 1);
1324 Result.FBody := bufBody;
1325 Result.FTitle := Trim(GetTokenIndex(Line, Delim, 4));
1329 (*************************************************************************
1330 * URL
\82©
\82çBBSID
\82ð
\8eæ
\93¾
1331 *************************************************************************)
1332 function TGikoSys.UrlToID(url: string): string;
1339 if url = '' then Exit;
1341 url := Copy(url, 0, Length(url) - 1);
1342 for i := Length(url) downto 0 do begin
1343 if url[i] = '/' then begin
1344 Result := Copy(url, i + 1, Length(url));
1350 (*************************************************************************
1351 *URL
\82©
\82çBBSID
\88È
\8aO
\82Ì
\95\94\95ª(http://teri.2ch.net/)
\82ð
\8eæ
\93¾
1352 *************************************************************************)
1353 function TGikoSys.UrlToServer(url: string): string;
1360 wsURL := Trim(wsURL);
1362 if wsURL = '' then exit;
1364 if Copy(wsURL, Length(wsURL), 1) = '/' then
1365 wsURL := Copy(wsURL, 0, Length(wsURL) - 1);
1367 for i := Length(wsURL) downto 0 do begin
1368 if wsURL[i] = '/' then begin
1369 Result := Copy(wsURL, 0, i);
1375 (*************************************************************************
1376 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ª
\91¶
\8dÝ
\82·
\82é
\82©
\83`
\83F
\83b
\83N
1377 *************************************************************************)
1378 function TGikoSys.DirectoryExistsEx(const Name: string): Boolean;
1382 Code := GetFileAttributes(PChar(Name));
1383 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
1386 (*************************************************************************
1387 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\8dì
\90¬
\81i
\95¡
\90\94\8aK
\91w
\91Î
\89\9e\81j
1388 *************************************************************************)
1389 function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean;
1392 if Length(Dir) = 0 then
1393 raise Exception.Create('
\83t
\83H
\83\8b\83_
\82ª
\8dì
\90¬
\8fo
\97\88\82Ü
\82¹
\82ñ');
1394 Dir := ExcludeTrailingPathDelimiter(Dir);
1395 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
1396 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
1397 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
1400 (*************************************************************************
1401 *
\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
1402 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1403 *************************************************************************)
1404 function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1408 Result := StrTokNext(sep, Rec);
1411 (*************************************************************************
1412 *
\95¶
\8e\9a\97ñ
\82©
\82ç
\83g
\81[
\83N
\83\93\82Ì
\90Ø
\82è
\8fo
\82µ
1413 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1414 *************************************************************************)
1415 function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1422 if Len >= Pos then begin
1423 while (Pos <= Len) and (Str[Pos] in sep) do begin
1427 while (Pos<= Len) and not (Str[Pos] in sep) do begin
1428 if IsDBCSLeadByte(Byte(Str[Pos])) then begin
1433 Result := Copy(Str, I, Pos - I);
1434 while (Pos <= Len) and (Str[Pos] in sep) do begin//
\82±
\82ê
\82Í
\82¨
\8dD
\82Ý
1441 (*************************************************************************
1442 *
\83t
\83@
\83C
\83\8b\83T
\83C
\83Y
\8eæ
\93¾
1443 *************************************************************************)
1444 function TGikoSys.GetFileSize(FileName : string): longint;
1449 if not FileExists(FileName) then begin
1453 Assign(F, FileName);
1455 Result := FileSize(F);
1462 (*************************************************************************
1463 *
\83t
\83@
\83C
\83\8b\8ds
\90\94\8eæ
\93¾
1464 *************************************************************************)
1465 function TGikoSys.GetFileLineCount(FileName : string): longint;
1469 sl := TStringList.Create;
1472 sl.LoadFromFile(FileName);
1483 (*************************************************************************
1484 *
\83X
\83\8c\83b
\83h
\83t
\83@
\83C
\83\8b\82©
\82ç
\8ew
\92è
\8ds
\82ð
\8eæ
\93¾
1485 *************************************************************************)
1486 function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string;
1493 ArrBuff: array [1..BUFFER_SIZE] of Char;
1496 if FileExists(FileName) then begin
1497 AssignFile(f, FileName);
1498 System.SetTextBuf(f, ArrBuff);
1502 while not Eof(f) do begin
1504 if Line = num then begin
1517 (*************************************************************************
1518 *
\83V
\83X
\83e
\83\80\83\81\83j
\83\85\81[
\83t
\83H
\83\93\83g
\82Ì
\91®
\90«
\82ð
\8eæ
\93¾
1519 *************************************************************************)
1520 procedure TGikoSys.MenuFont(Font: TFont);
1523 nm: NONCLIENTMETRICS;
1525 nm.cbSize := sizeof(NONCLIENTMETRICS);
1527 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0);
1528 lf := nm.lfMenuFont;
1530 Font.Name := lf.lfFaceName;
1531 Font.Height := lf.lfHeight;
1533 if lf.lfWeight >= 700 then
1534 Font.Style := Font.Style + [fsBold];
1535 if lf.lfItalic = 1 then
1536 Font.Style := Font.Style + [fsItalic];
1539 (*************************************************************************
1541 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1542 *************************************************************************)
1543 function TGikoSys.RemoveToken(var s: string; delimiter: string): string;
1547 p := AnsiPos(delimiter, s);
1551 Result := Copy(s, 1, p - 1);
1552 s := Copy(s, Length(Result) + Length(delimiter) + 1, Length(s));
1555 (*************************************************************************
1557 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1558 *************************************************************************)
1559 function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string;
1564 for i := 0 to index do
1565 Result := RemoveToken(s, delimiter);
1568 (*************************************************************************
1570 *************************************************************************)
1571 function TGikoSys.DeleteLink(const s: string): string;
1581 s1 := GetTokenIndex(s, '<a href="', i);
1582 s2 := GetTokenIndex(s, '<a href="', i + 1);
1584 idx := Pos('">', s1);
1586 Delete(s1, 1, idx + 1);
1587 idx := Pos('">', s2);
1589 Delete(s2, 1, idx + 1);
1591 Result := Result + s1 + s2;
1600 //
\83C
\83\93\83f
\83b
\83N
\83X
\96¢
\8dX
\90V
\83o
\83b
\83t
\83@
\82ð
\83t
\83\89\83b
\83V
\83\85\81I
1601 {procedure TGikoSys.FlashExitWrite;
1605 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
1606 for i := 0 to FExitWrite.Count - 1 do
1607 WriteThreadDat(FExitWrite[i]);
1611 (*************************************************************************
1612 *
\83X
\83\8c\96¼
\82È
\82Ç
\82ð
\92Z
\82¢
\96¼
\91O
\82É
\95Ï
\8a·
\82·
\82é
1614 *************************************************************************)
1615 function TGikoSys.GetShortName(const LongName: string; ALength: integer): string;
1617 ERASECHAR : array [1..39] of string =
1618 ('
\81\99','
\81\9a','
\81¡','
\81 ','
\81\9f','
\81\9e','
\81Q','
\81\94','
\81£','
\81¥',
1619 '
\81¢','
\81¤','
\81\9c','
\81\9b','
\81\9d','
\81y','
\81z','
\81ô','
\81s','
\81t',
1620 '
\81g','
\81h','
\81k','
\81l','
\81e','
\81f','
\81\83','
\81\84','
\81á','
\81â',
1621 '
\81o','
\81p','
\81q','
\81r','
\81w','
\81x','
\81¬','
\81c', '
\81@');
1623 Chr : array [0..255] of char;
1627 s := Trim(LongName);
1628 if (Length(s) <= ALength) then begin
1632 for i := Low(ERASECHAR) to High(ERASECHAR) do begin
1633 S := StringReplace(S, ERASECHAR[i], '', [rfReplaceAll]);
1635 if (Length(S) <= ALength) then begin
1638 Windows.LCMapString(
1639 GetUserDefaultLCID(),
1647 S := Copy(S,1,ALength);
1649 if (ByteType(S, Length(S)) = mbLeadByte ) then begin
1650 S := Copy(S, 1, Length(S) - 1);
1660 (*************************************************************************
1663 *************************************************************************)
1664 function TGikoSys.ConvRes(const Body, Bbs, Key,
1665 ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
1669 FIndexFrom : integer;
1676 ZN = '
\82O
\82P
\82Q
\82R
\82S
\82T
\82U
\82V
\82W
\82X
\81|';
1690 procedure Add(IndexFrom, IndexTo: integer; const No: string);
1695 FIndex.FIndexFrom := IndexFrom;
1696 FIndex.FIndexTo := IndexTo;
1700 function ChooseString(const Text, Separator: string; Index: integer): string;
1706 for i := 0 to Index - 1 do begin
1707 if (AnsiPos(Separator, S) = 0) then S := ''
1708 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
1710 p := AnsiPos(Separator, S);
1711 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
1720 List:= TList.Create;
1726 b := ByteType(s, i);
1728 mbSingleByte : begin
1729 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1730 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1738 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1739 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
1745 if (not sw) and (Copy(s,i,4) = GT) then begin
1746 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1754 if ((not sw) and (Copy(s,i,1) = ',')) or
1755 ((not sw) and (Copy(s,i,1) = '=')) then begin
1756 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
1757 ((Chk) and (oc = '')) or
1758 ((not Chk) and (al)) then
1768 if (AnsiPos(sx, SN) > 0) then begin
1771 if (No <> '') and (No <> '-') then begin
1784 if Copy(s,i,1) = '<' then oc := '';
1785 oc := oc + Copy(s,i,1);
1791 if (not sw) and (Copy(s,i,4) = '
\81\84\81\84') then begin
1797 if (not sw) and (Copy(s,i,2) = '
\81\84') then begin
1805 if (AnsiPos(sx, ZN) > 0) then begin
1806 No := No + ZenToHan(sx);
1808 if (No <> '') and (No <> '-') and (No <> '
\81|') then begin
1823 if (i > Length(Body)) then begin
1825 if (No <> '') then Add(sp, i, No);
1830 for i := List.Count - 1 downto 0 do begin
1831 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
1832 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
1833 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
1835 st := PIndex(List[i]).FNo;
1836 et := PIndex(List[i]).FNo;
1838 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
1839 Format('<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">',
1840 [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
1841 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
1842 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
1843 Dispose(PIndex(List[i]));
1849 (*************************************************************************
1850 *
\91S
\8ap
\81¨
\94¼
\8ap
1852 *************************************************************************)
1853 function TGikoSys.ZenToHan(const s: string): string;
1855 Chr: array [0..255] of char;
1857 Windows.LCMapString(
1858 GetUserDefaultLCID(),
1860 LCMAP_HALFWIDTH or LCMAP_KATAKANA or LCMAP_LOWERCASE,
1869 (*************************************************************************
1870 *
\91S
\8ap
\94¼
\8ap
\82Ð
\82ç
\82ª
\82È
\82©
\82½
\82©
\82È
\82ð
\8bæ
\95Ê
\82µ
\82È
\82¢
\90¦
\82¢Pos
1871 *************************************************************************)
1872 function TGikoSys.VaguePos(const Substr, S: string): Integer;
1874 Result := Pos(ZenToHan(Substr), ZenToHan(S));
1877 function TGikoSys.BoolToInt(b: Boolean): Integer;
1879 Result := IfThen(b, 1, 0);
1882 function TGikoSys.IntToBool(i: Integer): Boolean;
1887 //gzip
\82Å
\88³
\8fk
\82³
\82ê
\82½
\82Ì
\82ð
\96ß
\82·
1888 function TGikoSys.GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
1892 GZipStream: TGzipDecompressStream;
1893 TextStream: TStringStream;
1894 buf: array[0..BUF_SIZE - 1] of Byte;
1900 TextStream := TStringStream.Create('');
1902 //
\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¢)
1903 // if LowerCase(Trim(ContentEncoding)) = 'gzip' then begin
1904 if AnsiPos('gzip', LowerCase(Trim(ContentEncoding))) > 0 then begin
1905 ResStream.Position := 0;
1906 GZipStream := TGzipDecompressStream.Create(TextStream);
1909 FillChar(buf, BUF_SIZE, 0);
1910 cnt := ResStream.Read(buf, BUF_SIZE);
1912 GZipStream.Write(buf, BUF_SIZE);
1918 ResStream.Position := 0;
1920 FillChar(buf, BUF_SIZE, 0);
1921 cnt := ResStream.Read(buf, BUF_SIZE);
1923 TextStream.Write(buf, BUF_SIZE);
1927 //NULL
\95¶
\8e\9a\82ð"*"
\82É
\82·
\82é
1928 s := TextStream.DataString;
1930 while (i > 0) and (s[i] = #0) do
1935 while i <> 0 do begin
1945 procedure TGikoSys.LoadKeySetting(ActionList: TActionList);
1947 STD_SEC = 'KeySetting';
1953 SecList: TStringList;
1954 Component: TComponent;
1956 if not FileExists(GetConfigDir + KEY_SETTING_FILE_NAME) then
1958 SecList := TStringList.Create;
1959 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
1961 ini.ReadSection(STD_SEC, SecList);
1962 for i := 0 to SecList.Count - 1 do begin
1963 ActionName := SecList[i];
1964 ActionKey := ini.ReadInteger(STD_SEC, ActionName, -1);
1965 if ActionKey <> -1 then begin
1966 Component := ActionList.Owner.FindComponent(ActionName);
1967 if TObject(Component) is TAction then begin
1968 TAction(Component).ShortCut := ActionKey;
1978 procedure TGikoSys.SaveKeySetting(ActionList: TActionList);
1980 STD_SEC = 'KeySetting';
1985 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
1987 for i := 0 to ActionList.ActionCount - 1 do begin
1988 if ActionList.Actions[i].Tag = -1 then
1990 ini.WriteInteger(STD_SEC, ActionList.Actions[i].Name, TAction(ActionList.Actions[i]).ShortCut);
1999 procedure TGikoSys.CreateProcess(const AppPath: string; const Param: string);
2001 PI: TProcessInformation;
2005 Path := '"' + AppPath + '"';
2007 Path := Path + ' ' + Param;
2009 SI.Cb := SizeOf(Si);
2010 SI.lpReserved := nil;
2011 SI.lpDesktop := nil;
2014 SI.cbReserved2 := 0;
2015 SI.lpReserved2 := nil;
2017 Windows.CreateProcess(nil,
2029 procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
2033 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2034 gbtUserApp, gbtAuto:
2035 if (Setting.URLApp) and (FileExists(Setting.URLAppFile)) then
2036 GikoSys.CreateProcess(Setting.URLAppFile, URL)
2038 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2042 function TGikoSys.HTMLDecode(const AStr: String): String;
2044 Sp, Rp, Cp, Tp: PChar;
2049 SetLength(Result, Length(AStr));
2051 Rp := PChar(Result);
2054 while Sp^ <> #0 do begin
2060 'a': if AnsiStrPos(Sp, 'amp;') = Sp then
2066 'g': if (AnsiStrPos(Sp, 'lt;') = Sp) or (AnsiStrPos(Sp, 'gt;') = Sp) then
2070 while (Sp^ <> ';') and (Sp^ <> #0) do
2077 'q': if AnsiStrPos(Sp, 'quot;') = Sp then
2085 Num := IsNumeric(Copy(Tp, 1, 1));
2086 while (Sp^ <> ';') and (Sp^ <> #0) do begin
2087 if (Num) and (not IsNumeric(Copy(Sp, 1, 1))) then
2091 SetString(S, Tp, Sp - Tp);
2096 //raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2097 //[Cp^ + Sp^, Cp - PChar(AStr)])
2107 // on E:EConvertError do
2108 // raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2109 // [Cp^ + Sp^, Cp - PChar(AStr)])
2111 SetLength(Result, Rp - PChar(Result));
2114 function TGikoSys.GetHRefText(s: string): string;
2124 Index := AnsiPos('href', LowerCase(s));
2127 s := Trim(Copy(s, Index + 4, Length(s)));
2128 s := Trim(Copy(s, 2, Length(s)));
2130 //
\8en
\82ß
\82Ì
\95¶
\8e\9a\82ª'"'
\82È
\82ç
\8eæ
\82è
\8f\9c\82
2131 if Copy(s, 1, 1) = '"' then begin
2132 s := Trim(Copy(s, 2, Length(s)));
2135 Index := AnsiPos('"', s);
2136 if Index <> 0 then begin
2137 //'"'
\82Ü
\82ÅURL
\82Æ
\82·
\82é
2138 s := Copy(s, 1, Index - 1);
2140 //'"'
\82ª
\96³
\82¯
\82ê
\82Î
\83X
\83y
\81[
\83X
\82©">"
\82Ì
\91\81\82¢
\95û
\82Ü
\82Å
\82ðURL
\82Æ
\82·
\82é
2141 Index := AnsiPos(' ', s);
2142 Index2 := AnsiPos('>', s);
2145 if Index > Index2 then
2148 s := Copy(s, 1, Index - 1)
2150 //
\82±
\82ê
\88È
\8fã
\82à
\82¤
\92m
\82ç
\82ñ
\82Ê
2156 //
\83z
\83X
\83g
\96¼
\82ª
\82Q
\82\83\82\88\82©
\82Ç
\82¤
\82©
\83`
\83F
\83b
\83N
\82·
\82é
2157 function TGikoSys.Is2chHost(Host: string): Boolean;
2159 HOST_NAME: array[0..1] of string = ('2ch.net', 'bbspink.com');
2165 OutputDebugString(pchar(HOST_NAME[0]));
2166 for i := 0 to Length(HOST_NAME) - 1 do begin
2167 // Len := Length(HOST_NAME[i]);
2168 if AnsiPos(HOST_NAME[i], Host) = (Length(Host) - Length(HOST_NAME[i]) + 1) then begin
2175 function TGikoSys.Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
2177 READ_PATH: string = '/test/read.cgi/';
2178 OLD_READ_PATH: string = '/test/read.cgi?';
2179 KAKO_PATH: string = '/kako/';
2189 Index := AnsiPos(READ_PATH, path);
2190 if Index <> 0 then begin
2191 s := Copy(path, Length(READ_PATH) + 1, Length(path));
2192 BBSID := GetTokenIndex(s, '/', 0);
2193 BBSKey := GetTokenIndex(s, '/', 1);
2196 Result := (BBSID <> '') or (BBSKey <> '');
2199 Index := AnsiPos(KAKO_PATH, path);
2200 if Index <> 0 then begin
2201 s := Copy(path, 2, Length(path));
2202 BBSID := GetTokenIndex(s, '/', 0);
2203 if (BBSID = 'log') and (GetTokenIndex(s, '/', 2) = 'kako') then
2204 BBSID := GetTokenIndex(s, '/', 1);
2205 BBSKey := ChangeFileExt(Document, '');
2206 Result := (BBSID <> '') or (BBSKey <> '');
2209 Index := AnsiPos('read.cgi?', URL);
2210 if Index <> 0 then begin
2211 SList := TStringList.Create;
2214 // s := HTMLDecode(Document);
2215 ExtractHTTPFields(['?', '&'], [], PChar(URL), SList, False);
2216 BBSID := SList.Values['bbs'];
2217 BBSKey := SList.Values['key'];
2218 Result := (BBSID <> '') or (BBSKey <> '');
2229 function TGikoSys.Parse2chURL2(URL: string): TPathRec;
2241 URL := Trim(LowerCase(URL));
2246 Result.FFirst := False;
2247 Result.FStBegin := False;
2248 Result.FToEnd := False;
2249 Result.FDone := False;
2254 FAWKStr.RegExp := 'http://.+\.(2ch\.net|bbspink\.com)/';
2255 if FAWKStr.Match(FAWKStr.ProcessEscSeq(URL), RStart, RLength) = 0 then
2257 s := Copy(URL, RStart + RLength - 1, Length(URL));
2259 //
\95W
\8f\80\8f\91\8e®
2260 //
\8dÅ
\8cã
\82Íl50, 10, 10-20, 10n, 10-20n, -10, 10-, 10n-
\82È
\82Ç
2261 //http://xxx.2ch.net/test/read.cgi/bbsid/1000000000/
2262 FAWKStr.RegExp := '/test/read.cgi/.+/[0-9]+/.*';
2263 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2264 s := Copy(s, 15, Length(s));
2266 SList := TStringList.Create;
2269 FAWKStr.RegExp := '/';
2270 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2271 Result.FBBS := SList[1];
2272 Result.FKey := SList[2];
2273 if SList.Count >= 3 then
2281 FAWKStr.LineSeparator := mcls_CRLF;
2282 FAWKStr.RegExp := '-';
2283 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) = 0 then begin
2284 Result.FFirst := True;
2286 FAWKStr.RegExp := 'l[0-9]+';
2287 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2288 Result.FFirst := True;
2290 for i := 0 to SList.Count - 1 do begin
2291 if Trim(SList[i]) = '' then begin
2293 Result.FStBegin := True;
2294 if i = (SList.Count - 1) then
2295 Result.FToEnd := True;
2296 end else if IsNumeric(SList[i]) then begin
2297 wkInt := StrToInt(SList[i]);
2298 wkMax := Max(wkMax, wkInt);
2302 wkMin := Min(wkMin, wkInt);
2303 end else if Trim(SList[i]) = 'n' then begin
2304 Result.FFirst := True;
2306 FAWKStr.RegExp := '^n[0-9]+$|^[0-9]+n$';
2307 if FAWKStr.Match(FAWKStr.ProcessEscSeq(SList[i]), RStart, RLength) > 0 then begin
2308 if Copy(SList[i], 1, 1) = 'n' then
2309 wkInt := StrToInt(Copy(SList[i], 2, Length(SList[i])))
2311 wkInt := StrToInt(Copy(SList[i], 1, Length(SList[i]) - 1));
2312 Result.FFirst := True;
2313 wkMax := Max(wkMax, wkInt);
2317 wkMin := Min(wkMin, wkInt);
2321 if Result.FStBegin and (not Result.FToEnd) then
2323 else if (not Result.FStBegin) and Result.FToEnd then
2325 else if (not Result.FStBegin) and (not Result.FToEnd) then begin
2326 Result.FSt := wkMin;
2327 Result.FTo := wkMax;
2329 //Result.FSt := wkMin;
2330 //Result.FTo := wkMax;
2336 Result.FDone := True;
2340 //
\90Vkako
\8f\91\8e®
2341 //http://server.2ch.net/ITA_NAME/kako/1000/10000/1000000000.html
2342 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+/[0-9]+\.html';
2343 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2344 SList := TStringList.Create;
2347 FAWKStr.RegExp := '/';
2348 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2349 Result.FBBS := SList[1];
2350 Result.FKey := ChangeFileExt(SList[5], '');
2351 Result.FFirst := True;
2357 Result.FDone := True;
2361 //
\8b\8ckako
\8f\91\8e®
2362 //http://server.2ch.net/ITA_NAME/kako/999/999999999.html
2363 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+\.html';
2364 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2365 SList := TStringList.Create;
2368 FAWKStr.RegExp := '/';
2369 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 5 then begin
2370 Result.FBBS := SList[1];
2371 Result.FKey := ChangeFileExt(SList[4], '');
2372 Result.FFirst := True;
2378 Result.FDone := True;
2382 //log
\8by
\82Ñlog2
\8f\91\8e®
2383 //http://server.2ch.net/log/ITA_NAME/kako/999/999999999.html
2384 //http://server.2ch.net/log2/ITA_NAME/kako/999/999999999.html
2385 FAWKStr.RegExp := '/log2?/.+/kako/[0-9]+/[0-9]+\.html';
2386 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2387 SList := TStringList.Create;
2390 FAWKStr.RegExp := '/';
2391 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2392 Result.FBBS := SList[2];
2393 Result.FKey := ChangeFileExt(SList[5], '');
2394 Result.FFirst := True;
2400 Result.FDone := True;
2405 //
\8b\8cURL
\8f\91\8e®
2406 //http://server.2ch.net/test/read.cgi?bbs=ITA_NAME&key=1000000000&st=1&to=5&nofirst=true
2407 FAWKStr.RegExp := '/test/read\.cgi\?';
2408 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2409 s := Copy(s, 16, Length(s));
2410 SList := TStringList.Create;
2413 FAWKStr.RegExp := '&';
2414 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2415 Result.FFirst := True;
2416 for i := 0 to SList.Count - 1 do begin
2417 if Pos('bbs=', SList[i]) = 1 then begin
2418 Result.FBBS := Copy(SList[i], 5, Length(SList[i]));
2419 end else if Pos('key=', SList[i]) = 1 then begin
2420 Result.FKey := Copy(SList[i], 5, Length(SList[i]));
2421 end else if Pos('st=', SList[i]) = 1 then begin
2422 wk := Copy(SList[i], 4, Length(SList[i]));
2423 if IsNumeric(wk) then
2424 Result.FSt := StrToInt(wk)
2425 else if wk = '' then
2426 Result.FStBegin := True;
2427 end else if Pos('to=', SList[i]) = 1 then begin
2428 wk := Copy(SList[i], 4, Length(SList[i]));
2429 if IsNumeric(wk) then
2430 Result.FTo := StrToInt(wk)
2431 else if wk = '' then
2432 Result.FToEnd := True;
2433 end else if Pos('nofirst=', SList[i]) = 1 then begin
2434 Result.FFirst := False;
2443 if (Result.FBBS <> '') and (Result.FKey <> '') then begin
2444 Result.FDone := True;
2450 procedure TGikoSys.ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
2460 URI := TIdURI.Create(URL);
2462 Protocol := URI.Protocol;
2465 Document := URI.Document;
2467 Bookmark := URI.Bookmark;
2473 function TGikoSys.GetVersionBuild: Integer;
2475 FixedFileInfo: PVSFixedFileInfo;
2476 VersionHandle, VersionSize: DWORD;
2477 pVersionInfo: Pointer;
2482 AppFile := Application.ExeName;
2483 VersionSize := GetFileVersionInfoSize(pChar(AppFile), VersionHandle);
2484 if VersionSize = 0 then
2486 GetMem(pVersionInfo, VersionSize);
2488 if GetFileVersionInfo(PChar(AppFile),VersionHandle,VersionSize, pVersionInfo) then
2489 if VerQueryValue(pVersionInfo, '\', Pointer(FixedFileInfo), ItemLen) then
2490 Result := LOWORD(FixedFileInfo^.dwFileVersionLS);
2492 FreeMem(pVersionInfo, VersionSize);
2497 GikoSys := TGikoSys.Create;
2500 if GikoSys <> nil then begin