$pat) { $rep_arr['{'.$name.'}'] = "(?P<$name>$pat)"; } $rep_arr['/'] = '\/'; $rep_arr['.'] = '\.'; $matches = []; if (isset($route['domain'])) { $domain_pat = strtr($route['domain'], $rep_arr); if (!preg_match('/^'.$domain_pat.'$/', UOJContext::requestDomain(), $domain_matches)) { return false; } $matches = array_merge($matches, $domain_matches); } if (isset($route['port'])) { $ports = explode('/', $route['port']); if (!in_array(UOJContext::requestPort(), $ports)) { return false; } } $uri_pat = strtr($route['uri'], $rep_arr); if (!preg_match('/^'.$uri_pat.'$/', rtrim(UOJContext::requestPath(), '/'), $uri_matches)) { return false; } $matches = array_merge($matches, $uri_matches); foreach ($matches as $key => $val) { if (!is_numeric($key)) { $_GET[$key] = $val; } } if (isset($route['protocol'])) { switch ($route['protocol']) { case 'http': if (UOJContext::isUsingHttps()) { permanentlyRedirectToHTTP(); } break; case 'https': if (!UOJContext::isUsingHttps()) { permanentlyRedirectToHTTPS(); } break; } } return true; } }