X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=GikoSystem.pas;h=2c1e4d7d5a4794a97f545d1c3ed8f82f52d7aca3;hb=refs%2Fheads%2FBb62;hp=9320474c1eaf386bf6017f919c8cc525b27778a5;hpb=fd96f552157fdf507e6004a744cd88d9cac0b18e;p=gikonavigoeson%2Fgikonavi.git diff --git a/GikoSystem.pas b/GikoSystem.pas index 9320474..2c1e4d7 100644 --- a/GikoSystem.pas +++ b/GikoSystem.pas @@ -4,7 +4,7 @@ interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, - ComCtrls, IniFiles, ShellAPI, ActnList, Math, + ComCtrls, {IniFiles,} ShellAPI, ActnList, Math, {$IF Defined(DELPRO) } SHDocVw, MSHTML, @@ -12,33 +12,33 @@ uses SHDocVw_TLB, MSHTML_TLB, {$IFEND} - {HttpApp,} YofUtils, URLMon, IdGlobal, IdURI, {Masks,} + {HttpApp,} URLMon, IdGlobal, IdURI, {Masks,} Setting, BoardGroup, gzip, Dolib, bmRegExp, AbonUnit, - MojuUtils, ExternalBoardManager, ExternalBoardPlugInMain, - Sort, GikoBayesian; + ExternalBoardManager, ExternalBoardPlugInMain, + GikoBayesian, GikoMessage, Belib; type TVerResourceKey = ( - vrComments, // ƒRƒƒ“ƒg - vrCompanyName, // ‰ïŽÐ–¼ - vrFileDescription, // à–¾ - vrFileVersion, // ƒtƒ@ƒCƒ‹ƒo[ƒWƒ‡ƒ“ - vrInternalName, // “à•”–¼ - vrLegalCopyright, // ’˜ìŒ  - vrLegalTrademarks, // ¤•W - vrOriginalFilename, // ³Ž®ƒtƒ@ƒCƒ‹–¼ - vrPrivateBuild, // ƒvƒ‰ƒCƒx[ƒgƒrƒ‹ƒhî•ñ - vrProductName, // »•i–¼ - vrProductVersion, // »•iƒo[ƒWƒ‡ƒ“ - vrSpecialBuild); // ƒXƒyƒVƒƒƒ‹ƒrƒ‹ƒhî•ñ - - //BBSƒ^ƒCƒv + vrComments, //!< ƒRƒƒ“ƒg + vrCompanyName, //!< ‰ïŽÐ–¼ + vrFileDescription, //!< à–¾ + vrFileVersion, //!< ƒtƒ@ƒCƒ‹ƒo[ƒWƒ‡ƒ“ + vrInternalName, //!< “à•”–¼ + vrLegalCopyright, //!< ’˜ìŒ  + vrLegalTrademarks, //!< ¤•W + vrOriginalFilename, //!< ³Ž®ƒtƒ@ƒCƒ‹–¼ + vrPrivateBuild, //!< ƒvƒ‰ƒCƒx[ƒgƒrƒ‹ƒhî•ñ + vrProductName, //!< »•i–¼ + vrProductVersion, //!< »•iƒo[ƒWƒ‡ƒ“ + vrSpecialBuild); //!< ƒXƒyƒVƒƒƒ‹ƒrƒ‹ƒhî•ñ + + //! BBSƒ^ƒCƒv TGikoBBSType = (gbt2ch); - //ƒƒOƒ^ƒCƒv + //! ƒƒOƒ^ƒCƒv TGikoLogType = (glt2chNew, glt2chOld); - //ƒƒbƒZ[ƒWƒAƒCƒRƒ“ + //! ƒƒbƒZ[ƒWƒAƒCƒRƒ“ TGikoMessageIcon = (gmiOK, gmiSAD, gmiNG, gmiWhat, gmiNone); - //URLƒI[ƒvƒ“ƒuƒ‰ƒEƒUƒ^ƒCƒv + //! URLƒI[ƒvƒ“ƒuƒ‰ƒEƒUƒ^ƒCƒv TGikoBrowserType = (gbtIE, gbtUserApp, gbtAuto); @@ -48,7 +48,7 @@ type Pos: Integer; end; - //ƒCƒ“ƒfƒbƒNƒXƒtƒ@ƒCƒ‹ƒŒƒR[ƒh + //! ƒCƒ“ƒfƒbƒNƒXƒtƒ@ƒCƒ‹ƒŒƒR[ƒh TIndexRec = record FNo: Integer; FFileName: string; @@ -60,7 +60,7 @@ type FLastModified: TDateTime; FKokomade: Integer; FNewReceive: Integer; - FMishiyou: Boolean; //–¢Žg—p + FMishiyou: Boolean; //!< –¢Žg—p FUnRead: Boolean; FScrollTop: Integer; //Index Ver 1.01 @@ -69,14 +69,17 @@ type FAgeSage: TGikoAgeSage; end; - //ƒTƒuƒWƒFƒNƒgƒŒƒR[ƒh + //! ƒTƒuƒWƒFƒNƒgƒŒƒR[ƒh TSubjectRec = record FFileName: string; FTitle: string; FCount: Integer; end; - //ƒŒƒXƒŒƒR[ƒh + //! ƒŒƒXƒŒƒR[ƒh‚ւ̃|ƒCƒ“ƒ^ + PResRec = ^TResRec; + + //! ƒŒƒXƒŒƒR[ƒh TResRec = record FTitle: string; FMailTo: string; @@ -86,24 +89,19 @@ type FType: TGikoLogType; end; - //URLPathƒŒƒR[ƒh + //! URLPathƒŒƒR[ƒh TPathRec = record - FBBS: string; //BBSID - FKey: string; //ThreadID - FSt: Int64; //ŠJŽnƒŒƒX”Ô - FTo: Int64; //I—¹ƒŒƒX”Ô - FFirst: Boolean; //>>1‚Ì•\Ž¦ - FStBegin: Boolean; //1`•\Ž¦ - FToEnd: Boolean; //`ÅŒã‚Ü‚Å•\Ž¦ - FDone: Boolean; //¬Œ÷ - FNoParam: Boolean; //ƒŒƒX”Ôƒpƒ‰ƒ[ƒ^‚È‚µ + FBBS: string; //!< BBSID + FKey: string; //!< ThreadID + FSt: Int64; //!< ŠJŽnƒŒƒX”Ô + FTo: Int64; //!< I—¹ƒŒƒX”Ô + FFirst: Boolean; //!< >>1‚Ì•\Ž¦ + FStBegin: Boolean; //!< 1`•\Ž¦ + FToEnd: Boolean; //!< `ÅŒã‚Ü‚Å•\Ž¦ + FDone: Boolean; //!< ¬Œ÷ + FNoParam: Boolean; //!< ƒŒƒX”Ôƒpƒ‰ƒ[ƒ^‚È‚µ end; - //MessageList - TGikoMessageListType = (gmLogout, gmLogin, gmForceLogin, gmSureItiran, - gmUnKnown, gmSureSyutoku, gmSureDiff, gmNotMod, gmAbort, gmError, - gmNewRes, gmNewSure, gmResError, gmSureError); - TGikoSys = class(TObject) private { Private éŒ¾ } @@ -112,10 +110,13 @@ type FAWKStr: TAWKStr; FResRange : Longint; FBayesian : TGikoBayesian; //!< ƒxƒCƒWƒAƒ“ƒtƒBƒ‹ƒ^ - FVersion : String; //ƒtƒ@ƒCƒ‹ƒo[ƒWƒ‡ƒ“ -// FExitWrite: TStringList; -// function StrToFloatDef(s: string; Default: Double): Double; - function SetUserOptionalStyle(): string; + FVersion : String; //!< ƒtƒ@ƒCƒ‹ƒo[ƒWƒ‡ƒ“ + FGikoMessage: TGikoMessage; + FBelib: TBelib; + //! ‚ ‚éƒZƒpƒŒ[ƒ^‚Å‹æØ‚ç‚ꂽ•¶Žš—ñ‚©‚ç‚Ž”Ô–Ú‚Ì•¶Žš—ñ‚ðŽæ‚èo‚· + function ChooseString(const Text, Separator: string; Index: integer): string; + //! ˆêŽžƒtƒ@ƒCƒ‹‚©‚ç‚Ì•œ‹Œ + procedure RestoreThreadData(Board: TBoard); public { Public éŒ¾ } FAbon : TAbon; @@ -125,15 +126,12 @@ type destructor Destroy; override; property ResRange : Longint read FResRange write FResRange; - //ƒo[ƒWƒ‡ƒ“î•ñ + //! ƒo[ƒWƒ‡ƒ“î•ñ property Version : String read FVersion; -// function MsgBox(Msg: string; Title: string; Flags: Longint): integer; overload; -// function MsgBox(Handle: THandle; Msg: string; Title: string; Flags: Longint): integer; overload; function IsNumeric(s: string): boolean; function IsFloat(s: string): boolean; function DirectoryExistsEx(const Name: string): Boolean; function ForceDirectoriesEx(Dir: string): Boolean; -// function GetVersion: string; function GetBoardFileName: string; function GetCustomBoardFileName: string; @@ -154,6 +152,9 @@ type function GetUserAgent: string; function GetSambaFileName : string; + function GetMainKeyFileName : String; + function GetEditorKeyFileName: String; + function GetInputAssistFileName: String; procedure ReadSubjectFile(Board: TBoard); procedure CreateThreadDat(Board: TBoard); procedure WriteThreadDat(Board: TBoard); @@ -162,15 +163,10 @@ type procedure GetFileList(Path: string; Mask: string; var List: TStringList; IsPathAdd: Boolean); overload;//ƒTƒuƒtƒHƒ‹ƒ_‚ÍŒŸõ‚µ‚È‚¢ procedure GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean); - procedure CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string); - procedure CreateHTML3(var html: TStringList; ThreadItem: TThreadItem; var sTitle: string); - function AddAnchorTag(s: string): string; - function DivideSubject(Line: string): TSubjectRec; - function DivideStrLine(Line: string): TResRec; - property Setting: TSetting read FSetting write FSetting; property Dolib: TDolib read FDolib write FDolib; + property Belib: TBelib read FBelib write FBelib; function UrlToID(url: string): string; function UrlToServer(url: string): string; @@ -180,7 +176,6 @@ type function GetFileSize(FileName : string) : longint; function GetFileLineCount(FileName : string): longint; - function Get2chDate(aDate: TDateTime): string; function IntToDateTime(val: Int64): TDateTime; function DateTimeToInt(ADate: TDateTime): Int64; @@ -188,22 +183,15 @@ type procedure MenuFont(Font: TFont); - function RemoveToken(var s:string; const delimiter:string):string; +// function RemoveToken(var s:string; const delimiter:string):string; function GetTokenIndex(s: string; delimiter: string; index: Integer): string; - function DeleteLink(const s: string): string; function GetShortName(const LongName: string; ALength: integer): string; - function ConvRes(const Body, Bbs, Key, ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string; DatToHTML: boolean = false): string; overload; - function ConvRes(const Body, Bbs, Key, ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue, FullURL : string): string; overload; - function ConvertResAnchor(res: string): string; function BoolToInt(b: Boolean): Integer; function IntToBool(i: Integer): Boolean; function GzipDecompress(ResStream: TStream; ContentEncoding: string): string; - procedure LoadKeySetting(ActionList: TActionList); - procedure SaveKeySetting(ActionList: TActionList); - procedure LoadEditorKeySetting(ActionList: TActionList); - procedure SaveEditorKeySetting(ActionList: TActionList); - + procedure LoadKeySetting(ActionList: TActionList; FileName: String); + procedure SaveKeySetting(ActionList: TActionList; FileName: String); procedure CreateProcess(const AppPath: string; const Param: string); procedure OpenBrowser(URL: string; BrowserType: TGikoBrowserType); function HTMLDecode(const AStr: String): String; @@ -226,22 +214,12 @@ type procedure GetPopupResNumber(URL : string; var stRes, endRes : Int64); - // ƒXƒLƒ“‚ð“ǂݍž‚݁A’l‚ð’uŠ·‚·‚é - function LoadFromSkin( fileName: string; ThreadItem: TThreadItem; SizeByte: Integer ): string; - // ƒŒƒX‚Ì’l‚ð’uŠ·‚·‚é - function SkinedRes( skin: string; Res: TResRec; No: string ): string; - - //Samba24‚̃tƒ@ƒCƒ‹‚ª‘¶Ý‚·‚é‚©B‘¶Ý‚µ‚È‚¢ê‡Adefaultƒtƒ@ƒCƒ‹‚ðrename‚·‚é - procedure SambaFileExists(); - property Bayesian : TGikoBayesian read FBayesian write FBayesian; - function GetSameIDResAnchor(const AID : string; ThreadItem: TThreadItem; limited: boolean):string; overload; - function GetSameIDResAnchor(AIDNum : Integer; ThreadItem: TThreadItem; limited: boolean):string; overload; + function CreateResAnchor(var Numbers: TStringList; ThreadItem: TThreadItem; limited: Integer):string; procedure GetSameIDRes(const AID : string; ThreadItem: TThreadItem;var body: TStringList); overload; procedure GetSameIDRes(AIDNum : Integer; ThreadItem: TThreadItem;var body: TStringList); overload; - function GetSameIDResCount(const AID : string; ThreadItem: TThreadItem):Integer; overload; - function GetSameIDResCount(AIDNum : Integer; ThreadItem: TThreadItem):Integer; overload; - + function GetResID(AIDNum: Integer; ThreadItem: TThreadItem): String; + function ExtructResID(ADateStr: String): String; //! ’PŒê‰ðÍ procedure SpamCountWord( const text : string; wordCount : TWordCount ); //! ŠwKƒNƒŠƒA @@ -250,13 +228,45 @@ type procedure SpamLearn( wordCount : TWordCount; isSpam : Boolean ); //! ƒXƒpƒ€“x” function SpamParse( const text : string; wordCount : TWordCount ) : Extended; - //ˆø”‚ªA“ú•t‚Å‚àŽž‚Å‚à‚È‚¢‚±‚Ƃ𒲂ׂé - function NotDateorTimeString(const AStr : string): boolean; - //ˆø”‚É‘—‚ç‚ê‚Ä‚«‚½“ú•t/ID•”‚ÉBE‚Ì•¶Žš—ñ‚ª‚ ‚Á‚½‚çAƒvƒƒtƒ@ƒCƒ‹‚ւ̃Šƒ“ƒN‚ð’ljÁ + //! ˆø”‚É‘—‚ç‚ê‚Ä‚«‚½“ú•t/ID•”‚ÉBE‚Ì•¶Žš—ñ‚ª‚ ‚Á‚½‚çAƒvƒƒtƒ@ƒCƒ‹‚ւ̃Šƒ“ƒN‚ð’ljÁ function AddBeProfileLink(AID : string; ANum: Integer): string; - //ƒo[ƒWƒ‡ƒ“î•ñ‚̎擾 + //! ƒo[ƒWƒ‡ƒ“î•ñ‚̎擾 function GetVersionInfo(KeyWord: TVerResourceKey): string; + //! Plugin‚̏î•ñ‚̎擾 + function GetPluginsInfo(): string; + //! IE‚̃o[ƒWƒ‡ƒ“î•ñ‚̎擾 + function GetIEVersion: string; + function SetUserOptionalStyle(): string; + //! ƒMƒRƒiƒr‚̃ƒbƒZ[ƒW‚ðÝ’è‚·‚é + procedure SetGikoMessage; + //! ƒMƒRƒiƒr‚̃ƒbƒZ[ƒW‚ðŽæ“¾‚·‚é + function GetGikoMessage(MesType: TGikoMessageListType): String; + //! GMT‚ÌŽž‚ðTDateTime‚É•ÏŠ·‚·‚é + function DateStrToDateTime(const DateStr: string): TDateTime; + //! User32.dll‚ª—˜—p‚Å‚«‚é‚© + function CanUser32DLL: Boolean; + //! OEˆø—p•„Žæ“¾ + function GetOEIndentChar : string; + //! ’uŠ·Ý’èƒtƒ@ƒCƒ‹Žæ“¾ + function GetReplaceFileName: String; + //! ƒCƒ“ƒfƒbƒNƒX‚É‚È‚¢dati‚Í‚®‚êdatj‚̒ljÁ + procedure AddOutofIndexDat(Board: TBoard; DatList: TStringList; AllCreate: boolean = True); + //! ƒtƒ@ƒCƒ‹–¼‚©‚ç‚̃XƒŒƒbƒhì¬“ú‚̎擾 + function GetCreateDateFromName(FileName: String): TDateTime; + function GetExtpreviewFileName: String; + + procedure ShowRefCount(msg: String; unk: IUnknown); + //! –`Œ¯‚̏‘CookieŽæ“¾ + function GetBoukenCookie(AURL: String): String; + //! –`Œ¯‚̏‘CookieÝ’è + procedure SetBoukenCookie(ACookieValue, ADomain: String); + //! –`Œ¯‚̏‘Cookieíœ + procedure DelBoukenCookie(ADomain: String); + //! –`Œ¯‚̏‘Domainˆê——Žæ“¾ + procedure GetBoukenDomain(var ADomain: TStringList); + //! –`Œ¯‚̏‘ƒhƒƒCƒ“–¼CookieŽæ“¾ + function GetBouken(AURL: String; var Domain: String): String; end; var @@ -266,8 +276,8 @@ const ZERO_DATE: Integer = 25569; BETA_VERSION_NAME_E = 'beta'; BETA_VERSION_NAME_J = 'ÊÞÀ'; - BETA_VERSION = 50; - BETA_VERSION_BUILD = ''; //debug”Å‚È‚Ç + BETA_VERSION = 62; + BETA_VERSION_BUILD = ''; //!< debug”Å‚È‚Ç APP_NAME = 'gikoNavi'; BE_PHP_URL = 'http://be.2ch.net/test/p.php?i='; @@ -275,7 +285,8 @@ const implementation uses - Giko, RoundData, Favorite; + Giko, RoundData, Favorite, Registry, HTMLCreate, MojuUtils, Sort, YofUtils, + IniFiles, DateUtils, SkinFiles; const FOLDER_INDEX_VERSION = '1.01'; @@ -284,6 +295,7 @@ const NGWORDs_DIR_NAME : String = 'NGwords'; READ_PATH: string = '/test/read.cgi/'; + HTML_READ_PATH: string = '/test/read.html/'; OLD_READ_PATH: string = '/test/read.cgi?'; KAKO_PATH: string = '/kako/'; @@ -301,28 +313,32 @@ const 'ProductVersion', 'SpecialBuild'); -(************************************************************************* - *GikoSysƒRƒ“ƒXƒgƒ‰ƒNƒ^ - *************************************************************************) +// ************************************************************************* +//! GikoSysƒRƒ“ƒXƒgƒ‰ƒNƒ^ +// ************************************************************************* constructor TGikoSys.Create; begin + Inherited; FSetting := TSetting.Create; FDolib := TDolib.Create; + FBelib := TBelib.Create; FAWKStr := TAWKStr.Create(nil); if DirectoryExists(GetConfigDir) = false then begin CreateDir(GetConfigDir); end; FAbon := TAbon.Create; + FAbon.IgnoreKana := FSetting.IgnoreKana; FAbon.Setroot(GetConfigDir+NGWORDs_DIR_NAME); FAbon.GoHome; FAbon.ReturnNGwordLineNum := FSetting.ShowNGLinesNum; FAbon.SetNGResAnchor := FSetting.AddResAnchor; - FAbon.DeleteSyria := FSetting.DeleteSyria; + FAbon.DeleteSyria := FSetting.DeleteSyria; FAbon.Deleterlo := FSetting.AbonDeleterlo; FAbon.Replaceul := FSetting.AbonReplaceul; FAbon.AbonPopupRes := FSetting.PopUpAbon; FSelectResFilter := TAbon.Create; + FSelectResFilter.IgnoreKana := True; // i‚荞‚Þ‚Æ‚«‚͋ɗ͈ꗗ‚ªŒ©‚ç‚ê‚é‚Ù‚¤‚ª‚¢‚¢‚Ì‚Å‘¼‚ÍŠ®‘S‚ɍ폜 FSelectResFilter.AbonString := ''; // @@ -330,27 +346,18 @@ begin FVersion := Trim(GetVersionInfo(vrFileVersion)); FBayesian := TGikoBayesian.Create; //FBoardURLList := TStringList.Create; + //ƒƒbƒZ[ƒW‚̍쐬 + FGikoMessage := TGikoMessage.Create; end; -(************************************************************************* - *GikoSysƒfƒXƒgƒ‰ƒNƒ^ - *************************************************************************) +// ************************************************************************* +//! GikoSysƒfƒXƒgƒ‰ƒNƒ^ +// ************************************************************************* destructor TGikoSys.Destroy; var i: Integer; FileList: TStringList; begin - //ƒXƒŒƒbƒhƒf[ƒ^ƒtƒ@ƒCƒ‹‚ðXV -// FlashExitWrite; - -// FExitWrite.Free; - FBayesian.Free; - FAWKStr.Free; - FSetting.Free; - FDolib.Free; - FAbon.Free; - FSelectResFilter.Free; - //FBoardURLList.Free; //ƒeƒ“ƒ|ƒ‰ƒŠHTML‚ðíœ FileList := TStringList.Create; try @@ -363,12 +370,22 @@ begin finally FileList.Free; end; + FreeAndNil(FGikoMessage); + FreeAndNil(FBayesian); + FreeAndNil(FSelectResFilter); + FreeAndNil(FAbon); + FreeAndNil(FAWKStr); + FreeAndNil(FBelib); + FreeAndNil(FDolib); + FreeAndNil(FSetting); inherited; end; -(************************************************************************* - *•¶Žš—ñ”Žšƒ`ƒFƒbƒN - *************************************************************************) +{! +\brief •¶Žš—ñ”Žšƒ`ƒFƒbƒN +\param s ƒ`ƒFƒbƒN‚·‚镶Žš—ñ +\return s ‚ª•„†•t‚«®”‚Æ‚µ‚Ä”FŽ¯‰Â”\‚È‚ç True +} {$HINTS OFF} function TGikoSys.IsNumeric(s: string): boolean; var @@ -380,9 +397,11 @@ begin end; {$HINTS ON} -(************************************************************************* - *•¶Žš—ñ•‚“®¬”“_”Žšƒ`ƒFƒbƒN - *************************************************************************) +{! +\brief •¶Žš—ñ•‚“®¬”“_”Žšƒ`ƒFƒbƒN +\param s ƒ`ƒFƒbƒN‚·‚镶Žš—ñ +\return s ‚ª•„†•t‚«•‚“®¬”‚Æ‚µ‚Ä”FŽ¯‰Â”\‚È‚ç True +} function TGikoSys.IsFloat(s: string): boolean; var v: Extended; @@ -390,112 +409,120 @@ begin Result := TextToFloat(PChar(s), v, fvExtended); end; -(************************************************************************* - *ƒ{[ƒhƒtƒ@ƒCƒ‹–¼Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j - *************************************************************************) +// ************************************************************************* +//! ƒ{[ƒhƒtƒ@ƒCƒ‹–¼Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j +// ************************************************************************* function TGikoSys.GetBoardFileName: string; begin Result := Setting.GetBoardFileName; end; -(************************************************************************* - *ƒ{[ƒhƒtƒ@ƒCƒ‹–¼Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j - *************************************************************************) +// ************************************************************************* +//! ƒ{[ƒhƒtƒ@ƒCƒ‹–¼Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j +// ************************************************************************* function TGikoSys.GetCustomBoardFileName: string; begin Result := Setting.GetCustomBoardFileName; end; -(************************************************************************* - *ƒeƒ“ƒ|ƒ‰ƒŠƒtƒHƒ‹ƒ_[–¼Žæ“¾ - *************************************************************************) +// ************************************************************************* +//! ƒeƒ“ƒ|ƒ‰ƒŠƒtƒHƒ‹ƒ_[–¼Žæ“¾ +// ************************************************************************* function TGikoSys.GetHtmlTempFileName: string; begin Result := Setting.GetHtmlTempFileName; end; -(************************************************************************* - *ŽÀsƒtƒ@ƒCƒ‹ƒtƒHƒ‹ƒ_Žæ“¾ - *************************************************************************) +// ************************************************************************* +//! ŽÀsƒtƒ@ƒCƒ‹ƒtƒHƒ‹ƒ_Žæ“¾ +// ************************************************************************* function TGikoSys.GetAppDir: string; begin Result := Setting.GetAppDir; end; -(************************************************************************* - *TempHtmlƒtƒ@ƒCƒ‹–¼Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j - *************************************************************************) +// ************************************************************************* +//! TempHtmlƒtƒ@ƒCƒ‹–¼Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j +// ************************************************************************* function TGikoSys.GetTempFolder: string; begin Result := Setting.GetTempFolder; end; -(************************************************************************* - *sent.iniƒtƒ@ƒCƒ‹–¼Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j - *************************************************************************) +// ************************************************************************* +//! sent.iniƒtƒ@ƒCƒ‹–¼Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j +// *************************************************************************) function TGikoSys.GetSentFileName: string; begin Result := Setting.GetSentFileName; end; -(************************************************************************* - *outbox.iniƒtƒ@ƒCƒ‹–¼Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j - *************************************************************************) +// ************************************************************************* +//! outbox.iniƒtƒ@ƒCƒ‹–¼Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j +// ************************************************************************* function TGikoSys.GetOutBoxFileName: string; begin Result := Setting.GetOutBoxFileName; end; -(************************************************************************* - *ConfigƒtƒHƒ‹ƒ_Žæ“¾ - *************************************************************************) +// ************************************************************************* +//! ConfigƒtƒHƒ‹ƒ_Žæ“¾ +// ************************************************************************* function TGikoSys.GetConfigDir: string; begin Result := Setting.GetConfigDir; end; +//! ƒXƒ^ƒCƒ‹ƒV[ƒgƒtƒHƒ‹ƒ_ function TGikoSys.GetStyleSheetDir: string; begin Result := Setting.GetStyleSheetDir; end; +//! ƒXƒLƒ“ƒtƒHƒ‹ƒ_ function TGikoSys.GetSkinDir: string; begin Result := Setting.GetSkinDir; end; +//! Skin:ƒwƒbƒ_‚̃tƒ@ƒCƒ‹–¼ function TGikoSys.GetSkinHeaderFileName: string; begin - Result := Setting.GetSkinHeaderFileName; + Result := Setting.SkinFiles.GetSkinHeaderFileName; end; +//! Skin:ƒtƒbƒ^‚̃tƒ@ƒCƒ‹–¼ function TGikoSys.GetSkinFooterFileName: string; begin - Result := Setting.GetSkinFooterFileName; + Result := Setting.SkinFiles.GetSkinFooterFileName; end; +//! Skin:V’…ƒŒƒX‚̃tƒ@ƒCƒ‹–¼ function TGikoSys.GetSkinNewResFileName: string; begin - Result := Setting.GetSkinNewResFileName; + Result := Setting.SkinFiles.GetSkinNewResFileName; end; +//! Skin:”ñV’…ƒŒƒX‚̃tƒ@ƒCƒ‹–¼ function TGikoSys.GetSkinResFileName: string; begin - Result := Setting.GetSkinResFileName; + Result := Setting.SkinFiles.GetSkinResFileName; end; +//! Skin:‚µ‚¨‚è(‚±‚±‚Ü‚Å“Ç‚ñ‚¾)‚̃tƒ@ƒCƒ‹–¼ function TGikoSys.GetSkinBookmarkFileName: string; begin - Result := Setting.GetSkinBookmarkFileName; + Result := Setting.SkinFiles.GetSkinBookmarkFileName; end; +//! Skin:‚µ‚¨‚è(V’…ƒŒƒX)‚̃tƒ@ƒCƒ‹–¼ function TGikoSys.GetSkinNewmarkFileName: string; begin - Result := Setting.GetSkinNewmarkFileName; + Result := Setting.SkinFiles.GetSkinNewmarkFileName; end; -// UserAgentŽæ“¾ +//! UserAgentŽæ“¾ function TGikoSys.GetUserAgent: string; begin if Dolib.Connected then begin @@ -516,96 +543,97 @@ begin end; end; -(************************************************************************* - *‚Q‚¿‚á‚ñ‚Ë‚é•ûŽ®ŽžŽæ“¾ - *************************************************************************) -function TGikoSys.Get2chDate(aDate: TDateTime): string; -var - d2: TDateTime; -begin - d2 := aDate - EncodeTime(9, 0, 0, 0); - Result := FloatToStr(Trunc((d2 - ZERO_DATE) * 86400)); -end; - -//val‚́A1970/1/1/ 00:00:00 ‚©‚ç‚ÌŒo‰ßŽžŠÔ +{! +\brief Œo‰ß•b‚ð TDateTime ‚É•ÏŠ· +\param val 1970/1/1/ 00:00:00 ‚©‚ç‚ÌŒo‰ß•b +\return val ‚ðŽ¦‚· TDateTime +} function TGikoSys.IntToDateTime(val: Int64): TDateTime; begin Result := ZERO_DATE + val / 86400.0; end; -//ADate‚ð1970/1/1/ 00:00:00 ‚©‚ç‚ÌŒo‰ßŽžŠÔ‚É•ÏŠ·‚·‚é + +{! +\brief TDateTime ‚ðŒo‰ß•b‚É•ÏŠ· +\param ADate •ÏŠ·‚·‚鎞 +\return 1970/1/1/ 00:00:00 ‚©‚ç‚ÌŒo‰ß•b +} function TGikoSys.DateTimeToInt(ADate: TDateTime): Int64; begin Result := Trunc((ADate - ZERO_DATE) * 86400); end; -(************************************************************************* - *Subjectƒtƒ@ƒCƒ‹Read - *************************************************************************) +{! +\brief Subjectƒtƒ@ƒCƒ‹Read +\param Board ƒXƒŒˆê——‚ðŽæ“¾‚·‚é” +} procedure TGikoSys.ReadSubjectFile(Board: TBoard); var ThreadItem: TThreadItem; FileName: string; FileList: TStringList; - TmpFileList: TStringList; Index: Integer; sl: TStringList; i: Integer; Rec: TIndexRec; UnRead: Integer; - ini: TMemIniFile; - ResRec: TResRec; -// RoundItem: TRoundItem; -// idx: Integer; usePlugIn : Boolean; - tmpStr: string; - BoardPath : String; - server : String; islog : Boolean; - //protocol, host, path, document, port, bookmark : string; - //is2ch : Boolean; + urlHead: String; + datFileCheck: Boolean; {* FavoThreadItem : TFavoriteThreadItem; Node: TTreeNode; *} +{$IFDEF DEBUG} + st, rt: Cardinal; +{$ENDIF} begin +{$IFDEF DEBUG} + st := GetTickCount; +{$ENDIF} if Board.IsThreadDatRead then Exit; Board.Clear; UnRead := 0; - //is2ch := false; usePlugIn := Board.IsBoardPlugInAvailable; - server := UrlToServer( Board.URL ); - //is2ch := Is2chHost(server); + //server := UrlToServer( Board.URL ); + // ƒXƒŒƒbƒh‚Å‹¤’Ê‚ÌURL•” + if Board.is2ch then begin + urlHead := UrlToServer( Board.URL ) + 'test/read.cgi/' + Board.BBSID + '/'; + end else begin + urlHead := UrlToServer( Board.URL ) + 'test/read.cgi?bbs=' + Board.BBSID + '&key='; + end; FileName := Board.GetFolderIndexFileName; - FileList := TStringList.Create; - FileList.Sorted := True; - FileList.BeginUpdate; - TmpFileList := TStringList.Create; - TmpFileList.Sorted := True; - TmpFileList.BeginUpdate; - //IsLogFile—pDATƒtƒ@ƒCƒ‹ƒŠƒXƒg - GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False); - FileList.EndUpdate; - //‘O‰ñˆÙíI—¹Žž—pTmpƒtƒ@ƒCƒ‹ƒŠƒXƒg - GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.tmp', TmpFileList, False); - TmpFileList.EndUpdate; + // + datFileCheck := (Setting.CheckDatFile) or (not FileExists(FileName)); + if (datFileCheck) then begin + FileList := TStringList.Create; + FileList.Sorted := True; + FileList.BeginUpdate; + //IsLogFile—pDATƒtƒ@ƒCƒ‹ƒŠƒXƒg + GetFileList(ExtractFileDir(Board.GetFolderIndexFileName), '*.dat', FileList, False); + FileList.EndUpdate; + end; // d•¡‚ð–h‚® Board.BeginUpdate; Board.Sorted := True; - sl := TStringList.Create; try if FileExists(FileName) then begin sl.LoadFromFile(FileName); - //‚Qs–Ú‚©‚çi‚Ps–ڂ̓o[ƒWƒ‡ƒ“j for i := sl.Count - 1 downto 1 do begin Rec := ParseIndexLine(sl[i]); - islog := FileList.Find( Rec.FFileName, Index ); + if (datFileCheck) then begin + islog := FileList.Find( Rec.FFileName, Index ); + end else begin + islog := (Rec.FSize <> 0) and (Rec.FCount <> 0); + end; if usePlugIn then ThreadItem := TThreadItem.Create( Board.BoardPlugIn, @@ -616,7 +644,7 @@ begin ThreadItem := TThreadItem.Create( nil, Board, - server + 'test/read.cgi/' + Board.BBSID + '/' + ChangeFileExt( Rec.FFileName, '' ) + '/l50', + urlHead + ChangeFileExt( Rec.FFileName, '' ) + '/l50', islog, Rec.FFileName ); @@ -624,29 +652,26 @@ begin ThreadItem := TThreadItem.Create( nil, Board, - server + 'test/read.cgi?bbs=' + Board.BBSID + '&key=' + ChangeFileExt( Rec.FFileName, '' ) + '&ls=50', + urlHead + ChangeFileExt( Rec.FFileName, '' ) + '&ls=50', islog, Rec.FFileName ); end; end; - ThreadItem.BeginUpdate; - if islog then + //ThreadItem.BeginUpdate; + if (datFileCheck) and (islog) then FileList.Delete( Index ); ThreadItem.No := Rec.FNo; ThreadItem.FileName := Rec.FFileName; - ThreadItem.Title := Rec.FTitle; - //ThreadItem.ShortTitle := CustomStringReplace(ZenToHan(ThreadItem.Title), ' ', ''); + ThreadItem.Title := MojuUtils.UnSanitize(Rec.FTitle); ThreadItem.Count := Rec.FCount; ThreadItem.Size := Rec.FSize; -// ThreadItem.RoundNo := Rec.FRoundNo; ThreadItem.RoundDate := Rec.FRoundDate; ThreadItem.LastModified := Rec.FLastModified; ThreadItem.Kokomade := Rec.FKokomade; ThreadItem.NewReceive := Rec.FNewReceive; -// ThreadItem.Round := Rec.FRound; ThreadItem.UnRead := Rec.FUnRead; ThreadItem.ScrollTop := Rec.FScrollTop; ThreadItem.AllResCount := Rec.FAllResCount; @@ -659,21 +684,10 @@ begin Node := FavoriteDM.TreeView.Items.AddChildObject( FavoriteDM.TreeView.Items.Item[0], ThreadItem.Title, FavoThreadItem); *} - {//„‰ñƒŠƒXƒg‚É‘¶Ý‚µ‚½‚珄‰ñƒtƒ‰ƒOƒZƒbƒg - if ThreadItem.IsLogFile then begin - idx := RoundList.Find(ThreadItem); - if idx <> -1 then begin - RoundItem := RoundList.Items[idx, grtItem]; - ThreadItem.RoundName := RoundItem.RoundName; - ThreadItem.Round := True; - end; - end; - } - - ThreadItem.EndUpdate; + //ThreadItem.EndUpdate; Board.Add(ThreadItem); - if (ThreadItem.IsLogFile) and (ThreadItem.UnRead) then + if (ThreadItem.UnRead) and (ThreadItem.IsLogFile) then Inc(UnRead); end; end; @@ -681,100 +695,105 @@ begin if UnRead <> Board.UnRead then Board.UnRead := UnRead; - Boardpath := ExtractFilePath(Board.GetFolderIndexFileName); - //ƒCƒ“ƒfƒbƒNƒX‚É–³‚©‚Á‚½ƒƒO‚ð’ljÁi•…‚êƒCƒ“ƒfƒbƒNƒX‘Ήžj - for i := 0 to FileList.Count - 1 do begin - FileName := Boardpath + FileList[i]; - - //ResRec := DivideStrLine(ReadThreadFile(FileName, 1)); - if usePlugIn then begin - ThreadItem := TThreadItem.Create( - Board.BoardPlugIn, - Board, - Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), FileList[i] ) ); - ResRec := DivideStrLine(Board.BoardPlugIn.GetDat( DWORD( ThreadItem ), 1 )); - end else begin - ThreadItem := TThreadItem.Create( - nil, - Board, - Get2chBoard2ThreadURL( Board, ChangeFileExt( FileList[i], '' ) ) ); - ResRec := DivideStrLine(ReadThreadFile(FileName, 1)); - end; - - ThreadItem.BeginUpdate; - ThreadItem.FileName := FileList[i]; - //ThreadItem.FilePath := FileName; - ThreadItem.No := Board.Count + 1; - ThreadItem.Title := ResRec.FTitle; - ThreadItem.Count := GetFileLineCount(FileName); - ThreadItem.AllResCount := ThreadItem.Count; - ThreadItem.NewResCount := ThreadItem.Count; - ThreadItem.Size := GetFileSize(FileName) - ThreadItem.Count;//1byte‚¸‚ê‚é‚Æ‚«‚ª‚ ‚邯‚Ç‚»‚ê‚Í‚ ‚«‚ç‚ß‚é - ThreadItem.RoundDate := ZERO_DATE; - ThreadItem.LastModified := ZERO_DATE; - ThreadItem.Kokomade := -1; - ThreadItem.NewReceive := ThreadItem.Count; - ThreadItem.ParentBoard := Board; - ThreadItem.IsLogFile := True; - ThreadItem.Round := False; - ThreadItem.UnRead := False; - ThreadItem.ScrollTop := 0; - ThreadItem.AgeSage := gasNone; - ThreadItem.EndUpdate; - Board.Add(ThreadItem); - end; + if (datFileCheck) then begin + //ƒCƒ“ƒfƒbƒNƒX‚É–³‚©‚Á‚½ƒƒO‚ð’ljÁi•…‚êƒCƒ“ƒfƒbƒNƒX‘Ήžj + AddOutofIndexDat(Board, FileList); + end; Board.EndUpdate; - //‘O‰ñˆÙíI—¹Žžƒ`ƒFƒbƒN - for i := TmpFileList.Count - 1 downto 0 do begin - //if TmpFileList.Count <> 0 then begin - ThreadItem := Board.FindThreadFromFileName(ChangeFileExt(TmpFileList[i], '.dat')); - if ThreadItem <> nil then begin - //if TmpFileList.Find(ChangeFileExt(ThreadItem.FileName, '.tmp'), Index) then begin - ini := TMemIniFile.Create(Boardpath + TmpFileList[i]); - try - tmpStr := ini.ReadString('Setting', 'RoundDate', DateTimeToStr(ZERO_DATE)); - ThreadItem.RoundDate := ConvertDateTimeString(tmpStr); - - tmpStr := ini.ReadString('Setting', 'LastModified', DateTimeToStr(ZERO_DATE)); - ThreadItem.LastModified := ConvertDateTimeString(tmpStr); - ThreadItem.Count := ini.ReadInteger('Setting', 'Count', 0); - ThreadItem.NewReceive := ini.ReadInteger('Setting', 'NewReceive', 0); - - ThreadItem.Size := ini.ReadInteger('Setting', 'Size', 0); - if(ThreadItem.Size = 0) and (FileExists(ThreadItem.GetThreadFileName)) then begin - try - ThreadItem.Size := GetFileSize(ThreadItem.GetThreadFileName) - ThreadItem.Count; - except - end; - end; - - - ThreadItem.Round := ini.ReadBool('Setting', 'Round', False); - ThreadItem.UnRead := False;//ini.ReadBool('Setting', 'UnRead', False); - ThreadItem.ScrollTop := ini.ReadInteger('Setting', 'ScrollTop', 0); - ThreadItem.AllResCount := ini.ReadInteger('Setting', 'AllResCount', ThreadItem.Count); - ThreadItem.NewResCount := ini.ReadInteger('Setting', 'NewResCount', 0); - ThreadItem.AgeSage := TGikoAgeSage(ini.ReadInteger('Setting', 'AgeSage', Ord(gasNone))); - finally - ini.Free; - end; - DeleteFile(Boardpath + TmpFileList[i]); - end; - end; - + //‘O‰ñˆÙíI—¹Žžƒ`ƒFƒbƒN + RestoreThreadData( Board ); finally sl.Free; - FileList.Free; - TmpFileList.Free; + if (datFileCheck) then begin + FileList.Free; + end; Board.Sorted := False; end; Board.IsThreadDatRead := True; +{$IFDEF DEBUG} + rt := GetTickCount - st; + Writeln('Read Done.' + Board.Title + ':' + IntToStr(rt) + ' ms'); +{$ENDIF} +end; +{! +\brief ƒCƒ“ƒfƒbƒNƒX‚É‚È‚¢dati‚Í‚®‚êdatj‚̒ljÁ +\param Board ’ljÁ‚·‚é” +\param DatList datƒtƒ@ƒCƒ‹–¼ +} +procedure TGikoSys.AddOutofIndexDat(Board: TBoard; DatList: TStringList; AllCreate: Boolean = True); +var + i : Integer; + Boardpath,FileName : String; + ResRec: TResRec; + ThreadItem: TThreadItem; + create: Boolean; +begin + create := False; + Boardpath := ExtractFilePath(Board.GetFolderIndexFileName); + //ƒCƒ“ƒfƒbƒNƒX‚É–³‚©‚Á‚½ƒƒO‚ð’ljÁi•…‚êƒCƒ“ƒfƒbƒNƒX‘Ήžj + for i := 0 to DatList.Count - 1 do begin + FileName := Boardpath + DatList[i]; + ThreadItem := nil; + if (not AllCreate) then begin + create := False; + ThreadItem := Board.FindThreadFromFileName(DatList[i]); + if (ThreadItem = nil) then begin + create := True; + end else begin + if Board.IsBoardPlugInAvailable then begin + THTMLCreate.DivideStrLine(Board.BoardPlugIn.GetDat( DWORD( ThreadItem ), 1 ), @ResRec); + end else begin + THTMLCreate.DivideStrLine(ReadThreadFile(FileName, 1), @ResRec); + end; + end; + end; + if (ThreadItem = nil) then begin + if Board.IsBoardPlugInAvailable then begin + ThreadItem := TThreadItem.Create( + Board.BoardPlugIn, + Board, + Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), DatList[i] ) ); + THTMLCreate.DivideStrLine(Board.BoardPlugIn.GetDat( DWORD( ThreadItem ), 1 ), @ResRec); + end else begin + ThreadItem := TThreadItem.Create( + nil, + Board, + Get2chBoard2ThreadURL( Board, ChangeFileExt( DatList[i], '' ) ) ); + THTMLCreate.DivideStrLine(ReadThreadFile(FileName, 1), @ResRec); + end; + end; + + + ThreadItem.BeginUpdate; + ThreadItem.FileName := DatList[i]; + //ThreadItem.FilePath := FileName; + ThreadItem.No := Board.Count + 1; + ThreadItem.Title := ResRec.FTitle; + ThreadItem.Count := GetFileLineCount(FileName); + ThreadItem.AllResCount := ThreadItem.Count; + ThreadItem.NewResCount := ThreadItem.Count; + ThreadItem.Size := GetFileSize(FileName) - ThreadItem.Count;//1byte‚¸‚ê‚é‚Æ‚«‚ª‚ ‚邯‚Ç‚»‚ê‚Í‚ ‚«‚ç‚ß‚é + ThreadItem.RoundDate := FileDateToDateTime( FileAge( FileName ) ); + ThreadItem.LastModified := ThreadItem.RoundDate; + ThreadItem.Kokomade := -1; + ThreadItem.NewReceive := 0; + ThreadItem.ParentBoard := Board; + ThreadItem.IsLogFile := True; + ThreadItem.Round := False; + ThreadItem.UnRead := False; + ThreadItem.ScrollTop := 0; + ThreadItem.AgeSage := gasNone; + ThreadItem.EndUpdate; + if (AllCreate) or (create) then begin + Board.Add(ThreadItem); + end; + end; end; - -(************************************************************************* - *ƒXƒŒƒbƒhƒCƒ“ƒfƒbƒNƒXƒtƒ@ƒCƒ‹(Folder.idx)ì¬ - *************************************************************************) +{! +\brief ƒXƒŒƒbƒhƒCƒ“ƒfƒbƒNƒXƒtƒ@ƒCƒ‹(Folder.idx)ì¬ +\param Board Folder.idx ‚ðì¬‚·‚é” +} procedure TGikoSys.CreateThreadDat(Board: TBoard); var i: integer; @@ -822,7 +841,7 @@ begin '%s'#1'%x'#1'%x'#1'%x'#1'%x'#1'%x', [cnt, //”ԍ† Rec.FFileName, //ƒtƒ@ƒCƒ‹–¼ - Rec.FTitle, //ƒ^ƒCƒgƒ‹ + MojuUtils.Sanitize(Rec.FTitle), //ƒ^ƒCƒgƒ‹ Rec.FCount, //ƒJƒEƒ“ƒg 0, //size 0, //RoundDate @@ -850,10 +869,10 @@ begin end; end; -(************************************************************************* - *ƒXƒŒƒbƒhƒCƒ“ƒfƒbƒNƒX(Thread.dat)‘‚«ž‚Ý - *Public - *************************************************************************) +{! +\brief ƒXƒŒƒbƒhƒCƒ“ƒfƒbƒNƒX(Thread.dat)‘‚«ž‚Ý +\param Thread.dat ‚ðì¬‚·‚é” +} procedure TGikoSys.WriteThreadDat(Board: TBoard); //const // Values: array[Boolean] of string = ('0', '1'); @@ -880,9 +899,9 @@ begin sl.Add(FOLDER_INDEX_VERSION); // ƒXƒŒ”ԍ†•Û‘¶‚Ì‚½‚߃\[ƒg - Sort.SortNoFlag := true; - Sort.SortOrder := true; - Sort.SortIndex := 0; + Sort.SetSortNoFlag(true); + Sort.SetSortOrder(true); + Sort.SetSortIndex(0); //Sort.SortNonAcquiredCountFlag := GikoSys.Setting.NonAcquiredCount; Board.CustomSort(ThreadItemSortProc); @@ -892,7 +911,7 @@ begin '%s'#1'%x'#1'%x'#1'%x'#1'%x'#1'%x', [Board.Items[i].No, //”ԍ† Board.Items[i].FileName, //ƒtƒ@ƒCƒ‹–¼ - Board.Items[i].Title, //ƒ^ƒCƒgƒ‹ + MojuUtils.Sanitize(Board.Items[i].Title), //ƒ^ƒCƒgƒ‹ Board.Items[i].Count, //ƒJƒEƒ“ƒg Board.Items[i].Size, //size DateTimeToInt(Board.Items[i].RoundDate), //RoundDate @@ -922,45 +941,59 @@ begin end; end; +{! +\brief Folder.idx ‚ð 1 s‰ðŽß +\param Line Folder.idx ‚ð\¬‚·‚é 1 s +\return ƒXƒŒƒbƒhî•ñ +} function TGikoSys.ParseIndexLine(Line: string): TIndexRec; begin - Result.FNo := StrToIntDef('$' + RemoveToken(Line, #1), 0); - Result.FFileName := RemoveToken(Line, #1); - Result.FTitle := RemoveToken(Line, #1); - Result.FCount := StrToIntDef('$' + RemoveToken(Line, #1), 0); - Result.FSize := StrToIntDef('$' + RemoveToken(Line, #1), 0); - Result.FRoundDate := IntToDateTime(StrToIntDef('$' + RemoveToken(Line, #1), ZERO_DATE)); - Result.FLastModified := IntToDateTime(StrToIntDef('$' + RemoveToken(Line, #1), ZERO_DATE)); - Result.FKokomade := StrToIntDef('$' + RemoveToken(Line, #1), -1); - Result.FNewReceive := StrToIntDef('$' + RemoveToken(Line, #1), 0); - RemoveToken(Line, #1);//9: ; //–¢Žg—p - Result.FUnRead := IntToBool(StrToIntDef('$' + RemoveToken(Line, #1), 0)); - Result.FScrollTop := StrToIntDef('$' + RemoveToken(Line, #1), 0); - Result.FAllResCount := StrToIntDef('$' + RemoveToken(Line, #1), 0); - Result.FNewResCount := StrToIntDef('$' + RemoveToken(Line, #1), 0); - Result.FAgeSage := TGikoAgeSage(StrToIntDef('$' + RemoveToken(Line, #1), 0)); - -end; - -//Žw’èƒtƒHƒ‹ƒ_“à‚ÌŽw’èƒtƒ@ƒCƒ‹ˆê——‚ðŽæ“¾‚·‚é -// ListFiles('c:\', '*.txt', list, True); + Result.FNo := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0); + Result.FFileName := MojuUtils.RemoveToken(Line, #1); + Result.FTitle := MojuUtils.UnSanitize(MojuUtils.RemoveToken(Line, #1)); + Result.FCount := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0); + Result.FSize := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0); + Result.FRoundDate := IntToDateTime(StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), ZERO_DATE)); + Result.FLastModified := IntToDateTime(StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), ZERO_DATE)); + Result.FKokomade := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), -1); + Result.FNewReceive := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0); + MojuUtils.RemoveToken(Line, #1);//9: ; //–¢Žg—p + Result.FUnRead := IntToBool(StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0)); + Result.FScrollTop := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0); + Result.FAllResCount := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0); + Result.FNewResCount := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0); + Result.FAgeSage := TGikoAgeSage(StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0)); + +end; + +{! +\brief Žw’èƒtƒHƒ‹ƒ_“à‚ÌŽw’èƒtƒ@ƒCƒ‹ˆê——‚ðŽæ“¾‚·‚é +\param Path ‹N“_‚Æ‚È‚éƒtƒHƒ‹ƒ_ƒpƒX +\param Mask ƒtƒ@ƒCƒ‹–¼‚̃}ƒXƒN +\param List OUT:Žæ“¾‚³‚ꂽƒtƒ@ƒCƒ‹–¼ˆê——‚ª•Ô‚é +\param SubDir ’†‚̃tƒHƒ‹ƒ_‚܂ōċA“I‚ɃŠƒXƒg‚·‚éê‡‚Í True +\param IsPathAdd ƒpƒX•t‚«‚ŃŠƒXƒgƒAƒbƒv‚·‚éê‡‚Í True + +Mask ‚ð '*.txt' ‚̂悤‚ÉŽw’è‚·‚邱‚ƂŁA +“Á’è‚̃tƒ@ƒCƒ‹–¼‚â“Á’è‚ÌŠg’£Žq‚ɍi‚Á‚½ƒŠƒXƒgƒAƒbƒv‚ª‰Â”\‚Å‚·B + +\par —á: +\code +GetFileList('c:\', '*.txt', list, True, True); +\endcode +} procedure TGikoSys.GetFileList(Path: string; Mask: string; var List: TStringList; SubDir: Boolean; IsPathAdd: Boolean); var rc: Integer; SearchRec : TSearchRec; s: string; - maskExt: string; begin - //maskExt := Copy(Mask, 1, Length(Mask) - 1); - maskExt := Mask; Path := IncludeTrailingPathDelimiter(Path); rc := FindFirst(Path + '*.*', faAnyfile, SearchRec); try while rc = 0 do begin if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin s := Path + SearchRec.Name; - //if (SearchRec.Attr and faDirectory > 0) then - // s := IncludeTrailingPathDelimiter(s) if (SearchRec.Attr and faDirectory = 0) and (MatchesMask(s, Mask)) then if IsPathAdd then @@ -977,27 +1010,37 @@ begin end; List.Sort; end; -//Žw’èƒtƒHƒ‹ƒ_“à‚ÌŽw’èƒtƒ@ƒCƒ‹ˆê——‚ðŽæ“¾‚·‚é -//ƒTƒuƒtƒHƒ‹ƒ_‚ÍŒŸõ‚µ‚È‚¢ -// ListFiles('c:\', '*.txt', list, True); + +{! +\breif Žw’èƒtƒHƒ‹ƒ_“à‚ÌŽw’èƒtƒ@ƒCƒ‹ˆê——‚ðŽæ“¾‚·‚éB + ƒTƒuƒtƒHƒ‹ƒ_‚ÍŒŸõ‚µ‚È‚¢ +\param Path ‹N“_‚Æ‚È‚éƒtƒHƒ‹ƒ_ƒpƒX +\param Mask ƒtƒ@ƒCƒ‹–¼‚̃}ƒXƒN +\param List OUT:Žæ“¾‚³‚ꂽƒtƒ@ƒCƒ‹–¼ˆê——‚ª•Ô‚é +\param IsPathAdd ƒpƒX•t‚«‚ŃŠƒXƒgƒAƒbƒv‚·‚éê‡‚Í True +\note Ä‹NŽw’è‰Â”\‚È GetFileList() ‚ª‚ ‚é‚Ì‚Å‚±‚̊֐”‚Í•s—v? +\par —á +\code +GetFileList('c:\', '*.txt', list, True); +\endcode +} procedure TGikoSys.GetFileList(Path: string; Mask: string; var List: TStringList; IsPathAdd: Boolean); var rc: Integer; SearchRec : TSearchRec; - s: string; begin Path := IncludeTrailingPathDelimiter(Path); rc := FindFirst(Path + Mask, faAnyfile, SearchRec); try while rc = 0 do begin if (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then begin - s := Path + SearchRec.Name; - - if (SearchRec.Attr and faDirectory = 0) then - if IsPathAdd then - List.Add(s) - else - List.Add(SearchRec.Name); + if (SearchRec.Attr and faDirectory = 0) then begin + if IsPathAdd then begin + List.Add(Path + SearchRec.Name) + end else begin + List.Add(SearchRec.Name); + end; + end; end; rc := FindNext(SearchRec); end; @@ -1006,7 +1049,22 @@ begin end; List.Sort; end; -//Žw’èƒtƒHƒ‹ƒ_“à‚̃fƒBƒŒƒNƒgƒŠˆê——‚ðŽæ“¾‚·‚é + +{! +\brief Žw’èƒtƒHƒ‹ƒ_“à‚̃fƒBƒŒƒNƒgƒŠˆê——‚ðŽæ“¾‚·‚é +\param Path ‹N“_‚Æ‚È‚éƒtƒHƒ‹ƒ_ƒpƒX +\param Mask ƒtƒHƒ‹ƒ_–¼‚̃}ƒXƒN +\param List OUT:Žæ“¾‚³‚ꂽƒtƒHƒ‹ƒ_–¼ˆê——‚ª•Ô‚é +\param SubDir ’†‚̃tƒHƒ‹ƒ_‚܂ōċA“I‚ɃŠƒXƒg‚·‚éê‡‚Í True + +Mask ‚ð '*.txt' ‚̂悤‚ÉŽw’è‚·‚邱‚ƂŁA +“Á’è‚̃tƒ@ƒCƒ‹–¼‚â“Á’è‚ÌŠg’£Žq‚ɍi‚Á‚½ƒŠƒXƒgƒAƒbƒv‚ª‰Â”\‚Å‚·B + +\par —á: +\code +GetDirectoryList('c:\', '*.txt', list, True); +\endcode +} procedure TGikoSys.GetDirectoryList(Path: string; Mask: string; List: TStringList; SubDir: Boolean); var rc: Integer; @@ -1034,1075 +1092,191 @@ begin end; end; -// ƒXƒLƒ“‚ð“ǂݍž‚݁A’l‚ð’uŠ·‚·‚é -function TGikoSys.LoadFromSkin( - fileName: string; - ThreadItem: TThreadItem; - SizeByte: Integer -): string; + +{! +\brief Subject.txt ˆês‚ð‰ðŽß +\param Line Subject.txt ‚ð\¬‚·‚é 1 s +\return ƒXƒŒƒbƒhî•ñ +} +function TGikoSys.DivideSubject(Line: string): TSubjectRec; var - Skin: TStringList; + i: integer; + ws: WideString; + Delim: string; + LeftK: string; + RightK: string; begin + Result.FCount := 0; - Skin := TStringList.Create; - try - if FileExists( fileName ) then begin - Skin.LoadFromFile( fileName ); + if AnsiPos('<>', Line) = 0 then + Delim := ',' + else + Delim := '<>'; + Result.FFileName := MojuUtils.RemoveToken(Line, Delim); + Result.FTitle := Trim(MojuUtils.RemoveToken(Line, Delim)); - // ‚â‚è‚©‚½‚ª‹ê‚µ‚¢‚¯‚ǁAƒIƒvƒVƒ‡ƒ“ƒ_ƒCƒAƒƒO‚̃vƒŒƒrƒ…[—p try - try - if ThreadItem.ParentBoard <> nil then - if ThreadItem.ParentBoard.ParentCategory <> nil then - CustomStringReplace( Skin, '', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title); - CustomStringReplace( Skin, '', ThreadItem.URL); - except end; - CustomStringReplace( Skin, '', ThreadItem.ParentBoard.Title); - CustomStringReplace( Skin, '', ThreadItem.ParentBoard.URL); - CustomStringReplace( Skin, '', ThreadItem.Title); - CustomStringReplace( Skin, '', Setting.CSSFileName); - CustomStringReplace( Skin, '', IntToStr( ThreadItem.Count - ThreadItem.NewResCount )); - CustomStringReplace( Skin, '', IntToStr( ThreadItem.NewResCount )); - CustomStringReplace( Skin, '', IntToStr( ThreadItem.Count )); - - CustomStringReplace( Skin, '',FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate)); - CustomStringReplace( Skin, '', IntToStr( Floor( SizeByte / 1024 ) )); - CustomStringReplace( Skin, '', IntToStr( SizeByte )); - - //----- ‚Æ‚è‚ ‚¦‚¸‚©‚¿‚ã`‚µ‚áŒÝŠ·—pBƒRƒƒ“ƒgƒAƒEƒg‚µ‚Ä‚à‚悵 - // ‚â‚è‚©‚½‚ª‹ê‚µ‚¢‚¯‚ǁAƒIƒvƒVƒ‡ƒ“ƒ_ƒCƒAƒƒO‚̃vƒŒƒrƒ…[—p try - try - if ThreadItem.ParentBoard <> nil then - if ThreadItem.ParentBoard.ParentCategory <> nil then - CustomStringReplace( Skin, '&BBSNAME', ThreadItem.ParentBoard.ParentCategory.ParenTBBS.Title); - CustomStringReplace( Skin, '&THREADURL', ThreadItem.URL); - except end; - CustomStringReplace( Skin, '&BOARDNAME', ThreadItem.ParentBoard.Title); - CustomStringReplace( Skin, '&BOARDURL', ThreadItem.ParentBoard.URL); - CustomStringReplace( Skin, '&THREADNAME', ThreadItem.Title); - CustomStringReplace( Skin, '&SKINPATH', Setting.CSSFileName); - CustomStringReplace( Skin, '&GETRESCOUNT', IntToStr( ThreadItem.NewReceive - 1 )); - CustomStringReplace( Skin, '&NEWRESCOUNT', IntToStr( ThreadItem.NewResCount )); - CustomStringReplace( Skin, '&ALLRESCOUNT', IntToStr( ThreadItem.AllResCount )); - - CustomStringReplace( Skin, '&NEWDATE', FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate)); - CustomStringReplace( Skin, '&SIZEKB', IntToStr( Floor( SizeByte / 1024 ) )); - CustomStringReplace( Skin, '&SIZE', IntToStr( SizeByte )); - //----- ‚±‚±‚Ü‚Å + ws := Result.FTitle; + if Copy(ws, Length(ws), 1) = ')' then begin + LeftK := '('; + RightK := ')'; + end else if Copy(ws, Length(ws)-1, 2) = 'j' then begin + LeftK := 'i'; + RightK := 'j'; + end else if Copy(ws, Length(ws), 1) = '>' then begin + LeftK := '<'; + RightK := '>'; + end; + for i := Length(ws) - 1 downto 1 do begin + if Copy(ws, i, Length(LeftK)) = LeftK then begin + Result.FTitle := TrimRight(Copy(ws, 1, i - 1)); + ws := Copy(ws, i + Length(LeftK), Length(ws) - i - Length(RightK)); + if IsNumeric(ws) then + Result.FCount := StrToInt(ws); + //Delete(Result.FTitle, i, Length(LeftK) + Length(ws) + Length(RightK)); + break; end; - Result := Skin.Text; - finally - Skin.Free; end; end; -// ƒŒƒX‚Ì’l‚ð’uŠ·‚·‚é -function TGikoSys.SkinedRes( - skin: string; - Res: TResRec; - No: string -): string; +{! +\brief URL‚©‚çBBSID‚ðŽæ“¾ +\param url BBSID ‚ðŽæ“¾‚·‚é URL +\return BBSID +} +function TGikoSys.UrlToID(url: string): string; var - spamminess : Extended; - wordCount : TWordCount; + i: integer; begin + Result := ''; + url := Trim(url); - wordCount := TWordCount.Create; + if url = '' then Exit; try - spamminess := Floor( SpamParse( - Res.FName + '<>' + Res.FMailTo + '<>' + Res.FBody, wordCount ) * 100 ); - - Skin := CustomStringReplace( Skin, '', - '' + No + ''); - Skin := CustomStringReplace( Skin, '', No); - Skin := CustomStringReplace( Skin, '', '' + Res.FName + ''); - Skin := CustomStringReplace( Skin, '', - '' + Res.FName + ''); - Skin := CustomStringReplace( Skin, '', Res.FMailTo); - Skin := CustomStringReplace( Skin, '', Res.FDateTime); - Skin := CustomStringReplace( Skin, '', Res.FBody); - Skin := CustomStringReplace( Skin, '', FloatToStr( spamminess ) ); - Skin := CustomStringReplace( Skin, '', FloatToStr( 100 - spamminess ) ); - - //----- ‚©‚¿‚ã`‚µ‚áŒÝŠ·—pBƒRƒƒ“ƒgƒAƒEƒg‚µ‚Ä‚à‚悵 - Skin := CustomStringReplace( Skin, '&NUMBER', - '' + No + ''); - Skin := CustomStringReplace( Skin, '&PLAINNUMBER', No); - Skin := CustomStringReplace( Skin, '&NAME', '' + Res.FName + ''); - Skin := CustomStringReplace( Skin, '&MAILNAME', - '' + Res.FName + ''); - Skin := CustomStringReplace( Skin, '&MAIL', Res.FMailTo); - Skin := CustomStringReplace( Skin, '&DATE', Res.FDateTime); - Skin := CustomStringReplace( Skin, '&MESSAGE', Res.FBody); - Skin := CustomStringReplace( Skin, '&SPAMMINESS', FloatToStr( spamminess ) ); - Skin := CustomStringReplace( Skin, '&NONSPAMMINESS', FloatToStr( 100 - spamminess ) ); - //----- ‚±‚±‚Ü‚Å - - Result := Skin; - finally - wordCount.Free; + url := Copy(url, 0, Length(url) - 1); + for i := Length(url) downto 0 do begin + if url[i] = '/' then begin + Result := Copy(url, i + 1, Length(url)); + Break; + end; + end; + except + Result := ''; end; - end; -procedure TGikoSys.CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string); +{! +\brief URL‚©‚çÅŒã‚Ì—v‘f‚ðíœ +\param url ‰ðŽß‚·‚é URL +\return Ø‚èŽæ‚ç‚ꂽŒã‚Ì URL + +URL ‚©‚ç BBSIDˆÈŠO‚Ì•”•ª‚ðŽæ“¾‚·‚é‚Ì‚ÉŽg—p‚µ‚Ü‚·B +} +function TGikoSys.UrlToServer(url: string): string; var i: integer; - No: string; - //bufList : TStringList; - ReadList: TStringList; - SaveList: TStringList; - CSSFileName: string; - BBSID: string; - FileName: string; - NewReceiveNo: Integer; - Res: TResRec; - boardPlugIn : TBoardPlugIn; + wsURL: WideString; +begin + Result := ''; + wsURL := url; + wsURL := Trim(wsURL); + + if wsURL = '' then exit; - UserOptionalStyle: string; - SkinHeader: string; - SkinNewRes: string; - SkinRes: string; + if Copy(wsURL, Length(wsURL), 1) = '/' then + wsURL := Copy(wsURL, 0, Length(wsURL) - 1); - strTmp : string; -// threadURL : string; - function LoadSkin( fileName: string ): string; - begin - Result := LoadFromSkin( fileName, ThreadItem, ThreadItem.Size ); - end; - function ReplaceRes( skin: string ): string; - begin - Result := SkinedRes( skin, Res, No ); + for i := Length(wsURL) downto 0 do begin + if wsURL[i] = '/' then begin + Result := Copy(wsURL, 0, i); + break; + end; end; -begin - if ThreadItem <> nil then begin - //if ThreadItem.IsBoardPlugInAvailable then begin - if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin - //===== ƒvƒ‰ƒOƒCƒ“‚É‚æ‚é•\Ž¦ - //boardPlugIn := ThreadItem.BoardPlugIn; - boardPlugIn := ThreadItem.ParentBoard.BoardPlugIn; - NewReceiveNo := ThreadItem.NewReceive; - // ƒtƒHƒ“ƒg‚âƒTƒCƒY‚̐ݒè - UserOptionalStyle := SetUserOptionalStyle; - SaveList := TStringList.Create; - try - doc.open; - // •¶ŽšƒR[ƒh‚̓vƒ‰ƒOƒCƒ“‚É”C‚¹‚é - // doc.charset := 'Shift_JIS'; - - // ƒwƒbƒ_ - SaveList.Add( boardPlugIn.GetHeader( DWORD( threadItem ), - '' ) ); - - SaveList.Add('

'); - for i := 0 to threadItem.Count - 1 do begin - // 1 ‚Í•K‚¸•\Ž¦ - if i <> 0 then begin - // •\Ž¦”͈͂ðŒÀ’è - case ResRange of - Ord( grrKoko ): - if ThreadItem.Kokomade > (i + 1) then - Continue; - Ord( grrNew ): - if NewReceiveNo > (i + 1) then - Continue; - 10..65535: - if (threadItem.Count - i) > ResRange then - Continue; - end; - end; +end; - // V’…ƒ}[ƒN - if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin - try - if GikoSys.Setting.UseSkin then begin - if FileExists( GetSkinNewmarkFileName ) then - SaveList.Add( LoadSkin( GetSkinNewmarkFileName ) ) - else - SaveList.Add( '' ); - end else if GikoSys.Setting.UseCSS then begin - SaveList.Add('
V’…ƒŒƒX ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '
'); - end else begin - SaveList.Add(''); - SaveList.Add(''); - SaveList.Add('
V’…ƒŒƒX ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '
'); - SaveList.Add('
'); - end; - except - SaveList.Add( '' ); - end; - end; +{! +\brief ƒfƒBƒŒƒNƒgƒŠ‚ª‘¶Ý‚·‚é‚©ƒ`ƒFƒbƒN +\param Name ‘¶Ý‚ðŠm”F‚·‚éƒtƒHƒ‹ƒ_ƒpƒX +\return ƒtƒHƒ‹ƒ_‚ª‘¶Ý‚·‚é‚È‚ç True +} +function TGikoSys.DirectoryExistsEx(const Name: string): Boolean; +var + Code: Cardinal; +begin + Code := GetFileAttributes(PChar(Name)); + Result := (Code <> Cardinal(-1)) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0); +end; - // ƒŒƒX - SaveList.Add( boardPlugIn.GetRes( DWORD( threadItem ), i + 1 ) ); +{! +\brief ƒfƒBƒŒƒNƒgƒŠì¬i•¡”ŠK‘w‘Ήžj +\param Dir ì¬‚·‚éƒpƒX +\return ì¬‚ɐ¬Œ÷‚µ‚½ê‡‚Í True +} +function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean; +begin + Result := True; + if Length(Dir) = 0 then + raise Exception.Create('ƒtƒHƒ‹ƒ_‚ªì¬o—ˆ‚Ü‚¹‚ñ'); + Dir := ExcludeTrailingPathDelimiter(Dir); + if (Length(Dir) < 3) or DirectoryExistsEx(Dir) + or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem. + Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir); +end; - if ThreadItem.Kokomade = (i + 1) then begin - // ‚±‚±‚Ü‚Å“Ç‚ñ‚¾ - try - if GikoSys.Setting.UseSkin then begin - if FileExists( GetSkinBookmarkFileName ) then - SaveList.Add( LoadSkin( GetSkinBookmarkFileName ) ) - else - SaveList.Add( '' ); - end else if GikoSys.Setting.UseCSS then begin - SaveList.Add('
ƒRƒR‚Ü‚Å“Ç‚ñ‚¾
'); - end else begin - SaveList.Add('
'); - SaveList.Add('
ƒRƒR‚Ü‚Å“Ç‚ñ‚¾
'); - SaveList.Add('
'); - end; - except - SaveList.Add( '' ); - end; - end; +{! +\brief •¶Žš—ñ‚©‚çƒg[ƒNƒ“‚̐؂èo‚µi‰Šúˆ—j + FDelphi‚©‚ç‚̃pƒNƒŠ +\param s Œ³‚É‚È‚éƒLƒƒƒ‰ƒNƒ^ +\param sep ‹æØ‚è‚ɂȂ镶Žš—ñ +\param Rec OUT:•¶Žš—ñ‘–¸î•ñ‚ª•Ô‚é +\return Ø‚èo‚µ‚½ƒg[ƒNƒ“ +\todo Split, RemoveToken, GetTokenIndex, NthField s‚« +} +function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string; +begin + Rec.Str := s; + Rec.Pos := 1; + Result := StrTokNext(sep, Rec); +end; - doc.Write(SaveList.Text); - SaveList.Clear; +{! +\brief •¶Žš—ñ‚©‚çƒg[ƒNƒ“‚̐؂èo‚µ + FDelphi‚©‚ç‚̃pƒNƒŠ +\param sep ‹æØ‚è‚É‚È‚éƒLƒƒƒ‰ƒNƒ^ +\param Rec IN/OUT:StrTokFirst‚ō쐬‚³‚ꂽ•¶Žš—ñ‘–¸î•ñ +\return Ø‚èo‚µ‚½ƒg[ƒNƒ“ +\todo Split, RemoveToken, GetTokenIndex, NthField s‚« +} +function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string; +var + Len, I: Integer; +begin + with Rec do begin + Len := Length(Str); + Result := ''; + if Len >= Pos then begin + while (Pos <= Len) and (Str[Pos] in sep) do begin + Inc(Pos); + end; + I := Pos; + while (Pos<= Len) and not (Str[Pos] in sep) do begin + if IsDBCSLeadByte(Byte(Str[Pos])) then begin + Inc(Pos); end; - - - // ƒXƒLƒ“(ƒtƒbƒ^) - SaveList.Add( boardPlugIn.GetFooter( DWORD( threadItem ), '' ) ); - doc.Write(SaveList.Text); - finally - SaveList.Free; - doc.Close; + Inc(Pos); end; + Result := Copy(Str, I, Pos - I); + while (Pos <= Len) and (Str[Pos] in sep) do begin// ‚±‚ê‚Í‚¨D‚Ý + Inc(Pos); + end; + end; + end; +end; - // Exit; - //end; - end else begin - ShortDayNames[1] := '“ú'; ShortDayNames[2] := 'ŒŽ'; - ShortDayNames[3] := '‰Î'; ShortDayNames[4] := '…'; - ShortDayNames[5] := '–Ø'; ShortDayNames[6] := '‹à'; - ShortDayNames[7] := '“y'; - BBSID := ThreadItem.ParentBoard.BBSID; - NewReceiveNo := ThreadItem.NewReceive; - ReadList := TStringList.Create; - - try - if ThreadItem.IsLogFile then begin - FileName := ThreadItem.GetThreadFileName; - ReadList.LoadFromFile(FileName); - FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG')); - FAbon.Execute(ReadList); // ‚ ‚ځ`‚ñ‚µ‚Ä - FSelectResFilter.Execute(ReadList); //ƒŒƒX‚̃tƒBƒ‹ƒ^ƒŠƒ“ƒO‚ð‚·‚é - if ThreadItem.Title = '' then begin - Res := DivideStrLine(ReadList[0]); - sTitle := Res.FTitle; - end else - sTitle := ThreadItem.Title - end else begin - sTitle := CustomStringReplace(ThreadItem.Title, '—M', ','); - end; - SaveList := TStringList.Create; - //threadURL := CustomStringReplace(ThreadItem.URL, 'l50', ''); - try - doc.open; - doc.charset := 'Shift_JIS'; - - // ƒtƒHƒ“ƒg‚âƒTƒCƒY‚̐ݒè - UserOptionalStyle := SetUserOptionalStyle; - CSSFileName := GetStyleSheetDir + Setting.CSSFileName; - if GikoSys.Setting.UseSkin then begin - // ƒXƒLƒ“Žg—p - // ƒXƒLƒ“‚̐ݒè - try - SkinHeader := LoadSkin( GetSkinHeaderFileName ); - if Length( UserOptionalStyle ) > 0 then - SkinHeader := CustomStringReplace( SkinHeader, '', - ''); - SaveList.Add( SkinHeader ); - except - end; - try - SkinNewRes := LoadSkin( GetSkinNewResFileName ); - except - end; - try - SkinRes := LoadSkin( GetSkinResFileName ); - except - end; - SaveList.Add('

