浏览代码

no commit message

齐博 3 年之前
父节点
当前提交
d225e06cca
共有 3 个文件被更改,包括 98 次插入14 次删除
  1. 9 7
      application/admin/controller/Module.php
  2. 20 7
      application/common.php
  3. 69 0
      application/helper.php

+ 9 - 7
application/admin/controller/Module.php

@@ -223,13 +223,15 @@ class Module extends AdminBase
 	    }
 	    
 	    $this->form_items = [
-	            ['text','name', '模块名称', ''],
-	            ['static','keywords', '所在目录', ''],	      
-	            ['radio','ifsys', '使用顶部菜单', '',['禁用','启用']],
-	            ['radio','ifopen', '启用或禁用', '',['关闭系统','启用系统']],
-	            ['textarea','about', '介绍', ''],
-	            ['number','list', '排序值', ''],
-	            ['icon','icon', '图标', ''],
+	        ['text','name', '模块名称', ''],
+	        ['static','keywords', '所在目录', ''],	      
+	        ['radio','ifsys', '使用顶部菜单', '',['禁用','启用']],
+	        ['radio','ifopen', '启用或禁用', '',['关闭系统','启用系统']],
+	        ['textarea','about', '介绍', ''],
+	        ['number','list', '排序值', ''],
+	        ['icon','icon', '图标', ''],
+	        //['text','pc_domain', '二级域名', '没配置好服务器的话,必须留空,否则请输入二级域名比如“bbs”而不是http://bbs.xxx.com也不是bbs.xxx.com'],
+	        //['text','wap_domain', 'WAP版二级域名', '一般留空,如果配置好服务器的话,请输入http://或https://开头'],
 	    ];
 	    
 	    return $this->editContent($info);

+ 20 - 7
application/common.php

@@ -486,6 +486,7 @@ if (!function_exists('urls')) {
                 $_url = '/member.php'.$_url;
             }else{
                 $_url = str_replace(array(ADMIN_FILENAME,'index.php'), 'member.php', $_url);
+                $_url = preg_replace("/^(http|https):\/\/([^\/]+)\/([\w-]+)\//i", "\\1://\\2/member.php/\\3/", $_url);
             }            
         }
         return $_url ;
@@ -554,6 +555,7 @@ if (!function_exists('purl')) {
                 $url = '/member.php'.$url;
             }else{
                 $url = str_replace(array(ADMIN_FILENAME,'index.php'), 'member.php', $url);
+                $url = preg_replace("/^(http|https):\/\/([^\/]+)\/([\w-]+)\//i", "\\1://\\2/member.php/\\3/", $url);
             }            
         }
         return $url;
@@ -670,11 +672,12 @@ if (!function_exists('murl')) {
         }else{
             $url = str_replace([ADMIN_FILENAME.'/admin','index.php/index'],'member.php/member', $_url);
             $url = str_replace([ADMIN_FILENAME,'index.php'],'member.php', $url);
+            $url = preg_replace("/^(http|https):\/\/([^\/]+)\/([\w-]+)\//i", "\\1://\\2/member.php/\\3/", $url);
         }        
 
-        if(!preg_match('/^member.php/', $url)){
+        //if(!preg_match('/^member.php/', $url)){
             //$url = '/index.php'.$url;
-        }
+        //}
         return $url;
     }
 }
