项目核心文件

core/shopld.php

 if (!@include(BASE_DATA_PATH.'/config/config.ini.php')) exit('config.ini.php isn\'t exists!');
if (file_exists(BASE_PATH.'/config/config.ini.php')){
include(BASE_PATH.'/config/config.ini.php');
}
global $config; //默认平台店铺id
define('DEFAULT_PLATFORM_STORE_ID', $config['default_store_id']); define('URL_MODEL',$config['url_model']);
define(SUBDOMAIN_SUFFIX, $config['subdomain_suffix']); define('SHOP_SITE_URL', $config['shop_site_url']);
define('CMS_SITE_URL', $config['cms_site_url']);
define('CIRCLE_SITE_URL', $config['circle_site_url']);
define('MICROSHOP_SITE_URL', $config['microshop_site_url']);
define('ADMIN_SITE_URL', $config['admin_site_url']);
define('MOBILE_SITE_URL', $config['mobile_site_url']);
define('WAP_SITE_URL', $config['wap_site_url']);
define('UPLOAD_SITE_URL',$config['upload_site_url']);
define('RESOURCE_SITE_URL',$config['resource_site_url']); define('BASE_DATA_PATH',BASE_ROOT_PATH.'/data');
define('BASE_UPLOAD_PATH',BASE_DATA_PATH.'/upload');
define('BASE_RESOURCE_PATH',BASE_DATA_PATH.'/resource'); define('CHARSET',$config['db'][1]['dbcharset']);
define('DBDRIVER',$config['dbdriver']);
define('SESSION_EXPIRE',$config['session_expire']);
define('LANG_TYPE',$config['lang_type']);
define('COOKIE_PRE',$config['cookie_pre']);
define('DBPRE',($config['db'][1]['dbname']).'`.`'.($config['tablepre'])); $_GET['act'] = $_GET['act'] ? strtolower($_GET['act']) : ($_POST['act'] ? strtolower($_POST['act']) : null);
$_GET['op'] = $_GET['op'] ? strtolower($_GET['op']) : ($_POST['op'] ? strtolower($_POST['op']) : null); if (empty($_GET['act'])){
require_once(BASE_CORE_PATH.'/framework/core/route.php');
new Route($config);
}
//统一ACTION
$_GET['act'] = preg_match('/^[\w]+$/i',$_GET['act']) ? $_GET['act'] : 'index';
$_GET['op'] = preg_match('/^[\w]+$/i',$_GET['op']) ? $_GET['op'] : 'index'; //对GET POST接收内容进行过滤,$ignore内的下标不被过滤
$ignore = array('article_content','pgoods_body','doc_content','content','sn_content','g_body','store_description','p_content','groupbuy_intro','remind_content','note_content','ref_url','adv_pic_url','adv_word_url','adv_slide_url','appcode','mail_content');
if (!class_exists('Security')) require(BASE_CORE_PATH.'/framework/libraries/security.php');
$_GET = !empty($_GET) ? Security::getAddslashesForInput($_GET,$ignore) : array();
$_POST = !empty($_POST) ? Security::getAddslashesForInput($_POST,$ignore) : array();
$_REQUEST = !empty($_REQUEST) ? Security::getAddslashesForInput($_REQUEST,$ignore) : array();
$_SERVER = !empty($_SERVER) ? Security::getAddSlashes($_SERVER) : array(); //启用ZIP压缩
if ($config['gzip'] == 1 && function_exists('ob_gzhandler') && $_GET['inajax'] != 1){
ob_start('ob_gzhandler');
}else {
ob_start();
} require_once(BASE_CORE_PATH.'/framework/function/core.php');
require_once(BASE_CORE_PATH.'/framework/core/base.php'); require_once(BASE_CORE_PATH.'/framework/function/goods.php'); if(function_exists('spl_autoload_register')) {
spl_autoload_register(array('Base', 'autoload'));
} else {
function __autoload($class) {
return Base::autoload($class);
}
}

