public static function url($url = null, $query = null, $fragment = null) { if (!$url) { $url = \Gini\CGI::route(); } $ui = parse_url($url); if ($ui['scheme'] == 'mailto') { //邮件地址 return 'mailto:' . $ui['user'] . '@' . $ui['host']; } if ($query) { if ($ui['query']) { if (is_string($query)) { parse_str($query, $query); } parse_str($ui['query'], $old_query); $ui['query'] = http_build_query(array_merge($old_query, $query)); } else { $ui['query'] = is_string($query) ? $query : http_build_query($query); } } if ($fragment) { $ui['fragment'] = $fragment; } if ($ui['host']) { $url = $ui['scheme'] ?: 'http'; $url .= '://'; if ($ui['user']) { if ($ui['pass']) { $url .= $ui['user'] . ':' . $ui['pass'] . '@'; } else { $url .= $ui['user'] . '@'; } } $url .= $ui['host']; if ($ui['port']) { $url .= ':' . $ui['port']; } $url .= '/'; } else { $url = self::base(); } if ($ui['path']) { $url .= ltrim($ui['path'], '/'); } if ($ui['query']) { $url .= '?' . $ui['query']; } if ($ui['fragment']) { $url .= '#' . $ui['fragment']; } return $url; }
public static function setup() { //获取系统维护模块的状态信息 $config = \Gini\Config::get('maintenance'); $route = \Gini\CGI::route(); $path = 'maintain'; //维护模块开启 if ($config['status'] && $config['status'] == 'on') { //判断$route是防止后续的模块不给他机会直接跳转,判断$route != $path是防止重定向跳转 if ($route && $route != $path) { \Gini\CGI::redirect($path); } } }