Update
2015-10-06
This commit is contained in:
56
Application/User/Controller/ChangeController.class.php
Normal file
56
Application/User/Controller/ChangeController.class.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace User\Controller;
|
||||
use Think\Controller;
|
||||
|
||||
/**
|
||||
* @author Zhou Yuyang <1009465756@qq.com> 2015-08-03
|
||||
* @copyright ©2105-2018 SRCMS
|
||||
* @homepage http://www.src.pw
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
class ChangeController extends BaseController{
|
||||
/**
|
||||
* 显示更改密码页面
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码流程
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
//验证请求方式
|
||||
if(!IS_POST)$this->error("非法请求");
|
||||
$member = M('member');
|
||||
$id = session('userId');
|
||||
$oldpassword =I('post.oldpassword','','md5');
|
||||
$password =I('post.password','','md5');
|
||||
|
||||
//验证原密码
|
||||
$user = $member->where(array('id'=>$id,'password'=>$oldpassword))->find();
|
||||
|
||||
if(!$user) {
|
||||
$this->error('邮箱不存在 :(') ;
|
||||
}
|
||||
|
||||
//验证账户是否管理员
|
||||
if($user['type'] == 2){
|
||||
$this->error('前台无法修改管理员密码 :(') ;
|
||||
}
|
||||
|
||||
|
||||
$member-> password=$password;
|
||||
$result = $member->where(array('id'=>$id,'password'=>$oldpassword))->save();
|
||||
if($result){
|
||||
$this->success("修改成功",U('login/logout'));
|
||||
}else{
|
||||
$this->error('修改失败 :(') ;
|
||||
}
|
||||
}
|
||||
}
|
||||
60
Application/User/Controller/ForgetController.class.php
Normal file
60
Application/User/Controller/ForgetController.class.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
namespace User\Controller;
|
||||
use Think\Controller;
|
||||
|
||||
/**
|
||||
* @author Zhou Yuyang <1009465756@qq.com> 2015-07-27
|
||||
* @copyright ©2105-2018 SRCMS
|
||||
* @homepage http://www.src.pw
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
class ForgetController extends Controller {
|
||||
//显示找回密码页面
|
||||
public function index(){
|
||||
$this->display();
|
||||
}
|
||||
//找回密码逻辑
|
||||
public function find(){
|
||||
if(!IS_POST)$this->error("非法请求");
|
||||
$member = M('member');
|
||||
$email =I('post.email','','email');
|
||||
$username =I('post.username');
|
||||
//$code = I('verify','','strtolower');
|
||||
//验证验证码是否正确
|
||||
//if(!($this->check_verify($code))){
|
||||
//$this->error('验证码错误');
|
||||
//}
|
||||
//验证输入邮箱是否存在
|
||||
$user = $member->where(array('username'=>$username,'email'=>$email))->find();
|
||||
|
||||
if(!$user) {
|
||||
$this->error('邮箱不存在 :(') ;
|
||||
}
|
||||
//验证账户是否被禁用
|
||||
if($user['status'] == 0){
|
||||
$this->error('账号被禁用,无法找回密码 :(') ;
|
||||
}
|
||||
|
||||
if($user['type'] == 2){
|
||||
$this->error('前台无法重置管理员密码 :(') ;
|
||||
}
|
||||
|
||||
//发送验证码邮件
|
||||
import('ORG.Net.Mail');
|
||||
$str = '1234567890abcdefghijklmnopqrstuvwxyz';
|
||||
$passwd=$str[rand(0,35)].$str[rand(0,35)].$str[rand(0,35)].$str[rand(0,35)].$str[rand(0,35)].$str[rand(0,35)];
|
||||
$content = md5($passwd);
|
||||
$member = M('member');
|
||||
$member-> password=$content;
|
||||
$member ->where(array('username'=>$username,'email'=>$email))->save();
|
||||
$con='您好您正在找回密码,您的临时新密码为'.$passwd.'请您妥善保管,登陆平台后请及时修改密码';
|
||||
if(SendMail($email,'找回密码',$con,'应急响应中心')){
|
||||
$this->success("发送成功",U('login/index'));
|
||||
}else{
|
||||
$this->error('账号被禁用 :(') ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
78
Application/User/Controller/InfoController.class.php
Normal file
78
Application/User/Controller/InfoController.class.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
namespace User\Controller;
|
||||
use Think\Controller;
|
||||
|
||||
/**
|
||||
* @author Zhou Yuyang <1009465756@qq.com> 2015-08-02
|
||||
* @copyright ©2105-2018 SRCMS
|
||||
* @homepage http://www.src.pw
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
class InfoController extends BaseController{
|
||||
|
||||
public function index(){
|
||||
$id = session('userId');
|
||||
$info = M('info')->where('user_id='.$id)->select();
|
||||
$this->assign('info',$info);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加联系方式
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
//默认显示添加表单
|
||||
if (!IS_POST) {
|
||||
$this->display();
|
||||
}
|
||||
if (IS_POST) {
|
||||
//如果用户提交数据
|
||||
$model = D("info");
|
||||
$model->user_id = 1;
|
||||
$model->username = 1;
|
||||
if (!$model->create()) {
|
||||
// 如果创建失败 表示验证没有通过 输出错误提示信息
|
||||
$this->error($model->getError());
|
||||
exit();
|
||||
} else {
|
||||
if ($model->add()) {
|
||||
$this->success("添加成功", U('info/index'));
|
||||
} else {
|
||||
$this->error("添加失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新联系方式
|
||||
*/
|
||||
|
||||
public function update()
|
||||
{
|
||||
//默认显示添加表单
|
||||
if (!IS_POST) {
|
||||
$this->display();
|
||||
}
|
||||
if (IS_POST) {
|
||||
//如果用户提交数据
|
||||
$model = D("info");
|
||||
$model->user_id = 1;
|
||||
$model->username = 1;
|
||||
if (!$model->create()) {
|
||||
// 如果创建失败 表示验证没有通过 输出错误提示信息
|
||||
$this->error($model->getError());
|
||||
exit();
|
||||
} else {
|
||||
if ($model->save()) {
|
||||
$this->success("更新成功", U('info/index'));
|
||||
} else {
|
||||
$this->error("更新失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ use Think\Controller;
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
class PostController extends Controller
|
||||
class PostController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 漏洞报告列表
|
||||
|
||||
Reference in New Issue
Block a user