/** * Resolve an url with hashbang. * * @param Url $url * * @return string */ protected static function hashBang(Url $url) { if ($path = preg_replace('|^(/?!)|', '', $url->getFragment())) { return $url->withPath($url->getPath() . $path)->getUrl(); } return $url->getUrl(); }
private function checkMenu() { // 根据Router::$CLASS_DIR确定菜单 if (empty(Router::$CLASS_DIR)) { throw new ControllerException('无法确定菜单!'); } $arr = explode('/', Router::$CLASS_DIR); $menuFile = __DIR__ . '/menu/' . $arr[0] . '.menu.inc.php'; if (!is_file($menuFile)) { throw new ControllerException("菜单{$menuFile}不存在!"); } $this->backendMenuList = (include $menuFile); // 计算当前菜单 $currentPath = Url::getPath(); foreach ($this->backendMenuList as $menuInfo) { foreach ($menuInfo['menu'] as $menuItem) { if ($currentPath == $menuItem['url']) { $this->backendMenuInfo = $menuItem; $this->backendMenuInfo['parent_title'] = $menuInfo['title']; $this->backendMenuInfo['parent_code'] = Arr::get('code', $menuInfo, ''); break; } } if (!empty($this->backendMenuInfo)) { break; } } // assign $this->view->assign(array('backendMenuList' => $this->backendMenuList, 'backendMenuInfo' => $this->backendMenuInfo)); }
public static function dispatch() { $url = new Url(); $uri = $url->getPath(); foreach (array_reverse(self::$routes, true) as $route => $class) { if (preg_match("~^{$route}\$~", $uri, $params)) { Router::$current = $class; $return = call_user_func_array(array('Controller', 'dispatch'), array_merge(array($class), array_slice($params, 1))); if (!(false === $return)) { $vars = get_class_vars($class); $type = 'text/html'; if (isset($vars['type'])) { $type = $vars['type']; } # PHP >= 5.3 # if ( isset($class::$type) ) # $type = $class::$type; //Response::setHeader('Content-Type', 'application/xhtml+xml'); Response::setHeader('Content-Type', "{$type};charset=UTF-8"); Response::setBody($class, $return); return; } Router::$current = null; } } if (Response::getHttpResponseCode() == 200) { $class = 'Error404'; $return = Controller::dispatch($class); Response::setHeader('Content-Type', 'text/html;charset=UTF-8'); Response::setBody($class, $return); //Response::setHeader('HTTP/1.0 404 Not Found'); //Response::setHttpResponseCode(404); //Response::setBody('404', 'Error 404'); } }
/** * * @return boolean */ private function isSourcePathSubtringOfComparatorPath() { if (!$this->sourceUrl->hasPath() && $this->comparatorUrl->hasPath()) { return true; } $sourcePath = (string) $this->sourceUrl->getPath(); $comparatorpath = (string) $this->comparatorUrl->getPath(); if ($sourcePath == $comparatorpath) { return true; } return substr($comparatorpath, 0, strlen($sourcePath)) == $sourcePath; }
/** * @private * @static * Sets the session cookie path to the right path * @return nothing */ function setSessionCookiePath() { // get the right url for the script... somehow $_SERVER["REQUEST_URI"] // is returning things like "http://83.102.183.10.in-addr.arpa/plog/test.php" // in my case which are correct but probably not what we're expecting! $scriptUrl = HttpVars::getBaseUrl(); $url = new Url($scriptUrl); $path = dirname($url->getPath()); if ($path == "" || $path == "\\") { $path = "/"; } return $path; }
/** * Generate a base string for a RSA-SHA1 signature * based on the given a url, method, and any parameters. * * @param Url $url * @param string $method * @param array $parameters * * @return string */ protected function baseString(Url $url, $method = 'POST', array $parameters = []) { $baseString = rawurlencode($method) . '&'; $schemeHostPath = $url->getScheme() . '://' . $url->getHost(); if ($url->getPort() != '') { $schemeHostPath .= ':' . $url->getPort(); } if ($url->getPath() != '') { $schemeHostPath .= $url->getPath(); } $baseString .= rawurlencode($schemeHostPath) . '&'; $data = []; parse_str($url->getQuery(), $query); foreach (array_merge($query, $parameters) as $key => $value) { $data[rawurlencode($key)] = rawurlencode($value); } ksort($data); array_walk($data, function (&$value, $key) { $value = $key . '=' . $value; }); $baseString .= rawurlencode(implode('&', $data)); return $baseString; }
public function __construct() { parent::__construct(); $menuArr = array(); foreach (DocVars::$CATEGORY as $i => $title) { $menuItem = array('title' => $title, 'url' => '/list/' . $i . '/'); $menuArr[] = $menuItem; if ($menuItem['url'] == Url::getPath()) { $this->backendMenuInfo = $menuItem; $this->backendMenuInfo['parent_title'] = $this->backendMenuList['category']['title']; $this->backendMenuInfo['parent_code'] = Arr::get('code', $this->backendMenuList['category'], ''); } } $this->backendMenuList['category']['menu'] = $menuArr; $this->view->assign(array('backendMenuList' => $this->backendMenuList, 'backendMenuInfo' => $this->backendMenuInfo)); }
function testUrl() { $url = new Url(self::TEST_URL); $this->assertEquals($url->getFull(), self::TEST_URL); $this->assertEquals($url->getScheme(), 'https'); $this->assertEquals($url->getHost(), 'www.google.com'); $this->assertEquals($url->getPort(), '80'); $this->assertEquals($url->getPath(), '/some_path'); // The HTML entities remain intact $this->assertEquals($url->getQuery(), 'some=query&something=%20weird'); // The HTML entities are resolved $this->assertEquals($url->getParam('some'), 'query'); $this->assertEquals($url->getParam('something'), ' weird'); $this->assertEquals($url->getParams(), ['some' => 'query', 'something' => ' weird']); $this->assertEquals($url->getFragment(), 'some_fragment'); $this->assertEquals($url->getUser(), 'user'); $this->assertEquals($url->getPass(), 'pass'); }
/** * @biref 将网络文件上传到CDN源,非UTF-8的文本页面可能会出现乱码 * @param string $url 网络文件的url * @param int $id 标识用户id,默认0 * @param string $ext 文件的扩展名,$ext = 'jpg',如果不指定的话,会从url的扩展名中获取 * @return string cdnKey cdnKey * @exception Exception */ public static function uploadRemoteFile($url, $id = 0, $ext = '') { // 获取扩展名 $path = Url::getPath($url); if (empty($ext) && strpos($path, '.')) { $arr = explode('.', $path); $ext = end($arr); } $ossClient = self::getOssClient(); $cdnKey = self::makeKey($id, $ext); // 获取content type $contentType = ''; if (!empty($ext)) { $mimeTypes = Response::getMimeTypes(); $contentType = $mimeTypes[$ext]; } $curl = new Curl(); $ossClient->putObject(array('Bucket' => CdnConfig::BUCKET_NAME, 'Key' => $cdnKey, 'Content' => $curl->get($url), 'ContentEncoding' => GlobalConfig::CONTENT_CHARSET, 'ContentType' => $contentType)); return $cdnKey; }
/** * 处理原生url * @param $rawUrl * @return Url */ protected function handleRawUrl($rawUrl) { if (strpos($rawUrl, 'http') !== false || substr($rawUrl, 0, 2) == '//') { $newRawUrl = $rawUrl; } else { if ($rawUrl[0] !== '/') { if ($this->url->getParameter('extension') == '') { $pathname = rtrim($this->url->getPath(), '/') . '/' . $rawUrl; } else { $pathname = dirname($this->url->getPath()) . '/' . $rawUrl; } } else { $pathname = $rawUrl; } $newRawUrl = $this->url->getOrigin() . $pathname; } $url = Url::createFromUrl($newRawUrl); $url->setRawUrl($rawUrl); //将链接所属的repository记录下来 $url->setParameter('repository', $this); return $url; }
public function dispatch() { $response = Response::getInstance(); $url = new Url(); $uri = $url->getPath(); foreach (array_reverse($this->routes, true) as $route => $class) { if (preg_match("~^{$route}\$~", $uri, $params)) { $return = call_user_func_array(array('Controller', 'dispatch'), array_merge(array($class), array_slice($params, 1))); if (!(false === $return)) { //$response->setHeader('Content-Type', 'application/xhtml+xml'); $response->setHeader('Content-Type', 'text/html;charset=UTF-8'); $response->setBody($class, $return); return true; } } } if ($response->getHttpResponseCode() == 200) { //$response->setHeader('HTTP/1.0 404 Not Found'); $response->setHttpResponseCode(404); $response->setBody('404', 'Error 404'); } return false; }
function CustomUrlHandler() { $this->Object(); // we need to figure out the full server path so that we can generate proper // regexps for the url parsing. This should get rid of issues like // http://bugs.plogworld.net/view.php?id=369 // The base url will be one or another depending $config =& Config::getConfig(); if ($config->getValue("subdomains_enabled")) { $url = new Url($config->getValue("subdomains_base_url")); } else { $url = new Url($config->getValue("base_url")); } $path = $url->getPath(); // intialize the array we're going to use $config =& Config::getConfig(); $this->_indexName = $config->getValue("script_name"); $this->_formats = array("permalink_format" => $path . $config->getValue("permalink_format"), "category_link_format" => $path . $config->getValue("category_link_format"), "blog_link_format" => $path . $config->getValue("blog_link_format"), "archive_link_format" => $path . $config->getValue("archive_link_format"), "user_posts_link_format" => $path . $config->getValue("user_posts_link_format"), "post_trackbacks_link_format" => $path . $config->getValue("post_trackbacks_link_format"), "template_link_format" => $path . $config->getValue("template_link_format"), "album_link_format" => $path . $config->getValue("album_link_format"), "resource_link_format" => $path . $config->getValue("resource_link_format"), "resource_download_link_format" => $path . $config->getValue("resource_download_link_format"), "resource_preview_link_format" => $path . $config->getValue("resource_preview_link_format"), "resource_medium_size_preview_link_format" => $path . $config->getValue("resource_medium_size_preview_link_format")); // if the url did not match any of the current settings, then let's try to parse it as an old // "search engine friendly" url $this->_fallback = array("permalink_format" => $path . "/post/{blogid}/{postid}", "category_link_format" => $path . "/category/{blogid}/{catid}", "blog_link_format" => $path . "/{blogid}", "archive_link_format" => $path . "/archives/{blogid}/{year}/{month}/{day}", "user_posts_link_format" => $path . "/user/{blogid}/{userid}", "post_trackbacks_link_format" => $path . "/trackbacks/{blogid}/{postid}", "template_link_format" => $path . "/static/{blogid}/{templatename}", "album_link_format" => $path . "/album/{blogid}/{albumid}", "resource_link_format" => $path . "/resource/{blogid}/{resourceid}", "resource_download_link_format" => $path . "/get/{blogid}/{resourceid}", "resource_preview_link_format" => "", "resource_medium_size_preview_link_format" => ""); // this one does not exist either }
public function test1() { // test url manipulation $url = new Url(); $url->set('http://www.test.com/'); $this->assertEquals($url->getPath(), '/'); $url->setParam('cat', 1); $this->assertEquals($url->get(), 'http://www.test.com/?cat=1'); $this->assertEquals($url->getPath(), '/?cat=1'); $url->removeParam('cat'); $url->setParam('t', 'kalas'); $url->setParam('f', 'bas'); $this->assertEquals($url->get(), 'http://www.test.com/?t=kalas&f=bas'); $this->assertEquals($url->getPath(), '/?t=kalas&f=bas'); $url = new Url('http://test.com/?param'); $this->assertEquals($url->get(), 'http://test.com/?param'); $this->assertEquals($url->getPath(), '/?param'); $url = new Url('http://test.com/?p=n;hb=HEAD'); $this->assertEquals($url->get(), 'http://test.com/?p=n;hb=HEAD'); $this->assertEquals($url->getPath(), '/?p=n;hb=HEAD'); $url = new Url('http://test.com/?q=minuter+p%E5+skoj'); $this->assertEquals($url->get(), 'http://test.com/?q=minuter+p%E5+skoj'); $this->assertEquals($url->getPath(), '/?q=minuter+p%E5+skoj'); }
/** * Constructs absolute URL from Request object. * @return string|NULL */ public function constructUrl(PresenterRequest $appRequest, Url $refUrl) { if ($this->flags & self::ONE_WAY) { return NULL; } $params = $appRequest->getParameters(); // presenter name $presenter = $appRequest->getPresenterName(); if (strncasecmp($presenter, $this->module, strlen($this->module)) === 0) { $params[self::PRESENTER_KEY] = substr($presenter, strlen($this->module)); } else { return NULL; } // remove default values; NULL values are retain foreach ($this->defaults as $key => $value) { if (isset($params[$key]) && $params[$key] == $value) { // intentionally == unset($params[$key]); } } $url = ($this->flags & self::SECURED ? 'https://' : 'http://') . $refUrl->getAuthority() . $refUrl->getPath(); $sep = ini_get('arg_separator.input'); $query = http_build_query($params, '', $sep ? $sep[0] : '&'); if ($query != '') { // intentionally == $url .= '?' . $query; } return $url; }
<form class="mt10 mb10 bg-gray widget-form widget-form-toolbar" method="get"> <div class="fl"> <label class="label">比赛标题</label> <input class="w250 input" type="text" name="title" value="<?php echo Request::getGET('title'); ?> " /> <input type="hidden" name="uri" value="<?php echo Url::getPath(); ?> " /> <input class="w80 btn" type="submit" value="查找" /> </div> <div class="fr"> <?php if (Url::getPath() == '/diy_list/') { ?> <a href="/setup_contest_list/" class="f12" style="display: inline-block; padding-top: 6px;" ><< 我要创建DIY比赛<span class="fw red">【HOT】</span></a> <?php } ?> <label class="label">比赛进行状态</label> <select class="select" name="passed"> <option <?php echo (int) Request::getGET('passed', 0) == 0 ? 'selected' : ''; ?> value="0">当前</option> <option <?php echo (int) Request::getGET('passed', 0) == 1 ? 'selected' : ''; ?> value="1">已结束</option>
private function checkMenu() { $menuFile = __DIR__ . '/menu/' . $this->backendProjectInfo['menu']; if (!is_file($menuFile)) { $this->backendMenuList = array(); $this->backendMenuInfo = array(); // assign $this->view->assign(array('backendMenuList' => $this->backendMenuList, 'backendMenuInfo' => $this->backendMenuInfo)); return; } $this->backendMenuList = (include $menuFile); // 计算当前菜单 $currentPath = Url::getPath(); foreach ($this->backendMenuList as $menuInfo) { foreach ($menuInfo['menu'] as $menuItem) { if ($currentPath == $menuItem['url']) { $this->backendMenuInfo = $menuItem; $this->backendMenuInfo['parent_title'] = $menuInfo['title']; $this->backendMenuInfo['parent_code'] = Arr::get('code', $menuInfo, ''); break; } } if (!empty($this->backendMenuInfo)) { break; } } // 当前一级菜单和二级菜单权限判断 if (!empty($this->backendMenuInfo)) { // 一级菜单权限 $code = Arr::get('parent_code', $this->backendMenuInfo, ''); if (!empty($code)) { $allowed = RootCommonInterface::allowed(array('user_id' => $this->loginUserInfo['id'], 'path' => $code)); if (!$allowed) { $this->render404('你没有权限访问!'); } } // 二级菜单权限 $code = Arr::get('code', $this->backendMenuInfo, ''); if (!empty($code)) { $allowed = RootCommonInterface::allowed(array('user_id' => $this->loginUserInfo['id'], 'path' => $code)); if (!$allowed) { $this->render404('你没有权限访问!'); } } } // 过滤没有权限的菜单 foreach ($this->backendMenuList as $i => $menuInfo) { $code = Arr::get('code', $menuInfo, ''); if (!empty($code)) { $allowed = RootCommonInterface::allowed(array('user_id' => $this->loginUserInfo['id'], 'path' => $code)); if (!$allowed) { unset($this->backendMenuList[$i]); continue; } } foreach ($menuInfo['menu'] as $j => $menuItem) { $code = Arr::get('code', $menuItem, ''); if (!empty($code)) { $allowed = RootCommonInterface::allowed(array('user_id' => $this->loginUserInfo['id'], 'path' => $code)); if (!$allowed) { unset($this->backendMenuList[$i]['menu'][$j]); if (empty($this->backendMenuList[$i]['menu'])) { unset($this->backendMenuList[$i]); } continue; } } } } // assign $this->view->assign(array('backendMenuList' => $this->backendMenuList, 'backendMenuInfo' => $this->backendMenuInfo)); }
/** * Get the url relative to another url or two predefined formats. * * @param string|Url $relativeTo The url that the resulting string is going to be relative to */ public function getRelativeTo($relativeTo = self::RELATIVE_TO_NONE) { $buildUrl = ''; if ((int) $relativeTo === $relativeTo) { switch ($relativeTo) { case static::RELATIVE_TO_NONE: $parsed = parse_url($this->_url); return static::buildUrl($parsed); case static::RELATIVE_TO_SCHEME: $hostPart = $this->getHost(); if ($userPart = $this->getUser()) { if ($passPart = $this->getPassword()) { $userPart = $userPart . ':' . $passPart; } $hostPart = $userPart . '@' . $hostPart; } $buildUrl .= '//' . $hostPart; case static::RELATIVE_TO_HOST: $buildUrl .= $this->getPath(); if ($query = $this->getQuery()) { $buildUrl .= '?' . $query; } if ($fragment = $this->getFragment()) { $buildUrl .= '#' . $fragment; } return $buildUrl; } } if (!$relativeTo instanceof Url && is_string($relativeTo)) { $relativeTo = new Url($relativeTo); } else { if ($relativeTo instanceof Url) { $relativeTo = new Url($relativeTo->__toString()); } else { throw new Exception('Invalid argument, expected url!'); } } $relativeTo->clearParams(); $relativeTo->unsetFragment(); $pathRelative = $relativeTo->getPath(); if (!$pathRelative) { $pathRelative = '/'; } $relativeTo->setPath('/'); $relativeTo = $relativeTo->__toString(); $url = $this->getRelativeTo(static::RELATIVE_TO_NONE); if (strpos($url, $relativeTo) === 0) { $relWithPath = substr($url, strlen($relativeTo)); if (!$relWithPath || $relWithPath[0] != '/') { $relWithPath = '/' . $relWithPath; } $pathLen = strlen($pathRelative); while ($pathRelative[$pathLen - 1] == '/') { $pathLen--; } if ($pathLen == 0) { return $relWithPath; } $pathRelative = substr($pathRelative, 0, $pathLen); if ($pathRelative == $relWithPath) { return ''; } else { if (strpos($relWithPath, $pathRelative) === 0 && in_array($relWithPath[$pathLen], array('/', '?', '#'))) { /* Simple removal of the path relative to */ $relWithPath = substr($relWithPath, $pathLen); while ($relWithPath && $relWithPath[0] == '/') { $relWithPath = substr($relWithPath, 1); } return $relWithPath; } } return $relWithPath; } /* * Host-part did not match.. * Return full absolute url.. */ return $url; }
?> >状态</a> <a href="/rank_list/" <?php echo Url::getPath() == '/rank_list/' ? 'class="selected"' : ''; ?> >排名</a> </div> </td> <td> <div> <a href="/contest_list/" <?php echo Url::getPath() == '/contest_list/' ? 'class="selected"' : ''; ?> >竞赛</a> | <a href="/diy_list/" <?php echo Url::getPath() == '/diy_list/' ? 'class="selected"' : ''; ?> >DIY</a> </div> </td> <td> <?php if ($this->loginUserInfo) { ?> <div> <a href="/user_my/?username=<?php echo $this->loginUserInfo['username']; ?> "> <?php echo $this->loginUserInfo['username'];
/** * get a link from the current URL to another one * @param UrlInterface|string $url the URL to link to * @param boolean $forceAbsolute should an absolute path be used, defaults to `true`) * @return string the link */ public function linkTo($url, $forceAbsolute = true) { if (is_string($url)) { $url = new Url($url); } $str = (string) $url; if ($this->getScheme() !== $url->getScheme()) { return $str; } $str = preg_replace('(^[^/]+//)', '', $str); if ($this->getHost() !== $url->getHost() || $this->getPort() !== $url->getPort()) { return '//' . $str; } $str = preg_replace('(^[^/]+)', '', $str); if ($this->getPath() !== $url->getPath()) { if ($forceAbsolute) { return $str; } $cnt = 0; $tseg = $this->getSegments(); $useg = $url->getSegments(); foreach ($tseg as $k => $v) { if (!isset($useg[$k]) || $useg[$k] !== $v) { break; } $cnt++; } $str = './' . str_repeat('../', count($useg) - $cnt) . implode('/', array_slice($useg, $cnt)); if ($url->getQuery()) { $str .= '?' . $url->getQuery(); } if ($url->getFragment()) { $str .= '#' . $url->getFragment(); } return $str; } $str = preg_replace('(^[^?]+)', '', $str); if ($this->getQuery() !== $url->getQuery() || $url->getFragment() === null) { return $str; } return '#' . $url->getFragment(); }
/** * Resolve given relative Url using this url * @param Url $Url * @return Url */ public function resolve($Url) { $new = clone $this; if (!$Url->getHost()) { $new->setHost($this->getHost()); $new->setProtocol($this->getProtocol()); $new->setPort($this->getPort()); } $new->setQuery($Url->getQuery()); /* @var $new Url */ if (String::StartsWith($Url->getPath(), '/')) { $new->setPath($Url->getPath()); return $new; } else { $file = basename($Url->getPath()); $path = trim(trim(dirname($this->getPath()), '/') . '/' . trim(dirname($Url->getPath()), '/'), '/'); $parts = explode('/', $path); $resolved = array(); foreach ($parts as $part) { switch ($part) { case '.': case '': //Do nothing... break; case '..': array_pop($resolved); break; default: array_push($resolved, $part); break; } } if (count($resolved) > 0) { $new->setPath('/' . implode('/', $resolved) . '/' . $file); } else { $new->setPath('/' . $file); } return $new; } }
/** * 判断cookie是否与url适配 * @param Cookie $cookie * @param Url $url * @return bool */ protected function isComfortableForUrl(Cookie $cookie, Url $url) { return $this->matchPath($cookie->getPath(), $url->getPath()); }
/** * @param $url * @param $expectedPath * * @dataProvider dataProviderForTestGetPath */ public function testGetPath($url, $expectedPath) { $url = new Url($url); $this->assertEquals($expectedPath, $url->getPath()); }
public function testGetPath() { $this->assertEquals('/about', $this->absoluteUrl->getPath()); }
/** * Resolve an url with hashbang * * @param Url $url */ protected static function hashBang(Url $url) { if ($path = preg_replace('|^(/?!)|', '', $url->getFragment())) { $url->setPath($url->getPath() . $path); } }
public function formatLink(Url $url) { // save and reset query to save variable order $query = $url->getQuery(); $url->setQuery([]); // extract path to separate params and remove actions $parts = explode(self::REWRITE_PARAM_TO_ACTION_DELIMITER, $url->getPath()); foreach ($parts as $part) { // only extract "normal" parameters, avoid actions if (strpos($part, '-action') === false) { $paths = explode('/', strip_tags($part)); array_shift($paths); // create key => value pairs from the current request $x = 0; while ($x <= count($paths) - 1) { if (isset($paths[$x + 1])) { $url->setQueryParameter($paths[$x], $paths[$x + 1]); } // increment by 2, because the next offset is the key! $x = $x + 2; } } } // reset the path to not have duplicate path due to generic param generation $url->setPath(null); // merge query now to overwrite values already contained in the url $url->mergeQuery($query); $resultUrl = $this->getFormattedBaseUrl($url); $query = $url->getQuery(); if (count($query) > 0) { // get URL mappings and try to resolve mapped actions $mappings = $this->getActionUrMappingTokens(); foreach ($query as $name => $value) { // allow empty params that are action definitions to not // exclude actions with no params! if (!$this->isValueEmpty($value) || $this->isValueEmpty($value) && strpos($name, '-action') !== false || $this->isValueEmpty($value) && in_array($name, $mappings) !== false) { if (strpos($name, '-action') === false && in_array($name, $mappings) === false) { $resultUrl .= '/' . $name . '/' . $value; } else { // action blocks must be separated with group indicator // to be able to parse the parameters $resultUrl .= self::REWRITE_PARAM_TO_ACTION_DELIMITER . $name; // check whether value is empty and append action only if (!$this->isValueEmpty($value)) { $resultUrl .= '/' . $value; } } } } } // apply query to detect duplicate action definitions $actions = $this->getActionsUrlRepresentation($query, true); if (!empty($actions)) { $resultUrl .= self::REWRITE_PARAM_TO_ACTION_DELIMITER . $actions; } // encode blanks if desired if ($this->getEncodeBlanks() === true) { $resultUrl = strtr($resultUrl, [' ' => '%20']); } return $this->sanitizeUrl($this->appendAnchor($resultUrl, $url)); }
public function testUrlFragmentEncoding() { $url = new Url('http://127.0.0.1/foobar?bar=foo#!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'); $this->assertEquals('http', $url->getScheme()); $this->assertEquals(null, $url->getUserInfo()); $this->assertEquals('127.0.0.1', $url->getHost()); $this->assertEquals(null, $url->getPort()); $this->assertEquals('/foobar', $url->getPath()); $this->assertEquals(array('bar' => 'foo'), $url->getParameters()); $this->assertEquals('!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~', $url->getFragment()); }
<a class="item <?php echo Url::getPath() == '/problem_list/' ? 'item-hover' : ''; ?> " href="/problem_list/?contest-id=<?php echo $this->contestInfo['id']; ?> ">题目</a> <a class="item <?php echo Url::getPath() == '/rank_list/' ? 'item-hover' : ''; ?> " href="/rank_list/?contest-id=<?php echo $this->contestInfo['id']; ?> ">排名</a> <a class="item <?php echo Url::getPath() == '/status_list/' ? 'item-hover' : ''; ?> " href="/status_list/?contest-id=<?php echo $this->contestInfo['id']; ?> ">状态</a> </div> </div> <?php if (!empty($this->contestInfo['notice'])) { ?> <marquee scrollamount="3" style="margin: 5px 0 5px 0; color:red; font-weight: 700; font-size: 14px; display: block;"> <?php echo $this->contestInfo['notice']; ?>