Skip to content

Commit 28ef7e5

Browse files
committed
v2.1
1 parent a0e8c19 commit 28ef7e5

File tree

12 files changed

+183
-20
lines changed

12 files changed

+183
-20
lines changed

application/controllers/Admin.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ public function __construct(){
99
$this->load->model('query','',TRUE);
1010
//加载辅助函数
1111
$this->load->helper('basic');
12+
//加载常用类
13+
$this->load->library('basic');
1214
$info = $this->query->userinfo()->values;
1315
$info = json_decode($info);
1416

1517
//验证用户是否登录
16-
is_login($info->username,$info->password);
18+
$this->basic->is_login(TRUE);
19+
//is_login($info->username,$info->password);
1720
}
1821
//后台首页
1922
public function index(){

application/controllers/Deal.php

+42
Original file line numberDiff line numberDiff line change
@@ -195,5 +195,47 @@ protected function suc_msg($msg){
195195
$arr = json_encode($arr);
196196
echo $arr;
197197
}
198+
//重置密码
199+
public function resetpass(){
200+
$password1 = $this->input->post('password1', TRUE);
201+
$password2 = $this->input->post('password2', TRUE);
202+
//验证文件路径
203+
$pass_txt = FCPATH."data/password.txt";
204+
if(!file_exists($pass_txt)){
205+
$this->err_msg("没有权限,请参考帮助文档操作!");
206+
}
207+
else{
208+
$pattern = '/^[a-zA-Z0-9!@#$%^&*.]+$/';
209+
if($password1 != $password2){
210+
$this->err_msg("两次密码不一致!");
211+
}
212+
else if(!preg_match($pattern,$password2)){
213+
$this->err_msg("密码格式有误!");
214+
exit;
215+
}
216+
else{
217+
//进行密码重置
218+
$password = md5($password2.'imgurl');
219+
220+
//加载数据库模型
221+
$this->load->model('query','',TRUE);
222+
$this->load->model('update','',TRUE);
223+
//查询用户信息
224+
$userinfo = $this->query->userinfo()->values;
225+
$userinfo = json_decode($userinfo);
226+
$userinfo->password = $password;
227+
$values = json_encode($userinfo);
228+
//更新数据库
229+
if($this->update->password($values)){
230+
//删除验证文件
231+
unlink($pass_txt);
232+
$this->suc_msg("密码已重置,请重新登录。");
233+
}
234+
else{
235+
$this->err_msg("更新失败,未知错误!");
236+
}
237+
}
238+
}
239+
}
198240
}
199241
?>

