1、内核更新
2、代码更新
This commit is contained in:
@@ -225,7 +225,7 @@ class App
|
||||
}
|
||||
$args = self::bindParams($reflect, $vars);
|
||||
|
||||
self::$debug && Log::record('[ RUN ] ' . $reflect->__toString(), 'info');
|
||||
self::$debug && Log::record('[ RUN ] ' . $reflect->class . '->' . $reflect->name . '[ ' . $reflect->getFileName() . ' ]', 'info');
|
||||
return $reflect->invokeArgs(isset($class) ? $class : null, $args);
|
||||
}
|
||||
|
||||
@@ -245,8 +245,6 @@ class App
|
||||
} else {
|
||||
$args = [];
|
||||
}
|
||||
|
||||
self::$debug && Log::record('[ RUN ] ' . $reflect->__toString(), 'info');
|
||||
return $reflect->newInstanceArgs($args);
|
||||
}
|
||||
|
||||
|
||||
@@ -124,10 +124,10 @@ class Request
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param array $options 参数
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
protected function __construct($options = [])
|
||||
{
|
||||
foreach ($options as $name => $item) {
|
||||
if (property_exists($this, $name)) {
|
||||
@@ -910,18 +910,22 @@ class Request
|
||||
{
|
||||
if (empty($this->header)) {
|
||||
$header = [];
|
||||
$server = $this->server ?: $_SERVER;
|
||||
foreach ($server as $key => $val) {
|
||||
if (0 === strpos($key, 'HTTP_')) {
|
||||
$key = str_replace('_', '-', strtolower(substr($key, 5)));
|
||||
$header[$key] = $val;
|
||||
if (function_exists('apache_request_headers') && $result = apache_request_headers()) {
|
||||
$header = $result;
|
||||
} else {
|
||||
$server = $this->server ?: $_SERVER;
|
||||
foreach ($server as $key => $val) {
|
||||
if (0 === strpos($key, 'HTTP_')) {
|
||||
$key = str_replace('_', '-', strtolower(substr($key, 5)));
|
||||
$header[$key] = $val;
|
||||
}
|
||||
}
|
||||
if (isset($server['CONTENT_TYPE'])) {
|
||||
$header['content-type'] = $server['CONTENT_TYPE'];
|
||||
}
|
||||
if (isset($server['CONTENT_LENGTH'])) {
|
||||
$header['content-length'] = $server['CONTENT_LENGTH'];
|
||||
}
|
||||
}
|
||||
if (isset($server['CONTENT_TYPE'])) {
|
||||
$header['content-type'] = $server['CONTENT_TYPE'];
|
||||
}
|
||||
if (isset($server['CONTENT_LENGTH'])) {
|
||||
$header['content-length'] = $server['CONTENT_LENGTH'];
|
||||
}
|
||||
$this->header = array_change_key_case($header);
|
||||
}
|
||||
|
||||
@@ -943,8 +943,16 @@ class Route
|
||||
|
||||
if (is_array($item)) {
|
||||
list($rule, $option) = $item;
|
||||
if (isset($option['method'][$array[0]])) {
|
||||
$option['method'] = $option['method'][$array[0]];
|
||||
$action = $array[0];
|
||||
if (isset($option['allow']) && !in_array($action, explode(',', $option['allow']))) {
|
||||
// 允许操作
|
||||
return false;
|
||||
} elseif (isset($option['except']) && in_array($action, explode(',', $option['except']))) {
|
||||
// 排除操作
|
||||
return false;
|
||||
}
|
||||
if (isset($option['method'][$action])) {
|
||||
$option['method'] = $option['method'][$action];
|
||||
}
|
||||
} else {
|
||||
$rule = $item;
|
||||
@@ -957,7 +965,7 @@ class Route
|
||||
} elseif (0 === strpos($rule, '\\')) {
|
||||
// 路由到类
|
||||
return self::bindToClass($bind, substr($rule, 1), $depr);
|
||||
} elseif (0 === strpos($url, '@')) {
|
||||
} elseif (0 === strpos($rule, '@')) {
|
||||
// 路由到控制器类
|
||||
return self::bindToController($bind, substr($rule, 1), $depr);
|
||||
} else {
|
||||
@@ -1406,7 +1414,7 @@ class Route
|
||||
if ($route instanceof \Closure) {
|
||||
// 执行闭包
|
||||
$result = ['type' => 'function', 'function' => $route];
|
||||
} elseif (0 === strpos($route, '/') || 0 === strpos($route, 'http')) {
|
||||
} elseif (0 === strpos($route, '/') || strpos($route, '://')) {
|
||||
// 路由到重定向地址
|
||||
$result = ['type' => 'redirect', 'url' => $route, 'status' => isset($option['status']) ? $option['status'] : 301];
|
||||
} elseif (false !== strpos($route, '\\')) {
|
||||
|
||||
@@ -85,13 +85,28 @@ class Url
|
||||
} elseif (!empty($rule) && isset($name)) {
|
||||
throw new \InvalidArgumentException('route name not exists:' . $name);
|
||||
} else {
|
||||
// 检查别名路由
|
||||
$alias = Route::rules('alias');
|
||||
if ($alias) {
|
||||
// 别名路由解析
|
||||
foreach ($alias as $key => $val) {
|
||||
if (is_array($val)) {
|
||||
$val = $val[0];
|
||||
}
|
||||
if (0 === strpos($url, $val)) {
|
||||
$url = $key . substr($url, strlen($val));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 路由标识不存在 直接解析
|
||||
$url = self::parseUrl($url, $domain);
|
||||
}
|
||||
if (isset($info['query'])) {
|
||||
// 解析地址里面参数 合并到vars
|
||||
parse_str($info['query'], $params);
|
||||
$vars = array_merge($params, $vars);
|
||||
}
|
||||
// 路由标识不存在 直接解析
|
||||
$url = self::parseUrl($url, $domain);
|
||||
}
|
||||
|
||||
// 检测URL绑定
|
||||
@@ -119,7 +134,11 @@ class Url
|
||||
} else {
|
||||
foreach ($vars as $var => $val) {
|
||||
if ('' !== trim($val)) {
|
||||
$url .= $depr . $var . $depr . urlencode($val);
|
||||
if (Config::get('url_param_type')) {
|
||||
$url .= $depr . urlencode($val);
|
||||
} else {
|
||||
$url .= $depr . $var . $depr . urlencode($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
$url .= $suffix . $anchor;
|
||||
|
||||
Reference in New Issue
Block a user