'); - SaveList.Add(''); - - for i := 0 to ReadList.Count - 1 do begin - // 1 ‚Í•K‚¸•\Ž¦ - if i <> 0 then begin - // •\Ž¦”͈͂ðŒÀ’è - case ResRange of - Ord( grrKoko ): - if ThreadItem.Kokomade > (i + 1) then - Continue; - Ord( grrNew ): - if NewReceiveNo > (i + 1) then - Continue; - 10..65535: - if (threadItem.Count - i) > ResRange then - Continue; - end; - end; - - // V’…ƒ}[ƒN - if (NewReceiveNo = i + 1) or ((NewReceiveNo = 0) and (i = 0)) then begin - try - if FileExists( GetSkinNewmarkFileName ) then - SaveList.Add( LoadSkin( GetSkinNewmarkFileName ) ) - else - SaveList.Add( '' ); - except - SaveList.Add( '' ); - end; - end; - if (Trim(ReadList[i]) <> '') then begin - No := IntToStr(i + 1); - - Res := DivideStrLine(ReadList[i]); - Res.FBody := ConvRes(AddAnchorTag(Res.FBody), ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true'); - Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1); - try - if NewReceiveNo <= (i + 1) then - // V’…ƒŒƒX - strTmp := ReplaceRes( SkinNewRes ) - else - // ’ʏí‚̃ŒƒX - strTmp := ReplaceRes( SkinRes ); - - SaveList.Add( strTmp ); - except - end; - end; - - if ThreadItem.Kokomade = (i + 1) then begin - // ‚±‚±‚Ü‚Å“Ç‚ñ‚¾ - try - if FileExists( GetSkinBookmarkFileName ) then - SaveList.Add( LoadSkin( GetSkinBookmarkFileName ) ) - else - SaveList.Add( '' ); - except - SaveList.Add( '' ); - end; - end; - doc.Write(SaveList.Text); - SaveList.Clear; - end; - SaveList.Add(''); - // ƒXƒLƒ“(ƒtƒbƒ^) - try - SaveList.Add( LoadSkin( GetSkinFooterFileName ) ); - except - end; - doc.Write(SaveList.Text); - end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin - //CSSŽg—p - //CSSFileName := GetAppDir + CSS_FILE_NAME; - // SaveList.Add(''); - SaveList.Add(''); - SaveList.Add(''); - SaveList.Add('' + sTitle + ''); - SaveList.Add(''); - if Length( UserOptionalStyle ) > 0 then - SaveList.Add(''); - SaveList.Add(''); - SaveList.Add(''); - SaveList.Add(''); - SaveList.Add('