application/controllers/Install.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function check($type){
8787
//imagick
8888
$env['imagick'] = array(
8989
"name" => 'ImageMagick',
90-
"requir" => '必须支持',
90+
"requir" => '可选',
9191
"info" => array_search('imagick',$ext) ? 'Yes':'No',
9292
"result" => array_search('imagick',$ext) ? $yes : $no
9393
);
@@ -116,8 +116,11 @@ protected function check($type){
116116
if($type == 'part'){
117117
//检测不通过
118118
foreach($env as $value){
119-
//echo $value['result'];
120-
if($value['result'] == $no){
119+
//当检测到ImageMagick的时候直接让其通过
120+
if($value['name'] == 'ImageMagick'){
121+
122+
}
123+
elseif($value['result'] == $no){
121124
return FALSE;
122125
exit;
123126
}
@@ -265,9 +268,5 @@ protected function is_install(){
265268
exit;
266269
}
267270
}
268-
public function test(){
269-
echo $this->get_domain();
270-
271-
}
272271
}
273272
?>

application/controllers/User.php

+23
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,28 @@ protected function err_msg($msg){
8787
$data = json_encode($data);
8888
echo $data;
8989
}
90+
//重置密码
91+
public function resetpass(){
92+
//加载数据库模型
93+
$this->load->model('query','',TRUE);
94+
//查询站点信息
95+
$siteinfo = $this->query->site_setting('1');
96+
$siteinfo->title = '重置密码 - '.$siteinfo->title;
97+
//查询用户信息
98+
$userinfo = $this->query->userinfo()->values;
99+
$userinfo = json_decode($userinfo);
100+
//$userinfo = $userinfo['userinfo'];
101+
$siteinfo->username = $userinfo->username;
102+
//验证文件路径
103+
$pass_txt = FCPATH."data/password.txt";
104+
if(!file_exists($pass_txt)){
105+
echo "没有权限,请参考帮助文档重置密码!";
106+
}
107+
else{
108+
$this->load->view('user/header.php',$siteinfo);
109+
$this->load->view('user/resetpass.php');
110+
$this->load->view('user/footer.php');
111+
}
112+
}
90113
}
91114
?>

application/libraries/Image.php

+43-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
defined('BASEPATH') OR exit('No direct script access allowed');
44

55
class Image{
6+
protected $CI;
7+
8+
//构造函数
9+
public function __construct(){
10+
//附属类,让其可以访问CI的资源
11+
$this->CI = & get_instance();
12+
}
613
public function thumbnail($source,$width,$height){
714
//获取缩略图名称
815
$source = str_replace("\\","/",$source);
@@ -23,19 +30,48 @@ public function thumbnail($source,$width,$height){
2330
$dirname = dirname($source); //获取的路径最后没有/
2431
//缩略图完整路径
2532
$thumbnail_full = $dirname.'/'.$thumbnail_name;
26-
$image = new Imagick($source);
2733
// 创建缩略图
2834
//原图宽高大于缩略图
2935
if(($img_w > $width) || ($img_h > $height)){
30-
//$image->setImageCompressionQuality(90);
31-
$image->cropThumbnailImage( $width, $height );
36+
//检测是否支持ImageMagick
37+
if($this->check()){
38+
//使用ImageMagick裁剪图像
39+
$image = new Imagick($source);
40+
$image->cropThumbnailImage( $width, $height );
41+
//将缩略图输出到文件
42+
$image->writeImage( $thumbnail_full );
43+
//清理工作
44+
$image->clear();
45+
}
46+
//不支持ImageMagick,使用GD2进行裁剪
47+
else{
48+
//配置裁剪参数,参考:https://codeigniter.org.cn/user_guide/libraries/image_lib.html
49+
$config['image_library'] = 'gd2';
50+
$config['source_image'] = $source;
51+
$config['create_thumb'] = TRUE;
52+
$config['maintain_ratio'] = TRUE;
53+
$config['width'] = $width;
54+
$config['height'] = $height;
55+
$this->CI->load->library('image_lib', $config);
56+
$this->CI->image_lib->resize();
57+
}
58+
3259
}
3360

34-
//将缩略图输出到文件
35-
$image->writeImage( $thumbnail_full );
3661

37-
//清理工作
38-
$image->clear();
62+
63+
64+
}
65+
//检测是否支持ImageMagick
66+
protected function check(){
67+
$ext = get_loaded_extensions();
68+
//如果已经安装ImageMagick
69+
if(array_search('imagick',$ext)){
70+
return TRUE;
71+
}
72+
else{
73+
return FALSE;
74+
}
3975
}
4076
//压缩图片
4177
public function compress($source){

application/models/Update.php

+11
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ public function storage($data,$engine){
8181
return FALSE;
8282
}
8383
}
84+
//更新密码
85+
public function password($values){
86+
$sql = "UPDATE img_options SET `values` = '{$values}' WHERE `name` = 'userinfo'";
87+
$query = $this->db->query($sql);
88+
if($query){
89+
return TRUE;
90+
}
91+
else{
92+
return FALSE;
93+
}
94+
}
8495

8596
}
8697
?>

application/views/admin/header.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<?php echo $_COOKIE['user']; ?>
4242
</a>
4343
<dl class="layui-nav-child">
44-
<dd><a href="">修改密码</a></dd>
44+
<dd><a href="/user/resetpass">修改密码</a></dd>
4545
</dl>
4646
</li>
4747
<li class="layui-nav-item"><a href="/user/logout">退出</a></li>

application/views/user/img.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@
2222
</div>
2323
<!-- 评论按钮 -->
2424
<div id="comments">
25-
25+
<!--存在评论就加载 -->
26+
<?php
27+
//评论代码路径
28+
$com_file = FCPATH.'application/views/user/comment.html';
29+
if(file_exists($com_file)){
30+
$comment = file_get_contents($com_file);
31+
echo $comment;
32+
}
33+
?>
2634
</div>
2735
<!-- 评论按钮END -->
2836
</div>

application/views/user/install3.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<div class="layui-btn-group">
88
<a href="/" class="layui-btn">返回首页</a>
99
<a href="/user/login" class="layui-btn">登录后台</a>
10-
<a class="layui-btn" href="https://doc.xiaoz.me/#/imgurl/">查看帮助文档</a>
10+
<a class="layui-btn" href="https://doc.xiaoz.me/#/imgurl2/">查看帮助文档</a>
1111
<a class="layui-btn" href="https://dwz.ovh/imgurl" rel = "nofollow" target = "_blank">打赏支持</a>
1212
</div>
1313
</div>

application/views/user/resetpass.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!-- 内容部分 -->
2+
<div id="container">
3+
<div class="layui-container">
4+
<div class="layui-row">
5+
<div class="layui-col-lg4 layui-col-md-offset4">
6+
<!-- 登录表单 -->
7+
<div class="login">
8+
<h2 style = "padding-bottom:0.6em;color:#FFFFFF;">当前用户名为: <code style = "color:#FF5722;"><?php echo $username; ?></code>,请设置新密码。</h2>
9+
<div class="layui-form-item">
10+
<input id = "password1" type="password" required lay-verify="required" placeholder="设置新密码" autocomplete="off" class="layui-input">
11+
</div>
12+
<div class="layui-form-item">
13+
<input id = "password2" type="password" name="password" required lay-verify="required" placeholder="确认新密码" autocomplete="off" class="layui-input">
14+
</div>
15+
<div class="layui-form-item">
16+
<button class="layui-btn" lay-submit lay-filter="formDemo" onclick = "resetpass()">设置密码</button>
17+
</div>
18+
</div>
19+
<!-- 登录表单END -->
20+
</div>
21+
</div>
22+
</div>
23+
</div>
24+
<!-- 内容部分end -->

data/version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.01-20190314
1+
v2.1-20190318

static/embed.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ layui.use(['upload','form','element','layer','flow'], function(){
1818
var storage = $('#storage input[name="storage"]:checked ').val();
1919
//图片懒加载
2020
var flow = layui.flow;
21-
flow.lazyimg();
21+
flow.lazyimg({
22+
elem:'#found img'
23+
});
2224
//图片查看器
2325
layer.photos({
2426
photos: '#found'
@@ -213,4 +215,19 @@ function identify(id){
213215
console.log(re.code);
214216
}
215217
});
218+
}
219+
//重置密码
220+
function resetpass(){
221+
var password1 = $("#password1").val();
222+
var password2 = $("#password2").val();
223+
224+
if(password1 != password2){
225+
layer.msg("两次密码不一致!");
226+
}
227+
else if(password1 == password2){
228+
$.post("/deal/resetpass",{password1:password1,password2:password2},function(data,status){
229+
var re = JSON.parse(data);
230+
layer.msg(re.msg);
231+
});
232+
}
216233
}

0 commit comments

Comments
 (0)