diff --git a/application/controllers/Admin.php b/application/controllers/Admin.php index 89d5f64..5c2dcdf 100644 --- a/application/controllers/Admin.php +++ b/application/controllers/Admin.php @@ -9,11 +9,14 @@ $this->load->model('query','',TRUE); //加载辅助函数 $this->load->helper('basic'); + //加载常用类 + $this->load->library('basic'); $info = $this->query->userinfo()->values; $info = json_decode($info); //验证用户是否登录 - is_login($info->username,$info->password); + $this->basic->is_login(TRUE); + //is_login($info->username,$info->password); } //后台首页 public function index(){ diff --git a/application/controllers/Deal.php b/application/controllers/Deal.php index 3cbccfc..4e9a22a 100644 --- a/application/controllers/Deal.php +++ b/application/controllers/Deal.php @@ -195,5 +195,47 @@ $arr = json_encode($arr); echo $arr; } + //重置密码 + public function resetpass(){ + $password1 = $this->input->post('password1', TRUE); + $password2 = $this->input->post('password2', TRUE); + //验证文件路径 + $pass_txt = FCPATH."data/password.txt"; + if(!file_exists($pass_txt)){ + $this->err_msg("没有权限,请参考帮助文档操作!"); + } + else{ + $pattern = '/^[a-zA-Z0-9!@#$%^&*.]+$/'; + if($password1 != $password2){ + $this->err_msg("两次密码不一致!"); + } + else if(!preg_match($pattern,$password2)){ + $this->err_msg("密码格式有误!"); + exit; + } + else{ + //进行密码重置 + $password = md5($password2.'imgurl'); + + //加载数据库模型 + $this->load->model('query','',TRUE); + $this->load->model('update','',TRUE); + //查询用户信息 + $userinfo = $this->query->userinfo()->values; + $userinfo = json_decode($userinfo); + $userinfo->password = $password; + $values = json_encode($userinfo); + //更新数据库 + if($this->update->password($values)){ + //删除验证文件 + unlink($pass_txt); + $this->suc_msg("密码已重置,请重新登录。"); + } + else{ + $this->err_msg("更新失败,未知错误!"); + } + } + } + } } ?> \ No newline at end of file diff --git a/application/controllers/Install.php b/application/controllers/Install.php index 110fd0d..e75db1c 100644 --- a/application/controllers/Install.php +++ b/application/controllers/Install.php @@ -87,7 +87,7 @@ //imagick $env['imagick'] = array( "name" => 'ImageMagick', - "requir" => '必须支持', + "requir" => '可选', "info" => array_search('imagick',$ext) ? 'Yes':'No', "result" => array_search('imagick',$ext) ? $yes : $no ); @@ -116,8 +116,11 @@ if($type == 'part'){ //检测不通过 foreach($env as $value){ - //echo $value['result']; - if($value['result'] == $no){ + //当检测到ImageMagick的时候直接让其通过 + if($value['name'] == 'ImageMagick'){ + + } + elseif($value['result'] == $no){ return FALSE; exit; } @@ -265,9 +268,5 @@ exit; } } - public function test(){ - echo $this->get_domain(); - - } } ?> \ No newline at end of file diff --git a/application/controllers/User.php b/application/controllers/User.php index 598ac91..25b8629 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -87,5 +87,28 @@ $data = json_encode($data); echo $data; } + //重置密码 + public function resetpass(){ + //加载数据库模型 + $this->load->model('query','',TRUE); + //查询站点信息 + $siteinfo = $this->query->site_setting('1'); + $siteinfo->title = '重置密码 - '.$siteinfo->title; + //查询用户信息 + $userinfo = $this->query->userinfo()->values; + $userinfo = json_decode($userinfo); + //$userinfo = $userinfo['userinfo']; + $siteinfo->username = $userinfo->username; + //验证文件路径 + $pass_txt = FCPATH."data/password.txt"; + if(!file_exists($pass_txt)){ + echo "没有权限,请参考帮助文档重置密码!"; + } + else{ + $this->load->view('user/header.php',$siteinfo); + $this->load->view('user/resetpass.php'); + $this->load->view('user/footer.php'); + } + } } ?> \ No newline at end of file diff --git a/application/libraries/Image.php b/application/libraries/Image.php index 23f283a..7e2b0cd 100644 --- a/application/libraries/Image.php +++ b/application/libraries/Image.php @@ -3,6 +3,13 @@ defined('BASEPATH') OR exit('No direct script access allowed'); class Image{ + protected $CI; + + //构造函数 + public function __construct(){ + //附属类,让其可以访问CI的资源 + $this->CI = & get_instance(); + } public function thumbnail($source,$width,$height){ //获取缩略图名称 $source = str_replace("\\","/",$source); @@ -23,19 +30,48 @@ $dirname = dirname($source); //获取的路径最后没有/ //缩略图完整路径 $thumbnail_full = $dirname.'/'.$thumbnail_name; - $image = new Imagick($source); // 创建缩略图 //原图宽高大于缩略图 if(($img_w > $width) || ($img_h > $height)){ - //$image->setImageCompressionQuality(90); - $image->cropThumbnailImage( $width, $height ); + //检测是否支持ImageMagick + if($this->check()){ + //使用ImageMagick裁剪图像 + $image = new Imagick($source); + $image->cropThumbnailImage( $width, $height ); + //将缩略图输出到文件 + $image->writeImage( $thumbnail_full ); + //清理工作 + $image->clear(); + } + //不支持ImageMagick,使用GD2进行裁剪 + else{ + //配置裁剪参数,参考:https://codeigniter.org.cn/user_guide/libraries/image_lib.html + $config['image_library'] = 'gd2'; + $config['source_image'] = $source; + $config['create_thumb'] = TRUE; + $config['maintain_ratio'] = TRUE; + $config['width'] = $width; + $config['height'] = $height; + $this->CI->load->library('image_lib', $config); + $this->CI->image_lib->resize(); + } + } - //将缩略图输出到文件 - $image->writeImage( $thumbnail_full ); - //清理工作 - $image->clear(); + + + } + //检测是否支持ImageMagick + protected function check(){ + $ext = get_loaded_extensions(); + //如果已经安装ImageMagick + if(array_search('imagick',$ext)){ + return TRUE; + } + else{ + return FALSE; + } } //压缩图片 public function compress($source){ diff --git a/application/models/Update.php b/application/models/Update.php index 65488ee..d2f371e 100644 --- a/application/models/Update.php +++ b/application/models/Update.php @@ -81,6 +81,17 @@ return FALSE; } } + //更新密码 + public function password($values){ + $sql = "UPDATE img_options SET `values` = '{$values}' WHERE `name` = 'userinfo'"; + $query = $this->db->query($sql); + if($query){ + return TRUE; + } + else{ + return FALSE; + } + } } ?> \ No newline at end of file diff --git a/application/views/admin/header.php b/application/views/admin/header.php index d1d0422..bf3fcc7 100644 --- a/application/views/admin/header.php +++ b/application/views/admin/header.php @@ -41,7 +41,7 @@
-
修改密码
+
修改密码
  • 退出
  • diff --git a/application/views/user/img.php b/application/views/user/img.php index eeeaa40..73ca47b 100644 --- a/application/views/user/img.php +++ b/application/views/user/img.php @@ -22,7 +22,15 @@
    - + +
    diff --git a/application/views/user/install3.php b/application/views/user/install3.php index 10a1e08..e8a2ae4 100644 --- a/application/views/user/install3.php +++ b/application/views/user/install3.php @@ -7,7 +7,7 @@
    返回首页 登录后台 - 查看帮助文档 + 查看帮助文档 打赏支持
    diff --git a/application/views/user/resetpass.php b/application/views/user/resetpass.php new file mode 100644 index 0000000..a0cb754 --- /dev/null +++ b/application/views/user/resetpass.php @@ -0,0 +1,24 @@ + +
    +
    +
    +
    + + + +
    +
    +
    +
    + \ No newline at end of file diff --git a/data/version.txt b/data/version.txt index 127aab2..fb353c2 100644 --- a/data/version.txt +++ b/data/version.txt @@ -1 +1 @@ -v2.01-20190314 \ No newline at end of file +v2.1-20190318 \ No newline at end of file diff --git a/static/embed.js b/static/embed.js index 50b076f..a98505b 100644 --- a/static/embed.js +++ b/static/embed.js @@ -18,7 +18,9 @@ layui.use(['upload','form','element','layer','flow'], function(){ var storage = $('#storage input[name="storage"]:checked ').val(); //图片懒加载 var flow = layui.flow; - flow.lazyimg(); + flow.lazyimg({ + elem:'#found img' + }); //图片查看器 layer.photos({ photos: '#found' @@ -213,4 +215,19 @@ function identify(id){ console.log(re.code); } }); +} +//重置密码 +function resetpass(){ + var password1 = $("#password1").val(); + var password2 = $("#password2").val(); + + if(password1 != password2){ + layer.msg("两次密码不一致!"); + } + else if(password1 == password2){ + $.post("/deal/resetpass",{password1:password1,password2:password2},function(data,status){ + var re = JSON.parse(data); + layer.msg(re.msg); + }); + } } \ No newline at end of file