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,15 @@
<?php
namespace Admin\Controller;
use Think\Controller;
class BaseController extends Controller {
public function _initialize(){
$sid = session('adminId');
//判断用户是否登陆
if(!isset($sid ) ) {
redirect(U('Login/index'));
}
}
}

View File

@@ -0,0 +1,114 @@
<?php
namespace Admin\Controller;
use Admin\Controller;
/**
* 分类管理
*/
class CategoryController extends BaseController
{
/**
* 分类列表
* @return [type] [description]
*/
public function index($key="")
{
if($key == ""){
$model = M('category');
}else{
$where['title'] = array('like',"%$key%");
$where['name'] = array('like',"%$key%");
$where['_logic'] = 'or';
$model = M('category')->where($where);
}
$category = $model->limit($Page->firstRow.','.$Page->listRows)->where($where)->order('id ASC')->select();
$this->assign('model',getSortedCategory($category));
$this->display();
}
/**
* 添加分类
*/
public function add()
{
//默认显示添加表单
if (!IS_POST) {
$model = M('category')->select();
$cate = getSortedCategory($model);
$this->assign('cate',$cate);
$this->display();
}
if (IS_POST) {
//如果用户提交数据
$model = D("Category");
if (!$model->create()) {
// 如果创建失败 表示验证没有通过 输出错误提示信息
$this->error($model->getError());
exit();
} else {
if ($model->add()) {
$this->success("分类添加成功", U('category/index'));
} else {
$this->error("分类添加失败");
}
}
}
}
/**
* 更新分类信息
* @param [type] $id [分类ID]
* @return [type] [description]
*/
public function update()
{
//默认显示添加表单
if (!IS_POST) {
$model = M('category')->find(I('id'));
$this->assign('cate',getSortedCategory(M('category')->select()));
$this->assign('model',$model);
$this->display();
}
if (IS_POST) {
$model = D("Category");
if (!$model->create()) {
$this->error($model->getError());
}else{
// dd(I());die;
if ($model->save()) {
$this->success("分类更新成功", U('category/index'));
} else {
$this->error("分类更新失败");
}
}
}
}
/**
* 删除分类
* @param [type] $id [description]
* @return [type] [description]
*/
public function delete($id)
{
$model = M('category');
//查询属于这个分类的文章
$posts = M('post')->where('cate_id='.$id)->select();
if($posts){
$this->error("禁止删除含有文章的分类");
}
//禁止删除含有子分类的分类
$hasChild = $model->where('pid='.$id)->select();
if($hasChild){
$this->error("禁止删除含有子分类的分类");
}
//验证通过
$result = $model->delete($id);
if($result){
$this->success("分类删除成功", U('category/index'));
}else{
$this->error("分类删除失败");
}
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Admin\Controller;
use Admin\Controller;
class IndexController extends BaseController{
public function index(){
$page = M('page')->count();
$user = M('member')->count();
$post = M('post')->count();
$links = M('links')->count();
$this->assign('page',$page);
$this->assign('user',$user);
$this->assign('post',$post);
$this->assign('links',$links);
$this->display();
}
}

View File

@@ -0,0 +1,99 @@
<?php
namespace Admin\Controller;
use Admin\Controller;
/**
* 链接管理
*/
class LinksController extends BaseController
{
/**
* 链接列表
* @return [type] [description]
*/
public function index($key="")
{
if($key == ""){
$model = M('links');
}else{
$where['title'] = array('like',"%$key%");
$where['url'] = array('like',"%$key%");
$where['_logic'] = 'or';
$model = M('links')->where($where);
}
$count = $model->where($where)->count();// 查询满足要求的总记录数
$Page = new \Extend\Page($count,15);// 实例化分页类 传入总记录数和每页显示的记录数(25)
$show = $Page->show();// 分页显示输出
$links = $model->limit($Page->firstRow.','.$Page->listRows)->where($where)->order('id DESC')->select();
$this->assign('model', $links);
$this->assign('page',$show);
$this->display();
}
/**
* 添加链接
*/
public function add()
{
//默认显示添加表单
if (!IS_POST) {
$this->display();
}
if (IS_POST) {
//如果用户提交数据
$model = D("links");
if (!$model->create()) {
// 如果创建失败 表示验证没有通过 输出错误提示信息
$this->error($model->getError());
exit();
} else {
if ($model->add()) {
$this->success("链接添加成功", U('links/index'));
} else {
$this->error("链接添加失败");
}
}
}
}
/**
* 更新链接信息
* @param [type] $id [链接ID]
* @return [type] [description]
*/
public function update($id)
{
//默认显示添加表单
if (!IS_POST) {
$model = M('links')->where('id='.$id)->find();
$this->assign('model',$model);
$this->display();
}
if (IS_POST) {
$model = D("links");
if (!$model->create()) {
$this->error($model->getError());
}else{
if ($model->save()) {
$this->success("更新成功", U('links/index'));
} else {
$this->error("更新失败");
}
}
}
}
/**
* 删除链接
* @param [type] $id [description]
* @return [type] [description]
*/
public function delete($id)
{
$model = M('links');
$result = $model->delete($id);
if($result){
$this->success("链接删除成功", U('links/index'));
}else{
$this->error("链接删除失败");
}
}
}

View File

@@ -0,0 +1,70 @@
<?php
namespace Admin\Controller;
use Think\Controller;
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('账号被禁用,请联系超级管理员 :(') ;
}
if($user['type'] == 1){
$this->error('您没权限登陆后台 :(') ;
}
//验证是否为管理员
//更新登陆信息
$data =array(
'id' => $user['id'],
'update_at' => time(),
'login_ip' => get_client_ip(),
);
//如果数据更新成功 跳转到后台主页
if($member->save($data)){
session('adminId',$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('adminId',null);
session('username',null);
redirect(U('Login/index'));
}
}

View File

@@ -0,0 +1,120 @@
<?php
namespace Admin\Controller;
use Admin\Controller;
/**
* 用户管理
*/
class MemberController extends BaseController
{
/**
* 用户列表
* @return [type] [description]
*/
public function index($key="")
{
if($key == ""){
$model = M('member');
}else{
$where['username'] = array('like',"%$key%");
$where['email'] = array('like',"%$key%");
$where['_logic'] = 'or';
$model = M('member')->where($where);
}
$count = $model->where($where)->count();// 查询满足要求的总记录数
$Page = new \Extend\Page($count,15);// 实例化分页类 传入总记录数和每页显示的记录数(25)
$show = $Page->show();// 分页显示输出
$member = $model->limit($Page->firstRow.','.$Page->listRows)->where($where)->order('id DESC')->select();
$this->assign('member', $member);
$this->assign('page',$show);
$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('member/index'));
} else {
$this->error("用户添加失败");
}
}
}
}
/**
* 更新管理员信息
* @param [type] $id [管理员ID]
* @return [type] [description]
*/
public function update()
{
//默认显示添加表单
if (!IS_POST) {
$model = M('member')->find(I('id'));
$this->assign('model',$model);
$this->display();
}
if (IS_POST) {
$model = D("Member");
if (!$model->create()) {
$this->error($model->getError());
}else{
//验证密码是否为空
$data = I();
unset($data['password']);
if(I('password') != ""){
$data['password'] = md5(I('password'));
}
//强制更改超级管理员用户类型
if(C('SUPER_ADMIN_ID') == I('id')){
$data['type'] = 2;
}
//更新
if ($model->save($data)) {
$this->success("用户信息更新成功", U('member/index'));
} else {
$this->error("未做任何修改,用户信息更新失败");
}
}
}
}
/**
* 删除管理员
* @param [type] $id [description]
* @return [type] [description]
*/
public function delete($id)
{
if(C('SUPER_ADMIN_ID') == $id) $this->error("超级管理员不可禁用!");
$model = M('member');
//查询status字段值
$result = $model->find($id);
//更新字段
$data['id']=$id;
if($result['status'] == 1){
$data['status']=0;
}
if($result['status'] == 0){
$data['status']=1;
}
if($model->save($data)){
$this->success("状态更新成功", U('member/index'));
}else{
$this->error("状态更新失败");
}
}
}

