fix relative urls, close #27

This commit is contained in:
printempw 2016-08-13 21:41:53 +08:00
parent 46bf958215
commit e28be4cc32
4 changed files with 19 additions and 10 deletions

View File

@ -59,11 +59,6 @@ class Http
return $_SERVER["REQUEST_URI"];
}
public static function getCurrentUrl()
{
return self::getBaseUrl().$_SERVER["REQUEST_URI"];
}
public static function getBaseUrl()
{
$base_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? "https://" : "http://";
@ -73,6 +68,22 @@ class Http
return $base_url;
}
public static function getCurrentUrl()
{
return self::getBaseUrl().$_SERVER["REQUEST_URI"];
}
/**
* Generate absolute url according to relative one
*
* @param string $relative
* @return string
*/
public static function urlTo($relative)
{
return Option::get('site_url').$relative;
}
public static function abort($code, $msg = "Something happened.", $is_json = false)
{
http_response_code((int)$code);

View File

@ -66,7 +66,7 @@
</td>
</tr>
<tr title="以 http:// 开头,不要以 / 结尾" data-toggle="tooltip" data-placement="top">
<tr title="以 http(s):// 开头,不要以 / 结尾" data-toggle="tooltip" data-placement="top">
<td class="key">站点地址URL</td>
<td class="value">
<input type="text" class="form-control" name="site_url" value="{{ Option::get('site_url') }}">

View File

@ -75,9 +75,7 @@
<!-- Navbar Right Menu -->
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
@unless (isset($with_out_filter))
<li><a href="./skinlib/upload"><i class="fa fa-upload" aria-hidden="true"></i> 上传新皮肤</a></li>
@endunless
<li><a href="{{ Http::urlTo('/skinlib/upload') }}"><i class="fa fa-upload" aria-hidden="true"></i> 上传新皮肤</a></li>
@if (!is_null($user))
<!-- User Account Menu -->
<li class="dropdown user user-menu">

View File

@ -9,7 +9,7 @@
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
搜索结果
搜索结果{{ $_GET['q'] or "未指定关键字" }}
<small>Skin Library</small>
</h1>