路由解析文件位于core/framework/core/route.php 主要控制路由功能和伪静态功能

  

 <?php
/**
* 路由
*
* @copyright Copyright (c) 2014-2015 shopld Inc.
* @license
* @link
* @since File available since Release v1.0
*/
defined('InSC') or exit('Access Invalid!'); class Route { /**
* PATH_INFO 分隔符
*
* @var string
*/
private $_pathinfo_split = '-'; /**
* 系统配置信息
*
* @var array
*/ private $_config = array(); /**
* PATH_INFO内容分隔正则
*
* @var string
*/
private $_pathinfo_pattern = ''; /**
* 伪静态文件扩展名
*
* @var string
*/
private $_rewrite_extname = '.html'; /**
* 构造方法
*
*/
public function __construct($config = array()) {
$this->_config = $config;
$this->_pathinfo_pattern = "/{$this->_pathinfo_split}/";
$this->parseRule();
} /**
* 路由解析
*
*/
public function parseRule() {
if ($this->_config['url_model']) {
$this->_parseRuleRewrite();
} else {
$this->_parseRuleNormal();
}
} /**
* 默认URL模式
*
*/
private function _parseRuleNormal() {
//不进行任何处理
} /**
* 伪静态模式
*
*/
private function _parseRuleRewrite() {
       //$_SERVER['path_info']包含真实脚本名称之后,并且在查询语句之前的信息,如果当前脚本是通过 URL http://www.example.com/php/path_info.php/some/stuff?foo=bar 被访问,那么 $_SERVER['PATH_INFO'] 将包含 /some/stuff。  
       //$_SERVER['REDIRECT_REDIRECT_PATH_INFO']     
$path_info = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['REDIRECT_REDIRECT_PATH_INFO'];
$path_info = trim($path_info,'/'); //如果为二级目录去掉目录信息
if(strpos($path_info, '/')) {
$path_info_array = explode('/', $path_info);
$path_info = end($path_info_array);
} if (!empty($path_info) && $path_info != 'index.php' && strpos($path_info, $this->_rewrite_extname)){
//去掉伪静态扩展名
$path_info = substr($path_info,0,-strlen($this->_rewrite_extname)); //根据不同APP匹配url规则
$path_info_function = '_' . APP_ID . 'PathInfo';
$path_info = $this->$path_info_function($path_info); $split_array = preg_split($this->_pathinfo_pattern,$path_info);
//act,op强制赋值
$_GET['act'] = isset($split_array[0]) ? $split_array[0] : 'index';
$_GET['op'] = isset($split_array[1]) ? $split_array[1] : 'index';
unset($split_array[0]);
unset($split_array[1]); //其它参数也放入$_GET
while (current($split_array) !== false) {
$name = current($split_array);
$value = next($split_array);
$_GET[$name] = $value;
if (next($split_array) === false){
break;
}
}
} else {
$_GET['act'] = $_GET['op'] = 'index';
}
} /**
* 商城短网址还原成长网址
* @param unknown $path_info
* @return mixed
*/
private function _shopPathInfo($path_info) {
$reg_match_from = array(
'/^item-(\d+)$/',
'/^shop-(\d+)$/',
'/^shop_view-(\d+)-(\d+)-([0-5])-([0-2])-(\d+)$/',
'/^article-(\d+)$/',
'/^article_cate-(\d+)$/',
'/^document-([a-z_]+)$/',
'/^cate-(\d+)-([0-9_]+)-([0-9_]+)-([0-3])-([0-2])-([0-2])-(\d+)-(\d+)$/',
'/^brand-(\d+)-([0-3])-([0-2])-([0-2])-(\d+)-(\d+)$/',
'/^brand$/',
'/^groupbuy-(\d+)-(\d+)-(\d+)-(\d+)-(\d+)-(\d+)$/',
'/^groupbuy_soon-(\d+)-(\d+)-(\d+)-(\d+)-(\d+)-(\d+)$/',
'/^groupbuy_history-(\d+)-(\d+)-(\d+)-(\d+)-(\d+)-(\d+)$/',
'/^groupbuy_detail-(\d+)$/',
'/^integral$/',
'/^integral_list$/',
'/^integral_item-(\d+)$/',
'/^voucher$/',
'/^comments-(\d+)-([0-3])-(\d+)$/',
'/^special-(\d+)$/'
);
$reg_match_to = array(
'goods-index-goods_id-\\1',
'show_store-index-store_id-\\1',
'show_store-goods_all-store_id-\\1-stc_id-\\2-key-\\3-order-\\4-curpage-\\5',
'article-show-article_id-\\1',
'article-article-ac_id-\\1',
'document-index-code-\\1',
'search-index-cate_id-\\1-b_id-\\2-a_id-\\3-key-\\4-order-\\5-type-\\6-area_id-\\7-curpage-\\8',
'brand-list-brand-\\1-key-\\2-order-\\3-type-\\4-area_id-\\5-curpage-\\6',
'brand-index',
'show_groupbuy-index-area_id-\\1-groupbuy_class-\\2-groupbuy_price-\\3-groupbuy_order_key-\\4-groupbuy_order-\\5-curpage-\\6',
'show_groupbuy-groupbuy_soon-area_id-\\1-groupbuy_class-\\2-groupbuy_price-\\3-groupbuy_order_key-\\4-groupbuy_order-\\5-curpage-\\6',
'show_groupbuy-groupbuy_history-area_id-\\1-groupbuy_class-\\2-groupbuy_price-\\3-groupbuy_order_key-\\4-groupbuy_order-\\5-curpage-\\6',
'show_groupbuy-groupbuy_detail-group_id-\\1',
'pointprod-index',
'pointprod-plist',
'pointprod-pinfo-id-\\1',
'pointvoucher-index',
'goods-comments_list-goods_id-\\1-type-\\2-curpage-\\3',
'special-special_detail-special_id-\\1'
);
return preg_replace($reg_match_from,$reg_match_to,$path_info);
} /**
* CMS短网址还原成长网址
* @param unknown $path_info
* @return mixed
*/
private function _cmsPathInfo($path_info) {
$reg_match_from = array(
'/^article-(\d+)$/',
'/^picture-(\d+)$/'
);
$reg_match_to = array(
'article-article_detail-article_id-\\1',
'picture-picture_detail-picture_id-\\1'
);
return preg_replace($reg_match_from,$reg_match_to,$path_info);
} }