View File

@@ -0,0 +1,99 @@
<?php
namespace Admin\Controller;
use Admin\Controller;
/**
* 单页管理
*/
class PageController extends BaseController
{
/**
* 单页列表
* @return [type] [description]
*/
public function index($key="")
{
if($key == ""){
$model = M('page');
}else{
$where['title'] = array('like',"%$key%");
$where['name'] = array('like',"%$key%");
$where['_logic'] = 'or';
$model = M('page')->where($where);
}
$count = $model->where($where)->count();// 查询满足要求的总记录数
$Page = new \Extend\Page($count,15);// 实例化分页类 传入总记录数和每页显示的记录数(25)
$show = $Page->show();// 分页显示输出
$pages = $model->limit($Page->firstRow.','.$Page->listRows)->where($where)->order('id DESC')->select();
$this->assign('model', $pages);
$this->assign('page',$show);
$this->display();
}
/**
* 添加单页
*/
public function add()
{
//默认显示添加表单
if (!IS_POST) {
$this->display();
}
if (IS_POST) {
//如果用户提交数据
$model = D("Page");
if (!$model->create()) {
// 如果创建失败 表示验证没有通过 输出错误提示信息
$this->error($model->getError());
exit();
} else {
if ($model->add()) {
$this->success("添加成功", U('page/index'));
} else {
$this->error("添加失败");
}
}
}
}
/**
* 更新单页信息
* @param [type] $id [单页ID]
* @return [type] [description]
*/
public function update($id)
{
//默认显示添加表单
if (!IS_POST) {
$model = M('page')->where('id='.$id)->find();
$this->assign('page',$model);
$this->display();
}
if (IS_POST) {
$model = D("Page");
if (!$model->create()) {
$this->error($model->getError());
}else{
if ($model->save()) {
$this->success("更新成功", U('page/index'));
} else {
$this->error("更新失败");
}
}
}
}
/**
* 删除单页
* @param [type] $id [description]
* @return [type] [description]
*/
public function delete($id)
{
$model = M('page');
$result = $model->where("id=".$id)->delete();
if($result){
$this->success("删除成功", U('page/index'));
}else{
$this->error("删除失败");
}
}
}

