重新初始化

This commit is contained in:
2020-02-17 20:47:06 +08:00
parent 5c320206fb
commit 58d999ed73
4016 changed files with 1271 additions and 302396 deletions

View File

@@ -1,20 +0,0 @@
<?php
namespace app\model;
use think\Model;
class Ad extends Model {
public $status = array(
1 => '开启',
0 => '关闭'
);
public function getCoverAttr($value, $data){
return get_cover($data['cover_id'], 'path');
}
public function getStatusTextAttr($value, $data){
return isset($this->status[$data['status']]) ? $this->status[$data['status']] : '未知';
}
}

View File

@@ -1,33 +0,0 @@
<?php
namespace app\model;
use think\Model;
class AdPlace extends Model {
protected $type = array(
'start_time' => 'timestamp',
'end_time' => 'timestamp'
);
public $show_type = array(
1 => '幻灯片',
2 => '对联',
3 => '图片列表',
4 => '图文列表',
5 => '文字列表',
6 => '代码广告'
);
public $status = array(
1 => '开启',
0 => '关闭'
);
public function getShowTypeTextAttr($value, $data){
return isset($this->show_type[$data['show_type']]) ? $this->show_type[$data['show_type']] : '未知';
}
public function getStatusTextAttr($value, $data){
return isset($this->status[$data['status']]) ? $this->status[$data['status']] : '未知';
}
}

View File

@@ -1,19 +0,0 @@
<?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\model;
use think\Model;
/**
* @title: À¸Ä¿Ä£ÐÍ
*/
class Category extends Model {
}

View File

@@ -1,9 +0,0 @@
<?php
namespace app\model;
use think\Model;
class Channel extends Model
{
}

View File

@@ -1,15 +0,0 @@
<?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\model;
use think\Model;
class Client extends Model {
}

View File

@@ -1,122 +0,0 @@
<?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\model;
use think\facade\Cache;
use think\Model;
/**
* 设置模型
*/
class Config extends Model {
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) {
$config = Cache::get('system_config');
$type = $config['config_type_list'];
$type_text = explode(',', $type[$data['type']]);
return $type_text[0];
}
protected function getGroupTextAttr($value, $data) {
$config = Cache::get('system_config');
$group = $config['config_group_list'];
return isset($group[$data['group']]) ? $group[$data['group']] : '未分组';
}
public function lists() {
$map = array('status' => 1);
$res = $this->where($map)->field('type,name,value')->select();
$config = array();
foreach ($res->toArray() as $value) {
$config[$value['name']] = $this->parse($value['type'], $value['value']);
}
return $config;
}
public function updateConfig($data) {
if (empty($data['config'])) {
$this->error = "无更新";
return false;
}
foreach ($data['config'] as $key => $value) {
self::update(['value' => $value], ['name' => $key], ['value']);
}
Cache::set('system_config', null);
return true;
}
/**
* 根据配置类型解析配置
* @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;
}
public function getThemesList() {
$files = array();
$files['pc'] = $this->getList('pc');
$files['mobile'] = $this->getList('mobile');
return $files;
}
protected function getList($type) {
$path = './template/';
$file = opendir($path);
while (false !== ($filename = readdir($file))) {
if (!in_array($filename, array('.', '..'))) {
$files = $path . $filename . '/info.php';
if (is_file($files)) {
$info = include $files;
if (isset($info['type']) && $info['type'] == $type) {
$info['id'] = $filename;
$info['img'] = '/template/' . $filename . '/' . $info['img'];
$list[] = $info;
} else {
continue;
}
}
}
}
return isset($list) ? $list : array();
}
}

View File

@@ -1,10 +0,0 @@
<?php
namespace app\model;
use think\Model;
class Content extends Model {
// 定义默认的表后缀(默认查询中文数据)
protected $suffix = '';
}

View File

@@ -1,17 +0,0 @@
<?php
namespace app\model;
use think\Model;
class Form extends Model {
public $status = array(
1 => '开启',
0 => '关闭'
);
public function getStatusTextAttr($value, $data){
return isset($this->status[$data['status']]) ? $this->status[$data['status']] : '未知';
}
}

View File

@@ -1,15 +0,0 @@
<?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\model;
use think\Model;
class Link extends Model {
}

View File

@@ -1,125 +0,0 @@
<?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\model;
use think\Model;
/**
* @title: 用户模型
*/
class Member extends Model {
protected $pk = 'uid';
protected $createTime = 'reg_time';
protected $updateTime = 'last_login_time';
protected $insert = ['reg_ip'];
protected $type = [
'uid' => 'integer',
'reg_time' => 'integer',
];
public $loginVisible = array('uid', 'username', 'nickname', 'access_token'); //用户登录成功返回的字段
protected function setPasswordAttr($value) {
$salt = rand_string(6);
$this->set('salt', $salt);
return md5($value . $salt);
}
protected function setRegIpAttr($value) {
return get_client_ip(1);
}
protected function getAccessTokenAttr($value, $data) {
return authcode($data['uid'] . '|' . $data['username'] . '|' . $data['password'], 'ENCODE');
}
/**
* @title 用户登录
* param username:用户名、手机号码、邮箱 password:密码、手机验证码、开源类型 type:登录类型(账号密码登录、手机号码+验证码登录、开源账号登录)
*/
public function login($username, $password, $type = 1) {
$map = array();
if (preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $username)) {
$type = 2;
} elseif (preg_match("/^1[34578]{1}\d{9}$/", $username)) {
$type = 3;
}
switch ($type) {
case 1:
$map['username'] = $username;
break;
case 2:
$map['email'] = $username;
break;
case 3:
$map['mobile'] = $username;
break;
default:
return false; //参数错误
}
if (!$username) {
return false;
}
$user = $this->where($map)->find();
if (isset($user['uid']) && $user['uid'] && $user['status']) {
/* 验证用户密码 */
if (md5($password . $user['salt']) === $user['password']) {
/* 更新登录信息 */
(new MemberLog())->record($user);
return $user->append(array('access_token'))->visible($this->loginVisible)->toArray(); //登录成功,返回用户信息
} else {
$this->error = "密码错误";
return false; //密码错误
}
} else {
$this->error = "用户不存在或被禁用";
return false;
}
}
/**
* @title: 注册
*/
public function register($data) {
$result = self::create($data);
if (false !== $result) {
$user = $this->where('uid', $result->uid)->find();
} else {
$this->error = "注册失败!";
return false;
}
/* 更新登录信息 */
(new MemberLog())->record($user);
return $user->append(array('access_token'))->visible($this->loginVisible)->toArray(); //登录成功,返回用户信息
}
/**
* @title: 获取用户列表
*/
public function getUserList() {
}
/**
* @title: 获取用户信息
*/
public function getInfo($uid) {
}
public function socialite() {
return $this->hasMany('MemberSocialite', 'uid', 'uid');
}
}

