目录结构更新,增加composer支持

This commit is contained in:
2018-01-14 09:40:04 +08:00
parent 3818619504
commit ae46a73172
945 changed files with 421 additions and 210179 deletions

View File

@@ -26,7 +26,7 @@ class Addons extends Base {
public function _initialize() {
$mc = $this->getAddonsName();
$this->addon_path = ROOT_PATH . "/addons/{$mc}/";
$this->addon_path = SENT_ADDON_PATH . "{$mc}/";
if (is_file($this->addon_path . 'config.php')) {
$this->config_file = $this->addon_path . 'config.php';
}
@@ -38,13 +38,13 @@ class Addons extends Base {
$mc = $this->getAddonsName();
$ac = input('ac', '', 'trim,strtolower');
$parse_str = \think\Config::get('parse_str');
$parse_str['__ADDONROOT__'] = ROOT_PATH . "/addons/{$mc}";
$parse_str['__ADDONROOT__'] = SENT_ADDON_PATH . "{$mc}";
\think\Config::set('parse_str', $parse_str);
$this->view->engine(
array(
'view_path' => "addons/" . $mc . "/view/",
'replace' => array('__ADDONROOT__'=>ROOT_PATH . "/addons/{$mc}")
'view_path' => SENT_ADDON_PATH . $mc . "/view/",
'replace' => array('__ADDONROOT__'=>SENT_ADDON_PATH . "{$mc}")
)
);
}

View File

@@ -1,26 +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\common\controller;
use app\common\model\AuthGroup;
use app\common\model\AuthRule;
class Admin extends Base {
public function _initialize() {
parent::_initialize();
if (!is_login() and !in_array($this->url, array('admin/index/login', 'admin/index/logout', 'admin/index/verify'))) {
if (!is_login() and !in_array($this->url_path, array('admin/index/login', 'admin/index/logout', 'admin/index/verify'))) {
$this->redirect('admin/index/login');
}
if (!in_array($this->url, array('admin/index/login', 'admin/index/logout', 'admin/index/verify'))) {
if (!in_array($this->url_path, array('admin/index/login', 'admin/index/logout', 'admin/index/verify'))) {
// 是否是超级管理员
define('IS_ROOT', is_administrator());
@@ -119,7 +112,7 @@ class Admin extends Base {
protected function setMenu() {
$hover_url = $this->request->module() . '/' . $this->request->controller();
$controller = $this->url;
$controller = $this->url_path;
$menu = array(
'main' => array(),
'child' => array(),
@@ -218,4 +211,4 @@ class Admin extends Base {
$this->assign('extend_menu', array('管理插件' => $menu));
}
}
}
}

View File

@@ -1,23 +1,14 @@
<?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\controller;
class Base extends \think\Controller {
use think\Controller;
protected $url;
protected $request;
protected $module;
protected $controller;
protected $action;
class Base extends Controller{
public function _initialize() {
protected $url_path = ""; //当前完全访问路径
public function _initialize(){
$this->url_path = strtolower($this->request->module() . '/' . $this->request->controller() . '/' . $this->request->action());
if (!is_file(APP_PATH . 'database.php') || !is_file(APP_PATH . 'install.lock')) {
return $this->redirect('install/index/index');
}
@@ -28,8 +19,6 @@ class Base extends \think\Controller {
cache('db_config_data', $config);
}
config($config);
//获取request信息
$this->requestInfo();
}
public function execute($mc = null, $op = '', $ac = null) {
@@ -110,34 +99,6 @@ class Base extends \think\Controller {
$this->assign($data);
}
/**
* 验证码
* @param integer $id 验证码ID
* @author 郭平平 <molong@tensent.cn>
*/
public function verify($id = 1) {
$verify = new \org\Verify(array('length' => 4));
$verify->entry($id);
}
/**
* 检测验证码
* @param integer $id 验证码ID
* @return boolean 检测结果
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function checkVerify($code, $id = 1) {
if ($code) {
$verify = new \org\Verify();
$result = $verify->check($code, $id);
if (!$result) {
return $this->error("验证码错误!", "");
}
} else {
return $this->error("验证码为空!", "");
}
}
/**
* @title 后台设置title
* @description 设置后台页面的title
@@ -149,29 +110,6 @@ class Base extends \think\Controller {
$this->assign('meta_title', $title);
}
//request信息
protected function requestInfo() {
$this->param = $this->request->param();
defined('MODULE_NAME') or define('MODULE_NAME', $this->request->module());
defined('CONTROLLER_NAME') or define('CONTROLLER_NAME', $this->request->controller());
defined('ACTION_NAME') or define('ACTION_NAME', $this->request->action());
defined('IS_POST') or define('IS_POST', $this->request->isPost());
defined('IS_GET') or define('IS_GET', $this->request->isGet());
$this->url = strtolower($this->request->module() . '/' . $this->request->controller() . '/' . $this->request->action());
$this->assign('request', $this->request);
$this->assign('param', $this->param);
}
/**
* 获取单个参数的数组形式
*/
protected function getArrayParam($param) {
if (isset($this->param['id'])) {
return array_unique((array) $this->param[$param]);
} else {
return array();
}
}
/**
* 是否为手机访问
@@ -214,4 +152,4 @@ class Base extends \think\Controller {
}
return false;
}
}
}

View File

@@ -1,125 +1,35 @@
<?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\controller;
class Front extends Base {
class Front extends Base{
public $wechat_oauth;
public function _initialize() {
public function _initialize(){
parent::_initialize();
//判读是否为关闭网站
if (\think\Config::get('web_site_close')) {
header("Content-type:text/html;charset=utf-8");
echo $this->fetch('common@default/public/close');exit();
}
//设置SEO
$this->setSeo();
$this->setHoverNav();
//主题设置
//设置主题信息
$this->setThemes();
//微信访问时
// if ($this->isMobile() && $this->is_wechat()) {
// if (!session('oauth')) {
// $this->getOpentId();
// }else{
// $this->wechat_oauth = session('oauth');
// $this->assign('oauth', session('oauth'));
// }
// //微信用户直接使用微信登录
// $this->WechatUser();
// }
}
/**
* 微信用户登录
*/
protected function WechatUser(){
if (!is_login()) {
$openid = $this->wechat_oauth['openid'];
//若系统内存在则直接登录,不存在不登录
$result = model('User')->login($openid, '', 5);
if ($result == -1) {
$user = & load_wechat('User');
$wechat_user = $user->getUserInfo($this->wechat_oauth['openid']);
$result = model('User')->register($openid, $openid, $openid, $openid.'@openid.com', true, array('openid'=>$openid,'nickname'=>$this->jsonName($wechat_user['nickname']),'headimgurl'=>$wechat_user['headimgurl']));
}
return $result;
}else{
return true;
}
}
/**
+----------------------------------------------------------
* 过滤用户昵称里面的特殊字符
+----------------------------------------------------------
* @param string $str 待输出的用户昵称
+----------------------------------------------------------
*/
protected function jsonName($str) {
if($str){
$return = '';
$length = mb_strlen($str,'utf-8');
for ($i=0; $i < $length; $i++) {
$_tmpStr = mb_substr($str,$i,1,'utf-8');
if(strlen($_tmpStr) >= 4){
$return .= '';
}else{
$return .= $_tmpStr;
}
}
}else{
$return = 'wechat_'.time();
}
return $return;
}
protected function getOpentId(){
$oauth = &load_wechat('Oauth');
$user_oauth = $oauth->getOauthAccessToken();
if ($user_oauth) {
session('oauth',$user_oauth);
}else{
$uri = $oauth->getOauthRedirect('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
header("Location:".$uri);
}
}
//当前栏目导航
protected function setHoverNav() {
//dump($_SERVER['PHP_SELF']);
}
protected function setThemes() {
//网站主题设置
$themes['mobile'] = config('mobile_themes') ? config('mobile_themes') : 'mobile';
$themes['pc'] = config('pc_themes') ? config('pc_themes') : 'default';
$view_path = ($this->isMobile() && config('open_mobile_site') == '1') ? 'template/' . $themes['mobile'] . '/' : 'template/' . $themes['pc'] . '/';
public function setThemes(){
$theme = 'default';
$module = $this->request->module();
if (!in_array($module, array('index', 'install'))) {
$view_path_pre = $module . '/';
} else {
$view_path_pre = '';
if ($module == 'index') {
$view_path = './template/' . $theme . '/' ;
}else{
$view_path = './template/' . $theme . '/' . $module . '/';
}
$this->view->config('view_path', $view_path . $view_path_pre)
->config('tpl_replace_string',array(
'__IMG__' => BASE_PATH . '/' . $view_path . 'static/images',
'__JS__' => BASE_PATH . '/' . $view_path . 'static/js',
'__CSS__' => BASE_PATH . '/' . $view_path . 'static/css',
));
$tpl_replace = array(
'__TPL__' => $view_path,
'__CSS__' => $view_path . 'static/css/',
'__JS__' => $view_path . 'static/js/',
'__IMG__' => $view_path . 'static/images/',
);
$tpl_conf = array(
'view_path' => $view_path,
'tpl_replace_string' => $tpl_replace
);
$this->view->config($tpl_conf);
}
}
}