@@ -686,10 +689,14 @@ if (!function_exists('full_url')) {
      * @return string
      */
     function full_url($url=''){
+        $detail = explode('/',$url);
+        if (count($detail)==3) {
+            return $url;
+        }
         static $_m = null;
         $_m===null && $_m = Request::instance()->dispatch();
         $m = $_m['module'];
-        $detail = explode('/',$url);
+        
         if(count($detail)==1){
             $url = $m[0] . '/' . $m[1] . '/' . $url;
         }elseif(count($detail)==2){
@@ -1457,7 +1464,8 @@ if(!function_exists('modules_config')){
      * @return NULL|unknown|string|array|NULL[]|string|array|unknown|NULL[]
      */
     function modules_config($id=null , $getcache=true){
-        $array = $getcache===true ? cache('cache_modules_config') : '';
+        static $data = null;
+        $array = $getcache===true ? ($data?:cache('cache_modules_config')) : '';
         if(empty($array)){
             $result = Module::getList(['ifopen'=>1]);
             foreach($result AS $rs){
@@ -1465,6 +1473,7 @@ if(!function_exists('modules_config')){
             }
             cache('cache_modules_config',$array);
         }
+        $data = $array;
         if(is_numeric($id)){ //根据模块ID返回数组
             return $array[$id];
         }elseif($id!==null){ //根据模块目录名返回数组
@@ -1473,6 +1482,7 @@ if(!function_exists('modules_config')){
                     return $rs;
                 }
             }
+            return [];
         }else{
             return $array;
         }
@@ -1488,14 +1498,16 @@ if(!function_exists('plugins_config')){
      * @return NULL|unknown|string|array|NULL[]|string|array|unknown|NULL[]
      */
     function plugins_config($id=null , $getcache=true){
-        $array = $getcache===true ? cache('cache_plugins_config') : '';
+        static $data = null;
+        $array = $getcache===true ? ($data?:cache('cache_plugins_config')) : '';
         if(empty($array)){
             $result = Plugin::getList(['ifopen'=>1]);
             foreach($result AS $rs){
                 $array[$rs['id']] = $rs;
             }
             cache('cache_plugins_config',$array);
-        }        
+        }
+        $data = $array;
         if(is_numeric($id)){ //根据插件ID返回数组
             return $array[$id];
         }elseif($id!==null){ //根据插件目录名返回数组
@@ -1504,6 +1516,7 @@ if(!function_exists('plugins_config')){
                     return $rs;
                 }
             }
+            return [];
         }else{
             return $array;
         }
@@ -2815,7 +2828,7 @@ if (!function_exists('getTemplate')) {
                  $url = request()->domain().'/';
                  break;
              case 'member':  //会员中心
-                 $url = request()->domain().'/member.php';
+                 $url = murl('member/index/index');//request()->domain().'/member.php';
                  break;
              case 'user':   //用户的主页
                  $url = murl('member/user/index',is_numeric($array)?['uid'=>$array]:$array);

+ 69 - 0
application/helper.php

@@ -0,0 +1,69 @@
+<?php
+use think\Url;
+
+if (!function_exists('url')) {
+    /**
+     * Url生成
+     * @param string        $url 路由地址
+     * @param string|array  $vars 变量
+     * @param bool|string   $suffix 生成的URL后缀
+     * @param bool|string   $domain 域名
+     * @return string
+     */
+    function url($url = '', $vars = '', $suffix = true, $domain = false)
+    {
+        static $array = null;
+        if ($array===null) {
+            $array = @include(RUNTIME_PATH.'url_cfg.php');
+            if (empty($array)) {
+                $array = [];
+            }
+        }
+        if ($vars && is_string($vars)) {
+            parse_str($vars,$vars);
+        }
+        $par = '';
+        $_vars = $vars;     //避免改变顺序
+        if ($vars) {
+            ksort($vars);
+            $par = http_build_query($vars);
+        }
+        
+        if ($domain===false) {
+            $url = full_url($url);
+            list($m_name,$m_file,$m_action) = explode('/', $url);
+            $md = modules_config($m_name);
+            if(IN_WAP===true){
+                if ($md['wap_domain']) {
+                    $domain = $md['wap_domain'];
+                }
+            }else{
+                if ($md['pc_domain']) {
+                    $domain = $md['pc_domain'];
+                }
+            }
+            
+            if ($domain===false) {                
+                if(IN_WAP===true && config('webdb.wap_domain')){
+                    $domain = config('webdb.wap_domain');
+                }elseif(config('webdb.pc_domain')){
+                    $domain = config('webdb.pc_domain');
+                }
+            }
+        }
+        
+        if ($par && $array[$url][$par]) {
+            $_url = Url::build($url.'?'.$par, [], $suffix, $domain);
+        }else{
+            $_url = Url::build($url, $_vars, $suffix, $domain);
+        }
+        
+        if ( ($m_name=='index'&&!in_array($m_file, ['alonepage','index','login','reg','plugin']))|| ($m_name=='member'&&!in_array($m_file, ['index'])) ) { //避免ajax或框架的跨域
+            $_url = preg_replace("/^(http|https):\/\/([^\/]+)\//i", "/",$_url);
+        }elseif($url=='index/index/index'){
+            $_url = str_replace('index/index/index.html','',$_url);
+        }
+        return $_url;
+        
+    }
+}