代码更新
This commit is contained in:
1177
app/common.php
1177
app/common.php
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@
|
|||||||
namespace app\controller;
|
namespace app\controller;
|
||||||
|
|
||||||
use app\BaseController;
|
use app\BaseController;
|
||||||
|
use think\facade\Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title 后端公共模块
|
* @title 后端公共模块
|
||||||
@@ -21,6 +22,15 @@ class Admin extends BaseController {
|
|||||||
'\app\middleware\Admin'
|
'\app\middleware\Admin'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $data = ['meta' => [], 'data' => [], 'code' => 0, 'msg' => ''];
|
protected $data = ['meta' => ['title'=>''], 'data' => [], 'code' => 0, 'msg' => ''];
|
||||||
|
|
||||||
|
protected function initialize(){
|
||||||
|
$config = Config::get('system');
|
||||||
|
if (!$config) {
|
||||||
|
$config = (new \app\model\Config())->lists();
|
||||||
|
Config::set($config, 'system');
|
||||||
|
}
|
||||||
|
$this->data['config'] = $config;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
namespace app\controller\admin;
|
namespace app\controller\admin;
|
||||||
|
|
||||||
use app\controller\Admin;
|
use app\controller\Admin;
|
||||||
|
use app\model\Config as ConfigModel;
|
||||||
|
|
||||||
class Config extends Admin{
|
class Config extends Admin{
|
||||||
|
|
||||||
@@ -22,7 +23,21 @@ class Config extends Admin{
|
|||||||
/**
|
/**
|
||||||
* @title 系统首页
|
* @title 系统首页
|
||||||
*/
|
*/
|
||||||
public function group(){
|
public function group(ConfigModel $config){
|
||||||
|
if ($this->request->isAjax()) {
|
||||||
|
# code...
|
||||||
|
}else{
|
||||||
|
$this->data['id'] = $this->request->param('id', 1);
|
||||||
|
$res = $config->where(array('status' => 1, 'group' => $this->data['id']))->field('id,name,title,extra,value,remark,type')->order('sort')->select();
|
||||||
|
|
||||||
|
$this->data['list'] = $res->toArray();
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title 主题设置
|
||||||
|
*/
|
||||||
|
public function themes(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,9 +13,15 @@ use app\controller\Admin;
|
|||||||
class Database extends Admin{
|
class Database extends Admin{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title 系统首页
|
* @title 数据备份
|
||||||
*/
|
*/
|
||||||
public function index(){
|
public function export(){
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @title 数据导入
|
||||||
|
*/
|
||||||
|
public function import(){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,11 +31,31 @@ class Index extends Admin{
|
|||||||
/**
|
/**
|
||||||
* @title 后台登录
|
* @title 后台登录
|
||||||
*/
|
*/
|
||||||
public function login(){
|
public function login(\app\model\Member $member){
|
||||||
if ($this->request->isAjax()) {
|
if ($this->request->isAjax()) {
|
||||||
Session::set('user', ['uid'=>1,'username'=>'admin']);
|
$username = $this->request->param('username', '');
|
||||||
|
$password = $this->request->param('password', '');
|
||||||
|
$user = $member->login($username, $password);
|
||||||
|
if ($user) {
|
||||||
|
Session::set('user', $user);
|
||||||
|
$this->data['url'] = "/admin/index/index.html";
|
||||||
|
$this->data['msg'] = "登录成功!";
|
||||||
|
}else{
|
||||||
|
Session::set('user', null);
|
||||||
|
$this->data['code'] = 1;
|
||||||
|
$this->data['msg'] = "登录失败!";
|
||||||
|
}
|
||||||
|
|
||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title 后台登出
|
||||||
|
*/
|
||||||
|
public function logout(){
|
||||||
|
Session::set('user', null);
|
||||||
|
$this->data['code'] = 0;
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,4 +18,11 @@ class Seo extends Admin{
|
|||||||
public function index(){
|
public function index(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title 重写规则
|
||||||
|
*/
|
||||||
|
public function rewrite(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -19,11 +19,15 @@ class Admin {
|
|||||||
|
|
||||||
public function handle($request, \Closure $next) {
|
public function handle($request, \Closure $next) {
|
||||||
$response = $next($request);
|
$response = $next($request);
|
||||||
$this->data = $response->getData();
|
if (is_array($response->getData())) {
|
||||||
|
$this->data = array_merge($this->data, $response->getData());
|
||||||
|
} else {
|
||||||
|
$this->data = $response->getData();
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->isAjax()) {
|
if ($request->isAjax()) {
|
||||||
return json($this->data);
|
return json($this->data);
|
||||||
}else{
|
} else {
|
||||||
return $response->data($this->fetch());
|
return $response->data($this->fetch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,17 +35,18 @@ class Admin {
|
|||||||
/**
|
/**
|
||||||
* @title 显示类
|
* @title 显示类
|
||||||
*/
|
*/
|
||||||
protected function fetch($template = ''){
|
protected function fetch($template = '') {
|
||||||
// 使用内置PHP模板引擎渲染模板输出
|
// 使用内置PHP模板引擎渲染模板输出
|
||||||
$config = array(
|
$config = array(
|
||||||
'tpl_replace_string' => array(
|
'tpl_replace_string' => array(
|
||||||
'__static__' => '/static',
|
'__static__' => '/static',
|
||||||
'__img__' => '/static/admin/images',
|
'__img__' => '/static/admin/images',
|
||||||
'__css__' => '/static/admin/css',
|
'__css__' => '/static/admin/css',
|
||||||
'__js__' => '/static/admin/js',
|
'__js__' => '/static/admin/js',
|
||||||
'__public__' => '/static/admin',
|
'__public__' => '/static/admin',
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return View::config($config)->assign($this->data)->fetch($template);
|
return View::config($config)->assign($this->data)->fetch($template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,21 +8,81 @@
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
namespace app\middleware;
|
namespace app\middleware;
|
||||||
|
|
||||||
use think\facade\View;
|
use think\facade\Cache;
|
||||||
use think\facade\Session;
|
use think\facade\Session;
|
||||||
|
use think\facade\View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title 后台中间件
|
* @title 后台中间件
|
||||||
*/
|
*/
|
||||||
class AdminAuth {
|
class AdminAuth {
|
||||||
|
|
||||||
|
protected $data = ['headerMenu' => [], 'asideMenu' => []];
|
||||||
|
|
||||||
public function handle($request, \Closure $next) {
|
public function handle($request, \Closure $next) {
|
||||||
$user = Session::get('user');
|
$user = Session::get('user');
|
||||||
|
|
||||||
if (Session::has('user') && $user['uid']) {
|
if (Session::has('user') && $user['uid']) {
|
||||||
|
$request->user = $user;
|
||||||
|
if ($user['uid'] == 1) {
|
||||||
|
$request->isAdmin = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getMenu($request); //设置菜单
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}else{
|
} else {
|
||||||
return redirect(url('admin.index/login'))->remember();
|
return redirect(url('admin.index/login'))->remember();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title 显示菜单
|
||||||
|
*/
|
||||||
|
protected function getMenu($request) {
|
||||||
|
$current_controller = str_replace('.', '/', strtolower($request->controller()));
|
||||||
|
$current_url = $current_controller . '/' . strtolower($request->action());
|
||||||
|
$menu = Cache::get('menu');
|
||||||
|
if (!$menu) {
|
||||||
|
$dao = new \app\model\Menu();
|
||||||
|
$res = $dao->where('is_menu', 1)->select();
|
||||||
|
$menu = $res->toArray();
|
||||||
|
Cache::set('menu', $menu);
|
||||||
|
}
|
||||||
|
$current_pid = 0;
|
||||||
|
foreach ($menu as $key => $value) {
|
||||||
|
if (strpos($value['url'], $current_controller) !== false) {
|
||||||
|
if ($value['pid'] == 0) {
|
||||||
|
$current_pid = $value['id'];
|
||||||
|
} else {
|
||||||
|
$current_pid = $value['pid'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($request->isAdmin || in_array($value['id'], array())) {
|
||||||
|
$list[$value['id']] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$headerMenu = list_to_tree($list);
|
||||||
|
foreach ($headerMenu as $key => $value) {
|
||||||
|
if ($value['id'] == $current_pid) {
|
||||||
|
$value['active'] = true;
|
||||||
|
$current_aside = $value['_child'];
|
||||||
|
} else {
|
||||||
|
$value['active'] = false;
|
||||||
|
}
|
||||||
|
$headerMenu[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($current_aside as $key => $value) {
|
||||||
|
if ($current_url == $value['url']) {
|
||||||
|
$value['active'] = true;
|
||||||
|
} else {
|
||||||
|
$value['active'] = false;
|
||||||
|
}
|
||||||
|
$asideMenu[$value['group']][] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->data['asideMenu'] = $asideMenu;
|
||||||
|
$this->data['headerMenu'] = $headerMenu;
|
||||||
|
View::assign($this->data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,102 @@
|
|||||||
<?php
|
<?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;
|
namespace app\model;
|
||||||
|
|
||||||
use think\Model;
|
use think\Model;
|
||||||
|
|
||||||
class Config extends 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){
|
||||||
|
$type = config('config_type_list');
|
||||||
|
$type_text = explode(',', $type[$data['type']]);
|
||||||
|
return $type_text[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据配置类型解析配置
|
||||||
|
* @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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,125 @@
|
|||||||
<?php
|
<?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;
|
namespace app\model;
|
||||||
|
|
||||||
use think\Model;
|
use think\Model;
|
||||||
|
|
||||||
class Member extends 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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
29
app/model/MemberLog.php
Normal file
29
app/model/MemberLog.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
||||||
59
app/model/MemberSocialite.php
Normal file
59
app/model/MemberSocialite.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/model/Menu.php
Normal file
19
app/model/Menu.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?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 Menu extends Model {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
||||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
|
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>SentCMS后台管理系统-{$meta|default="后台首页"}</title>
|
<title>SentCMS后台管理系统-{$meta['title']|default="后台首页"}</title>
|
||||||
<link href="__static__/libs/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
|
<link href="__static__/libs/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
|
||||||
<link href="__static__/libs/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
|
<link href="__static__/libs/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
|
||||||
<link rel="stylesheet" href="__static__/libs/nanoscroller/nanoscroller.css" />
|
<link rel="stylesheet" href="__static__/libs/nanoscroller/nanoscroller.css" />
|
||||||
@@ -73,49 +73,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="collapse navbar-collapse" id="header-nav">
|
<div class="collapse navbar-collapse" id="header-nav">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li class="active">
|
{volist name="headerMenu" id="item"}
|
||||||
<a href="/admin/index/index.html">
|
<li class="{if isset($item['active']) && $item['active']}active{/if}">
|
||||||
<i class="fa fa-home"></i>
|
<a href="/{$item['url']}">
|
||||||
<span>首页</span>
|
<i class="fa fa-{$item['icon']}"></i>
|
||||||
|
<span>{$item['title']}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="">
|
{/volist}
|
||||||
<a href="/admin/config/group.html">
|
</ul>
|
||||||
<i class="fa fa-laptop"></i>
|
|
||||||
<span>系统</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="">
|
|
||||||
<a href="/admin/category/index.html">
|
|
||||||
<i class="fa fa-list"></i>
|
|
||||||
<span>内容</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="">
|
|
||||||
<a href="/admin/user/index.html">
|
|
||||||
<i class="fa fa-user"></i>
|
|
||||||
<span>会员</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="">
|
|
||||||
<a href="/admin/link/index.html">
|
|
||||||
<i class="fa fa-th"></i>
|
|
||||||
<span>运营</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="">
|
|
||||||
<a href="/admin/addons/index.html">
|
|
||||||
<i class="fa fa-tags"></i>
|
|
||||||
<span>扩展</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="">
|
|
||||||
<a href="/admin/client/index.html">
|
|
||||||
<i class="fa fa-android"></i>
|
|
||||||
<span>客户端</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<ul class="nav navbar-nav pull-right">
|
<ul class="nav navbar-nav pull-right">
|
||||||
<li class="dropdown profile-dropdown hidden-sm hidden-xs">
|
<li class="dropdown profile-dropdown hidden-sm hidden-xs">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||||
@@ -166,14 +132,13 @@
|
|||||||
<div id="col-left-inner" class="col-left-nano-content">
|
<div id="col-left-inner" class="col-left-nano-content">
|
||||||
<div id="sidebar-nav">
|
<div id="sidebar-nav">
|
||||||
<ul class="nav nav-pills nav-stacked">
|
<ul class="nav nav-pills nav-stacked">
|
||||||
<li class="nav-header hidden-sm hidden-xs">后台首页</li>
|
{volist name="asideMenu" id="menu"}
|
||||||
<li class="">
|
<li class="nav-header hidden-sm hidden-xs">{$key}</li>
|
||||||
<a href="/admin/index/clear.html">
|
{volist name="menu" id="item"}
|
||||||
<i class="fa fa-refresh"></i>
|
<li {if $item['active']}class="active"{/if}><a href="/{$item['url']}"><i class="fa fa-{$item['icon']}"></i><span>{$item['title']}</span></a></li>
|
||||||
<span>更新缓存</span>
|
{/volist}
|
||||||
</a>
|
{/volist}
|
||||||
</li>
|
</ul>
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -192,8 +157,8 @@
|
|||||||
<a href="/Admin/index/index.html">后台首页</a>
|
<a href="/Admin/index/index.html">后台首页</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="active">
|
<li class="active">
|
||||||
<span>后台首页</span>
|
<span>后台首页</span>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<div class="pull-right hidden-xs">
|
<div class="pull-right hidden-xs">
|
||||||
@@ -228,12 +193,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{include file="admin/setting"}
|
{include file="admin/setting"}
|
||||||
<script src="__js__/skin-changer.js"></script>
|
<script src="__js__/skin-changer.js"></script>
|
||||||
<script src="__static__/libs/jquery/jquery.min.js"></script>
|
<script src="__static__/libs/jquery/jquery.min.js"></script>
|
||||||
<script src="__static__/libs/bootstrap/js/bootstrap.min.js"></script>
|
<script src="__static__/libs/bootstrap/js/bootstrap.min.js"></script>
|
||||||
<script src="__static__/libs/nanoscroller/jquery.nanoscroller.min.js"></script>
|
<script src="__static__/libs/nanoscroller/jquery.nanoscroller.min.js"></script>
|
||||||
<script type="text/javascript" src="__static__/js/jquery.slimscroll.min.js"></script>
|
<script type="text/javascript" src="__static__/js/jquery.slimscroll.min.js"></script>
|
||||||
<script type="text/javascript" src="__js__/app.js"></script>
|
<script src="__js__/app.js"></script>
|
||||||
|
<script type="text/javascript" src="__static__/js/require.js" data-main="__static__/admin/js/main"></script>
|
||||||
{block name="script"}{/block}
|
{block name="script"}{/block}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
1
app/view/admin/channel/index.html
Normal file
1
app/view/admin/channel/index.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{extend name="admin/base"/}
|
||||||
@@ -1 +1,95 @@
|
|||||||
{extend name="admin/base"/}
|
{extend name="admin/base"/}
|
||||||
|
{block name="body"}
|
||||||
|
|
||||||
|
<div class="main-box clearfix vue-main">
|
||||||
|
<header class="main-box-header clearfix">
|
||||||
|
<div class="pull-left">
|
||||||
|
<h2>配置管理</h2>
|
||||||
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
|
<a href="{:url('Config/index')}" class="btn btn-primary">
|
||||||
|
<i class="fa fa-list"></i>
|
||||||
|
配置列表
|
||||||
|
</a>
|
||||||
|
<a href="{:url('Config/add')}" class="btn btn-danger">
|
||||||
|
<i class="fa fa-list"></i>
|
||||||
|
添加配置
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="main-box-body clearfix">
|
||||||
|
<div class="tabs-wrapper">
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
{volist name="config['config_group_list']" id="item"}
|
||||||
|
<li {if isset($id) && $id == $key}class="active"{/if}>
|
||||||
|
<a href="/admin/config/group.html?id={$key}">{$item}</a>
|
||||||
|
</li>
|
||||||
|
{/volist}
|
||||||
|
</ul>
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab-pane fade in active" id="tab-home">
|
||||||
|
<form method="post" class="form form-horizontal" role="form">
|
||||||
|
{volist name="list" id="item"}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="inputEmail1" class="col-lg-2 control-label">{$item['title']}</label>
|
||||||
|
<div class="col-lg-10">
|
||||||
|
{switch name="item['type']"}
|
||||||
|
{case value="text"}
|
||||||
|
<input type="text" class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" value="{$item['value']}" placeholder="{$item['title']}" style="width:50%;">
|
||||||
|
{/case}
|
||||||
|
{case value="num"}
|
||||||
|
<input type="text" class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" value="{$item['value']}" placeholder="{$item['title']}" style="width:30%;">
|
||||||
|
{/case}
|
||||||
|
{case value="string"}
|
||||||
|
<input type="text" class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" value="{$item['value']}" placeholder="{$item['title']}" style="width:80%;">
|
||||||
|
{/case}
|
||||||
|
{case value="textarea"}
|
||||||
|
<textarea class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" style="width:80%; height:120px;">{$item['value']}</textarea>
|
||||||
|
{/case}
|
||||||
|
{case value="select"}
|
||||||
|
<select class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" style="width:auto;">
|
||||||
|
{volist name=":parse_config_attr($item['extra'])" id="vo"}
|
||||||
|
<option value="{$key}" {eq name="item['value']" value="$key"}selected{/eq}>{$vo}</option>
|
||||||
|
{/volist}
|
||||||
|
</select>
|
||||||
|
{/case}
|
||||||
|
{case value="bool"}
|
||||||
|
<select class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" style="width:auto;">
|
||||||
|
{volist name=":parse_config_attr($item['extra'])" id="vo"}
|
||||||
|
<option value="{$key}" {eq name="item['value']" value="$key"}selected{/eq}>{$vo}</option>
|
||||||
|
{/volist}
|
||||||
|
</select>
|
||||||
|
{/case}
|
||||||
|
{case value="image"}
|
||||||
|
{:widget('common/Form/showConfig',array($item,$item))}
|
||||||
|
{/case}
|
||||||
|
{/switch}
|
||||||
|
{if condition="$item['remark']"}
|
||||||
|
<span class="help-block">({$item['remark']})</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/volist}
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-lg-offset-2 col-lg-10">
|
||||||
|
<button type="submit" class="btn btn-success submit-btn ajax-post" target-form="form">确认提交</button>
|
||||||
|
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/block}
|
||||||
|
{block name="script"}
|
||||||
|
<script type="text/javascript">
|
||||||
|
require(['vue', 'jquery'], function(Vue, $){
|
||||||
|
new Vue({
|
||||||
|
el:".vue-main",
|
||||||
|
data:{}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
{/block}
|
||||||
|
|||||||
1
app/view/admin/config/themes.html
Normal file
1
app/view/admin/config/themes.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{extend name="admin/base"/}
|
||||||
1
app/view/admin/database/export.html
Normal file
1
app/view/admin/database/export.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{extend name="admin/base"/}
|
||||||
1
app/view/admin/database/import.html
Normal file
1
app/view/admin/database/import.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{extend name="admin/base"/}
|
||||||
@@ -1 +1,15 @@
|
|||||||
{extend name="admin/base"/}
|
{extend name="admin/base"/}
|
||||||
|
|
||||||
|
{block name="body"}
|
||||||
|
<div class="main-box clearfix">
|
||||||
|
<header class="main-box-header clearfix">
|
||||||
|
<div class="pull-left">
|
||||||
|
<h2>清除缓存</h2>
|
||||||
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="main-box-body clearfix">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/block}
|
||||||
1
app/view/admin/menu/index.html
Normal file
1
app/view/admin/menu/index.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{extend name="admin/base"/}
|
||||||
1
app/view/admin/model/index.html
Normal file
1
app/view/admin/model/index.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{extend name="admin/base"/}
|
||||||
1
app/view/admin/seo/index.html
Normal file
1
app/view/admin/seo/index.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{extend name="admin/base"/}
|
||||||
1
app/view/admin/seo/rewrite.html
Normal file
1
app/view/admin/seo/rewrite.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{extend name="admin/base"/}
|
||||||
@@ -46,7 +46,7 @@ return [
|
|||||||
// 数据库编码默认采用utf8
|
// 数据库编码默认采用utf8
|
||||||
'charset' => Env::get('database.charset', 'utf8'),
|
'charset' => Env::get('database.charset', 'utf8'),
|
||||||
// 数据库表前缀
|
// 数据库表前缀
|
||||||
'prefix' => Env::get('database.prefix', ''),
|
'prefix' => Env::get('database.prefix', 'sent_'),
|
||||||
// 数据库调试模式
|
// 数据库调试模式
|
||||||
'debug' => Env::get('database.debug', true),
|
'debug' => Env::get('database.debug', true),
|
||||||
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
|
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
|
||||||
|
|||||||
@@ -137,9 +137,6 @@ $(function($) {
|
|||||||
$(this).addClass('active');
|
$(this).addClass('active');
|
||||||
writeStorage(storage, 'config-skin', $(this).data('skin'));
|
writeStorage(storage, 'config-skin', $(this).data('skin'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$('#content-wrapper > .row').css({
|
$('#content-wrapper > .row').css({
|
||||||
opacity: 1
|
opacity: 1
|
||||||
@@ -200,7 +197,6 @@ $(function($) {
|
|||||||
$('#make-small-nav').click(function(e) {
|
$('#make-small-nav').click(function(e) {
|
||||||
$('#page-wrapper').toggleClass('nav-small');
|
$('#page-wrapper').toggleClass('nav-small');
|
||||||
});
|
});
|
||||||
|
|
||||||
setContentBody();
|
setContentBody();
|
||||||
$(window).smartresize(function() {
|
$(window).smartresize(function() {
|
||||||
if ($(document).width() <= 991) {
|
if ($(document).width() <= 991) {
|
||||||
@@ -208,7 +204,6 @@ $(function($) {
|
|||||||
}
|
}
|
||||||
setContentBody();
|
setContentBody();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.mobile-search').click(function(e) {
|
$('.mobile-search').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('.mobile-search').addClass('active');
|
$('.mobile-search').addClass('active');
|
||||||
@@ -281,9 +276,9 @@ $.fn.removeClassPrefix = function(prefix) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
function setContentBody(){
|
function setContentBody() {
|
||||||
header_height = $('header#header-navbar').height();
|
header_height = $('header#header-navbar').height();
|
||||||
if ($(window).height() - header_height -50 > $('#content-wrapper').height()) {
|
if ($(window).height() - header_height - 50 > $('#content-wrapper').height()) {
|
||||||
$('#content-wrapper').height($(window).height() - header_height -50);
|
$('#content-wrapper').height($(window).height() - header_height - 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
6
public/static/admin/js/main.js
Normal file
6
public/static/admin/js/main.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
require.config({
|
||||||
|
paths:{
|
||||||
|
'vue':'/static/js/vue.js',
|
||||||
|
"jquery":'/static/libs/jquery/jquery.min.js'
|
||||||
|
}
|
||||||
|
});
|
||||||
5
public/static/js/require.js
Normal file
5
public/static/js/require.js
Normal file
File diff suppressed because one or more lines are too long
11944
public/static/js/vue.js
Normal file
11944
public/static/js/vue.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,7 @@ Route::rule('topic-:id', 'index/topic');
|
|||||||
Route::group('admin', function(){
|
Route::group('admin', function(){
|
||||||
Route::rule('/', 'admin.index/index');
|
Route::rule('/', 'admin.index/index');
|
||||||
Route::rule('login', 'admin.index/login');
|
Route::rule('login', 'admin.index/login');
|
||||||
|
Route::rule('logout', 'admin.index/logout');
|
||||||
Route::rule(':controller/:function', 'admin.:controller/:function');
|
Route::rule(':controller/:function', 'admin.:controller/:function');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user