OSDN Git Service

エラー表示を訂正
authoryamat0jp <terukohietori@gmail.com>
Fri, 10 Jan 2020 23:16:45 +0000 (08:16 +0900)
committeryamat0jp <terukohietori@gmail.com>
Fri, 10 Jan 2020 23:16:45 +0000 (08:16 +0900)
設定レコードにフィールドを追加

Unit1.dfm
Unit1.pas
WebModuleUnit1.pas

index 9fa646d..061c926 100644 (file)
--- a/Unit1.dfm
+++ b/Unit1.dfm
@@ -118,6 +118,10 @@ object DataModule1: TDataModule1
       FieldName = 'password'
       Size = 100
     end
+    object FDTable3ng: TWideStringField
+      FieldName = 'ng'
+      Size = 300
+    end
   end
   object FDGUIxWaitCursor1: TFDGUIxWaitCursor
     Provider = 'Forms'
index e0aa29c..1e2df4f 100644 (file)
--- a/Unit1.pas
+++ b/Unit1.pas
@@ -47,6 +47,7 @@ type
     FDTable1DATABASE: TWideStringField;
     FDQuery1: TFDQuery;
     FDTable3password: TWideStringField;
+    FDTable3ng: TWideStringField;
   private
     { Private \90é\8c¾ }
   public
index fb49fbd..4ebcafe 100644 (file)
@@ -108,6 +108,7 @@ type
     ss: TStringList;
     tagstr: string;
     procedure pages(count: Integer; var page: Integer);
+    procedure strsCheck(var error: string; var list: TStringList);
     function isInfo: Boolean;
     function loginCheck: Boolean;
     function hash(str: string): string;
@@ -548,6 +549,29 @@ begin
     ReplaceText := css2.Content;
 end;
 
+procedure TWebModule1.strsCheck(var error: string; var list: TStringList);
+var
+  s: TStringList;
+  i, j: Integer;
+  x: Boolean;
+begin
+  s := TStringList.Create;
+  try
+    s.DelimitedText := DataModule1.FDTable3.FieldByName('ng').AsString;
+    for i := 0 to s.count - 1 do
+      for j := 0 to list.count - 1 do
+      begin
+        if Pos(s[i], list[j]) > 0 then
+          x := true;
+        list[j] := '<p>' + list[j];
+      end;
+  finally
+    s.Free;
+  end;
+  if x = true then
+    error := error + '<p>\8bÖ\8e~\8cê\8bå\82ª\8aÜ\82Ü\82ê\82Ä\82¢\82Ü\82·.';
+end;
+
 procedure TWebModule1.tiHTMLTag(Sender: TObject; Tag: TTag;
   const TagString: string; TagParams: TStrings; var ReplaceText: string);
 begin
@@ -1015,7 +1039,6 @@ var
   title, na, raw, pass, kotoba, error: string;
   s: string;
   comment: TStringList;
-  x: Boolean;
   function scan(Text: string): string;
   var
     reg: TRegEx;
@@ -1080,25 +1103,16 @@ begin
   comment := TStringList.Create;
   try
     comment.Text := raw;
-    for i := 0 to comment.count - 1 do
-    begin
-      if Pos('ng', comment[i]) > 0 then
-      begin
-        error := error + '<p>\8bÖ\8e~\8cê\8bå\82ª\8aÜ\82Ü\82ê\82Ä\82¢\82Ü\82·.';
-        break;
-      end;
-      comment[i] := '<p>' + scan(comment[i]);
-    end;
-    x := Request.ContentFields.Values['show'] = 'true';
+    strsCheck(error, comment);
+    Request.ContentFields.Values['show'] := 'false';
+    Request.ContentFields.Values['raw'] := raw;
     if error <> '' then
-      error := error + '</section>'
-    else if x = true then
+      Request.ContentFields.Values['preview'] := error + '</section>'
+    else if Request.ContentFields.Values['show'] = 'true' then
     begin
       error := '<p style=font-size:2.3em;color:blue>\81«\81«\83v\83\8c\83r\83\85\81[\81«\81«<p>' +
         comment.Text;
-      Request.ContentFields.Values['show'] := 'false';
       Request.ContentFields.Values['preview'] := error;
-      Request.ContentFields.Values['raw'] := raw;
     end
     else
     begin
@@ -1152,6 +1166,7 @@ procedure TWebModule1.WebModuleCreate(Sender: TObject);
 var
   i: Integer;
   a: Variant;
+  s: string;
 begin
   with DataModule1 do
   begin
@@ -1183,10 +1198,11 @@ begin
   if DataModule1.FDTable3.Bof and DataModule1.FDTable3.Eof then
   begin
     a := DataModule1.FDTable1.Lookup('database', 'info', 'dbnum');
+    s := '\88¢\95Û,\94n\8e­,\8e\80\82Ë';
     DataModule1.FDTable3.AppendRecord
       (['\82Æ\82é\82Ë\81`\82Ç\8d\86',
       '<h1 style=color:maron;text-align:center;font-style:italic>\82Æ\82é\82Ë\81`\82Ç\8d\86</h1>',
-      false, a, 30, hash(hash('admin'))]);
+      false, a, 30, hash(hash('admin')), s]);
   end;
 end;