Jonlin 6 năm trước cách đây
mục cha
commit
d3fc401abe

+ 6 - 12
application/admin/controller/Iplimit.php

@@ -61,12 +61,9 @@ class Iplimit extends Base
 
             if(strpos($param['ip'], '-') !== false){
                 $ip = explode('-',$param['ip']);
-                $param['start_ip'] = $ip[0];
-                $param['end_ip'] = $ip[1];
-                $param['ip'] = null;
-            }else{
-                $param['start_ip'] = null;
-                $param['end_ip'] = null;
+                //将ip地址转换成int型
+                $param['start_ip'] = bindec(decbin(ip2long($ip[0])));
+                $param['end_ip'] = bindec(decbin(ip2long($ip[1])));
             }
             $param['ctime'] = date('Y-m-d H:i:s',time());
             $param['utime']  = date('Y-m-d H:i:s',time());
@@ -103,12 +100,9 @@ class Iplimit extends Base
 
             if(strpos($param['ip'], '-') !== false){
                 $ip = explode('-',$param['ip']);
-                $param['start_ip'] = $ip[0];
-                $param['end_ip'] = $ip[1];
-                $param['ip'] = null;
-            }else{
-                $param['start_ip'] = null;
-                $param['end_ip'] = null;
+                //将ip地址转换成int型
+                $param['start_ip'] = bindec(decbin(ip2long($ip[0])));
+                $param['end_ip'] = bindec(decbin(ip2long($ip[1])));
             }
             $param['ctime'] = date('Y-m-d H:i:s',time());
             $param['utime']  = date('Y-m-d H:i:s',time());

+ 4 - 2
application/admin/controller/Material.php

@@ -47,7 +47,7 @@ class Material extends Base
         }
 
         //所有素材
-        $material = db('material')->select();
+        $material = db('material')->order('name', 'asc')->select();
         $allmaterial = '';
         if(!empty($material)){
             $allmaterial = '<div style="margin-top: 20px;">';
@@ -114,7 +114,9 @@ class Material extends Base
             $name = './'.$material['url'];
 //            $name = iconv("UTF-8", "gbk",$name);
             try{
-                unlink($name);
+                if (file_exists($name)) {
+                    unlink($name);
+                }
                 db('material')->where('id', $id)->delete();
             }catch(\Exception $e){
                 return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);

+ 5 - 2
application/index/controller/Register.php

@@ -101,9 +101,12 @@ class Register extends Common
         //验证用户IP
         @$ip = ($_SERVER["HTTP_VIA"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : $_SERVER["REMOTE_ADDR"];
         $ip = ($ip) ? $ip : $_SERVER["REMOTE_ADDR"];
+        //将ip地址转换成int型
+        $intip = bindec(decbin(ip2long($ip)));
+        //return $ip.$intip;
         $res = db('iplimit')->where('ip',$ip)->where('object',1)->find();
-        //$result = db('iplimit')->where('start_ip','<=',$ip)->where('end_ip','>=',$ip)->where('object',1)->find();
-        if(!empty($res)){
+        $result = db('iplimit')->where('start_ip','<=',$intip)->where('end_ip','>=',$intip)->where('object',1)->find();
+        if(!empty($res) || !empty($result)){
             return json(['code' => 0, 'data' => [], 'msg' => 'ip禁止登陆']);
         }