|
|
@ -2,15 +2,32 @@
|
|
|
|
class AppUrlHandler implements ZcUrlHandler {
|
|
|
|
class AppUrlHandler implements ZcUrlHandler {
|
|
|
|
|
|
|
|
|
|
|
|
public function buildUrl($route, $params = '', $scheme = false, $host = false) {
|
|
|
|
public function buildUrl($route, $params = '', $scheme = false, $host = false) {
|
|
|
|
$scheme = ($scheme === false) ? $this->getCurProtocol() : $scheme;
|
|
|
|
$isNotForceHttps = preg_match('/^(timer|open)/', $route);
|
|
|
|
|
|
|
|
if (!$isNotForceHttps && $scheme === false && !AppConst::isDev()) {
|
|
|
|
|
|
|
|
$scheme = 'https';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scheme = empty($scheme) ? self::getCurProtocol() : $scheme;
|
|
|
|
$host = ($host === false) ? $this->getHost() : $host;
|
|
|
|
$host = ($host === false) ? $this->getHost() : $host;
|
|
|
|
$port = (filter_var($host, FILTER_VALIDATE_IP) !== false) ? $_SERVER['SERVER_PORT'] : (($scheme == 'https') ? 443 : 80);
|
|
|
|
$port = ($scheme == 'https') ? $_SERVER['SERVER_PORT'] : 80;
|
|
|
|
|
|
|
|
$port = in_array($port, [80, 443]) ? '' : (':' . $port);
|
|
|
|
|
|
|
|
|
|
|
|
$route = trim($route, '/');
|
|
|
|
$route = trim($route, '/');
|
|
|
|
$scriptName = $this->getScriptName();
|
|
|
|
if (preg_match('/v2\./i', $host) && $host != Zc::C('jflow.host')) {
|
|
|
|
$url = $scheme . '://' . $host . (in_array($port, [80, 443]) ? '' : ':' . $port) . substr($scriptName, 0, strpos($scriptName, 'index.php')) . $route;
|
|
|
|
$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 = '/';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$url = "{$scheme}://{$host}{$port}{$scriptName}{$route}";
|
|
|
|
|
|
|
|
|
|
|
|
if (is_array($params)) {
|
|
|
|
if (is_array($params)) {
|
|
|
|
|
|
|
|
unset($params['__NOAPI__']);
|
|
|
|
$params = http_build_query($params, '', '&');
|
|
|
|
$params = http_build_query($params, '', '&');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -20,26 +37,12 @@ class AppUrlHandler implements ZcUrlHandler {
|
|
|
|
return $url;
|
|
|
|
return $url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function getScriptName() {
|
|
|
|
|
|
|
|
$scriptName = $_SERVER['SCRIPT_NAME'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $scriptName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function getHost() {
|
|
|
|
private function getHost() {
|
|
|
|
return $_SERVER['HTTP_HOST'];
|
|
|
|
return $_SERVER['HTTP_HOST'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function getCurProtocol() {
|
|
|
|
private function getCurProtocol() {
|
|
|
|
return AppConst::getCurProtocol();
|
|
|
|
return 'http';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function parseBack() {
|
|
|
|
public function parseBack() {
|
|
|
@ -88,10 +91,6 @@ class AppUrlHandler implements ZcUrlHandler {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (preg_match('/^pdd\/control\/decrypt/', $route)) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$realRouteList = array(
|
|
|
|
$realRouteList = array(
|
|
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|