shopnc路由功能分析的更多相关文章

  1. 07. vue-router嵌套路由

    嵌套路由用法 1.嵌套路由功能分析 点击父级路由链接显示模板内容 模板内容中又有子级路由链接 点击子级路由链接显示子级模板内容 2.父路由组件模板 父级路由链接 父组件路由填充位 <p> ...

  2. 四、vue前端路由(轻松入门vue)

    轻松入门vue系列 Vue前端路由 七.Vue前端路由 1. 路由的基本概念与原理 后端路由 前端路由 实现简单的前端路由 vue-router基本概念 2. vue-router的基本使用 基本使用 ...

  3. 01-02 Flutter仿京东商城项目 功能分析、底部导航Tab切换以及路由配置、架构搭建:(Flutter仿京东商城项目 首页布局以及不同终端屏幕适配方案)

    Flutter和Dart交流学习群:交流群:452892873 01Flutter仿京东商城项目 功能分析.底部导航Tab切换以及路由配置.架构搭建 02Flutter仿京东商城项目 首页布局以及不同 ...

  4. 理解 OpenStack 高可用(HA)(3):Neutron 分布式虚拟路由(Neutron Distributed Virtual Routing)

    本系列会分析OpenStack 的高可用性(HA)概念和解决方案: (1)OpenStack 高可用方案概述 (2)Neutron L3 Agent HA - VRRP (虚拟路由冗余协议) (3)N ...

  5. Angular2入门系列教程6-路由(二)-使用多层级路由并在在路由中传递复杂参数

    上一篇:Angular2入门系列教程5-路由(一)-使用简单的路由并在在路由中传递参数 之前介绍了简单的路由以及传参,这篇文章我们将要学习复杂一些的路由以及传递其他附加参数.一个好的路由系统可以使我们 ...

  6. Angular2入门系列教程5-路由(一)-使用简单的路由并在在路由中传递参数

    上一篇:Angular2入门系列教程-服务 上一篇文章我们将Angular2的数据服务分离出来,学习了Angular2的依赖注入,这篇文章我们将要学习Angualr2的路由 为了编写样式方便,我们这篇 ...

  7. nodejs进阶(3)—路由处理

    1. url.parse(url)解析 该方法将一个URL字符串转换成对象并返回. url.parse(urlStr, [parseQueryString], [slashesDenoteHost]) ...

  8. .NetCore MVC中的路由(2)在路由中使用约束

    p { margin-bottom: 0.25cm; direction: ltr; color: #000000; line-height: 120%; orphans: 2; widows: 2 ...

  9. .NetCore MVC中的路由(1)路由配置基础

    .NetCore MVC中的路由(1)路由配置基础 0x00 路由在MVC中起到的作用 前段时间一直忙于别的事情,终于搞定了继续学习.NetCore.这次学习的主题是MVC中的路由.路由是所有MVC框 ...

随机推荐

  1. java基础第十二篇之集合、增强for循环、迭代器和泛型

    Collection接口中的常用方法: * 所有的子类子接口都是具有的 * 集合的方法:增删改查 * * public boolean add(E e);//添加元素 返回值表示是否添加成功 * pu ...

  2. Nacos深入浅出(四)

    private void executeAsyncInvoke() { while (!queue.isEmpty()) { NotifySingleTask task = queue.poll(); ...

  3. Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) D

    Arpa has found a list containing n numbers. He calls a list bad if and only if it is not empty and g ...

  4. curl_setopt 注意

    最近碰到好多奇怪的BUG,今天就是一个例子. 我在用CURL调用麦考林的接口,在浏览器测试完全没问题,调用全都成功.但是用命令行执行PHP时,却一直不行,返回http code 302错误.百思不得其 ...

  5. NET高性能IO

    System.IO.Pipelines: .NET高性能IO https://www.cnblogs.com/xxfy1/p/9290235.html System.IO.Pipelines是一个新的 ...

  6. IIS中的 Asp.Net Core 和 dotnet watch

    在基于传统的.NET Framework的Asp.Net Mvc的时候,本地开发环境中可以在IIS中建立一个站点,可以直接把站点的目录指向asp.net mvc的项目的根目录.然后build一下就可以 ...

  7. Linux (Windows Linux子系统)

    Linux (Windows Linux子系统) 如果想体验Linux环境下开发和运行.NET Core应用,我们有多种选择.一种就是在一台物理机上安装原生的Linux,我们可以根据自身的喜好选择某种 ...

  8. Spark Mllib里决策树回归分析如何对numClasses无控制和将部分参数设置为variance(图文详解)

    不多说,直接上干货! 在决策树二元或决策树多元分类参数设置中: 使用DecisionTree.trainClassifier   见 Spark Mllib里如何对决策树二元分类和决策树多元分类的分类 ...

  9. 初学Android,创建,启动,停止Service(五十八)

    Service跟Windows系统里的服务概念差不多,都在后台执行,它跟Activity的最大区别就是,它是无界面的 开发Service与开发Activity的步骤类似 1.定义一个继承Service ...

  10. <img/>标签属性

    属性        属性值               描述 src            url               图像的路径 alt             文本            ...