Develop and Download Open Source Software

Browse CVS Repository

Contents of /gikonavigoeson/gikonavi/GikoSystem.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.37 - (show annotations) (download) (as text)
Thu Sep 25 19:28:42 2003 UTC (20 years, 6 months ago) by yoffy
Branch: MAIN
Changes since 1.36: +2 -1 lines
File MIME type: text/x-pascal
・指摘のあった
 o スレッドの名前(<div class="title">...)が自動で出力されているので
 <a name="top"></a>だけを出力してください。
 o Bookmark.htmlがない場合には、<a name="koko"></a>を出力してください。
の修正。

1 unit GikoSystem;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
7 ComCtrls, IniFiles, ShellAPI, ActnList, Math,
8 {$IF Defined(DELPRO) }
9 SHDocVw,
10 MSHTML,
11 {$ELSE}
12 SHDocVw_TLB,
13 MSHTML_TLB,
14 {$IFEND}
15 {HttpApp,} YofUtils, URLMon, IdGlobal, IdURI, {Masks,}
16 Setting, BoardGroup, gzip, Dolib, bmRegExp, AbonUnit;
17
18 type
19 //BBS?帥?ゃ??
20 TGikoBBSType = (gbt2ch);
21 //???違?帥?ゃ??
22 TGikoLogType = (glt2chNew, glt2chOld);
23 //?<???祉?若?吾?≪?ゃ?潟??/span>
24 TGikoMessageIcon = (gmiOK, gmiSAD, gmiNG, gmiWhat, gmiNone);
25 //URL???若???潟???????吟?帥?ゃ??
26 TGikoBrowserType = (gbtIE, gbtUserApp, gbtAuto);
27
28
29 TStrTokSeparator = set of Char;
30 TStrTokRec = record
31 Str: string;
32 Pos: Integer;
33 end;
34
35 //?ゃ?潟???????鴻???<?ゃ?????潟?若??
36 TIndexRec = record
37 FNo: Integer;
38 FFileName: string;
39 FTitle: string;
40 FCount: Integer;
41 FSize: Integer;
42 // FRoundNo: Integer;
43 FRoundDate: TDateTime;
44 FLastModified: TDateTime;
45 FKokomade: Integer;
46 FNewReceive: Integer;
47 FMishiyou: Boolean; //??戎??/span>
48 FUnRead: Boolean;
49 FScrollTop: Integer;
50 //Index Ver 1.01
51 FAllResCount: Integer;
52 FNewResCount: Integer;
53 FAgeSage: TGikoAgeSage;
54 end;
55
56 //?泣???吾?с???????潟?若??
57 TSubjectRec = record
58 FFileName: string;
59 FTitle: string;
60 FCount: Integer;
61 end;
62
63 //???鴻???潟?若??
64 TResRec = record
65 FTitle: string;
66 FMailTo: string;
67 FName: string;
68 FDateTime: string;
69 FBody: string;
70 FType: TGikoLogType;
71 end;
72
73 //URLPath???潟?若??
74 TPathRec = record
75 FBBS: string; //BBSID
76 FKey: string; //ThreadID
77 FSt: Integer; //??紮????合??/span>
78 FTo: Integer; //腟?篋????合??/span>
79 FFirst: Boolean; //>>1??;腓?/span>
80 FStBegin: Boolean; //1??茵?ず
81 FToEnd: Boolean; //????緇??障?ц;腓?/span>
82 FDone: Boolean; //????
83 end;
84
85 TGikoSys = class(TObject)
86 private
87 { Private 絎h? }
88 FSetting: TSetting;
89 FDolib: TDolib;
90 FAWKStr: TAWKStr;
91 // FExitWrite: TStringList;
92 // function StrToFloatDef(s: string; Default: Double): Double;
93
94 public
95 { Public 絎h? }
96 FAbon : TAbon;
97 FSelectResFilter : TAbon;
98 constructor Create;
99
100 destructor Destroy; override;
101
102
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;
110
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;
123
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);
130
131 procedure CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
132 function AddAnchorTag(s: string): string;
133
134 function DivideSubject(Line: string): TSubjectRec;
135 function DivideStrLine(Line: string): TResRec;
136
137 property Setting: TSetting read FSetting write FSetting;
138 property Dolib: TDolib read FDolib write FDolib;
139
140 function UrlToID(url: string): string;
141 function UrlToServer(url: string): string;
142
143 function StrTokFirst(const s:string; const sep:TStrTokSeparator; var Rec:TStrTokRec):string;
144 function StrTokNext(const sep:TStrTokSeparator; var Rec:TStrTokRec): string;
145
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;
151
152 function ReadThreadFile(FileName: string; Line: Integer): string;
153
154 procedure MenuFont(Font: TFont);
155
156 function RemoveToken(var s:string;delimiter:string):string;
157 function GetTokenIndex(s: string; delimiter: string; index: Integer): string;
158
159 function DeleteLink(const s: string): string;
160
161 function GetShortName(const LongName: string; ALength: integer): string;
162 function ConvRes(const Body, Bbs, Key, ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
163
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;
180 end;
181
182 var
183 GikoSys: TGikoSys;
184 const
185 LENGTH_RESTITLE = 40;
186 ZERO_DATE: Integer = 25569;
187 BETA_VERSION_NAME_E = 'beta';
188 BETA_VERSION_NAME_J = '鐓?鐓?鐓?';
189 BETA_VERSION = 41;
190 BETA_VERSION_BUILD = ''; //debug??????/span>
191
192 implementation
193
194 uses
195 Giko, RoundData;
196
197 const
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';
218
219 (*************************************************************************
220 *GikoSys?潟?潟?鴻????????/span>
221 *************************************************************************)
222 constructor TGikoSys.Create;
223 begin
224 FSetting := TSetting.Create;
225 FDolib := TDolib.Create;
226 FAWKStr := TAWKStr.Create(nil);
227 if DirectoryExists(GetConfigDir) = false then begin
228 CreateDir(GetConfigDir);
229 end;
230 FAbon := TAbon.Create;
231 FAbon.Setroot(GetConfigDir+NGWORDs_DIR_NAME);
232 //FAbon.SetNGwordpath(DEFAULT_NGWORD_FILE_NAME);
233 FAbon.GoHome;
234 FSelectResFilter := TAbon.Create;
235 // 腟???莨若????????サ??筝?荀с??荀????????祉???????????т????????????/span>
236 FSelectResFilter.AbonString := '';
237 end;
238
239 (*************************************************************************
240 *GikoSys???鴻????????/span>
241 *************************************************************************)
242 destructor TGikoSys.Destroy;
243 var
244 i: Integer;
245 FileList: TStringList;
246 begin
247 //?鴻?????????若?帥???<?ゃ?????贋??/span>
248 // FlashExitWrite;
249
250 // FExitWrite.Free;
251 FAWKStr.Free;
252 FSetting.Free;
253 FDolib.Free;
254
255 //???潟??????TML??????/span>
256 FileList := TStringList.Create;
257 try
258 GetFileList(GetTempFolder, '*.html', FileList, False, True);
259 for i := 0 to FileList.Count - 1 do begin
260 DeleteFile(FileList[i]);
261 end;
262 finally
263 FileList.Free;
264 end;
265 inherited;
266 end;
267
268 (*************************************************************************
269 *??絖????医????с????/span>
270 *************************************************************************)
271 {$HINTS OFF}
272 function TGikoSys.IsNumeric(s: string): boolean;
273 var
274 e: integer;
275 v: integer;
276 begin
277 Val(s, v, e);
278 Result := e = 0;
279 end;
280 {$HINTS ON}
281
282 (*************************************************************************
283 *??絖???羌???絨?亥?号?医????с????/span>
284 *************************************************************************)
285 function TGikoSys.IsFloat(s: string): boolean;
286 var
287 v: Extended;
288 begin
289 Result := TextToFloat(PChar(s), v, fvExtended);
290 end;
291
292 (*************************************************************************
293 *???若?????<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
294 *************************************************************************)
295 function TGikoSys.GetBoardFileName: string;
296 begin
297 Result := GetAppDir + CONFIG_DIR_NAME + '\' + BOARD_FILE_NAME;
298 end;
299
300 (*************************************************************************
301 *???若?????<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
302 *************************************************************************)
303 function TGikoSys.GetCustomBoardFileName: string;
304 begin
305 Result := GetAppDir + CONFIG_DIR_NAME + '\' + CUSTOMBOARD_FILE_NAME;
306 end;
307
308 (*************************************************************************
309 *???潟???????????????弱????緇?
310 *************************************************************************)
311 function TGikoSys.GetHtmlTempFileName: string;
312 begin
313 Result := TEMP_FOLDER;
314 end;
315
316
317 (*************************************************************************
318 *絎?茵????<?ゃ????????????緇?
319 *************************************************************************)
320 function TGikoSys.GetAppDir: string;
321 begin
322 Result := ExtractFilePath(Application.ExeName);
323 end;
324
325 (*************************************************************************
326 *TempHtml???<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
327 *************************************************************************)
328 function TGikoSys.GetTempFolder: string;
329 begin
330 Result := GetAppDir + TEMP_FOLDER;
331 end;
332
333 (*************************************************************************
334 *sent.ini???<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
335 *************************************************************************)
336 function TGikoSys.GetSentFileName: string;
337 begin
338 Result := GetAppDir + SENT_FILE_NAME;
339 end;
340
341 (*************************************************************************
342 *outbox.ini???<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
343 *************************************************************************)
344 function TGikoSys.GetOutBoxFileName: string;
345 begin
346 Result := GetAppDir + OUTBOX_FILE_NAME;
347 end;
348
349 (*************************************************************************
350 *Config??????????緇?
351 *************************************************************************)
352 function TGikoSys.GetConfigDir: string;
353 begin
354 Result := IncludeTrailingPathDelimiter(GetAppDir + CONFIG_DIR_NAME);
355 end;
356
357 function TGikoSys.GetStyleSheetDir: string;
358 begin
359 Result := IncludeTrailingPathDelimiter(GetConfigDir + CSS_DIR_NAME);
360 end;
361
362 function TGikoSys.GetSkinDir: string;
363 begin
364 Result := IncludeTrailingPathDelimiter(GetConfigDir + SKIN_DIR_NAME);
365 end;
366
367 (*************************************************************************
368 *URL??篏???(?潟??????
369 *************************************************************************)
370 function TGikoSys.GetURL(BBSID: string; FileName: string): string;
371 var
372 Board: TBoard;
373 begin
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
378 end;
379
380 // UserAgent??緇?
381 function TGikoSys.GetUserAgent: string;
382 begin
383 if Dolib.Connected then begin
384 Result := Format('%s %s/%s%d%s', [
385 Dolib.UserAgent,
386 APP_NAME,
387 //MAJOR_VERSION,
388 //MINOR_VERSION,
389 BETA_VERSION_NAME_E,
390 BETA_VERSION,
391 BETA_VERSION_BUILD]);
392 end else begin
393 Result := Format('%s/%s %s/%s%d%s', [
394 USER_AGENT,
395 Dolib.Version,
396 APP_NAME,
397 //MAJOR_VERSION,
398 //MINOR_VERSION,
399 BETA_VERSION_NAME_E,
400 BETA_VERSION,
401 BETA_VERSION_BUILD]);
402 end;
403 end;
404
405 (*************************************************************************
406 *鐚??<?????????劫????糸??
407 *************************************************************************)
408 function TGikoSys.Get2chDate(aDate: TDateTime): string;
409 var
410 d1: TDateTime;
411 d2: TDateTime;
412 begin
413 d1 := EncodeDate(1970, 1, 1);
414 d2 := aDate - EncodeTime(9, 0, 0, 0);
415 Result := FloatToStr(Trunc((d2 - d1) * 24 * 60 * 60));
416 end;
417
418
419 function TGikoSys.IntToDateTime(val: Int64): TDateTime;
420 var
421 d1: tdatetime;
422 d2: tdatetime;
423 begin
424 d1 := EncodeDate(1970, 1, 1);
425 d2 := (val * 1000) / (24 * 60 * 60 * 1000);
426 Result := d1 + d2;
427 end;
428
429 function TGikoSys.DateTimeToInt(ADate: TDateTime): Integer;
430 var
431 d: TDateTime;
432 c: Currency;
433 begin
434 d := EncodeDate(1970, 1, 1);
435 c := (ADate - d) * 24 * 60 * 60;
436 Result := Trunc(c);
437 end;
438
439
440 (*************************************************************************
441 *Subject???<?ゃ??ead
442 *************************************************************************)
443 procedure TGikoSys.ReadSubjectFile(Board: TBoard);
444 var
445 ThreadItem: TThreadItem;
446 FileName: string;
447 FileList: TStringList;
448 TmpFileList: TStringList;
449 // SrchRec: TSearchRec;
450 // R: integer;
451 Index: Integer;
452 sl: TStringList;
453 i: Integer;
454 Rec: TIndexRec;
455 UnRead: Integer;
456 // TmpUpdate: Boolean;
457 ini: TMemIniFile;
458 ResRec: TResRec;
459 RoundItem: TRoundItem;
460 idx: Integer;
461 begin
462 Board.Clear;
463 UnRead := 0;
464 // TmpUpdate := False;
465
466 FileName := Board.GetFolderIndexFileName;
467 if not FileExists(FileName) then CreateThreadDat(Board);
468 // if not FileExists(FileName) then Exit;
469
470 //IsLogFile??AT???<?ゃ?????鴻??
471 FileList := TStringList.Create;
472 FileList.Sorted := True;
473 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False, False);
474
475 //?????医幻腟?篋?????mp???<?ゃ?????鴻??
476 TmpFileList := TStringList.Create;
477 TmpFileList.Sorted := True;
478 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, False, False);
479
480 { R := FindFirst(ExtractFileDir(Board.GetFolderIndexFileName) + '\*.dat', 0, SrchRec);
481 while R = 0 do begin
482 FileList.Add(SrchRec.Name);
483 R := FindNext(SrchRec);
484 end;
485 FindClose(SrchRec);}
486
487 sl := TStringList.Create;
488 try
489 if FileExists(FileName) then
490 sl.LoadFromFile(FileName);
491
492 //鐚?茵???????鐚?鐚?茵????????若?吾?с?鰹?
493 for i := 1 to sl.Count - 1 do begin
494 Rec := ParseIndexLine(sl[i]);
495
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;
515
516 //IsLogFile???с????/span>
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);
522 end;
523 end;
524
525 //綏≦?????鴻?????????????綏≦???????違?祉????
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;
532 end;
533 end;
534
535 //?????医幻腟?篋??????с????/span>
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'));
539 try
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)));
551 finally
552 ini.Free;
553 end;
554 TmpFileList.Delete(Index);
555 end;
556 end;
557
558 ThreadItem.EndUpdate;
559 Board.Add(ThreadItem);
560
561 // if (ThreadItem.IsLogFile) and (ThreadItem.Count > ThreadItem.Kokomade) then
562 if (ThreadItem.IsLogFile) and (ThreadItem.UnRead) then
563 Inc(UnRead);
564 end;
565 if UnRead <> Board.UnRead then
566 Board.UnRead := UnRead;
567
568 //?ゃ?潟???????鴻???<???c?????違??菴遵??鐚??????ゃ?潟???????劫?綽?鐚?
569 for i := 0 to FileList.Count - 1 do begin
570 FileName := ExtractFileDir(Board.GetFolderIndexFileName) + '\' + FileList[i];
571
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);
592 end;
593 finally
594 sl.Free;
595 end;
596 FileList.Free;
597 TmpFileList.Free;
598 Board.IsThreadDatRead := True;
599 end;
600
601 (*************************************************************************
602 *?鴻???????ゃ?潟???????鴻???<?ゃ??Folder.idx)篏???
603 *************************************************************************)
604 procedure TGikoSys.CreateThreadDat(Board: TBoard);
605 var
606 i: integer;
607 s: string;
608 SubjectList: TStringList;
609 sl: TStringList;
610 Rec: TSubjectRec;
611 FileName: string;
612 cnt: Integer;
613 begin
614 if not FileExists(Board.GetSubjectFileName) then Exit;
615 FileName := Board.GetFolderIndexFileName;
616
617 SubjectList := TStringList.Create;
618 try
619 SubjectList.LoadFromFile(Board.GetSubjectFileName);
620 sl := TStringList.Create;
621 try
622 cnt := 1;
623 sl.Add(FOLDER_INDEX_VERSION);
624 for i := 0 to SubjectList.Count - 1 do begin
625 Rec := DivideSubject(SubjectList[i]);
626
627 if (Trim(Rec.FFileName) = '') or (Trim(Rec.FTitle) = '') then
628 Continue;
629
630 s := Format('%x', [cnt]) + #1 //???/span>
631 + Rec.FFileName + #1 //???<?ゃ????
632 + Rec.FTitle + #1 //?帥?ゃ????/span>
633 + Format('%x', [Rec.FCount]) + #1 //?????潟??
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 //??戎??/span>
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
645
646 sl.Add(s);
647 inc(cnt);
648 end;
649 sl.SaveToFile(FileName);
650 finally
651 sl.Free;
652 end;
653 finally
654 SubjectList.Free;
655 end;
656 end;
657
658 (*************************************************************************
659 *?鴻???????ゃ?潟????????Thread.dat)?吾??莨若??/span>
660 *Public
661 *************************************************************************)
662 procedure TGikoSys.WriteThreadDat(Board: TBoard);
663 //const
664 // Values: array[Boolean] of string = ('0', '1');
665 var
666 i: integer;
667 FileName: string;
668 sl: TStringList;
669 s: string;
670 FileList: TStringList;
671 begin
672 if not Board.IsThreadDatRead then
673 Exit;
674 FileName := Board.GetFolderIndexFileName;
675 ForceDirectoriesEx(Board.ParentCategory.ParentBBS2ch.GetLogFolder + Board.BBSID);
676
677 sl := TStringList.Create;
678 try
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;
683
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 //??戎??/span>
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)]);
699
700 sl.Add(s);
701 end;
702
703 sl.SaveToFile(FileName);
704
705 FileList := TStringList.Create;
706 try
707 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', FileList, False, True);
708 for i := 0 to FileList.Count - 1 do begin
709 DeleteFile(FileList[i]);
710 end;
711 finally
712 FileList.Free;
713 end;
714 finally
715 sl.Free;
716 end;
717 end;
718
719 function TGikoSys.ParseIndexLine(Line: string): TIndexRec;
720 var
721 s: string;
722 i: Integer;
723 begin
724 for i := 0 to 14 do begin
725 s := GetTokenIndex(Line, #1, i);
726 case i of
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);
736 9: ; //??戎??/span>
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));
742 end;
743 end;
744 end;
745
746 //??絎???????????????絎????<?ゃ???荀с????緇?????
747 // ListFiles('c:\', '*.txt', list, True);
748 procedure TGikoSys.GetFileList(Path: string; Mask: string; List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
749 var
750 rc: Integer;
751 SearchRec : TSearchRec;
752 s: string;
753 begin
754 Path := IncludeTrailingPathDelimiter(Path);
755 rc := FindFirst(Path + '*.*', faAnyfile, SearchRec);
756 try
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)
762
763 if (SearchRec.Attr and faDirectory = 0) and (MatchesMask(s, Mask)) then
764 if IsPathAdd then
765 List.Add(s)
766 else
767 List.Add(SearchRec.Name);
768 if SubDir and (SearchRec.Attr and faDirectory > 0) then
769 GetFileList(s, Mask, List, True, IsPathAdd);
770 end;
771 rc := FindNext(SearchRec);
772 end;
773 finally
774 SysUtils.FindClose(SearchRec);
775 end;
776 end;
777
778 //??絎????????????????c?????????荀с????緇?????
779 procedure TGikoSys.GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
780 var
781 rc: Integer;
782 SearchRec : TSearchRec;
783 s: string;
784 begin
785 Path := IncludeTrailingPathDelimiter(Path);
786 rc := FindFirst(Path + '*.*', faDirectory, SearchRec);
787 try
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)
793
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);
798 end;
799 rc := FindNext(SearchRec);
800 end;
801 finally
802 SysUtils.FindClose(SearchRec);
803 end;
804 end;
805
806 procedure TGikoSys.CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
807 var
808 i: integer;
809 No: string;
810 //bufList : TStringList;
811 ReadList: TStringList;
812 SaveList: TStringList;
813 CSSFileName: string;
814 BBSID: string;
815 FileName: string;
816 NewReceiveNo: Integer;
817 Res: TResRec;
818 SkinHeaderFileName: string;
819 SkinNewResFileName: string;
820 SkinResFileName: string;
821 SkinFooterFileName: string;
822 SkinBookmarkFileName: string;
823 SkinNewmarkFileName: string;
824 SkinNewRes: string;
825 SkinRes: string;
826 SizeByte: Integer;
827
828 // ?鴻???潟??茯??粋昭?帥???ゃ??臀??????
829 function LoadSkin( fileName: string ): string;
830 var
831 Skin: TStringList;
832 begin
833
834 Skin := TStringList.Create;
835 try
836 Skin.LoadFromFile( fileName );
837
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 - 1 ), [rfReplaceAll] );
842 Skin.Text := StringReplace( Skin.Text, '<NEWRESCOUNT/>', IntToStr( ThreadItem.NewResCount ), [rfReplaceAll] );
843 Skin.Text := StringReplace( Skin.Text, '<ALLRESCOUNT/>', IntToStr( ThreadItem.AllResCount ), [rfReplaceAll] );
844
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] );
849
850 //----- ?????????????<????????篋????????潟?<?潟???≪??????????????
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 - 1 ), [rfReplaceAll] );
855 Skin.Text := StringReplace( Skin.Text, '&NEWRESCOUNT', IntToStr( ThreadItem.NewResCount ), [rfReplaceAll] );
856 Skin.Text := StringReplace( Skin.Text, '&ALLRESCOUNT', IntToStr( ThreadItem.AllResCount ), [rfReplaceAll] );
857
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 //----- ?????障??/span>
863
864 Result := Skin.Text;
865 finally
866 Skin.Free;
867 end;
868
869 end;
870
871 // ???鴻???ゃ??臀??????
872 function ReplaceRes( skin: string ): string;
873 begin
874
875 try
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/>', '<b>' + Res.FName + '</b>', [rfReplaceAll] );
880 Skin := StringReplace( Skin, '<MAILNAME/>',
881 '<a href="mailo:' + Res.FMailTo + '"><b>' + Res.FName + '</b></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] );
885
886 //----- ???<????????篋????????潟?<?潟???≪??????????????
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', '<b>' + Res.FName + '</b>', [rfReplaceAll] );
891 Skin := StringReplace( Skin, '&MAILNAME',
892 '<a href="mailo:' + Res.FMailTo + '"><b>' + Res.FName + '</b></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 //----- ?????障??/span>
897
898 Result := Skin;
899 finally
900 end;
901
902 end;
903
904 begin
905 ShortDayNames[1] := '??#39;; ShortDayNames[2] := '??';
906 ShortDayNames[3] := '??#39;; ShortDayNames[4] := '羂?#39;;
907 ShortDayNames[5] := '??#39;; ShortDayNames[6] := '??';
908 ShortDayNames[7] := '??';
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;
917 try
918 if ThreadItem.IsLogFile then begin
919 ReadList.LoadFromFile(FileName);
920 FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
921 FAbon.Execute(ReadList); // ???若????????/span>
922 FSelectResFilter.Execute(ReadList); //???鴻?????c???帥???潟?違??????
923 Res := DivideStrLine(ReadList[0]);
924 Res.FTitle := StringReplace(Res.FTitle, '鐚?鐔?', ',', [rfReplaceAll]);
925 sTitle := Res.FTitle;
926
927 end else begin
928 sTitle := StringReplace(ThreadItem.Title, '鐚?鐔?', ',', [rfReplaceAll]);
929 end;
930 SaveList := TStringList.Create;
931 try
932 doc.open;
933 doc.charset := 'Shift_JIS';
934
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 // ?鴻???割戎??/span>
946
947 // ?鴻???潟??┃絎?
948 try
949 SaveList.Add( LoadSkin( SkinHeaderFileName ) );
950 SkinNewRes := LoadSkin( SkinNewResFileName );
951 SkinRes := LoadSkin( SkinResFileName );
952 except
953 end;
954
955 SaveList.Add('<a name="top"></a>');
956
957 for i := 0 to ReadList.Count - 1 do begin
958 if (Trim(ReadList[i]) <> '') then begin
959 No := IntToStr(i + 1);
960
961 Res := DivideStrLine(ReadList[i]);
962 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
963
964 if Res.FType = glt2chOld then begin
965 Res.FMailTo := StringReplace(Res.FMailTo, '鐚?鐔?', ',', [rfReplaceAll]);
966 Res.FName := StringReplace(Res.FName, '鐚?鐔?', ',', [rfReplaceAll]);
967 Res.FBody := StringReplace(Res.FBody, '鐚?鐔?', ',', [rfReplaceAll]);
968 end;
969
970 Res.FBody := AddAnchorTag(Res.FBody);
971 if Res.FName = '' then
972 Res.FName := '&nbsp;';
973
974 // ?亥?????若??/span>
975 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
976 try
977 SaveList.Add( LoadSkin( SkinNewmarkFileName ) );
978 except
979 SaveList.Add( '<a name="new"></a>' );
980 end;
981 end;
982
983 try
984 if NewReceiveNo <= (i + 1) then
985 // ?亥??????/span>
986 SaveList.Add( ReplaceRes( SkinNewRes ) )
987 else
988 // ??絽吾??????/span>
989 SaveList.Add( ReplaceRes( SkinRes ) );
990 except
991 end;
992
993 if ThreadItem.Kokomade = (i + 1) then begin
994 // ?????障?ц?????
995 try
996 SaveList.Add( LoadSkin( SkinBookmarkFileName ) );
997 except
998 SaveList.Add( '<a name="koko"></a>' );
999 end;
1000 end;
1001 end;
1002
1003 //if SaveList.Count > 50 then begin
1004 if i = 20 then begin
1005 //Sleep(1);
1006 //Application.ProcessMessages;
1007
1008 doc.Write(SaveList.Text);
1009 //while GikoForm.Browser.Busy do begin
1010 // Sleep(1);
1011 // Application.ProcessMessages;
1012 //end;
1013 while (GikoForm.Browser.ReadyState <> READYSTATE_COMPLETE) and
1014 (GikoForm.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
1015 //Sleep(1);
1016 //Application.ProcessMessages;
1017 end;
1018 SaveList.Clear;
1019 end;
1020 end;
1021
1022 SaveList.Add('<a name="bottom"></a>');
1023
1024 SizeByte := Length( SaveList.Text );
1025
1026 // ?鴻??????????
1027 try
1028 SaveList.Add( LoadSkin( SkinFooterFileName ) );
1029 except
1030 end;
1031
1032 doc.Write(SaveList.Text);
1033
1034 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
1035 //CSS篏睡??/span>
1036 //CSSFileName := GetAppDir + CSS_FILE_NAME;
1037 // SaveList.Add('<html lang="ja"><head>');
1038 SaveList.Add('<html><head>');
1039 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1040 SaveList.Add('<title>' + sTitle + '</title>');
1041 SaveList.Add('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
1042 SaveList.Add('</head>');
1043 SaveList.Add('<body>');
1044 SaveList.Add('<a name="top"></a>');
1045 SaveList.Add('<div class="title">' + sTitle + '</div>');
1046 //doc.Write(SaveList.Text);
1047 //SaveList.Clear;
1048 //Application.ProcessMessages;
1049 for i := 0 to ReadList.Count - 1 do begin
1050 if (Trim(ReadList[i]) <> '') then begin
1051 No := IntToStr(i + 1);
1052 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1053 SaveList.Add('<a name="new"></a><div class="new">?亥????? <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>');
1054 end;
1055 Res := DivideStrLine(ReadList[i]);
1056 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1057
1058 if Res.FType = glt2chOld then begin
1059 Res.FMailTo := StringReplace(Res.FMailTo, '鐚?鐔?', ',', [rfReplaceAll]);
1060 Res.FName := StringReplace(Res.FName, '鐚?鐔?', ',', [rfReplaceAll]);
1061 Res.FBody := StringReplace(Res.FBody, '鐚?鐔?', ',', [rfReplaceAll]);
1062 end;
1063 //Res.FBody := StringReplace(Res.FBody, '&amphearts;', '&hearts;', [rfReplaceAll]);
1064 //Res.FBody := StringReplace(Res.FBody, '&ampnbsp;', '&nbsp;', [rfReplaceAll]);
1065 //Res.FBody := StringReplace(Res.FBody, '&amp#', '&#', [rfReplaceAll]);
1066 //Res.FBody := StringReplace(Res.FBody, '&amp', '&amp;', [rfReplaceAll]);
1067 Res.FBody := AddAnchorTag(Res.FBody);
1068 if Res.FName = '' then
1069 Res.FName := '&nbsp;';
1070 if Res.FMailTo = '' then
1071 SaveList.Add('<a name="' + No + '"></a>'
1072 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span> '
1073 + '<span class="name_label">????鐚?</span> '
1074 + '<span class="name"><b>' + Res.FName + '</b></span> '
1075 + '<span class="date_label">??腮炊?ワ?</span> '
1076 + '<span class="date">' + Res.FDateTime+ '</span></div>'
1077 + '<div class="mes">' + Res.FBody + ' </div>')
1078 else
1079 if GikoSys.Setting.ShowMail then
1080 SaveList.Add('<a name="' + No + '"></a>'
1081 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1082 + '<span class="name_label"> ????鐚? </span>'
1083 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1084 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
1085 + '<span class="date_label"> ??腮炊?ワ?</span>'
1086 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1087 + '<div class="mes">' + Res.FBody + ' </div>')
1088 else
1089 SaveList.Add('<a name="' + No + '"></a>'
1090 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1091 + '<span class="name_label"> ????鐚? </span>'
1092 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1093 + '<b>' + Res.FName + '</b></a>'
1094 + '<span class="date_label"> ??腮炊?ワ?</span>'
1095 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1096 + '<div class="mes">' + Res.FBody + ' </div>');
1097 if ThreadItem.Kokomade = (i + 1) then begin
1098 SaveList.Add('<a name="koko"></a><div class="koko">?潟?潟?障?ц?????</div>');
1099 end;
1100 end;
1101 //if SaveList.Count > 50 then begin
1102 if i = 20 then begin
1103 //Sleep(1);
1104 //Application.ProcessMessages;
1105
1106 doc.Write(SaveList.Text);
1107 //while GikoForm.Browser.Busy do begin
1108 // Sleep(1);
1109 // Application.ProcessMessages;
1110 //end;
1111 while (GikoForm.Browser.ReadyState <> READYSTATE_COMPLETE) and
1112 (GikoForm.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
1113 //Sleep(1);
1114 //Application.ProcessMessages;
1115 end;
1116 SaveList.Clear;
1117 end;
1118 end;
1119 SaveList.Add('<a name="bottom"></a>');
1120 SaveList.Add('</body></html>');
1121 SaveList.Add('<a name="last"></a>');
1122 SaveList.Add('</body></html>');
1123
1124 doc.Write(SaveList.Text);
1125 end else begin
1126 //CSS??篏睡??/span>
1127 // SaveList.Add('<html lang="ja"><head>');
1128 SaveList.Add('<html><head>');
1129 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1130 SaveList.Add('<title>' + sTitle + '</title></head>');
1131 SaveList.Add('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1132 SaveList.Add('<a name="top"></a>');
1133 SaveList.Add('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1134 SaveList.Add('<dl>');
1135 doc.Write(SaveList.Text);
1136 SaveList.Clear;
1137 //Application.ProcessMessages;
1138 for i := 0 to ReadList.Count - 1 do begin
1139 if (Trim(ReadList[i]) <> '') then begin
1140 No := IntToStr(i + 1);
1141
1142 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1143 SaveList.Add('</dl>');
1144 SaveList.Add('<a name="new"></a>');
1145 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>?亥????? ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</b></font></td></tr></table>');
1146 SaveList.Add('<dl>');
1147 end;
1148 Res := DivideStrLine(ReadList[i]);
1149 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1150 if Res.FType = glt2chOld then begin
1151 Res.FMailTo := StringReplace(Res.FMailTo, '鐚?鐔?', ',', [rfReplaceAll]);
1152 Res.FName := StringReplace(Res.FName, '鐚?鐔?', ',', [rfReplaceAll]);
1153 Res.FBody := StringReplace(Res.FBody, '鐚?鐔?', ',', [rfReplaceAll]);
1154 end;
1155 //Res.FBody := StringReplace(Res.FBody, '&amphearts;', '&hearts;', [rfReplaceAll]);
1156 //Res.FBody := StringReplace(Res.FBody, '&ampnbsp;', '&nbsp;', [rfReplaceAll]);
1157 //Res.FBody := StringReplace(Res.FBody, '&amp#', '&#', [rfReplaceAll]);
1158 //Res.FBody := StringReplace(Res.FBody, '&amp', '&amp;', [rfReplaceAll]);
1159 Res.FBody := AddAnchorTag(Res.FBody);
1160 if Res.FMailTo = '' then
1161 SaveList.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ????鐚?<font color="forestgreen"><b> ' + Res.FName + ' </b></font> ??腮炊?ワ? ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>')
1162 else
1163 if GikoSys.Setting.ShowMail then
1164 SaveList.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ????鐚?<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> [' + Res.FMailTo + '] ??腮炊?ワ? ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>')
1165 else
1166 SaveList.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> ????鐚?<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> ??腮炊?ワ? ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>');
1167 if ThreadItem.Kokomade = (i + 1) then begin
1168 SaveList.Add('</dl>');
1169 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>?潟?潟?障?ц?????</b></font></td></tr></table>');
1170 SaveList.Add('<dl>');
1171 end;
1172 end;
1173 if SaveList.Count > 50 then begin
1174 doc.Write(SaveList.Text);
1175 SaveList.Clear;
1176 //Application.ProcessMessages;
1177 end;
1178 end;
1179 SaveList.Add('</dl>');
1180 SaveList.Add('<a name="bottom"></a>');
1181 SaveList.Add('</body></html>');
1182 doc.Write(SaveList.Text);
1183 end;
1184 finally
1185 SaveList.Free;
1186 doc.Close;
1187 end;
1188 finally
1189 ReadList.Free;
1190 end;
1191 end;
1192
1193 (*************************************************************************
1194 *http://????絖?????anchor?帥?遺???????????
1195 *************************************************************************)
1196 function TGikoSys.AddAnchorTag(s: string): string;
1197 const
1198 URL_CHAR: string = '0123456789'
1199 + 'abcdefghijklmnopqrstuvwxyz'
1200 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1201 + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
1202 var
1203 wkIdx: array[0..9] of Integer;
1204 url: string;
1205 href: string;
1206 i: Integer;
1207 idx: Integer;
1208 begin
1209 Result := '';
1210
1211 while True do begin
1212 wkIdx[0] := AnsiPos('http://', s);
1213 wkIdx[1] := AnsiPos('ttp://', s);
1214 wkIdx[2] := AnsiPos('tp://', s);
1215 wkIdx[3] := AnsiPos('ms-help://', s);
1216 wkIdx[4] := AnsiPos('p://', s);
1217 wkIdx[5] := AnsiPos('https://', s);
1218 wkIdx[6] := AnsiPos('www.', s);
1219 wkIdx[7] := AnsiPos('ftp://', s);
1220 wkIdx[8] := AnsiPos('news://', s);
1221 wkIdx[9] := AnsiPos('rtsp://', s);
1222
1223 idx := MaxInt;
1224 for i := 0 to 8 do
1225 if wkIdx[i] <> 0 then idx := Min(wkIdx[i], idx);
1226
1227 if idx = MaxInt then begin
1228 //???潟?????<??????
1229 Result := Result + s;
1230 Break;
1231 end;
1232
1233 if (idx > 1) and (Copy(s, idx - 1, 1) = '"') then begin
1234 //?≪?????潟???帥?違???ゃ?????????c?純????????????/span>
1235 Result := Result + Copy(s, 0, idx + Length('http://') - 1);
1236 s := Copy(s, idx + Length('http://'), length(s));
1237 Continue;
1238 end;
1239
1240 Result := Result + Copy(s, 0, idx - 1);
1241
1242 s := Copy(s, idx, length(s));
1243
1244 for i := 0 to Length(s) do begin
1245 idx := AnsiPos(s[i + 1], URL_CHAR);
1246 if (idx = 0) or (i = (Length(s))) then begin
1247 //URL??????????絖??肴?鐚?????????絖?????????c????
1248 url := Copy(s, 0, i);
1249
1250 if AnsiPos('ttp://', url) = 1 then
1251 href := 'h' + url
1252 else if AnsiPos('tp://', url) = 1 then
1253 href := 'ht' + url
1254 else if AnsiPos('p://', url) = 1 then
1255 href := 'htt' + url
1256 else if AnsiPos('www.', url) = 1 then
1257 href := 'http://' + url
1258 else
1259 href := url;
1260 Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
1261 s := Copy(s, i + 1, Length(s));
1262 Break;
1263 end;
1264 end;
1265 end;
1266 end;
1267
1268 (*************************************************************************
1269 *?泣???吾?с????筝?茵???????/span>
1270 *************************************************************************)
1271 function TGikoSys.DivideSubject(Line: string): TSubjectRec;
1272 var
1273 i: integer;
1274 ws: WideString;
1275 Delim: string;
1276 LeftK: string;
1277 RightK: string;
1278 begin
1279 Result.FCount := 0;
1280
1281 if Pos('<>', Line) = 0 then
1282 Delim := ','
1283 else
1284 Delim := '<>';
1285
1286 Result.FFileName := GetTokenIndex(Line, Delim, 0);
1287 Result.FTitle := GetTokenIndex(Line, Delim, 1);
1288
1289 ws := Trim(Result.FTitle);
1290
1291 if Copy(ws, Length(ws), 1) = ')' then begin
1292 LeftK := '(';
1293 RightK := ')';
1294 end else if Copy(ws, Length(ws), 1) = '鐚?' then begin
1295 LeftK := '鐚?';
1296 RightK := '鐚?';
1297 end else if Copy(ws, Length(ws), 1) = '<' then begin
1298 LeftK := '<';
1299 RightK := '>';
1300 end;
1301
1302 for i := Length(ws) - 1 downto 1 do begin
1303 if ws[i] = LeftK then begin
1304 ws := Copy(ws, i + 1, Length(ws) - i - 1);
1305 if IsNumeric(ws) then
1306 Result.FCount := StrToInt(ws);
1307 Result.FTitle := Trim(StringReplace(Result.FTitle, LeftK + ws + RightK, '', [rfReplaceAll]));
1308 break;
1309 end;
1310 end;
1311 end;
1312
1313 (*************************************************************************
1314 * dat???<?ゃ????????ゃ?潟????茹?/span>
1315 *************************************************************************)
1316 function TGikoSys.DivideStrLine(Line: string): TResRec;
1317 var
1318 Delim: string;
1319 bufbody : String;
1320 begin
1321 if Pos('<>', Line) = 0 then begin
1322 Delim := ',';
1323 Result.FType := glt2chOld;
1324 end else begin
1325 Delim := '<>';
1326 Result.FType := glt2chNew;
1327 end;
1328 Result.FName := Trim(GetTokenIndex(Line, Delim, 0));
1329 Result.FMailTo := Trim(GetTokenIndex(Line, Delim, 1));
1330 Result.FDateTime := Trim(GetTokenIndex(Line, Delim, 2));
1331 bufBody := Trim(GetTokenIndex(Line, Delim, 3));
1332 if bufbody = '' then begin
1333 Insert('&nbsp;',bufbody, 1);
1334 end;
1335 Result.FBody := bufBody;
1336 Result.FTitle := Trim(GetTokenIndex(Line, Delim, 4));
1337
1338 end;
1339
1340 (*************************************************************************
1341 * URL????BBSID????緇?
1342 *************************************************************************)
1343 function TGikoSys.UrlToID(url: string): string;
1344 var
1345 i: integer;
1346 begin
1347 Result := '';
1348 url := Trim(url);
1349
1350 if url = '' then Exit;
1351
1352 url := Copy(url, 0, Length(url) - 1);
1353 for i := Length(url) downto 0 do begin
1354 if url[i] = '/' then begin
1355 Result := Copy(url, i + 1, Length(url));
1356 Break;
1357 end;
1358 end;
1359 end;
1360
1361 (*************************************************************************
1362 *URL????BBSID篁ュ???????(http://teri.2ch.net/)????緇?
1363 *************************************************************************)
1364 function TGikoSys.UrlToServer(url: string): string;
1365 var
1366 i: integer;
1367 wsURL: WideString;
1368 begin
1369 Result := '';
1370 wsURL := url;
1371 wsURL := Trim(wsURL);
1372
1373 if wsURL = '' then exit;
1374
1375 if Copy(wsURL, Length(wsURL), 1) = '/' then
1376 wsURL := Copy(wsURL, 0, Length(wsURL) - 1);
1377
1378 for i := Length(wsURL) downto 0 do begin
1379 if wsURL[i] = '/' then begin
1380 Result := Copy(wsURL, 0, i);
1381 break;
1382 end;
1383 end;
1384 end;
1385
1386 (*************************************************************************
1387 *???c??????????絖????????????с????/span>
1388 *************************************************************************)
1389 function TGikoSys.DirectoryExistsEx(const Name: string): Boolean;
1390 var
1391 Code: Integer;
1392 begin
1393 Code := GetFileAttributes(PChar(Name));
1394 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
1395 end;
1396
1397 (*************************************************************************
1398 *???c???????????鐚?茲??育??韻絲上?鐚?
1399 *************************************************************************)
1400 function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean;
1401 begin
1402 Result := True;
1403 if Length(Dir) = 0 then
1404 raise Exception.Create('??????????篏????堺?ャ?障????');
1405 Dir := ExcludeTrailingPathDelimiter(Dir);
1406 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
1407 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
1408 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
1409 end;
1410
1411 (*************************************************************************
1412 *??絖??????????若???潟???????冴??鐚?????????鐚?
1413 *FDelphi????????????/span>
1414 *************************************************************************)
1415 function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1416 begin
1417 Rec.Str := s;
1418 Rec.Pos := 1;
1419 Result := StrTokNext(sep, Rec);
1420 end;
1421
1422 (*************************************************************************
1423 *??絖??????????若???潟???????冴??
1424 *FDelphi????????????/span>
1425 *************************************************************************)
1426 function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1427 var
1428 Len, I: Integer;
1429 begin
1430 with Rec do begin
1431 Len := Length(Str);
1432 Result := '';
1433 if Len >= Pos then begin
1434 while (Pos <= Len) and (Str[Pos] in sep) do begin
1435 Inc(Pos);
1436 end;
1437 I := Pos;
1438 while (Pos<= Len) and not (Str[Pos] in sep) do begin
1439 if IsDBCSLeadByte(Byte(Str[Pos])) then begin
1440 Inc(Pos);
1441 end;
1442 Inc(Pos);
1443 end;
1444 Result := Copy(Str, I, Pos - I);
1445 while (Pos <= Len) and (Str[Pos] in sep) do begin// ????????絅純??/span>
1446 Inc(Pos);
1447 end;
1448 end;
1449 end;
1450 end;
1451
1452 (*************************************************************************
1453 *???<?ゃ???泣?ゃ?阪??
1454 *************************************************************************)
1455 function TGikoSys.GetFileSize(FileName : string): longint;
1456 var
1457 F : File;
1458 begin
1459 try
1460 if not FileExists(FileName) then begin
1461 Result := 0;
1462 Exit;
1463 end;
1464 Assign(F, FileName);
1465 Reset(F, 1);
1466 Result := FileSize(F);
1467 CloseFile(F);
1468 except
1469 Result := 0;
1470 end;
1471 end;
1472
1473 (*************************************************************************
1474 *???<?ゃ????医??
1475 *************************************************************************)
1476 function TGikoSys.GetFileLineCount(FileName : string): longint;
1477 var
1478 sl: TStringList;
1479 begin
1480 sl := TStringList.Create;
1481 try
1482 try
1483 sl.LoadFromFile(FileName);
1484 Result := sl.Count;
1485 except
1486 Result := 0;
1487 end;
1488 finally
1489 sl.Free;
1490 end;
1491
1492 end;
1493
1494 (*************************************************************************
1495 *?鴻?????????<?ゃ????????絎?茵?????緇?
1496 *************************************************************************)
1497 function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string;
1498 const
1499 BUFFER_SIZE = 1024;
1500 var
1501 f: TextFile;
1502 s: string;
1503 num: Integer;
1504 ArrBuff: array [1..BUFFER_SIZE] of Char;
1505 begin
1506 Result := '';
1507 if FileExists(FileName) then begin
1508 AssignFile(f, FileName);
1509 System.SetTextBuf(f, ArrBuff);
1510 try
1511 Reset(f);
1512 num := 1;
1513 while not Eof(f) do begin
1514 Readln(f, s);
1515 if Line = num then begin
1516 Result := s;
1517 // CloseFile(f);
1518 Break;
1519 end;
1520 inc(num);
1521 end;
1522 finally
1523 CloseFile(f);
1524 end;
1525 end;
1526 end;
1527
1528 (*************************************************************************
1529 *?激?鴻?????<???ャ?若?????潟??????с????緇?
1530 *************************************************************************)
1531 procedure TGikoSys.MenuFont(Font: TFont);
1532 var
1533 lf: LOGFONT;
1534 nm: NONCLIENTMETRICS;
1535 begin
1536 nm.cbSize := sizeof(NONCLIENTMETRICS);
1537
1538 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0);
1539 lf := nm.lfMenuFont;
1540
1541 Font.Name := lf.lfFaceName;
1542 Font.Height := lf.lfHeight;
1543 Font.Style := [];
1544 if lf.lfWeight >= 700 then
1545 Font.Style := Font.Style + [fsBold];
1546 if lf.lfItalic = 1 then
1547 Font.Style := Font.Style + [fsItalic];
1548 end;
1549
1550 (*************************************************************************
1551 *
1552 *?????????泣?ゃ??????????????/span>
1553 *************************************************************************)
1554 function TGikoSys.RemoveToken(var s: string; delimiter: string): string;
1555 var
1556 p: Integer;
1557 begin
1558 p := AnsiPos(delimiter, s);
1559 if p = 0 then
1560 Result := s
1561 else
1562 Result := Copy(s, 1, p - 1);
1563 s := Copy(s, Length(Result) + Length(delimiter) + 1, Length(s));
1564 end;
1565
1566 (*************************************************************************
1567 *
1568 *?????????泣?ゃ??????????????/span>
1569 *************************************************************************)
1570 function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string;
1571 var
1572 i: Integer;
1573 begin
1574 Result := '';
1575 for i := 0 to index do
1576 Result := RemoveToken(s, delimiter);
1577 end;
1578
1579 (*************************************************************************
1580 *
1581 *************************************************************************)
1582 function TGikoSys.DeleteLink(const s: string): string;
1583 var
1584 s1: string;
1585 s2: string;
1586 idx: Integer;
1587 i: Integer;
1588 begin
1589 i := 0;
1590 Result := '';
1591 while True do begin
1592 s1 := GetTokenIndex(s, '<a href="', i);
1593 s2 := GetTokenIndex(s, '<a href="', i + 1);
1594
1595 idx := Pos('">', s1);
1596 if idx <> 0 then
1597 Delete(s1, 1, idx + 1);
1598 idx := Pos('">', s2);
1599 if idx <> 0 then
1600 Delete(s2, 1, idx + 1);
1601
1602 Result := Result + s1 + s2;
1603
1604 if s2 = '' then
1605 Break;
1606
1607 inc(i, 2);
1608 end;
1609 end;
1610
1611 //?ゃ?潟???????号???贋?違???????<?????????激?ワ?
1612 {procedure TGikoSys.FlashExitWrite;
1613 var
1614 i: Integer;
1615 begin
1616 //?鴻?????????若?帥???<?ゃ?????贋??/span>
1617 for i := 0 to FExitWrite.Count - 1 do
1618 WriteThreadDat(FExitWrite[i]);
1619 FExitWrite.Clear;
1620 end;}
1621
1622 (*************************************************************************
1623 *?鴻???????????????????????????
1624 *from HotZonu
1625 *************************************************************************)
1626 function TGikoSys.GetShortName(const LongName: string; ALength: integer): string;
1627 const
1628 ERASECHAR : array [1..39] of string =
1629 ('??','??','??','??#39;,'??','??','鐚?#39;,'鐚?','??#39;,'??#39;,
1630 '??#39;,'??#39;,'??39;,'??','??#39;,'??','??','??#39;,'??','??',
1631 '??','??','??','??','??','??','鐚?','鐚?','??#39;,'??#39;,
1632 '鐔?','鐔?','??','??','??#39;,'??39;,'??','??#39;, '??');
1633 var
1634 Chr : array [0..255] of char;
1635 S : string;
1636 i : integer;
1637 begin
1638 s := Trim(LongName);
1639 if (Length(s) <= ALength) then begin
1640 Result := s;
1641 end else begin
1642 S := s;
1643 for i := Low(ERASECHAR) to High(ERASECHAR) do begin
1644 S := StringReplace(S, ERASECHAR[i], '', [rfReplaceAll]);
1645 end;
1646 if (Length(S) <= ALength) then begin
1647 Result := S;
1648 end else begin
1649 Windows.LCMapString(
1650 GetUserDefaultLCID(),
1651 LCMAP_HALFWIDTH,
1652 PChar(S),
1653 Length(S) + 1,
1654 chr,
1655 Sizeof(chr)
1656 );
1657 S := Chr;
1658 S := Copy(S,1,ALength);
1659 while true do begin
1660 if (ByteType(S, Length(S)) = mbLeadByte ) then begin
1661 S := Copy(S, 1, Length(S) - 1);
1662 end else begin
1663 Break;
1664 end;
1665 end;
1666 Result := S;
1667 end;
1668 end;
1669 end;
1670
1671 (*************************************************************************
1672 *
1673 * from HotZonu
1674 *************************************************************************)
1675 function TGikoSys.ConvRes(const Body, Bbs, Key,
1676 ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
1677 type
1678 PIndex = ^TIndex;
1679 TIndex = record
1680 FIndexFrom : integer;
1681 FIndexTo : integer;
1682 FNo : string;
1683 end;
1684 const
1685 GT = '&gt;';
1686 SN = '0123456789-';
1687 ZN = '鐚?鐚?鐚?鐚?鐚?鐚?鐚?鐚?鐚?鐚???';
1688 var
1689 i : integer;
1690 s,r : string;
1691 b : TMbcsByteType;
1692 sw: boolean;
1693 sp: integer;
1694 No: string;
1695 sx: string;
1696 List: TList;
1697 oc : string;
1698 st, et: string;
1699 chk : boolean;
1700 al : boolean;
1701 procedure Add(IndexFrom, IndexTo: integer; const No: string);
1702 var
1703 FIndex : PIndex;
1704 begin
1705 New(FIndex);
1706 FIndex.FIndexFrom := IndexFrom;
1707 FIndex.FIndexTo := IndexTo;
1708 FIndex.FNo := No;
1709 List.Add(FIndex);
1710 end;
1711 function ChooseString(const Text, Separator: string; Index: integer): string;
1712 var
1713 S : string;
1714 i, p : integer;
1715 begin
1716 S := Text;
1717 for i := 0 to Index - 1 do begin
1718 if (AnsiPos(Separator, S) = 0) then S := ''
1719 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
1720 end;
1721 p := AnsiPos(Separator, S);
1722 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
1723 end;
1724 begin
1725 { v1.0 b2 - 03 }
1726 s := Body;
1727 r := Body;
1728 i := 1;
1729 sw := False;
1730 No := '';
1731 List:= TList.Create;
1732 oc := '';
1733 sp := 0;
1734 chk := False;
1735 al := False;
1736 while true do begin
1737 b := ByteType(s, i);
1738 case b of
1739 mbSingleByte : begin
1740 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1741 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1742 sw := True;
1743 sp := i;
1744 i := i + 7;
1745 oc:='';
1746 chk := True;
1747 end;
1748 end else
1749 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1750 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
1751 i := i + 7;
1752 oc:='';
1753 chk := True;
1754 end;
1755 end else
1756 if (not sw) and (Copy(s,i,4) = GT) then begin
1757 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1758 sw := True;
1759 sp := i;
1760 i := i + 3;
1761 oc:='';
1762 chk := True;
1763 end;
1764 end else
1765 if ((not sw) and (Copy(s,i,1) = ',')) or
1766 ((not sw) and (Copy(s,i,1) = '=')) then begin
1767 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
1768 ((Chk) and (oc = '')) or
1769 ((not Chk) and (al)) then
1770 begin
1771 sw := True;
1772 sp := i;
1773 //i := i + 1;
1774 oc:='';
1775 end;
1776 end else
1777 if (sw) then begin
1778 sx := Copy(s,i,1);
1779 if (AnsiPos(sx, SN) > 0) then begin
1780 No := No + sx;
1781 end else begin
1782 if (No <> '') and (No <> '-') then begin
1783 Add(sp, i, No);
1784 al := True;
1785 end;
1786 sw := False;
1787 //
1788 i := i - 1;
1789 //
1790 No := '';
1791 oc:='';
1792 //chk := False;
1793 end;
1794 end else begin
1795 if Copy(s,i,1) = '<' then oc := '';
1796 oc := oc + Copy(s,i,1);
1797 chk := False;
1798 al := False;
1799 end;
1800 end;
1801 mbLeadByte : begin
1802 if (not sw) and (Copy(s,i,4) = '鐚?鐚?') then begin
1803 sw := True;
1804 sp := i;
1805 i := i + 3;
1806 chk := True;
1807 end else
1808 if (not sw) and (Copy(s,i,2) = '鐚?') then begin
1809 sw := True;
1810 sp := i;
1811 i := i + 1;
1812 chk := True;
1813 end else
1814 if (sw) then begin
1815 sx := Copy(s,i,2);
1816 if (AnsiPos(sx, ZN) > 0) then begin
1817 No := No + ZenToHan(sx);
1818 end else begin
1819 if (No <> '') and (No <> '-') and (No <> '??') then begin
1820 Add(sp, i, No);
1821 end;
1822 sw := False;
1823 i := i - 1;
1824 No := '';
1825 end;
1826 end else begin
1827 oc := '';
1828 chk := False;
1829 end;
1830 al := False;
1831 end;
1832 end;
1833 inc(i);
1834 if (i > Length(Body)) then begin
1835 if (sw) then begin
1836 if (No <> '') then Add(sp, i, No);
1837 end;
1838 Break;
1839 end;
1840 end;
1841 for i := List.Count - 1 downto 0 do begin
1842 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
1843 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
1844 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
1845 end else begin
1846 st := PIndex(List[i]).FNo;
1847 et := PIndex(List[i]).FNo;
1848 end;
1849 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
1850 Format('<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">',
1851 [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
1852 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
1853 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
1854 Dispose(PIndex(List[i]));
1855 end;
1856 List.Free;
1857 Result := r;
1858 end;
1859
1860 (*************************************************************************
1861 * ???????茹?
1862 * from HotZonu
1863 *************************************************************************)
1864 function TGikoSys.ZenToHan(const s: string): string;
1865 var
1866 Chr: array [0..255] of char;
1867 begin
1868 Windows.LCMapString(
1869 GetUserDefaultLCID(),
1870 // LCMAP_HALFWIDTH,
1871 LCMAP_HALFWIDTH or LCMAP_KATAKANA or LCMAP_LOWERCASE,
1872 PChar(s),
1873 Length(s) + 1,
1874 chr,
1875 Sizeof(chr)
1876 );
1877 Result := Chr;
1878 end;
1879
1880 (*************************************************************************
1881 * ?????茹??蚊?????????????????阪?ャ??????????Pos
1882 *************************************************************************)
1883 function TGikoSys.VaguePos(const Substr, S: string): Integer;
1884 begin
1885 Result := Pos(ZenToHan(Substr), ZenToHan(S));
1886 end;
1887
1888 function TGikoSys.BoolToInt(b: Boolean): Integer;
1889 begin
1890 Result := IfThen(b, 1, 0);
1891 end;
1892
1893 function TGikoSys.IntToBool(i: Integer): Boolean;
1894 begin
1895 Result := i = 1;
1896 end;
1897
1898 //gzip?у?х軒???????????祉??
1899 function TGikoSys.GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
1900 const
1901 BUF_SIZE = 4096;
1902 var
1903 GZipStream: TGzipDecompressStream;
1904 TextStream: TStringStream;
1905 buf: array[0..BUF_SIZE - 1] of Byte;
1906 cnt: Integer;
1907 s: string;
1908 i: Integer;
1909 begin
1910 Result := '';
1911 TextStream := TStringStream.Create('');
1912 try
1913 //???若???潟???潟?????c????003絲丞?(x-gzip???????????帥????)
1914 // if LowerCase(Trim(ContentEncoding)) = 'gzip' then begin
1915 if AnsiPos('gzip', LowerCase(Trim(ContentEncoding))) > 0 then begin
1916 ResStream.Position := 0;
1917 GZipStream := TGzipDecompressStream.Create(TextStream);
1918 try
1919 repeat
1920 FillChar(buf, BUF_SIZE, 0);
1921 cnt := ResStream.Read(buf, BUF_SIZE);
1922 if cnt > 0 then
1923 GZipStream.Write(buf, BUF_SIZE);
1924 until cnt = 0;
1925 finally
1926 GZipStream.Free;
1927 end;
1928 end else begin
1929 ResStream.Position := 0;
1930 repeat
1931 FillChar(buf, BUF_SIZE, 0);
1932 cnt := ResStream.Read(buf, BUF_SIZE);
1933 if cnt > 0 then
1934 TextStream.Write(buf, BUF_SIZE);
1935 until cnt = 0;
1936 end;
1937
1938 //NULL??絖???"*"??????
1939 s := TextStream.DataString;
1940 i := Length(s);
1941 while (i > 0) and (s[i] = #0) do
1942 Dec(i);
1943 s := Copy(s, 1, i);
1944
1945 i := Pos(#0, s);
1946 while i <> 0 do begin
1947 s[i] := '*';
1948 i := Pos(#0, s);
1949 end;
1950 Result := s;
1951 finally
1952 TextStream.Free;
1953 end;
1954 end;
1955
1956 procedure TGikoSys.LoadKeySetting(ActionList: TActionList);
1957 const
1958 STD_SEC = 'KeySetting';
1959 var
1960 i: Integer;
1961 ini: TMemIniFile;
1962 ActionName: string;
1963 ActionKey: Integer;
1964 SecList: TStringList;
1965 Component: TComponent;
1966 begin
1967 if not FileExists(GetConfigDir + KEY_SETTING_FILE_NAME) then
1968 Exit;
1969 SecList := TStringList.Create;
1970 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
1971 try
1972 ini.ReadSection(STD_SEC, SecList);
1973 for i := 0 to SecList.Count - 1 do begin
1974 ActionName := SecList[i];
1975 ActionKey := ini.ReadInteger(STD_SEC, ActionName, -1);
1976 if ActionKey <> -1 then begin
1977 Component := ActionList.Owner.FindComponent(ActionName);
1978 if TObject(Component) is TAction then begin
1979 TAction(Component).ShortCut := ActionKey;
1980 end;
1981 end;
1982 end;
1983 finally
1984 ini.Free;
1985 SecList.Free;
1986 end;
1987 end;
1988
1989 procedure TGikoSys.SaveKeySetting(ActionList: TActionList);
1990 const
1991 STD_SEC = 'KeySetting';
1992 var
1993 i: Integer;
1994 ini: TMemIniFile;
1995 begin
1996 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
1997 try
1998 for i := 0 to ActionList.ActionCount - 1 do begin
1999 if ActionList.Actions[i].Tag = -1 then
2000 Continue;
2001 ini.WriteInteger(STD_SEC, ActionList.Actions[i].Name, TAction(ActionList.Actions[i]).ShortCut);
2002 end;
2003 ini.UpdateFile;
2004 finally
2005 ini.Free;
2006 end;
2007 end;
2008
2009 //
2010 procedure TGikoSys.CreateProcess(const AppPath: string; const Param: string);
2011 var
2012 PI: TProcessInformation;
2013 SI: TStartupInfo;
2014 Path: string;
2015 begin
2016 Path := '"' + AppPath + '"';
2017 if Param <> '' then
2018 Path := Path + ' ' + Param;
2019
2020 SI.Cb := SizeOf(Si);
2021 SI.lpReserved := nil;
2022 SI.lpDesktop := nil;
2023 SI.lpTitle := nil;
2024 SI.dwFlags := 0;
2025 SI.cbReserved2 := 0;
2026 SI.lpReserved2 := nil;
2027 SI.dwysize := 0;
2028 Windows.CreateProcess(nil,
2029 PChar(Path),
2030 nil,
2031 nil,
2032 False,
2033 0,
2034 nil,
2035 nil,
2036 SI,
2037 PI);
2038 end;
2039
2040 procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
2041 begin
2042 case BrowserType of
2043 gbtIE:
2044 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2045 gbtUserApp, gbtAuto:
2046 if (Setting.URLApp) and (FileExists(Setting.URLAppFile)) then
2047 GikoSys.CreateProcess(Setting.URLAppFile, URL)
2048 else
2049 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2050 end;
2051 end;
2052
2053 function TGikoSys.HTMLDecode(const AStr: String): String;
2054 var
2055 Sp, Rp, Cp, Tp: PChar;
2056 S: String;
2057 I, Code: Integer;
2058 Num: Boolean;
2059 begin
2060 SetLength(Result, Length(AStr));
2061 Sp := PChar(AStr);
2062 Rp := PChar(Result);
2063 //Cp := Sp;
2064 try
2065 while Sp^ <> #0 do begin
2066 case Sp^ of
2067 '&': begin
2068 //Cp := Sp;
2069 Inc(Sp);
2070 case Sp^ of
2071 'a': if AnsiStrPos(Sp, 'amp;') = Sp then
2072 begin
2073 Inc(Sp, 3);
2074 Rp^ := '&';
2075 end;
2076 'l',
2077 'g': if (AnsiStrPos(Sp, 'lt;') = Sp) or (AnsiStrPos(Sp, 'gt;') = Sp) then
2078 begin
2079 Cp := Sp;
2080 Inc(Sp, 2);
2081 while (Sp^ <> ';') and (Sp^ <> #0) do
2082 Inc(Sp);
2083 if Cp^ = 'l' then
2084 Rp^ := '<'
2085 else
2086 Rp^ := '>';
2087 end;
2088 'q': if AnsiStrPos(Sp, 'quot;') = Sp then
2089 begin
2090 Inc(Sp,4);
2091 Rp^ := '"';
2092 end;
2093 '#': begin
2094 Tp := Sp;
2095 Inc(Tp);
2096 Num := IsNumeric(Copy(Tp, 1, 1));
2097 while (Sp^ <> ';') and (Sp^ <> #0) do begin
2098 if (Num) and (not IsNumeric(Copy(Sp, 1, 1))) then
2099 Break;
2100 Inc(Sp);
2101 end;
2102 SetString(S, Tp, Sp - Tp);
2103 Val(S, I, Code);
2104 Rp^ := Chr((I));
2105 end;
2106 // else
2107 //raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2108 //[Cp^ + Sp^, Cp - PChar(AStr)])
2109 end;
2110 end
2111 else
2112 Rp^ := Sp^;
2113 end;
2114 Inc(Rp);
2115 Inc(Sp);
2116 end;
2117 except
2118 // on E:EConvertError do
2119 // raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2120 // [Cp^ + Sp^, Cp - PChar(AStr)])
2121 end;
2122 SetLength(Result, Rp - PChar(Result));
2123 end;
2124
2125 function TGikoSys.GetHRefText(s: string): string;
2126 var
2127 Index: Integer;
2128 Index2: Integer;
2129 begin
2130 Result := '';
2131 s := Trim(s);
2132 if s = '' then
2133 Exit;
2134
2135 Index := AnsiPos('href', LowerCase(s));
2136 if Index = 0 then
2137 Exit;
2138 s := Trim(Copy(s, Index + 4, Length(s)));
2139 s := Trim(Copy(s, 2, Length(s)));
2140
2141 //紮???????絖???'"'?????????ゃ??span>
2142 if Copy(s, 1, 1) = '"' then begin
2143 s := Trim(Copy(s, 2, Length(s)));
2144 end;
2145
2146 Index := AnsiPos('"', s);
2147 if Index <> 0 then begin
2148 //'"'?障??RL??????
2149 s := Copy(s, 1, Index - 1);
2150 end else begin
2151 //'"'???<?????違?鴻???若?鴻??">"???????鴻?障?с??URL??????
2152 Index := AnsiPos(' ', s);
2153 Index2 := AnsiPos('>', s);
2154 if Index = 0 then
2155 Index := Index2;
2156 if Index > Index2 then
2157 Index := Index2;
2158 if Index <> 0 then
2159 s := Copy(s, 1, Index - 1)
2160 else
2161 //????篁ヤ??????ャ??????/span>
2162 ;
2163 end;
2164 Result := Trim(s);
2165 end;
2166
2167 //???鴻??????鐚?鐔?鐔????????????с????????
2168 function TGikoSys.Is2chHost(Host: string): Boolean;
2169 const
2170 HOST_NAME: array[0..1] of string = ('2ch.net', 'bbspink.com');
2171 var
2172 i: Integer;
2173 // Len: Integer;
2174 begin
2175 Result := False;
2176 OutputDebugString(pchar(HOST_NAME[0]));
2177 for i := 0 to Length(HOST_NAME) - 1 do begin
2178 // Len := Length(HOST_NAME[i]);
2179 if AnsiPos(HOST_NAME[i], Host) = (Length(Host) - Length(HOST_NAME[i]) + 1) then begin
2180 Result := True;
2181 Exit;
2182 end;
2183 end;
2184 end;
2185
2186 function TGikoSys.Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
2187 const
2188 READ_PATH: string = '/test/read.cgi/';
2189 OLD_READ_PATH: string = '/test/read.cgi?';
2190 KAKO_PATH: string = '/kako/';
2191 var
2192 Index: Integer;
2193 s: string;
2194 SList: TStringList;
2195 begin
2196 BBSID := '';
2197 BBSKey := '';
2198 Result := False;
2199
2200 Index := AnsiPos(READ_PATH, path);
2201 if Index <> 0 then begin
2202 s := Copy(path, Length(READ_PATH) + 1, Length(path));
2203 BBSID := GetTokenIndex(s, '/', 0);
2204 BBSKey := GetTokenIndex(s, '/', 1);
2205 if BBSKey = '' then
2206 BBSKey := Document;
2207 Result := (BBSID <> '') or (BBSKey <> '');
2208 Exit;
2209 end;
2210 Index := AnsiPos(KAKO_PATH, path);
2211 if Index <> 0 then begin
2212 s := Copy(path, 2, Length(path));
2213 BBSID := GetTokenIndex(s, '/', 0);
2214 if (BBSID = 'log') and (GetTokenIndex(s, '/', 2) = 'kako') then
2215 BBSID := GetTokenIndex(s, '/', 1);
2216 BBSKey := ChangeFileExt(Document, '');
2217 Result := (BBSID <> '') or (BBSKey <> '');
2218 Exit;
2219 end;
2220 Index := AnsiPos('read.cgi?', URL);
2221 if Index <> 0 then begin
2222 SList := TStringList.Create;
2223 try
2224 try
2225 // s := HTMLDecode(Document);
2226 ExtractHTTPFields(['?', '&'], [], PChar(URL), SList, False);
2227 BBSID := SList.Values['bbs'];
2228 BBSKey := SList.Values['key'];
2229 Result := (BBSID <> '') or (BBSKey <> '');
2230 Exit;
2231 except
2232 Exit;
2233 end;
2234 finally
2235 SList.Free;
2236 end;
2237 end;
2238 end;
2239
2240 function TGikoSys.Parse2chURL2(URL: string): TPathRec;
2241 var
2242 i: Integer;
2243 s: string;
2244 wk: string;
2245 wkMin: Integer;
2246 wkMax: Integer;
2247 wkInt: Integer;
2248 RStart: Integer;
2249 RLength: Integer;
2250 SList: TStringList;
2251 begin
2252 URL := Trim(LowerCase(URL));
2253 Result.FBBS := '';
2254 Result.FKey := '';
2255 Result.FSt := 0;
2256 Result.FTo := 0;
2257 Result.FFirst := False;
2258 Result.FStBegin := False;
2259 Result.FToEnd := False;
2260 Result.FDone := False;
2261
2262 wkMin := 0;
2263 wkMax := 1;
2264
2265 FAWKStr.RegExp := 'http://.+\.(2ch\.net|bbspink\.com)/';
2266 if FAWKStr.Match(FAWKStr.ProcessEscSeq(URL), RStart, RLength) = 0 then
2267 Exit;
2268 s := Copy(URL, RStart + RLength - 1, Length(URL));
2269
2270 //罔?羣??後?
2271 //??緇???50, 10, 10-20, 10n, 10-20n, -10, 10-, 10n- ????/span>
2272 //http://xxx.2ch.net/test/read.cgi/bbsid/1000000000/
2273 FAWKStr.RegExp := '/test/read.cgi/.+/[0-9]+/.*';
2274 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2275 s := Copy(s, 15, Length(s));
2276
2277 SList := TStringList.Create;
2278 try
2279 SList.Clear;
2280 FAWKStr.RegExp := '/';
2281 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2282 Result.FBBS := SList[1];
2283 Result.FKey := SList[2];
2284 if SList.Count >= 3 then
2285 s := SList[3]
2286 else
2287 s := '';
2288 end else
2289 Exit;
2290
2291 SList.Clear;
2292 FAWKStr.LineSeparator := mcls_CRLF;
2293 FAWKStr.RegExp := '-';
2294 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) = 0 then begin
2295 Result.FFirst := True;
2296 end else begin
2297 FAWKStr.RegExp := 'l[0-9]+';
2298 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2299 Result.FFirst := True;
2300 end else begin
2301 for i := 0 to SList.Count - 1 do begin
2302 if Trim(SList[i]) = '' then begin
2303 if i = 0 then
2304 Result.FStBegin := True;
2305 if i = (SList.Count - 1) then
2306 Result.FToEnd := True;
2307 end else if IsNumeric(SList[i]) then begin
2308 wkInt := StrToInt(SList[i]);
2309 wkMax := Max(wkMax, wkInt);
2310 if wkMin = 0 then
2311 wkMin := wkInt
2312 else
2313 wkMin := Min(wkMin, wkInt);
2314 end else if Trim(SList[i]) = 'n' then begin
2315 Result.FFirst := True;
2316 end else begin
2317 FAWKStr.RegExp := '^n[0-9]+$|^[0-9]+n$';
2318 if FAWKStr.Match(FAWKStr.ProcessEscSeq(SList[i]), RStart, RLength) > 0 then begin
2319 if Copy(SList[i], 1, 1) = 'n' then
2320 wkInt := StrToInt(Copy(SList[i], 2, Length(SList[i])))
2321 else
2322 wkInt := StrToInt(Copy(SList[i], 1, Length(SList[i]) - 1));
2323 Result.FFirst := True;
2324 wkMax := Max(wkMax, wkInt);
2325 if wkMin = 1 then
2326 wkMin := wkInt
2327 else
2328 wkMin := Min(wkMin, wkInt);
2329 end;
2330 end;
2331 end;
2332 if Result.FStBegin and (not Result.FToEnd) then
2333 Result.FSt := wkMin
2334 else if (not Result.FStBegin) and Result.FToEnd then
2335 Result.FTo := wkMax
2336 else if (not Result.FStBegin) and (not Result.FToEnd) then begin
2337 Result.FSt := wkMin;
2338 Result.FTo := wkMax;
2339 end;
2340 //Result.FSt := wkMin;
2341 //Result.FTo := wkMax;
2342 end;
2343 end;
2344 finally
2345 SList.Free;
2346 end;
2347 Result.FDone := True;
2348 Exit;
2349 end;
2350
2351 //??ako?後?
2352 //http://server.2ch.net/ITA_NAME/kako/1000/10000/1000000000.html
2353 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+/[0-9]+\.html';
2354 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2355 SList := TStringList.Create;
2356 try
2357 SList.Clear;
2358 FAWKStr.RegExp := '/';
2359 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2360 Result.FBBS := SList[1];
2361 Result.FKey := ChangeFileExt(SList[5], '');
2362 Result.FFirst := True;
2363 end else
2364 Exit;
2365 finally
2366 SList.Free;
2367 end;
2368 Result.FDone := True;
2369 Exit;
2370 end;
2371
2372 //??ako?後?
2373 //http://server.2ch.net/ITA_NAME/kako/999/999999999.html
2374 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+\.html';
2375 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2376 SList := TStringList.Create;
2377 try
2378 SList.Clear;
2379 FAWKStr.RegExp := '/';
2380 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 5 then begin
2381 Result.FBBS := SList[1];
2382 Result.FKey := ChangeFileExt(SList[4], '');
2383 Result.FFirst := True;
2384 end else
2385 Exit;
2386 finally
2387 SList.Free;
2388 end;
2389 Result.FDone := True;
2390 Exit;
2391 end;
2392
2393 //log????og2?後?
2394 //http://server.2ch.net/log/ITA_NAME/kako/999/999999999.html
2395 //http://server.2ch.net/log2/ITA_NAME/kako/999/999999999.html
2396 FAWKStr.RegExp := '/log2?/.+/kako/[0-9]+/[0-9]+\.html';
2397 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2398 SList := TStringList.Create;
2399 try
2400 SList.Clear;
2401 FAWKStr.RegExp := '/';
2402 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2403 Result.FBBS := SList[2];
2404 Result.FKey := ChangeFileExt(SList[5], '');
2405 Result.FFirst := True;
2406 end else
2407 Exit;
2408 finally
2409 SList.Free;
2410 end;
2411 Result.FDone := True;
2412 Exit;
2413 end;
2414
2415
2416 //??RL?後?
2417 //http://server.2ch.net/test/read.cgi?bbs=ITA_NAME&key=1000000000&st=1&to=5&nofirst=true
2418 FAWKStr.RegExp := '/test/read\.cgi\?';
2419 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2420 s := Copy(s, 16, Length(s));
2421 SList := TStringList.Create;
2422 try
2423 SList.Clear;
2424 FAWKStr.RegExp := '&';
2425 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2426 Result.FFirst := True;
2427 for i := 0 to SList.Count - 1 do begin
2428 if Pos('bbs=', SList[i]) = 1 then begin
2429 Result.FBBS := Copy(SList[i], 5, Length(SList[i]));
2430 end else if Pos('key=', SList[i]) = 1 then begin
2431 Result.FKey := Copy(SList[i], 5, Length(SList[i]));
2432 end else if Pos('st=', SList[i]) = 1 then begin
2433 wk := Copy(SList[i], 4, Length(SList[i]));
2434 if IsNumeric(wk) then
2435 Result.FSt := StrToInt(wk)
2436 else if wk = '' then
2437 Result.FStBegin := True;
2438 end else if Pos('to=', SList[i]) = 1 then begin
2439 wk := Copy(SList[i], 4, Length(SList[i]));
2440 if IsNumeric(wk) then
2441 Result.FTo := StrToInt(wk)
2442 else if wk = '' then
2443 Result.FToEnd := True;
2444 end else if Pos('nofirst=', SList[i]) = 1 then begin
2445 Result.FFirst := False;
2446 end;
2447 end;
2448 end else
2449 Exit;
2450 finally
2451 SList.Free;
2452 end;
2453
2454 if (Result.FBBS <> '') and (Result.FKey <> '') then begin
2455 Result.FDone := True;
2456 end;
2457 Exit;
2458 end;
2459 end;
2460
2461 procedure TGikoSys.ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
2462 var
2463 URI: TIdURI;
2464 begin
2465 Protocol := '';
2466 Host := '';
2467 Path := '';
2468 Document := '';
2469 Port := '';
2470 Bookmark := '';
2471 URI := TIdURI.Create(URL);
2472 try
2473 Protocol := URI.Protocol;
2474 Host := URI.Host;
2475 Path := URI.Path;
2476 Document := URI.Document;
2477 Port := URI.Port;
2478 Bookmark := URI.Bookmark;
2479 finally
2480 URI.Free;
2481 end;
2482 end;
2483
2484 function TGikoSys.GetVersionBuild: Integer;
2485 var
2486 FixedFileInfo: PVSFixedFileInfo;
2487 VersionHandle, VersionSize: DWORD;
2488 pVersionInfo: Pointer;
2489 ItemLen : UInt;
2490 AppFile: string;
2491 begin
2492 Result := 0;
2493 AppFile := Application.ExeName;
2494 VersionSize := GetFileVersionInfoSize(pChar(AppFile), VersionHandle);
2495 if VersionSize = 0 then
2496 Exit;
2497 GetMem(pVersionInfo, VersionSize);
2498 try
2499 if GetFileVersionInfo(PChar(AppFile),VersionHandle,VersionSize, pVersionInfo) then
2500 if VerQueryValue(pVersionInfo, '\', Pointer(FixedFileInfo), ItemLen) then
2501 Result := LOWORD(FixedFileInfo^.dwFileVersionLS);
2502 finally
2503 FreeMem(pVersionInfo, VersionSize);
2504 end;
2505 end;
2506
2507 initialization
2508 GikoSys := TGikoSys.Create;
2509
2510 finalization
2511 if GikoSys <> nil then begin
2512 GikoSys.Free;
2513 GikoSys := nil;
2514 end;
2515 end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26