SRCMS(轻响应)企业应急响应中心开发框架模版
This commit is contained in:
martinzhou2015
2015-07-28 15:15:57 +08:00
parent 0da4a2951c
commit c1dc9cf28e
856 changed files with 242152 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
<?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 BaseController extends Controller {
public function _initialize(){
$sid = session('userId');
//判断用户是否登陆
if(!isset($sid ) ) {
redirect(U('Login/index'));
}
}
}

View File

@@ -0,0 +1,16 @@
<?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 IndexController extends BaseController {
public function index(){
$this->display();
}
}

View File

@@ -0,0 +1,77 @@
<?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 LoginController extends Controller {
//登陆主页
public function index(){
$this->display();
}
//登陆验证
public function login(){
if(!IS_POST)$this->error("非法请求");
$member = M('member');
$username =I('username');
$password =I('password','','md5');
$code = I('verify','','strtolower');
//验证验证码是否正确
if(!($this->check_verify($code))){
$this->error('验证码错误');
}
//验证账号密码是否正确
$user = $member->where(array('username'=>$username,'password'=>$password))->find();
if(!$user) {
$this->error('账号或密码错误 :(') ;
}
//验证账户是否被禁用
if($user['status'] == 0){
$this->error('账号被禁用,请联系超级管理员 :(') ;
}
//更新登陆信息
$data =array(
'id' => $user['id'],
'update_at' => time(),
'login_ip' => get_client_ip(),
);
//如果数据更新成功 跳转到后台主页
if($member->save($data)){
session('userId',$user['id']);
session('username',$user['username']);
$this->success("登陆成功",U('Index/index'));
}
//定向之后台主页
}
//验证码
public function verify(){
$Verify = new \Think\Verify();
$Verify->codeSet = '0123456789';
$Verify->fontSize = 13;
$Verify->length = 4;
$Verify->entry();
}
protected function check_verify($code){
$verify = new \Think\Verify();
return $verify->check($code);
}
//退出登录
public function logout(){
session('userId',null);
session('username',null);
redirect(U('Login/index'));
}
}

View File

@@ -0,0 +1,67 @@
<?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 PostController extends Controller
{
/**
* 漏洞报告列表
* @return [type] [description]
*/
public function index($key="")
{
if($key == ""){
$model = D('PostView');
}else{
$where['post.title'] = array('like',"%$key%");
$where['member.username'] = array('like',"%$key%");
$where['category.title'] = array('like',"%$key%");
$where['_logic'] = 'or';
$model = D('PostView')->where($where);
}
$id = session('userId');
$count = $model->where($where)->where('user_id='.$id)->count();// 查询满足要求的总记录数
$Page = new \Extend\Page($count,15);// 实例化分页类 传入总记录数和每页显示的记录数(25)
$show = $Page->show();// 分页显示输出
$post = $model->limit($Page->firstRow.','.$Page->listRows)->where($where)->order('post.id DESC')->where('user_id='.$id)->select();
$this->assign('model', $post);
$this->assign('page',$show);
$this->display();
}
/**
* 添加漏洞报告
*/
public function add()
{
//默认显示添加表单
if (!IS_POST) {
$this->assign("category",getSortedCategory(M('category')->select()));
$this->display();
}
if (IS_POST) {
//如果用户提交数据
$model = D("Post");
$model->time = time();
$model->user_id = 1;
if (!$model->create()) {
// 如果创建失败 表示验证没有通过 输出错误提示信息
$this->error($model->getError());
exit();
} else {
if ($model->add()) {
$this->success("添加成功", U('post/index'));
} else {
$this->error("添加失败");
}
}
}
}
}

View File

@@ -0,0 +1,51 @@
<?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 RegController extends Controller{
/**
* 用户列表
* @return [type] [description]
*/
public function index()
{
$this->display();
}
/**
* 添加用户
*/
public function add()
{
//默认显示添加表单
if (!IS_POST) {
$this->display();
}
if (IS_POST) {
//如果用户提交数据
$model = D("Member");
if (!$model->create()) {
// 如果创建失败 表示验证没有通过 输出错误提示信息
$this->error($model->getError());
exit();
} else {
if ($model->add()) {
$this->success("用户添加成功", U('index/index'));
} else {
$this->error("用户添加失败");
}
}
}
}
}

View File

@@ -0,0 +1 @@