修改bug

20240120-ljl-routeConfig
ljl 11 months ago
parent 9fcfa9626d
commit 13350ae6c0

@ -1,56 +1,59 @@
<?php
class AppUrlHandler implements ZcUrlHandler {
public function buildUrl($route, $params = '', $scheme = false, $host = false) {
$scheme = ($scheme === false) ? $this->getCurProtocol() : $scheme;
$host = ($host === false) ? $this->getHost() : $host;
$port = (filter_var($host, FILTER_VALIDATE_IP) !== false) ? $_SERVER['SERVER_PORT'] : (($scheme == 'https') ? 443 : 80);
$route = trim($route, '/');
$scriptName = $this->getScriptName();
$url = $scheme . '://' . $host . (in_array($port, [80, 443]) ? '' : ':' . $port) . substr($scriptName, 0, strpos($scriptName, 'index.php')) . $route;
if (is_array($params)) {
$params = http_build_query($params, '', '&');
}
if ($params) {
$url .= '?' . ltrim($params, '&');
}
return $url;
}
public function buildUrl($route, $params = '', $scheme = false, $host = false) {
$isNotForceHttps = preg_match('/^(timer|open)/', $route);
if (!$isNotForceHttps && $scheme === false && !AppConst::isDev()) {
$scheme = 'https';
}
private function getScriptName() {
$scriptName = $_SERVER['SCRIPT_NAME'];
$scheme = empty($scheme) ? self::getCurProtocol() : $scheme;
$host = ($host === false) ? $this->getHost() : $host;
$port = ($scheme == 'https') ? $_SERVER['SERVER_PORT'] : 80;
$port = in_array($port, [80, 443]) ? '' : (':' . $port);
if (AppConst::isUseAppModuleApp()) {
if (strpos($scriptName, '/pdd-order') === 0) {
$scriptName = substr($scriptName, strlen('/pdd-order'));
} elseif (strpos($_SERVER['SCRIPT_NAME'], '/pdd') === 0) {
$scriptName = substr($scriptName, strlen('/pdd'));
}
$route = trim($route, '/');
if (preg_match('/v2\./i', $host) && $host != Zc::C('jflow.host')) {
$scriptName = substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], 'index.php'));
$scriptName = (($route == '') && ($scriptName == '/api/')) ? '/' : $scriptName;
} else {
$scriptName = '/';
}
if (is_array($params) && $params['__NOAPI__']) {
$scriptName = '/';
}
return $scriptName;
$url = "{$scheme}://{$host}{$port}{$scriptName}{$route}";
if (is_array($params)) {
unset($params['__NOAPI__']);
$params = http_build_query($params, '', '&');
}
if ($params) {
$url .= '?' . ltrim($params, '&');
}
return $url;
}
private function getHost() {
return $_SERVER['HTTP_HOST'];
}
private function getCurProtocol() {
return AppConst::getCurProtocol();
}
return $_SERVER['HTTP_HOST'];
}
public function parseBack() {
$_GET['_route_'] = $_GET['_route_'] ? : Zc::C(ZcConfigConst::DefaultRoute);
if (isset($_GET['_route_'])) {
$_GET['route'] = $this->rewriteRoute($_GET['_route_']);
unset($_GET['_route_']);
}
}
private function rewriteRoute($route){
private function getCurProtocol() {
return 'http';
}
public function parseBack() {
$_GET['_route_'] = $_GET['_route_'] ? : Zc::C(ZcConfigConst::DefaultRoute);
if (isset($_GET['_route_'])) {
$_GET['route'] = $this->rewriteRoute($_GET['_route_']);
unset($_GET['_route_']);
}
}
private function rewriteRoute($route){
$route = trim($route, '/');
if (AppConst::isUseAppModuleApp() && (stripos($route, 'control/decrypt/') === 0)) {
@ -88,10 +91,6 @@ class AppUrlHandler implements ZcUrlHandler {
return true;
}
if (preg_match('/^pdd\/control\/decrypt/', $route)) {
return true;
}
$realRouteList = array(
);

Loading…
Cancel
Save