轻量web开发框架
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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