View File

@@ -0,0 +1,125 @@
<?php
namespace Admin\Controller;
use Admin\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 BaseController
{
/**
* 漏洞报告列表
* @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);
}
$count = $model->where($where)->count();// 查询满足要求的总记录数
$Page = new \Extend\Page($count,15);// 实例化分页类 传入总记录数和每页显示的记录数(25)
$show = $Page->show();// 分页显示输出
$post = $model->limit($Page->firstRow.','.$Page->listRows)->where($where)->order('post.id DESC')->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("添加失败");
}
}
}
}
/**
* 审核漏洞报告
* @param [type] $id [文章ID]
* @return [type] [description]
*/
public function update($id)
{
//默认显示添加表单
if (!IS_POST) {
$model = M('post')->where('id='.$id)->find();
$this->assign("category",getSortedCategory(M('category')->select()));
$this->assign('post',$model);
$this->display();
}
if (IS_POST) {
$model = D("Post");
if (!$model->create()) {
$this->error($model->getError());
}else{
if ($model->save()) {
$this->success("更新成功", U('post/index'));
} else {
$this->error("更新失败");
}
}
}
}
/**
* 删除漏洞报告
* @param [type] $id [description]
* @return [type] [description]
*/
public function delete($id)
{
$model = M('post');
$result = $model->where("id=".$id)->delete();
if($result){
$this->success("删除成功", U('post/index'));
}else{
$this->error("删除失败");
}
}
/**
* 添加积分
* @param [type] $id [description]
* @return [type] [description]
*/
public function jifen()
{
$user_id = I('post.user_id');
$amount = I('post.amount');
$model = M('member');
$result = $model->where('id='.$user_id)->setInc('jifen',$amount);
if($result){
$this->success("添加积分成功", U('post/index'));
}else{
$this->error("添加积分失败");
}
}
}

View File

@@ -0,0 +1,105 @@
<?php
namespace Admin\Controller;
use Admin\Controller;
/**
* 字段管理
*/
class SettingController extends BaseController
{
/**
* 分类列表
* @return [type] [description]
*/
public function index($key="")
{
if($key == ""){
$model = M('setting');
}else{
$where['key'] = array('like',"%$key%");
$where['description'] = array('like',"%$key%");
$where['_logic'] = 'or';
$model = M('setting')->where($where);
}
$count = $model->where($where)->count();// 查询满足要求的总记录数
$Page = new \Extend\Page($count,15);// 实例化分页类 传入总记录数和每页显示的记录数(25)
$show = $Page->show();// 分页显示输出
$setting = $model->limit($Page->firstRow.','.$Page->listRows)->where($where)->order('id DESC')->select();
$this->assign('model', $setting);
$this->assign('page',$show);
$this->display();
}
/**
* 添加分类
*/
public function add()
{
//默认显示添加表单
if (!IS_POST) {
$this->display();
}
if (IS_POST) {
//如果用户提交数据
$model = D("Setting");
if (!$model->create()) {
// 如果创建失败 表示验证没有通过 输出错误提示信息
$this->error($model->getError());
exit();
} else {
if ($model->add()) {
$this->success("字段添加成功", U('setting/index'));
} else {
$this->error("字段添加失败");
}
}
}
}
/**
* 更新分类信息
* @param [type] $id [分类ID]
* @return [type] [description]
*/
public function update()
{
//默认显示添加表单
if (!IS_POST) {
$model = M('setting')->find(I('id'));
$this->assign('model',$model);
$this->display();
}
if (IS_POST) {
$model = D("Setting");
if (!$model->create()) {
$this->error($model->getError());
}else{
// dd(I());die;
if ($model->save()) {
$this->success("字段更新成功", U('setting/index'));
} else {
$this->error("字段更新失败");
}
}
}
}
/**
* 删除分类
* @param [type] $id [description]
* @return [type] [description]
*/
public function delete($id)
{
$model = M('setting');
//验证通过
$result = $model->delete($id);
if($result){
$this->success("字段删除成功", U('setting/index'));
}else{
$this->error("字段删除失败");
}
}
}

View File

@@ -0,0 +1 @@