mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-02-17 14:49:27 +08:00
remove constant BASE_DIR
This commit is contained in:
parent
3a527137d4
commit
4ef6fba0c6
@ -5,11 +5,13 @@ namespace App\Http\Controllers;
|
||||
use Utils;
|
||||
use Schema;
|
||||
use Option;
|
||||
use Storage;
|
||||
use Artisan;
|
||||
use Database;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Validator;
|
||||
use App\Exceptions\PrettyPageException;
|
||||
|
||||
class SetupController extends Controller
|
||||
{
|
||||
@ -121,10 +123,7 @@ class SetupController extends Controller
|
||||
|
||||
protected function createDirectories()
|
||||
{
|
||||
if (!is_dir(BASE_DIR.'/storage/textures/')) {
|
||||
if (!mkdir(BASE_DIR.'/storage/textures/'))
|
||||
throw new App\Exceptions\PrettyPageException('/storage/textures 文件夹创建失败,请检查目录权限是否正确,或者手动放置一个。', -1);
|
||||
}
|
||||
Utils::checkTextureDirectory();
|
||||
}
|
||||
|
||||
protected function checkTablesExist()
|
||||
|
@ -100,7 +100,7 @@ class TextureController extends Controller
|
||||
if (isset($responses[0]) && $responses[0] instanceof \Symfony\Component\HttpFoundation\Response) {
|
||||
return $responses[0];
|
||||
} else {
|
||||
$filename = BASE_DIR."/storage/textures/{$t->hash}";
|
||||
$filename = storage_path("textures/{$t->hash}");
|
||||
|
||||
$png = Minecraft::generateAvatarFromSkin($filename, $size);
|
||||
imagepng($png);
|
||||
@ -135,7 +135,7 @@ class TextureController extends Controller
|
||||
if (isset($responses[0]) && $responses[0] instanceof \Symfony\Component\HttpFoundation\Response) {
|
||||
return $responses[0];
|
||||
} else {
|
||||
$filename = BASE_DIR."/storage/textures/{$t->hash}";
|
||||
$filename = storage_path("textures/{$t->hash}");
|
||||
|
||||
if ($t->type == "cape") {
|
||||
$png = Minecraft::generatePreviewFromCape($filename, $size);
|
||||
|
@ -121,7 +121,7 @@ class Player extends Model
|
||||
{
|
||||
if ($this->getTexture($type)) {
|
||||
$hash = $this->getTexture($type);
|
||||
$path = BASE_DIR."/storage/textures/".$hash;
|
||||
$path = storage_path("textures/$hash");
|
||||
|
||||
if (Storage::disk('textures')->has($hash)) {
|
||||
// Cache friendly
|
||||
@ -202,7 +202,9 @@ class Player extends Model
|
||||
{
|
||||
// Support both CustomSkinLoader API & UniSkinAPI
|
||||
if ($api_type == self::CSL_API || $api_type == self::USM_API) {
|
||||
|
||||
$responses = Event::fire(new GetPlayerJson($this, $api_type));
|
||||
|
||||
// if listeners return nothing
|
||||
if (isset($responses[0]) && $responses[0] !== null) {
|
||||
return $responses[0];
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use View;
|
||||
use Utils;
|
||||
use Schema;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
@ -29,7 +30,7 @@ class BootServiceProvider extends ServiceProvider
|
||||
|
||||
protected function checkFileExists()
|
||||
{
|
||||
if (!file_exists(BASE_DIR."/.env")) {
|
||||
if (!file_exists(base_path('.env'))) {
|
||||
throw new PrettyPageException(trans('setup.file.no-dot-env'), -1);
|
||||
}
|
||||
}
|
||||
@ -63,10 +64,7 @@ class BootServiceProvider extends ServiceProvider
|
||||
return redirect('/setup')->send();
|
||||
}
|
||||
|
||||
if (!is_dir(BASE_DIR.'/storage/textures/')) {
|
||||
if (!mkdir(BASE_DIR.'/storage/textures/'))
|
||||
throw new PrettyPageException(trans('setup.file.permission-error'), -1);
|
||||
}
|
||||
Utils::checkTextureDirectory();
|
||||
|
||||
if (version_compare(config('app.version'), option('version', ''), '>')) {
|
||||
return redirect('/setup/update')->send();
|
||||
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Database;
|
||||
|
||||
class Migration
|
||||
{
|
||||
/**
|
||||
* Create tables, prefix will be added automatically
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function creatTables()
|
||||
{
|
||||
require BASE_DIR."/setup/tables.php";
|
||||
}
|
||||
|
||||
public static function __callStatic($method, $args)
|
||||
{
|
||||
if (strpos($method, 'import') !== false) {
|
||||
$filename = BASE_DIR."/setup/migrations/".snake_case($method).".php";
|
||||
if (file_exists($filename)) {
|
||||
return require $filename;
|
||||
}
|
||||
}
|
||||
throw new \InvalidArgumentException('Non-existent migration');
|
||||
}
|
||||
|
||||
}
|
@ -51,7 +51,7 @@ class Updater
|
||||
public function __construct($current_version)
|
||||
{
|
||||
$this->current_version = $current_version;
|
||||
$this->update_sources = require BASE_DIR."/config/update.php";
|
||||
$this->update_sources = config('update');
|
||||
|
||||
$source = Option::get('update_source');
|
||||
|
||||
@ -115,7 +115,7 @@ class Updater
|
||||
if (!$silent)
|
||||
echo "<p>下载完成。</p>";
|
||||
|
||||
$update_cache = BASE_DIR."/setup/update_cache/";
|
||||
$update_cache = storage_path('update_cache');
|
||||
|
||||
if (!is_dir($update_cache)) {
|
||||
if (false === mkdir($update_cache)) {
|
||||
@ -126,7 +126,7 @@ class Updater
|
||||
$zip_path = $update_cache."update_".time().".zip";
|
||||
|
||||
if (Storage::put($zip_path, $file) === false) {
|
||||
Storage::removeDir(BASE_DIR.'/setup/update_cache/');
|
||||
Storage::removeDir($update_cache);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Exceptions\PrettyPageException;
|
||||
use Storage;
|
||||
use Log;
|
||||
use Storage;
|
||||
use App\Exceptions\PrettyPageException;
|
||||
|
||||
class Utils
|
||||
{
|
||||
@ -17,11 +17,11 @@ class Utils
|
||||
public static function upload($file)
|
||||
{
|
||||
$path = 'tmp'.time();
|
||||
$absolute_path = BASE_DIR."/storage/textures/$path";
|
||||
$absolute_path = storage_path("textures/$path");
|
||||
|
||||
try {
|
||||
if (false === move_uploaded_file($file['tmp_name'], $absolute_path)) {
|
||||
throw new Exception('Failed to remove uploaded files, please check the permission', 1);
|
||||
throw new \Exception('Failed to remove uploaded files, please check the permission', 1);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::warning("Failed to move uploaded file, $e");
|
||||
@ -79,4 +79,13 @@ class Utils
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function checkTextureDirectory()
|
||||
{
|
||||
if (!Storage::disk('storage')->has('textures')) {
|
||||
// mkdir
|
||||
if (!Storage::disk('storage')->makeDirectory('textures'))
|
||||
throw new PrettyPageException(trans('setup.file.permission-error'), -1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ if (! function_exists('bs_menu')) {
|
||||
|
||||
function bs_menu($type)
|
||||
{
|
||||
$menu = require BASE_DIR."/config/menu.php";
|
||||
$menu = config('menu');
|
||||
|
||||
event($type == "user" ? new App\Events\ConfigureUserMenu($menu)
|
||||
: new App\Events\ConfigureAdminMenu($menu));
|
||||
|
6
artisan
6
artisan
@ -1,8 +1,6 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
define('BASE_DIR', __DIR__);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
@ -15,9 +13,9 @@ define('BASE_DIR', __DIR__);
|
||||
|
|
||||
*/
|
||||
|
||||
require BASE_DIR.'/bootstrap/autoload.php';
|
||||
require __DIR__.'/bootstrap/autoload.php';
|
||||
|
||||
$app = require_once BASE_DIR.'/bootstrap/app.php';
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -48,6 +48,11 @@ return [
|
||||
'root' => storage_path('app'),
|
||||
],
|
||||
|
||||
'storage' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path(),
|
||||
],
|
||||
|
||||
'textures' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('textures'),
|
||||
|
@ -7,11 +7,9 @@
|
||||
* @author printempw <h@prinzeugen.net>
|
||||
*/
|
||||
|
||||
define('BASE_DIR', __DIR__);
|
||||
require __DIR__.'/bootstrap/autoload.php';
|
||||
|
||||
require BASE_DIR.'/bootstrap/autoload.php';
|
||||
|
||||
$app = require_once BASE_DIR.'/bootstrap/app.php';
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
}
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$extract_dir = BASE_DIR."/setup/update_cache/{$updater->latest_version}";
|
||||
$extract_dir = storage_path("update_cache/{$updater->latest_version}");
|
||||
$res = $zip->open($zip_path);
|
||||
|
||||
if ($res === true) {
|
||||
@ -42,12 +42,12 @@
|
||||
}
|
||||
$zip->close();
|
||||
|
||||
if (Storage::copyDir($extract_dir, BASE_DIR) !== true) {
|
||||
Storage::removeDir(BASE_DIR.'/setup/update_cache/');
|
||||
if (Storage::copyDir($extract_dir, base_path()) !== true) {
|
||||
Storage::removeDir(storage_path('update_cache'));
|
||||
exit('无法覆盖文件。');
|
||||
} else {
|
||||
echo "<p>正在覆盖文件</p>";
|
||||
Storage::removeDir(BASE_DIR.'/setup/update_cache/');
|
||||
Storage::removeDir(storage_path('update_cache'));
|
||||
echo "<p>正在清理</p>";
|
||||
}
|
||||
echo "<p>更新完成。</p>";
|
||||
@ -57,7 +57,7 @@
|
||||
</div><!-- /.box-body -->
|
||||
|
||||
<div class="box-footer">
|
||||
<a href="../setup/update.php" class="btn btn-primary">下一步</a>
|
||||
<a href="{{ url('setup/update') }}" class="btn btn-primary">下一步</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user