| 1 |
unit AbonUnit; |
| 2 |
|
| 3 |
interface |
| 4 |
uses |
| 5 |
Windows,Messages, ShellAPI, SysUtils, Classes,StdCtrls,StrUtils; |
| 6 |
|
| 7 |
type |
| 8 |
TIndiviAbon = record |
| 9 |
Res: Integer; |
| 10 |
option: Integer; // 0:?? 1:??絽吾???若?若?? |
| 11 |
end; |
| 12 |
|
| 13 |
TAbon = class(TObject) |
| 14 |
private |
| 15 |
{ Private 絎h? } |
| 16 |
Froot : String; |
| 17 |
Flistpath : String; |
| 18 |
FNGwordpath : String; |
| 19 |
Ftokens : array of array of string; |
| 20 |
FAbonRes : array of TIndiviAbon; |
| 21 |
FAbonString : String; |
| 22 |
FCutoffNum : Integer; //?????遺札筝??g??????????怨???NG???若???????? |
| 23 |
FDeleterlo : Boolean; //&rlo;???????? //菴遵??&lro;?????? |
| 24 |
FReplaceul :Boolean ; //<ul>?帥?違??<br>?帥?違??舟???????? |
| 25 |
FReverse : Boolean ; //NG???若???с?????若?????????????荵≪???????? |
| 26 |
FAbonPopupRes : Boolean; //???鴻???????≪?????????????若?若???????? |
| 27 |
FCreateNGwordFile : Boolean; //??絎???????path??G???若??txt???<???c?????????????????????????? |
| 28 |
FNGwordFileIndex : Integer; //?上????粋昭???с??NG???若????list???茵????? |
| 29 |
FNGwordname : String; //?上????粋昭???с??NG???若????;腓阪?? |
| 30 |
FIndividualFileName : String; //???ャ???若?????????<?ゃ???? |
| 31 |
FReturnNGwordLineNum : Boolean; //NG???若??????違??菴????? |
| 32 |
FSetNGResAnchor : Boolean; //NG???綵????????????????????????鴻?吾?????鴻?≪?潟???若???ゃ???????????? |
| 33 |
procedure SetTokens(index: integer ; argline:String); |
| 34 |
function Getlistpath() : String; |
| 35 |
procedure Setlistpath(const Value : String); |
| 36 |
function LoadListFile(path :String;listStringList : TStringList) : Boolean; |
| 37 |
function ReadNGwordslist(line : Integer) : Boolean; |
| 38 |
function LoadFromSetResNumFile(SetResNumFile : String) : Boolean; |
| 39 |
public |
| 40 |
{ Public 絎h? } |
| 41 |
constructor Create; // ?潟?潟?鴻????????/span> |
| 42 |
destructor Destroy; override; // ???鴻????????/span> |
| 43 |
property Deleterlo: Boolean read FDeleterlo write FDeleterlo default false; |
| 44 |
property Replaceul: Boolean read FReplaceul write FReplaceul default false; |
| 45 |
property Reverse: Boolean read FReverse write FReverse default false; |
| 46 |
property CreateNGwordFile: Boolean read FCreateNGwordFile write FCreateNGwordFile; |
| 47 |
property AbonString : String read FAbonString write FAbonString; |
| 48 |
property AbonPopupRes : Boolean read FAbonPopupRes write FAbonPopupRes default false; |
| 49 |
property listpath : String read Getlistpath write Setlistpath; |
| 50 |
property NGwordFileIndex : Integer read FNGwordFileIndex write FNGwordFileIndex default 0; |
| 51 |
property NGwordname : String read FNGwordname write FNGwordname; |
| 52 |
property ReturnNGwordLineNum : Boolean read FReturnNGwordLineNum write FReturnNGwordLineNum default false; |
| 53 |
property SetNGResAnchor : Boolean read FSetNGResAnchor write FSetNGResAnchor default false; |
| 54 |
procedure Setroot(root :String); |
| 55 |
function Getroot() : String; |
| 56 |
|
| 57 |
function Getfullpath(argpath : String) : String; |
| 58 |
procedure SetNGwordpath(path :String); |
| 59 |
function GetNGwordpath() : String; |
| 60 |
function LoadFromNGwordFile(path :String) : Boolean; |
| 61 |
function ReLoadFromNGwordFile() : Boolean; |
| 62 |
procedure LoadFromStringList( bufstl : TStringList ); |
| 63 |
function CheckAbonPopupRes(line : String) :Boolean; |
| 64 |
function FindNGwords(line : String) : Boolean; overload;//1???ゃ?潟???ょ???? |
| 65 |
function FindNGwords(line : String; var NGwordsLineNum : Integer) : Boolean; overload;//1???ゃ?潟???ょ???? |
| 66 |
function FindNGwords(line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean; overload;//1???ゃ?潟???ょ???? |
| 67 |
function Cutoff(line : String) : Boolean; //CutOff?や札筝??????????掩?違??筝????с??????true |
| 68 |
//???若????????(NG???若???с?????c???帥???潟?? |
| 69 |
procedure Execute(var ThreadStrings : TStringList); overload; |
| 70 |
procedure Execute(var ThreadStrings : TStringList; NGwords : TStringList); overload; |
| 71 |
procedure Execute(var ThreadStrings : TStringList; NGwords : TStrings); overload; |
| 72 |
procedure Execute(var ResString : String; ResNumber : Integer); overload; //筝祉??lugin??????at To HTML ??/span> |
| 73 |
//???ャ???若?????????? |
| 74 |
procedure IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String); overload; |
| 75 |
procedure IndividualAbon(var ResString : String; SetResNumFile : String; ResNumber : Integer); overload; |
| 76 |
procedure AddIndividualAbon( ResNum : Integer ; option : Integer); |
| 77 |
procedure DeleteIndividualAbon( ResNum : Integer); |
| 78 |
function GetAbonResCount() : Integer; |
| 79 |
function GetAbonResString(Num : Integer) : String; |
| 80 |
function CheckIndividualAbonList(ResNum : Integer) : Boolean; |
| 81 |
//-- |
| 82 |
function ExecuteFile(datfilepath : String; NGwordpath : String) : Boolean; overload;//DAT???<?ゃ?????眼???????? |
| 83 |
function ExecuteFile(datfilepath : String; resnum : Integer) : Boolean; overload; //DAT???<?ゃ?????眼???????? |
| 84 |
function ExecuteFile(datfilepath : String; firstres : Integer; count : Integer) : Boolean; overload; //DAT???<?ゃ?????眼???????? |
| 85 |
function ReverseExecuteFile(datfilepath : String) : Boolean; overload; //DAT???<?ゃ?????眼???????? |
| 86 |
function ReverseExecuteFile(datfilepath : String; resnum : Integer) : Boolean; overload; //DAT???<?ゃ?????眼???????? |
| 87 |
function ReverseExecuteFile(datfilepath : String; firstres : Integer; count : Integer) : Boolean; overload; //DAT???<?ゃ?????眼???????? |
| 88 |
//-- |
| 89 |
procedure EditNGwords(); //NGword.txt??????? |
| 90 |
function ShowAllTokens() : String; //???????亥??/span> |
| 91 |
//-- |
| 92 |
procedure GoHome();//List???茵?????茯??? |
| 93 |
function GoForward() : Boolean; //List????ゆ???G???若?????<?ゃ????茯??粋昭?? |
| 94 |
function GoBack() : Boolean; //List????ゅ????G???若?????<?ゃ????茯??粋昭?? |
| 95 |
end; |
| 96 |
var |
| 97 |
Abon1 :TAbon; |
| 98 |
const |
| 99 |
NGwordListFileName : String = 'NGwords.list'; |
| 100 |
|
| 101 |
implementation |
| 102 |
|
| 103 |
uses MojuUtils; |
| 104 |
|
| 105 |
constructor TAbon.Create; |
| 106 |
begin |
| 107 |
// ?????? |
| 108 |
FAbonString := ' <> <> <> <><>'; |
| 109 |
FCreateNGwordFile := true; |
| 110 |
SetLength(FAbonRes,1); |
| 111 |
FAbonRes[0].Res := 0; |
| 112 |
FAbonRes[0].option := -1; |
| 113 |
|
| 114 |
end; |
| 115 |
|
| 116 |
destructor TAbon.Destroy; |
| 117 |
begin |
| 118 |
inherited; |
| 119 |
end; |
| 120 |
//root??xe\config\NGwords???????? |
| 121 |
procedure TAbon.Setroot(root :String); |
| 122 |
var |
| 123 |
bufStringList : TStringList; |
| 124 |
begin |
| 125 |
bufStringList := TStringList.Create; |
| 126 |
try |
| 127 |
if not DirectoryExists(root) then begin |
| 128 |
CreateDir(root); |
| 129 |
end; |
| 130 |
if root[Length(root)] <> '\' then begin |
| 131 |
root := root + '\'; |
| 132 |
end; |
| 133 |
Flistpath := root + NGwordListFileName; |
| 134 |
LoadListFile(Flistpath, bufStringList); |
| 135 |
finally |
| 136 |
bufStringList.Free; |
| 137 |
end; |
| 138 |
Froot := root; |
| 139 |
end; |
| 140 |
function TAbon.Getroot() : String; |
| 141 |
begin |
| 142 |
Result := Froot; |
| 143 |
end; |
| 144 |
//NGwordpath??Gword.txt??????????/span> |
| 145 |
procedure TAbon.SetNGwordpath(path :String); |
| 146 |
begin |
| 147 |
FNGwordpath := Getfullpath(path); |
| 148 |
LoadFromNGwordFile(FNGwordpath); |
| 149 |
end; |
| 150 |
function TAbon.GetNGwordpath() : String; |
| 151 |
begin |
| 152 |
Result := FNGwordpath; |
| 153 |
end; |
| 154 |
//???????鴻?с???????違???????鴻??????????? |
| 155 |
function TAbon.Getfullpath(argpath : String) : String; |
| 156 |
begin |
| 157 |
if AnsiPos(':\',argpath) <> 2 then begin //?????ゃ???????????????鴻???<??????/span> |
| 158 |
if Getroot() = '' then begin |
| 159 |
Result := ''; //root???鴻??荐??????????????腥冴?????? |
| 160 |
end else begin |
| 161 |
if (Froot[Length(Froot)] = '\') and (argpath[1] = '\') then begin //????????????/span> |
| 162 |
Delete(argpath,1,1); |
| 163 |
end; |
| 164 |
Insert( Getroot(), argpath , 1);//root???鴻???水??/span> |
| 165 |
Result := argpath; |
| 166 |
end; |
| 167 |
end else begin |
| 168 |
Result := argpath; |
| 169 |
end; |
| 170 |
|
| 171 |
end; |
| 172 |
//NGword???<?ゃ??????粋昭??/span> |
| 173 |
function TAbon.LoadFromNGwordFile(path :String) : boolean; |
| 174 |
var |
| 175 |
bufstl : TStringList; |
| 176 |
begin |
| 177 |
path := Getfullpath(path); |
| 178 |
if path = '' then begin |
| 179 |
Result := false; |
| 180 |
end else begin |
| 181 |
bufstl := TStringList.Create; |
| 182 |
try |
| 183 |
try |
| 184 |
bufstl.LoadFromFile(path); |
| 185 |
LoadFromStringList( bufstl ); |
| 186 |
Result := true; |
| 187 |
except |
| 188 |
if CreateNGwordFile = true then begin |
| 189 |
bufstl.SaveToFile(path); |
| 190 |
end; |
| 191 |
Result := false; |
| 192 |
end; |
| 193 |
finally |
| 194 |
bufstl.Free; |
| 195 |
end; |
| 196 |
end; |
| 197 |
|
| 198 |
end; |
| 199 |
//NGword???鴻??茯??粋昭??/span> |
| 200 |
procedure TAbon.LoadFromStringList( bufstl : TStringList ); |
| 201 |
var |
| 202 |
i : integer; |
| 203 |
begin |
| 204 |
try |
| 205 |
for i := bufstl.Count -1 downto 0 do begin |
| 206 |
if bufstl.Strings[i] = '' then begin |
| 207 |
bufstl.Delete(i); |
| 208 |
end; |
| 209 |
end; |
| 210 |
SetLength(Ftokens,bufstl.Count); |
| 211 |
for i := 0 to bufstl.Count -1 do begin |
| 212 |
SetTokens(i , bufstl.Strings[i]); |
| 213 |
end; |
| 214 |
|
| 215 |
except |
| 216 |
Exit; |
| 217 |
end; |
| 218 |
end; |
| 219 |
//NGwordpath???≪??┃絎??????????????????????若?????∽??/span> |
| 220 |
function TAbon.ReLoadFromNGwordFile() : boolean; |
| 221 |
begin |
| 222 |
if GetNGwordpath() ='' then begin |
| 223 |
Result := false; |
| 224 |
end else begin |
| 225 |
Result := LoadFromNGwordFile( GetNGwordpath() ); |
| 226 |
end; |
| 227 |
end; |
| 228 |
function TAbon.Getlistpath() : String; |
| 229 |
begin |
| 230 |
Result := Flistpath; |
| 231 |
end; |
| 232 |
procedure TAbon.Setlistpath(const Value : String); |
| 233 |
begin |
| 234 |
Flistpath := Getfullpath(Value); |
| 235 |
end; |
| 236 |
//筝?茵???賢?????若???潟?????????????祉???? |
| 237 |
procedure TAbon.SetTokens(index: integer ; argline : String); |
| 238 |
var |
| 239 |
ret : Integer; |
| 240 |
bufstl : TStringList; |
| 241 |
i : Integer; |
| 242 |
pos : Integer; |
| 243 |
buftoken : String; |
| 244 |
begin |
| 245 |
pos := 0; |
| 246 |
bufstl := TStringList.Create; |
| 247 |
try |
| 248 |
if Length(argline) > 0 then begin |
| 249 |
pos := AnsiPos(#9,argline); |
| 250 |
while pos <> 0 DO begin |
| 251 |
buftoken := Copy(argline,1,pos-1); |
| 252 |
Delete(argline,1,pos); |
| 253 |
if Length(buftoken) > 0 then begin |
| 254 |
bufstl.Append(buftoken); |
| 255 |
end else if ( bufstl.Count = 0 ) then begin |
| 256 |
bufstl.Append(''); |
| 257 |
end; |
| 258 |
pos := AnsiPos(#9,argline); |
| 259 |
end; |
| 260 |
if Length(argline) > 0 then begin |
| 261 |
bufstl.Append(argline); |
| 262 |
end; |
| 263 |
ret := bufstl.Count; |
| 264 |
SetLength(Ftokens[index],ret); |
| 265 |
for i := 0 to bufstl.Count - 1 do begin |
| 266 |
Ftokens[index][i] := bufstl.Strings[i]; |
| 267 |
end; |
| 268 |
end; |
| 269 |
finally |
| 270 |
bufstl.Free; |
| 271 |
end; |
| 272 |
|
| 273 |
end; |
| 274 |
//Debug???<??????G???若?????障?????????? |
| 275 |
function TAbon.ShowAllTokens() : String; |
| 276 |
var |
| 277 |
i : Integer; |
| 278 |
j : Integer; |
| 279 |
ret : String; |
| 280 |
begin |
| 281 |
for i := 0 to High(Ftokens) do begin |
| 282 |
for j := 0 to High(Ftokens[i]) do begin |
| 283 |
ret := ret + Ftokens[i][j]; |
| 284 |
end; |
| 285 |
end; |
| 286 |
Result := ret; |
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
end; |
| 291 |
|
| 292 |
//****************************************************************************// |
| 293 |
//NG???若???????障????????true??菴????? |
| 294 |
function TAbon.FindNGwords(line : String) : Boolean; |
| 295 |
var |
| 296 |
lines : Integer; |
| 297 |
cells : Integer; |
| 298 |
hit : Boolean; |
| 299 |
bufline : String; |
| 300 |
begin |
| 301 |
hit := false; |
| 302 |
if AnsiPos(FAbonString,line) <> 1 then begin |
| 303 |
for lines := 0 to High(Ftokens) do begin |
| 304 |
hit := true; |
| 305 |
bufline := line; |
| 306 |
for cells := 0 to High(Ftokens[lines]) do begin |
| 307 |
if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin |
| 308 |
hit := false; |
| 309 |
break; |
| 310 |
end else begin |
| 311 |
Delete(bufline,AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells])); |
| 312 |
end; |
| 313 |
end; |
| 314 |
if hit = true then begin |
| 315 |
break; |
| 316 |
end; |
| 317 |
end; |
| 318 |
end; |
| 319 |
Result := hit; |
| 320 |
end; |
| 321 |
//NG???若???????障??????????true??菴?????????G???若??????違??NGwordsLineNum???ャ??????? |
| 322 |
function TAbon.FindNGwords(line : String; var NGwordsLineNum : Integer) : Boolean; |
| 323 |
var |
| 324 |
lines : Integer; |
| 325 |
cells : Integer; |
| 326 |
hit : Boolean; |
| 327 |
bufline : String; |
| 328 |
begin |
| 329 |
hit := false; |
| 330 |
if AnsiPos(FAbonString,line) <> 1 then begin |
| 331 |
for lines := 0 to High(Ftokens) do begin |
| 332 |
hit := true; |
| 333 |
bufline := line; |
| 334 |
for cells := 0 to High(Ftokens[lines]) do begin |
| 335 |
if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin |
| 336 |
hit := false; |
| 337 |
break; |
| 338 |
end else begin |
| 339 |
Delete(bufline,AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells])); |
| 340 |
end; |
| 341 |
end; |
| 342 |
if hit = true then begin |
| 343 |
NGwordsLineNum := lines + 1; |
| 344 |
break; |
| 345 |
end; |
| 346 |
end; |
| 347 |
end; |
| 348 |
Result := hit; |
| 349 |
end; |
| 350 |
//NG???若???????障??????????true??菴?????????G???若??????違??NGwordsLineNum???ャ????????? |
| 351 |
//????????????若??????????????Inbisible??true????????? |
| 352 |
function TAbon.FindNGwords(line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean; //1???ゃ?潟???ょ???? |
| 353 |
var |
| 354 |
lines : Integer; |
| 355 |
cells : Integer; |
| 356 |
hit : Boolean; |
| 357 |
bufline : String; |
| 358 |
start : Integer; |
| 359 |
begin |
| 360 |
hit := false; |
| 361 |
if AnsiPos(FAbonString,line) <> 1 then begin |
| 362 |
for lines := 0 to High(Ftokens) do begin |
| 363 |
hit := true; |
| 364 |
bufline := line; |
| 365 |
if Ftokens[lines][0] <> '' then begin |
| 366 |
Invisible := false; |
| 367 |
start := 0; |
| 368 |
end else begin |
| 369 |
Invisible := true; |
| 370 |
start := 1; |
| 371 |
end; |
| 372 |
|
| 373 |
for cells := start to High(Ftokens[lines]) do begin |
| 374 |
if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin |
| 375 |
hit := false; |
| 376 |
break; |
| 377 |
end else begin |
| 378 |
Delete(bufline,AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells])); |
| 379 |
end; |
| 380 |
end; |
| 381 |
if hit = true then begin |
| 382 |
NGwordsLineNum := lines + 1; |
| 383 |
break; |
| 384 |
end; |
| 385 |
end; |
| 386 |
end; |
| 387 |
Result := hit; |
| 388 |
end; |
| 389 |
|
| 390 |
//CutOff?や札筝??????????掩?違??筝????с??????true |
| 391 |
function TAbon.Cutoff(line : String) : Boolean; |
| 392 |
var |
| 393 |
i : Integer; |
| 394 |
sheed : AnsiChar; |
| 395 |
buf : String; |
| 396 |
ret : Bool; |
| 397 |
begin |
| 398 |
ret := false; |
| 399 |
if FCutoffNum <> 0 then begin |
| 400 |
for i := 65 to 90 do begin |
| 401 |
sheed := Chr(i); |
| 402 |
buf := DupeString(sheed, FCutoffNum); |
| 403 |
if AnsiContainsText(line, buf) = true then begin |
| 404 |
ret := true; |
| 405 |
break; |
| 406 |
end; |
| 407 |
end; |
| 408 |
end; |
| 409 |
Result := ret; |
| 410 |
end; |
| 411 |
//??鮎?????若???ゃ??rue??????NG???若??????????????????菴????? |
| 412 |
procedure TAbon.Execute(var ThreadStrings : TStringList); |
| 413 |
var |
| 414 |
i : Integer; |
| 415 |
NGwordsLine : Integer; |
| 416 |
bufline : String; |
| 417 |
invisi : Boolean; |
| 418 |
begin |
| 419 |
for i:=0 to ThreadStrings.Count - 1 do begin |
| 420 |
NGwordsLine := 0; |
| 421 |
if FindNGwords(ThreadStrings.Strings[i], NGwordsLine ,invisi) <> Reverse then begin |
| 422 |
if invisi = true then begin |
| 423 |
ThreadStrings.Strings[i] := ''; |
| 424 |
end else begin |
| 425 |
if not ReturnNGwordLineNum and not SetNGResAnchor then begin |
| 426 |
ThreadStrings.Strings[i] := FAbonString; |
| 427 |
end else if not ReturnNGwordLineNum then begin |
| 428 |
ThreadStrings.Strings[i] := Format(' <> <> <>>%d<><>',[(i+1)]); |
| 429 |
end else if not SetNGResAnchor then begin |
| 430 |
ThreadStrings.Strings[i] := Format(' <> <> <><B> %d 茵?????G???若???????障???????障????</B><><>',[NGwordsLine]); |
| 431 |
end else begin |
| 432 |
ThreadStrings.Strings[i] := Format(' <> <> <><B> %d 茵?????G???若???????障???????障????</B>>%d <><>',[NGwordsLine,(i+1)]); |
| 433 |
end; |
| 434 |
end; |
| 435 |
end else begin |
| 436 |
bufline := ThreadStrings.Strings[i]; |
| 437 |
if Deleterlo = true then begin |
| 438 |
bufline := CustomStringReplace(bufline,'&rlo;',''); |
| 439 |
bufline := CustomStringReplace(bufline,'&lro;',''); |
| 440 |
end; |
| 441 |
if Replaceul = true then begin |
| 442 |
bufline := CustomStringReplace( bufline,'<ul>','<br>' ); |
| 443 |
bufline := CustomStringReplace( bufline,'</ul>','<br>' ); |
| 444 |
end; |
| 445 |
ThreadStrings.Strings[i] := bufline; |
| 446 |
end; |
| 447 |
end; |
| 448 |
end; |
| 449 |
procedure TAbon.Execute(var ResString : String; ResNumber : Integer); |
| 450 |
var |
| 451 |
i : Integer; |
| 452 |
NGwordsLine : Integer; |
| 453 |
bufline : String; |
| 454 |
invisi : Boolean; |
| 455 |
begin |
| 456 |
NGwordsLine := 0; |
| 457 |
if FindNGwords(ResString, NGwordsLine ,invisi) <> Reverse then begin |
| 458 |
if invisi = true then begin |
| 459 |
ResString := ''; |
| 460 |
end else begin |
| 461 |
if not ReturnNGwordLineNum and not SetNGResAnchor then begin |
| 462 |
ResString := FAbonString; |
| 463 |
end else if not ReturnNGwordLineNum then begin |
| 464 |
ResString := Format(' <> <> <>>%d<><>',[(ResNumber)]); |
| 465 |
end else if not SetNGResAnchor then begin |
| 466 |
ResString := Format(' <> <> <><B> %d 茵?????G???若???????障???????障????</B><><>',[NGwordsLine]); |
| 467 |
end else begin |
| 468 |
ResString := Format(' <> <> <><B> %d 茵?????G???若???????障???????障????</B>>%d <><>',[NGwordsLine,(ResNumber)]); |
| 469 |
end; |
| 470 |
end; |
| 471 |
end else begin |
| 472 |
bufline := ResString; |
| 473 |
if Deleterlo = true then begin |
| 474 |
bufline := CustomStringReplace( bufline,'&rlo;','' ); |
| 475 |
bufline := CustomStringReplace( bufline,'&lro;','' ); |
| 476 |
end; |
| 477 |
if Replaceul = true then begin |
| 478 |
bufline := CustomStringReplace( bufline,'<ul>','<br>' ); |
| 479 |
bufline := CustomStringReplace( bufline,'</ul>','<br>' ); |
| 480 |
end; |
| 481 |
ResString := bufline; |
| 482 |
end; |
| 483 |
end; |
| 484 |
|
| 485 |
procedure TAbon.Execute(var ThreadStrings : TStringList; NGwords : TStringList); |
| 486 |
var |
| 487 |
i : Integer; |
| 488 |
begin |
| 489 |
SetLength(Ftokens,NGwords.Count); |
| 490 |
for i := 0 to NGwords.Count -1 do begin |
| 491 |
SetTokens(i , NGwords.Strings[i]); |
| 492 |
end; |
| 493 |
Execute(ThreadStrings); |
| 494 |
|
| 495 |
end; |
| 496 |
procedure TAbon.Execute(var ThreadStrings : TStringList; NGwords : TStrings); |
| 497 |
var |
| 498 |
i : Integer; |
| 499 |
buf : TStringList; |
| 500 |
begin |
| 501 |
buf := TStringList.Create; |
| 502 |
buf.AddStrings(NGwords); |
| 503 |
SetLength(Ftokens,buf.Count); |
| 504 |
for i := 0 to buf.Count -1 do begin |
| 505 |
SetTokens(i , buf.Strings[i]); |
| 506 |
end; |
| 507 |
Execute(ThreadStrings); |
| 508 |
buf.Free; |
| 509 |
end; |
| 510 |
|
| 511 |
|
| 512 |
//****************************************************************************// |
| 513 |
//DAT???眼????????絅眼??=========================================================== |
| 514 |
//NG???若???????????鴻???????????若?若?????水??/span> |
| 515 |
function TAbon.ExecuteFile(datfilepath : String; NGwordpath : String) : Boolean; //DAT???<?ゃ?????眼???????? |
| 516 |
var |
| 517 |
datstl : TStringList; |
| 518 |
ret : Boolean; |
| 519 |
i : Integer; |
| 520 |
begin |
| 521 |
datstl := TStringList.Create; |
| 522 |
ret := true; |
| 523 |
try |
| 524 |
try |
| 525 |
datstl.LoadFromFile(datfilepath); |
| 526 |
for i := 0 to datstl.Count -1 do begin |
| 527 |
if FindNGwords(datstl.Strings[i]) = true then begin |
| 528 |
datstl.Strings[i] := FAbonString + datstl.Strings[i] |
| 529 |
end; |
| 530 |
end; |
| 531 |
|
| 532 |
datstl.SaveToFile(datfilepath); |
| 533 |
except |
| 534 |
ret := false; |
| 535 |
end; |
| 536 |
finally |
| 537 |
datstl.Free; |
| 538 |
end; |
| 539 |
Result := ret; |
| 540 |
|
| 541 |
end; |
| 542 |
//??絎??????????合?????????????若?若???水??/span> |
| 543 |
function TAbon.ExecuteFile(datfilepath : String; resnum : Integer) : Boolean; //DAT???<?ゃ?????眼???????? |
| 544 |
var |
| 545 |
datstl : TStringList; |
| 546 |
ret : Boolean; |
| 547 |
begin |
| 548 |
ret := true; |
| 549 |
datstl := TStringList.Create; |
| 550 |
try |
| 551 |
try |
| 552 |
datstl.LoadFromFile(datfilepath); |
| 553 |
if (resnum > 0) and (resnum <= datstl.Count) then begin |
| 554 |
if AnsiPos(FAbonString, datstl.Strings[resnum-1]) <> 1 then begin |
| 555 |
datstl.Strings[resnum-1] := FAbonString + datstl.Strings[resnum-1]; |
| 556 |
end; |
| 557 |
end; |
| 558 |
datstl.SaveToFile(datfilepath); |
| 559 |
except |
| 560 |
ret := false; |
| 561 |
end; |
| 562 |
finally |
| 563 |
datstl.Free; |
| 564 |
end; |
| 565 |
Result := ret; |
| 566 |
end; |
| 567 |
//firstres????count???????鴻???????????若?若???水??/span> |
| 568 |
function TAbon.ExecuteFile(datfilepath : String; firstres : Integer; count : Integer) : Boolean; //DAT???<?ゃ?????眼???????? |
| 569 |
var |
| 570 |
datstl : TStringList; |
| 571 |
i : Integer; |
| 572 |
endnum : Integer; //腟?????????合??/span> |
| 573 |
ret : Boolean; |
| 574 |
begin |
| 575 |
ret := true; |
| 576 |
datstl := TStringList.Create; |
| 577 |
try |
| 578 |
try |
| 579 |
datstl.LoadFromFile(datfilepath); |
| 580 |
if (firstres > 0) and (firstres <= datstl.Count) then begin |
| 581 |
if firstres + count -1 > datstl.Count then begin |
| 582 |
endnum := datstl.Count; |
| 583 |
end else if count <= 0 then begin |
| 584 |
endnum := firstres + 1; |
| 585 |
end else begin |
| 586 |
endnum := firstres + count -1; |
| 587 |
end; |
| 588 |
|
| 589 |
for i := firstres to endnum do begin |
| 590 |
if AnsiPos(FAbonString, datstl.Strings[i-1]) <> 1 then begin |
| 591 |
datstl.Strings[i-1] := FAbonString + datstl.Strings[i-1]; |
| 592 |
end; |
| 593 |
end; |
| 594 |
end; |
| 595 |
datstl.SaveToFile(datfilepath); |
| 596 |
except |
| 597 |
ret := false; |
| 598 |
end; |
| 599 |
finally |
| 600 |
datstl.Free; |
| 601 |
end; |
| 602 |
Result := ret; |
| 603 |
end; |
| 604 |
//DAT???眼????????絅眼??==========?????障??======================================== |
| 605 |
|
| 606 |
//?????祉??絅眼??================================================================== |
| 607 |
function TAbon.ReverseExecuteFile(datfilepath : String) : Boolean; //DAT???<?ゃ?????眼???????? |
| 608 |
var |
| 609 |
datstl : TStringList; |
| 610 |
i : Integer; |
| 611 |
buf : String; |
| 612 |
ret : Boolean; |
| 613 |
begin |
| 614 |
ret := true; |
| 615 |
datstl := TStringList.Create; |
| 616 |
try |
| 617 |
try |
| 618 |
datstl.LoadFromFile(datfilepath); |
| 619 |
for i:=0 to datstl.Count -1 do begin |
| 620 |
if AnsiPos(FAbonString, datstl.Strings[i]) = 1 then begin |
| 621 |
buf := datstl.Strings[i]; |
| 622 |
Delete(buf,1,Length(FAbonString)); |
| 623 |
datstl.Strings[i] := buf; |
| 624 |
end; |
| 625 |
end; |
| 626 |
datstl.SaveToFile(datfilepath); |
| 627 |
except |
| 628 |
ret := false; |
| 629 |
end; |
| 630 |
finally |
| 631 |
datstl.Free; |
| 632 |
end; |
| 633 |
Result := ret; |
| 634 |
|
| 635 |
end; |
| 636 |
function TAbon.ReverseExecuteFile(datfilepath : String; resnum : Integer) : Boolean; //DAT???<?ゃ?????眼???????? |
| 637 |
var |
| 638 |
datstl : TStringList; |
| 639 |
buf : String; |
| 640 |
ret : Boolean; |
| 641 |
begin |
| 642 |
ret := true; |
| 643 |
datstl := TStringList.Create; |
| 644 |
try |
| 645 |
try |
| 646 |
datstl.LoadFromFile(datfilepath); |
| 647 |
if (resnum > 0) and (resnum <= datstl.Count) then begin |
| 648 |
if AnsiPos(FAbonString, datstl.Strings[resnum-1]) = 1 then begin |
| 649 |
buf := datstl.Strings[resnum-1]; |
| 650 |
Delete(buf,1,Length(FAbonString)); |
| 651 |
datstl.Strings[resnum-1] := buf; |
| 652 |
end; |
| 653 |
end; |
| 654 |
datstl.SaveToFile(datfilepath); |
| 655 |
except |
| 656 |
ret := false; |
| 657 |
end; |
| 658 |
finally |
| 659 |
datstl.Free; |
| 660 |
end; |
| 661 |
Result := ret; |
| 662 |
|
| 663 |
end; |
| 664 |
function TAbon.ReverseExecuteFile(datfilepath : String; firstres : Integer; count : Integer) : Boolean;//DAT???<?ゃ?????眼???????? |
| 665 |
var |
| 666 |
datstl : TStringList; |
| 667 |
i : Integer; |
| 668 |
endnum : Integer; //腟?????????合??/span> |
| 669 |
buf : String; |
| 670 |
ret : Boolean; |
| 671 |
begin |
| 672 |
ret := true; |
| 673 |
datstl := TStringList.Create; |
| 674 |
try |
| 675 |
try |
| 676 |
datstl.LoadFromFile(datfilepath); |
| 677 |
if (firstres > 0) and (firstres <= datstl.Count) then begin |
| 678 |
if firstres + count -1 > datstl.Count then begin |
| 679 |
endnum := datstl.Count; |
| 680 |
end else if count <= 0 then begin |
| 681 |
endnum := firstres + 1; |
| 682 |
end else begin |
| 683 |
endnum := firstres + count -1; |
| 684 |
end; |
| 685 |
for i := firstres to endnum do begin |
| 686 |
if AnsiPos(FAbonString, datstl.Strings[i-1]) = 1 then begin |
| 687 |
buf := datstl.Strings[i-1]; |
| 688 |
Delete(buf,1,Length(FAbonString)); |
| 689 |
datstl.Strings[i-1] := buf; |
| 690 |
end; |
| 691 |
end; |
| 692 |
end; |
| 693 |
datstl.SaveToFile(datfilepath); |
| 694 |
except |
| 695 |
ret := false; |
| 696 |
end; |
| 697 |
finally |
| 698 |
datstl.Free; |
| 699 |
end; |
| 700 |
Result := ret; |
| 701 |
end; |
| 702 |
//?????祉??絅眼??=================?????障??======================================== |
| 703 |
//?上???祉??????????????NGword.txt??????span> |
| 704 |
procedure TAbon.EditNGwords(); |
| 705 |
begin |
| 706 |
ShellExecute(0 ,nil,PChar(FNGwordpath),nil,nil,SW_SHOW); |
| 707 |
end; |
| 708 |
//???????≪???????ゅ??∽??/span> |
| 709 |
function TAbon.CheckAbonPopupRes(line : String) :Boolean; |
| 710 |
begin |
| 711 |
if AbonPopupRes = true then begin |
| 712 |
Result := FindNGwords(line); |
| 713 |
end else begin |
| 714 |
Result := false; |
| 715 |
end; |
| 716 |
end; |
| 717 |
//茲??違??G???若???????鴻????茯??粋昭??============================================== |
| 718 |
//List???<?ゃ????茯??粋昭?? |
| 719 |
function TAbon.LoadListFile(path :String; listStringList : TStringList) : Boolean; |
| 720 |
begin |
| 721 |
try |
| 722 |
listStringList.LoadFromFile(path); |
| 723 |
Result := true; |
| 724 |
except |
| 725 |
listStringList.Append('筝???NGword.txt'); |
| 726 |
listStringList.SaveToFile(path); |
| 727 |
Result := false; |
| 728 |
end; |
| 729 |
end; |
| 730 |
//List????ゆ???G???若?????<?ゃ????茯??粋昭?? |
| 731 |
function TAbon.GoForward() : Boolean; |
| 732 |
begin |
| 733 |
FNGwordFileIndex := FNGwordFileIndex + 1; |
| 734 |
Result := ReadNGwordslist(FNGwordFileIndex); |
| 735 |
end; |
| 736 |
//List????ゅ????G???若?????<?ゃ????茯??粋昭?? |
| 737 |
function TAbon.GoBack() : Boolean; |
| 738 |
begin |
| 739 |
FNGwordFileIndex := FNGwordFileIndex -1; |
| 740 |
Result := ReadNGwordslist(FNGwordFileIndex); |
| 741 |
end; |
| 742 |
//List???茵?????茯??? |
| 743 |
procedure TAbon.GoHome(); |
| 744 |
begin |
| 745 |
FNGwordFileIndex := 0; |
| 746 |
ReadNGwordslist(FNGwordFileIndex); |
| 747 |
end; |
| 748 |
//List??ine茵?????茯??? |
| 749 |
function TAbon.ReadNGwordslist(line : Integer) : Boolean; |
| 750 |
var |
| 751 |
liststl : TStringList; |
| 752 |
linebuf : String; |
| 753 |
begin |
| 754 |
liststl := TStringList.Create; |
| 755 |
try |
| 756 |
if LoadListFile(Flistpath,liststl) = true then begin |
| 757 |
if line < 0 then begin |
| 758 |
line := liststl.Count - 1; |
| 759 |
FNGwordFileIndex := liststl.Count - 1; |
| 760 |
end else if line > liststl.Count - 1 then begin |
| 761 |
line := 0; |
| 762 |
FNGwordFileIndex := 0; |
| 763 |
end; |
| 764 |
linebuf := liststl.Strings[line]; |
| 765 |
FNGwordname := Copy(linebuf,1,AnsiPos('=',linebuf)-1); |
| 766 |
Delete(linebuf,1,AnsiPos('=',linebuf)); |
| 767 |
SetNGwordpath(linebuf); |
| 768 |
Result := true; |
| 769 |
end else begin |
| 770 |
Result := false; |
| 771 |
end |
| 772 |
finally |
| 773 |
liststl.Free; |
| 774 |
end; |
| 775 |
|
| 776 |
end; |
| 777 |
//茲??違??G???若???????鴻????茯??粋昭??=====?????障??================================ |
| 778 |
//???ャ???若????絎?茵??∽??/span> |
| 779 |
procedure TAbon.IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String); |
| 780 |
var |
| 781 |
i : Integer; |
| 782 |
begin |
| 783 |
if FileExists(SetResNumFile) = true then begin |
| 784 |
if LoadFromSetResNumFile(SetResNumFile) = true then begin |
| 785 |
for i := 0 to High(FAbonRes) do begin |
| 786 |
if (FAbonRes[i].Res <= ThreadStrings.Count) and (FAbonRes[i].Res > 0) then begin |
| 787 |
if FAbonRes[i].option = 0 then begin |
| 788 |
ThreadStrings.Strings[FAbonRes[i].Res-1] := ''; |
| 789 |
end else begin |
| 790 |
ThreadStrings.Strings[FAbonRes[i].Res-1] := '???若????<>???若????<>???若????<>???若????<>'; |
| 791 |
end; |
| 792 |
end; |
| 793 |
|
| 794 |
end; |
| 795 |
end; |
| 796 |
end else begin |
| 797 |
FIndividualFileName := SetResNumFile; |
| 798 |
SetLength(FAbonRes,1); |
| 799 |
FAbonRes[0].Res := 0; |
| 800 |
FAbonRes[0].option := -1; |
| 801 |
end; |
| 802 |
end; |
| 803 |
procedure TAbon.IndividualAbon(var ResString : String; SetResNumFile : String; ResNumber : Integer); |
| 804 |
var |
| 805 |
i : Integer; |
| 806 |
begin |
| 807 |
if FileExists(SetResNumFile) = true then begin |
| 808 |
if LoadFromSetResNumFile(SetResNumFile) = true then begin |
| 809 |
for i := 0 to High(FAbonRes) do begin |
| 810 |
if FAbonRes[i].Res = ResNumber then begin |
| 811 |
if FAbonRes[i].option = 0 then begin |
| 812 |
ResString := ''; |
| 813 |
end else begin |
| 814 |
ResString := '???若????<>???若????<>???若????<>???若????<>'; |
| 815 |
end; |
| 816 |
Exit; |
| 817 |
end; |
| 818 |
end; |
| 819 |
end; |
| 820 |
end else begin |
| 821 |
FIndividualFileName := SetResNumFile; |
| 822 |
SetLength(FAbonRes,1); |
| 823 |
FAbonRes[0].Res := 0; |
| 824 |
FAbonRes[0].option := -1; |
| 825 |
end; |
| 826 |
end; |
| 827 |
|
| 828 |
//???ャ???若???????<?ゃ????粋昭?翠?∽??/span> |
| 829 |
function TAbon.LoadFromSetResNumFile(SetResNumFile : String) : Boolean; |
| 830 |
var |
| 831 |
bufStringList : TStringList; |
| 832 |
bufLine : String; |
| 833 |
i : Integer; |
| 834 |
begin |
| 835 |
bufStringList := TStringList.Create; |
| 836 |
try |
| 837 |
try |
| 838 |
bufStringList.LoadFromFile(SetResNumFile); |
| 839 |
FIndividualFileName := SetResNumFile; |
| 840 |
//腥肴?????/span> |
| 841 |
for i := bufStringList.Count-1 downto 0 do begin |
| 842 |
if bufStringList.Strings[i] = '' then begin |
| 843 |
bufStringList.Delete(i); |
| 844 |
end; |
| 845 |
end; |
| 846 |
|
| 847 |
//?<?≪??∈篆? |
| 848 |
SetLength(FAbonRes,bufStringList.Count); |
| 849 |
//篁e??/span> |
| 850 |
for i :=0 to bufStringList.Count - 1 do begin |
| 851 |
bufLine := Trim(bufStringList.Strings[i]); |
| 852 |
FAbonRes[i].Res := StrToInt(Copy(bufLine,1,AnsiPos('-',bufLine)-1)); |
| 853 |
FAbonRes[i].option := StrToInt(Copy(bufLine,AnsiPos('-',bufLine)+1,1)); |
| 854 |
end; |
| 855 |
except |
| 856 |
Result := false; |
| 857 |
Exit; |
| 858 |
end; |
| 859 |
finally |
| 860 |
bufStringList.Free; |
| 861 |
end; |
| 862 |
Result := true; |
| 863 |
end; |
| 864 |
//???ャ???若???????<?ゃ????申?? |
| 865 |
procedure TAbon.AddIndividualAbon( ResNum : Integer ; option : Integer); |
| 866 |
var |
| 867 |
IndividualFile : TStringList; |
| 868 |
linebuf : String; |
| 869 |
i : Integer; |
| 870 |
begin |
| 871 |
IndividualFile := TStringList.Create; |
| 872 |
if FAbonRes[0].Res <> 0 then begin |
| 873 |
for i := 0 to High(FAbonRes) do begin |
| 874 |
if FAbonRes[i].Res <> ResNum then begin |
| 875 |
linebuf := IntToStr(FAbonRes[i].Res) + '-' + IntToStr(FabonRes[i].option); |
| 876 |
IndividualFile.Append(linebuf); |
| 877 |
end; |
| 878 |
end; |
| 879 |
end; |
| 880 |
linebuf := IntToStr(ResNum) + '-' + IntToStr(option); |
| 881 |
IndividualFile.Append(linebuf); |
| 882 |
try |
| 883 |
IndividualFile.SaveToFile(FIndividualFileName); |
| 884 |
finally |
| 885 |
IndividualFile.Free; |
| 886 |
end; |
| 887 |
end; |
| 888 |
//???ャ???若???????<?ゃ??????????/span> |
| 889 |
procedure TAbon.DeleteIndividualAbon( ResNum : Integer); |
| 890 |
var |
| 891 |
IndividualFile : TStringList; |
| 892 |
linebuf : String; |
| 893 |
i : Integer; |
| 894 |
begin |
| 895 |
IndividualFile := TStringList.Create; |
| 896 |
if FAbonRes[0].Res <> 0 then begin |
| 897 |
for i := 0 to High(FAbonRes) do begin |
| 898 |
if FAbonRes[i].Res <> ResNum then begin |
| 899 |
linebuf := IntToStr(FAbonRes[i].Res) + '-' + IntToStr(FabonRes[i].option); |
| 900 |
IndividualFile.Append(linebuf); |
| 901 |
end; |
| 902 |
end; |
| 903 |
end; |
| 904 |
if IndividualFile.Count <> 0 then begin |
| 905 |
try |
| 906 |
IndividualFile.SaveToFile(FIndividualFileName); |
| 907 |
finally |
| 908 |
IndividualFile.Free; |
| 909 |
end; |
| 910 |
end else begin |
| 911 |
if FileExists(FIndividualFileName) = true then begin |
| 912 |
DeleteFile(FIndividualFileName); |
| 913 |
end; |
| 914 |
end; |
| 915 |
end; |
| 916 |
//???ャ???若?????????鴻???????違??菴??? |
| 917 |
function TAbon.GetAbonResCount() : Integer; |
| 918 |
var |
| 919 |
i : Integer; |
| 920 |
begin |
| 921 |
if FAbonRes[0].Res = 0 then begin |
| 922 |
Result := 0 |
| 923 |
end else begin |
| 924 |
i := High(FAbonRes); |
| 925 |
Result := i+1; |
| 926 |
end; |
| 927 |
end; |
| 928 |
//???ャ???若?????????鴻?????茵????????鴻????絖????ц??? |
| 929 |
function TAbon.GetAbonResString(Num : Integer) : String; |
| 930 |
begin |
| 931 |
if (Num <= High(FAbonRes)) and (Num >= 0) then begin |
| 932 |
Result := IntToStr(FAbonRes[Num].Res); |
| 933 |
end else begin |
| 934 |
Result := ''; |
| 935 |
end; |
| 936 |
end; |
| 937 |
//???????≪???????ゅ???/span> |
| 938 |
function TAbon.CheckIndividualAbonList(ResNum : Integer) : Boolean; |
| 939 |
var |
| 940 |
i : Integer; |
| 941 |
begin |
| 942 |
if FAbonRes[0].Res <> 0 then begin |
| 943 |
for i := 0 to High(FAbonRes) do begin |
| 944 |
if FAbonRes[i].Res = ResNum then begin |
| 945 |
Result := true; |
| 946 |
Exit; |
| 947 |
end; |
| 948 |
end; |
| 949 |
end; |
| 950 |
Result := false; |
| 951 |
|
| 952 |
end; |
| 953 |
end. |
| 954 |
|