mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-21 06:19:38 +08:00
33 lines
897 B
PHP
33 lines
897 B
PHP
<?php
|
|
|
|
namespace App\Middlewares;
|
|
|
|
use Pecee\Http\Middleware\IMiddleware;
|
|
use Pecee\Http\Request;
|
|
use App\Models\PlayerModel;
|
|
|
|
class CheckPlayerExistMiddleware implements IMiddleware
|
|
{
|
|
public function handle(Request $request)
|
|
{
|
|
if (stripos($request->getUri(), '.json') != false) {
|
|
preg_match('/\/([^\/]*)\.json/', $request->getUri(), $matches);
|
|
} else {
|
|
preg_match('/\/([^\/]*)\.png/', $request->getUri(), $matches);
|
|
}
|
|
|
|
$player_name = $matches[1];
|
|
|
|
if (\Option::get('allow_chinese_playername')) {
|
|
$player_name = urldecode($player_name);
|
|
// quick fix of chinese playername route parameter problem
|
|
$GLOBALS['player_name'] = $player_name;
|
|
}
|
|
|
|
if (!PlayerModel::where('player_name', $player_name)->count()) {
|
|
\Http::abort(404, '角色不存在');
|
|
}
|
|
|
|
}
|
|
}
|