Browse Source

v2.1

dev v2.1
xiaoz 6 years ago
parent
commit
28ef7e5304
  1. 5
      application/controllers/Admin.php
  2. 42
      application/controllers/Deal.php
  3. 13
      application/controllers/Install.php
  4. 23
      application/controllers/User.php
  5. 50
      application/libraries/Image.php
  6. 11
      application/models/Update.php
  7. 2
      application/views/admin/header.php
  8. 10
      application/views/user/img.php
  9. 2
      application/views/user/install3.php
  10. 24
      application/views/user/resetpass.php
  11. 2
      data/version.txt
  12. 19
      static/embed.js

5
application/controllers/Admin.php

@ -9,11 +9,14 @@ @@ -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(){

42
application/controllers/Deal.php

@ -195,5 +195,47 @@ @@ -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("更新失败,未知错误!");
}
}
}
}
}
?>

13
application/controllers/Install.php

@ -87,7 +87,7 @@ @@ -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 @@ @@ -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 @@ @@ -265,9 +268,5 @@
exit;
}
}
public function test(){
echo $this->get_domain();
}
}
?>

23
application/controllers/User.php

@ -87,5 +87,28 @@ @@ -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');
}
}
}
?>

50
application/libraries/Image.php

@ -3,6 +3,13 @@ @@ -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 @@ @@ -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){

11
application/models/Update.php

@ -81,6 +81,17 @@ @@ -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;
}
}
}
?>

2
application/views/admin/header.php

@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
<?php echo $_COOKIE['user']; ?>
</a>
<dl class="layui-nav-child">
<dd><a href="">修改密码</a></dd>
<dd><a href="/user/resetpass">修改密码</a></dd>
</dl>
</li>
<li class="layui-nav-item"><a href="/user/logout">退出</a></li>

10
application/views/user/img.php

@ -22,7 +22,15 @@ @@ -22,7 +22,15 @@
</div>
<!-- 评论按钮 -->
<div id="comments">
<!--存在评论就加载 -->
<?php
//评论代码路径
$com_file = FCPATH.'application/views/user/comment.html';
if(file_exists($com_file)){
$comment = file_get_contents($com_file);
echo $comment;
}
?>
</div>
<!-- 评论按钮END -->
</div>

2
application/views/user/install3.php

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

24
application/views/user/resetpass.php

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
<!-- 内容部分 -->
<div id="container">
<div class="layui-container">
<div class="layui-row">
<div class="layui-col-lg4 layui-col-md-offset4">
<!-- 登录表单 -->
<div class="login">
<h2 style = "padding-bottom:0.6em;color:#FFFFFF;">当前用户名为: <code style = "color:#FF5722;"><?php echo $username; ?></code>,请设置新密码。</h2>
<div class="layui-form-item">
<input id = "password1" type="password" required lay-verify="required" placeholder="设置新密码" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-item">
<input id = "password2" type="password" name="password" required lay-verify="required" placeholder="确认新密码" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-item">
<button class="layui-btn" lay-submit lay-filter="formDemo" onclick = "resetpass()">设置密码</button>
</div>
</div>
<!-- 登录表单END -->
</div>
</div>
</div>
</div>
<!-- 内容部分end -->

2
data/version.txt

@ -1 +1 @@ @@ -1 +1 @@
v2.01-20190314
v2.1-20190318

19
static/embed.js

@ -18,7 +18,9 @@ layui.use(['upload','form','element','layer','flow'], function(){ @@ -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){ @@ -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);
});
}
}
Loading…
Cancel
Save