View File

@@ -1,29 +0,0 @@
<?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\model;
use think\Model;
/**
* @title: 用户日志模型
*/
class MemberLog extends Model {
public function record($user){
/* 更新登录信息 */
$data = array(
'uid' => $user['uid'],
'login' => array('inc', '1'),
'last_login_time' => time(),
'last_login_ip' => get_client_ip(1),
);
Member::where(array('uid'=>$user['uid']))->update($data);
}
}

View File

@@ -1,59 +0,0 @@
<?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 MemberSocialite extends Base{
protected $type = array(
'uid' => 'integer',
);
public function register(){
if ($socialite->where('openid', $data['info']['openid'])->value('id')) {
$this->error = "请勿重复注册!";
return false;
} else {
$account = array(
'username' => $data['info']['openid'],
'password' => rand_string(8),
);
$result = self::create($account);
if (false !== $result) {
$socialite_info = $data['info'];
$user = $this->where('uid', $result->uid)->find();
$socialite_info['uid'] = $user['uid'];
$socialite_info['type'] = $data['open_type'];
$socialite->register($socialite_info);
} else {
$this->error = "注册失败!";
return false;
}
}
}
public function wechatLogin($user_info){
$socialite = $this->where('openid', $user_info['openid'])->where('type', 'wechat')->find();
$member = new Member();
if ($socialite) {
$this->where('id', $socialite['id'])->update($user_info);
if ($socialite['uid'] > 0) {
//绑定了用户则自动登录
$user = $member->where('uid', $socialite['uid'])->find();
$member->autoLogin($user);
}
}else{
$user_info['type'] = 'wechat';
$this->insert($user_info);
}
}
}

View File

@@ -1,45 +0,0 @@
<?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\model;
use think\facade\Cache;
use think\Model;
use think\Request;
/**
* @title: ²Ëµ¥Ä£ÐÍ
*/
class Menu extends Model {
/**
* @title ÏÔʾ²Ëµ¥
*/
public function getAuthMenuList(Request $request) {
$list = [];
$current_controller = '/' . str_replace('.', '/', strtolower($request->controller()));
$current_url = $request->url;
$menu = Cache::get('menu');
if (!$menu) {
$res = self::where('is_menu', 1)->order('sort asc, id asc')->select()->toArray();
foreach ($res as $key => $item) {
$menu[$item['id']] = $item;
}
Cache::set('menu', $menu);
}
foreach ($menu as $key => $value) {
if ($request->isAdmin || in_array($value['id'], array())) {
$list[$value['id']] = $value;
}
}
$menuList = list_to_tree($list);
return $menuList;
}
}

View File

@@ -1,9 +0,0 @@
<?php
namespace app\model;
use think\Model;
class Model extends Model
{
}

View File

@@ -1,8 +0,0 @@
<?php
namespace app\model;
use think\Model;
class Rewrite extends Model {
}

View File

@@ -1,8 +0,0 @@
<?php
namespace app\model;
use think\Model;
class SeoRule extends Model {
}