'); - SaveList.Add('
' + sTitle + '
'); - doc.Write(SaveList.Text); - SaveList.Clear; - //Application.ProcessMessages; - for i := 0 to ReadList.Count - 1 do begin - // 1 ‚Í•K‚¸•\Ž¦ - if i <> 0 then begin - // •\Ž¦”͈͂ðŒÀ’è - case ResRange of - Ord( grrKoko ): - if ThreadItem.Kokomade > (i + 1) then - Continue; - Ord( grrNew ): - if NewReceiveNo > (i + 1) then - Continue; - 10..65535: - if (threadItem.Count - i) > ResRange then - Continue; - end; - end; - - if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin - SaveList.Add('
V’…ƒŒƒX ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '
'); - end; - if (Trim(ReadList[i]) <> '') then begin - No := IntToStr(i + 1); - Res := DivideStrLine(ReadList[i]); - Res.FBody := ConvRes(AddAnchorTag(Res.FBody), ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true'); - Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1); - if Res.FMailTo = '' then - SaveList.Add('' - + '
' + No + ' ' - + '–¼‘OF ' - + '' + Res.FName + ' ' - + '“Še“úF ' - + '' + Res.FDateTime+ '
' - + '
' + Res.FBody + '
') - else if GikoSys.Setting.ShowMail then - SaveList.Add('' - + '
' + No + '' - + ' –¼‘OF ' - + '' - + '' + Res.FName + ' [' + Res.FMailTo + ']' - + ' “Še“úF' - + ' ' + Res.FDateTime+ '
' - + '
' + Res.FBody + '
') - else - SaveList.Add('' - + '
' + No + '' - + ' –¼‘OF ' - + '' - + '' + Res.FName + '' - + ' “Še“úF' - + ' ' + Res.FDateTime+ '
' - + '
' + Res.FBody + '
'); - end; - if ThreadItem.Kokomade = (i + 1) then begin - SaveList.Add('
ƒRƒR‚Ü‚Å“Ç‚ñ‚¾
'); - end; - - doc.Write(SaveList.Text); - SaveList.Clear; - end; - SaveList.Add(''); - //SaveList.Add(''); - SaveList.Add(''); - SaveList.Add(''); - doc.Write(SaveList.Text); - end else begin - //CSS”ñŽg—p - // SaveList.Add(''); - SaveList.Add(''); - SaveList.Add(''); - SaveList.Add('' + sTitle + ''); - SaveList.Add(''); - SaveList.Add(''); - SaveList.Add('' + sTitle + ''); - SaveList.Add('
'); - SaveList.Add('

'); - doc.Write(SaveList.Text); - SaveList.Clear; - //Application.ProcessMessages; - for i := 0 to ReadList.Count - 1 do begin - // 1 ‚Í•K‚¸•\Ž¦ - if i <> 0 then begin - // •\Ž¦”͈͂ðŒÀ’è - case ResRange of - Ord( grrKoko ): - if ThreadItem.Kokomade > (i + 1) then - Continue; - Ord( grrNew ): - if NewReceiveNo > (i + 1) then - Continue; - 10..65535: - if (threadItem.Count - i) > ResRange then - Continue; - end; - end; - - if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin - SaveList.Add('
'); - SaveList.Add(''); - SaveList.Add('
V’…ƒŒƒX ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '
'); - SaveList.Add('
'); - end; - if (Trim(ReadList[i]) <> '') then begin - No := IntToStr(i + 1); - Res := DivideStrLine(ReadList[i]); - Res.FBody := ConvRes(AddAnchorTag(Res.FBody), ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true'); - Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1); - if Res.FMailTo = '' then - SaveList.Add('
' + No + ' –¼‘OF ' + Res.FName + ' “Še“úF ' + Res.FDateTime+ '
' + Res.Fbody + '


') - else if GikoSys.Setting.ShowMail then - SaveList.Add('
' + No + ' –¼‘OF ' + Res.FName + ' [' + Res.FMailTo + '] “Še“úF ' + Res.FDateTime+ '
' + Res.Fbody + '


') - else - SaveList.Add('
' + No + ' –¼‘OF ' + Res.FName + ' “Še“úF ' + Res.FDateTime+ '
' + Res.Fbody + '


'); - end; - if ThreadItem.Kokomade = (i + 1) then begin - SaveList.Add('
'); - SaveList.Add('
ƒRƒR‚Ü‚Å“Ç‚ñ‚¾
'); - SaveList.Add('
'); - end; - doc.Write(SaveList.Text); - SaveList.Clear; - end; - SaveList.Add('
'); - SaveList.Add(''); - SaveList.Add(''); - doc.Write(SaveList.Text); - end; - finally - SaveList.Free; - doc.Close; - end; - finally - ReadList.Free; - end; - end; - end; -end; -procedure TGikoSys.CreateHTML3(var html: TStringList; ThreadItem: TThreadItem; var sTitle: string); -var - i: integer; - No: string; - //bufList : TStringList; - ReadList: TStringList; -// SaveList: TStringList; - CSSFileName: string; - BBSID: string; - FileName: string; - Res: TResRec; - boardPlugIn : TBoardPlugIn; - - UserOptionalStyle: string; - SkinHeader: string; - SkinRes: string; - tmp, tmp1: string; - function LoadSkin( fileName: string ): string; - begin - Result := LoadFromSkin( fileName, ThreadItem, ThreadItem.Size ); - end; - function ReplaceRes( skin: string ): string; - begin - Result := SkinedRes( skin, Res, No ); - end; - -begin - if ThreadItem <> nil then begin - CSSFileName := GetStyleSheetDir + Setting.CSSFileName; - html.Clear; - html.BeginUpdate; - //if ThreadItem.IsBoardPlugInAvailable then begin - if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin - //===== ƒvƒ‰ƒOƒCƒ“‚É‚æ‚é•\Ž¦ - //boardPlugIn := ThreadItem.BoardPlugIn; - boardPlugIn := ThreadItem.ParentBoard.BoardPlugIn; - // ƒtƒHƒ“ƒg‚âƒTƒCƒY‚̐ݒè - UserOptionalStyle := SetUserOptionalStyle; - try - // •¶ŽšƒR[ƒh‚̓vƒ‰ƒOƒCƒ“‚É”C‚¹‚é - // ƒwƒbƒ_ - tmp := boardPlugIn.GetHeader( DWORD( threadItem ), - '' ); - //â‘ÎŽQÆ‚©‚ç‘Š‘ÎŽQÆ‚Ö - if Setting.UseSkin then begin - tmp1 := './' +Setting.CSSFileName; - tmp1 := CustomStringReplace(tmp1, GetConfigDir, ''); - tmp1 := CustomStringReplace(tmp1, '\', '/'); - tmp := CustomStringReplace(tmp, ExtractFilePath(Setting.CSSFileName), tmp1); - end else if Setting.UseCSS then begin - tmp1 := './' + CSSFileName; - tmp1 := CustomStringReplace(tmp1, GetConfigDir, ''); - tmp1 := CustomStringReplace(tmp1, '\', '/'); - tmp := CustomStringReplace(tmp, CSSFileName, tmp1); - end; - html.Append( tmp ); - - for i := 0 to threadItem.Count - 1 do begin - - // ƒŒƒX - html.Append( ConvertResAnchor(boardPlugIn.GetRes( DWORD( threadItem ), i + 1 )) ); - - end; - // ƒXƒLƒ“(ƒtƒbƒ^) - html.Append( boardPlugIn.GetFooter( DWORD( threadItem ), '' ) ); - finally - end; - html.EndUpdate; - //Exit; - end else begin - ShortDayNames[1] := '“ú'; ShortDayNames[2] := 'ŒŽ'; - ShortDayNames[3] := '‰Î'; ShortDayNames[4] := '…'; - ShortDayNames[5] := '–Ø'; ShortDayNames[6] := '‹à'; - ShortDayNames[7] := '“y'; - BBSID := ThreadItem.ParentBoard.BBSID; - ReadList := TStringList.Create; - try - if ThreadItem.IsLogFile then begin - FileName := ThreadItem.GetThreadFileName; - ReadList.LoadFromFile(FileName); - FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG')); - FAbon.Execute(ReadList); // ‚ ‚ځ`‚ñ‚µ‚Ä - FSelectResFilter.Execute(ReadList); //ƒŒƒX‚̃tƒBƒ‹ƒ^ƒŠƒ“ƒO‚ð‚·‚é - Res := DivideStrLine(ReadList[0]); - //Res.FTitle := CustomStringReplace(Res.FTitle, '—M', ','); - sTitle := Res.FTitle; - end else begin - sTitle := CustomStringReplace(ThreadItem.Title, '—M', ','); - end; - try - // ƒtƒHƒ“ƒg‚âƒTƒCƒY‚̐ݒè - UserOptionalStyle := SetUserOptionalStyle; - - if GikoSys.Setting.UseSkin then begin - // ƒXƒLƒ“Žg—p - // ƒXƒLƒ“‚̐ݒè - try - SkinHeader := LoadSkin( GetSkinHeaderFileName ); - if Length( UserOptionalStyle ) > 0 then - SkinHeader := CustomStringReplace( SkinHeader, '', - ''); - //â‘ÎŽQÆ‚©‚ç‘Š‘ÎŽQÆ‚Ö - tmp1 := './' +Setting.CSSFileName; - tmp1 := CustomStringReplace(tmp1, GetConfigDir, ''); - tmp1 := CustomStringReplace(tmp1, '\', '/'); - SkinHeader := CustomStringReplace(SkinHeader, ExtractFilePath(Setting.CSSFileName), tmp1); - html.Append( SkinHeader ); - except - end; - try - SkinRes := LoadSkin( GetSkinResFileName ); - except - end; - html.Append(''); - for i := 0 to ReadList.Count - 1 do begin - if (Trim(ReadList[i]) <> '') then begin - No := IntToStr(i + 1); - - Res := DivideStrLine(ReadList[i]); - Res.FBody := AddAnchorTag(Res.FBody); - Res.FBody := ConvertResAnchor(ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true', true)); - - try - html.Append( ReplaceRes( SkinRes ) ); - except - end; - end; - - end; - html.Append(''); - // ƒXƒLƒ“(ƒtƒbƒ^) - try - html.Append( LoadSkin( GetSkinFooterFileName ) ); - except - end; - end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin - //CSSŽg—p - //CSSFileName := GetAppDir + CSS_FILE_NAME; - html.Append(''); - html.Append(''); - html.Append('' + sTitle + ''); - //â‘ÎŽQÆ‚©‚ç‘Š‘ÎŽQÆ‚Ö - tmp1 := './' + CSSFileName; - tmp1 := CustomStringReplace(tmp1, GetConfigDir, ''); - tmp1 := CustomStringReplace(tmp1, '\', '/'); - - html.Append(''); - if Length( UserOptionalStyle ) > 0 then - html.Append(''); - html.Append(''); - html.Append(''); - html.Append(''); - html.Append('
' + sTitle + '
'); - for i := 0 to ReadList.Count - 1 do begin - if (Trim(ReadList[i]) <> '') then begin - No := IntToStr(i + 1); - Res := DivideStrLine(ReadList[i]); - Res.FBody := AddAnchorTag(Res.FBody); - Res.FBody := ConvertResAnchor(ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true', true)); - if Res.FMailTo = '' then - html.Append('' - + '
' + No + ' ' - + '–¼‘OF ' - + '' + Res.FName + ' ' - + '“Še“úF ' - + '' + Res.FDateTime+ '
' - + '
' + Res.FBody + '
') - else if GikoSys.Setting.ShowMail then - html.Append('' - + '
' + No + '' - + ' –¼‘OF ' - + '' - + '' + Res.FName + ' [' + Res.FMailTo + ']' - + ' “Še“úF' - + ' ' + Res.FDateTime+ '
' - + '
' + Res.FBody + '
') - else - html.Append('' - + '
' + No + '' - + ' –¼‘OF ' - + '' - + '' + Res.FName + '' - + ' “Še“úF' - + ' ' + Res.FDateTime+ '
' - + '
' + Res.FBody + '
'); - end; - end; - html.Append(''); - html.Append(''); - html.Append(''); - end else begin - //CSS”ñŽg—p - html.Append(''); - html.Append(''); - html.Append('' + sTitle + ''); - html.Append(''); - html.Append(''); - html.Append('' + sTitle + ''); - html.Append('
'); - for i := 0 to ReadList.Count - 1 do begin - if (Trim(ReadList[i]) <> '') then begin - No := IntToStr(i + 1); - Res := DivideStrLine(ReadList[i]); - Res.FBody := AddAnchorTag(Res.FBody); - Res.FBody := ConvertResAnchor(ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true', true)); - if Res.FMailTo = '' then - html.Append('
' + No + ' –¼‘OF ' + Res.FName + ' “Še“úF ' + Res.FDateTime+ '
' + Res.Fbody + '


') - else if GikoSys.Setting.ShowMail then - html.Append('
' + No + ' –¼‘OF ' + Res.FName + ' [' + Res.FMailTo + '] “Še“úF ' + Res.FDateTime+ '
' + Res.Fbody + '


') - else - html.Append('
' + No + ' –¼‘OF ' + Res.FName + ' “Še“úF ' + Res.FDateTime+ '
' + Res.Fbody + '


'); - end; - end; - html.Append('
'); - html.Append(''); - html.Append(''); - end; - finally - html.EndUpdate; - end; - finally - ReadList.Free; - end; - end; - end; -end; -function TGikoSys.ConvertResAnchor(res: string): string; -const - _HEAD : string = ''; - _ST: string = '&st='; - _TO: string = '&to='; - _STA: string = '&START='; - _END: string = '&END='; -var - i, j, k: Integer; - tmp: string; -begin - Result := ''; - i := AnsiPos(_HEAD, res); - while i <> 0 do begin - Result := Result + Copy(res, 1, i -1); - Delete(res, 1, i - 1); - j := AnsiPos(_TAIL, res); - if j = 0 then begin - Result := Result + res; - Exit; - end; - tmp := Copy(res, 1, j - 1); - Delete(res, 1, j + 16); - if (AnsiPos(_ST, tmp) <> 0) and (AnsiPos(_TO, tmp) <> 0) then begin - Delete(tmp, 1, AnsiPos(_ST, tmp) + 3); - Delete(tmp, AnsiPos(_TO, tmp), Length(tmp)); - Result := Result + ''; - end else if (AnsiPos(_STA, tmp) <> 0) and (AnsiPos(_END, tmp) <> 0) then begin - Delete(tmp, 1, AnsiPos(_STA, tmp) + 6); - Delete(tmp, AnsiPos(_END, tmp), Length(tmp)); - Result := Result + ''; - end else begin - k := LastDelimiter('/', tmp); - Delete(tmp, 1, k); - if AnsiPos('-', tmp) < AnsiPos('"', tmp) then - Delete(tmp, AnsiPos('-', tmp), Length(tmp)) - else - Delete(tmp, AnsiPos('"', tmp), Length(tmp)); - - Result := Result + ''; - end; - i := AnsiPos(_HEAD, res); - end; - Result := Result + res; - -end; - -(************************************************************************* - *http://‚Ì•¶Žš—ñ‚ðanchorƒ^ƒO•t‚«‚É‚·‚éB - *************************************************************************) -function TGikoSys.AddAnchorTag(s: string): string; -const - URL_CHAR: string = '0123456789' - + 'abcdefghijklmnopqrstuvwxyz' - + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' - + '#$%&()*+,-./:;=?@[]^_`{|}~!''\'; - ANCHOR_REF = 'href='; - RES_REF = '>>'; - REF_MARK: array[0..9] of string = ('http://', 'ttp://', 'tp://', - 'ms-help://','p://', 'https://', - 'www.', 'ftp://','news://','rtsp://'); - -var -// wkIdx: array[0..9] of Integer; - url: string; - href: string; - i, j, b: Integer; - tmp: Integer; - idx, idx2: Integer; - anchorLen : Integer; - pp, pe : PChar; - pURLCHARs : PChar; - pURLCHARe : PChar; -begin - Result := ''; - // + 3 ‚Í 'href="' ('"'‚‚«)‚Ȃǂ̃oƒŠƒG[ƒVƒ‡ƒ“‚É—]—T‚ðŽ‚½‚¹‚邽‚ß - anchorLen := Length( ANCHOR_REF ) + 3; - pURLCHARs := PChar(URL_CHAR); - pURLCHARe := pURLCHARs + Length(URL_CHAR); - while True do begin - idx := MaxInt; - idx2 := MaxInt; - for j := 0 to 9 do begin - tmp := AnsiPos(REF_MARK[j], s); - if tmp <> 0 then idx := Min(tmp, idx); - if idx = tmp then idx2 := j; //‚ǂ̃}[ƒN‚ňø‚Á‚©‚©‚Á‚½‚©‚ð•Û‘¶ - end; - if idx = MaxInt then begin - //ƒŠƒ“ƒN‚ª–³‚¢‚æB - Result := Result + s; - Break; - end; - - if (idx > 1) and - (Pos( ANCHOR_REF, Copy(s, idx - anchorLen, anchorLen ) ) > 0) then begin - //Šù‚ɃŠƒ“ƒNƒ^ƒO‚ª‚‚¢‚Ä‚¢‚é‚Á‚Û‚¢‚Æ‚«‚̓€ƒV - href := Copy( s, idx, Length( s ) ); - Result := Result + Copy( s, 1, idx + Pos( '', href ) + Length( '' ) - 2 ); - s := href; - s := Copy( s, Pos( '', s ) + Length( '' ), Length( s ) ); - - Continue; - end; - - Result := Result + Copy(s, 1, idx - 1); - - Delete(s, 1, idx - 1); - b := Length( s ) + 1; - pp := PChar(s); - for i := 1 to b do begin - pe := AnsiStrPosEx(pURLCHARs, pURLCHARe, pp, pp + 1); - - if pe = nil then begin - //URL‚¶‚á‚È‚¢•¶Žš”­Œ©I‚Æ‚©A•¶Žš‚ª‚È‚­‚È‚Á‚½B - url := Copy(s, 1, i - 1); - case idx2 of - 1 : href := 'h' + url; - 2 : href := 'ht' + url; - 4 : href := 'htt' + url; - 6 : href := 'http://' + url; - else - href := url; - end; - - Result := Result + '' + url + ''; - Delete(s, 1, i - 1); - Break; - end; - //ˆê•¶Žši‚ß‚éB - Inc(pp); - end; - end; -end; - -(************************************************************************* - *ƒTƒuƒWƒFƒNƒgˆês‚𕪊„ - *************************************************************************) -function TGikoSys.DivideSubject(Line: string): TSubjectRec; -var - i: integer; - ws: WideString; - Delim: string; - LeftK: string; - RightK: string; -begin - Result.FCount := 0; - - if AnsiPos('<>', Line) = 0 then - Delim := ',' - else - Delim := '<>'; - Result.FFileName := RemoveToken(Line, Delim); - Result.FTitle := Trim(RemoveToken(Line, Delim)); - - ws := Result.FTitle; - if Copy(ws, Length(ws), 1) = ')' then begin - LeftK := '('; - RightK := ')'; - end else if Copy(ws, Length(ws)-1, 2) = 'j' then begin - LeftK := 'i'; - RightK := 'j'; - end else if Copy(ws, Length(ws), 1) = '>' then begin - LeftK := '<'; - RightK := '>'; - end; - for i := Length(ws) - 1 downto 1 do begin - if Copy(ws, i, Length(LeftK)) = LeftK then begin - Result.FTitle := TrimRight(Copy(ws, 1, i - 1)); - ws := Copy(ws, i + Length(LeftK), Length(ws) - i - Length(RightK)); - if IsNumeric(ws) then - Result.FCount := StrToInt(ws); - //Delete(Result.FTitle, i, Length(LeftK) + Length(ws) + Length(RightK)); - break; - end; - end; -end; - -(************************************************************************* - * datƒtƒ@ƒCƒ‹‚̈ꃉƒCƒ“‚𕪉ð - *************************************************************************) -function TGikoSys.DivideStrLine(Line: string): TResRec; -var - Delim: string; -begin - if AnsiPos('<>', Line) = 0 then begin - //Delim := ','; - //Result.FType := glt2chOld; - Line := CustomStringReplace(Line, '<>', '<>'); - Line := CustomStringReplace(Line, ',', '<>'); - Line := CustomStringReplace(Line, '—M', ','); - end; - Delim := '<>'; - Result.FType := glt2chNew; - //Trim‚µ‚Ä‚Í‚¢‚¯‚È‚¢‹C‚ª‚·‚é@by‚à‚¶‚ã - Result.FName := RemoveToken(Line, Delim); - Result.FMailTo := RemoveToken(Line, Delim); - Result.FDateTime := RemoveToken(Line, Delim); - Result.FBody := RemoveToken(Line, Delim); - //‹ó‚¾‚Æ–â‘肪‹N‚«‚é‚©‚çA‹ó”’‚ðÝ’è‚·‚é - if Result.FBody = '' then begin - Result.FBody := ' '; - end else if ( Result.FBody[1] = ' ' ) then begin - //‚Q‚¿‚á‚ñ‚Ë‚é‚Æ‚©‚¾‚ƁA–{•¶‚̐擪‚É‚P‚”¼Šp‹ó”’‚ª“ü‚Á‚Ä‚¢‚é‚̂ō폜‚·‚é - //‘¼‚ÌŒfŽ¦”‚ŁAƒŒƒXŽ©‘Ì‚Ì‹ó”’‚©‚à‚µ‚ê‚È‚¢‚¯‚Ç‚»‚ê‚Í’ú‚ß‚é - Delete(Result.FBody, 1, 1); - end; - //Result.FTitle := Trim(RemoveToken(Line, Delim)); - Result.FTitle := RemoveToken(Line, Delim); - -end; - -(************************************************************************* - * URL‚©‚çBBSID‚ðŽæ“¾ - *************************************************************************) -function TGikoSys.UrlToID(url: string): string; -var - i: integer; -begin - Result := ''; - url := Trim(url); - - if url = '' then Exit; - try - url := Copy(url, 0, Length(url) - 1); - for i := Length(url) downto 0 do begin - if url[i] = '/' then begin - Result := Copy(url, i + 1, Length(url)); - Break; - end; - end; - except - Result := ''; - end; -end; - -(************************************************************************* - *URL‚©‚çBBSIDˆÈŠO‚Ì•”•ª(http://teri.2ch.net/)‚ðŽæ“¾ - *************************************************************************) -function TGikoSys.UrlToServer(url: string): string; -var - i: integer; - wsURL: WideString; -begin - Result := ''; - wsURL := url; - wsURL := Trim(wsURL); - - if wsURL = '' then exit; - - if Copy(wsURL, Length(wsURL), 1) = '/' then - wsURL := Copy(wsURL, 0, Length(wsURL) - 1); - - for i := Length(wsURL) downto 0 do begin - if wsURL[i] = '/' then begin - Result := Copy(wsURL, 0, i); - break; - end; - end; -end; - -(************************************************************************* - *ƒfƒBƒŒƒNƒgƒŠ‚ª‘¶Ý‚·‚é‚©ƒ`ƒFƒbƒN - *************************************************************************) -function TGikoSys.DirectoryExistsEx(const Name: string): Boolean; -var - Code: Integer; -begin - Code := GetFileAttributes(PChar(Name)); - Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0); -end; - -(************************************************************************* - *ƒfƒBƒŒƒNƒgƒŠì¬i•¡”ŠK‘w‘Ήžj - *************************************************************************) -function TGikoSys.ForceDirectoriesEx(Dir: string): Boolean; -begin - Result := True; - if Length(Dir) = 0 then - raise Exception.Create('ƒtƒHƒ‹ƒ_‚ªì¬o—ˆ‚Ü‚¹‚ñ'); - Dir := ExcludeTrailingPathDelimiter(Dir); - if (Length(Dir) < 3) or DirectoryExistsEx(Dir) - or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem. - Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir); -end; - -(************************************************************************* - *•¶Žš—ñ‚©‚çƒg[ƒNƒ“‚̐؂èo‚µi‰Šúˆ—j - *FDelphi‚©‚ç‚̃pƒNƒŠ - *************************************************************************) -function TGikoSys.StrTokFirst(const s:string; const sep: TStrTokSeparator; var Rec: TStrTokRec): string; -begin - Rec.Str := s; - Rec.Pos := 1; - Result := StrTokNext(sep, Rec); -end; - -(************************************************************************* - *•¶Žš—ñ‚©‚çƒg[ƒNƒ“‚̐؂èo‚µ - *FDelphi‚©‚ç‚̃pƒNƒŠ - *************************************************************************) -function TGikoSys.StrTokNext(const sep: TStrTokSeparator; var Rec: TStrTokRec): string; -var - Len, I: Integer; -begin - with Rec do begin - Len := Length(Str); - Result := ''; - if Len >= Pos then begin - while (Pos <= Len) and (Str[Pos] in sep) do begin - Inc(Pos); - end; - I := Pos; - while (Pos<= Len) and not (Str[Pos] in sep) do begin - if IsDBCSLeadByte(Byte(Str[Pos])) then begin - Inc(Pos); - end; - Inc(Pos); - end; - Result := Copy(Str, I, Pos - I); - while (Pos <= Len) and (Str[Pos] in sep) do begin// ‚±‚ê‚Í‚¨D‚Ý - Inc(Pos); - end; - end; - end; -end; - -(************************************************************************* - *ƒtƒ@ƒCƒ‹ƒTƒCƒYŽæ“¾ - *************************************************************************) +{! +\brief ƒtƒ@ƒCƒ‹ƒTƒCƒYŽæ“¾ +\param FileName ƒtƒ@ƒCƒ‹ƒTƒCƒY‚ðŽæ“¾‚·‚éƒtƒ@ƒCƒ‹ƒpƒX +\return ƒtƒ@ƒCƒ‹ƒTƒCƒY(bytes) +} function TGikoSys.GetFileSize(FileName : string): longint; var F : File; @@ -2121,9 +1295,12 @@ begin end; end; -(************************************************************************* - *ƒtƒ@ƒCƒ‹s”Žæ“¾ - *************************************************************************) +{! +\brief ƒeƒLƒXƒgƒtƒ@ƒCƒ‹‚̍s”‚ðŽæ“¾ +\param FileName s”‚ðŽæ“¾‚·‚éƒtƒ@ƒCƒ‹ƒpƒX +\return s” +\todo ƒƒ‚ƒŠƒ}ƒbƒvƒhƒtƒ@ƒCƒ‹s‚« +} function TGikoSys.GetFileLineCount(FileName : string): longint; var sl: TStringList; @@ -2142,9 +1319,13 @@ begin end; -(************************************************************************* - *ƒXƒŒƒbƒhƒtƒ@ƒCƒ‹‚©‚çŽw’ès‚ðŽæ“¾ - *************************************************************************) +{! +\brief ƒtƒ@ƒCƒ‹‚©‚çŽw’ès‚ðŽæ“¾ +\param FileName ƒtƒ@ƒCƒ‹‚̃pƒX +\param Line Žw’ès +\return Žw’肳‚ꂽ 1 s +\todo ƒƒ‚ƒŠƒ}ƒbƒvƒhƒtƒ@ƒCƒ‹s‚« +} function TGikoSys.ReadThreadFile(FileName: string; Line: Integer): string; var fileTmp : TStringList; @@ -2167,33 +1348,36 @@ begin end; end; -(************************************************************************* - *ƒVƒXƒeƒ€ƒƒjƒ…[ƒtƒHƒ“ƒg‚Ì‘®«‚ðŽæ“¾ - *************************************************************************) +{! +\brief ƒVƒXƒeƒ€ƒƒjƒ…[ƒtƒHƒ“ƒg‚Ì‘®«‚ðŽæ“¾ +\param Font OUT:Žæ“¾‚µ‚½ƒtƒHƒ“ƒg‘®«‚ª•Ô‚é +} procedure TGikoSys.MenuFont(Font: TFont); var lf: LOGFONT; nm: NONCLIENTMETRICS; begin nm.cbSize := sizeof(NONCLIENTMETRICS); - - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0); - lf := nm.lfMenuFont; - - Font.Name := lf.lfFaceName; - Font.Height := lf.lfHeight; - Font.Style := []; - if lf.lfWeight >= 700 then - Font.Style := Font.Style + [fsBold]; - if lf.lfItalic = 1 then - Font.Style := Font.Style + [fsItalic]; -end; - -(************************************************************************* - * - *‚Ç‚±‚©‚̃TƒCƒg‚©‚ç‚̃pƒNƒŠ - *************************************************************************) -function TGikoSys.RemoveToken(var s: string;const delimiter: string): string; + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @nm, 0); + lf := nm.lfMenuFont; + Font.Name := lf.lfFaceName; + Font.Height := lf.lfHeight; + Font.Style := []; + if lf.lfWeight >= 700 then + Font.Style := Font.Style + [fsBold]; + if lf.lfItalic = 1 then + Font.Style := Font.Style + [fsItalic]; +end; + +{! +\brief æ“ª‚̃g[ƒNƒ“‚ðØ‚èo‚µ +\param s IN/OUT:Œ³‚ɂȂ镶Žš—ñAØ‚èo‚µ‚½Œã‚ÌŽc‚è‚Ì•¶Žš—ñ +\param delimiter ‹æØ‚è‚ɂȂ镶Žš—ñ +\return Ø‚èo‚µ‚½•¶Žš—ñ + +‚Ç‚±‚©‚̃TƒCƒg‚©‚ç‚̃pƒNƒŠ +} +{function TGikoSys.RemoveToken(var s: string;const delimiter: string): string; var p: Integer; begin @@ -2204,51 +1388,25 @@ begin Result := Copy(s, 1, p - 1); Delete(s, 1, Length(Result) + Length(delimiter)); end; +} + +{! +\brief n ŒÂ–ڂ̃g[ƒNƒ“‚ðØ‚èo‚µ +\param s Œ³‚ɂȂ镶Žš—ñ +\param index 0 ‚©‚çŽn‚Ü‚éƒCƒ“ƒfƒbƒNƒX(n ŒÂ–Ú‚Ì n) +\return Ø‚èo‚µ‚½ƒg[ƒNƒ“ -(************************************************************************* - * - *‚Ç‚±‚©‚̃TƒCƒg‚©‚ç‚̃pƒNƒŠ - *************************************************************************) +‚Ç‚±‚©‚̃TƒCƒg‚©‚ç‚̃pƒNƒŠ +} function TGikoSys.GetTokenIndex(s: string; delimiter: string; index: Integer): string; var i: Integer; begin Result := ''; for i := 0 to index do - Result := RemoveToken(s, delimiter); + Result := MojuUtils.RemoveToken(s, delimiter); end; -(************************************************************************* - * - *************************************************************************) -function TGikoSys.DeleteLink(const s: string): string; -var - s1: string; - s2: string; - idx: Integer; - i: Integer; -begin - i := 0; - Result := ''; - while True do begin - s1 := GetTokenIndex(s, '', s1); - if idx <> 0 then - Delete(s1, 1, idx + 1); - idx := Pos('">', s2); - if idx <> 0 then - Delete(s2, 1, idx + 1); - - Result := Result + s1 + s2; - - if s2 = '' then - Break; - - inc(i, 2); - end; -end; //ƒCƒ“ƒfƒbƒNƒX–¢XVƒoƒbƒtƒ@‚ðƒtƒ‰ƒbƒVƒ…I {procedure TGikoSys.FlashExitWrite; @@ -2261,10 +1419,14 @@ begin FExitWrite.Clear; end;} -(************************************************************************* - *ƒXƒŒ–¼‚È‚Ç‚ð’Z‚¢–¼‘O‚É•ÏŠ·‚·‚é - *from HotZonu - *************************************************************************) +{! +\brief ƒXƒŒ–¼‚È‚Ç‚ð’Z‚¢–¼‘O‚É•ÏŠ·‚·‚é +\param LongName Œ³‚ɂȂ镶Žš—ñ +\param ALength Žû‚߂镶Žš—ñ’·(bytes) +\return •ÏŠ·‚³‚ꂽ•¶Žš—ñ + +from HotZonu +} function TGikoSys.GetShortName(const LongName: string; ALength: integer): string; const ERASECHAR : array [1..39] of string = @@ -2310,404 +1472,32 @@ begin end; end; -(************************************************************************* - * - * from HotZonu - *************************************************************************) -function TGikoSys.ConvRes(const Body, Bbs, Key, - ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string; - DatToHTML: boolean = false): string; -type - PIndex = ^TIndex; - TIndex = record - FIndexFrom : integer; - FIndexTo : integer; - FNo : string; - end; -const - GT = '>'; - SN = '0123456789-'; - ZN = '‚O‚P‚Q‚R‚S‚T‚U‚V‚W‚X|'; -var - i : integer; - s,r : string; - b : TMbcsByteType; - sw: boolean; - sp: integer; - No: string; - sx: string; - List: TList; - oc : string; - st, et: string; - chk : boolean; - al : boolean; - procedure Add(IndexFrom, IndexTo: integer; const No: string); - var - FIndex : PIndex; - begin - New(FIndex); - FIndex.FIndexFrom := IndexFrom; - FIndex.FIndexTo := IndexTo; - FIndex.FNo := No; - List.Add(FIndex); - end; - function ChooseString(const Text, Separator: string; Index: integer): string; - var - S : string; - i, p : integer; - begin - S := Text; - for i := 0 to Index - 1 do begin - if (AnsiPos(Separator, S) = 0) then S := '' - else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S)); - end; - p := AnsiPos(Separator, S); - if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S; - end; -begin - { v1.0 b2 - 03 } - s := Body; - r := Body; - i := 1; - sw := False; - No := ''; - List:= TList.Create; - oc := ''; - sp := 0; - chk := False; - al := False; - while true do begin - b := ByteType(s, i); - case b of - mbSingleByte : begin - if (not sw) and (Copy(s,i,8) = GT + GT) then begin - if (AnsiPos(' 0) then begin - No := No + sx; - end else begin - if (No <> '') and (No <> '-') then begin - Add(sp, i, No); - al := True; - end; - sw := False; - // - i := i - 1; - // - No := ''; - oc:=''; - //chk := False; - end; - end else begin - if Copy(s,i,1) = '<' then oc := ''; - oc := oc + Copy(s,i,1); - chk := False; - al := False; - end; - end; - mbLeadByte : begin - if (not sw) and (Copy(s,i,4) = '„„') then begin - sw := True; - sp := i; - i := i + 3; - chk := True; - end else - if (not sw) and (Copy(s,i,2) = '„') then begin - sw := True; - sp := i; - i := i + 1; - chk := True; - end else - if (sw) then begin - sx := Copy(s,i,2); - if (AnsiPos(sx, ZN) > 0) then begin - No := No + ZenToHan(sx); - end else begin - if (No <> '') and (No <> '-') and (No <> '|') then begin - Add(sp, i, No); - end; - sw := False; - i := i - 1; - No := ''; - end; - end else begin - oc := ''; - chk := False; - end; - al := False; - end; - end; - inc(i); - if (i > Length(Body)) then begin - if (sw) then begin - if (No <> '') then Add(sp, i, No); - end; - Break; - end; - end; - for i := List.Count - 1 downto 0 do begin - if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin - st := ChooseString(PIndex(List[i]).FNo, '-', 0); - et := ChooseString(PIndex(List[i]).FNo, '-', 1); - end else begin - st := PIndex(List[i]).FNo; - et := PIndex(List[i]).FNo; - end; - if not DatToHTML then - r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) + - Format('', - [ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) + - Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '' + - Copy(r,PIndex(List[i]).FIndexTo,Length(r)) - else - r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) + - Format('', [st]) + - Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '' + - Copy(r,PIndex(List[i]).FIndexTo,Length(r)); - - Dispose(PIndex(List[i])); - end; - List.Free; - Result := r; -end; - -function TGikoSys.ConvRes( - const Body, Bbs, Key, ParamBBS, ParamKey, - ParamStart, ParamTo, ParamNoFirst, - ParamTrue, FullURL : string -): string; -type - PIndex = ^TIndex; - TIndex = record - FIndexFrom : integer; - FIndexTo : integer; - FNo : string; - end; -const - GT = '>'; - SN = '0123456789-'; - ZN = '‚O‚P‚Q‚R‚S‚T‚U‚V‚W‚X|'; -var - i : integer; - s,r : string; - b : TMbcsByteType; - sw: boolean; - sp: integer; - No: string; - sx: string; - List: TList; - oc : string; - st, et: string; - chk : boolean; - al : boolean; - procedure Add(IndexFrom, IndexTo: integer; const No: string); - var - FIndex : PIndex; - begin - New(FIndex); - FIndex.FIndexFrom := IndexFrom; - FIndex.FIndexTo := IndexTo; - FIndex.FNo := No; - List.Add(FIndex); - end; - function ChooseString(const Text, Separator: string; Index: integer): string; - var - S : string; - i, p : integer; - begin - S := Text; - for i := 0 to Index - 1 do begin - if (AnsiPos(Separator, S) = 0) then S := '' - else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S)); - end; - p := AnsiPos(Separator, S); - if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S; - end; -begin - { v1.0 b2 - 03 } - s := Body; - r := Body; - i := 1; - sw := False; - No := ''; - List:= TList.Create; - oc := ''; - sp := 0; - chk := False; - al := False; - while true do begin - b := ByteType(s, i); - case b of - mbSingleByte : begin - if (not sw) and (Copy(s,i,8) = GT + GT) then begin - if (AnsiPos(' 0) then begin - No := No + sx; - end else begin - if (No <> '') and (No <> '-') then begin - Add(sp, i, No); - al := True; - end; - sw := False; - // - i := i - 1; - // - No := ''; - oc:=''; - //chk := False; - end; - end else begin - if Copy(s,i,1) = '<' then oc := ''; - oc := oc + Copy(s,i,1); - chk := False; - al := False; - end; - end; - mbLeadByte : begin - if (not sw) and (Copy(s,i,4) = '„„') then begin - sw := True; - sp := i; - i := i + 3; - chk := True; - end else - if (not sw) and (Copy(s,i,2) = '„') then begin - sw := True; - sp := i; - i := i + 1; - chk := True; - end else - if (sw) then begin - sx := Copy(s,i,2); - if (AnsiPos(sx, ZN) > 0) then begin - No := No + ZenToHan(sx); - end else begin - if (No <> '') and (No <> '-') and (No <> '|') then begin - Add(sp, i, No); - end; - sw := False; - i := i - 1; - No := ''; - end; - end else begin - oc := ''; - chk := False; - end; - al := False; - end; - end; - inc(i); - if (i > Length(Body)) then begin - if (sw) then begin - if (No <> '') then Add(sp, i, No); - end; - Break; - end; - end; - for i := List.Count - 1 downto 0 do begin - //plName := Copy(PluginName, LastDelimiter('\',PluginName) + 1, Length(PluginName) - LastDelimiter('/',PluginName) -1 ); - if (AnsiPos('-', PIndex(List[i]).FNo) > 0) then begin - st := ChooseString(PIndex(List[i]).FNo, '-', 0); - et := ChooseString(PIndex(List[i]).FNo, '-', 1); - end else begin - st := PIndex(List[i]).FNo; - et := PIndex(List[i]).FNo; - end; - r := Copy(r,0, PIndex(List[i]).FIndexFrom - 1) + - Format('', - [FullURL, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) + - Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '' + - Copy(r,PIndex(List[i]).FIndexTo,Length(r)); - Dispose(PIndex(List[i])); - end; - List.Free; - Result := r; -end; - - +{! +\brief Boolean ‚ð Integer ‚É•ÏŠ· +\return False..0, True..1 +} function TGikoSys.BoolToInt(b: Boolean): Integer; begin Result := IfThen(b, 1, 0); end; +{! +\brief Integer ‚ð Boolean ‚É•ÏŠ· +\return 1..True, other..False +\todo 0..False, other..True ‚Ì•û‚ª‚¢‚¢‚Ì‚Å‚Í? + (‚±‚ÌŽd—l‚Ɉˑ¶‚µ‚Ä‚¢‚é‚©‚à‚µ‚ê‚È‚¢‚Ì‚Å–¢C³) +} function TGikoSys.IntToBool(i: Integer): Boolean; begin Result := i = 1; end; -//gzip‚ň³k‚³‚ꂽ‚Ì‚ð–ß‚· +{! +\brief gzip‚ň³k‚³‚ꂽ‚Ì‚ð–ß‚· +\param ResStream “ǂݍž‚ÞƒXƒgƒŠ[ƒ€ +\param ContentEncoding ƒGƒ“ƒR[ƒfƒBƒ“ƒO +\return “WŠJ‚³‚ꂽ•¶Žš—ñ +} function TGikoSys.GzipDecompress(ResStream: TStream; ContentEncoding: string): string; const BUF_SIZE = 4096; @@ -2717,7 +1507,7 @@ var buf: array[0..BUF_SIZE - 1] of Byte; cnt: Integer; s: string; - i: Integer; + i, ln: Integer; begin Result := ''; TextStream := TStringStream.Create(''); @@ -2750,22 +1540,29 @@ begin //NULL•¶Žš‚ð"*"‚É‚·‚é s := TextStream.DataString; i := Length(s); + ln := i; while (i > 0) and (s[i] = #0) do Dec(i); - s := Copy(s, 1, i); + Delete(s, i + 1, ln - i); i := Pos(#0, s); while i <> 0 do begin s[i] := '*'; i := Pos(#0, s); end; + Result := s; finally TextStream.Free; end; end; -procedure TGikoSys.LoadKeySetting(ActionList: TActionList); +{! +\brief ƒAƒNƒVƒ‡ƒ“‚ɃVƒ‡[ƒgƒJƒbƒgƒL[‚ðÝ’è +\param ActionList Ý’è‚·‚éƒAƒNƒVƒ‡ƒ“ˆê—— +\param FileName Iniƒtƒ@ƒCƒ‹‚Ì–¼‘O +} +procedure TGikoSys.LoadKeySetting(ActionList: TActionList; FileName: String); const STD_SEC = 'KeySetting'; var @@ -2776,10 +1573,10 @@ var SecList: TStringList; Component: TComponent; begin - if not FileExists(GetConfigDir + KEY_SETTING_FILE_NAME) then + if not FileExists(fileName) then Exit; SecList := TStringList.Create; - ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME); + ini := TMemIniFile.Create(fileName); try ini.ReadSection(STD_SEC, SecList); for i := 0 to SecList.Count - 1 do begin @@ -2798,67 +1595,21 @@ begin end; end; -procedure TGikoSys.SaveKeySetting(ActionList: TActionList); -const - STD_SEC = 'KeySetting'; -var - i: Integer; - ini: TMemIniFile; -begin - ini := TMemIniFile.Create(GetConfigDir + KEY_SETTING_FILE_NAME); - try - for i := 0 to ActionList.ActionCount - 1 do begin - if ActionList.Actions[i].Tag = -1 then - Continue; - ini.WriteInteger(STD_SEC, ActionList.Actions[i].Name, TAction(ActionList.Actions[i]).ShortCut); - end; - ini.UpdateFile; - finally - ini.Free; - end; -end; +{! +\brief ƒAƒNƒVƒ‡ƒ“‚ɐݒ肳‚ê‚Ä‚¢‚éƒVƒ‡[ƒgƒJƒbƒgƒL[‚ðƒtƒ@ƒCƒ‹‚É•Û‘¶ +\param ActionList •Û‘¶‚·‚éƒAƒNƒVƒ‡ƒ“ˆê—— +\param FileName Iniƒtƒ@ƒCƒ‹–¼ -procedure TGikoSys.LoadEditorKeySetting(ActionList: TActionList); +ActionList ‚ɐݒ肳‚ê‚Ä‚¢‚éƒVƒ‡[ƒgƒJƒbƒgƒL[‚ð FileName ‚É•Û‘¶‚µ‚Ü‚·B +} +procedure TGikoSys.SaveKeySetting(ActionList: TActionList; FileName: String); const STD_SEC = 'KeySetting'; var i: Integer; ini: TMemIniFile; - ActionName: string; - ActionKey: Integer; - SecList: TStringList; - Component: TComponent; begin - if not FileExists(GetConfigDir + EKEY_SETTING_FILE_NAME) then - Exit; - SecList := TStringList.Create; - ini := TMemIniFile.Create(GetConfigDir + EKEY_SETTING_FILE_NAME); - try - ini.ReadSection(STD_SEC, SecList); - for i := 0 to SecList.Count - 1 do begin - ActionName := SecList[i]; - ActionKey := ini.ReadInteger(STD_SEC, ActionName, -1); - if ActionKey <> -1 then begin - Component := ActionList.Owner.FindComponent(ActionName); - if TObject(Component) is TAction then begin - TAction(Component).ShortCut := ActionKey; - end; - end; - end; - finally - ini.Free; - SecList.Free; - end; -end; - -procedure TGikoSys.SaveEditorKeySetting(ActionList: TActionList); -const - STD_SEC = 'KeySetting'; -var - i: Integer; - ini: TMemIniFile; -begin - ini := TMemIniFile.Create(GetConfigDir + EKEY_SETTING_FILE_NAME); + ini := TMemIniFile.Create(GetConfigDir + FileName); try for i := 0 to ActionList.ActionCount - 1 do begin if ActionList.Actions[i].Tag = -1 then @@ -2871,7 +1622,12 @@ begin end; end; -// + +{! +\brief ƒvƒƒZƒX‚̐¶¬ +\param AppPath ‹N“®‚·‚éƒvƒƒZƒX‚̃tƒ@ƒCƒ‹ƒpƒX +\param Param AppPath ‚É“n‚·ˆø” +} procedure TGikoSys.CreateProcess(const AppPath: string; const Param: string); var PI: TProcessInformation; @@ -2890,7 +1646,7 @@ begin SI.cbReserved2 := 0; SI.lpReserved2 := nil; SI.dwysize := 0; - Windows.CreateProcess(nil, + if Windows.CreateProcess(nil, PChar(Path), nil, nil, @@ -2899,22 +1655,67 @@ begin nil, nil, SI, - PI); + PI) then + begin + CloseHandle(PI.hProcess); + end; + end; +{! +\brief Web ƒuƒ‰ƒEƒU‚ð‹N“® +\param URL Web ƒuƒ‰ƒEƒU‚Å•\Ž¦‚·‚é URL +\param BrowserType ƒuƒ‰ƒEƒU‚̃^ƒCƒv(IE ‚©‚Ç‚¤‚©) +} procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType); +var + i, j : Integer; + path, arg : String; + params : TStringList; begin case BrowserType of gbtIE: HlinkNavigateString(nil, PWideChar(WideString(URL))); gbtUserApp, gbtAuto: - if (Setting.URLApp) and (FileExists(Setting.URLAppFile)) then - GikoSys.CreateProcess(Setting.URLAppFile, URL) - else + if (Setting.URLApp) then begin + if (FileExists(Setting.URLAppFile)) then begin + GikoSys.CreateProcess(Setting.URLAppFile, URL) + end else begin + // ‹N“®ƒpƒ‰ƒ[ƒ^•t‚«‘΍ô + path := ''; + params := TStringList.Create; + try + params.Delimiter := ' '; + params.DelimitedText := Setting.URLAppFile; + for i := 0 to params.Count - 1 do begin + path := TrimLeft(path + ' ' + params[i]); + if (FileExists(path)) then begin + arg := ''; + for j := i + 1 to params.Count - 1 do begin + arg := arg + ' ' + params[j]; + end; + break; + end; + end; + if i < params.Count then begin + GikoSys.CreateProcess(path, arg + ' ' + URL); + end else begin + HlinkNavigateString(nil, PWideChar(WideString(URL))); + end; + finally + params.Free; + end; + end; + end else HlinkNavigateString(nil, PWideChar(WideString(URL))); end; end; +{! +\brief •¶ŽšŽÀ‘ÌŽQÆ‚ðƒfƒR[ƒh +\param AStr ƒfƒR[ƒh‚·‚镶Žš—ñ +\return ƒfƒR[ƒh‚³‚ꂽ•¶Žš—ñ +} function TGikoSys.HTMLDecode(const AStr: String): String; var Sp, Rp, Cp, Tp: PChar; @@ -2987,6 +1788,11 @@ begin SetLength(Result, Rp - PChar(Result)); end; +{! +\brief HTML ‚̃Aƒ“ƒJ[ƒ^ƒO‚©‚ç URL ‚ðŽæ“¾ +\param s URL ‚ðŽæ“¾‚·‚é HTML +\return Žæ“¾‚µ‚½ URL +} function TGikoSys.GetHRefText(s: string): string; var Index: Integer; @@ -3030,7 +1836,11 @@ begin Result := Trim(s); end; -//ƒzƒXƒg–¼‚ª‚Q‚ƒ‚ˆ‚©‚Ç‚¤‚©ƒ`ƒFƒbƒN‚·‚é +{! +\brief ƒzƒXƒg–¼‚ª‚Q‚ƒ‚ˆ‚©‚Ç‚¤‚©ƒ`ƒFƒbƒN‚·‚é +\param Host ƒ`ƒFƒbƒN‚·‚éƒzƒXƒg–¼ +\return 2‚¿‚á‚ñ‚Ë‚é‚̃zƒXƒg–¼‚È‚ç True +} function TGikoSys.Is2chHost(Host: string): Boolean; const HOST_NAME: array[0..1] of string = ('2ch.net', 'bbspink.com'); @@ -3052,6 +1862,15 @@ begin end; end; +{! +\brief 2‚¿‚á‚ñ‚Ë‚éŒ`Ž®‚Ì URL ‚𕪉ð +\param url 2‚¿‚á‚ñ‚Ë‚éŒ`Ž®‚Ì URL +\param path test/read.cgi ‚È‚Ç‚Ì’†ŠÔƒpƒX(ParseURI ‚©‚瓾‚é) +\param document index.html ‚Ȃǂ̃hƒLƒ…ƒƒ“ƒg–¼(ParseURI ‚©‚瓾‚é) +\param BBSID OUT:BBSID ‚ª•Ô‚é(ex. giko) +\param BBSKey OUT:ƒXƒŒƒbƒhƒL[‚ª•Ô‚é(ex. 10000000000) +\return 2‚¿‚á‚ñ‚Ë‚é‚Ì URL ‚Æ‚µ‚Ä•ª‰ð‚Å‚«‚½‚È‚ç True +} function TGikoSys.Parse2chURL(const url: string; const path: string; const document: string; var BBSID: string; var BBSKey: string): Boolean; var Index: Integer; @@ -3065,7 +1884,13 @@ begin Index := AnsiPos(READ_PATH, path); if Index <> 0 then begin s := Copy(path, Index + Length(READ_PATH), Length(path)); - + end else begin + Index := AnsiPos(HTML_READ_PATH, path); + if Index <> 0 then begin + s := Copy(path, Index + Length(HTML_READ_PATH), Length(path)); + end; + end; + if Index <> 0 then begin if (Length(s) > 0) and (s[1] = '/') then Delete(s, 1, 1); BBSID := GetTokenIndex(s, '/', 0); @@ -3104,102 +1929,116 @@ begin end; end; end; + +{! +\brief 2ch Œ`Ž®‚Ì URL ‚©‚烌ƒX”Ô‚ðŽæ“¾ +\param URL 2‚¿‚á‚ñ‚Ë‚éŒ`Ž®‚Ì URL +\param stRes OUT:ŠJŽnƒŒƒX”Ô‚ª•Ô‚é +\param endRes OUT:I—¹ƒŒƒX”Ô‚ª•Ô‚é + +http://2ch.net/’†—ª/32-50 \n +‚̏ꍇ stRef = 32, endRes = 50 ‚É‚È‚é +} procedure TGikoSys.GetPopupResNumber(URL : string; var stRes, endRes : Int64); +const + START_NAME : array[0..1] of String = ('st=', 'start='); + END_NAME : array[0..1] of String = ('to=', 'end='); + RES_NAME : array[0..0] of String = ('res='); var buf : String; convBuf : String; ps : Int64; pch : PChar; + bufList : TStringList; + i, j, idx : Integer; begin URL := Trim(LowerCase(URL)); - if (AnsiPos('&st=', URL ) <> 0) and ( AnsiPos( '&to=',URL) <> 0 ) then begin - stRes := 0; - endRes := 0; - try - buf := Copy( URL, AnsiPos('&st=', URL ) + 4, AnsiPos( '&to=',URL) - AnsiPos('&st=', URL ) - 4 ); - if buf <> '' then - stRes := StrToInt64( buf ); - if AnsiPos( '&nofirst=',URL) <> 0 then begin - buf := Copy( URL, AnsiPos('&to=', URL ) + 4, AnsiPos( '&nofirst=',URL) - AnsiPos('&to=', URL ) - 4); - end else begin - buf := Copy( URL, AnsiPos('&to=', URL ) + 4, Length( URL ) - AnsiPos('&to=', URL ) - 4 + 1 ); - ps := 0; - pch := PChar(buf); - while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps); - buf := Copy( buf, 1, ps ); - end; - try - if buf <> '' then - endRes := StrToInt64(buf) - except - endRes := 0; - end; - except - stRes := 0; - end; - if (stRes <> 0) and (endRes = 0) then - endRes := stRes + MAX_POPUP_RES - else if (stRes = 0) and (endRes <> 0) then begin - stRes := endRes - MAX_POPUP_RES; - if stRes < 1 then - stRes := 1; - end; - GikoSys.GetBrowsableThreadURL( URL ); - end else if( AnsiPos('&res=', URL ) <> 0 ) then begin - endRes := 0; - buf := Copy( URL, AnsiPos('&res=', URL ) + 5, Length( URL ) - AnsiPos('&res=', URL ) - 5 + 1 ); - ps := 0; - pch := PChar(buf); - while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps); - buf := Copy( buf, 1, ps ); - try - if buf <> '' then - stRes := StrToInt(buf) - else begin - stRes := 0; - end; - except - stRes := 0; - end; - end else if (AnsiPos('&start=', URL ) <> 0) and ( AnsiPos( '&end=',URL) <> 0 ) then begin - try - stRes := StrToInt64( Copy( URL, AnsiPos('&start=', URL ) + 7, AnsiPos( '&end=',URL) - AnsiPos('&start=', URL ) - 7 ) ); - if AnsiPos( '&nofirst=',URL) <> 0 then begin - buf := Copy( URL, AnsiPos('&end=', URL ) + 5, AnsiPos( '&nofirst=',URL) - AnsiPos('&end=', URL ) - 5); - end else begin - buf := Copy( URL, AnsiPos('&end=', URL ) + 5, Length( URL ) - AnsiPos('&to=', URL ) - 5 + 1 ); - ps := 0; - pch := PChar(buf); - while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps); - buf := Copy( buf, 1, ps ); - end; - try - if buf <> '' then - endRes := StrToInt64(buf); - except - endRes := 0; - end; - except - stRes := 0; - end; - end else if ( AnsiPos('.html',URL) <> Length(URL) -4 ) and ( AnsiPos('.htm',URL) <> Length(URL) -3 ) then begin + for i := 0 to Length(START_NAME) -1 do begin + idx := AnsiPos(START_NAME[i], URL); + if (idx <> 0) then begin + break; + end; + idx := AnsiPos(END_NAME[i], URL); + if (idx <> 0) then begin + break; + end; + + end; + + if (idx <> 0) then begin + idx := AnsiPos('?', URL); + if (idx = 0) then begin + idx := LastDelimiter('/', URL); + end; + stRes := 0; + endRes := 0; + bufList := TStringList.Create(); + try + bufList.Delimiter := '&'; + bufList.DelimitedText := Copy(URL, idx + 1, Length(URL)); + for i := 0 to bufList.Count - 1 do begin + convBuf := ''; + // ŠJŽnƒŒƒX”Ô‚ÌŒŸõ + if (stRes = 0) then begin + for j := 0 to Length(START_NAME) - 1 do begin + idx := AnsiPos(START_NAME[j], bufList[i]); + if (idx = 1) then begin + convBuf := Copy(bufList[i], idx + Length(START_NAME[j]), Length(bufList[i])); + stRes := StrToInt64Def( convBuf, 0 ); + break; + end; + end; + end; + // I—¹ƒŒƒX”Ô‚ÌŒŸõ + if (convBuf = '') and (endRes = 0) then begin + for j := 0 to Length(END_NAME) - 1 do begin + idx := AnsiPos(END_NAME[j], bufList[i]); + if (idx = 1) then begin + convBuf := Copy(bufList[i], idx + Length(END_NAME[j]), Length(bufList[i])); + endRes := StrToInt64Def( convBuf, 0 ); + break; + end; + end; + end; + // ƒŒƒX”Ô‚ÌŒŸõ + if ((stRes = 0) and (endRes = 0) and (convBuf = '')) then begin + for j := 0 to Length(RES_NAME) - 1 do begin + idx := AnsiPos(RES_NAME[j], bufList[i]); + if (idx = 1) then begin + convBuf := Copy(bufList[i], idx + Length(RES_NAME[j]), Length(bufList[i])); + stRes := StrToInt64Def( convBuf, 0 ); + endRes := stRes; + break; + end; + end; + end; + end; + + if (stRes <> 0) and (endRes = 0) then begin + endRes := stRes + MAX_POPUP_RES; + end else if (stRes = 0) and (endRes <> 0) then begin + stRes := endRes - MAX_POPUP_RES; + if stRes < 1 then begin + stRes := 1; + end; + end; + finally + bufList.clear; + bufList.free; + end; + end else if ( AnsiPos('.html',URL) <> Length(URL) -4 ) and ( AnsiPos('.htm',URL) <> Length(URL) -3 ) then begin buf := Copy(URL, LastDelimiter('/',URL)+1,Length(URL)-LastDelimiter('/',URL)+1); if Length(buf) > 0 then begin if AnsiPos('-', buf) = 1 then begin stRes := 0; - Delete(buf,1,1); - ps := 0; - pch := PChar(buf); - while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps); - try - convBuf := Copy( buf, 1, ps ); - if convBuf <> '' then - endRes := StrToInt64(convBuf) - else - endRes := 0; - except - endRes := 0; - end; + Delete(buf,1,1); + ps := 0; + pch := PChar(buf); + while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps); + convBuf := Copy( buf, 1, ps ); + if convBuf <> '' then begin + endRes := StrToInt64Def(convBuf, 0); + end; if endRes <> 0 then begin stRes := endRes - MAX_POPUP_RES; if stRes < 1 then @@ -3217,15 +2056,10 @@ begin ps := 0; pch := PChar(buf); while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps); - try - convBuf := Copy( buf, 1, ps ); - if convBuf <> '' then - endRes := StrToInt64(convBuf) - else - endRes := 0; - except - endRes := 0; - end; + convBuf := Copy( buf, 1, ps ); + if convBuf <> '' then begin + endRes := StrToInt64Def(convBuf, 0); + end; end else begin stRes := 0; end; @@ -3235,12 +2069,14 @@ begin end; end; end; - end else begin - //stRes := 0; - //endRes := 0; end; end; +{! +\brief 2‚¿‚á‚ñ‚Ë‚éŒ`Ž®‚Ì URL ‚𕪉ð +\param URL 2‚¿‚á‚ñ‚Ë‚éŒ`Ž®‚Ì URL +\return •ª‰ð‚³‚ꂽ—v‘f +} function TGikoSys.Parse2chURL2(URL: string): TPathRec; var i: Integer; @@ -3279,7 +2115,7 @@ begin //•W€‘Ž® //ÅŒã‚Íl50, 10, 10-20, 10n, 10-20n, -10, 10-, 10n- ‚È‚Ç //http://xxx.2ch.net/test/read.cgi/bbsid/1000000000/ - FAWKStr.RegExp := '/test/read.cgi/.+/[0-9]+/?.*'; + FAWKStr.RegExp := '/test/read.(cgi|html)/.+/[0-9]+/?.*'; if FAWKStr.Match(FAWKStr.ProcessEscSeq(s), RStart, RLength) > 0 then begin s := Copy(s, 15, Length(s)); @@ -3470,6 +2306,16 @@ begin end; end; +{! +\brief URI ‚𕪉ð +\param URL •ª‰ð‚·‚é URI +\param Protocol OUT:ƒvƒƒgƒRƒ‹‚ª•Ô‚é(ex. http) +\param Host OUT:ƒzƒXƒg‚ª•Ô‚é(ex. hoge.com) +\param Path OUT:’†ŠÔƒpƒX‚ª•Ô‚é(ex. test/read.cgi) +\param Document OUT:ƒhƒLƒ…ƒƒ“ƒg–¼‚ª•Ô‚é(ex. index.html) +\param Port OUT:ƒ|[ƒg‚ª•Ô‚é(ex. 8080) +\param Bookmark OUT:ƒuƒbƒNƒ}[ƒN(?)‚ª•Ô‚é +} procedure TGikoSys.ParseURI(const URL : string; var Protocol, Host, Path, Document, Port, Bookmark: string); var URI: TIdURI; @@ -3493,6 +2339,10 @@ begin end; end; +{! +\brief ƒMƒRƒiƒr‚̃o[ƒWƒ‡ƒ“‚ðŽæ“¾ +\return ƒo[ƒWƒ‡ƒ“‚̉º 2 Œ…(dwFileVersionLS) +} function TGikoSys.GetVersionBuild: Integer; var FixedFileInfo: PVSFixedFileInfo; @@ -3516,6 +2366,23 @@ begin end; end; +{! +\brief ƒXƒŒƒbƒh URL ‚̐³‹K‰» +\param inURL ³‹K‰»‚·‚éƒXƒŒƒbƒh URL +\return ³‹K‰»‚³‚ꂽƒXƒŒƒbƒh URL + +ƒXƒŒƒbƒh URL ‚ðƒMƒRƒiƒr‚Ì’†‚ňêˆÓ‚È‚à‚̂ɐ³‹K‰»‚µ‚Ü‚·B +ˆêˆÓ‚È URL ‚É‚·‚鎖‚ŁAURL ‚©‚çƒXƒŒƒbƒh‚𓱂«o‚·ì‹Æ‚ðÅ“K‰»‚µ‚Ü‚·B\n +³‹K‰»‚Ì•ûj‚Æ‚µ‚āAƒTƒCƒg‚ª„§‚·‚éƒfƒtƒHƒ‹ƒg‚Ì URL ‚É‚È‚é‚悤‚ɐS‚ª‚¯‚Ü‚·B +(1-1000 ‚̂悤‚È•‰‰×‚ð‚©‚¯‚é‚à‚Ì‚É‚Í‚µ‚È‚¢‚±‚Æ) + +—á(³‹K‰»‘O):\n +http://’†—ª/ \n +http://’†—ª/20-100 + +(³‹K‰»Œã):\n +http://’†—ª/l50 +} function TGikoSys.GetBrowsableThreadURL( inURL : string ) : string; @@ -3552,6 +2419,11 @@ begin end; +{! +\brief ƒXƒŒƒbƒh URL ‚ð” URL ‚É•ÏŠ· +\param inURL ƒXƒŒƒbƒh URL +\return ” URL +} function TGikoSys.GetThreadURL2BoardURL( inURL : string ) : string; @@ -3586,6 +2458,12 @@ begin end; +{! +\brief 2ch—p:ƒXƒŒƒbƒh URL ‚ð” URL ‚É•ÏŠ· +\param inURL ƒXƒŒƒbƒh URL +\return ” URL +\see TGikoSys.GetThreadURL2BoardURL +} function TGikoSys.Get2chThreadURL2BoardURL( inURL : string ) : string; @@ -3606,6 +2484,12 @@ begin end; +{! +\brief 2ch—p:ƒXƒŒƒbƒh URL ‚̐³‹K‰» +\param inURL ³‹K‰»‚·‚éƒXƒŒƒbƒh URL +\return ³‹K‰»‚³‚ꂽƒXƒŒƒbƒh URL +\see TGikoSys.GetBrowsableThreadURL +} function TGikoSys.Get2chBrowsableThreadURL( inURL : string ) : string; @@ -3637,6 +2521,12 @@ begin end; +{! +\brief 2ch—p:” URL ‚©‚çƒXƒŒƒbƒh URL ‚ðì¬ +\param inBoard ” URL +\param inKey ƒXƒŒƒbƒhƒL[(ex. 1000000000) +\return ƒXƒŒƒbƒh URL +} function TGikoSys.Get2chBoard2ThreadURL( inBoard : TBoard; inKey : string @@ -3654,14 +2544,16 @@ begin end; -(************************************************************************* - *‹@”\–¼@@Fƒ{[ƒhƒtƒ@ƒCƒ‹—ñ‹“ - *‰ÂŽ‹@@@FPublic - *************************************************************************) +{! +\brief ƒ{[ƒhƒtƒ@ƒCƒ‹—ñ‹“ + +—ñ‹“‚³‚ꂽ BBS(ƒ{[ƒh) ‚Í BBSs ‚É“ü‚è‚Ü‚·B +} procedure TGikoSys.ListBoardFile; var boardFileList : TStringList; - i, l, k : Integer; + i, l : Integer; + sCategory : TCategory; begin // BBS ‚ÌŠJ•ú try @@ -3692,13 +2584,9 @@ begin BoardFileList := TStringList.Create; try BoardFileList.BeginUpdate; - GikoSys.GetFileList( GikoSys.Setting.GetBoardDir, '*', BoardFileList, True, True ); + GikoSys.GetFileList( GikoSys.Setting.GetBoardDir, '*.txt', BoardFileList, True, True ); BoardFileList.EndUpdate; - for k := BoardFileList.Count - 1 downto 0 do begin - if AnsiCompareText(ExtractFileExt(BoardFileList[ k ]), '.bak') = 0 then - BoardFileList.Delete(k); - end; - SetLength( BBSs, l + BoardFileList.Count ); + SetLength( BBSs, l + BoardFileList.Count ); for i := BoardFileList.Count - 1 downto 0 do begin BBSs[ l ] := TBBS.Create( BoardFileList[ i ] ); BBSs[ l ].Title := ChangeFileExt( ExtractFileName( BoardFileList[ i ] ), '' ); @@ -3708,11 +2596,26 @@ begin BoardFileList.Free; end; end; -end; -(************************************************************************* - *‹@”\–¼@@Fƒ{[ƒhƒtƒ@ƒCƒ‹“ǂݍž‚Ý - *‰ÂŽ‹@@@FPublic - *************************************************************************) + + // “ÁŽê—p“rBBS¶¬ + // Šù‚É‘¶Ý‚·‚éê‡‚͍폜‚·‚é + DestorySpecialBBS(BoardGroup.SpecialBBS); + SpecialBBS := TBBS.Create(''); + SpecialBBS.Title := '“ÁŽê—p“r(”ñ•\Ž¦)'; + sCategory := TCategory.Create; + sCategory.No := 1; + sCategory.Title := '“ÁŽê—p“r(”ñ•\Ž¦)'; + SpecialBBS.Add(sCategory); + BoardGroup.SpecialBoard := TSpecialBoard.Create(nil, 'http://localhost/gikonavi/special/index.html'); + BoardGroup.SpecialBoard.Title := 'ƒ^ƒuˆê——'; + BoardGroup.SpecialBoard.IsThreadDatRead := True; + sCategory.Add(BoardGroup.SpecialBoard); +end; + +{! +\brief ƒ{[ƒhƒtƒ@ƒCƒ‹“ǂݍž‚Ý +\param bbs ƒ{[ƒhƒtƒ@ƒCƒ‹‚ð“ǂݍž‚Þ BBS +} procedure TGikoSys.ReadBoardFile( bbs : TBBS ); var // idx : Integer; @@ -3819,13 +2722,12 @@ begin end; end; - if (Board.No = 0) then begin + if (Board.Multiplicity = 0) then begin Board.BeginUpdate; Board.No := j + 1; + Board.Multiplicity := 1; Board.Title := BoardList[j]; Board.RoundDate := ZERO_DATE; - - Board.Multiplicity := 0; Board.LoadSettings; Board.EndUpdate; end else begin @@ -3852,6 +2754,10 @@ begin end; +{! +\brief –¼Ì‚ª•s–¾‚ȃJƒeƒSƒŠ‚̐¶¬ +\return ¶¬‚³‚ꂽƒJƒeƒSƒŠ +} function TGikoSys.GetUnknownCategory : TCategory; const UNKNOWN_CATEGORY = '(–¼Ì•s–¾)'; @@ -3871,6 +2777,10 @@ begin end; +{! +\brief –¼Ì‚ª•s–¾‚È BBS ‚̐¶¬ +\return ¶¬‚³‚ꂽ BBS +} function TGikoSys.GetUnknownBoard( inPlugIn : TBoardPlugIn; inURL : string ) : TBoard; var category : TCategory; @@ -3891,60 +2801,77 @@ begin end; end; + +//! Samba.ini function TGikoSys.GetSambaFileName : string; begin Result := Setting.GetSambaFileName; end; -procedure TGikoSys.SambaFileExists(); -var - sambaTmp: string; - sambaStrList: TStringList; -begin - if not FileExists(GikoSys.GetSambaFileName) then begin - sambaTmp := ChangeFileExt(GikoSys.GetSambaFileName, '.default'); - sambaStrList := TStringList.Create; - try - if FileExists(sambaTmp) then begin - sambaStrList.LoadFromFile(sambaTmp); - sambaStrList.SaveToFile(GikoSys.GetSambaFileName); - end; - finally - sambaStrList.Free; - end; - end; -end; -function TGikoSys.GetSameIDResAnchor(const AID : string; ThreadItem: TThreadItem; limited: boolean):string; +{! +\brief —ñ‹“‚³‚ꂽƒŒƒX”ԍ†‚ւ̃Aƒ“ƒJ[—pHTMLì¬ +\param Numbers —ñ‹“‚³‚ꂽƒŒƒX”ԍ† +\param ThreadItem —ñ‹“‚·‚éƒXƒŒƒbƒh +\param limited —ñ‹“‚·‚鐔‚𐧌À‚·‚é‚È‚ç1ˆÈã +\return —ñ‹“‚³‚ꂽƒŒƒXƒAƒ“ƒJ[ +} +function TGikoSys.CreateResAnchor( + var Numbers: TStringList; ThreadItem: TThreadItem; + limited: Integer):string; var i: integer; - body: TStringList; + Res: TResRec; + ResLink : TResLinkRec; begin - Result := ''; - if (not IsNoValidID(AID)) and - (ThreadItem <> nil) and (ThreadItem.IsLogFile) then begin - body := TStringList.Create; - try - GetSameIDRes(AID, ThreadItem, body); - if (limited) and (body.Count > 20) then begin - for i := body.Count - 20 to body.Count - 1 do begin - Result := Result + '>' + body[i] + ' '; - end; - end else begin - for i := 0 to body.Count - 1 do begin - Result := Result + '>' + body[i] + ' '; - end; + // bodyˆÈŠO‚ÍŽg—p‚µ‚È‚¢‚̂ŏ‰Šú‰»‚µ‚È‚¢ + Res.FBody := ''; + Res.FType := glt2chNew; + + Result := ''; + if (Numbers <> nil) and (Numbers.Count > 0) then begin + if (limited > 0) and (Numbers.Count > limited) then begin + for i := Numbers.Count - limited to Numbers.Count - 1 do begin + Res.FBody := Res.FBody + '>' + Numbers[i] + ' '; + end; + end else begin + for i := 0 to Numbers.Count - 1 do begin + Res.FBody := Res.FBody + '>' + Numbers[i] + ' '; end; - finally - body.Free; end; - Result := ConvRes(Result, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true', false); + ResLink.FBbs := ThreadItem.ParentBoard.BBSID; + ResLink.FKey := ChangeFileExt(ThreadItem.FileName, ''); + HTMLCreater.ConvRes(@Res, @ResLink, false); + Result := Res.FBody; end; end; + +{! +\brief “¯‚¶“Še ID ‚ðŽ‚ÂƒŒƒX‚ð—ñ‹“ +\param AID ŒÂl‚ð“Á’è‚·‚é“Še ID +\param ThreadItem —ñ‹“‚·‚éƒXƒŒƒbƒh +\param body OUT:—ñ‹“‚³‚ꂽƒŒƒX”ԍ†‚ª•Ô‚é +} procedure TGikoSys.GetSameIDRes(const AID : string; ThreadItem: TThreadItem;var body: TStringList); var i: integer; ReadList: TStringList; Res: TResRec; boardPlugIn : TBoardPlugIn; + + procedure CheckSameID(const AID:String; const Target: String; no: Integer); + var + pos: Integer; + begin + pos := AnsiPos('id:', LowerCase(Target)); + if (pos > 0) then begin + if(AnsiPos(AID, Copy(Target, pos-1, Length(Target))) > 0) then begin + body.Add(IntToStr(no)); + end; + end else begin + if(AnsiPos(AID, Target) > 0) then begin + body.Add(IntToStr(no)); + end; + end; + end; begin if (not IsNoValidID(AID)) and (ThreadItem <> nil) and (ThreadItem.IsLogFile) then begin @@ -3956,20 +2883,16 @@ begin for i := 0 to threadItem.Count - 1 do begin // ƒŒƒX - Res := DivideStrLine(boardPlugIn.GetDat(DWORD( threadItem ), i + 1)); - if(AnsiPos(AID, Res.FDateTime) > 0) then begin - body.Add(IntToStr(i+1)); - end; + THTMLCreate.DivideStrLine(boardPlugIn.GetDat(DWORD( threadItem ), i + 1), @Res); + CheckSameID(AID, Res.FDateTime, i+1); end; end else begin ReadList := TStringList.Create; try ReadList.LoadFromFile(ThreadItem.GetThreadFileName); for i := 0 to ReadList.Count - 1 do begin - Res := DivideStrLine(ReadList[i]); - if AnsiPos(AID, Res.FDateTime) > 0 then begin - body.Add(IntToStr(i+1)); - end; + THTMLCreate.DivideStrLine(ReadList[i], @Res); + CheckSameID(AID, Res.FDateTime, i+1); end; finally ReadList.Free; @@ -3977,40 +2900,34 @@ begin end; end; end; -function TGikoSys.GetSameIDResAnchor(AIDNum : Integer; ThreadItem: TThreadItem; limited: boolean):string; + +{! +\brief “¯‚¶“Še ID ‚ðŽ‚ÂƒŒƒX‚ð—ñ‹“ +\param AIDNum ŒÂl‚ð“Á’è‚·‚é“Še ID +\param ThreadItem —ñ‹“‚·‚éƒXƒŒƒbƒh +\param body OUT:—ñ‹“‚³‚ꂽƒŒƒX”ԍ†‚ª•Ô‚é +} +procedure TGikoSys.GetSameIDRes(AIDNum : Integer; ThreadItem: TThreadItem;var body: TStringList); var - i: integer; - body: TStringList; + AID : String; begin - Result := ''; - if (ThreadItem <> nil) and (ThreadItem.IsLogFile) then begin - body := TStringList.Create; - try - GetSameIDRes(AIDNum, ThreadItem, body); - if (limited) and (body.Count > 20) then begin - for i := body.Count - 20 to body.Count - 1 do begin - Result := Result + '>' + body[i] + ' '; - end; - end else begin - for i := 0 to body.Count - 1 do begin - Result := Result + '>' + body[i] + ' '; - end; - end; - finally - body.Free; - end; - Result := ConvRes(Result, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true', false); + AID := GetResID(AIDNum, ThreadItem); + if not IsNoValidID(AID) then begin + GetSameIDRes(AID, ThreadItem, body); end; end; - -procedure TGikoSys.GetSameIDRes(AIDNum : Integer; ThreadItem: TThreadItem;var body: TStringList); +{! +\brief “Še ID Žæ“¾ +\param AIDNum “Še ƒŒƒX”ԍ† +\param ThreadItem “ŠeƒXƒŒƒbƒh +\param body OUT:“ŠeID +} +function TGikoSys.GetResID(AIDNum: Integer; ThreadItem: TThreadItem): String; var Res: TResRec; boardPlugIn : TBoardPlugIn; - AID : String; - stList: TStringList; - i : Integer; begin + Result := ''; if (ThreadItem <> nil) and (ThreadItem.IsLogFile) and (AIDNum > 0) and (AIDNum <= ThreadItem.Count) then begin //if ThreadItem.IsBoardPlugInAvailable then begin @@ -4018,85 +2935,51 @@ begin //===== ƒvƒ‰ƒOƒCƒ“‚É‚æ‚é•\Ž¦ //boardPlugIn := ThreadItem.BoardPlugIn; boardPlugIn := ThreadItem.ParentBoard.BoardPlugIn; - Res := DivideStrLine(boardPlugIn.GetDat(DWORD( threadItem ), AIDNum)); - end else begin - Res := DivideStrLine( ReadThreadFile(ThreadItem.GetThreadFileName, AIDNum)); - end; - AID := Res.FDateTime; - if AnsiPos('id', AnsiLowerCase(AID)) > 0 then begin - AID := Copy(AID, AnsiPos('id', AnsiLowerCase(AID)) - 1, 11); - if AnsiPos(' be:', AnsiLowerCase(AID)) > 0 then begin - AID := Copy(AID, 1, AnsiPos(' BE:', AnsiLowerCase(AID)) - 1) - end; + THTMLCreate.DivideStrLine(boardPlugIn.GetDat(DWORD( threadItem ), AIDNum), @Res); end else begin - stlist := TStringList.Create; - try - stList.DelimitedText := AID; - AID := ''; - for i := 0 to stList.Count - 1 do - if Length(WideString(stList[i])) = 8 then begin - if NotDateorTimeString(stList[i]) then begin - AID := stList[i]; - break; - end; - end; - finally - stList.Free; - end; - end; - if not IsNoValidID(AID) then - GetSameIDRes(AID, ThreadItem, body); - end; -end; -function TGikoSys.GetSameIDResCount(const AID : string; ThreadItem: TThreadItem):Integer; -var - body: TStringList; -begin - Result := 0; - if (not IsNoValidID(AID)) - and (ThreadItem <> nil) and (ThreadItem.IsLogFile) then begin - body := TStringList.Create; - try - GetSameIDRes(AID, ThreadItem, body); - Result := body.Count; - finally - body.Free; + THTMLCreate.DivideStrLine( ReadThreadFile(ThreadItem.GetThreadFileName, AIDNum), @Res); end; + Result := ExtructResID(Res.FDateTime); end; - end; -function TGikoSys.GetSameIDResCount(AIDNum : Integer; ThreadItem: TThreadItem):Integer; +{! +\brief ƒŒƒX‚ÌŽž•”‚©‚çID‚𒊏o‚·‚é +\param ADateStr Žž•”‚Ì•¶Žš—ñ +\return ID(ID‚Æ‚Ý‚È‚¹‚é•”•ª‚ª‚È‚¢‚Æ‚«‚͋󕶎š—ñ) +} +function TGikoSys.ExtructResID(ADateStr: String): String; var - body: TStringList; -begin - Result := 0; - if (ThreadItem <> nil) and (ThreadItem.IsLogFile) then begin - body := TStringList.Create; - try - GetSameIDRes(AIDNum, ThreadItem, body); - Result := body.Count; - finally - body.Free; - end; - end; -end; - -function TGikoSys.NotDateorTimeString(const AStr : string): boolean; + stlist : TStringList; begin - Result := false; - try - StrToDate(AStr); - except - try - StrToTime(AStr); - Result := false; - except - Result := true; - end; - end; - + Result := ''; + if AnsiPos('id', AnsiLowerCase(ADateStr)) > 0 then begin + Result := Copy(ADateStr, AnsiPos('id', AnsiLowerCase(ADateStr)), Length(ADateStr)); + if AnsiPos(' ', Result) > 0 then begin + Result := Copy(Result, 1, AnsiPos(' ', Result) - 1); + end; + Result := ' ' + Result; + end else begin + stlist := TStringList.Create; + try + stList.Delimiter := ' '; + stList.DelimitedText := ADateStr; + // “ú•t Žž ID ‘¼@‚ƌŒè‚ōl‚¦‚é + if (stList.Count >= 3) then begin + if Length(stList[3 - 1]) >= 7 then begin + Result := stList[3 - 1]; + end; + end; + finally + stList.Free; + end; + end; end; +{! +\brief ƒXƒpƒ€:Œê”‚ðƒJƒEƒ“ƒg +\param text Œ³‚ɂȂ镶Í +\param wordCount OUT:ƒJƒEƒ“ƒg‚³‚ꂽ’PŒê‚̈ꗗ‚ª•Ô‚é +} procedure TGikoSys.SpamCountWord( const text : string; wordCount : TWordCount ); begin @@ -4105,6 +2988,20 @@ begin end; +{! +\brief ƒXƒpƒ€:ŠwKŒ‹‰Ê‚ð•úŠü +\param wordCount •úŠü‚·‚é’PŒê‚̈ꗗ +\param isSpam wordCount ‚ªƒXƒpƒ€‚Æ‚µ‚ÄŠwK‚³‚ê‚Ä‚¢‚½‚È‚ç True +\warning ŠwKÏ‚Ý‚Ì•¶Í‚©‚Ç‚¤‚©‚ÍŠm”Fo—ˆ‚Ü‚¹‚ñB\n + Learn ‚µ‚Ä‚¢‚È‚¢•¶Í‚â isSpam ‚ðŠÔˆá‚¦‚ÄŽw’è‚·‚é‚Æ + ƒf[ƒ^ƒx[ƒX‚ª”j‘¹‚µ‚Ü‚·B\n + ŠwKÏ‚Ý‚©‚Ç‚¤‚©‚Í“ÆŽ©‚ÉŠÇ—‚µ‚Ä‚­‚¾‚³‚¢B + +‘S‚Ä‚ÌŠwKŒ‹‰Ê‚ðƒNƒŠƒA‚·‚é‚킯‚Å‚Í‚ ‚è‚Ü‚¹‚ñB\n +wordCount ‚𓾂½•¶Í‚ÌŠwKŒ‹‰Ê‚̂݃NƒŠƒA‚µ‚Ü‚·B + +Žå‚ɃXƒpƒ€‚ƃnƒ€‚ðØ‚è‘Ö‚¦‚邽‚ß‚É Forget -> Learn ‚̏‡‚ÅŽg—p‚µ‚Ü‚·B +} procedure TGikoSys.SpamForget( wordCount : TWordCount; isSpam : Boolean ); begin @@ -4113,6 +3010,11 @@ begin end; +{! +\brief ƒXƒpƒ€:ŠwK +\param wordCount ŠwK‚·‚é’PŒê‚̈ꗗ +\param isSpam ƒXƒpƒ€‚Æ‚µ‚ÄŠwK‚·‚é‚È‚ç True +} procedure TGikoSys.SpamLearn( wordCount : TWordCount; isSpam : Boolean ); begin @@ -4121,6 +3023,12 @@ begin end; +{! +\brief ƒXƒpƒ€:•¶Í‚ð‰ðÍ‚µAƒXƒpƒ€“x”‚𓾂é +\param text Œ³‚ɂȂ镶Í +\param wordCount OUT:ƒJƒEƒ“ƒg‚³‚ꂽ’PŒê‚̈ꗗ‚ª•Ô‚é(SpamCountWord ‚Æ“¯“™) +\return 0`1 ‚̃Xƒpƒ€“x” +} function TGikoSys.SpamParse( const text : string; wordCount : TWordCount ) : Extended; begin @@ -4133,9 +3041,17 @@ begin end; end; + +{! +\brief ƒ†[ƒUÝ’è‚Ì CSS ‚𐶐¬ +\return ¶¬‚³‚ꂽ CSS + +[ƒc[ƒ‹]ƒƒjƒ…[-[ƒIƒvƒVƒ‡ƒ“]-[CSS ‚ƃXƒLƒ“]ƒ^ƒu‚Ì +[ƒtƒHƒ“ƒg‚ðŽw’è], [”wŒiF‚ðŽw’è] ‚ɉˆ‚Á‚½ CSS ‚𐶐¬‚µ‚Ü‚·B +} function TGikoSys.SetUserOptionalStyle(): string; begin - Result := ''; + Result := ''; if Length( GikoSys.Setting.BrowserFontName ) > 0 then Result := 'font-family:"' + GikoSys.Setting.BrowserFontName + '";'; if GikoSys.Setting.BrowserFontSize <> 0 then @@ -4153,7 +3069,14 @@ begin 1: Result := Result + 'font-style:italic;'; end; end; -//ˆø”AAIDF‘ΏۂƂȂé“ú•tID•¶Žš—ñAANum:ƒŒƒX”Ô AURLF‚»‚̃XƒŒƒbƒh‚ÌURL + +{! +\brief Be ƒvƒƒtƒ@ƒCƒ‹‚ւ̃Aƒ“ƒJ[ƒ^ƒO‚𐶐¬ +\param AID ‘ΏۂƂȂé“ú•tID•¶Žš—ñ +\param ANum ƒŒƒX”Ô +\param AURL ‚»‚̃XƒŒƒbƒh‚ÌURL +\return ¶¬‚³‚ꂽƒAƒ“ƒJ[ƒ^ƒO +} function TGikoSys.AddBeProfileLink(AID : string; ANum: Integer):string ; var p : integer; @@ -4174,7 +3097,12 @@ begin end else Result := AID; end; -// ƒo[ƒWƒ‡ƒ“î•ñ‚ðŽæ“¾ + +{! +\brief ƒo[ƒWƒ‡ƒ“î•ñ‚ðŽæ“¾ +\param KeyWord Žæ“¾‚·‚鍀–Ú +\return ƒo[ƒWƒ‡ƒ“•¶Žš—ñ +} function TGikoSys.GetVersionInfo(KeyWord: TVerResourceKey): string; const Translation = '\VarFileInfo\Translation'; @@ -4219,14 +3147,377 @@ begin end; end; +{! +\brief Load ‚³‚ê‚Ä‚¢‚éƒvƒ‰ƒOƒCƒ“‚̃o[ƒWƒ‡ƒ“‚ð—ñ‹“ +\return 1s1plugin +} +function TGikoSys.GetPluginsInfo(): String; +var + i : Integer; + major, minor, revision : Cardinal; + agent, release : String; +begin + //Œ‹‰Ê‚ðƒNƒŠƒA‚µ‚Ä‚¨‚­ + Result := ''; + + //BoardGroupsŒo—R‚ÅPlugin‚ɃAƒNƒZƒX‚·‚é + for i := 0 to Length(BoardGroups) - 1 do begin + //BoardGroups‚Ì’†‚ɂ́APlugin‚ðŽ‚Á‚Ä‚¢‚È‚¢‚́i2‚¿‚á‚ñj‚ª + //‚¢‚é‚Ì‚Å‚»‚ê‚ðœ‚­ + if BoardGroups[i].BoardPlugIn <> nil then begin + BoardGroups[i].BoardPlugIn.VersionInfo(agent, major, minor, release, revision); + + + //"Plugin‚Ì–¼‘O(major.minor.revision)" + Result := Result + + Format('%s(%d.%d.%d)', [agent, major, minor, revision]) + #13#10; + end; + end; +end; + + +//! IE‚̃o[ƒWƒ‡ƒ“‚ðŽæ“¾‚·‚é +function TGikoSys.GetIEVersion: string; +var + R: TRegistry; +begin + R := TRegistry.Create; + try + //“Ç‚ÝŽæ‚èê—p‚É‚µ‚È‚¢‚ƁA§ŒÀUSER‚Æ‚©‚̏ꍇAŠJ‚¯‚È‚¢‚Ý‚½‚¢ + R.Access := KEY_EXECUTE; + R.RootKey := HKEY_LOCAL_MACHINE; + R.OpenKey('Software\Microsoft\Internet Explorer', False); + try + Result := R.ReadString('version'); + except + Result := 'ƒo[ƒWƒ‡ƒ“‚̎擾‚ÉŽ¸”s‚µ‚Ü‚µ‚½B'; + end; + R.CloseKey; + finally + R.Free; + end; +end; +//! mainƒtƒH[ƒ€‚̃Vƒ‡[ƒgƒJƒbƒgƒL[‚ÌIniƒtƒ@ƒCƒ‹–¼ +function TGikoSys.GetMainKeyFileName : String; +begin + Result := Setting.GetMainKeyFileName; +end; +//! EditorƒtƒH[ƒ€‚̃Vƒ‡[ƒgƒJƒbƒgƒL[‚ÌIniƒtƒ@ƒCƒ‹–¼ +function TGikoSys.GetEditorKeyFileName: String; +begin + Result := Setting.GetEditorKeyFileName; +end; +//! “ü—̓AƒVƒXƒg‚̐ݒèƒtƒ@ƒCƒ‹–¼ +function TGikoSys.GetInputAssistFileName: String; +begin + Result := Setting.GetInputAssistFileName; +end; +//! ƒMƒRƒiƒr‚̃ƒbƒZ[ƒW‚ðÝ’è‚·‚é +procedure TGikoSys.SetGikoMessage; +begin + if FGikoMessage = nil then begin + FGikoMessage := TGikoMessage.Create; + end else begin + FGikoMessage.Clear; + end; + + if (Setting.GengoSupport) then begin + try + if (FileExists(Setting.GetLanguageFileName)) then begin + FGikoMessage.LoadFromFile(Setting.GetLanguageFileName); + end; + except + FGikoMessage.Clear; + end; + end; +end; +//! ƒMƒRƒiƒr‚̃ƒbƒZ[ƒW‚ðŽæ“¾‚·‚é +function TGikoSys.GetGikoMessage(MesType: TGikoMessageListType): String; +begin + Result := ''; + if FGikoMessage <> nil then begin + Result := FGikoMessage.GetMessage(MesType); + end; +end; + +//Tue, 17 Dec 2002 12:18:07 GMT ¨ TDateTime‚Ö +//MonaUtils‚©‚çˆÚ“® +function TGikoSys.DateStrToDateTime(const DateStr: string): TDateTime; + function StrMonthToMonth(const s: string): integer; + const + m: array[1..12] of string = ('Jan','Feb','Mar','Apr','May','Jun', 'Jul','Aug','Sep','Oct','Nov','Dec'); + var + i: integer; + begin + Result := -1; + for i := Low(m) to High(m) do begin + if (SameText(s, m[i])) then begin + Result := i; + Break; + end; + end; + end; +var + wDay, wMonth, wYear: word; + wHour, wMinute, wSecond: word; + sTime: string; + d: TDateTime; +begin + wDay := StrToIntDef(ChooseString(DateStr, ' ', 1), 0); + wMonth := StrMonthToMonth(ChooseString(DateStr, ' ', 2)); + wYear := StrToIntDef(ChooseString(DateStr, ' ', 3), 0); + sTime := ChooseString(DateStr, ' ', 4); + wHour := StrToIntDef(ChooseString(sTime, ':', 0), 0); + wMinute := StrToIntDef(ChooseString(sTime, ':', 1), 0); + wSecond := StrToIntDef(ChooseString(sTime, ':', 2), 0); + d := EncodeDateTime(wYear, wMonth, wDay, wHour, wMinute, wSecond, 0); + Result := d; +end; +//MonaUtils‚©‚çˆÚ“® +//! ‚ ‚éƒZƒpƒŒ[ƒ^‚Å‹æØ‚ç‚ꂽ•¶Žš—ñ‚©‚ç‚Ž”Ô–Ú‚Ì•¶Žš—ñ‚ðŽæ‚èo‚· +function TGikoSys.ChooseString(const Text, Separator: string; Index: integer): string; +var + S : string; + i, p : integer; +begin + S := Text; + for i := 0 to Index - 1 do begin + if (AnsiPos(Separator, S) = 0) then S := '' + else S := Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S)); + end; + p := AnsiPos(Separator, S); + if (p > 0) then Result := Copy(S, 1, p - 1) else Result := S; +end; +//! ˆêŽžƒtƒ@ƒCƒ‹‚©‚ç‚Ì•œ‹Œ +procedure TGikoSys.RestoreThreadData(Board : TBoard); +const + SECTION = 'Setting'; +var + TmpFileList : TStringList; + i : Integer; + ini : TMemIniFile; + ThreadItem : TThreadItem; + Boardpath, tmpStr : string; +begin + Boardpath := ExtractFilePath(Board.GetFolderIndexFileName); + + TmpFileList := TStringList.Create; + TmpFileList.Sorted := True; + TmpFileList.BeginUpdate; + try + //‘O‰ñˆÙíI—¹Žž—pTmpƒtƒ@ƒCƒ‹ƒŠƒXƒg + GetFileList(Boardpath, '*.tmp', TmpFileList, False); + TmpFileList.EndUpdate; + //‘O‰ñˆÙíI—¹Žžƒ`ƒFƒbƒN + for i := TmpFileList.Count - 1 downto 0 do begin + ThreadItem := Board.FindThreadFromFileName(ChangeFileExt(TmpFileList[i], '.dat')); + if ThreadItem <> nil then begin + ini := TMemIniFile.Create(Boardpath + TmpFileList[i]); + try + tmpStr := ini.ReadString(SECTION, 'RoundDate', DateTimeToStr(ZERO_DATE)); + ThreadItem.RoundDate := ConvertDateTimeString(tmpStr); + + tmpStr := ini.ReadString(SECTION, 'LastModified', DateTimeToStr(ZERO_DATE)); + ThreadItem.LastModified := ConvertDateTimeString(tmpStr); + ThreadItem.Count := ini.ReadInteger(SECTION, 'Count', 0); + ThreadItem.NewReceive := ini.ReadInteger(SECTION, 'NewReceive', 0); + + ThreadItem.Size := ini.ReadInteger(SECTION, 'Size', 0); + ThreadItem.IsLogFile := FileExists(ThreadItem.GetThreadFileName); + if(ThreadItem.Size = 0) and (ThreadItem.IsLogFile) then begin + try + ThreadItem.Size := GetFileSize(ThreadItem.GetThreadFileName) - ThreadItem.Count; + except + end; + end; + + //„‰ñ‚̐ݒè‚ÍRoundData‚Ì•û‚ª‚â‚é‚©‚珟Žè‚ɐݒ肵‚Ă̓_ƒI@by ‚à‚¶‚ã + //ThreadItem.Round := ini.ReadBool('Setting', 'Round', False); + //ThreadItem.RoundName := ini.ReadString('Setting', 'RoundName', ThreadItem.RoundName); + ThreadItem.UnRead := False;//ini.ReadBool('Setting', 'UnRead', False); + ThreadItem.ScrollTop := ini.ReadInteger(SECTION, 'ScrollTop', 0); + ThreadItem.AllResCount := ini.ReadInteger(SECTION, 'AllResCount', ThreadItem.Count); + ThreadItem.NewResCount := ini.ReadInteger(SECTION, 'NewResCount', 0); + ThreadItem.AgeSage := TGikoAgeSage(ini.ReadInteger(SECTION, 'AgeSage', Ord(gasNone))); + finally + ini.Free; + end; + DeleteFile(Boardpath + TmpFileList[i]); + end; + end; + finally + TmpFileList.Clear; + TmpFileList.Free; + end; +end; +{ +\brief User32.dll‚ª—˜—p‚Å‚«‚é‚© +\return Boolean —˜—p‚Å‚«‚éê‡‚ÍTrue +} +function TGikoSys.CanUser32DLL: Boolean; +var + hUser32 : HINST; +begin + Result := False; + hUser32 := 0; + try + try + hUser32 := LoadLibrary('User32.dll'); + if hUser32 <> 0 then begin + Result := True; + end; + except + Result := false; + end; + finally + FreeLibrary(hUser32); + end; +end; +{ +\brief OEˆø—p•„Žæ“¾ +\return OE‚̈ø—p•„iÝ’肳‚ê‚Ä‚¢‚È‚¢ê‡‚Í'>') +} +function TGikoSys.GetOEIndentChar : string; +var + regKey : TRegistry; + Identities : string; + IndentChar : DWORD; +const + DEFAULT_CHAR = '> '; + OE_MAIL_PATH = '\Software\Microsoft\Outlook Express\5.0\Mail'; + INDENT_CHAR = 'Indent Char'; +begin + + Result := DEFAULT_CHAR; + regKey := TRegistry.Create; + try + try + regKey.RootKey := HKEY_CURRENT_USER; + if not regKey.OpenKey( 'Identities', False ) then + Exit; + Identities := regKey.ReadString( 'Default User ID' ); + if Identities = '' then + Exit; + if not regKey.OpenKey( Identities + OE_MAIL_PATH, False ) then + Exit; + IndentChar := regKey.ReadInteger( INDENT_CHAR ); + Result := Char( IndentChar ) + ' '; + except + end; + finally + regKey.Free; + end; + +end; +//! ’uŠ·Ý’èƒtƒ@ƒCƒ‹Žæ“¾ +function TGikoSys.GetReplaceFileName: String; +begin + Result := Setting.GetReplaceFileName; +end; +//! ƒvƒŒƒrƒ…[Šg’£‚̐ݒèƒtƒ@ƒCƒ‹Žæ“¾ +function TGikoSys.GetExtpreviewFileName: String; +begin + Result := Setting.GetExtprevieFileName; +end; + +//! ƒtƒ@ƒCƒ‹–¼‚©‚ç‚̃XƒŒƒbƒhì¬“ú‚̎擾 +function TGikoSys.GetCreateDateFromName(FileName: String): TDateTime; +var + tmp : String; + unixtime: Int64; +begin + // ƒƒOƒtƒ@ƒCƒ‹‚ÌŠg’£Žq‚ð‚Í‚¸‚µ‚½‚à‚Ì‚ªƒXƒŒì¬“úŽž + tmp := ChangeFileExt(FileName, ''); + if AnsiPos('_', tmp) <> 0 then + if AnsiPos('_', tmp) > 9 then + tmp := Copy(tmp, 1, AnsiPos('_', tmp)-1) + else + Delete(tmp, AnsiPos('_', tmp), 1); + + if ( Length(tmp) = 9) and ( tmp[1] = '0' ) then + Insert('1', tmp, 1); + + unixtime := StrToInt64Def(tmp, ZERO_DATE); + Result := UnixToDateTime(unixtime) + OffsetFromUTC; +end; + +procedure TGikoSys.ShowRefCount(msg: String; unk: IUnknown); +{$IFDEF DEBUG} +var + count : integer; +{$ENDIF} +begin + if not Assigned(unk) then + Exit; +{$IFDEF DEBUG} + try + unk._AddRef; + count := unk._Release; + + Writeln(msg + ' RefCount=' + IntToStr(count)); + except + Writeln(msg + ' RefCount=exception!!'); + end; +{$ENDIF} +end; +function TGikoSys.GetBoukenCookie(AURL: String): String; +var + Protocol, Host, Path, Document, Port,Bookmark : String; +begin + Result := ''; + GikoSys.ParseURI(AURL, Protocol, Host, Path, Document, Port,Bookmark); + if ( Length(Host) > 0 ) then begin + Result := Setting.GetBoukenCookie(Host); + end; +end; +procedure TGikoSys.SetBoukenCookie(ACookieValue, ADomain: String); +begin + if ( Length(ADomain) > 0 ) then begin + Setting.SetBoukenCookie(ACookieValue, ADomain); + end; +end; +//! –`Œ¯‚̏‘Domainˆê——Žæ“¾ +procedure TGikoSys.GetBoukenDomain(var ADomain: TStringList); +var + i : Integer; +begin + ADomain.Clear; + for i := 0 to Setting.BoukenCookieList.Count - 1 do begin + ADomain.Add( Setting.BoukenCookieList.Names[i] ); + end; +end; +//! –`Œ¯‚̏‘Cookieíœ +procedure TGikoSys.DelBoukenCookie(ADomain: String); +var + i : Integer; +begin + for i := 0 to Setting.BoukenCookieList.Count - 1 do begin + if ( Setting.BoukenCookieList.Names[i] = ADomain ) then begin + Setting.BoukenCookieList.Delete(i); + Break; + end; + end; +end; +function TGikoSys.GetBouken(AURL: String; var Domain: String): String; +var + Protocol, Host, Path, Document, Port,Bookmark : String; + Cookie : String; +begin + Domain := ''; + Cookie := ''; + GikoSys.ParseURI(AURL, Protocol, Host, Path, Document, Port,Bookmark); + if ( Length(Host) > 0 ) then begin + Setting.GetBouken(Host, Domain, Cookie); + Result := Cookie; + end; +end; initialization GikoSys := TGikoSys.Create; finalization if GikoSys <> nil then begin - GikoSys.Free; - GikoSys := nil; + FreeAndNil(GikoSys); end; end.