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;
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;
96 destructor Destroy; override;
98 // function MsgBox(Msg: string; Title: string; Flags: Longint): integer; overload;
99 // function MsgBox(Handle: THandle; Msg: string; Title: string; Flags: Longint): integer; overload;
100 function IsNumeric(s: string): boolean;
101 function IsFloat(s: string): boolean;
102 function DirectoryExistsEx(const Name: string): Boolean;
103 function ForceDirectoriesEx(Dir: string): Boolean;
104 // function GetVersion: string;
106 function GetBoardFileName: string;
107 function GetCustomBoardFileName: string;
108 // function GetSubjectFileName(BBSID: string): string;
109 // function GetThreadFileName(BBSID: string; FileName: string): string;
110 // function GetThreadDatFileName(BBSID: string): string;
111 function GetHtmlTempFileName: string;
112 // function GetLogDir: string;
113 function GetAppDir: string;
114 // function GetTempFileName: string;
115 function GetTempFolder: string;
116 function GetSentFileName: string;
117 function GetConfigDir: string;
118 function GetStyleSheetDir: string;
119 function GetOutBoxFileName: string;
120 function GetURL(BBSID: string; FileName: string): string;
121 function GetUserAgent: string;
123 // function GetRootNodeName: string;
125 procedure ReadSubjectFile(Board: TBoard);
126 procedure CreateThreadDat(Board: TBoard);
127 procedure WriteThreadDat(Board: TBoard);
128 function ParseIndexLine(Line: string): TIndexRec;
129 // procedure ReNewThreadDat(FileName: string; Ver: Double);
130 // procedure GetFileList(Path: string; FileList: TStringList);
131 procedure GetFileList(Path: string; Mask: string; List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
133 // function CreateHTML(ThreadItem: TThreadItem; var sTitle: string): string;
134 procedure CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
135 function AddAnchorTag(s: string): string;
137 function DivideSubject(Line: string): TSubjectRec;
138 function DivideStrLine(Line: string): TResRec;
140 property Setting: TSetting read FSetting write FSetting;
141 property Dolib: TDolib read FDolib write FDolib;
143 function UrlToID(url: string): string;
144 function UrlToServer(url: string): string;
146 function StrTokFirst(const s:string; const sep:TStrTokSeparator; var Rec:TStrTokRec):string;
147 function StrTokNext(const sep:TStrTokSeparator; var Rec:TStrTokRec): string;
149 function GetFileSize(FileName : string) : longint;
150 function GetFileLineCount(FileName : string): longint;
151 function Get2chDate(aDate: TDateTime): string;
152 function IntToDateTime(val: Int64): TDateTime;
153 function DateTimeToInt(ADate: TDateTime): Integer;
155 function ReadThreadFile(FileName: string; Line: Integer): string;
157 procedure MenuFont(Font: TFont);
159 function RemoveToken(var s:string;delimiter:string):string;
160 function GetTokenIndex(s: string; delimiter: string; index: Integer): string;
162 function DeleteLink(const s: string): string;
164 // procedure FlashExitWrite;
165 function GetShortName(const LongName: string; ALength: integer): string;
166 // function ConvRes(const Body, Bbs, Key: string): string;
167 function ConvRes(const Body, Bbs, Key, ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
169 function ZenToHan(const s: string): string;
170 function VaguePos(const Substr, S: string): Integer;
171 function BoolToInt(b: Boolean): Integer;
172 function IntToBool(i: Integer): Boolean;
173 function GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
174 procedure LoadKeySetting(ActionList: TActionList);
175 procedure SaveKeySetting(ActionList: TActionList);
176 procedure CreateProcess(const AppPath: string; const Param: string);
177 procedure OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
178 function HTMLDecode(const AStr: String): String;
179 function GetHRefText(s: string): string;
180 function Is2chHost(Host: string): Boolean;
181 function Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
182 function Parse2chURL2(URL: string): TPathRec;
183 procedure ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
184 function GetVersionBuild: Integer;
190 LENGTH_RESTITLE = 40;
191 ZERO_DATE: Integer = 25569;
192 // MAJOR_VERSION = 1;
193 // MINOR_VERSION = 0;
194 BETA_VERSION_NAME_E = 'theta';
195 BETA_VERSION_NAME_J = '¼¨(ß
\81[ß*)ÀÞ¯º
\81ô';
197 // BETA_VERSION_NAME_E = 'beta';
198 // BETA_VERSION_NAME_J = 'ÊÞÀ';
199 // BETA_VERSION = 33;
200 BETA_VERSION_BUILD = '';
201 // BETA_VERSION_BUILD = 'Debug2';
204 // VERSION_TYPE = 'ÊÞÀ 7';
205 // VERSION: string = '1.00';
206 // VERSION_TYPE: string = 'Test 12/13';
207 // VERSION_TYPE: string = 'ÊÞÀ 7';
208 // USER_AGENT: string = 'Mozilla/3.0 (compatible; gikoNavi)';
209 // USER_AGENT: string = 'Mozilla/1.0 (compatible; gikoNavi)';
216 BOARD_FILE_NAME = 'board.2ch';
217 CUSTOMBOARD_FILE_NAME = 'custom.2ch';
218 KEY_SETTING_FILE_NAME = 'key.ini';
219 TEMP_FOLDER = 'Temp';
220 OUTBOX_FILE_NAME = 'outbox.ini';
221 SENT_FILE_NAME = 'sent.ini';
222 CONFIG_DIR_NAME = 'config';
223 CSS_DIR_NAME = 'css';
224 //CSS_FILE_NAME = 'gikoNavi.css';
225 FOLDER_INDEX_VERSION = '1.01';
226 USER_AGENT = 'Monazilla';
227 APP_NAME = 'gikoNavi';
229 // TITLE_NAME: string = '
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é';
230 // ROOT_NODE_NAME: string = '
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é';
231 // LOG_DIR: string = 'Log\';
232 // PATH_DELIM: string = '\';
233 // SUBJECT_FILE_NAME: string = 'subject.txt';
234 // THREAD_DAT_FILE_NAME: string = 'thread.idx';
235 // VERION: string = '1.00 Bata1';
236 // TEMP_FILE_NAME: string = 'temp.html';
237 // THREAD_DAT_VERION: double = 1.01;
238 // THREAD_DAT_TITLE_LEN: integer = 40;
239 // THREAD_DAT_TITLE: string = 'gikoNavi ThreadData 1.01 .' +#13#10#0;
240 // 1234567890123456789012345678901234567 8 9 0
243 (*************************************************************************
244 *GikoSys
\83R
\83\93\83X
\83g
\83\89\83N
\83^
245 *************************************************************************)
246 constructor TGikoSys.Create;
248 FSetting := TSetting.Create;
249 FDolib := TDolib.Create;
250 FAWKStr := TAWKStr.Create(nil);
251 // FExitWrite := TStringList.Create;
252 // FExitWrite.Sorted := true;
253 // FExitWrite.Duplicates := dupIgnore;
256 (*************************************************************************
257 *GikoSys
\83f
\83X
\83g
\83\89\83N
\83^
258 *************************************************************************)
259 destructor TGikoSys.Destroy;
262 FileList: TStringList;
264 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
272 //
\83e
\83\93\83|
\83\89\83\8aHTML
\82ð
\8dí
\8f\9c
273 FileList := TStringList.Create;
275 GetFileList(GetTempFolder, '*.html', FileList, False, True);
276 for i := 0 to FileList.Count - 1 do begin
277 DeleteFile(FileList[i]);
285 (*************************************************************************
286 *
\83\81\83b
\83Z
\81[
\83W
\83{
\83b
\83N
\83X
287 *************************************************************************)
288 {function TGikoSys.MsgBox(Msg: string; Title: string; Flags: Longint): integer;
289 begin //
\83n
\83\93\83h
\83\8b\8ew
\92è
\96³
\82µ
\94Å
290 Result := Application.MessageBox(PChar(Msg), PChar(Title), Flags);
292 function TGikoSys.MsgBox(Handle: THandle; Msg: string; Title: string; Flags: Longint): integer;
293 begin //
\83n
\83\93\83h
\83\8b\8ew
\92è
\97L
\82è
\94Å
294 Result := Windows.MessageBox(Handle, PChar(Msg), PChar(Title), Flags);
297 (*************************************************************************
298 *
\95¶
\8e\9a\97ñ
\90\94\8e\9a\83`
\83F
\83b
\83N
299 *************************************************************************)
301 function TGikoSys.IsNumeric(s: string): boolean;
311 (*************************************************************************
312 *
\95¶
\8e\9a\97ñ
\95\82\93®
\8f¬
\90\94\93_
\90\94\8e\9a\83`
\83F
\83b
\83N
313 *************************************************************************)
314 function TGikoSys.IsFloat(s: string): boolean;
318 Result := TextToFloat(PChar(s), v, fvExtended);
321 (*************************************************************************
322 *GikoNavi
\83o
\81[
\83W
\83\87\83\93\8eæ
\93¾
323 *************************************************************************)
324 //function TGikoSys.GetVersion: string;
326 // Result := VERSION;
329 (*************************************************************************
330 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
331 *************************************************************************)
332 function TGikoSys.GetBoardFileName: string;
334 Result := GetAppDir + CONFIG_DIR_NAME + '\' + BOARD_FILE_NAME;
337 (*************************************************************************
338 *
\83{
\81[
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
339 *************************************************************************)
340 function TGikoSys.GetCustomBoardFileName: string;
342 Result := GetAppDir + CONFIG_DIR_NAME + '\' + CUSTOMBOARD_FILE_NAME;
346 (*************************************************************************
347 *
\83T
\83u
\83W
\83F
\83N
\83g
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
348 *************************************************************************)
349 {function TGikoSys.GetSubjectFileName(BBSID: string): string;
351 Result := IncludeTrailingPathDelimiter(GetLogDir + BBSID)
355 (*************************************************************************
356 *
\83X
\83\8c\83b
\83h
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
357 *************************************************************************)
358 {function TGikoSys.GetThreadFileName(BBSID: string; FileName: string): string;
360 Result := IncludeTrailingPathDelimiter(GetLogDir + BBSID)
364 (*************************************************************************
365 *thread.dat
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
366 *************************************************************************)
367 {function TGikoSys.GetThreadDatFileName(BBSID: string): string;
369 Result := IncludeTrailingPathDelimiter(GetLogDir + BBSID)
370 + THREAD_DAT_FILE_NAME;
373 (*************************************************************************
374 *
\83e
\83\93\83|
\83\89\83\8a\83t
\83H
\83\8b\83_
\81[
\96¼
\8eæ
\93¾
375 *************************************************************************)
376 function TGikoSys.GetHtmlTempFileName: string;
378 Result := TEMP_FOLDER;
381 (*************************************************************************
382 *
\83\8d\83O
\83t
\83H
\83\8b\83_
\8eæ
\93¾
383 *************************************************************************)
384 {function TGikoSys.GetLogDir: string;
386 Result := IncludeTrailingPathDelimiter(Setting.LogFolder) + '2ch' + PATH_DELIM;
390 (*************************************************************************
391 *
\8eÀ
\8ds
\83t
\83@
\83C
\83\8b\83t
\83H
\83\8b\83_
\8eæ
\93¾
392 *************************************************************************)
393 function TGikoSys.GetAppDir: string;
395 Result := ExtractFilePath(Application.ExeName);
398 (*************************************************************************
399 *TempHtml
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
400 *************************************************************************)
401 {function TGikoSys.GetTempFileName: string;
403 Result := GetAppDir + TEMP_FILE_NAME;
405 (*************************************************************************
406 *TempHtml
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
407 *************************************************************************)
408 function TGikoSys.GetTempFolder: string;
410 Result := GetAppDir + TEMP_FOLDER;
413 (*************************************************************************
414 *sent.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
415 *************************************************************************)
416 function TGikoSys.GetSentFileName: string;
418 Result := GetAppDir + SENT_FILE_NAME;
421 (*************************************************************************
422 *outbox.ini
\83t
\83@
\83C
\83\8b\96¼
\8eæ
\93¾
\81i
\83p
\83X
\81{
\83t
\83@
\83C
\83\8b\96¼
\81j
423 *************************************************************************)
424 function TGikoSys.GetOutBoxFileName: string;
426 Result := GetAppDir + OUTBOX_FILE_NAME;
429 (*************************************************************************
430 *Config
\83t
\83H
\83\8b\83_
\8eæ
\93¾
431 *************************************************************************)
432 function TGikoSys.GetConfigDir: string;
434 Result := IncludeTrailingPathDelimiter(GetAppDir + CONFIG_DIR_NAME);
437 function TGikoSys.GetStyleSheetDir: string;
439 Result := IncludeTrailingPathDelimiter(GetConfigDir + CSS_DIR_NAME);
442 (*************************************************************************
443 *URL
\82ð
\8dì
\90¬(
\83R
\83s
\83y
\97p)
444 *************************************************************************)
445 function TGikoSys.GetURL(BBSID: string; FileName: string): string;
449 Board := BoardGroup.BBS2ch.GetBoardFromBBSID(BBSID);
450 Result := UrlToServer(Board.URL) + 'test/read.cgi/' + UrlToID(Board.URL) + '/' + ChangeFileExt(FileName, '') + '/l50';
451 //http://teri.2ch.net/test/read.cgi?bbs=accuse&key=974619522&ls=50
452 //http://pc.2ch.net/test/read.cgi/tech/1003664165/l50
455 (*************************************************************************
456 *
\83\8b\81[
\83g
\83m
\81[
\83h
\82Ì
\95\
\8e¦
\96¼
\8eæ
\93¾
457 *************************************************************************)
458 {function TGikoSys.GetRootNodeName: string;
460 Result := ROOT_NODE_NAME;
464 function TGikoSys.GetUserAgent: string;
466 if Dolib.Connected then begin
467 Result := Format('%s %s/%s%f%s', [
474 BETA_VERSION_BUILD]);
476 Result := Format('%s/%s %s/%s%f%s', [
484 BETA_VERSION_BUILD]);
488 (*************************************************************************
489 *
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é
\95û
\8e®
\8e\9e\8d\8f\8eæ
\93¾
490 *************************************************************************)
491 function TGikoSys.Get2chDate(aDate: TDateTime): string;
496 d1 := EncodeDate(1970, 1, 1);
497 d2 := aDate - EncodeTime(9, 0, 0, 0);
498 Result := FloatToStr(Trunc((d2 - d1) * 24 * 60 * 60));
502 function TGikoSys.IntToDateTime(val: Int64): TDateTime;
507 d1 := EncodeDate(1970, 1, 1);
508 d2 := (val * 1000) / (24 * 60 * 60 * 1000);
512 function TGikoSys.DateTimeToInt(ADate: TDateTime): Integer;
517 d := EncodeDate(1970, 1, 1);
518 c := (ADate - d) * 24 * 60 * 60;
523 (*************************************************************************
524 *Subject
\83t
\83@
\83C
\83\8bRead
525 *************************************************************************)
526 procedure TGikoSys.ReadSubjectFile(Board: TBoard);
528 ThreadItem: TThreadItem;
530 FileList: TStringList;
531 TmpFileList: TStringList;
532 // SrchRec: TSearchRec;
542 RoundItem: TRoundItem;
549 FileName := Board.GetFolderIndexFileName;
550 if not FileExists(FileName) then CreateThreadDat(Board);
551 // if not FileExists(FileName) then Exit;
553 //IsLogFile
\97pDAT
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
554 FileList := TStringList.Create;
555 FileList.Sorted := True;
556 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False, False);
558 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\97pTmp
\83t
\83@
\83C
\83\8b\83\8a\83X
\83g
559 TmpFileList := TStringList.Create;
560 TmpFileList.Sorted := True;
561 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, False, False);
563 { R := FindFirst(ExtractFileDir(Board.GetFolderIndexFileName) + '\*.dat', 0, SrchRec);
565 FileList.Add(SrchRec.Name);
566 R := FindNext(SrchRec);
570 sl := TStringList.Create;
572 if FileExists(FileName) then
573 sl.LoadFromFile(FileName);
575 //
\82Q
\8ds
\96Ú
\82©
\82ç
\81i
\82P
\8ds
\96Ú
\82Í
\83o
\81[
\83W
\83\87\83\93\81j
576 for i := 1 to sl.Count - 1 do begin
577 Rec := ParseIndexLine(sl[i]);
579 ThreadItem := TThreadItem.Create;
580 ThreadItem.BeginUpdate;
581 ThreadItem.No := Rec.FNo;
582 ThreadItem.FileName := Rec.FFileName;
583 ThreadItem.Title := Rec.FTitle;
584 ThreadItem.Count := Rec.FCount;
585 ThreadItem.Size := Rec.FSize;
586 // ThreadItem.RoundNo := Rec.FRoundNo;
587 ThreadItem.RoundDate := Rec.FRoundDate;
588 ThreadItem.LastModified := Rec.FLastModified;
589 ThreadItem.Kokomade := Rec.FKokomade;
590 ThreadItem.NewReceive := Rec.FNewReceive;
591 // ThreadItem.Round := Rec.FRound;
592 ThreadItem.UnRead := Rec.FUnRead;
593 ThreadItem.ScrollTop := Rec.FScrollTop;
594 ThreadItem.AllResCount := Rec.FAllResCount;
595 ThreadItem.NewResCount := Rec.FNewResCount;
596 ThreadItem.AgeSage := Rec.FAgeSage;
597 ThreadItem.ParentBoard := Board;
599 //IsLogFile
\83`
\83F
\83b
\83N
600 ThreadItem.IsLogFile := False;
601 if FileList.Count <> 0 then begin
602 if FileList.Find(ThreadItem.FileName, Index) then begin
603 ThreadItem.IsLogFile := True;
604 FileList.Delete(Index);
608 //
\8f\84\89ñ
\83\8a\83X
\83g
\82É
\91¶
\8dÝ
\82µ
\82½
\82ç
\8f\84\89ñ
\83t
\83\89\83O
\83Z
\83b
\83g
609 if ThreadItem.IsLogFile then begin
610 idx := RoundList.Find(ThreadItem);
611 if idx <> -1 then begin
612 RoundItem := RoundList.Items[idx, grtItem];
613 ThreadItem.RoundName := RoundItem.RoundName;
614 ThreadItem.Round := True;
618 //
\91O
\89ñ
\88Ù
\8fí
\8fI
\97¹
\8e\9e\83`
\83F
\83b
\83N
619 if TmpFileList.Count <> 0 then begin
620 if TmpFileList.Find(ChangeFileExt(ThreadItem.FileName, '.tmp'), Index) then begin
621 ini := TMemIniFile.Create(ChangeFileExt(ThreadItem.GetThreadFileName, '.tmp'));
623 ThreadItem.RoundDate := ini.ReadDateTime('Setting', 'RoundDate', ZERO_DATE);
624 ThreadItem.LastModified := ini.ReadDateTime('Setting', 'LastModified', ZERO_DATE);
625 ThreadItem.Size := ini.ReadInteger('Setting', 'Size', 0);
626 ThreadItem.Count := ini.ReadInteger('Setting', 'Count', 0);
627 ThreadItem.NewReceive := ini.ReadInteger('Setting', 'NewReceive', 0);
628 ThreadItem.Round := ini.ReadBool('Setting', 'Round', False);
629 ThreadItem.UnRead := False;//ini.ReadBool('Setting', 'UnRead', False);
630 ThreadItem.ScrollTop := ini.ReadInteger('Setting', 'ScrollTop', 0);
631 ThreadItem.AllResCount := ini.ReadInteger('Setting', 'AllResCount', 0);
632 ThreadItem.NewResCount := ini.ReadInteger('Setting', 'NewResCount', 0);
633 ThreadItem.AgeSage := TGikoAgeSage(ini.ReadInteger('Setting', 'AgeSage', Ord(gasNone)));
637 TmpFileList.Delete(Index);
641 ThreadItem.EndUpdate;
642 Board.Add(ThreadItem);
644 // if (ThreadItem.IsLogFile) and (ThreadItem.Count > ThreadItem.Kokomade) then
645 if (ThreadItem.IsLogFile) and (ThreadItem.UnRead) then
648 if UnRead <> Board.UnRead then
649 Board.UnRead := UnRead;
651 //
\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
652 for i := 0 to FileList.Count - 1 do begin
653 FileName := ExtractFileDir(Board.GetFolderIndexFileName) + '\' + FileList[i];
655 ResRec := DivideStrLine(ReadThreadFile(FileName, 1));
656 ThreadItem := TThreadItem.Create;
657 ThreadItem.No := Board.Count + 1;
658 ThreadItem.FileName := FileList[i];
659 ThreadItem.Title := ResRec.FTitle;
660 ThreadItem.Count := GetFileLineCount(FileName);
661 ThreadItem.AllResCount := ThreadItem.Count;
662 ThreadItem.NewResCount := 0;
663 ThreadItem.Size := 0;
664 ThreadItem.RoundDate := ZERO_DATE;
665 ThreadItem.LastModified := ZERO_DATE;
666 ThreadItem.Kokomade := -1;
667 ThreadItem.NewReceive := 0;
668 ThreadItem.ParentBoard := Board;
669 ThreadItem.IsLogFile := True;
670 ThreadItem.Round := False;
671 ThreadItem.UnRead := False;
672 ThreadItem.ScrollTop := 0;
673 ThreadItem.AgeSage := gasNone;
674 Board.Add(ThreadItem);
681 Board.IsThreadDatRead := True;
684 (*************************************************************************
685 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X
\83t
\83@
\83C
\83\8b(Folder.idx)
\8dì
\90¬
686 *************************************************************************)
687 procedure TGikoSys.CreateThreadDat(Board: TBoard);
691 SubjectList: TStringList;
697 if not FileExists(Board.GetSubjectFileName) then Exit;
698 FileName := Board.GetFolderIndexFileName;
700 SubjectList := TStringList.Create;
702 SubjectList.LoadFromFile(Board.GetSubjectFileName);
703 sl := TStringList.Create;
706 sl.Add(FOLDER_INDEX_VERSION);
707 for i := 0 to SubjectList.Count - 1 do begin
708 Rec := DivideSubject(SubjectList[i]);
710 if (Trim(Rec.FFileName) = '') or (Trim(Rec.FTitle) = '') then
713 s := Format('%x', [cnt]) + #1 //
\94Ô
\8d\86
714 + Rec.FFileName + #1 //
\83t
\83@
\83C
\83\8b\96¼
715 + Rec.FTitle + #1 //
\83^
\83C
\83g
\83\8b
716 + Format('%x', [Rec.FCount]) + #1 //
\83J
\83E
\83\93\83g
717 + Format('%x', [0]) + #1 //size
718 + Format('%x', [0]) + #1 //RoundDate
719 + Format('%x', [0]) + #1 //LastModified
720 + Format('%x', [0]) + #1 //Kokomade
721 + Format('%x', [0]) + #1 //NewReceive
722 + '0' + #1 //
\96¢
\8eg
\97p
723 + Format('%x', [0]) + #1 //UnRead
724 + Format('%x', [0]) + #1 //ScrollTop
725 + Format('%x', [Rec.FCount]) + #1 //AllResCount
726 + Format('%x', [0]) + #1 //NewResCount
727 + Format('%x', [0]); //AgeSage
732 sl.SaveToFile(FileName);
741 (*************************************************************************
742 *
\83X
\83\8c\83b
\83h
\83C
\83\93\83f
\83b
\83N
\83X(Thread.dat)
\8f\91\82«
\8d\9e\82Ý
744 *************************************************************************)
745 procedure TGikoSys.WriteThreadDat(Board: TBoard);
747 // Values: array[Boolean] of string = ('0', '1');
753 FileList: TStringList;
755 if not Board.IsThreadDatRead then
757 FileName := Board.GetFolderIndexFileName;
758 ForceDirectoriesEx(Board.ParentCategory.ParentBBS2ch.GetLogFolder + Board.BBSID);
760 sl := TStringList.Create;
762 sl.Add(FOLDER_INDEX_VERSION);
763 for i := 0 to Board.Count - 1 do begin
764 if Board.Items[i].No = 0 then
765 Board.Items[i].No := i + 1;
767 s := Format('%x', [Board.Items[i].No]) + #1
768 + Board.Items[i].FileName + #1
769 + Board.Items[i].Title + #1
770 + Format('%x', [Board.Items[i].Count]) + #1
771 + Format('%x', [Board.Items[i].Size]) + #1
772 + Format('%x', [DateTimeToInt(Board.Items[i].RoundDate)]) + #1
773 + Format('%x', [DateTimeToInt(Board.Items[i].LastModified)]) + #1
774 + Format('%x', [Board.Items[i].Kokomade]) + #1
775 + Format('%x', [Board.Items[i].NewReceive]) + #1
776 + '0' + #1 //
\96¢
\8eg
\97p
777 + Format('%x', [BoolToInt(Board.Items[i].UnRead)]) + #1
778 + Format('%x', [Board.Items[i].ScrollTop]) + #1
779 + Format('%x', [Board.Items[i].AllResCount]) + #1
780 + Format('%x', [Board.Items[i].NewResCount]) + #1
781 + Format('%x', [Ord(Board.Items[i].AgeSage)]);
786 sl.SaveToFile(FileName);
788 FileList := TStringList.Create;
790 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', FileList, False, True);
791 for i := 0 to FileList.Count - 1 do begin
792 DeleteFile(FileList[i]);
802 function TGikoSys.ParseIndexLine(Line: string): TIndexRec;
807 for i := 0 to 14 do begin
808 s := GetTokenIndex(Line, #1, i);
810 0: Result.FNo := StrToIntDef('$' + s, 0);
811 1: Result.FFileName := s;
812 2: Result.FTitle := s;
813 3: Result.FCount := StrToIntDef('$' + s, 0);
814 4: Result.FSize := StrToIntDef('$' + s, 0);
815 5: Result.FRoundDate := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
816 6: Result.FLastModified := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
817 7: Result.FKokomade := StrToIntDef('$' + s, -1);
818 8: Result.FNewReceive := StrToIntDef('$' + s, 0);
820 10: Result.FUnRead := IntToBool(StrToIntDef('$' + s, 0));
821 11: Result.FScrollTop := StrToIntDef('$' + s, 0);
822 12: Result.FAllResCount := StrToIntDef('$' + s, 0);
823 13: Result.FNewResCount := StrToIntDef('$' + s, 0);
824 14: Result.FAgeSage := TGikoAgeSage(StrToIntDef('$' + s, 0));
829 //
\8ew
\92è
\83t
\83H
\83\8b\83_
\93à
\82Ì
\8ew
\92è
\83t
\83@
\83C
\83\8b\88ê
\97\97\82ð
\8eæ
\93¾
\82·
\82é
830 // GetFileList('c:\*.txt', list);
831 {procedure TGikoSys.GetFileList(Path: string; FileList: TStringList);
837 R := FindFirst(Path, 0, SrchRec);
840 FileList.Add(SrchRec.Name);
841 R := FindNext(SrchRec);
844 SysUtils.FindClose(SrchRec);
848 //
\8ew
\92è
\83t
\83H
\83\8b\83_
\93à
\82Ì
\8ew
\92è
\83t
\83@
\83C
\83\8b\88ê
\97\97\82ð
\8eæ
\93¾
\82·
\82é
849 // ListFiles('c:\', '*.txt', list, True);
850 procedure TGikoSys.GetFileList(Path: string; Mask: string; List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
853 SearchRec : TSearchRec;
856 Path := IncludeTrailingPathDelimiter(Path);
857 rc := FindFirst(Path + '*.*', faAnyfile, SearchRec);
859 while rc = 0 do begin
860 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
861 s := Path + SearchRec.Name;
862 //if (SearchRec.Attr and faDirectory > 0) then
863 // s := IncludeTrailingPathDelimiter(s)
865 if (SearchRec.Attr and faDirectory = 0) and (MatchesMask(s, Mask)) then
869 List.Add(SearchRec.Name);
870 if SubDir and (SearchRec.Attr and faDirectory > 0) then
871 GetFileList(s, Mask, List, True, IsPathAdd);
873 rc := FindNext(SearchRec);
876 SysUtils.FindClose(SearchRec);
880 {function TGikoSys.StrToFloatDef(s: string; Default: Double): Double;
883 Result := StrToFloat(s)
889 procedure TGikoSys.CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
893 ReadList: TStringList;
894 SaveList: TStringList;
898 NewReceiveNo: Integer;
901 ShortDayNames[1] := '
\93ú'; ShortDayNames[2] := '
\8c\8e';
902 ShortDayNames[3] := '
\89Î'; ShortDayNames[4] := '
\90\85';
903 ShortDayNames[5] := '
\96Ø'; ShortDayNames[6] := '
\8bà';
904 ShortDayNames[7] := '
\93y';
905 BBSID := ThreadItem.ParentBoard.BBSID;
906 FileName := ThreadItem.FileName;
907 NewReceiveNo := ThreadItem.NewReceive;
908 FileName := ThreadItem.GetThreadFileName;
909 ReadList := TStringList.Create;
911 if ThreadItem.IsLogFile then begin
912 ReadList.LoadFromFile(FileName);
913 Res := DivideStrLine(ReadList[0]);
914 Res.FTitle := StringReplace(Res.FTitle, '
\81\97\81M', ',', [rfReplaceAll]);
915 sTitle := Res.FTitle;
917 sTitle := StringReplace(ThreadItem.Title, '
\81\97\81M', ',', [rfReplaceAll]);
919 SaveList := TStringList.Create;
922 doc.charset := 'Shift_JIS';
924 CSSFileName := GetStyleSheetDir + Setting.CSSFileName;
925 if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
927 //CSSFileName := GetAppDir + CSS_FILE_NAME;
928 // SaveList.Add('<html lang="ja"><head>');
929 SaveList.Add('<html><head>');
930 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
931 SaveList.Add('<title>' + sTitle + '</title>');
932 SaveList.Add('<style type="text/css">');
933 SaveList.Add('@import url(' + CSSFileName + ');');
934 SaveList.Add('</style>');
935 SaveList.Add('</head>');
936 SaveList.Add('<body>');
937 SaveList.Add('<a name="top"></a>');
938 SaveList.Add('<div class="title">' + sTitle + '</div>');
939 //doc.Write(SaveList.Text);
941 //Application.ProcessMessages;
942 for i := 0 to ReadList.Count - 1 do begin
943 if (Trim(ReadList[i]) <> '') then begin
944 No := IntToStr(i + 1);
945 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
946 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>');
948 Res := DivideStrLine(ReadList[i]);
949 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
951 if Res.FType = glt2chOld then begin
952 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
953 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
954 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
956 //Res.FBody := StringReplace(Res.FBody, '&hearts;', '♥', [rfReplaceAll]);
957 //Res.FBody := StringReplace(Res.FBody, '&nbsp;', ' ', [rfReplaceAll]);
958 //Res.FBody := StringReplace(Res.FBody, '&#', '&#', [rfReplaceAll]);
959 //Res.FBody := StringReplace(Res.FBody, '&', '&', [rfReplaceAll]);
960 Res.FBody := AddAnchorTag(Res.FBody);
961 if Res.FName = '' then
962 Res.FName := ' ';
963 if Res.FMailTo = '' then
964 SaveList.Add('<a name="' + No + '"></a>'
965 + '<div class="header"><span class="no"><a href="giko://?no=' + No + '">' + No + '</a></span> '
966 + '<span class="name_label">
\96¼
\91O
\81F</span> '
967 + '<span class="name"><b>' + Res.FName + '</b></span> '
968 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span> '
969 + '<span class="date">' + Res.FDateTime+ '</span></div>'
970 + '<div class="mes">' + Res.FBody + ' </div>')
972 if GikoSys.Setting.ShowMail then
973 SaveList.Add('<a name="' + No + '"></a>'
974 + '<div class="header"><span class="no"><a href="giko://?no=' + No + '">' + No + '</a></span>'
975 + '<span class="name_label">
\96¼
\91O
\81F </span>'
976 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
977 + '<b>' + Res.FName + '</a></b><span class="mail"> [' + Res.FMailTo + ']</span>'
978 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
979 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
980 + '<div class="mes">' + Res.FBody + ' </div>')
982 SaveList.Add('<a name="' + No + '"></a>'
983 + '<div class="header"><span class="no"><a href="giko://?no=' + No + '">' + No + '</a></span>'
984 + '<span class="name_label">
\96¼
\91O
\81F </span>'
985 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
986 + '<b>' + Res.FName + '</a></b>'
987 + '<span class="date_label">
\93\8a\8de
\93ú
\81F</span>'
988 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
989 + '<div class="mes">' + Res.FBody + ' </div>');
990 if ThreadItem.Kokomade = (i + 1) then begin
991 SaveList.Add('<a name="koko"></a><div class="koko">
\83R
\83R
\82Ü
\82Å
\93Ç
\82ñ
\82¾</div>');
994 //if SaveList.Count > 50 then begin
997 //Application.ProcessMessages;
999 doc.Write(SaveList.Text);
1000 //while GikoForm.Browser.Busy do begin
1002 // Application.ProcessMessages;
1004 while (GikoForm.Browser.ReadyState <> READYSTATE_COMPLETE) and
1005 (GikoForm.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
1007 //Application.ProcessMessages;
1012 SaveList.Add('<a name="bottom"></a>');
1013 SaveList.Add('</body></html>');
1014 SaveList.Add('</dl>');
1015 SaveList.Add('<a name="last"></a>');
1016 SaveList.Add('</body></html>');
1017 doc.Write(SaveList.Text);
1020 // SaveList.Add('<html lang="ja"><head>');
1021 SaveList.Add('<html><head>');
1022 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1023 SaveList.Add('<title>' + sTitle + '</title></head>');
1024 SaveList.Add('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1025 SaveList.Add('<a name="top"></a>');
1026 SaveList.Add('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1027 SaveList.Add('<dl>');
1028 doc.Write(SaveList.Text);
1030 //Application.ProcessMessages;
1031 for i := 0 to ReadList.Count - 1 do begin
1032 if (Trim(ReadList[i]) <> '') then begin
1033 No := IntToStr(i + 1);
1035 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1036 SaveList.Add('</dl>');
1037 SaveList.Add('<a name="new"></a>');
1038 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>');
1039 SaveList.Add('<dl>');
1041 Res := DivideStrLine(ReadList[i]);
1042 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1043 if Res.FType = glt2chOld then begin
1044 Res.FMailTo := StringReplace(Res.FMailTo, '
\81\97\81M', ',', [rfReplaceAll]);
1045 Res.FName := StringReplace(Res.FName, '
\81\97\81M', ',', [rfReplaceAll]);
1046 Res.FBody := StringReplace(Res.FBody, '
\81\97\81M', ',', [rfReplaceAll]);
1048 //Res.FBody := StringReplace(Res.FBody, '&hearts;', '♥', [rfReplaceAll]);
1049 //Res.FBody := StringReplace(Res.FBody, '&nbsp;', ' ', [rfReplaceAll]);
1050 //Res.FBody := StringReplace(Res.FBody, '&#', '&#', [rfReplaceAll]);
1051 //Res.FBody := StringReplace(Res.FBody, '&', '&', [rfReplaceAll]);
1052 Res.FBody := AddAnchorTag(Res.FBody);
1053 if Res.FMailTo = '' then
1054 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>')
1056 if GikoSys.Setting.ShowMail then
1057 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>')
1059 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>');
1060 if ThreadItem.Kokomade = (i + 1) then begin
1061 SaveList.Add('</dl>');
1062 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>');
1063 SaveList.Add('<dl>');
1066 if SaveList.Count > 50 then begin
1067 doc.Write(SaveList.Text);
1069 //Application.ProcessMessages;
1072 SaveList.Add('</dl>');
1073 SaveList.Add('<a name="bottom"></a>');
1074 SaveList.Add('</body></html>');
1075 doc.Write(SaveList.Text);
1086 (*************************************************************************
1087 *http://
\82Ì
\95¶
\8e\9a\97ñ
\82ðanchor
\83^
\83O
\95t
\82«
\82É
\82·
\82é
\81B
1088 *************************************************************************)
1089 function TGikoSys.AddAnchorTag(s: string): string;
1091 URL_CHAR: string = '0123456789'
1092 + 'abcdefghijklmnopqrstuvwxyz'
1093 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1094 + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
1096 wkIdx: array[0..9] of Integer;
1105 wkIdx[0] := AnsiPos('http://', s);
1106 wkIdx[1] := AnsiPos('ttp://', s);
1107 wkIdx[2] := AnsiPos('tp://', s);
1108 wkIdx[3] := AnsiPos('ms-help://', s);
1109 wkIdx[4] := AnsiPos('p://', s);
1110 wkIdx[5] := AnsiPos('https://', s);
1111 wkIdx[6] := AnsiPos('www.', s);
1112 wkIdx[7] := AnsiPos('ftp://', s);
1113 wkIdx[8] := AnsiPos('news://', s);
1114 wkIdx[9] := AnsiPos('rtsp://', s);
1118 if wkIdx[i] <> 0 then idx := Min(wkIdx[i], idx);
1120 if idx = MaxInt then begin
1121 //
\83\8a\83\93\83N
\82ª
\96³
\82¢
\82æ
\81B
1122 Result := Result + s;
1126 if (idx > 1) and (Copy(s, idx - 1, 1) = '"') then begin
1127 //
\8aù
\82É
\83\8a\83\93\83N
\83^
\83O
\82ª
\82Â
\82¢
\82Ä
\82¢
\82é
\82Á
\82Û
\82¢
\82Æ
\82«
\82Í
\83\80\83V
1128 Result := Result + Copy(s, 0, idx + Length('http://') - 1);
1129 s := Copy(s, idx + Length('http://'), length(s));
1133 Result := Result + Copy(s, 0, idx - 1);
1135 s := Copy(s, idx, length(s));
1137 for i := 0 to Length(s) do begin
1138 idx := AnsiPos(s[i + 1], URL_CHAR);
1139 if (idx = 0) or (i = (Length(s))) then begin
1140 //URL
\82¶
\82á
\82È
\82¢
\95¶
\8e\9a\94
\8c©
\81I
\82Æ
\82©
\81A
\95¶
\8e\9a\82ª
\82È
\82
\82È
\82Á
\82½
\81B
1141 url := Copy(s, 0, i);
1143 if AnsiPos('ttp://', url) = 1 then
1145 else if AnsiPos('tp://', url) = 1 then
1147 else if AnsiPos('p://', url) = 1 then
1149 else if AnsiPos('www.', url) = 1 then
1150 href := 'http://' + url
1153 Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
1154 s := Copy(s, i + 1, Length(s));
1161 (*************************************************************************
1162 *
\83T
\83u
\83W
\83F
\83N
\83g
\88ê
\8ds
\82ð
\95ª
\8a\84
1163 *************************************************************************)
1164 function TGikoSys.DivideSubject(Line: string): TSubjectRec;
1174 if Pos('<>', Line) = 0 then
1179 Result.FFileName := GetTokenIndex(Line, Delim, 0);
1180 Result.FTitle := GetTokenIndex(Line, Delim, 1);
1182 ws := Trim(Result.FTitle);
1184 if Copy(ws, Length(ws), 1) = ')' then begin
1187 end else if Copy(ws, Length(ws), 1) = '
\81j' then begin
1190 end else if Copy(ws, Length(ws), 1) = '<' then begin
1195 for i := Length(ws) - 1 downto 1 do begin
1196 if ws[i] = LeftK then begin
1197 ws := Copy(ws, i + 1, Length(ws) - i - 1);
1198 if IsNumeric(ws) then
1199 Result.FCount := StrToInt(ws);
1200 Result.FTitle := Trim(StringReplace(Result.FTitle, LeftK + ws + RightK, '', [rfReplaceAll]));
1206 (*************************************************************************
1207 * dat
\83t
\83@
\83C
\83\8b\82Ì
\88ê
\83\89\83C
\83\93\82ð
\95ª
\89ð
1208 *************************************************************************)
1209 function TGikoSys.DivideStrLine(Line: string): TResRec;
1213 if Pos('<>', Line) = 0 then begin
1215 Result.FType := glt2chOld;
1218 Result.FType := glt2chNew;
1220 Result.FName := Trim(GetTokenIndex(Line, Delim, 0));
1221 Result.FMailTo := Trim(GetTokenIndex(Line, Delim, 1));
1222 Result.FDateTime := Trim(GetTokenIndex(Line, Delim, 2));
1223 Result.FBody := Trim(GetTokenIndex(Line, Delim, 3));
1224 Result.FTitle := Trim(GetTokenIndex(Line, Delim, 4));
1228 (*************************************************************************
1229 * URL
\82©
\82çBBSID
\82ð
\8eæ
\93¾
1230 *************************************************************************)
1231 function TGikoSys.UrlToID(url: string): string;
1238 if url = '' then Exit;
1240 url := Copy(url, 0, Length(url) - 1);
1241 for i := Length(url) downto 0 do begin
1242 if url[i] = '/' then begin
1243 Result := Copy(url, i + 1, Length(url));
1249 (*************************************************************************
1250 *URL
\82©
\82çBBSID
\88È
\8aO
\82Ì
\95\94\95ª(http://teri.2ch.net/)
\82ð
\8eæ
\93¾
1251 *************************************************************************)
1252 function TGikoSys.UrlToServer(url: string): string;
1259 wsURL := Trim(wsURL);
1261 if wsURL = '' then exit;
1263 if Copy(wsURL, Length(wsURL), 1) = '/' then
1264 wsURL := Copy(wsURL, 0, Length(wsURL) - 1);
1266 for i := Length(wsURL) downto 0 do begin
1267 if wsURL[i] = '/' then begin
1268 Result := Copy(wsURL, 0, i);
1274 (*************************************************************************
1275 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ª
\91¶
\8dÝ
\82·
\82é
\82©
\83`
\83F
\83b
\83N
1276 *************************************************************************)
1277 function TGikoSys.DirectoryExistsEx(const Name: string): Boolean;
1281 Code := GetFileAttributes(PChar(Name));
1282 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
1285 (*************************************************************************
1286 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\8dì
\90¬
\81i
\95¡
\90\94\8aK
\91w
\91Î
\89\9e\81j
1287 *************************************************************************)
1288 function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean;
1291 if Length(Dir) = 0 then
1292 raise Exception.Create('
\83t
\83H
\83\8b\83_
\82ª
\8dì
\90¬
\8fo
\97\88\82Ü
\82¹
\82ñ');
1293 Dir := ExcludeTrailingPathDelimiter(Dir);
1294 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
1295 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
1296 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
1299 (*************************************************************************
1300 *
\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
1301 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1302 *************************************************************************)
1303 function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1307 Result := StrTokNext(sep, Rec);
1310 (*************************************************************************
1311 *
\95¶
\8e\9a\97ñ
\82©
\82ç
\83g
\81[
\83N
\83\93\82Ì
\90Ø
\82è
\8fo
\82µ
1312 *FDelphi
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1313 *************************************************************************)
1314 function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1321 if Len >= Pos then begin
1322 while (Pos <= Len) and (Str[Pos] in sep) do begin
1326 while (Pos<= Len) and not (Str[Pos] in sep) do begin
1327 if IsDBCSLeadByte(Byte(Str[Pos])) then begin
1332 Result := Copy(Str, I, Pos - I);
1333 while (Pos <= Len) and (Str[Pos] in sep) do begin//
\82±
\82ê
\82Í
\82¨
\8dD
\82Ý
1340 (*************************************************************************
1341 *
\83t
\83@
\83C
\83\8b\83T
\83C
\83Y
\8eæ
\93¾
1342 *************************************************************************)
1343 function TGikoSys.GetFileSize(FileName : string): longint;
1348 if not FileExists(FileName) then begin
1352 Assign(F, FileName);
1354 Result := FileSize(F);
1361 (*************************************************************************
1362 *
\83t
\83@
\83C
\83\8b\8ds
\90\94\8eæ
\93¾
1363 *************************************************************************)
1364 function TGikoSys.GetFileLineCount(FileName : string): longint;
1369 sl := TStringList.Create;
1371 sl.LoadFromFile(FileName);
1378 (*************************************************************************
1379 *
\83X
\83\8c\83b
\83h
\83t
\83@
\83C
\83\8b\82©
\82ç
\8ew
\92è
\8ds
\82ð
\8eæ
\93¾
1380 *************************************************************************)
1381 function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string;
1388 ArrBuff: array [1..BUFFER_SIZE] of Char;
1391 if FileExists(FileName) then begin
1392 AssignFile(f, FileName);
1393 System.SetTextBuf(f, ArrBuff);
1397 while not Eof(f) do begin
1399 if Line = num then begin
1412 (*************************************************************************
1413 *
\83V
\83X
\83e
\83\80\83\81\83j
\83\85\81[
\83t
\83H
\83\93\83g
\82Ì
\91®
\90«
\82ð
\8eæ
\93¾
1414 *************************************************************************)
1415 procedure TGikoSys.MenuFont(Font: TFont);
1418 nm: NONCLIENTMETRICS;
1420 nm.cbSize := sizeof(NONCLIENTMETRICS);
1422 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0);
1423 lf := nm.lfMenuFont;
1425 Font.Name := lf.lfFaceName;
1426 Font.Height := lf.lfHeight;
1428 if lf.lfWeight >= 700 then
1429 Font.Style := Font.Style + [fsBold];
1430 if lf.lfItalic = 1 then
1431 Font.Style := Font.Style + [fsItalic];
1434 (*************************************************************************
1436 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1437 *************************************************************************)
1438 function TGikoSys.RemoveToken(var s: string; delimiter: string): string;
1442 p := AnsiPos(delimiter, s);
1446 Result := Copy(s, 1, p - 1);
1447 s := Copy(s, Length(Result) + Length(delimiter) + 1, Length(s));
1450 (*************************************************************************
1452 *
\82Ç
\82±
\82©
\82Ì
\83T
\83C
\83g
\82©
\82ç
\82Ì
\83p
\83N
\83\8a
1453 *************************************************************************)
1454 function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string;
1459 for i := 0 to index do
1460 Result := RemoveToken(s, delimiter);
1463 (*************************************************************************
1465 *************************************************************************)
1466 function TGikoSys.DeleteLink(const s: string): string;
1476 s1 := GetTokenIndex(s, '<a href="', i);
1477 s2 := GetTokenIndex(s, '<a href="', i + 1);
1479 idx := Pos('">', s1);
1481 Delete(s1, 1, idx + 1);
1482 idx := Pos('">', s2);
1484 Delete(s2, 1, idx + 1);
1486 Result := Result + s1 + s2;
1495 //
\83C
\83\93\83f
\83b
\83N
\83X
\96¢
\8dX
\90V
\83o
\83b
\83t
\83@
\82ð
\83t
\83\89\83b
\83V
\83\85\81I
1496 {procedure TGikoSys.FlashExitWrite;
1500 //
\83X
\83\8c\83b
\83h
\83f
\81[
\83^
\83t
\83@
\83C
\83\8b\82ð
\8dX
\90V
1501 for i := 0 to FExitWrite.Count - 1 do
1502 WriteThreadDat(FExitWrite[i]);
1506 (*************************************************************************
1507 *
\83X
\83\8c\96¼
\82È
\82Ç
\82ð
\92Z
\82¢
\96¼
\91O
\82É
\95Ï
\8a·
\82·
\82é
1509 *************************************************************************)
1510 function TGikoSys.GetShortName(const LongName: string; ALength: integer): string;
1512 ERASECHAR : array [1..39] of string =
1513 ('
\81\99','
\81\9a','
\81¡','
\81 ','
\81\9f','
\81\9e','
\81Q','
\81\94','
\81£','
\81¥',
1514 '
\81¢','
\81¤','
\81\9c','
\81\9b','
\81\9d','
\81y','
\81z','
\81ô','
\81s','
\81t',
1515 '
\81g','
\81h','
\81k','
\81l','
\81e','
\81f','
\81\83','
\81\84','
\81á','
\81â',
1516 '
\81o','
\81p','
\81q','
\81r','
\81w','
\81x','
\81¬','
\81c', '
\81@');
1518 Chr : array [0..255] of char;
1522 s := Trim(LongName);
1523 if (Length(s) <= ALength) then begin
1527 for i := Low(ERASECHAR) to High(ERASECHAR) do begin
1528 S := StringReplace(S, ERASECHAR[i], '', [rfReplaceAll]);
1530 if (Length(S) <= ALength) then begin
1533 Windows.LCMapString(
1534 GetUserDefaultLCID(),
1542 S := Copy(S,1,ALength);
1544 if (ByteType(S, Length(S)) = mbLeadByte ) then begin
1545 S := Copy(S, 1, Length(S) - 1);
1555 (*************************************************************************
1558 *************************************************************************)
1559 function TGikoSys.ConvRes(const Body, Bbs, Key,
1560 ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
1564 FIndexFrom : integer;
1571 ZN = '
\82O
\82P
\82Q
\82R
\82S
\82T
\82U
\82V
\82W
\82X
\81|';
1585 procedure Add(IndexFrom, IndexTo: integer; const No: string);
1590 FIndex.FIndexFrom := IndexFrom;
1591 FIndex.FIndexTo := IndexTo;
1595 function ChooseString(const Text, Separator: string; Index: integer): string;
1601 for i := 0 to Index - 1 do begin
1602 if (AnsiPos(Separator, S) = 0) then S := ''
1603 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
1605 p := AnsiPos(Separator, S);
1606 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
1615 List:= TList.Create;
1621 b := ByteType(s, i);
1623 mbSingleByte : begin
1624 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1625 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1633 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1634 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
1640 if (not sw) and (Copy(s,i,4) = GT) then begin
1641 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1649 if ((not sw) and (Copy(s,i,1) = ',')) or
1650 ((not sw) and (Copy(s,i,1) = '=')) then begin
1651 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
1652 ((Chk) and (oc = '')) or
1653 ((not Chk) and (al)) then
1663 if (AnsiPos(sx, SN) > 0) then begin
1666 if (No <> '') and (No <> '-') then begin
1679 if Copy(s,i,1) = '<' then oc := '';
1680 oc := oc + Copy(s,i,1);
1686 if (not sw) and (Copy(s,i,4) = '
\81\84\81\84') then begin
1692 if (not sw) and (Copy(s,i,2) = '
\81\84') then begin
1700 if (AnsiPos(sx, ZN) > 0) then begin
1701 No := No + ZenToHan(sx);
1703 if (No <> '') and (No <> '-') and (No <> '
\81|') then begin
1718 if (i > Length(Body)) then begin
1720 if (No <> '') then Add(sp, i, No);
1725 for i := List.Count - 1 downto 0 do begin
1726 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
1727 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
1728 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
1730 st := PIndex(List[i]).FNo;
1731 et := PIndex(List[i]).FNo;
1733 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
1734 Format('<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">',
1735 [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
1736 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
1737 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
1738 Dispose(PIndex(List[i]));
1743 {function TGikoSys.ConvRes(const Body, Bbs, Key: string): string;
1747 FIndexFrom : integer;
1754 ZN = '
\82O
\82P
\82Q
\82R
\82S
\82T
\82U
\82V
\82W
\82X
\81|';
1766 procedure Add(IndexFrom, IndexTo: integer; const No: string);
1771 FIndex.FIndexFrom := IndexFrom;
1772 FIndex.FIndexTo := IndexTo;
1782 List:= TList.Create;
1786 b := ByteType(s, i);
1788 mbSingleByte : begin
1789 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1790 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1797 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1798 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
1803 if (not sw) and (Copy(s,i,4) = GT) then begin
1804 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1811 if (not sw) and (Copy(s,i,1) = ',') then begin
1812 //if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1813 if (oc = '') or (AnsiPos('</a>', AnsiLowerCase(oc)) = 1) then begin
1822 if (AnsiPos(sx, SN) > 0) then begin
1825 if (No <> '') and (No <> '-') then begin
1836 if Copy(s,i,1) = '<' then oc := '';
1837 oc := oc + Copy(s,i,1);
1841 if (not sw) and (Copy(s,i,4) = '
\81\84\81\84') then begin
1846 if (not sw) and (Copy(s,i,2) = '
\81\84') then begin
1851 //if (not sw) and (Copy(s,i,2) = '
\81C') and (oc = '') then begin
1858 if (AnsiPos(sx, ZN) > 0) then begin
1859 No := No + ZenToHan(sx);
1861 if (No <> '') and (No <> '-') and (No <> '
\81|') then begin
1876 if (i > Length(Body)) then begin
1878 if (No <> '') then Add(sp, i, No);
1884 for i := List.Count - 1 downto 0 do begin
1885 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
1886 st := GetTokenIndex(PIndex(List[i]).FNo, '-', 0);
1887 et := GetTokenIndex(PIndex(List[i]).FNo, '-', 1);
1889 st := PIndex(List[i]).FNo;
1890 et := PIndex(List[i]).FNo;
1892 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
1893 Format('<a href="../test/read.cgi?bbs=%s&key=%s&st=%s&to=%s&nofirst=true" target="_blank">',[Bbs, Key, st, et]) +
1894 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
1895 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
1896 Dispose(PIndex(List[i]));
1902 (*************************************************************************
1903 *
\91S
\8ap
\81¨
\94¼
\8ap
1905 *************************************************************************)
1906 function TGikoSys.ZenToHan(const s: string): string;
1908 Chr: array [0..255] of char;
1910 Windows.LCMapString(
1911 GetUserDefaultLCID(),
1913 LCMAP_HALFWIDTH or LCMAP_KATAKANA or LCMAP_LOWERCASE,
1922 (*************************************************************************
1923 *
\91S
\8ap
\94¼
\8ap
\82Ð
\82ç
\82ª
\82È
\82©
\82½
\82©
\82È
\82ð
\8bæ
\95Ê
\82µ
\82È
\82¢
\90¦
\82¢Pos
1924 *************************************************************************)
1925 function TGikoSys.VaguePos(const Substr, S: string): Integer;
1927 Result := Pos(ZenToHan(Substr), ZenToHan(S));
1930 function TGikoSys.BoolToInt(b: Boolean): Integer;
1932 Result := IfThen(b, 1, 0);
1935 function TGikoSys.IntToBool(i: Integer): Boolean;
1940 //gzip
\82Å
\88³
\8fk
\82³
\82ê
\82½
\82Ì
\82ð
\96ß
\82·
1941 function TGikoSys.GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
1945 GZipStream: TGzipDecompressStream;
1946 TextStream: TStringStream;
1947 buf: array[0..BUF_SIZE - 1] of Byte;
1953 TextStream := TStringStream.Create('');
1955 //
\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¢)
1956 // if LowerCase(Trim(ContentEncoding)) = 'gzip' then begin
1957 if AnsiPos('gzip', LowerCase(Trim(ContentEncoding))) > 0 then begin
1958 ResStream.Position := 0;
1959 GZipStream := TGzipDecompressStream.Create(TextStream);
1962 FillChar(buf, BUF_SIZE, 0);
1963 cnt := ResStream.Read(buf, BUF_SIZE);
1965 GZipStream.Write(buf, BUF_SIZE);
1971 ResStream.Position := 0;
1973 FillChar(buf, BUF_SIZE, 0);
1974 cnt := ResStream.Read(buf, BUF_SIZE);
1976 TextStream.Write(buf, BUF_SIZE);
1980 //NULL
\95¶
\8e\9a\82ð"*"
\82É
\82·
\82é
1981 s := TextStream.DataString;
1983 while (i > 0) and (s[i] = #0) do
1988 while i <> 0 do begin
1998 procedure TGikoSys.LoadKeySetting(ActionList: TActionList);
2000 STD_SEC = 'KeySetting';
2006 SecList: TStringList;
2007 Component: TComponent;
2009 if not FileExists(GetConfigDir + KEY_SETTING_FILE_NAME) then
2011 SecList := TStringList.Create;
2012 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
2014 ini.ReadSection(STD_SEC, SecList);
2015 for i := 0 to SecList.Count - 1 do begin
2016 ActionName := SecList[i];
2017 ActionKey := ini.ReadInteger(STD_SEC, ActionName, -1);
2018 if ActionKey <> -1 then begin
2019 Component := ActionList.Owner.FindComponent(ActionName);
2020 if TObject(Component) is TAction then begin
2021 TAction(Component).ShortCut := ActionKey;
2031 procedure TGikoSys.SaveKeySetting(ActionList: TActionList);
2033 STD_SEC = 'KeySetting';
2038 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
2040 for i := 0 to ActionList.ActionCount - 1 do begin
2041 if ActionList.Actions[i].Tag = -1 then
2043 ini.WriteInteger(STD_SEC, ActionList.Actions[i].Name, TAction(ActionList.Actions[i]).ShortCut);
2052 procedure TGikoSys.CreateProcess(const AppPath: string; const Param: string);
2054 PI: TProcessInformation;
2058 Path := '"' + AppPath + '"';
2060 Path := Path + ' ' + Param;
2062 SI.Cb := SizeOf(Si);
2063 SI.lpReserved := nil;
2064 SI.lpDesktop := nil;
2067 SI.cbReserved2 := 0;
2068 SI.lpReserved2 := nil;
2070 Windows.CreateProcess(nil,
2082 procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
2086 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2087 gbtUserApp, gbtAuto:
2088 if (Setting.URLApp) and (FileExists(Setting.URLAppFile)) then
2089 GikoSys.CreateProcess(Setting.URLAppFile, URL)
2091 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2095 function TGikoSys.HTMLDecode(const AStr: String): String;
2097 Sp, Rp, Cp, Tp: PChar;
2102 SetLength(Result, Length(AStr));
2104 Rp := PChar(Result);
2107 while Sp^ <> #0 do begin
2113 'a': if AnsiStrPos(Sp, 'amp;') = Sp then
2119 'g': if (AnsiStrPos(Sp, 'lt;') = Sp) or (AnsiStrPos(Sp, 'gt;') = Sp) then
2123 while (Sp^ <> ';') and (Sp^ <> #0) do
2130 'q': if AnsiStrPos(Sp, 'quot;') = Sp then
2138 Num := IsNumeric(Copy(Tp, 1, 1));
2139 while (Sp^ <> ';') and (Sp^ <> #0) do begin
2140 if (Num) and (not IsNumeric(Copy(Sp, 1, 1))) then
2144 SetString(S, Tp, Sp - Tp);
2149 //raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2150 //[Cp^ + Sp^, Cp - PChar(AStr)])
2160 // on E:EConvertError do
2161 // raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2162 // [Cp^ + Sp^, Cp - PChar(AStr)])
2164 SetLength(Result, Rp - PChar(Result));
2167 function TGikoSys.GetHRefText(s: string): string;
2177 Index := AnsiPos('href', LowerCase(s));
2180 s := Trim(Copy(s, Index + 4, Length(s)));
2181 s := Trim(Copy(s, 2, Length(s)));
2183 //
\8en
\82ß
\82Ì
\95¶
\8e\9a\82ª'"'
\82È
\82ç
\8eæ
\82è
\8f\9c\82
2184 if Copy(s, 1, 1) = '"' then begin
2185 s := Trim(Copy(s, 2, Length(s)));
2188 Index := AnsiPos('"', s);
2189 if Index <> 0 then begin
2190 //'"'
\82Ü
\82ÅURL
\82Æ
\82·
\82é
2191 s := Copy(s, 1, Index - 1);
2193 //'"'
\82ª
\96³
\82¯
\82ê
\82Î
\83X
\83y
\81[
\83X
\82©">"
\82Ì
\91\81\82¢
\95û
\82Ü
\82Å
\82ðURL
\82Æ
\82·
\82é
2194 Index := AnsiPos(' ', s);
2195 Index2 := AnsiPos('>', s);
2198 if Index > Index2 then
2201 s := Copy(s, 1, Index - 1)
2203 //
\82±
\82ê
\88È
\8fã
\82à
\82¤
\92m
\82ç
\82ñ
\82Ê
2209 //
\83z
\83X
\83g
\96¼
\82ª
\82Q
\82\83\82\88\82©
\82Ç
\82¤
\82©
\83`
\83F
\83b
\83N
\82·
\82é
2210 function TGikoSys.Is2chHost(Host: string): Boolean;
2212 HOST_NAME: array[0..1] of string = ('2ch.net', 'bbspink.com');
2218 OutputDebugString(pchar(HOST_NAME[0]));
2219 for i := 0 to Length(HOST_NAME) - 1 do begin
2220 Len := Length(HOST_NAME[i]);
2221 if AnsiPos(HOST_NAME[i], Host) = (Length(Host) - Length(HOST_NAME[i]) + 1) then begin
2228 function TGikoSys.Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
2230 READ_PATH: string = '/test/read.cgi/';
2231 OLD_READ_PATH: string = '/test/read.cgi?';
2232 KAKO_PATH: string = '/kako/';
2242 Index := AnsiPos(READ_PATH, path);
2243 if Index <> 0 then begin
2244 s := Copy(path, Length(READ_PATH) + 1, Length(path));
2245 BBSID := GetTokenIndex(s, '/', 0);
2246 BBSKey := GetTokenIndex(s, '/', 1);
2249 Result := (BBSID <> '') or (BBSKey <> '');
2252 Index := AnsiPos(KAKO_PATH, path);
2253 if Index <> 0 then begin
2254 s := Copy(path, 2, Length(path));
2255 BBSID := GetTokenIndex(s, '/', 0);
2256 if (BBSID = 'log') and (GetTokenIndex(s, '/', 2) = 'kako') then
2257 BBSID := GetTokenIndex(s, '/', 1);
2258 BBSKey := ChangeFileExt(Document, '');
2259 Result := (BBSID <> '') or (BBSKey <> '');
2262 Index := AnsiPos('read.cgi?', URL);
2263 if Index <> 0 then begin
2264 SList := TStringList.Create;
2267 // s := HTMLDecode(Document);
2268 ExtractHTTPFields(['?', '&'], [], PChar(URL), SList, False);
2269 BBSID := SList.Values['bbs'];
2270 BBSKey := SList.Values['key'];
2271 Result := (BBSID <> '') or (BBSKey <> '');
2282 function TGikoSys.Parse2chURL2(URL: string): TPathRec;
2294 URL := Trim(LowerCase(URL));
2299 Result.FFirst := False;
2300 Result.FStBegin := False;
2301 Result.FToEnd := False;
2302 Result.FDone := False;
2307 FAWKStr.RegExp := 'http://.+\.(2ch\.net|bbspink\.com)/';
2308 if FAWKStr.Match(FAWKStr.ProcessEscSeq(URL), RStart, RLength) = 0 then
2310 s := Copy(URL, RStart + RLength - 1, Length(URL));
2312 //
\95W
\8f\80\8f\91\8e®
2313 //
\8dÅ
\8cã
\82Íl50, 10, 10-20, 10n, 10-20n, -10, 10-, 10n-
\82È
\82Ç
2314 //http://xxx.2ch.net/test/read.cgi/bbsid/1000000000/
2315 FAWKStr.RegExp := '/test/read.cgi/.+/[0-9]+/.*';
2316 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2317 s := Copy(s, 15, Length(s));
2319 SList := TStringList.Create;
2322 FAWKStr.RegExp := '/';
2323 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2324 Result.FBBS := SList[1];
2325 Result.FKey := SList[2];
2326 if SList.Count >= 3 then
2334 FAWKStr.LineSeparator := mcls_CRLF;
2335 FAWKStr.RegExp := '-';
2336 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) = 0 then begin
2337 Result.FFirst := True;
2339 FAWKStr.RegExp := 'l[0-9]+';
2340 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2341 Result.FFirst := True;
2343 for i := 0 to SList.Count - 1 do begin
2344 if Trim(SList[i]) = '' then begin
2346 Result.FStBegin := True;
2347 if i = (SList.Count - 1) then
2348 Result.FToEnd := True;
2349 end else if IsNumeric(SList[i]) then begin
2350 wkInt := StrToInt(SList[i]);
2351 wkMax := Max(wkMax, wkInt);
2355 wkMin := Min(wkMin, wkInt);
2356 end else if Trim(SList[i]) = 'n' then begin
2357 Result.FFirst := True;
2359 FAWKStr.RegExp := '^n[0-9]+$|^[0-9]+n$';
2360 if FAWKStr.Match(FAWKStr.ProcessEscSeq(SList[i]), RStart, RLength) > 0 then begin
2361 if Copy(SList[i], 1, 1) = 'n' then
2362 wkInt := StrToInt(Copy(SList[i], 2, Length(SList[i])))
2364 wkInt := StrToInt(Copy(SList[i], 1, Length(SList[i]) - 1));
2365 Result.FFirst := True;
2366 wkMax := Max(wkMax, wkInt);
2370 wkMin := Min(wkMin, wkInt);
2374 if Result.FStBegin and (not Result.FToEnd) then
2376 else if (not Result.FStBegin) and Result.FToEnd then
2378 else if (not Result.FStBegin) and (not Result.FToEnd) then begin
2379 Result.FSt := wkMin;
2380 Result.FTo := wkMax;
2382 //Result.FSt := wkMin;
2383 //Result.FTo := wkMax;
2389 Result.FDone := True;
2393 //
\90Vkako
\8f\91\8e®
2394 //http://server.2ch.net/ITA_NAME/kako/1000/10000/1000000000.html
2395 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+/[0-9]+\.html';
2396 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2397 SList := TStringList.Create;
2400 FAWKStr.RegExp := '/';
2401 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2402 Result.FBBS := SList[1];
2403 Result.FKey := ChangeFileExt(SList[5], '');
2404 Result.FFirst := True;
2410 Result.FDone := True;
2414 //
\8b\8ckako
\8f\91\8e®
2415 //http://server.2ch.net/ITA_NAME/kako/999/999999999.html
2416 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+\.html';
2417 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2418 SList := TStringList.Create;
2421 FAWKStr.RegExp := '/';
2422 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 5 then begin
2423 Result.FBBS := SList[1];
2424 Result.FKey := ChangeFileExt(SList[4], '');
2425 Result.FFirst := True;
2431 Result.FDone := True;
2435 //log
\8by
\82Ñlog2
\8f\91\8e®
2436 //http://server.2ch.net/log/ITA_NAME/kako/999/999999999.html
2437 //http://server.2ch.net/log2/ITA_NAME/kako/999/999999999.html
2438 FAWKStr.RegExp := '/log2?/.+/kako/[0-9]+/[0-9]+\.html';
2439 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2440 SList := TStringList.Create;
2443 FAWKStr.RegExp := '/';
2444 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2445 Result.FBBS := SList[2];
2446 Result.FKey := ChangeFileExt(SList[5], '');
2447 Result.FFirst := True;
2453 Result.FDone := True;
2458 //
\8b\8cURL
\8f\91\8e®
2459 //http://server.2ch.net/test/read.cgi?bbs=ITA_NAME&key=1000000000&st=1&to=5&nofirst=true
2460 FAWKStr.RegExp := '/test/read\.cgi\?';
2461 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2462 s := Copy(s, 16, Length(s));
2463 SList := TStringList.Create;
2466 FAWKStr.RegExp := '&';
2467 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2468 Result.FFirst := True;
2469 for i := 0 to SList.Count - 1 do begin
2470 if Pos('bbs=', SList[i]) = 1 then begin
2471 Result.FBBS := Copy(SList[i], 5, Length(SList[i]));
2472 end else if Pos('key=', SList[i]) = 1 then begin
2473 Result.FKey := Copy(SList[i], 5, Length(SList[i]));
2474 end else if Pos('st=', SList[i]) = 1 then begin
2475 wk := Copy(SList[i], 4, Length(SList[i]));
2476 if IsNumeric(wk) then
2477 Result.FSt := StrToInt(wk)
2478 else if wk = '' then
2479 Result.FStBegin := True;
2480 end else if Pos('to=', SList[i]) = 1 then begin
2481 wk := Copy(SList[i], 4, Length(SList[i]));
2482 if IsNumeric(wk) then
2483 Result.FTo := StrToInt(wk)
2484 else if wk = '' then
2485 Result.FToEnd := True;
2486 end else if Pos('nofirst=', SList[i]) = 1 then begin
2487 Result.FFirst := False;
2496 if (Result.FBBS <> '') and (Result.FKey <> '') then begin
2497 Result.FDone := True;
2503 procedure TGikoSys.ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
2513 URI := TIdURI.Create(URL);
2515 Protocol := URI.Protocol;
2518 Document := URI.Document;
2520 Bookmark := URI.Bookmark;
2526 function TGikoSys.GetVersionBuild: Integer;
2528 FixedFileInfo: PVSFixedFileInfo;
2529 VersionHandle, VersionSize: DWORD;
2530 pVersionInfo: Pointer;
2535 AppFile := Application.ExeName;
2536 VersionSize := GetFileVersionInfoSize(pChar(AppFile), VersionHandle);
2537 if VersionSize = 0 then
2539 GetMem(pVersionInfo, VersionSize);
2541 if GetFileVersionInfo(PChar(AppFile),VersionHandle,VersionSize, pVersionInfo) then
2542 if VerQueryValue(pVersionInfo, '\', Pointer(FixedFileInfo), ItemLen) then
2543 Result := LOWORD(FixedFileInfo^.dwFileVersionLS);
2545 FreeMem(pVersionInfo, VersionSize);
2550 GikoSys := TGikoSys.Create;
2553 if GikoSys <> nil then begin