redirect /api/textures request to real location

This commit is contained in:
printempw 2016-08-08 17:49:47 +08:00
parent b72252d109
commit 2934273086
3 changed files with 24 additions and 2 deletions

View File

@ -118,6 +118,11 @@ class TextureController extends BaseController
}
public static function redirectTextures($api, $hash)
{
Http::redirectPermanently('../../textures/'.$hash);
}
private function checkCache($player_name)
{
// Cache friendly

View File

@ -7,8 +7,10 @@ class Http
/**
* HTTP redirect
*
* @param string $url
* @return null
* @param string $url
* @param string $msg Write message to session
* @param boolean $use_js Use javascript to redirect
* @return void
*/
public static function redirect($url, $msg = "", $use_js = false)
{
@ -21,6 +23,19 @@ class Http
exit;
}
/**
* 301 Moved Permanently
*
* @param string $url
* @return void
*/
public static function redirectPermanently($url)
{
http_response_code(301);
header('Location: '.$url);
exit;
}
public static function getRealIP()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {

View File

@ -129,6 +129,8 @@ Route::group(['middleware' => 'App\Middlewares\CheckPlayerExis
}
});
Route::get('/{api}/textures/{hash}', 'TextureController@redirectTextures');
Route::get('/avatar/{base64_email}.png', 'TextureController@avatar');
Route::get('/avatar/{size}/{base64_email}.png', 'TextureController@avatarWithSize')->where(['base64_email' => '[^\\/]+?']);