初始化项目
This commit is contained in:
41
application/common/model/Action.php
Normal file
41
application/common/model/Action.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | OneThink [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 分类模型
|
||||
*/
|
||||
class Action extends Base{
|
||||
|
||||
protected function getStatusTextAttr($value, $data){
|
||||
$status = array(-1=>'删除',0=>'禁用',1=>'正常',2=>'待审核');
|
||||
return $status[$data['status']];
|
||||
}
|
||||
|
||||
public $fieldlist = array(
|
||||
array('name'=>'id','title'=>'ID','type'=>'hidden'),
|
||||
array('name'=>'name','title'=>'行为标识','type'=>'text','help'=>'输入行为标识 英文字母'),
|
||||
array('name'=>'title','title'=>'行为名称','type'=>'text','help'=>'输入行为名称'),
|
||||
array('name'=>'type','title'=>'行为类型','type'=>'select','help'=>'选择行为类型','option'=>''),
|
||||
array('name'=>'remark','title'=>'行为描述','type'=>'textarea','help'=>'输入行为描述'),
|
||||
array('name'=>'rule','title'=>'行为规则','type'=>'textarea','help'=>'输入行为规则,不写则只记录日志'),
|
||||
array('name'=>'log','title'=>'日志规则','type'=>'textarea','help'=>'记录日志备注时按此规则来生成,支持[变量|函数]。目前变量有:user,time,model,record,data'),
|
||||
);
|
||||
|
||||
public function _initialize(){
|
||||
parent::_initialize();
|
||||
foreach ($this->fieldlist as $key => $value) {
|
||||
if ($value['name'] == 'type') {
|
||||
$value['option'] = get_action_type(null,true);
|
||||
}
|
||||
$this->fieldlist[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
application/common/model/ActionLog.php
Normal file
21
application/common/model/ActionLog.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | OneThink [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 分类模型
|
||||
*/
|
||||
class ActionLog extends Base{
|
||||
|
||||
protected function getModelIdAttr($value, $data){
|
||||
$value = get_document_field($data['model'], "name", "id");
|
||||
return $value ? $value : 0;
|
||||
}
|
||||
}
|
||||
36
application/common/model/Ad.php
Normal file
36
application/common/model/Ad.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | OneThink [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 分类模型
|
||||
*/
|
||||
class Ad extends Base{
|
||||
|
||||
protected $auto = array('update_time');
|
||||
protected $insert = array('create_time');
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
'cover_id' => 'integer',
|
||||
);
|
||||
|
||||
public $keyList = array(
|
||||
array('name'=>'id', 'title'=>'ID', 'type'=>'hidden', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'place_id', 'title'=>'PLACE_ID', 'type'=>'hidden', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'title', 'title'=>'广告名称', 'type'=>'text', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'cover_id', 'title'=>'广告图片', 'type'=>'image', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'url', 'title'=>'广告链接', 'type'=>'text', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'photolist', 'title'=>'辅助图片', 'type'=>'images', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'listurl', 'title'=>'辅助链接', 'type'=>'textarea', 'help'=>'对应辅助图片的排序,一行一个', 'option'=>''),
|
||||
array('name'=>'background', 'title'=>'广告背景颜色', 'type'=>'text', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'content', 'title'=>'广告描述', 'type'=>'textarea', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'status', 'title'=>'状态', 'type'=>'select', 'help'=>'', 'option'=>array('1'=>'开启','0'=>'禁用')),
|
||||
);
|
||||
}
|
||||
54
application/common/model/AdPlace.php
Normal file
54
application/common/model/AdPlace.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | OneThink [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 分类模型
|
||||
*/
|
||||
class AdPlace extends Base{
|
||||
|
||||
protected $auto = array('update_time');
|
||||
protected $insert = array('create_time');
|
||||
protected $type = array(
|
||||
'start_time' => 'integer',
|
||||
'end_time' => 'integer',
|
||||
);
|
||||
|
||||
public $show_type = array(
|
||||
'1' => '幻灯片',
|
||||
'2' => '对联',
|
||||
'3' => '图片列表',
|
||||
'4' => '图文列表',
|
||||
'5' => '文字列表',
|
||||
'6' => '代码广告'
|
||||
);
|
||||
|
||||
public $keyList = array(
|
||||
array('name'=>'id', 'title'=>'ID', 'type'=>'hidden', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'title', 'title'=>'广告位名称', 'type'=>'text', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'name', 'title'=>'广告位标识', 'type'=>'text', 'help'=>'调用使用{:ad("广告位标识",参数)}', 'option'=>''),
|
||||
array('name'=>'show_type', 'title'=>'类型', 'type'=>'select', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'show_num', 'title'=>'显示条数', 'type'=>'num', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'start_time', 'title'=>'开始时间', 'type'=>'datetime', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'end_time', 'title'=>'结束时间', 'type'=>'datetime', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'template', 'title'=>'广告模版', 'type'=>'text', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'status', 'title'=>'状态', 'type'=>'select', 'help'=>'', 'option'=>array('1'=>'开启','0'=>'禁用')),
|
||||
);
|
||||
|
||||
public function initialize(){
|
||||
parent::initialize();
|
||||
foreach ($this->keyList as $key => $value) {
|
||||
if ($value['name'] == 'show_type') {
|
||||
$value['option'] = $this->show_type;
|
||||
}
|
||||
$this->keyList[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
128
application/common/model/Addons.php
Normal file
128
application/common/model/Addons.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 用户组模型类
|
||||
* Class AuthGroupModel
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
class Addons extends \app\common\model\Base {
|
||||
|
||||
protected $auto = array('status');
|
||||
protected $insert = array('create_time');
|
||||
|
||||
protected function setStatusAttr(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取插件列表
|
||||
* @param string $addon_dir
|
||||
*/
|
||||
public function getList($addon_dir = ''){
|
||||
if(!$addon_dir){
|
||||
$addon_dir = SENT_ADDON_PATH;
|
||||
}
|
||||
$dirs = array_map('basename',glob($addon_dir.'*', GLOB_ONLYDIR));
|
||||
if($dirs === FALSE || !file_exists($addon_dir)){
|
||||
$this->error = '插件目录不可读或者不存在';
|
||||
return FALSE;
|
||||
}
|
||||
$addons = array();
|
||||
$where['name'] = array('in',$dirs);
|
||||
$list = db('Addons')->where($where)->field(true)->select();
|
||||
foreach($list as $addon){
|
||||
$addon['uninstall'] = 0;
|
||||
$addons[$addon['name']] = $addon;
|
||||
}
|
||||
foreach ($dirs as $value) {
|
||||
$value = ucfirst($value);
|
||||
if(!isset($addons[$value])){
|
||||
$class = get_addon_class($value);
|
||||
if(!class_exists($class)){
|
||||
// 实例化插件失败忽略执行
|
||||
\think\Log::record('插件'.$value.'的入口文件不存在!');
|
||||
continue;
|
||||
}
|
||||
$obj = new $class;
|
||||
$addons[$value] = $obj->info;
|
||||
if($addons[$value]){
|
||||
$addons[$value]['id'] = 0;
|
||||
$addons[$value]['uninstall'] = 1;
|
||||
unset($addons[$value]['status']);
|
||||
}
|
||||
}
|
||||
}
|
||||
int_to_string($addons, array('status'=>array(-1=>'损坏', 0=>'禁用', 1=>'启用', null=>'未安装')));
|
||||
$addons = list_sort_by($addons,'uninstall','desc');
|
||||
return $addons;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取插件的后台列表
|
||||
*/
|
||||
public function getAdminList(){
|
||||
$admin = array();
|
||||
$db_addons = db('Addons')->where("status=1 AND has_adminlist=1")->field('title,name')->select();
|
||||
if($db_addons){
|
||||
foreach ($db_addons as $value) {
|
||||
$admin[] = array('title'=>$value['title'],'url'=>"Addons/adminList?name={$value['name']}");
|
||||
}
|
||||
}
|
||||
return $admin;
|
||||
}
|
||||
|
||||
public function install($data){
|
||||
if ($data) {
|
||||
$result = $this->save($data);
|
||||
if ($result) {
|
||||
model('Hooks')->addHooks($data['name']);
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function uninstall($id){
|
||||
$info = $this->get($id);
|
||||
if (!$info) {
|
||||
$this->error = "无此插件!";
|
||||
return false;
|
||||
}
|
||||
$class = get_addon_class($info['name']);
|
||||
if (class_exists($class)) {
|
||||
//插件卸载方法
|
||||
$addons = new $class;
|
||||
if (!method_exists($addons,'uninstall')) {
|
||||
$this->error = "插件卸载方法!";
|
||||
return false;
|
||||
}
|
||||
$result = $addons->uninstall();
|
||||
if ($result) {
|
||||
//卸载挂载点中的插件
|
||||
$result = model('Hooks')->removeHooks($info['name']);
|
||||
//删除插件表中数据
|
||||
$this->where(array('id'=>$id))->delete();
|
||||
return true;
|
||||
}else{
|
||||
$this->error = "无法卸载插件!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function build(){
|
||||
|
||||
}
|
||||
}
|
||||
139
application/common/model/Attribute.php
Normal file
139
application/common/model/Attribute.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Attribute extends Base{
|
||||
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
);
|
||||
|
||||
protected function getTypeTextAttr($value, $data){
|
||||
$type = config('config_type_list');
|
||||
$type_text = explode(',', $type[$data['type']]);
|
||||
return $type_text[0];
|
||||
}
|
||||
|
||||
public function getFieldlist($map,$index='id'){
|
||||
$list = array();
|
||||
$row = db('Attribute')->field('*,remark as help,type,extra as "option"')->where($map)->select();
|
||||
foreach ($row as $key => $value) {
|
||||
if (in_array($value['type'],array('checkbox','radio','select','bool'))) {
|
||||
$value['option'] = parse_field_attr($value['extra']);
|
||||
} elseif ($value['type'] == 'bind') {
|
||||
$extra = parse_field_bind($value['extra']);
|
||||
foreach ($extra as $k => $v) {
|
||||
$option[$v['id']] = $v['title_show'];
|
||||
}
|
||||
$value['option'] = $option;
|
||||
}
|
||||
$list[$value['id']] = $value;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function change(){
|
||||
$data = input('post.');
|
||||
|
||||
if (!empty($data)) {
|
||||
//在数据库内添加字段
|
||||
$result = $this->checkTableField($data);
|
||||
if (!$result) {
|
||||
$this->error = "字段创建失败!";
|
||||
return false;
|
||||
}
|
||||
if ($data['id']) {
|
||||
$status = $this->save($data, array('id'=>$data['id']));
|
||||
}else{
|
||||
$status = $this->save($data);
|
||||
}
|
||||
|
||||
if (false !== $status) {
|
||||
return $status;
|
||||
}else{
|
||||
$this->error = "添加失败!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function del($id){
|
||||
$map['id'] = $id;
|
||||
$info = $this->find($id);
|
||||
$model = db('Model')->where(array('id'=>$info['model_id']))->find();
|
||||
|
||||
//先删除字段表内的数据
|
||||
$result = $this->where($map)->delete();
|
||||
if ($result) {
|
||||
if ($model['extend'] == 1) {
|
||||
$tablename = 'document_'.$model['name'];
|
||||
}else{
|
||||
$tablename = $model['name'];
|
||||
}
|
||||
|
||||
//删除模型表中字段
|
||||
$db = new \com\Datatable();
|
||||
$result = $db->del_field($tablename,$info['name'])->query();
|
||||
if ($result) {
|
||||
return true;
|
||||
}else{
|
||||
$this->error = "删除失败!";
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
$this->error = "删除失败!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkTableField($field){
|
||||
$model = db('Model')->find($field['model_id']);
|
||||
if ($model['extend'] == 1) {
|
||||
$tablename = 'document_'.$model['name'];
|
||||
$key = "doc_id";
|
||||
}else{
|
||||
$tablename = $model['name'];
|
||||
$key = "id";
|
||||
}
|
||||
|
||||
//实例化一个数据库操作类
|
||||
$db = new \com\Datatable();
|
||||
//检查表是否存在并创建
|
||||
if (!$db->CheckTable($tablename)) {
|
||||
//创建新表
|
||||
$db->start_table($tablename)->create_id($key)->create_key($key)->end_table()->query();
|
||||
};
|
||||
$oldname = "";
|
||||
if ($field['id']) {
|
||||
$oldname = $this->db()->where(array('id'=>$field['id']))->value('name');
|
||||
}
|
||||
$attribute_type = get_attribute_type();
|
||||
$field['field'] = $field['name'];
|
||||
$field['type'] = $attribute_type[$field['type']][1];
|
||||
$field['is_null'] = $field['is_must']; //是否为null
|
||||
$field['default'] = $field['value']; //字段默认值
|
||||
$field['comment'] = $field['remark']; //字段注释
|
||||
if($db->CheckField($tablename,$oldname) && $oldname){
|
||||
$field['action'] = 'CHANGE';
|
||||
$field['oldname'] = $oldname;
|
||||
$field['newname'] = $field['name'];
|
||||
$db->colum_field($tablename,$field);
|
||||
}else{
|
||||
$field['action'] = 'ADD';
|
||||
$db->colum_field($tablename,$field);
|
||||
}
|
||||
|
||||
$result = $db->create();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
115
application/common/model/AuthGroup.php
Normal file
115
application/common/model/AuthGroup.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class AuthGroup extends Base{
|
||||
|
||||
const TYPE_ADMIN = 1; // 管理员用户组类型标识
|
||||
const MEMBER = 'member';
|
||||
const UCENTER_MEMBER = 'ucenter_member';
|
||||
const AUTH_GROUP_ACCESS = 'auth_group_access'; // 关系表表名
|
||||
const AUTH_EXTEND = 'auth_extend'; // 动态权限扩展信息表
|
||||
const AUTH_GROUP = 'auth_group'; // 用户组表名
|
||||
const AUTH_EXTEND_CATEGORY_TYPE = 1; // 分类权限标识
|
||||
const AUTH_EXTEND_MODEL_TYPE = 2; //分类权限标识
|
||||
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
);
|
||||
|
||||
public $keyList = array(
|
||||
array('name'=>'id', 'title'=>'ID', 'type'=>'hidden', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'module', 'title'=>'所属模块', 'type'=>'hidden', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'title', 'title'=>'用户组名', 'type'=>'text', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'description', 'title'=>'分组描述', 'type'=>'textarea', 'help'=>'', 'option'=>''),
|
||||
array('name'=>'status', 'title'=>'状态', 'type'=>'select', 'help'=>'', 'option'=>array(
|
||||
0 => '禁用',
|
||||
1 => '启用'
|
||||
)),
|
||||
);
|
||||
|
||||
public function change(){
|
||||
$data = input('post.');
|
||||
if ($data['id']) {
|
||||
$result = $this->save($data, array('id'=>$data['id']));
|
||||
}else{
|
||||
$result = $this->save($data);
|
||||
}
|
||||
if (false !== $result) {
|
||||
return true;
|
||||
}else{
|
||||
$this->error = "失败!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回用户拥有管理权限的分类id列表
|
||||
*
|
||||
* @param int $uid 用户id
|
||||
* @return array
|
||||
*
|
||||
* array(2,4,8,13)
|
||||
*
|
||||
* @author 朱亚杰 <zhuyajie@topthink.net>
|
||||
*/
|
||||
static public function getAuthModels($uid){
|
||||
return self::getAuthExtend($uid,self::AUTH_EXTEND_MODEL_TYPE,'AUTH_MODEL');
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回用户拥有管理权限的分类id列表
|
||||
*
|
||||
* @param int $uid 用户id
|
||||
* @return array
|
||||
*
|
||||
* array(2,4,8,13)
|
||||
*
|
||||
* @author 朱亚杰 <zhuyajie@topthink.net>
|
||||
*/
|
||||
static public function getAuthCategories($uid){
|
||||
return self::getAuthExtend($uid,self::AUTH_EXTEND_CATEGORY_TYPE,'AUTH_CATEGORY');
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回用户拥有管理权限的扩展数据id列表
|
||||
*
|
||||
* @param int $uid 用户id
|
||||
* @param int $type 扩展数据标识
|
||||
* @param int $session 结果缓存标识
|
||||
* @return array
|
||||
*
|
||||
* array(2,4,8,13)
|
||||
*
|
||||
* @author 朱亚杰 <xcoolcc@gmail.com>
|
||||
*/
|
||||
static public function getAuthExtend($uid,$type,$session){
|
||||
if ( !$type ) {
|
||||
return false;
|
||||
}
|
||||
if ( $session ) {
|
||||
$result = session($session);
|
||||
}
|
||||
if ( $uid == session('user_auth.uid') && !empty($result) ) {
|
||||
return $result;
|
||||
}
|
||||
$result = db(self::AUTH_GROUP_ACCESS)->alias('g')
|
||||
->join(self::AUTH_EXTEND.' c', 'g.group_id=c.group_id')
|
||||
->where("g.uid='$uid' and c.type='$type' and !isnull(extend_id)")
|
||||
->column('extend_id');
|
||||
if ( $uid == session('user_auth.uid') && $session ) {
|
||||
session($session,$result);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
17
application/common/model/AuthGroupAccess.php
Normal file
17
application/common/model/AuthGroupAccess.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class AuthGroupAccess extends Base{
|
||||
|
||||
}
|
||||
48
application/common/model/AuthRule.php
Normal file
48
application/common/model/AuthRule.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class AuthRule extends Base{
|
||||
|
||||
const rule_url = 1;
|
||||
const rule_mian = 2;
|
||||
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
);
|
||||
|
||||
public $keyList = array(
|
||||
array('name'=>'id','title'=>'标识','type'=>'hidden'),
|
||||
array('name'=>'module','title'=>'所属模块','type'=>'hidden'),
|
||||
array('name'=>'title','title'=>'节点名称','type'=>'text','help'=>''),
|
||||
array('name'=>'name','title'=>'节点标识','type'=>'text','help'=>''),
|
||||
array('name'=>'group','title'=>'功能组','type'=>'text','help'=>'功能分组'),
|
||||
array('name'=>'status','title'=>'状态','type'=>'select','option'=>array('1'=>'启用','0'=>'禁用'),'help'=>''),
|
||||
array('name'=>'condition','title'=>'条件','type'=>'text','help'=>'')
|
||||
);
|
||||
|
||||
public function change(){
|
||||
$data = input('post.');
|
||||
if ($data['id']) {
|
||||
$result = $this->save($data, array('id'=>$data));
|
||||
}else{
|
||||
$result = $this->save($data);
|
||||
}
|
||||
if (false !== $result) {
|
||||
return true;
|
||||
}else{
|
||||
$this->error = "失败!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
application/common/model/Base.php
Normal file
24
application/common/model/Base.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 模型基类
|
||||
*/
|
||||
class Base extends \think\Model{
|
||||
|
||||
public function scopeList($query, $map, $field = '*', $limit = 10, $order = 'id desc'){
|
||||
$query->field($field)->where($map)->limit($limit)->order($order);
|
||||
}
|
||||
|
||||
public function scopeWhere($query, $map){
|
||||
$query->where($map);
|
||||
}
|
||||
}
|
||||
54
application/common/model/Book.php
Normal file
54
application/common/model/Book.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | OneThink [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 分类模型
|
||||
*/
|
||||
class Book extends Content{
|
||||
|
||||
protected $auto = array('date_last_modify', 'user_last_modify');
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
'cover_id' => 'integer',
|
||||
'sort' => 'integer'
|
||||
);
|
||||
|
||||
protected function setStatusAttr($value){
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected function setCreateTimeAttr($value){
|
||||
return $value ? strtotime($value) : time();
|
||||
}
|
||||
|
||||
protected function setDateLastModifyAttr($value){
|
||||
return $value ? strtotime($value) : time();
|
||||
}
|
||||
|
||||
protected function setUserLastModifyAttr($value){
|
||||
return session('user_auth.uid');
|
||||
}
|
||||
|
||||
protected function getCreateTimeAttr($value){
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
|
||||
protected function getDateLastModifyAttr($value){
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
|
||||
protected function getStandClassTextAttr($value, $data){
|
||||
$text = array(
|
||||
'1' => 'BK ', '2' => 'CN', '3' => 'QT', '4' => 'DB',
|
||||
);
|
||||
return $text[$data['stand_class']];
|
||||
}
|
||||
}
|
||||
43
application/common/model/Category.php
Normal file
43
application/common/model/Category.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Category extends Base{
|
||||
|
||||
protected $name = "Category";
|
||||
protected $auto = array('update_time', 'icon'=>1, 'status'=>1);
|
||||
|
||||
protected $type = array(
|
||||
'icon' => 'integer',
|
||||
);
|
||||
|
||||
public function change(){
|
||||
$data = input('post.');
|
||||
if ($data['id']) {
|
||||
$result = $this->save($data,array('id'=>$data['id']));
|
||||
}else{
|
||||
unset($data['id']);
|
||||
$result = $this->save($data);
|
||||
}
|
||||
if (false !== $result) {
|
||||
return true;
|
||||
}else{
|
||||
$this->error = "失败!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function info($id, $field = true){
|
||||
return $this->db()->where(array('id'=>$id))->field($field)->find();
|
||||
}
|
||||
}
|
||||
23
application/common/model/Channel.php
Normal file
23
application/common/model/Channel.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Channel extends Base{
|
||||
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
);
|
||||
|
||||
protected $auto = array('update_time', 'status'=>1);
|
||||
protected $insert = array('create_time');
|
||||
}
|
||||
74
application/common/model/Config.php
Normal file
74
application/common/model/Config.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Config extends Base{
|
||||
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
);
|
||||
|
||||
protected $auto = array('name', 'update_time', 'status'=>1);
|
||||
protected $insert = array('create_time');
|
||||
|
||||
protected function setNameAttr($value){
|
||||
return strtolower($value);
|
||||
}
|
||||
|
||||
protected function getTypeTextAttr($value, $data){
|
||||
$type = config('config_type_list');
|
||||
$type_text = explode(',', $type[$data['type']]);
|
||||
return $type_text[0];
|
||||
}
|
||||
|
||||
public function lists(){
|
||||
$map = array('status' => 1);
|
||||
$data = $this->db()->where($map)->field('type,name,value')->select();
|
||||
|
||||
$config = array();
|
||||
if($data && is_array($data)){
|
||||
foreach ($data as $value) {
|
||||
$config[$value['name']] = $this->parse($value['type'], $value['value']);
|
||||
}
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据配置类型解析配置
|
||||
* @param integer $type 配置类型
|
||||
* @param string $value 配置值
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
private function parse($type, $value){
|
||||
switch ($type) {
|
||||
case 'textarea': //解析数组
|
||||
$array = preg_split('/[,;\r\n]+/', trim($value, ",;\r\n"));
|
||||
if(strpos($value,':')){
|
||||
$value = array();
|
||||
foreach ($array as $val) {
|
||||
$list = explode(':', $val);
|
||||
if(isset($list[2])){
|
||||
$value[$list[0]] = $list[1].','.$list[2];
|
||||
}else{
|
||||
$value[$list[0]] = $list[1];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$value = $array;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
68
application/common/model/Content.php
Normal file
68
application/common/model/Content.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Content extends Base{
|
||||
|
||||
//protected $name = "page";
|
||||
|
||||
protected $auto = array("update_time");
|
||||
protected $insert = array("create_time");
|
||||
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
'cover_id' => 'integer',
|
||||
);
|
||||
|
||||
protected function setCreateTimeAttr($value){
|
||||
return $value ? strtotime($value) : time();
|
||||
}
|
||||
|
||||
protected function setUpdateTimeAttr($value){
|
||||
return $value ? strtotime($value) : time();
|
||||
}
|
||||
|
||||
|
||||
protected function getCreateTimeAttr($value){
|
||||
return date('Y-m-d H:i:s',$value);
|
||||
}
|
||||
|
||||
protected function getUpdateTimeAttr($value){
|
||||
return date('Y-m-d H:i:s',$value);
|
||||
}
|
||||
|
||||
public function setInfo($name){
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function detail($id){
|
||||
$map['id'] = $id;
|
||||
$this->data = $this->db()->where($map)->find();
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function change(){
|
||||
$data = input('post.');
|
||||
if ($data['id']) {
|
||||
$result = $this->save($data,array('id'=>$data['id']));
|
||||
}else{
|
||||
$result = $this->save($data);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function del($map){
|
||||
return $this->db()->where($map)->delete();
|
||||
}
|
||||
}
|
||||
122
application/common/model/Document.php
Normal file
122
application/common/model/Document.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Document extends \think\model\Merge{
|
||||
|
||||
protected $table = "sent_document";
|
||||
protected $fk = 'doc_id';
|
||||
|
||||
// 定义需要自动写入时间戳格式的字段
|
||||
protected $autoTimeField = array('create_time','update_time','deadline');
|
||||
|
||||
protected $auto = array('doc_id', 'title', 'description', 'update_time','deadline');
|
||||
protected $insert = array('uid', 'attach'=>0, 'view'=>0, 'comment'=>0, 'extend'=>0, 'create_time', 'status');
|
||||
|
||||
protected $type = array(
|
||||
'cover_id' => 'integer',
|
||||
'link_id' => 'integer',
|
||||
'level' => 'integer',
|
||||
'comment' => 'integer',
|
||||
'view' => 'integer',
|
||||
);
|
||||
|
||||
protected function setUidAttr(){
|
||||
return session('user_auth.uid');
|
||||
}
|
||||
|
||||
protected function setDocIdAttr(){
|
||||
return input('id','','intval,trim');
|
||||
}
|
||||
|
||||
protected function setDeadlineAttr($value){
|
||||
return $value ? strtotime($value) : time();
|
||||
}
|
||||
|
||||
protected function setCreateTimeAttr($value){
|
||||
return $value ? strtotime($value) : time();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据状态
|
||||
* @return integer 数据状态
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
protected function setStatusAttr($value){
|
||||
$cate = input('post.category_id');
|
||||
$check = db('Category')->getFieldById($cate, 'check');
|
||||
if($check){
|
||||
$status = 2;
|
||||
}else{
|
||||
$status = 1;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
public function extend($name){
|
||||
if (is_numeric($name)) {
|
||||
$name = db('model')->where(array('id'=>$name))->value('name');
|
||||
}
|
||||
self::$relationModel = array('document_' . $name);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function scopeList($query, $map, $field = '*', $limit = 10, $order = 'Document.id desc'){
|
||||
if (!empty($map) && is_array($map)) {
|
||||
foreach ($map as $key => $value) {
|
||||
$where[$this->name . '.' . $key] = $value;
|
||||
}
|
||||
}else{
|
||||
$where = $map;
|
||||
}
|
||||
$query->field($field)->where($where)->limit($limit)->order($order);
|
||||
}
|
||||
|
||||
public function change(){
|
||||
/* 获取数据对象 */
|
||||
$data = input('post.');
|
||||
|
||||
if ($data !== false) {
|
||||
/* 添加或新增基础内容 */
|
||||
if(empty($data['id'])){ //新增数据
|
||||
unset($data['id']);
|
||||
$id = $this->save($data); //添加基础内容
|
||||
|
||||
if(!$id){
|
||||
$this->error = '添加基础内容出错!';
|
||||
return false;
|
||||
}
|
||||
$data['id'] = $id;
|
||||
} else { //更新数据
|
||||
$status = $this->save($data, array('id'=>$data['id'])); //更新基础内容
|
||||
if(false === $status){
|
||||
$this->error = '更新基础内容出错!';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $data['id'];
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function del($map){
|
||||
return $this->db()->where($map)->delete();
|
||||
}
|
||||
|
||||
public function detail($id){
|
||||
$data = $this->get($id);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
98
application/common/model/Hooks.php
Normal file
98
application/common/model/Hooks.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 友情链接类
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
class Hooks extends Base {
|
||||
|
||||
public $keyList = array(
|
||||
array('name'=>'name','title'=>'钩子名称','type'=>'text','help'=>'需要在程序中先添加钩子,否则无效'),
|
||||
array('name'=>'description','title'=>'钩子描述','type'=>'text','help'=>'钩子的描述信息'),
|
||||
array('name'=>'type_text','title'=>'钩子类型','type'=>'select','help'=>'钩子的描述信息'),
|
||||
array('name'=>'addons','title'=>'插件排序','type'=>'kanban')
|
||||
);
|
||||
|
||||
public function initialize(){
|
||||
parent::initialize();
|
||||
foreach ($this->keyList as $key => $value) {
|
||||
if ($value['name'] == 'type_text') {
|
||||
$value['option'] = \think\Config::get('hooks_type');
|
||||
}
|
||||
$this->keyList[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
protected function setAddonsAttr($value){
|
||||
$string = implode(",", $value[1]);
|
||||
return $string;
|
||||
}
|
||||
|
||||
protected function getTypeTextAttr($value, $data){
|
||||
$hooks_type = config('hooks_type');
|
||||
return $hooks_type[$data['type']];
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理钩子挂载插件排序
|
||||
*/
|
||||
public function getaddons($addons = ''){
|
||||
if ($addons) {
|
||||
$hook_list = explode(',',$addons);
|
||||
foreach ($hook_list as $key => $value) {
|
||||
$field_list[] = array('id'=>$value,'title'=>$value,'name'=>$value,'is_show'=>1);
|
||||
}
|
||||
$option[1] = array('name'=>'钩子挂载排序','list'=>$field_list);
|
||||
}else{
|
||||
$option[] = array('name'=>'钩子挂载排序','list'=>array());
|
||||
}
|
||||
foreach ($this->keyList as $key => $value) {
|
||||
if ($value['name'] == 'addons') {
|
||||
$value['option'] = $option;
|
||||
}
|
||||
$keylist[] = $value;
|
||||
}
|
||||
return $keylist;
|
||||
}
|
||||
|
||||
public function change($data){
|
||||
if (!empty($data)) {
|
||||
if ($data['id']) {
|
||||
$this->save($data,array('id'=>$data['id']));
|
||||
}else{
|
||||
$this->save($data);
|
||||
}
|
||||
}else{
|
||||
$this->error = "非法操作!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function addHooks($addons_name){
|
||||
$addons_class = get_addon_class($addons_name);//获取插件名
|
||||
if(!class_exists($addons_class)){
|
||||
$this->error = "未实现{$addons_name}插件的入口文件";
|
||||
return false;
|
||||
}
|
||||
$methods = get_class_methods($addons_class);
|
||||
dump($methods);
|
||||
}
|
||||
|
||||
public function removeHooks($addons_name){
|
||||
$addons_class = get_addon_class($addons_name);//获取插件名
|
||||
if(!class_exists($addons_class)){
|
||||
$this->error = "未实现{$addons_name}插件的入口文件";
|
||||
return false;
|
||||
}
|
||||
$methods = get_class_methods($addons_class);
|
||||
}
|
||||
}
|
||||
40
application/common/model/Link.php
Normal file
40
application/common/model/Link.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 友情链接类
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
class Link extends \app\common\model\Base {
|
||||
|
||||
public $keyList = array(
|
||||
array('name'=>'id' ,'title'=>'ID', 'type'=>'hidden'),
|
||||
array('name'=>'title' ,'title'=>'友链标题', 'type'=>'text', 'help'=>''),
|
||||
array('name'=>'url' ,'title'=>'URL链接', 'type'=>'text', 'help'=>''),
|
||||
array('name'=>'ftype' ,'title'=>'友链类别', 'type'=>'select', 'option'=>array(
|
||||
'1' => '常用链接',
|
||||
'2' => '网站导读',
|
||||
'3' => '对公服务',
|
||||
'4' => '校内服务',
|
||||
), 'help'=>''),
|
||||
array('name'=>'cover_id' ,'title'=>'网站LOGO', 'type'=>'image', 'help'=>''),
|
||||
array('name'=>'status' ,'title'=>'状态', 'type'=>'select','option'=>array('1'=>'启用','0'=>'禁用'), 'help'=>''),
|
||||
array('name'=>'sort' ,'title'=>'链接排序', 'type'=>'text', 'help'=>''),
|
||||
array('name'=>'descrip' ,'title'=>'描述', 'type'=>'textarea', 'help'=>'')
|
||||
);
|
||||
|
||||
protected $auto = array('update_time');
|
||||
|
||||
protected $type = array(
|
||||
'cover_id' => 'integer',
|
||||
'sort' => 'integer',
|
||||
);
|
||||
}
|
||||
36
application/common/model/Menu.php
Normal file
36
application/common/model/Menu.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 菜单模型类
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
class Menu extends \app\common\model\Base {
|
||||
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
);
|
||||
|
||||
public function getAuthNodes($type = 'admin'){
|
||||
$map['type'] = $type;
|
||||
$rows = $this->db()->field('id,pid,group,title,url')->where($map)->order('id asc')->select();
|
||||
foreach ($rows as $key => $value) {
|
||||
$data[$value['id']] = $value;
|
||||
}
|
||||
foreach ($data as $key => $value) {
|
||||
if ($value['pid'] > 0) {
|
||||
$value['group'] = $data[$value['pid']]['title'] . '管理';
|
||||
$list[] = $value;
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
170
application/common/model/Model.php
Normal file
170
application/common/model/Model.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Model extends Base{
|
||||
|
||||
protected $auto = [ 'update_time', 'field_sort', 'attribute_list'];
|
||||
protected $insert = ['name', 'create_time', 'status'=>1];
|
||||
protected $type = array(
|
||||
'id' => 'integer'
|
||||
);
|
||||
|
||||
public function setFieldSortAttr($value){
|
||||
return empty($value) ? '' : json_encode($value);
|
||||
}
|
||||
|
||||
public function setNameAttr($value){
|
||||
return strtolower($value);
|
||||
}
|
||||
|
||||
public function setAttributeListAttr($value){
|
||||
return empty($value) ? '' : json_encode($value);
|
||||
}
|
||||
|
||||
public function getStatusTextAttr($value, $data){
|
||||
$status = array(
|
||||
0 => '禁用',
|
||||
1 => '启用',
|
||||
);
|
||||
return $status[$data['status']];
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新一个或新增一个模型
|
||||
* @return array
|
||||
*/
|
||||
public function change() {
|
||||
if(IS_POST){
|
||||
$data = input('post.',array());
|
||||
if($data){
|
||||
if (empty($data['id'])) {
|
||||
/*创建表*/
|
||||
$db = new \com\Datatable();
|
||||
//文档模型
|
||||
if($data['extend'] == 1){
|
||||
//默认文档前缀
|
||||
$tablename = 'document_'.$data['name'];
|
||||
}else{
|
||||
$tablename = $data['name'];
|
||||
}
|
||||
$sql = $db->start_table($tablename)
|
||||
->create_id('id', 11 , '主键' , false);
|
||||
if ($data['extend'] != 1) {
|
||||
$sql = $sql->create_uid();
|
||||
}
|
||||
$sql->create_key('id')->end_table($data['title'], $data['engine_type'])
|
||||
->create();
|
||||
$id = $this->validate('model.add')->save($data);
|
||||
if (false === $id) {
|
||||
return array('info'=>$this->getError(), 'status'=>0);
|
||||
}else{
|
||||
// 清除模型缓存数据
|
||||
cache('document_model_list', null);
|
||||
|
||||
//记录行为
|
||||
action_log('update_model', 'model', $id, session('auth_user.uid'));
|
||||
return $id ? array('info'=>'创建模型成功!','status'=>1) : array('info'=>'创建模型失败!','status'=>1);
|
||||
}
|
||||
} else {
|
||||
//修改
|
||||
$status = $this->validate('model.edit')->save($data,array('id'=>$data['id']));
|
||||
if (false === $status) {
|
||||
return array('info'=>$this->getError(), 'status'=>0);
|
||||
}else{
|
||||
// 清除模型缓存数据
|
||||
cache('document_model_list', null);
|
||||
//记录行为
|
||||
action_log('update_model','model',$data['id'],session('auth_user.uid'));
|
||||
return array('info'=>'保存模型成功!','status'=>1);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return array('info'=>$this->getError(),'status'=>0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function del(){
|
||||
$id = input('id','','trim,intval');
|
||||
$model = $this->db()->where(array('id'=>$id))->find();
|
||||
|
||||
if ($model['extend'] == 0) {
|
||||
$this->error = "基础模型不允许删除!";
|
||||
return false;
|
||||
}elseif ($model['extend'] == 1){
|
||||
$tablename = 'document_'.$model['name'];
|
||||
}elseif ($model['extend'] == 2){
|
||||
$tablename = $model['name'];
|
||||
}
|
||||
//删除数据表
|
||||
$db = new \com\Datatable();
|
||||
if ($db->CheckTable($tablename)) {
|
||||
//检测表是否存在
|
||||
$result = $db->del_table($tablename)->query();
|
||||
if (!$result) {
|
||||
return false;
|
||||
$this->error = "数据表删除失败!";
|
||||
}
|
||||
}
|
||||
$result = $this->db()->where(array('id'=>$id))->delete();
|
||||
if ($result) {
|
||||
return true;
|
||||
}else{
|
||||
$this->error = "模型删除失败!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function attribute(){
|
||||
return $this->hasMany('Attribute');
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析字段
|
||||
* @param [array] $model [字段]
|
||||
* @return [array] [解析后的字段]
|
||||
*/
|
||||
public function preFields($model){
|
||||
$fields = $model->attribute;
|
||||
$groups = parse_config_attr($model['field_group']);
|
||||
$field_sort = json_decode($model['field_sort'],true);;
|
||||
|
||||
//获得数组的第一条数组
|
||||
$first_key = array_keys($groups);
|
||||
if (!empty($field_sort)) {
|
||||
foreach ($field_sort as $key => $value) {
|
||||
foreach ($value as $index) {
|
||||
if (isset($fields[$index])) {
|
||||
$groupfield[$key][] = $fields[$index];
|
||||
unset($fields[$index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//未进行排序的放入第一组中
|
||||
$fields[] = array('name'=>'model_id','type'=>'hidden'); //加入模型ID值
|
||||
$fields[] = array('name'=>'id','type'=>'hidden'); //加入模型ID值
|
||||
foreach ($fields as $key => $value) {
|
||||
$groupfield[$first_key[0]][] = $value;
|
||||
}
|
||||
|
||||
foreach ($groups as $key => $value) {
|
||||
if ($groupfield[$key]) {
|
||||
$data[$value] = $groupfield[$key];
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
return array();
|
||||
}
|
||||
}
|
||||
58
application/common/model/Order.php
Normal file
58
application/common/model/Order.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | OneThink [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 分类模型
|
||||
*/
|
||||
class Order extends Base{
|
||||
|
||||
protected $auto = array('update_time');
|
||||
protected $insert = array('create_time', 'uid', 'status'=>1, 'order_no');
|
||||
|
||||
protected function setOrderNoAttr($value){
|
||||
return 'SN'.date('YmdHis',time()).rand('1000','9999');
|
||||
}
|
||||
|
||||
protected function setUidAttr($value){
|
||||
return session('user_auth.uid');
|
||||
}
|
||||
|
||||
protected function getPayTypeTextAttr($value, $data){
|
||||
$type = array('wechat'=>'微信支付', 'alipay'=>'支付宝支付');
|
||||
return $type[$data['pay_type']];
|
||||
}
|
||||
protected function getPayStatusTextAttr($value, $data){
|
||||
$type = array(
|
||||
0 => '未付款',
|
||||
1 => '已付款',
|
||||
);
|
||||
return $type[$data['pay_status']];
|
||||
}
|
||||
|
||||
public function product(){
|
||||
return $this->hasMany('OrderProduct', 'order_no', 'order_no');
|
||||
}
|
||||
|
||||
//生成订单
|
||||
public function createOrder($data){
|
||||
$order_id = $this->save($data);
|
||||
foreach ($data['list'] as $key => $value) {
|
||||
$value['order_no'] = $this->data['order_no'];
|
||||
$value['product_id'] = $value['id'];
|
||||
unset($value['id']);
|
||||
$value['create_time'] = time();
|
||||
$value['update_time'] = time();
|
||||
$goods[] = $value;
|
||||
}
|
||||
db('OrderProduct')->insertAll($goods);
|
||||
return $order_id;
|
||||
}
|
||||
}
|
||||
20
application/common/model/OrderProduct.php
Normal file
20
application/common/model/OrderProduct.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | OneThink [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 分类模型
|
||||
*/
|
||||
class OrderProduct extends Base{
|
||||
|
||||
public function book(){
|
||||
return $this->hasOne('Book', 'id', 'product_id');
|
||||
}
|
||||
}
|
||||
17
application/common/model/Page.php
Normal file
17
application/common/model/Page.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | OneThink [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 分类模型
|
||||
*/
|
||||
class Page extends Content{
|
||||
|
||||
}
|
||||
102
application/common/model/SeoRule.php
Normal file
102
application/common/model/SeoRule.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 用户模型
|
||||
*/
|
||||
class SeoRule extends Base{
|
||||
|
||||
protected function getAppAttr($value){
|
||||
return $value ? $value : '*';
|
||||
}
|
||||
|
||||
protected function getControllerAttr($value){
|
||||
return $value ? $value : '*';
|
||||
}
|
||||
|
||||
protected function getActionAttr($value){
|
||||
return (isset($value) && $value) ? $value : '*';
|
||||
}
|
||||
|
||||
protected function getRuleNameAttr($value, $data){
|
||||
return $data['app'].'/'.$data['controller'].'/'.$data['action'];
|
||||
}
|
||||
|
||||
public function getMetaOfCurrentPage($seo){
|
||||
$request = \think\Request::instance();
|
||||
$result = $this->getMeta($request->module(), $request->controller(), $request->action(), $seo);
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function getMeta($module, $controller, $action, $seo){
|
||||
//查询缓存,如果已有,则直接返回
|
||||
$cacheKey = "sent_seo_meta_{$module}_{$controller}_{$action}";
|
||||
$cache = cache($cacheKey);
|
||||
if($cache !== false) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
//获取相关的规则
|
||||
$rules = $this->getRelatedRules($module, $controller, $action);
|
||||
|
||||
//按照排序计算最终结果
|
||||
$title = '';
|
||||
$keywords = '';
|
||||
$description = '';
|
||||
|
||||
$need_seo = 1;
|
||||
foreach ($rules as $e) {
|
||||
//如果存在完全匹配的seo配置,则不用程序设置的seo资料
|
||||
if ($e['app'] && $e['controller'] && $e['action']) {
|
||||
$need_seo = 0;
|
||||
}
|
||||
if (!$title && $e['seo_title']) {
|
||||
$title = $e['seo_title'];
|
||||
}
|
||||
if (!$keywords && $e['seo_keywords']) {
|
||||
$keywords = $e['seo_keywords'];
|
||||
}
|
||||
if (!$description && $e['seo_description']) {
|
||||
$description = $e['seo_description'];
|
||||
}
|
||||
}
|
||||
if ($need_seo) { //默认让全站的seo规则优先级小于$this->setTitle等方式设置的规则。
|
||||
if ($seo['title']) {
|
||||
$title = $seo['title'];
|
||||
}
|
||||
if ($seo['keywords']) {
|
||||
$keywords = $seo['keywords'];
|
||||
}
|
||||
if ($seo['description']) {
|
||||
$description = $seo['description'];
|
||||
}
|
||||
}
|
||||
//生成结果
|
||||
$result = array('title' => $title, 'keywords' => $keywords, 'description' => $description);
|
||||
|
||||
//写入缓存
|
||||
cache($cacheKey, $result);
|
||||
|
||||
//返回结果
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function getRelatedRules($module, $controller, $action){
|
||||
//查询与当前页面相关的SEO规则
|
||||
$map = array();
|
||||
$map = "(app='' or app='$module') and (controller='' or controller='$controller') and (action='' or action='$action') and status=1";
|
||||
|
||||
$rules = $this->db()->where($map)->order('sort asc')->select();
|
||||
|
||||
//返回规则列表
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
225
application/common/model/User.php
Normal file
225
application/common/model/User.php
Normal file
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 用户模型
|
||||
*/
|
||||
class User extends \think\model\Merge{
|
||||
|
||||
protected $name = "Member";
|
||||
protected static $relationModel = array('MemberExtend');
|
||||
protected $createTime = 'reg_time';
|
||||
protected $updateTime = 'last_login_time';
|
||||
protected $fk = 'user_id';
|
||||
protected $mapFields = array(
|
||||
'uid' => 'Member.uid',
|
||||
'user_id' => 'MemberExtend.uid',
|
||||
);
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
);
|
||||
protected $insert = array('salt', 'password', 'status', 'reg_time');
|
||||
protected $update = array();
|
||||
|
||||
public $editfield = array(
|
||||
array('name'=>'uid','type'=>'hidden'),
|
||||
array('name'=>'username','title'=>'用户名','type'=>'readonly','help'=>''),
|
||||
array('name'=>'nickname','title'=>'昵称','type'=>'text','help'=>''),
|
||||
array('name'=>'password','title'=>'密码','type'=>'password','help'=>'为空时则不修改'),
|
||||
array('name'=>'sex','title'=>'性别','type'=>'select','option'=>array('0'=>'保密','1'=>'男','2'=>'女'),'help'=>''),
|
||||
array('name'=>'email','title'=>'邮箱','type'=>'text','help'=>'用户邮箱,用于找回密码等安全操作'),
|
||||
array('name'=>'qq','title'=>'QQ','type'=>'text','help'=>''),
|
||||
array('name'=>'score','title'=>'用户积分','type'=>'text','help'=>''),
|
||||
array('name'=>'signature','title'=>'用户签名','type'=>'textarea','help'=>''),
|
||||
array('name'=>'status','title'=>'状态','type'=>'select','option'=>array('0'=>'禁用','1'=>'启用'),'help'=>''),
|
||||
);
|
||||
|
||||
public $addfield = array(
|
||||
array('name'=>'username','title'=>'用户名','type'=>'text','help'=>'用户名会作为默认的昵称'),
|
||||
array('name'=>'password','title'=>'密码','type'=>'password','help'=>'用户密码不能少于6位'),
|
||||
array('name'=>'repassword','title'=>'确认密码','type'=>'password','help'=>'确认密码'),
|
||||
array('name'=>'email','title'=>'邮箱','type'=>'text','help'=>'用户邮箱,用于找回密码等安全操作'),
|
||||
);
|
||||
|
||||
public $useredit = array(
|
||||
array('name'=>'uid','type'=>'hidden'),
|
||||
array('name'=>'nickname','title'=>'昵称','type'=>'text','help'=>''),
|
||||
array('name'=>'sex','title'=>'性别','type'=>'select','option'=>array('0'=>'保密','1'=>'男','2'=>'女'),'help'=>''),
|
||||
array('name'=>'email','title'=>'邮箱','type'=>'text','help'=>'用户邮箱,用于找回密码等安全操作'),
|
||||
array('name'=>'qq','title'=>'QQ','type'=>'text','help'=>''),
|
||||
array('name'=>'score','title'=>'用户积分','type'=>'text','help'=>''),
|
||||
array('name'=>'signature','title'=>'用户签名','type'=>'textarea','help'=>''),
|
||||
);
|
||||
|
||||
protected function setStatusAttr($value){
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected function setPasswordAttr($value){
|
||||
return md5($value.$this->data['salt']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登录模型
|
||||
*/
|
||||
public function login($username = '', $password = '', $type = 1){
|
||||
$map = array();
|
||||
switch ($type) {
|
||||
case 1:
|
||||
$map['username'] = $username;
|
||||
break;
|
||||
case 2:
|
||||
$map['email'] = $username;
|
||||
break;
|
||||
case 3:
|
||||
$map['mobile'] = $username;
|
||||
break;
|
||||
case 4:
|
||||
$map['uid'] = $username;
|
||||
break;
|
||||
case 5:
|
||||
$map['uid'] = $username;
|
||||
break;
|
||||
default:
|
||||
return 0; //参数错误
|
||||
}
|
||||
|
||||
$user = $this->db()->where($map)->find()->toArray();
|
||||
if(is_array($user) && $user['status']){
|
||||
/* 验证用户密码 */
|
||||
if(md5($password.$user['salt']) === $user['password']){
|
||||
$this->autoLogin($user); //更新用户登录信息
|
||||
return $user['uid']; //登录成功,返回用户ID
|
||||
} else {
|
||||
return -2; //密码错误
|
||||
}
|
||||
} else {
|
||||
return -1; //用户不存在或被禁用
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
* @param integer $user 用户信息数组
|
||||
*/
|
||||
function register($username, $password, $repassword, $isautologin = true){
|
||||
if ($password !== $repassword) {
|
||||
$this->error = "密码和确认密码不相同";
|
||||
return false;
|
||||
}
|
||||
|
||||
$data['username'] = $username;
|
||||
$data['salt'] = rand_string(6);
|
||||
$data['password'] = $password;
|
||||
$result = $this->validate(true)->save($data);
|
||||
if ($result) {
|
||||
$this->data['uid'] = $result;
|
||||
if ($isautologin) {
|
||||
$this->autoLogin($this->data);
|
||||
}
|
||||
return $result;
|
||||
}else{
|
||||
if (!$this->getError()) {
|
||||
$this->error = "注册失败!";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动登录用户
|
||||
* @param integer $user 用户信息数组
|
||||
*/
|
||||
private function autoLogin($user){
|
||||
/* 更新登录信息 */
|
||||
$data = array(
|
||||
'uid' => $user['uid'],
|
||||
'login' => array('exp', '`login`+1'),
|
||||
'last_login_time' => time(),
|
||||
'last_login_ip' => get_client_ip(1),
|
||||
);
|
||||
$this->db()->where(array('uid'=>$user['uid']))->update($data);
|
||||
$user = $this->db()->where(array('uid'=>$user['uid']))->find();
|
||||
|
||||
/* 记录登录SESSION和COOKIES */
|
||||
$auth = array(
|
||||
'uid' => $user['uid'],
|
||||
'username' => $user['username'],
|
||||
'last_login_time' => $user['last_login_time'],
|
||||
);
|
||||
|
||||
session('user_auth', $auth);
|
||||
session('user_auth_sign', data_auth_sign($auth));
|
||||
}
|
||||
|
||||
public function logout(){
|
||||
session('user_auth', null);
|
||||
session('user_auth_sign', null);
|
||||
}
|
||||
|
||||
public function getInfo($uid){
|
||||
$data = $this->db()->where(array('uid'=>$uid))->find();
|
||||
if ($data) {
|
||||
return $data->toArray();
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function change(){
|
||||
$data = input('post.');
|
||||
if ($data['uid']) {
|
||||
return $this->save($data, array('uid'=>$data['uid']));
|
||||
}else{
|
||||
$this->error = "非法操作!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function editpw(){
|
||||
$data = input('post.');
|
||||
$username = session('user_auth.username');
|
||||
$uid = session('user_auth.uid');
|
||||
$result = $this->checkPassword($username,$data['oldpassword']);
|
||||
if (!$result) {
|
||||
$this->error = '原始密码错误!';
|
||||
return false;
|
||||
}
|
||||
if (!$data['password']) {
|
||||
$this->error = '密码不能为空!';
|
||||
return false;
|
||||
}
|
||||
if ($data['password'] !== $data['repassword']) {
|
||||
$this->error = '密码和确认密码不相同!';
|
||||
return false;
|
||||
}
|
||||
if (!$uid) {
|
||||
return false;
|
||||
}
|
||||
$data['salt'] = rand_string(6);
|
||||
$data['password'] = md5($data['password'].$data['salt']);
|
||||
$data['uid'] = $uid;
|
||||
return $this->db()->where(array('uid'=>$uid))->update($data);
|
||||
}
|
||||
|
||||
protected function checkPassword($username,$password){
|
||||
if (!$username || !$password) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = $this->db()->where(array('username'=>$username))->find()->toArray();
|
||||
if (md5($password.$user['salt']) === $user['password']) {
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user