<?php
/** 
 * UQ云商：	www.uqcms.com  
 * 联系QQ：	2200631718 
 * 可免费商用，需要留UQ云商链接作为交换，只首页底部留取即可，不影响使用。
 */
  class router { function __construct() { $this->new_url = trim(cfg['site_string'], '/'); $uq0 = explode('?', $this->new_url); $uq0 = $uq0[0]; if(!empty($uq0)){ $uq1 = [ 'download'=>'product/download.html' ]; if(isset($uq1[$uq0])){ $uq0 = $uq1[$uq0]; } if(strpos($uq0, '.html')){ $uq2 = strstr($uq0, '.', true); }else{ $uq2 = $uq0; } }else{ $uq2 = ''; } $uq3 = explode('/', '/'.ltrim(@$uq2, '/')); array_shift($uq3); $uq4 = cfg['site_admin_url']; if($uq3[0] == $uq4){ define('UQCMS_APP', 'admin'); define('ADMIN_URL', $uq4); $uq2 = substr($uq2, strlen($uq4)); array_shift($uq3); }elseif($uq3[0] == 'wap'){ define('UQCMS_APP', 'wap'); $uq2 = substr($uq2, 4); array_shift($uq3); }elseif($uq3[0] == 'seller'){ define('UQCMS_APP', 'seller'); $uq2 = substr($uq2, 7); array_shift($uq3); }else{ define('UQCMS_APP', 'home'); } $this->url_path = $uq3; $this->server_url = $uq2; $this->request(); $this->request_safe(); $this->pc_to_wap(); } function request() { $uq3 = $this->url_path; if(empty($uq3[0]) && empty($uq3[1])){ $_GET['m'] = 'index'; $_GET['a'] = 'index'; }elseif(!empty($uq3[0]) && empty($uq3[1])){ $_GET['m'] = $uq3[0]; $_GET['a'] = 'index'; }elseif(!empty($uq3[0]) && !empty($uq3[1])){ $_GET['m'] = $uq3[0]; if(is_numeric($uq3[1])){ $_GET['a'] = 'detail'; $_GET['id'] = $uq3[1]; }else{ $_GET['a'] = $uq3[1]; } }else{ exit('路由错误'); } $uq5 = explode('/', $this->server_url); array_shift($uq5); array_shift($uq5); if(isset($uq5)){ for($uq6=0; $uq6 < count($uq5); $uq6++){ if($uq6%2==0){ $_GET[$uq5[$uq6]] = next($uq5); } } } $this->request_url = strstr($this->new_url, '?'); if(!empty($this->request_url)){ $uq7 = ltrim($this->request_url, '?'); if($uq7){ $uq5 = explode('&', $uq7); for($uq6=0; $uq6<count($uq5); $uq6++){ $uq8 = explode('=', $uq5[$uq6]); if(!isset($_GET[$uq8[0]])){ @$_GET[$uq8[0]] = $uq8[1]; } } } } } function pc_to_wap() { $uq9 = cfg['site_wap_status']; $uq10 = cfg['site_pc_status']; if($uq9 == '1' && $uq10 == '1'){ if(UQCMS_APP == 'home'){ if(is_mobile()){ $uq11 = $this->jump_arr(); $uq12 = $_GET['m'].'/'.$_GET['a']; if(isset($uq11[$uq12])){ $uq13 = $uq11[$uq12]; $uq13 = $uq13.@$this->request_url; location($uq13); } } } } } function request_safe() { if( ($_GET['m'] == 'notice' && $_GET['a'] == 'pay_notice') || ($_GET['m'] == 'notice' && $_GET['a'] == 'pay_return') ){ }else{ $uq14 = [ 'p', 'key', 'returnUrl', 'url', 'code', 'nsukey' ]; foreach($_GET as $uq15=>$uq16){ if(!empty($uq16)){ if(!in_array($uq15, $uq14)){ if(!preg_match("/^[\.\=_A-Za-z0-9]+$/", $uq16)){ exit('^!^ : 非法定义名称 : '.$uq16.' '); } }else{ $uq16 = str_replace('"', '', $uq16); $uq16 = str_replace("'", '', $uq16); $_GET[$uq15] = addslashes($uq16); } } } } } function jump_arr(){ return [ 'index/index' =>'wap/index/index', 'goods/index' =>'wap/goods/index', 'goods/detail' =>'wap/goods/'.G('id/i').'.html', 'goods/seckill' =>'wap/goods/seckill', 'goods/brand' =>'wap/goods/brand', 'article/index' =>'wap/article/index', 'article/detail' =>'wap/article/'.G('id/i').'.html', 'member/index' =>'wap/member/index', 'member/login' =>'wap/member/login', 'account/pay' =>'wap/account/pay', 'order/index' =>'wap/order/index', ]; } } new router(); 