CoreThink是一套完全开源免费的WEB产品开发框架,追求简单、高效、卓越。可轻松实现支持多终端的WEB产品快速搭建、部署、上线。系统功能采用模块化、组件化、插件化等开放化低耦合设计,应用商城拥有丰富的功能模块、插件、主题,便于用户灵活扩展和二次开发。
代码包大于4M传不上去,可以在我们官网获取:www.corethink.cn
1. [图片] 1.jpg
2. [代码][PHP]代码
<?php // +---------------------------------------------------------------------- // | OpenCMF [ Simple Efficient Excellent ] // +---------------------------------------------------------------------- // | Copyright (c) 2014 http://www.php.cn/ All rights reserved. // +---------------------------------------------------------------------- // | Author: jry <598821125@qq.com> // +---------------------------------------------------------------------- namespace Home\Controller; use Common\Controller\CommonController; /** * 前台公共控制器 * 为防止多分组Controller名称冲突,公共Controller名称统一使用模块名 * @author jry <598821125@qq.com> */ class HomeController extends CommonController { /** * 初始化方法 * @author jry <598821125@qq.com> */ protected function _initialize() { // 系统开关 if (!C('TOGGLE_WEB_SITE')) { $this->error('站点已经关闭,请稍后访问~'); } // 获取所有模块配置的用户导航 $mod_con['status'] = 1; $_user_nav_main = array(); $_user_nav_list = D('Admin/Module')->where($mod_con)->getField('user_nav', true); foreach ($_user_nav_list as $key => $val) { if ($val) { $val = json_decode($val, true); if ($val['main']) { $_user_nav_main = array_merge($_user_nav_main, $val['main']); } } } // 监听行为扩展 \Think\Hook::listen('corethink_behavior'); $this->assign('meta_keywords', C('WEB_SITE_KEYWORD')); $this->assign('meta_description', C('WEB_SITE_DESCRIPTION')); $this->assign('_new_message', cookie('_new_message')); // 获取用户未读消息数量 $this->assign('_user_auth', session('user_auth')); // 用户登录信息 $this->assign('_user_nav_main', $_user_nav_main); // 用户导航信息 $this->assign('_user_center_side', C('USER_CENTER_SIDE')); // 用户中心侧边 $this->assign('_user_login_modal', C('USER_LOGIN_MODAL')); // 用户登录弹窗 $this->assign('_home_public_layout', C('HOME_PUBLIC_LAYOUT')); // 页面公共继承模版 } /** * 用户登录检测 * @author jry <598821125@qq.com> */ protected function is_login() { //用户登录检测 $uid = is_login(); if ($uid) { return $uid; } else { if (IS_AJAX) { $return['status'] = 0; $return['info'] = '请先登录系统'; $return['login'] = 1; $this->ajaxReturn($return); } else { redirect(U('User/User/login', null, true, true)); } } } /** * 设置一条或者多条数据的状态 * @param $script 严格模式要求处理的纪录的uid等于当前登陆用户UID * @author jry <598821125@qq.com> */ public function setStatus($model = CONTROLLER_NAME, $script = true) { $ids = I('request.ids'); $status = I('request.status'); if (empty($ids)) { $this->error('请选择要操作的数据'); } $model_primary_key = D($model)->getPk(); $map[$model_primary_key] = array('in',$ids); if ($script) { $map['uid'] = array('eq', is_login()); } switch ($status) { case 'forbid' : // 禁用条目 $data = array('status' => 0); $this->editRow( $model, $data, $map, array('success'=>'禁用成功','error'=>'禁用失败') ); break; case 'resume' : // 启用条目 $data = array('status' => 1); $map = array_merge(array('status' => 0), $map); $this->editRow( $model, $data, $map, array('success'=>'启用成功','error'=>'启用失败') ); break; case 'hide' : // 隐藏条目 $data = array('status' => 2); $map = array_merge(array('status' => 1), $map); $this->editRow( $model, $data, $map, array('success'=>'隐藏成功','error'=>'隐藏失败') ); break; case 'show' : // 显示条目 $data = array('status' => 1); $map = array_merge(array('status' => 2), $map); $this->editRow( $model, $data, $map, array('success'=>'显示成功','error'=>'显示失败') ); break; case 'recycle' : // 移动至回收站 $data['status'] = -1; $this->editRow( $model, $data, $map, array('success'=>'成功移至回收站','error'=>'删除失败') ); break; case 'restore' : // 从回收站还原 $data = array('status' => 1); $map = array_merge(array('status' => -1), $map); $this->editRow( $model, $data, $map, array('success'=>'恢复成功','error'=>'恢复失败') ); break; case 'delete' : // 删除条目 $result = D($model)->where($map)->delete(); if ($result) { $this->success('删除成功,不可恢复!'); } else { $this->error('删除失败'); } break; default : $this->error('参数错误'); break; } } /** * 对数据表中的单行或多行记录执行修改 GET参数id为数字或逗号分隔的数字 * @param string $model 模型名称,供M函数使用的参数 * @param array $data 修改的数据 * @param array $map 查询时的where()方法的参数 * @param array $msg 执行正确和错误的消息 * array( * 'success' => '', * 'error' => '', * 'url' => '', // url为跳转页面 * 'ajax' => false //是否ajax(数字则为倒数计时) * ) * @author jry <598821125@qq.com> */ final protected function editRow($model, $data, $map, $msg) { $id = array_unique((array)I('id',0)); $id = is_array($id) ? implode(',',$id) : $id; //如存在id字段,则加入该条件 $fields = D($model)->getDbFields(); if (in_array('id', $fields) && !empty($id)) { $where = array_merge( array('id' => array('in', $id )), (array)$where ); } $msg = array_merge( array( 'success' => '操作成功!', 'error' => '操作失败!', 'url' => ' ', 'ajax' => IS_AJAX ), (array)$msg ); $result = D($model)->where($map)->save($data); if ($result != false) { $this->success($msg['success'], $msg['url'], $msg['ajax']); } else { $this->error($msg['error'], $msg['url'], $msg['ajax']); } } }

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Dreamweaver Mac version
Visual web development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.