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.82 - (show annotations) (download) (as text)
Sun Nov 23 10:38:30 2003 UTC (20 years, 5 months ago) by yoffy
Branch: MAIN
Changes since 1.81: +9 -10 lines
File MIME type: text/x-pascal
・色々と URL に関する不具合を修正。

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 FOnlyAHundredRes : Boolean;
92 // FExitWrite: TStringList;
93 // function StrToFloatDef(s: string; Default: Double): Double;
94
95 public
96 { Public 絎h? }
97 FAbon : TAbon;
98 FSelectResFilter : TAbon;
99 constructor Create;
100
101 destructor Destroy; override;
102 property OnlyAHundredRes : Boolean read FOnlyAHundredRes write FOnlyAHundredRes;
103
104 // function MsgBox(Msg: string; Title: string; Flags: Longint): integer; overload;
105 // function MsgBox(Handle: THandle; Msg: string; Title: string; Flags: Longint): integer; overload;
106 function IsNumeric(s: string): boolean;
107 function IsFloat(s: string): boolean;
108 function DirectoryExistsEx(const Name: string): Boolean;
109 function ForceDirectoriesEx(Dir: string): Boolean;
110 // function GetVersion: string;
111
112 function GetBoardFileName: string;
113 function GetCustomBoardFileName: string;
114 function GetHtmlTempFileName: string;
115 function GetAppDir: string;
116 function GetTempFolder: string;
117 function GetSentFileName: string;
118 function GetConfigDir: string;
119 function GetSkinDir: string;
120 function GetSkinHeaderFileName: string;
121 function GetSkinFooterFileName: string;
122 function GetSkinResFileName: string;
123 function GetSkinNewResFileName: string;
124 function GetSkinBookmarkFileName: string;
125 function GetSkinNewmarkFileName: string;
126 function GetStyleSheetDir: string;
127 function GetOutBoxFileName: string;
128 function GetUserAgent: string;
129
130 procedure ReadSubjectFile(Board: TBoard);
131 procedure CreateThreadDat(Board: TBoard);
132 procedure WriteThreadDat(Board: TBoard);
133 function ParseIndexLine(Line: string): TIndexRec;
134 procedure GetFileList(Path: string; Mask: string; List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
135 procedure GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
136
137 procedure CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
138 function AddAnchorTag(s: string): string;
139
140 function DivideSubject(Line: string): TSubjectRec;
141 function DivideStrLine(Line: string): TResRec;
142
143 property Setting: TSetting read FSetting write FSetting;
144 property Dolib: TDolib read FDolib write FDolib;
145
146 function UrlToID(url: string): string;
147 function UrlToServer(url: string): string;
148
149 function StrTokFirst(const s:string; const sep:TStrTokSeparator; var Rec:TStrTokRec):string;
150 function StrTokNext(const sep:TStrTokSeparator; var Rec:TStrTokRec): string;
151
152 function GetFileSize(FileName : string) : longint;
153 function GetFileLineCount(FileName : string): longint;
154 function Get2chDate(aDate: TDateTime): string;
155 function IntToDateTime(val: Int64): TDateTime;
156 function DateTimeToInt(ADate: TDateTime): Integer;
157
158 function ReadThreadFile(FileName: string; Line: Integer): string;
159
160 procedure MenuFont(Font: TFont);
161
162 function RemoveToken(var s:string;delimiter:string):string;
163 function GetTokenIndex(s: string; delimiter: string; index: Integer): string;
164
165 function DeleteLink(const s: string): string;
166
167 function GetShortName(const LongName: string; ALength: integer): string;
168 function ConvRes(const Body, Bbs, Key, ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
169
170 function ZenToHan(const s: string): string;
171 function VaguePos(const Substr, S: string): Integer;
172 function BoolToInt(b: Boolean): Integer;
173 function IntToBool(i: Integer): Boolean;
174 function GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
175 procedure LoadKeySetting(ActionList: TActionList);
176 procedure SaveKeySetting(ActionList: TActionList);
177 procedure CreateProcess(const AppPath: string; const Param: string);
178 procedure OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
179 function HTMLDecode(const AStr: String): String;
180 function GetHRefText(s: string): string;
181 function Is2chHost(Host: string): Boolean;
182 function Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
183 function Parse2chURL2(URL: string): TPathRec;
184 procedure ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
185 function GetVersionBuild: Integer;
186 function Get2chThreadURL2BoardURL( inURL : string ) : string;
187 function Get2chBrowsableThreadURL( inURL : string ) : string;
188 function Get2chBoard2ThreadURL( inBoard : TBoard; inKey : string ) : string;
189 procedure ReadBoardFile;
190
191 // ?鴻???潟??茯??粋昭?帥???ゃ??臀??????
192 function LoadFromSkin( fileName: string; ThreadItem: TThreadItem; SizeByte: Integer ): string;
193 // ???鴻???ゃ??臀??????
194 function SkinedRes( skin: string; Res: TResRec; No: string ): string;
195
196 end;
197
198 var
199 GikoSys: TGikoSys;
200 const
201 LENGTH_RESTITLE = 40;
202 ZERO_DATE: Integer = 25569;
203 BETA_VERSION_NAME_E = 'beta';
204 BETA_VERSION_NAME_J = '鐓?鐓?鐓?';
205 BETA_VERSION = 44;
206 BETA_VERSION_BUILD = ''; //debug??????/span>
207 APP_NAME = 'gikoNavi';
208
209 implementation
210
211 uses
212 Giko, RoundData, ExternalBoardManager, ExternalBoardPlugInMain;
213
214 const
215 FOLDER_INDEX_VERSION = '1.01';
216 USER_AGENT = 'Monazilla';
217 DEFAULT_NGWORD_FILE_NAME : String = 'NGword.txt';
218 NGWORDs_DIR_NAME : String = 'NGwords';
219
220 READ_PATH: string = '/test/read.cgi/';
221 OLD_READ_PATH: string = '/test/read.cgi?';
222 KAKO_PATH: string = '/kako/';
223
224 (*************************************************************************
225 *GikoSys?潟?潟?鴻????????/span>
226 *************************************************************************)
227 constructor TGikoSys.Create;
228 begin
229 FSetting := TSetting.Create;
230 FDolib := TDolib.Create;
231 FAWKStr := TAWKStr.Create(nil);
232 if DirectoryExists(GetConfigDir) = false then begin
233 CreateDir(GetConfigDir);
234 end;
235 FAbon := TAbon.Create;
236 FAbon.Setroot(GetConfigDir+NGWORDs_DIR_NAME);
237 FAbon.GoHome;
238 FAbon.ReturnNGwordLineNum := FSetting.ShowNGLinesNum;
239 FAbon.SetNGResAnchor := FSetting.AddResAnchor;
240 FAbon.Deleterlo := FSetting.AbonDeleterlo;
241 FAbon.Replaceul := FSetting.AbonReplaceul;
242 FAbon.AbonPopupRes := FSetting.PopUpAbon;
243
244 FSelectResFilter := TAbon.Create;
245 // 腟???莨若????????サ??筝?荀с??荀????????祉???????????т????????????/span>
246 FSelectResFilter.AbonString := '';
247 //
248 OnlyAHundredRes := FSetting.OnlyAHundredRes;
249 end;
250
251 (*************************************************************************
252 *GikoSys???鴻????????/span>
253 *************************************************************************)
254 destructor TGikoSys.Destroy;
255 var
256 i: Integer;
257 FileList: TStringList;
258 begin
259 //?鴻?????????若?帥???<?ゃ?????贋??/span>
260 // FlashExitWrite;
261
262 // FExitWrite.Free;
263 FAWKStr.Free;
264 FSetting.Free;
265 FDolib.Free;
266
267 //???潟??????TML??????/span>
268 FileList := TStringList.Create;
269 try
270 GetFileList(GetTempFolder, '*.html', FileList, False, True);
271 for i := 0 to FileList.Count - 1 do begin
272 DeleteFile(FileList[i]);
273 end;
274 finally
275 FileList.Free;
276 end;
277 inherited;
278 end;
279
280 (*************************************************************************
281 *??絖????医????с????/span>
282 *************************************************************************)
283 {$HINTS OFF}
284 function TGikoSys.IsNumeric(s: string): boolean;
285 var
286 e: integer;
287 v: integer;
288 begin
289 Val(s, v, e);
290 Result := e = 0;
291 end;
292 {$HINTS ON}
293
294 (*************************************************************************
295 *??絖???羌???絨?亥?号?医????с????/span>
296 *************************************************************************)
297 function TGikoSys.IsFloat(s: string): boolean;
298 var
299 v: Extended;
300 begin
301 Result := TextToFloat(PChar(s), v, fvExtended);
302 end;
303
304 (*************************************************************************
305 *???若?????<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
306 *************************************************************************)
307 function TGikoSys.GetBoardFileName: string;
308 begin
309 Result := Setting.GetBoardFileName;
310 end;
311
312 (*************************************************************************
313 *???若?????<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
314 *************************************************************************)
315 function TGikoSys.GetCustomBoardFileName: string;
316 begin
317 Result := Setting.GetCustomBoardFileName;
318 end;
319
320 (*************************************************************************
321 *???潟???????????????弱????緇?
322 *************************************************************************)
323 function TGikoSys.GetHtmlTempFileName: string;
324 begin
325 Result := Setting.GetHtmlTempFileName;
326 end;
327
328
329 (*************************************************************************
330 *絎?茵????<?ゃ????????????緇?
331 *************************************************************************)
332 function TGikoSys.GetAppDir: string;
333 begin
334 Result := Setting.GetAppDir;
335 end;
336
337 (*************************************************************************
338 *TempHtml???<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
339 *************************************************************************)
340 function TGikoSys.GetTempFolder: string;
341 begin
342 Result := Setting.GetTempFolder;
343 end;
344
345 (*************************************************************************
346 *sent.ini???<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
347 *************************************************************************)
348 function TGikoSys.GetSentFileName: string;
349 begin
350 Result := Setting.GetSentFileName;
351 end;
352
353 (*************************************************************************
354 *outbox.ini???<?ゃ??????緇?鐚????刻????<?ゃ????鐚?
355 *************************************************************************)
356 function TGikoSys.GetOutBoxFileName: string;
357 begin
358 Result := Setting.GetOutBoxFileName;
359 end;
360
361 (*************************************************************************
362 *Config??????????緇?
363 *************************************************************************)
364 function TGikoSys.GetConfigDir: string;
365 begin
366 Result := Setting.GetConfigDir;
367 end;
368
369 function TGikoSys.GetStyleSheetDir: string;
370 begin
371 Result := Setting.GetStyleSheetDir;
372 end;
373
374 function TGikoSys.GetSkinDir: string;
375 begin
376 Result := Setting.GetSkinDir;
377 end;
378
379 function TGikoSys.GetSkinHeaderFileName: string;
380 begin
381 Result := Setting.GetSkinHeaderFileName;
382 end;
383
384 function TGikoSys.GetSkinFooterFileName: string;
385 begin
386 Result := Setting.GetSkinFooterFileName;
387 end;
388
389 function TGikoSys.GetSkinNewResFileName: string;
390 begin
391 Result := Setting.GetSkinNewResFileName;
392 end;
393
394 function TGikoSys.GetSkinResFileName: string;
395 begin
396 Result := Setting.GetSkinResFileName;
397 end;
398
399 function TGikoSys.GetSkinBookmarkFileName: string;
400 begin
401 Result := Setting.GetSkinBookmarkFileName;
402 end;
403
404 function TGikoSys.GetSkinNewmarkFileName: string;
405 begin
406 Result := Setting.GetSkinNewmarkFileName;
407 end;
408
409 // UserAgent??緇?
410 function TGikoSys.GetUserAgent: string;
411 begin
412 if Dolib.Connected then begin
413 Result := Format('%s %s/%s%d%s', [
414 Dolib.UserAgent,
415 APP_NAME,
416 //MAJOR_VERSION,
417 //MINOR_VERSION,
418 BETA_VERSION_NAME_E,
419 BETA_VERSION,
420 BETA_VERSION_BUILD]);
421 end else begin
422 Result := Format('%s/%s %s/%s%d%s', [
423 USER_AGENT,
424 Dolib.Version,
425 APP_NAME,
426 //MAJOR_VERSION,
427 //MINOR_VERSION,
428 BETA_VERSION_NAME_E,
429 BETA_VERSION,
430 BETA_VERSION_BUILD]);
431 end;
432 end;
433
434 (*************************************************************************
435 *鐚??<?????????劫????糸??
436 *************************************************************************)
437 function TGikoSys.Get2chDate(aDate: TDateTime): string;
438 var
439 d1: TDateTime;
440 d2: TDateTime;
441 begin
442 d1 := EncodeDate(1970, 1, 1);
443 d2 := aDate - EncodeTime(9, 0, 0, 0);
444 Result := FloatToStr(Trunc((d2 - d1) * 24 * 60 * 60));
445 end;
446
447
448 function TGikoSys.IntToDateTime(val: Int64): TDateTime;
449 var
450 d1: tdatetime;
451 d2: tdatetime;
452 begin
453 d1 := EncodeDate(1970, 1, 1);
454 d2 := (val * 1000) / (24 * 60 * 60 * 1000);
455 Result := d1 + d2;
456 end;
457
458 function TGikoSys.DateTimeToInt(ADate: TDateTime): Integer;
459 var
460 d: TDateTime;
461 c: Currency;
462 begin
463 d := EncodeDate(1970, 1, 1);
464 c := (ADate - d) * 24 * 60 * 60;
465 Result := Trunc(c);
466 end;
467
468
469 (*************************************************************************
470 *Subject???<?ゃ??ead
471 *************************************************************************)
472 procedure TGikoSys.ReadSubjectFile(Board: TBoard);
473 var
474 ThreadItem: TThreadItem;
475 FileName: string;
476 FileList: TStringList;
477 TmpFileList: TStringList;
478 // SrchRec: TSearchRec;
479 // R: integer;
480 Index: Integer;
481 sl: TStringList;
482 i: Integer;
483 Rec: TIndexRec;
484 UnRead: Integer;
485 // TmpUpdate: Boolean;
486 ini: TMemIniFile;
487 ResRec: TResRec;
488 RoundItem: TRoundItem;
489 idx: Integer;
490 usePlugIn : Boolean;
491 begin
492 Board.Clear;
493 UnRead := 0;
494 // TmpUpdate := False;
495
496 usePlugIn := Board.IsBoardPlugInAvailable;
497
498 FileName := Board.GetFolderIndexFileName;
499 if not FileExists(FileName) then CreateThreadDat(Board);
500 // if not FileExists(FileName) then Exit;
501
502 { R := FindFirst(ExtractFileDir(Board.GetFolderIndexFileName) + '\*.dat', 0, SrchRec);
503 while R = 0 do begin
504 FileList.Add(SrchRec.Name);
505 R := FindNext(SrchRec);
506 end;
507 FindClose(SrchRec);}
508
509 FileList := TStringList.Create;
510 FileList.Sorted := True;
511 TmpFileList := TStringList.Create;
512 TmpFileList.Sorted := True;
513
514 //IsLogFile??AT???<?ゃ?????鴻??
515 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False, False);
516
517 //?????医幻腟?篋?????mp???<?ゃ?????鴻??
518 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, False, False);
519
520
521 sl := TStringList.Create;
522 try
523 if FileExists(FileName) then
524 sl.LoadFromFile(FileName);
525
526 //鐚?茵???????鐚?鐚?茵????????若?吾?с?鰹?
527 for i := sl.Count - 1 downto 1 do begin
528 Rec := ParseIndexLine(sl[i]);
529
530 if usePlugIn then
531 ThreadItem := TThreadItem.Create(
532 Board.BoardPlugIn,
533 Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), Rec.FFileName ) )
534 else begin
535 ThreadItem := TThreadItem.Create(
536 nil,
537 Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) );
538
539 //IsLogFile???с????/span>
540 ThreadItem.IsLogFile := False;
541 if FileList.Count <> 0 then begin
542 if FileList.Find( ThreadItem.FileName, Index ) then begin
543 ThreadItem.IsLogFile := True;
544 FileList.Delete( Index );
545 end;
546 end;
547 end;
548 ThreadItem.BeginUpdate;
549 ThreadItem.No := Rec.FNo;
550 ThreadItem.FileName := Rec.FFileName;
551 ThreadItem.Title := Rec.FTitle;
552 ThreadItem.Count := Rec.FCount;
553 ThreadItem.Size := Rec.FSize;
554 // ThreadItem.RoundNo := Rec.FRoundNo;
555 ThreadItem.RoundDate := Rec.FRoundDate;
556 ThreadItem.LastModified := Rec.FLastModified;
557 ThreadItem.Kokomade := Rec.FKokomade;
558 ThreadItem.NewReceive := Rec.FNewReceive;
559 // ThreadItem.Round := Rec.FRound;
560 ThreadItem.UnRead := Rec.FUnRead;
561 ThreadItem.ScrollTop := Rec.FScrollTop;
562 ThreadItem.AllResCount := Rec.FAllResCount;
563 ThreadItem.NewResCount := Rec.FNewResCount;
564 ThreadItem.AgeSage := Rec.FAgeSage;
565 ThreadItem.ParentBoard := Board;
566
567 //綏≦?????鴻?????????????綏≦???????違?祉????
568 if ThreadItem.IsLogFile then begin
569 idx := RoundList.Find(ThreadItem);
570 if idx <> -1 then begin
571 RoundItem := RoundList.Items[idx, grtItem];
572 ThreadItem.RoundName := RoundItem.RoundName;
573 ThreadItem.Round := True;
574 end;
575 end;
576
577 //?????医幻腟?篋??????с????/span>
578 if TmpFileList.Count <> 0 then begin
579 if TmpFileList.Find(ChangeFileExt(ThreadItem.FileName, '.tmp'), Index) then begin
580 ini := TMemIniFile.Create(ChangeFileExt(ThreadItem.GetThreadFileName, '.tmp'));
581 try
582 ThreadItem.RoundDate := ini.ReadDateTime('Setting', 'RoundDate', ZERO_DATE);
583 ThreadItem.LastModified := ini.ReadDateTime('Setting', 'LastModified', ZERO_DATE);
584 ThreadItem.Size := ini.ReadInteger('Setting', 'Size', 0);
585 ThreadItem.Count := ini.ReadInteger('Setting', 'Count', 0);
586 ThreadItem.NewReceive := ini.ReadInteger('Setting', 'NewReceive', 0);
587 ThreadItem.Round := ini.ReadBool('Setting', 'Round', False);
588 ThreadItem.UnRead := False;//ini.ReadBool('Setting', 'UnRead', False);
589 ThreadItem.ScrollTop := ini.ReadInteger('Setting', 'ScrollTop', 0);
590 ThreadItem.AllResCount := ini.ReadInteger('Setting', 'AllResCount', 0);
591 ThreadItem.NewResCount := ini.ReadInteger('Setting', 'NewResCount', 0);
592 ThreadItem.AgeSage := TGikoAgeSage(ini.ReadInteger('Setting', 'AgeSage', Ord(gasNone)));
593 finally
594 ini.Free;
595 end;
596 TmpFileList.Delete(Index);
597 end;
598 end;
599
600 ThreadItem.EndUpdate;
601 Board.Add(ThreadItem);
602
603 // if (ThreadItem.IsLogFile) and (ThreadItem.Count > ThreadItem.Kokomade) then
604 if (ThreadItem.IsLogFile) and (ThreadItem.UnRead) then
605 Inc(UnRead);
606 end;
607
608 if UnRead <> Board.UnRead then
609 Board.UnRead := UnRead;
610
611 //?ゃ?潟???????鴻???<???c?????違??菴遵??鐚??????ゃ?潟???????劫?綽?鐚?
612 for i := 0 to FileList.Count - 1 do begin
613 FileName := ExtractFileDir(Board.GetFolderIndexFileName) + '\' + FileList[i];
614
615 ResRec := DivideStrLine(ReadThreadFile(FileName, 1));
616 if usePlugIn then
617 ThreadItem := TThreadItem.Create(
618 Board.BoardPlugIn,
619 Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), Rec.FFileName ) )
620 else
621 ThreadItem := TThreadItem.Create(
622 nil, Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) );
623 ThreadItem.No := Board.Count + 1;
624 ThreadItem.FileName := FileList[i];
625 ThreadItem.Title := ResRec.FTitle;
626 ThreadItem.Count := GetFileLineCount(FileName);
627 ThreadItem.AllResCount := ThreadItem.Count;
628 ThreadItem.NewResCount := 0;
629 ThreadItem.Size := 0;
630 ThreadItem.RoundDate := ZERO_DATE;
631 ThreadItem.LastModified := ZERO_DATE;
632 ThreadItem.Kokomade := -1;
633 ThreadItem.NewReceive := 0;
634 ThreadItem.ParentBoard := Board;
635 ThreadItem.IsLogFile := True;
636 ThreadItem.Round := False;
637 ThreadItem.UnRead := False;
638 ThreadItem.ScrollTop := 0;
639 ThreadItem.AgeSage := gasNone;
640 Board.Add(ThreadItem);
641 end;
642 finally
643 sl.Free;
644 end;
645 FileList.Free;
646 TmpFileList.Free;
647 Board.IsThreadDatRead := True;
648 end;
649
650 (*************************************************************************
651 *?鴻???????ゃ?潟???????鴻???<?ゃ??Folder.idx)篏???
652 *************************************************************************)
653 procedure TGikoSys.CreateThreadDat(Board: TBoard);
654 var
655 i: integer;
656 s: string;
657 SubjectList: TStringList;
658 sl: TStringList;
659 Rec: TSubjectRec;
660 FileName: string;
661 cnt: Integer;
662 begin
663 if not FileExists(Board.GetSubjectFileName) then Exit;
664 FileName := Board.GetFolderIndexFileName;
665
666 SubjectList := TStringList.Create;
667 try
668 SubjectList.LoadFromFile(Board.GetSubjectFileName);
669 sl := TStringList.Create;
670 try
671 cnt := 1;
672 sl.Add(FOLDER_INDEX_VERSION);
673 for i := 0 to SubjectList.Count - 1 do begin
674 Rec := DivideSubject(SubjectList[i]);
675
676 if (Trim(Rec.FFileName) = '') or (Trim(Rec.FTitle) = '') then
677 Continue;
678
679 s := Format('%x', [cnt]) + #1 //???/span>
680 + Rec.FFileName + #1 //???<?ゃ????
681 + Rec.FTitle + #1 //?帥?ゃ????/span>
682 + Format('%x', [Rec.FCount]) + #1 //?????潟??
683 + Format('%x', [0]) + #1 //size
684 + Format('%x', [0]) + #1 //RoundDate
685 + Format('%x', [0]) + #1 //LastModified
686 + Format('%x', [0]) + #1 //Kokomade
687 + Format('%x', [0]) + #1 //NewReceive
688 + '0' + #1 //??戎??/span>
689 + Format('%x', [0]) + #1 //UnRead
690 + Format('%x', [0]) + #1 //ScrollTop
691 + Format('%x', [Rec.FCount]) + #1 //AllResCount
692 + Format('%x', [0]) + #1 //NewResCount
693 + Format('%x', [0]); //AgeSage
694
695 sl.Add(s);
696 inc(cnt);
697 end;
698 sl.SaveToFile(FileName);
699 finally
700 sl.Free;
701 end;
702 finally
703 SubjectList.Free;
704 end;
705 end;
706
707 (*************************************************************************
708 *?鴻???????ゃ?潟????????Thread.dat)?吾??莨若??/span>
709 *Public
710 *************************************************************************)
711 procedure TGikoSys.WriteThreadDat(Board: TBoard);
712 //const
713 // Values: array[Boolean] of string = ('0', '1');
714 var
715 i: integer;
716 FileName: string;
717 sl: TStringList;
718 s: string;
719 FileList: TStringList;
720 begin
721 if not Board.IsThreadDatRead then
722 Exit;
723 FileName := Board.GetFolderIndexFileName;
724 ForceDirectoriesEx( ExtractFilePath( FileName ) );
725
726 sl := TStringList.Create;
727 try
728 sl.Add(FOLDER_INDEX_VERSION);
729 for i := 0 to Board.Count - 1 do begin
730 if Board.Items[i].No = 0 then
731 Board.Items[i].No := i + 1;
732
733 s := Format('%x', [Board.Items[i].No]) + #1
734 + Board.Items[i].FileName + #1
735 + Board.Items[i].Title + #1
736 + Format('%x', [Board.Items[i].Count]) + #1
737 + Format('%x', [Board.Items[i].Size]) + #1
738 + Format('%x', [DateTimeToInt(Board.Items[i].RoundDate)]) + #1
739 + Format('%x', [DateTimeToInt(Board.Items[i].LastModified)]) + #1
740 + Format('%x', [Board.Items[i].Kokomade]) + #1
741 + Format('%x', [Board.Items[i].NewReceive]) + #1
742 + '0' + #1 //??戎??/span>
743 + Format('%x', [BoolToInt(Board.Items[i].UnRead)]) + #1
744 + Format('%x', [Board.Items[i].ScrollTop]) + #1
745 + Format('%x', [Board.Items[i].AllResCount]) + #1
746 + Format('%x', [Board.Items[i].NewResCount]) + #1
747 + Format('%x', [Ord(Board.Items[i].AgeSage)]);
748
749 sl.Add(s);
750 end;
751
752 sl.SaveToFile(FileName);
753
754 FileList := TStringList.Create;
755 try
756 GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', FileList, False, True);
757 for i := 0 to FileList.Count - 1 do begin
758 DeleteFile(FileList[i]);
759 end;
760 finally
761 FileList.Free;
762 end;
763 finally
764 sl.Free;
765 end;
766 end;
767
768 function TGikoSys.ParseIndexLine(Line: string): TIndexRec;
769 var
770 s: string;
771 i: Integer;
772 begin
773 for i := 0 to 14 do begin
774 s := GetTokenIndex(Line, #1, i);
775 case i of
776 0: Result.FNo := StrToIntDef('$' + s, 0);
777 1: Result.FFileName := s;
778 2: Result.FTitle := s;
779 3: Result.FCount := StrToIntDef('$' + s, 0);
780 4: Result.FSize := StrToIntDef('$' + s, 0);
781 5: Result.FRoundDate := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
782 6: Result.FLastModified := IntToDateTime(StrToIntDef('$' + s, ZERO_DATE));
783 7: Result.FKokomade := StrToIntDef('$' + s, -1);
784 8: Result.FNewReceive := StrToIntDef('$' + s, 0);
785 9: ; //??戎??/span>
786 10: Result.FUnRead := IntToBool(StrToIntDef('$' + s, 0));
787 11: Result.FScrollTop := StrToIntDef('$' + s, 0);
788 12: Result.FAllResCount := StrToIntDef('$' + s, 0);
789 13: Result.FNewResCount := StrToIntDef('$' + s, 0);
790 14: Result.FAgeSage := TGikoAgeSage(StrToIntDef('$' + s, 0));
791 end;
792 end;
793 end;
794
795 //??絎???????????????絎????<?ゃ???荀с????緇?????
796 // ListFiles('c:\', '*.txt', list, True);
797 procedure TGikoSys.GetFileList(Path: string; Mask: string; List: TStringList; SubDir: Boolean; IsPathAdd: Boolean);
798 var
799 rc: Integer;
800 SearchRec : TSearchRec;
801 s: string;
802 begin
803 Path := IncludeTrailingPathDelimiter(Path);
804 rc := FindFirst(Path + '*.*', faAnyfile, SearchRec);
805 try
806 while rc = 0 do begin
807 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
808 s := Path + SearchRec.Name;
809 //if (SearchRec.Attr and faDirectory > 0) then
810 // s := IncludeTrailingPathDelimiter(s)
811
812 if (SearchRec.Attr and faDirectory = 0) and (MatchesMask(s, Mask)) then
813 if IsPathAdd then
814 List.Add(s)
815 else
816 List.Add(SearchRec.Name);
817 if SubDir and (SearchRec.Attr and faDirectory > 0) then
818 GetFileList(s, Mask, List, True, IsPathAdd);
819 end;
820 rc := FindNext(SearchRec);
821 end;
822 finally
823 SysUtils.FindClose(SearchRec);
824 end;
825 end;
826
827 //??絎????????????????c?????????荀с????緇?????
828 procedure TGikoSys.GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean);
829 var
830 rc: Integer;
831 SearchRec : TSearchRec;
832 s: string;
833 begin
834 Path := IncludeTrailingPathDelimiter(Path);
835 rc := FindFirst(Path + '*.*', faDirectory, SearchRec);
836 try
837 while rc = 0 do begin
838 if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin
839 s := Path + SearchRec.Name;
840 //if (SearchRec.Attr and faDirectory > 0) then
841 // s := IncludeTrailingPathDelimiter(s)
842
843 if (SearchRec.Attr and faDirectory > 0) and (MatchesMask(s, Mask)) then
844 List.Add( IncludeTrailingPathDelimiter( s ) );
845 if SubDir and (SearchRec.Attr and faDirectory > 0) then
846 GetDirectoryList(s, Mask, List, True);
847 end;
848 rc := FindNext(SearchRec);
849 end;
850 finally
851 SysUtils.FindClose(SearchRec);
852 end;
853 end;
854
855 // ?鴻???潟??茯??粋昭?帥???ゃ??臀??????
856 function TGikoSys.LoadFromSkin(
857 fileName: string;
858 ThreadItem: TThreadItem;
859 SizeByte: Integer
860 ): string;
861 var
862 Skin: TStringList;
863 begin
864
865 Skin := TStringList.Create;
866 try
867 if FileExists( fileName ) then begin
868 Skin.LoadFromFile( fileName );
869
870 // ???????????????????????????激?с?潟???ゃ?≪???違?????????ャ?主? try
871 try
872 if ThreadItem.ParentBoard <> nil then
873 if ThreadItem.ParentBoard.ParentCategory <> nil then
874 Skin.Text := StringReplace( Skin.Text, '<BBSNAME/>', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title, [rfReplaceAll] );
875 Skin.Text := StringReplace( Skin.Text, '<THREADURL/>', ThreadItem.URL, [rfReplaceAll] );
876 except end;
877 Skin.Text := StringReplace( Skin.Text, '<BOARDNAME/>', ThreadItem.ParentBoard.Title, [rfReplaceAll] );
878 Skin.Text := StringReplace( Skin.Text, '<BOARDURL/>', ThreadItem.ParentBoard.URL, [rfReplaceAll] );
879 Skin.Text := StringReplace( Skin.Text, '<THREADNAME/>', ThreadItem.Title, [rfReplaceAll] );
880 Skin.Text := StringReplace( Skin.Text, '<SKINPATH/>', Setting.CSSFileName, [rfReplaceAll] );
881 Skin.Text := StringReplace( Skin.Text, '<GETRESCOUNT/>', IntToStr( ThreadItem.NewReceive - 1 ), [rfReplaceAll] );
882 Skin.Text := StringReplace( Skin.Text, '<NEWRESCOUNT/>', IntToStr( ThreadItem.NewResCount ), [rfReplaceAll] );
883 Skin.Text := StringReplace( Skin.Text, '<ALLRESCOUNT/>', IntToStr( ThreadItem.AllResCount ), [rfReplaceAll] );
884
885 Skin.Text := StringReplace( Skin.Text, '<NEWDATE/>',
886 FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate), [rfReplaceAll] );
887 Skin.Text := StringReplace( Skin.Text, '<SIZEKB/>', IntToStr( Floor( SizeByte / 1024 ) ), [rfReplaceAll] );
888 Skin.Text := StringReplace( Skin.Text, '<SIZE/>', IntToStr( SizeByte ), [rfReplaceAll] );
889
890 //----- ?????????????<????????篋????????潟?<?潟???≪??????????????
891 // ???????????????????????????激?с?潟???ゃ?≪???違?????????ャ?主? try
892 try
893 if ThreadItem.ParentBoard <> nil then
894 if ThreadItem.ParentBoard.ParentCategory <> nil then
895 Skin.Text := StringReplace( Skin.Text, '&BBSNAME', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title, [rfReplaceAll] );
896 Skin.Text := StringReplace( Skin.Text, '&THREADURL', ThreadItem.URL, [rfReplaceAll] );
897 except end;
898 Skin.Text := StringReplace( Skin.Text, '&BOARDNAME', ThreadItem.ParentBoard.Title, [rfReplaceAll] );
899 Skin.Text := StringReplace( Skin.Text, '&BOARDURL', ThreadItem.ParentBoard.URL, [rfReplaceAll] );
900 Skin.Text := StringReplace( Skin.Text, '&THREADNAME', ThreadItem.Title, [rfReplaceAll] );
901 Skin.Text := StringReplace( Skin.Text, '&SKINPATH', Setting.CSSFileName, [rfReplaceAll] );
902 Skin.Text := StringReplace( Skin.Text, '&GETRESCOUNT', IntToStr( ThreadItem.NewReceive - 1 ), [rfReplaceAll] );
903 Skin.Text := StringReplace( Skin.Text, '&NEWRESCOUNT', IntToStr( ThreadItem.NewResCount ), [rfReplaceAll] );
904 Skin.Text := StringReplace( Skin.Text, '&ALLRESCOUNT', IntToStr( ThreadItem.AllResCount ), [rfReplaceAll] );
905
906 Skin.Text := StringReplace( Skin.Text, '&NEWDATE',
907 FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate), [rfReplaceAll] );
908 Skin.Text := StringReplace( Skin.Text, '&SIZEKB', IntToStr( Floor( SizeByte / 1024 ) ), [rfReplaceAll] );
909 Skin.Text := StringReplace( Skin.Text, '&SIZE', IntToStr( SizeByte ), [rfReplaceAll] );
910 //----- ?????障??/span>
911 end;
912 Result := Skin.Text;
913 finally
914 Skin.Free;
915 end;
916 end;
917
918 // ???鴻???ゃ??臀??????
919 function TGikoSys.SkinedRes(
920 skin: string;
921 Res: TResRec;
922 No: string
923 ): string;
924 begin
925
926 try
927 Skin := StringReplace( Skin, '<NUMBER/>',
928 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>', [rfReplaceAll] );
929 Skin := StringReplace( Skin, '<PLAINNUMBER/>', No, [rfReplaceAll] );
930 Skin := StringReplace( Skin, '<NAME/>', '<b>' + Res.FName + '</b>', [rfReplaceAll] );
931 Skin := StringReplace( Skin, '<MAILNAME/>',
932 '<a href="mailo:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>', [rfReplaceAll] );
933 Skin := StringReplace( Skin, '<MAIL/>', Res.FMailTo, [rfReplaceAll] );
934 Skin := StringReplace( Skin, '<DATE/>', Res.FDateTime, [rfReplaceAll] );
935 Skin := StringReplace( Skin, '<MESSAGE/>', Res.FBody, [rfReplaceAll] );
936
937 //----- ???<????????篋????????潟?<?潟???≪??????????????
938 Skin := StringReplace( Skin, '&NUMBER',
939 '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>', [rfReplaceAll] );
940 Skin := StringReplace( Skin, '&PLAINNUMBER', No, [rfReplaceAll] );
941 Skin := StringReplace( Skin, '&NAME', '<b>' + Res.FName + '</b>', [rfReplaceAll] );
942 Skin := StringReplace( Skin, '&MAILNAME',
943 '<a href="mailo:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>', [rfReplaceAll] );
944 Skin := StringReplace( Skin, '&MAIL', Res.FMailTo, [rfReplaceAll] );
945 Skin := StringReplace( Skin, '&DATE', Res.FDateTime, [rfReplaceAll] );
946 Skin := StringReplace( Skin, '&MESSAGE', Res.FBody, [rfReplaceAll] );
947 //----- ?????障??/span>
948
949 Result := Skin;
950 finally
951 end;
952
953 end;
954
955 procedure TGikoSys.CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
956 var
957 i: integer;
958 No: string;
959 //bufList : TStringList;
960 ReadList: TStringList;
961 SaveList: TStringList;
962 CSSFileName: string;
963 BBSID: string;
964 FileName: string;
965 NewReceiveNo: Integer;
966 Res: TResRec;
967 boardPlugIn : TBoardPlugIn;
968
969 UserOptionalStyle: string;
970 SkinHeader: string;
971 SkinNewRes: string;
972 SkinRes: string;
973 SizeByte: Integer;
974
975 function LoadSkin( fileName: string ): string;
976 begin
977 Result := LoadFromSkin( fileName, ThreadItem, SizeByte );
978 end;
979 function ReplaceRes( skin: string ): string;
980 begin
981 Result := SkinedRes( skin, Res, No );
982 end;
983 begin
984 if ThreadItem <> nil then begin
985 if ThreadItem.IsBoardPlugInAvailable then begin
986 //===== ?????違?ゃ?潟??????茵?ず
987 boardPlugIn := ThreadItem.BoardPlugIn;
988 NewReceiveNo := ThreadItem.NewReceive;
989
990 // ?????潟?????泣?ゃ?冴??┃絎?
991 if Length( GikoSys.Setting.BrowserFontName ) > 0 then
992 UserOptionalStyle := UserOptionalStyle +
993 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
994 if GikoSys.Setting.BrowserFontSize <> 0 then
995 UserOptionalStyle := UserOptionalStyle +
996 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
997 if GikoSys.Setting.BrowserFontColor <> -1 then
998 UserOptionalStyle := UserOptionalStyle +
999 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
1000 if GikoSys.Setting.BrowserBackColor <> -1 then
1001 UserOptionalStyle := UserOptionalStyle +
1002 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
1003 case GikoSys.Setting.BrowserFontBold of
1004 -1: UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
1005 1: UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;';
1006 end;
1007 case GikoSys.Setting.BrowserFontItalic of
1008 -1: UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
1009 1: UserOptionalStyle := UserOptionalStyle + 'font-style:italic;';
1010 end;
1011
1012 SaveList := TStringList.Create;
1013 try
1014 doc.open;
1015 // ??絖??潟?若?????????違?ゃ?潟??算????
1016 // doc.charset := 'Shift_JIS';
1017 threadItem.SizeByte := 0;
1018
1019 // ??????
1020 SaveList.Add( boardPlugIn.GetHeader( DWORD( threadItem ),
1021 '<style type="text/css">body {' + UserOptionalStyle + '}</style>' ) );
1022
1023 for i := 0 to threadItem.Count - 1 do begin
1024 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (threadItem.Count-i) > 101 ) then begin
1025 Continue;
1026 end;
1027
1028 // ?亥?????若??/span>
1029 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1030 try
1031 if GikoSys.Setting.UseSkin then begin
1032 SaveList.Add( LoadSkin( GetSkinNewmarkFileName ) );
1033 end else if GikoSys.Setting.UseCSS then begin
1034 SaveList.Add('<a name="new"></a><div class="new">?亥????? <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>');
1035 end else 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>?亥????? ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</b></font></td></tr></table>');
1039 SaveList.Add('<dl>');
1040 end;
1041 except
1042 SaveList.Add( '<a name="new"></a>' );
1043 end;
1044 end;
1045
1046 // ????/span>
1047 SaveList.Add( boardPlugIn.GetRes( DWORD( threadItem ), i + 1 ) );
1048
1049 if ThreadItem.Kokomade = (i + 1) then begin
1050 // ?????障?ц?????
1051 try
1052 if GikoSys.Setting.UseSkin then begin
1053 SaveList.Add( LoadSkin( GetSkinBookmarkFileName ) );
1054 end else if GikoSys.Setting.UseCSS then begin
1055 SaveList.Add('<a name="koko"></a><div class="koko">?潟?潟?障?ц?????</div>');
1056 end else begin
1057 SaveList.Add('</dl>');
1058 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>');
1059 SaveList.Add('<dl>');
1060 end;
1061 except
1062 SaveList.Add( '<a name="koko"></a>' );
1063 end;
1064 end;
1065
1066 threadItem.SizeByte := threadItem.SizeByte + Length( SaveList.Text );
1067 doc.Write(SaveList.Text);
1068 SaveList.Clear;
1069 end;
1070
1071 threadItem.SizeByte := threadItem.SizeByte + Length( SaveList.Text );
1072
1073 // ?鴻??????????
1074 SaveList.Add( boardPlugIn.GetFooter( DWORD( threadItem ), '<a name="bottom"></a>' ) );
1075
1076 doc.Write(SaveList.Text);
1077 finally
1078 SaveList.Free;
1079 doc.Close;
1080 end;
1081
1082 Exit;
1083 end;
1084 end;
1085 ShortDayNames[1] := '??#39;; ShortDayNames[2] := '??';
1086 ShortDayNames[3] := '??#39;; ShortDayNames[4] := '羂?#39;;
1087 ShortDayNames[5] := '??#39;; ShortDayNames[6] := '??';
1088 ShortDayNames[7] := '??';
1089 SizeByte := 0;
1090 BBSID := ThreadItem.ParentBoard.BBSID;
1091 NewReceiveNo := ThreadItem.NewReceive;
1092 ReadList := TStringList.Create;
1093 try
1094 if ThreadItem.IsLogFile then begin
1095 FileName := ThreadItem.GetThreadFileName;
1096 ReadList.LoadFromFile(FileName);
1097 FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
1098 FAbon.Execute(ReadList); // ???若????????/span>
1099 FSelectResFilter.Execute(ReadList); //???鴻?????c???帥???潟?違??????
1100 Res := DivideStrLine(ReadList[0]);
1101 Res.FTitle := StringReplace(Res.FTitle, '鐚?鐔?', ',', [rfReplaceAll]);
1102 sTitle := Res.FTitle;
1103 end else begin
1104 sTitle := StringReplace(ThreadItem.Title, '鐚?鐔?', ',', [rfReplaceAll]);
1105 end;
1106 SaveList := TStringList.Create;
1107 try
1108 doc.open;
1109 doc.charset := 'Shift_JIS';
1110
1111 // ?????潟?????泣?ゃ?冴??┃絎?
1112 if Length( GikoSys.Setting.BrowserFontName ) > 0 then
1113 UserOptionalStyle := UserOptionalStyle +
1114 'font-family:"' + GikoSys.Setting.BrowserFontName + '";';
1115 if GikoSys.Setting.BrowserFontSize <> 0 then
1116 UserOptionalStyle := UserOptionalStyle +
1117 'font-size:' + IntToStr( GikoSys.Setting.BrowserFontSize ) + 'pt;';
1118 if GikoSys.Setting.BrowserFontColor <> -1 then
1119 UserOptionalStyle := UserOptionalStyle +
1120 'color:#' + IntToHex( GikoSys.Setting.BrowserFontColor, 6 ) + ';';
1121 if GikoSys.Setting.BrowserBackColor <> -1 then
1122 UserOptionalStyle := UserOptionalStyle +
1123 'background-color:#' + IntToHex( GikoSys.Setting.BrowserBackColor, 6 ) + ';';
1124 case GikoSys.Setting.BrowserFontBold of
1125 -1: UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
1126 1: UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;';
1127 end;
1128 case GikoSys.Setting.BrowserFontItalic of
1129 -1: UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
1130 1: UserOptionalStyle := UserOptionalStyle + 'font-style:italic;';
1131 end;
1132
1133 CSSFileName := GetStyleSheetDir + Setting.CSSFileName;
1134 if GikoSys.Setting.UseSkin then begin
1135 // ?鴻???割戎??/span>
1136 // ?鴻???潟??┃絎?
1137 try
1138 SkinHeader := LoadSkin( GetSkinHeaderFileName );
1139 if Length( UserOptionalStyle ) > 0 then
1140 SkinHeader := StringReplace( SkinHeader, '</head>',
1141 '<style type="text/css">body {' + UserOptionalStyle + '}</style></head>', [rfReplaceAll] );
1142 SaveList.Add( SkinHeader );
1143 except
1144 end;
1145 try
1146 SkinNewRes := LoadSkin( GetSkinNewResFileName );
1147 except
1148 end;
1149 try
1150 SkinRes := LoadSkin( GetSkinResFileName );
1151 except
1152 end;
1153
1154 SaveList.Add('<a name="top"></a>');
1155
1156 for i := 0 to ReadList.Count - 1 do begin
1157 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1158 Continue;
1159 end;
1160 if (Trim(ReadList[i]) <> '') then begin
1161 No := IntToStr(i + 1);
1162
1163 Res := DivideStrLine(ReadList[i]);
1164 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1165
1166 if Res.FType = glt2chOld then begin
1167 Res.FMailTo := StringReplace(Res.FMailTo, '鐚?鐔?', ',', [rfReplaceAll]);
1168 Res.FName := StringReplace(Res.FName, '鐚?鐔?', ',', [rfReplaceAll]);
1169 Res.FBody := StringReplace(Res.FBody, '鐚?鐔?', ',', [rfReplaceAll]);
1170 end;
1171
1172 Res.FBody := AddAnchorTag(Res.FBody);
1173 if Res.FName = '' then
1174 Res.FName := '&nbsp;';
1175
1176 // ?亥?????若??/span>
1177 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1178 try
1179 SaveList.Add( LoadSkin( GetSkinNewmarkFileName ) );
1180 except
1181 SaveList.Add( '<a name="new"></a>' );
1182 end;
1183 end;
1184 try
1185 if NewReceiveNo <= (i + 1) then
1186 // ?亥??????/span>
1187 SaveList.Add( ReplaceRes( SkinNewRes ) )
1188 else
1189 // ??絽吾??????/span>
1190 SaveList.Add( ReplaceRes( SkinRes ) );
1191 except
1192 end;
1193 if ThreadItem.Kokomade = (i + 1) then begin
1194 // ?????障?ц?????
1195 try
1196 SaveList.Add( LoadSkin( GetSkinBookmarkFileName ) );
1197 except
1198 SaveList.Add( '<a name="koko"></a>' );
1199 end;
1200 end;
1201 end;
1202 SizeByte := SizeByte + Length( SaveList.Text );
1203 doc.Write(SaveList.Text);
1204 SaveList.Clear;
1205 end;
1206 SaveList.Add('<a name="bottom"></a>');
1207 SizeByte := SizeByte + Length( SaveList.Text );
1208 // ?鴻??????????
1209 try
1210 SaveList.Add( LoadSkin( GetSkinFooterFileName ) );
1211 except
1212 end;
1213 doc.Write(SaveList.Text);
1214
1215 end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
1216 //CSS篏睡??/span>
1217 //CSSFileName := GetAppDir + CSS_FILE_NAME;
1218 // SaveList.Add('<html lang="ja"><head>');
1219 SaveList.Add('<html><head>');
1220 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1221 SaveList.Add('<title>' + sTitle + '</title>');
1222 SaveList.Add('<link rel="stylesheet" href="'+CSSFileName+'" type="text/css">');
1223 if Length( UserOptionalStyle ) > 0 then
1224 SaveList.Add('<style type="text/css">body {' + UserOptionalStyle + '}</style>');
1225 SaveList.Add('</head>');
1226 SaveList.Add('<body>');
1227 SaveList.Add('<a name="top"></a>');
1228 SaveList.Add('<div class="title">' + sTitle + '</div>');
1229 doc.Write(SaveList.Text);
1230 SaveList.Clear;
1231 //Application.ProcessMessages;
1232 for i := 0 to ReadList.Count - 1 do begin
1233 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1234 Continue;
1235 end;
1236 if (Trim(ReadList[i]) <> '') then begin
1237 No := IntToStr(i + 1);
1238 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1239 SaveList.Add('<a name="new"></a><div class="new">?亥????? <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>');
1240 end;
1241 Res := DivideStrLine(ReadList[i]);
1242 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1243 Res.FBody := AddAnchorTag(Res.FBody);
1244 if Res.FName = '' then
1245 Res.FName := '&nbsp;';
1246 if Res.FMailTo = '' then
1247 SaveList.Add('<a name="' + No + '"></a>'
1248 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span> '
1249 + '<span class="name_label">????鐚?</span> '
1250 + '<span class="name"><b>' + Res.FName + '</b></span> '
1251 + '<span class="date_label">??腮炊?ワ?</span> '
1252 + '<span class="date">' + Res.FDateTime+ '</span></div>'
1253 + '<div class="mes">' + Res.FBody + ' </div>')
1254 else if GikoSys.Setting.ShowMail then
1255 SaveList.Add('<a name="' + No + '"></a>'
1256 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1257 + '<span class="name_label"> ????鐚? </span>'
1258 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1259 + '<b>' + Res.FName + '</b></a><span class="mail"> [' + Res.FMailTo + ']</span>'
1260 + '<span class="date_label"> ??腮炊?ワ?</span>'
1261 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1262 + '<div class="mes">' + Res.FBody + ' </div>')
1263 else
1264 SaveList.Add('<a name="' + No + '"></a>'
1265 + '<div class="header"><span class="no"><a href="menu:' + No + '">' + No + '</a></span>'
1266 + '<span class="name_label"> ????鐚? </span>'
1267 + '<a class="name_mail" href="mailto:' + Res.FMailTo + '">'
1268 + '<b>' + Res.FName + '</b></a>'
1269 + '<span class="date_label"> ??腮炊?ワ?</span>'
1270 + '<span class="date"> ' + Res.FDateTime+ '</span></div>'
1271 + '<div class="mes">' + Res.FBody + ' </div>');
1272 if ThreadItem.Kokomade = (i + 1) then begin
1273 SaveList.Add('<a name="koko"></a><div class="koko">?潟?潟?障?ц?????</div>');
1274 end;
1275 end;
1276
1277 doc.Write(SaveList.Text);
1278 SaveList.Clear;
1279 end;
1280 //FOnlyAHundredRes
1281 SaveList.Add('<a name="bottom"></a>');
1282 SaveList.Add('</body></html>');
1283 SaveList.Add('<a name="last"></a>');
1284 SaveList.Add('</body></html>');
1285
1286 doc.Write(SaveList.Text);
1287 end else begin
1288 //CSS??篏睡??/span>
1289 // SaveList.Add('<html lang="ja"><head>');
1290 SaveList.Add('<html><head>');
1291 SaveList.Add('<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">');
1292 SaveList.Add('<title>' + sTitle + '</title></head>');
1293 SaveList.Add('<body TEXT="#000000" BGCOLOR="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">');
1294 SaveList.Add('<a name="top"></a>');
1295 SaveList.Add('<font size=+1 color="#FF0000">' + sTitle + '</font>');
1296 SaveList.Add('<dl>');
1297 doc.Write(SaveList.Text);
1298 SaveList.Clear;
1299 //Application.ProcessMessages;
1300 for i := 0 to ReadList.Count - 1 do begin
1301 if (OnlyAHundredRes = true) and ( i <> 0 ) and ( (ReadList.Count-i) > 101 ) then begin
1302 Continue;
1303 end;
1304 if (Trim(ReadList[i]) <> '') then begin
1305 No := IntToStr(i + 1);
1306
1307 if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
1308 SaveList.Add('</dl>');
1309 SaveList.Add('<a name="new"></a>');
1310 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>');
1311 SaveList.Add('<dl>');
1312 end;
1313 Res := DivideStrLine(ReadList[i]);
1314 Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
1315 if Res.FType = glt2chOld then begin
1316 Res.FMailTo := StringReplace(Res.FMailTo, '鐚?鐔?', ',', [rfReplaceAll]);
1317 Res.FName := StringReplace(Res.FName, '鐚?鐔?', ',', [rfReplaceAll]);
1318 Res.FBody := StringReplace(Res.FBody, '鐚?鐔?', ',', [rfReplaceAll]);
1319 end;
1320 Res.FBody := AddAnchorTag(Res.FBody);
1321 if Res.FMailTo = '' then
1322 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>')
1323 else if GikoSys.Setting.ShowMail then
1324 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>')
1325 else
1326 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>');
1327 if ThreadItem.Kokomade = (i + 1) then begin
1328 SaveList.Add('</dl>');
1329 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>');
1330 SaveList.Add('<dl>');
1331 end;
1332 end;
1333 //if SaveList.Count > 50 then begin
1334 doc.Write(SaveList.Text);
1335 SaveList.Clear;
1336 //Application.ProcessMessages;
1337 //end;
1338 end;
1339 SaveList.Add('</dl>');
1340 SaveList.Add('<a name="bottom"></a>');
1341 SaveList.Add('</body></html>');
1342 doc.Write(SaveList.Text);
1343 end;
1344 finally
1345 SaveList.Free;
1346 doc.Close;
1347 end;
1348 finally
1349 ReadList.Free;
1350 end;
1351 end;
1352 (*************************************************************************
1353 *http://????絖?????anchor?帥?遺???????????
1354 *************************************************************************)
1355 function TGikoSys.AddAnchorTag(s: string): string;
1356 const
1357 URL_CHAR: string = '0123456789'
1358 + 'abcdefghijklmnopqrstuvwxyz'
1359 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1360 + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
1361 ANCHOR_REF = 'href=';
1362 RES_REF = '&gt;&gt;';
1363 var
1364 wkIdx: array[0..9] of Integer;
1365 url: string;
1366 href: string;
1367 i: Integer;
1368 idx: Integer;
1369 anchorLen : Integer;
1370 begin
1371 Result := '';
1372 // + 3 ? 'href="' ('"'?ゃ??)?????????????若?激?с?潟???茖???????????????
1373 anchorLen := Length( ANCHOR_REF ) + 3;
1374
1375 while True do begin
1376 wkIdx[0] := AnsiPos('http://', s);
1377 wkIdx[1] := AnsiPos('ttp://', s);
1378 wkIdx[2] := AnsiPos('tp://', s);
1379 wkIdx[3] := AnsiPos('ms-help://', s);
1380 wkIdx[4] := AnsiPos('p://', s);
1381 wkIdx[5] := AnsiPos('https://', s);
1382 wkIdx[6] := AnsiPos('www.', s);
1383 wkIdx[7] := AnsiPos('ftp://', s);
1384 wkIdx[8] := AnsiPos('news://', s);
1385 wkIdx[9] := AnsiPos('rtsp://', s);
1386
1387 idx := MaxInt;
1388 for i := 0 to 9 do
1389 if wkIdx[i] <> 0 then idx := Min(wkIdx[i], idx);
1390
1391 if idx = MaxInt then begin
1392 //???潟?????<??????
1393 Result := Result + s;
1394 Break;
1395 end;
1396
1397 if (idx > 1) and
1398 (Pos( ANCHOR_REF, Copy(s, idx - anchorLen, anchorLen ) ) > 0) then begin
1399 //?≪?????潟???帥?違???ゃ?????????c?純????????????/span>
1400 href := Copy( s, idx, Length( s ) );
1401 Result := Result + Copy( s, 1, idx + Pos( '</a>', href ) + Length( '</a>' ) - 2 );
1402 s := href;
1403 s := Copy( s, Pos( '</a>', s ) + Length( '</a>' ), Length( s ) );
1404
1405 Continue;
1406 end;
1407
1408 Result := Result + Copy(s, 0, idx - 1);
1409
1410 s := Copy(s, idx, length(s));
1411
1412 for i := 0 to Length(s) do begin
1413 idx := AnsiPos(s[i + 1], URL_CHAR);
1414 if (idx = 0) or (i = (Length(s))) then begin
1415 //URL??????????絖??肴?鐚?????????絖?????????c????
1416 url := Copy(s, 0, i);
1417
1418 if AnsiPos('ttp://', url) = 1 then
1419 href := 'h' + url
1420 else if AnsiPos('tp://', url) = 1 then
1421 href := 'ht' + url
1422 else if AnsiPos('p://', url) = 1 then
1423 href := 'htt' + url
1424 else if AnsiPos('www.', url) = 1 then
1425 href := 'http://' + url
1426 else
1427 href := url;
1428 Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
1429 s := Copy(s, i + 1, Length(s));
1430 Break;
1431 end;
1432 end;
1433 end;
1434 end;
1435
1436 (*************************************************************************
1437 *?泣???吾?с????筝?茵???????/span>
1438 *************************************************************************)
1439 function TGikoSys.DivideSubject(Line: string): TSubjectRec;
1440 var
1441 i: integer;
1442 ws: WideString;
1443 Delim: string;
1444 LeftK: string;
1445 RightK: string;
1446 begin
1447 Result.FCount := 0;
1448
1449 if Pos('<>', Line) = 0 then
1450 Delim := ','
1451 else
1452 Delim := '<>';
1453
1454 Result.FFileName := GetTokenIndex(Line, Delim, 0);
1455 Result.FTitle := GetTokenIndex(Line, Delim, 1);
1456
1457 ws := Trim(Result.FTitle);
1458
1459 if Copy(ws, Length(ws), 1) = ')' then begin
1460 LeftK := '(';
1461 RightK := ')';
1462 end else if Copy(ws, Length(ws), 1) = '鐚?' then begin
1463 LeftK := '鐚?';
1464 RightK := '鐚?';
1465 end else if Copy(ws, Length(ws), 1) = '<' then begin
1466 LeftK := '<';
1467 RightK := '>';
1468 end;
1469
1470 for i := Length(ws) - 1 downto 1 do begin
1471 if ws[i] = LeftK then begin
1472 ws := Copy(ws, i + 1, Length(ws) - i - 1);
1473 if IsNumeric(ws) then
1474 Result.FCount := StrToInt(ws);
1475 Result.FTitle := Trim(StringReplace(Result.FTitle, LeftK + ws + RightK, '', [rfReplaceAll]));
1476 break;
1477 end;
1478 end;
1479 end;
1480
1481 (*************************************************************************
1482 * dat???<?ゃ????????ゃ?潟????茹?/span>
1483 *************************************************************************)
1484 function TGikoSys.DivideStrLine(Line: string): TResRec;
1485 var
1486 Delim: string;
1487 bufbody : String;
1488 begin
1489 if Pos('<>', Line) = 0 then begin
1490 Delim := ',';
1491 Result.FType := glt2chOld;
1492 end else begin
1493 Delim := '<>';
1494 Result.FType := glt2chNew;
1495 end;
1496 Result.FName := Trim(GetTokenIndex(Line, Delim, 0));
1497 Result.FMailTo := Trim(GetTokenIndex(Line, Delim, 1));
1498 Result.FDateTime := Trim(GetTokenIndex(Line, Delim, 2));
1499 bufBody := Trim(GetTokenIndex(Line, Delim, 3));
1500 if bufbody = '' then begin
1501 Insert('&nbsp;',bufbody, 1);
1502 end;
1503 Result.FBody := bufBody;
1504 Result.FTitle := Trim(GetTokenIndex(Line, Delim, 4));
1505
1506 end;
1507
1508 (*************************************************************************
1509 * URL????BBSID????緇?
1510 *************************************************************************)
1511 function TGikoSys.UrlToID(url: string): string;
1512 var
1513 i: integer;
1514 begin
1515 Result := '';
1516 url := Trim(url);
1517
1518 if url = '' then Exit;
1519
1520 url := Copy(url, 0, Length(url) - 1);
1521 for i := Length(url) downto 0 do begin
1522 if url[i] = '/' then begin
1523 Result := Copy(url, i + 1, Length(url));
1524 Break;
1525 end;
1526 end;
1527 end;
1528
1529 (*************************************************************************
1530 *URL????BBSID篁ュ???????(http://teri.2ch.net/)????緇?
1531 *************************************************************************)
1532 function TGikoSys.UrlToServer(url: string): string;
1533 var
1534 i: integer;
1535 wsURL: WideString;
1536 begin
1537 Result := '';
1538 wsURL := url;
1539 wsURL := Trim(wsURL);
1540
1541 if wsURL = '' then exit;
1542
1543 if Copy(wsURL, Length(wsURL), 1) = '/' then
1544 wsURL := Copy(wsURL, 0, Length(wsURL) - 1);
1545
1546 for i := Length(wsURL) downto 0 do begin
1547 if wsURL[i] = '/' then begin
1548 Result := Copy(wsURL, 0, i);
1549 break;
1550 end;
1551 end;
1552 end;
1553
1554 (*************************************************************************
1555 *???c??????????絖????????????с????/span>
1556 *************************************************************************)
1557 function TGikoSys.DirectoryExistsEx(const Name: string): Boolean;
1558 var
1559 Code: Integer;
1560 begin
1561 Code := GetFileAttributes(PChar(Name));
1562 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
1563 end;
1564
1565 (*************************************************************************
1566 *???c???????????鐚?茲??育??韻絲上?鐚?
1567 *************************************************************************)
1568 function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean;
1569 begin
1570 Result := True;
1571 if Length(Dir) = 0 then
1572 raise Exception.Create('??????????篏????堺?ャ?障????');
1573 Dir := ExcludeTrailingPathDelimiter(Dir);
1574 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
1575 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
1576 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
1577 end;
1578
1579 (*************************************************************************
1580 *??絖??????????若???潟???????冴??鐚?????????鐚?
1581 *FDelphi????????????/span>
1582 *************************************************************************)
1583 function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1584 begin
1585 Rec.Str := s;
1586 Rec.Pos := 1;
1587 Result := StrTokNext(sep, Rec);
1588 end;
1589
1590 (*************************************************************************
1591 *??絖??????????若???潟???????冴??
1592 *FDelphi????????????/span>
1593 *************************************************************************)
1594 function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string;
1595 var
1596 Len, I: Integer;
1597 begin
1598 with Rec do begin
1599 Len := Length(Str);
1600 Result := '';
1601 if Len >= Pos then begin
1602 while (Pos <= Len) and (Str[Pos] in sep) do begin
1603 Inc(Pos);
1604 end;
1605 I := Pos;
1606 while (Pos<= Len) and not (Str[Pos] in sep) do begin
1607 if IsDBCSLeadByte(Byte(Str[Pos])) then begin
1608 Inc(Pos);
1609 end;
1610 Inc(Pos);
1611 end;
1612 Result := Copy(Str, I, Pos - I);
1613 while (Pos <= Len) and (Str[Pos] in sep) do begin// ????????絅純??/span>
1614 Inc(Pos);
1615 end;
1616 end;
1617 end;
1618 end;
1619
1620 (*************************************************************************
1621 *???<?ゃ???泣?ゃ?阪??
1622 *************************************************************************)
1623 function TGikoSys.GetFileSize(FileName : string): longint;
1624 var
1625 F : File;
1626 begin
1627 try
1628 if not FileExists(FileName) then begin
1629 Result := 0;
1630 Exit;
1631 end;
1632 Assign(F, FileName);
1633 Reset(F, 1);
1634 Result := FileSize(F);
1635 CloseFile(F);
1636 except
1637 Result := 0;
1638 end;
1639 end;
1640
1641 (*************************************************************************
1642 *???<?ゃ????医??
1643 *************************************************************************)
1644 function TGikoSys.GetFileLineCount(FileName : string): longint;
1645 var
1646 sl: TStringList;
1647 begin
1648 sl := TStringList.Create;
1649 try
1650 try
1651 sl.LoadFromFile(FileName);
1652 Result := sl.Count;
1653 except
1654 Result := 0;
1655 end;
1656 finally
1657 sl.Free;
1658 end;
1659
1660 end;
1661
1662 (*************************************************************************
1663 *?鴻?????????<?ゃ????????絎?茵?????緇?
1664 *************************************************************************)
1665 function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string;
1666 var
1667 fileTmp : TStringList;
1668 begin
1669 Result := '';
1670 if FileExists(FileName) then begin
1671 fileTmp := TStringList.Create;
1672 try
1673 try
1674 fileTmp.LoadFromFile( FileName );
1675 if ( Line >= 1 ) and ( Line < fileTmp.Count + 1 ) then begin
1676 Result := fileTmp.Strings[ Line-1 ];
1677 end;
1678 except
1679 //on EFOpenError do Result := '';
1680 end;
1681 finally
1682 fileTmp.Free;
1683 end;
1684 end;
1685 end;
1686
1687 (*************************************************************************
1688 *?激?鴻?????<???ャ?若?????潟??????с????緇?
1689 *************************************************************************)
1690 procedure TGikoSys.MenuFont(Font: TFont);
1691 var
1692 lf: LOGFONT;
1693 nm: NONCLIENTMETRICS;
1694 begin
1695 nm.cbSize := sizeof(NONCLIENTMETRICS);
1696
1697 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0);
1698 lf := nm.lfMenuFont;
1699
1700 Font.Name := lf.lfFaceName;
1701 Font.Height := lf.lfHeight;
1702 Font.Style := [];
1703 if lf.lfWeight >= 700 then
1704 Font.Style := Font.Style + [fsBold];
1705 if lf.lfItalic = 1 then
1706 Font.Style := Font.Style + [fsItalic];
1707 end;
1708
1709 (*************************************************************************
1710 *
1711 *?????????泣?ゃ??????????????/span>
1712 *************************************************************************)
1713 function TGikoSys.RemoveToken(var s: string; delimiter: string): string;
1714 var
1715 p: Integer;
1716 begin
1717 p := AnsiPos(delimiter, s);
1718 if p = 0 then
1719 Result := s
1720 else
1721 Result := Copy(s, 1, p - 1);
1722 s := Copy(s, Length(Result) + Length(delimiter) + 1, Length(s));
1723 end;
1724
1725 (*************************************************************************
1726 *
1727 *?????????泣?ゃ??????????????/span>
1728 *************************************************************************)
1729 function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string;
1730 var
1731 i: Integer;
1732 begin
1733 Result := '';
1734 for i := 0 to index do
1735 Result := RemoveToken(s, delimiter);
1736 end;
1737
1738 (*************************************************************************
1739 *
1740 *************************************************************************)
1741 function TGikoSys.DeleteLink(const s: string): string;
1742 var
1743 s1: string;
1744 s2: string;
1745 idx: Integer;
1746 i: Integer;
1747 begin
1748 i := 0;
1749 Result := '';
1750 while True do begin
1751 s1 := GetTokenIndex(s, '<a href="', i);
1752 s2 := GetTokenIndex(s, '<a href="', i + 1);
1753
1754 idx := Pos('">', s1);
1755 if idx <> 0 then
1756 Delete(s1, 1, idx + 1);
1757 idx := Pos('">', s2);
1758 if idx <> 0 then
1759 Delete(s2, 1, idx + 1);
1760
1761 Result := Result + s1 + s2;
1762
1763 if s2 = '' then
1764 Break;
1765
1766 inc(i, 2);
1767 end;
1768 end;
1769
1770 //?ゃ?潟???????号???贋?違???????<?????????激?ワ?
1771 {procedure TGikoSys.FlashExitWrite;
1772 var
1773 i: Integer;
1774 begin
1775 //?鴻?????????若?帥???<?ゃ?????贋??/span>
1776 for i := 0 to FExitWrite.Count - 1 do
1777 WriteThreadDat(FExitWrite[i]);
1778 FExitWrite.Clear;
1779 end;}
1780
1781 (*************************************************************************
1782 *?鴻???????????????????????????
1783 *from HotZonu
1784 *************************************************************************)
1785 function TGikoSys.GetShortName(const LongName: string; ALength: integer): string;
1786 const
1787 ERASECHAR : array [1..39] of string =
1788 ('??','??','??','??#39;,'??','??','鐚?#39;,'鐚?','??#39;,'??#39;,
1789 '??#39;,'??#39;,'??39;,'??','??#39;,'??','??','??#39;,'??','??',
1790 '??','??','??','??','??','??','鐚?','鐚?','??#39;,'??#39;,
1791 '鐔?','鐔?','??','??','??#39;,'??39;,'??','??#39;, '??');
1792 var
1793 Chr : array [0..255] of char;
1794 S : string;
1795 i : integer;
1796 begin
1797 s := Trim(LongName);
1798 if (Length(s) <= ALength) then begin
1799 Result := s;
1800 end else begin
1801 S := s;
1802 for i := Low(ERASECHAR) to High(ERASECHAR) do begin
1803 S := StringReplace(S, ERASECHAR[i], '', [rfReplaceAll]);
1804 end;
1805 if (Length(S) <= ALength) then begin
1806 Result := S;
1807 end else begin
1808 Windows.LCMapString(
1809 GetUserDefaultLCID(),
1810 LCMAP_HALFWIDTH,
1811 PChar(S),
1812 Length(S) + 1,
1813 chr,
1814 Sizeof(chr)
1815 );
1816 S := Chr;
1817 S := Copy(S,1,ALength);
1818 while true do begin
1819 if (ByteType(S, Length(S)) = mbLeadByte ) then begin
1820 S := Copy(S, 1, Length(S) - 1);
1821 end else begin
1822 Break;
1823 end;
1824 end;
1825 Result := S;
1826 end;
1827 end;
1828 end;
1829
1830 (*************************************************************************
1831 *
1832 * from HotZonu
1833 *************************************************************************)
1834 function TGikoSys.ConvRes(const Body, Bbs, Key,
1835 ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
1836 type
1837 PIndex = ^TIndex;
1838 TIndex = record
1839 FIndexFrom : integer;
1840 FIndexTo : integer;
1841 FNo : string;
1842 end;
1843 const
1844 GT = '&gt;';
1845 SN = '0123456789-';
1846 ZN = '鐚?鐚?鐚?鐚?鐚?鐚?鐚?鐚?鐚?鐚???';
1847 var
1848 i : integer;
1849 s,r : string;
1850 b : TMbcsByteType;
1851 sw: boolean;
1852 sp: integer;
1853 No: string;
1854 sx: string;
1855 List: TList;
1856 oc : string;
1857 st, et: string;
1858 chk : boolean;
1859 al : boolean;
1860 procedure Add(IndexFrom, IndexTo: integer; const No: string);
1861 var
1862 FIndex : PIndex;
1863 begin
1864 New(FIndex);
1865 FIndex.FIndexFrom := IndexFrom;
1866 FIndex.FIndexTo := IndexTo;
1867 FIndex.FNo := No;
1868 List.Add(FIndex);
1869 end;
1870 function ChooseString(const Text, Separator: string; Index: integer): string;
1871 var
1872 S : string;
1873 i, p : integer;
1874 begin
1875 S := Text;
1876 for i := 0 to Index - 1 do begin
1877 if (AnsiPos(Separator, S) = 0) then S := ''
1878 else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
1879 end;
1880 p := AnsiPos(Separator, S);
1881 if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S;
1882 end;
1883 begin
1884 { v1.0 b2 - 03 }
1885 s := Body;
1886 r := Body;
1887 i := 1;
1888 sw := False;
1889 No := '';
1890 List:= TList.Create;
1891 oc := '';
1892 sp := 0;
1893 chk := False;
1894 al := False;
1895 while true do begin
1896 b := ByteType(s, i);
1897 case b of
1898 mbSingleByte : begin
1899 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1900 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1901 sw := True;
1902 sp := i;
1903 i := i + 7;
1904 oc:='';
1905 chk := True;
1906 end;
1907 end else
1908 if (not sw) and (Copy(s,i,8) = GT + GT) then begin
1909 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then begin
1910 i := i + 7;
1911 oc:='';
1912 chk := True;
1913 end;
1914 end else
1915 if (not sw) and (Copy(s,i,4) = GT) then begin
1916 if (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then begin
1917 sw := True;
1918 sp := i;
1919 i := i + 3;
1920 oc:='';
1921 chk := True;
1922 end;
1923 end else
1924 if ((not sw) and (Copy(s,i,1) = ',')) or
1925 ((not sw) and (Copy(s,i,1) = '=')) then begin
1926 if ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
1927 ((Chk) and (oc = '')) or
1928 ((not Chk) and (al)) then
1929 begin
1930 sw := True;
1931 sp := i;
1932 //i := i + 1;
1933 oc:='';
1934 end;
1935 end else
1936 if (sw) then begin
1937 sx := Copy(s,i,1);
1938 if (AnsiPos(sx, SN) > 0) then begin
1939 No := No + sx;
1940 end else begin
1941 if (No <> '') and (No <> '-') then begin
1942 Add(sp, i, No);
1943 al := True;
1944 end;
1945 sw := False;
1946 //
1947 i := i - 1;
1948 //
1949 No := '';
1950 oc:='';
1951 //chk := False;
1952 end;
1953 end else begin
1954 if Copy(s,i,1) = '<' then oc := '';
1955 oc := oc + Copy(s,i,1);
1956 chk := False;
1957 al := False;
1958 end;
1959 end;
1960 mbLeadByte : begin
1961 if (not sw) and (Copy(s,i,4) = '鐚?鐚?') then begin
1962 sw := True;
1963 sp := i;
1964 i := i + 3;
1965 chk := True;
1966 end else
1967 if (not sw) and (Copy(s,i,2) = '鐚?') then begin
1968 sw := True;
1969 sp := i;
1970 i := i + 1;
1971 chk := True;
1972 end else
1973 if (sw) then begin
1974 sx := Copy(s,i,2);
1975 if (AnsiPos(sx, ZN) > 0) then begin
1976 No := No + ZenToHan(sx);
1977 end else begin
1978 if (No <> '') and (No <> '-') and (No <> '??') then begin
1979 Add(sp, i, No);
1980 end;
1981 sw := False;
1982 i := i - 1;
1983 No := '';
1984 end;
1985 end else begin
1986 oc := '';
1987 chk := False;
1988 end;
1989 al := False;
1990 end;
1991 end;
1992 inc(i);
1993 if (i > Length(Body)) then begin
1994 if (sw) then begin
1995 if (No <> '') then Add(sp, i, No);
1996 end;
1997 Break;
1998 end;
1999 end;
2000 for i := List.Count - 1 downto 0 do begin
2001 if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin
2002 st := ChooseString(PIndex(List[i]).FNo, '-', 0);
2003 et := ChooseString(PIndex(List[i]).FNo, '-', 1);
2004 end else begin
2005 st := PIndex(List[i]).FNo;
2006 et := PIndex(List[i]).FNo;
2007 end;
2008 r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
2009 Format('<a href="../test/read.cgi?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s" target="_blank">',
2010 [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
2011 Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
2012 Copy(r,PIndex(List[i]).FIndexTo,Length(r));
2013 Dispose(PIndex(List[i]));
2014 end;
2015 List.Free;
2016 Result := r;
2017 end;
2018
2019 (*************************************************************************
2020 * ???????茹?
2021 * from HotZonu
2022 *************************************************************************)
2023 function TGikoSys.ZenToHan(const s: string): string;
2024 var
2025 Chr: array [0..255] of char;
2026 begin
2027 Windows.LCMapString(
2028 GetUserDefaultLCID(),
2029 // LCMAP_HALFWIDTH,
2030 LCMAP_HALFWIDTH or LCMAP_KATAKANA or LCMAP_LOWERCASE,
2031 PChar(s),
2032 Length(s) + 1,
2033 chr,
2034 Sizeof(chr)
2035 );
2036 Result := Chr;
2037 end;
2038
2039 (*************************************************************************
2040 * ?????茹??蚊?????????????????阪?ャ??????????Pos
2041 *************************************************************************)
2042 function TGikoSys.VaguePos(const Substr, S: string): Integer;
2043 begin
2044 Result := Pos(ZenToHan(Substr), ZenToHan(S));
2045 end;
2046
2047 function TGikoSys.BoolToInt(b: Boolean): Integer;
2048 begin
2049 Result := IfThen(b, 1, 0);
2050 end;
2051
2052 function TGikoSys.IntToBool(i: Integer): Boolean;
2053 begin
2054 Result := i = 1;
2055 end;
2056
2057 //gzip?у?х軒???????????祉??
2058 function TGikoSys.GzipDecompress(ResStream: TStream; ContentEncoding: string): string;
2059 const
2060 BUF_SIZE = 4096;
2061 var
2062 GZipStream: TGzipDecompressStream;
2063 TextStream: TStringStream;
2064 buf: array[0..BUF_SIZE - 1] of Byte;
2065 cnt: Integer;
2066 s: string;
2067 i: Integer;
2068 begin
2069 Result := '';
2070 TextStream := TStringStream.Create('');
2071 try
2072 //???若???潟???潟?????c????003絲丞?(x-gzip???????????帥????)
2073 // if LowerCase(Trim(ContentEncoding)) = 'gzip' then begin
2074 if AnsiPos('gzip', LowerCase(Trim(ContentEncoding))) > 0 then begin
2075 ResStream.Position := 0;
2076 GZipStream := TGzipDecompressStream.Create(TextStream);
2077 try
2078 repeat
2079 FillChar(buf, BUF_SIZE, 0);
2080 cnt := ResStream.Read(buf, BUF_SIZE);
2081 if cnt > 0 then
2082 GZipStream.Write(buf, BUF_SIZE);
2083 until cnt = 0;
2084 finally
2085 GZipStream.Free;
2086 end;
2087 end else begin
2088 ResStream.Position := 0;
2089 repeat
2090 FillChar(buf, BUF_SIZE, 0);
2091 cnt := ResStream.Read(buf, BUF_SIZE);
2092 if cnt > 0 then
2093 TextStream.Write(buf, BUF_SIZE);
2094 until cnt = 0;
2095 end;
2096
2097 //NULL??絖???"*"??????
2098 s := TextStream.DataString;
2099 i := Length(s);
2100 while (i > 0) and (s[i] = #0) do
2101 Dec(i);
2102 s := Copy(s, 1, i);
2103
2104 i := Pos(#0, s);
2105 while i <> 0 do begin
2106 s[i] := '*';
2107 i := Pos(#0, s);
2108 end;
2109 Result := s;
2110 finally
2111 TextStream.Free;
2112 end;
2113 end;
2114
2115 procedure TGikoSys.LoadKeySetting(ActionList: TActionList);
2116 const
2117 STD_SEC = 'KeySetting';
2118 var
2119 i: Integer;
2120 ini: TMemIniFile;
2121 ActionName: string;
2122 ActionKey: Integer;
2123 SecList: TStringList;
2124 Component: TComponent;
2125 begin
2126 if not FileExists(GetConfigDir + KEY_SETTING_FILE_NAME) then
2127 Exit;
2128 SecList := TStringList.Create;
2129 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
2130 try
2131 ini.ReadSection(STD_SEC, SecList);
2132 for i := 0 to SecList.Count - 1 do begin
2133 ActionName := SecList[i];
2134 ActionKey := ini.ReadInteger(STD_SEC, ActionName, -1);
2135 if ActionKey <> -1 then begin
2136 Component := ActionList.Owner.FindComponent(ActionName);
2137 if TObject(Component) is TAction then begin
2138 TAction(Component).ShortCut := ActionKey;
2139 end;
2140 end;
2141 end;
2142 finally
2143 ini.Free;
2144 SecList.Free;
2145 end;
2146 end;
2147
2148 procedure TGikoSys.SaveKeySetting(ActionList: TActionList);
2149 const
2150 STD_SEC = 'KeySetting';
2151 var
2152 i: Integer;
2153 ini: TMemIniFile;
2154 begin
2155 ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME);
2156 try
2157 for i := 0 to ActionList.ActionCount - 1 do begin
2158 if ActionList.Actions[i].Tag = -1 then
2159 Continue;
2160 ini.WriteInteger(STD_SEC, ActionList.Actions[i].Name, TAction(ActionList.Actions[i]).ShortCut);
2161 end;
2162 ini.UpdateFile;
2163 finally
2164 ini.Free;
2165 end;
2166 end;
2167
2168 //
2169 procedure TGikoSys.CreateProcess(const AppPath: string; const Param: string);
2170 var
2171 PI: TProcessInformation;
2172 SI: TStartupInfo;
2173 Path: string;
2174 begin
2175 Path := '"' + AppPath + '"';
2176 if Param <> '' then
2177 Path := Path + ' ' + Param;
2178
2179 SI.Cb := SizeOf(Si);
2180 SI.lpReserved := nil;
2181 SI.lpDesktop := nil;
2182 SI.lpTitle := nil;
2183 SI.dwFlags := 0;
2184 SI.cbReserved2 := 0;
2185 SI.lpReserved2 := nil;
2186 SI.dwysize := 0;
2187 Windows.CreateProcess(nil,
2188 PChar(Path),
2189 nil,
2190 nil,
2191 False,
2192 0,
2193 nil,
2194 nil,
2195 SI,
2196 PI);
2197 end;
2198
2199 procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
2200 begin
2201 case BrowserType of
2202 gbtIE:
2203 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2204 gbtUserApp, gbtAuto:
2205 if (Setting.URLApp) and (FileExists(Setting.URLAppFile)) then
2206 GikoSys.CreateProcess(Setting.URLAppFile, URL)
2207 else
2208 HlinkNavigateString(nil, PWideChar(WideString(URL)));
2209 end;
2210 end;
2211
2212 function TGikoSys.HTMLDecode(const AStr: String): String;
2213 var
2214 Sp, Rp, Cp, Tp: PChar;
2215 S: String;
2216 I, Code: Integer;
2217 Num: Boolean;
2218 begin
2219 SetLength(Result, Length(AStr));
2220 Sp := PChar(AStr);
2221 Rp := PChar(Result);
2222 //Cp := Sp;
2223 try
2224 while Sp^ <> #0 do begin
2225 case Sp^ of
2226 '&': begin
2227 //Cp := Sp;
2228 Inc(Sp);
2229 case Sp^ of
2230 'a': if AnsiStrPos(Sp, 'amp;') = Sp then
2231 begin
2232 Inc(Sp, 3);
2233 Rp^ := '&';
2234 end;
2235 'l',
2236 'g': if (AnsiStrPos(Sp, 'lt;') = Sp) or (AnsiStrPos(Sp, 'gt;') = Sp) then
2237 begin
2238 Cp := Sp;
2239 Inc(Sp, 2);
2240 while (Sp^ <> ';') and (Sp^ <> #0) do
2241 Inc(Sp);
2242 if Cp^ = 'l' then
2243 Rp^ := '<'
2244 else
2245 Rp^ := '>';
2246 end;
2247 'q': if AnsiStrPos(Sp, 'quot;') = Sp then
2248 begin
2249 Inc(Sp,4);
2250 Rp^ := '"';
2251 end;
2252 '#': begin
2253 Tp := Sp;
2254 Inc(Tp);
2255 Num := IsNumeric(Copy(Tp, 1, 1));
2256 while (Sp^ <> ';') and (Sp^ <> #0) do begin
2257 if (Num) and (not IsNumeric(Copy(Sp, 1, 1))) then
2258 Break;
2259 Inc(Sp);
2260 end;
2261 SetString(S, Tp, Sp - Tp);
2262 Val(S, I, Code);
2263 Rp^ := Chr((I));
2264 end;
2265 // else
2266 //raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2267 //[Cp^ + Sp^, Cp - PChar(AStr)])
2268 end;
2269 end
2270 else
2271 Rp^ := Sp^;
2272 end;
2273 Inc(Rp);
2274 Inc(Sp);
2275 end;
2276 except
2277 // on E:EConvertError do
2278 // raise EConvertError.CreateFmt(sInvalidHTMLEncodedChar,
2279 // [Cp^ + Sp^, Cp - PChar(AStr)])
2280 end;
2281 SetLength(Result, Rp - PChar(Result));
2282 end;
2283
2284 function TGikoSys.GetHRefText(s: string): string;
2285 var
2286 Index: Integer;
2287 Index2: Integer;
2288 begin
2289 Result := '';
2290 s := Trim(s);
2291 if s = '' then
2292 Exit;
2293
2294 Index := AnsiPos('href', LowerCase(s));
2295 if Index = 0 then
2296 Exit;
2297 s := Trim(Copy(s, Index + 4, Length(s)));
2298 s := Trim(Copy(s, 2, Length(s)));
2299
2300 //紮???????絖???'"'?????????ゃ??span>
2301 if Copy(s, 1, 1) = '"' then begin
2302 s := Trim(Copy(s, 2, Length(s)));
2303 end;
2304
2305 Index := AnsiPos('"', s);
2306 if Index <> 0 then begin
2307 //'"'?障??RL??????
2308 s := Copy(s, 1, Index - 1);
2309 end else begin
2310 //'"'???<?????違?鴻???若?鴻??">"???????鴻?障?с??URL??????
2311 Index := AnsiPos(' ', s);
2312 Index2 := AnsiPos('>', s);
2313 if Index = 0 then
2314 Index := Index2;
2315 if Index > Index2 then
2316 Index := Index2;
2317 if Index <> 0 then
2318 s := Copy(s, 1, Index - 1)
2319 else
2320 //????篁ヤ??????ャ??????/span>
2321 ;
2322 end;
2323 Result := Trim(s);
2324 end;
2325
2326 //???鴻??????鐚?鐔?鐔????????????с????????
2327 function TGikoSys.Is2chHost(Host: string): Boolean;
2328 const
2329 HOST_NAME: array[0..1] of string = ('2ch.net', 'bbspink.com');
2330 var
2331 i: Integer;
2332 // Len: Integer;
2333 begin
2334 Result := False;
2335 if RightStr( Host, 1 ) = '/' then
2336 Host := Copy( Host, 1, Length( Host ) - 1 );
2337 OutputDebugString(pchar(HOST_NAME[0]));
2338 for i := 0 to Length(HOST_NAME) - 1 do begin
2339 // Len := Length(HOST_NAME[i]);
2340 if AnsiPos(HOST_NAME[i], Host) = (Length(Host) - Length(HOST_NAME[i]) + 1) then begin
2341 Result := True;
2342 Exit;
2343 end;
2344 end;
2345 end;
2346
2347 function TGikoSys.Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean;
2348 var
2349 Index: Integer;
2350 s: string;
2351 SList: TStringList;
2352 begin
2353 BBSID := '';
2354 BBSKey := '';
2355 Result := False;
2356
2357 Index := AnsiPos(READ_PATH, path);
2358 if Index <> 0 then begin
2359 s := Copy(path, Length(READ_PATH) + 1, Length(path));
2360 BBSID := GetTokenIndex(s, '/', 0);
2361 BBSKey := GetTokenIndex(s, '/', 1);
2362 if BBSKey = '' then
2363 BBSKey := Document;
2364 Result := (BBSID <> '') or (BBSKey <> '');
2365 Exit;
2366 end;
2367 Index := AnsiPos(KAKO_PATH, path);
2368 if Index <> 0 then begin
2369 s := Copy(path, 2, Length(path));
2370 BBSID := GetTokenIndex(s, '/', 0);
2371 if (BBSID = 'log') and (GetTokenIndex(s, '/', 2) = 'kako') then
2372 BBSID := GetTokenIndex(s, '/', 1);
2373 BBSKey := ChangeFileExt(Document, '');
2374 Result := (BBSID <> '') or (BBSKey <> '');
2375 Exit;
2376 end;
2377 Index := AnsiPos('read.cgi?', URL);
2378 if Index <> 0 then begin
2379 SList := TStringList.Create;
2380 try
2381 try
2382 // s := HTMLDecode(Document);
2383 ExtractHTTPFields(['?', '&'], [], PChar(URL), SList, False);
2384 BBSID := SList.Values['bbs'];
2385 BBSKey := SList.Values['key'];
2386 Result := (BBSID <> '') or (BBSKey <> '');
2387 Exit;
2388 except
2389 Exit;
2390 end;
2391 finally
2392 SList.Free;
2393 end;
2394 end;
2395 end;
2396
2397 function TGikoSys.Parse2chURL2(URL: string): TPathRec;
2398 var
2399 i: Integer;
2400 s: string;
2401 wk: string;
2402 wkMin: Integer;
2403 wkMax: Integer;
2404 wkInt: Integer;
2405 RStart: Integer;
2406 RLength: Integer;
2407 SList: TStringList;
2408 begin
2409 URL := Trim(LowerCase(URL));
2410 Result.FBBS := '';
2411 Result.FKey := '';
2412 Result.FSt := 0;
2413 Result.FTo := 0;
2414 Result.FFirst := False;
2415 Result.FStBegin := False;
2416 Result.FToEnd := False;
2417 Result.FDone := False;
2418
2419 wkMin := 0;
2420 wkMax := 1;
2421
2422 FAWKStr.RegExp := 'http://.+\.(2ch\.net|bbspink\.com)/';
2423 if FAWKStr.Match(FAWKStr.ProcessEscSeq(URL), RStart, RLength) = 0 then
2424 Exit;
2425 s := Copy(URL, RStart + RLength - 1, Length(URL));
2426
2427 //罔?羣??後?
2428 //??緇???50, 10, 10-20, 10n, 10-20n, -10, 10-, 10n- ????/span>
2429 //http://xxx.2ch.net/test/read.cgi/bbsid/1000000000/
2430 FAWKStr.RegExp := '/test/read.cgi/.+/[0-9]+/.*';
2431 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2432 s := Copy(s, 15, Length(s));
2433
2434 SList := TStringList.Create;
2435 try
2436 SList.Clear;
2437 FAWKStr.RegExp := '/';
2438 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2439 Result.FBBS := SList[1];
2440 Result.FKey := SList[2];
2441 if SList.Count >= 3 then
2442 s := SList[3]
2443 else
2444 s := '';
2445 end else
2446 Exit;
2447
2448 SList.Clear;
2449 FAWKStr.LineSeparator := mcls_CRLF;
2450 FAWKStr.RegExp := '-';
2451 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) = 0 then begin
2452 Result.FFirst := True;
2453 end else begin
2454 FAWKStr.RegExp := 'l[0-9]+';
2455 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2456 Result.FFirst := True;
2457 end else begin
2458 for i := 0 to SList.Count - 1 do begin
2459 if Trim(SList[i]) = '' then begin
2460 if i = 0 then
2461 Result.FStBegin := True;
2462 if i = (SList.Count - 1) then
2463 Result.FToEnd := True;
2464 end else if IsNumeric(SList[i]) then begin
2465 wkInt := StrToInt(SList[i]);
2466 wkMax := Max(wkMax, wkInt);
2467 if wkMin = 0 then
2468 wkMin := wkInt
2469 else
2470 wkMin := Min(wkMin, wkInt);
2471 end else if Trim(SList[i]) = 'n' then begin
2472 Result.FFirst := True;
2473 end else begin
2474 FAWKStr.RegExp := '^n[0-9]+$|^[0-9]+n$';
2475 if FAWKStr.Match(FAWKStr.ProcessEscSeq(SList[i]), RStart, RLength) > 0 then begin
2476 if Copy(SList[i], 1, 1) = 'n' then
2477 wkInt := StrToInt(Copy(SList[i], 2, Length(SList[i])))
2478 else
2479 wkInt := StrToInt(Copy(SList[i], 1, Length(SList[i]) - 1));
2480 Result.FFirst := True;
2481 wkMax := Max(wkMax, wkInt);
2482 if wkMin = 1 then
2483 wkMin := wkInt
2484 else
2485 wkMin := Min(wkMin, wkInt);
2486 end;
2487 end;
2488 end;
2489 if Result.FStBegin and (not Result.FToEnd) then
2490 Result.FSt := wkMin
2491 else if (not Result.FStBegin) and Result.FToEnd then
2492 Result.FTo := wkMax
2493 else if (not Result.FStBegin) and (not Result.FToEnd) then begin
2494 Result.FSt := wkMin;
2495 Result.FTo := wkMax;
2496 end;
2497 //Result.FSt := wkMin;
2498 //Result.FTo := wkMax;
2499 end;
2500 end;
2501 finally
2502 SList.Free;
2503 end;
2504 Result.FDone := True;
2505 Exit;
2506 end;
2507
2508 //??ako?後?
2509 //http://server.2ch.net/ITA_NAME/kako/1000/10000/1000000000.html
2510 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+/[0-9]+\.html';
2511 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2512 SList := TStringList.Create;
2513 try
2514 SList.Clear;
2515 FAWKStr.RegExp := '/';
2516 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2517 Result.FBBS := SList[1];
2518 Result.FKey := ChangeFileExt(SList[5], '');
2519 Result.FFirst := True;
2520 end else
2521 Exit;
2522 finally
2523 SList.Free;
2524 end;
2525 Result.FDone := True;
2526 Exit;
2527 end;
2528
2529 //??ako?後?
2530 //http://server.2ch.net/ITA_NAME/kako/999/999999999.html
2531 FAWKStr.RegExp := '/.+/kako/[0-9]+/[0-9]+\.html';
2532 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2533 SList := TStringList.Create;
2534 try
2535 SList.Clear;
2536 FAWKStr.RegExp := '/';
2537 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 5 then begin
2538 Result.FBBS := SList[1];
2539 Result.FKey := ChangeFileExt(SList[4], '');
2540 Result.FFirst := True;
2541 end else
2542 Exit;
2543 finally
2544 SList.Free;
2545 end;
2546 Result.FDone := True;
2547 Exit;
2548 end;
2549
2550 //log????og2?後?
2551 //http://server.2ch.net/log/ITA_NAME/kako/999/999999999.html
2552 //http://server.2ch.net/log2/ITA_NAME/kako/999/999999999.html
2553 FAWKStr.RegExp := '/log2?/.+/kako/[0-9]+/[0-9]+\.html';
2554 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2555 SList := TStringList.Create;
2556 try
2557 SList.Clear;
2558 FAWKStr.RegExp := '/';
2559 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 6 then begin
2560 Result.FBBS := SList[2];
2561 Result.FKey := ChangeFileExt(SList[5], '');
2562 Result.FFirst := True;
2563 end else
2564 Exit;
2565 finally
2566 SList.Free;
2567 end;
2568 Result.FDone := True;
2569 Exit;
2570 end;
2571
2572
2573 //??RL?後?
2574 //http://server.2ch.net/test/read.cgi?bbs=ITA_NAME&key=1000000000&st=1&to=5&nofirst=true
2575 FAWKStr.RegExp := '/test/read\.cgi\?';
2576 if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin
2577 s := Copy(s, 16, Length(s));
2578 SList := TStringList.Create;
2579 try
2580 SList.Clear;
2581 FAWKStr.RegExp := '&';
2582 if FAWKStr.Split(FAWKStr.ProcessEscSeq(s), SList) >= 2 then begin
2583 Result.FFirst := True;
2584 for i := 0 to SList.Count - 1 do begin
2585 if Pos('bbs=', SList[i]) = 1 then begin
2586 Result.FBBS := Copy(SList[i], 5, Length(SList[i]));
2587 end else if Pos('key=', SList[i]) = 1 then begin
2588 Result.FKey := Copy(SList[i], 5, Length(SList[i]));
2589 end else if Pos('st=', SList[i]) = 1 then begin
2590 wk := Copy(SList[i], 4, Length(SList[i]));
2591 if IsNumeric(wk) then
2592 Result.FSt := StrToInt(wk)
2593 else if wk = '' then
2594 Result.FStBegin := True;
2595 end else if Pos('to=', SList[i]) = 1 then begin
2596 wk := Copy(SList[i], 4, Length(SList[i]));
2597 if IsNumeric(wk) then
2598 Result.FTo := StrToInt(wk)
2599 else if wk = '' then
2600 Result.FToEnd := True;
2601 end else if Pos('nofirst=', SList[i]) = 1 then begin
2602 Result.FFirst := False;
2603 end;
2604 end;
2605 end else
2606 Exit;
2607 finally
2608 SList.Free;
2609 end;
2610
2611 if (Result.FBBS <> '') and (Result.FKey <> '') then begin
2612 Result.FDone := True;
2613 end;
2614 Exit;
2615 end;
2616 end;
2617
2618 procedure TGikoSys.ParseURI(var URL, Protocol, Host, Path, Document, Port, Bookmark: string);
2619 var
2620 URI: TIdURI;
2621 begin
2622 Protocol := '';
2623 Host := '';
2624 Path := '';
2625 Document := '';
2626 Port := '';
2627 Bookmark := '';
2628 URI := TIdURI.Create(URL);
2629 try
2630 Protocol := URI.Protocol;
2631 Host := URI.Host;
2632 Path := URI.Path;
2633 Document := URI.Document;
2634 Port := URI.Port;
2635 Bookmark := URI.Bookmark;
2636 finally
2637 URI.Free;
2638 end;
2639 end;
2640
2641 function TGikoSys.GetVersionBuild: Integer;
2642 var
2643 FixedFileInfo: PVSFixedFileInfo;
2644 VersionHandle, VersionSize: DWORD;
2645 pVersionInfo: Pointer;
2646 ItemLen : UInt;
2647 AppFile: string;
2648 begin
2649 Result := 0;
2650 AppFile := Application.ExeName;
2651 VersionSize := GetFileVersionInfoSize(pChar(AppFile), VersionHandle);
2652 if VersionSize = 0 then
2653 Exit;
2654 GetMem(pVersionInfo, VersionSize);
2655 try
2656 if GetFileVersionInfo(PChar(AppFile),VersionHandle,VersionSize, pVersionInfo) then
2657 if VerQueryValue(pVersionInfo, '\', Pointer(FixedFileInfo), ItemLen) then
2658 Result := LOWORD(FixedFileInfo^.dwFileVersionLS);
2659 finally
2660 FreeMem(pVersionInfo, VersionSize);
2661 end;
2662 end;
2663
2664 function TGikoSys.Get2chThreadURL2BoardURL(
2665 inURL : string
2666 ) : string;
2667 var
2668 Protocol, Host, Path, Document, Port, Bookmark : string;
2669 BBSID, BBSKey : string;
2670 begin
2671
2672 ParseURI( inURL, Protocol, Host, Path, Document, Port, Bookmark );
2673 Parse2chURL( inURL, Path, Document, BBSID, BBSKey );
2674
2675 Result := Copy( inURL, 1, Pos( '/test/read.cgi', inURL ) ) + BBSID + '/';
2676
2677 end;
2678
2679 function TGikoSys.Get2chBrowsableThreadURL(
2680 inURL : string
2681 ) : string;
2682 var
2683 Protocol, Host, Path, Document, Port, Bookmark : string;
2684 BBSID, BBSKey : string;
2685 foundPos : Integer;
2686 begin
2687
2688 if Pos( KAKO_PATH, inURL ) > 0 then begin
2689 Result := inURL;
2690 end else begin
2691 ParseURI( inURL, Protocol, Host, Path, Document, Port, Bookmark );
2692 Parse2chURL( inURL, Path, Document, BBSID, BBSKey );
2693 foundPos := Pos( '/test/read.cgi', inURL );
2694
2695 if Is2chHost( Host ) then begin
2696 Result := Copy( inURL, 1, foundPos ) +
2697 READ_PATH + BBSID + '/' + BBSKey + '/l50';
2698 end else begin
2699 Result := Copy( inURL, 1, foundPos ) +
2700 OLD_READ_PATH + 'bbs=' + BBSID + '&key=' + BBSKey + '&ls=50';
2701 end;
2702 end;
2703
2704 end;
2705
2706 function TGikoSys.Get2chBoard2ThreadURL(
2707 inBoard : TBoard;
2708 inKey : string
2709 ) : string;
2710 var
2711 server : string;
2712 begin
2713
2714 server := UrlToServer( inBoard.URL );
2715 if Is2chHost( server ) then
2716 Result := server + 'test/read.cgi/' + inBoard.BBSID + '/' + inKey + '/l50'
2717 else
2718 Result := server + 'test/read.cgi?bbs=' + inBoard.BBSID + '&key=' + inKey + '&ls=50';
2719
2720 end;
2721
2722 (*************************************************************************
2723 *罘??遵??????鐚????若?????<?ゃ????粋昭??/span>
2724 *?????????鐚?Public
2725 *絮ユ?鐚?????鐚??域?篏???
2726 *************************************************************************)
2727 procedure TGikoSys.ReadBoardFile;
2728 var
2729 idx: Integer;
2730 ini: TMemIniFile;
2731 CategoryList: TStringList;
2732 BoardList: TStringList;
2733 Category: TCategory;
2734 Board: TBoard;
2735 inistr: string;
2736 RoundItem: TRoundItem;
2737
2738 // BBS ????(1 ???若?????<?ゃ?????ゃ?? 1 ????
2739 bbsList : array of TStringList;
2740 boardFileList : TStringList;
2741
2742 i, iBound : Integer;
2743 j, jBound : Integer;
2744 k, kBound : Integer;
2745 l, lBound : Integer;
2746 begin
2747 ini := TMemIniFile.Create('');
2748 try
2749 // BBS ??????/span>
2750 try
2751 for i := 0 to Length( BBSs ) - 1 do
2752 BBSs[ i ].Free;
2753 except
2754 end;
2755 SetLength( BBSs, 0 );
2756
2757 // ?帥???鴻????????
2758 if FileExists( GikoSys.GetBoardFileName ) then begin
2759 l := Length( bbsList );
2760 SetLength( bbsList, l + 1 );
2761 bbsList[ l ] := TStringList.Create;
2762 bbsList[ l ].LoadFromFile( GikoSys.GetBoardFileName );
2763
2764 SetLength( BBSs, l + 1 );
2765 BBSs[ l ] := TBBS.Create( GikoSys.Setting.LogFolder<