pengchanglu пре 3 година
родитељ
комит
ffc741a7c5
2 измењених фајлова са 12 додато и 2 уклоњено
  1. 5 2
      application/common.php
  2. 7 0
      application/index/controller/Index.php

+ 5 - 2
application/common.php

@@ -527,7 +527,7 @@ EOT;
                 $j = $j == 32 ? 0 : $j;
                 $tmp .= $mixStr[$j].($str[$i] ^ $mixStr[$j]);
             }
-            return base64_encode($key.$tmp);
+            return base64_encode($tmp.$key);
         }
     }
     if (!function_exists('decrypt')) {
@@ -540,7 +540,10 @@ EOT;
         function decrypt($str, $key = 'pig')
         {
             $str = base64_decode($str);
-            $str = substr($str, strLen($key));
+            if (!strpos($str, $key)) {
+                return '';
+            }
+            $str = substr($str, 0, -strLen($key));
             $strLen = strlen($str);
             $tmp = '';
             for ($i=0; $i<$strLen; $i++) {

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

@@ -29,6 +29,9 @@ class Index extends Frontend
             exit;
         }
         $id = intval(decrypt($code));
+        if (!$id) {
+            $this->error("参数错误!!");
+        }
         //$id = 1;
         echo $id;
         $code = new Code();
@@ -84,6 +87,10 @@ class Index extends Frontend
             exit;
         }
         $id = intval(decrypt($id));
+        if (!$id) {
+            $this->error("参数错误!!");
+            exit;
+        }
 
         $company = new Company();
         $companyinfo = $company->find($id);