Răsfoiți Sursa

1,修复传入内容为空时随机插入语句的问题。
2,其他细节。

magicblack 5 ani în urmă
părinte
comite
57909e15a2

+ 29 - 16
application/common.php

@@ -864,26 +864,39 @@ function mac_interface_type()
 
 function mac_rep_pse_rnd($psearr,$txt,$id=0)
 {
-    if(empty($txt)){ $txt=""; }
-    if(empty($id)){
-        $id = crc32($txt);
+    if(empty($psearr)){
+        return $txt;
     }
     $i=count($psearr);
-    $j=mb_strpos($txt,"<br>");
-    $k=mb_strlen($txt);
-    if ($j==0){ $j=mb_strpos($txt,"<br/>"); }
-    if ($j==0){ $j=mb_strpos($txt,"<br />"); }
-    if ($j==0){ $j=mb_strpos($txt,"</p>"); }
-    if ($j==0){ $j=mb_strpos($txt,"。");}
-    if ($j==0){ $j=mb_strpos($txt,"!");}
-    if ($j==0){ $j=mb_strpos($txt,"!");}
-    if ($j==0){ $j=mb_strpos($txt,"?");}
-    if ($j==0){ $j=mb_strpos($txt,"?");}
-    if ($j>0){
-        $res= mac_substring($txt,$j-1) . $psearr[$id % $i] . mac_substring($txt,$k-$j,$j);
+    if(empty($txt)){
+        if(empty($id)){
+            $r = mt_rand(0,$i-1);
+        }
+        else{
+            $r = $id % $i;
+        }
+        $res= $psearr[$r];
     }
     else{
-        $res= $psearr[$id % $i]. $txt;
+        if(empty($id)){
+            $id = crc32($txt);
+        }
+        $j=mb_strpos($txt,"<br>");
+        $k=mb_strlen($txt);
+        if($j==0){ $j=mb_strpos($txt,"<br/>"); }
+        if($j==0){ $j=mb_strpos($txt,"<br />"); }
+        if($j==0){ $j=mb_strpos($txt,"</p>"); }
+        if($j==0){ $j=mb_strpos($txt,"。"); }
+        if($j==0){ $j=mb_strpos($txt,"!"); }
+        if($j==0){ $j=mb_strpos($txt,"!"); }
+        if($j==0){ $j=mb_strpos($txt,"?"); }
+        if($j==0){ $j=mb_strpos($txt,"?"); }
+        if($j>0){
+            $res= mac_substring($txt,$j-1) . $psearr[$id % $i] . mac_substring($txt,$k-$j,$j);
+        }
+        else{
+            $res= $psearr[$id % $i]. $txt;
+        }
     }
     return $res;
 }

+ 1 - 1
application/extra/version.php

@@ -3,7 +3,7 @@ return array (
     'name' => '苹果CMS内容管理系统',
     'copyright' => 'MacCMS',
     'url' => '//github.com/magicblack',
-    'code' => '2020.1000.1057',
+    'code' => '2020.1000.1058',
     'license' => '免费版',
 );
 ?>

+ 0 - 5
application/index/controller/Index.php

@@ -13,9 +13,4 @@ class Index extends Base
         return $this->label_fetch('index/index');
     }
 
-    public function test()
-    {
-
-    }
-
 }