2015-12-06 18:58:49 +00:00
|
|
|
<?php
|
2017-01-25 00:15:03 +00:00
|
|
|
/**
|
|
|
|
* Pterodactyl - Panel
|
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
2015-12-06 18:58:49 +00:00
|
|
|
|
|
|
|
namespace Pterodactyl\Providers;
|
|
|
|
|
2017-04-28 02:28:01 +00:00
|
|
|
use View;
|
|
|
|
use Cache;
|
2017-02-18 00:23:27 +00:00
|
|
|
use Pterodactyl\Models;
|
|
|
|
use Pterodactyl\Observers;
|
2017-09-25 03:34:30 +00:00
|
|
|
use Illuminate\Support\Facades\Schema;
|
2015-12-06 18:58:49 +00:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2017-09-25 03:34:30 +00:00
|
|
|
Schema::defaultStringLength(191);
|
|
|
|
|
2017-02-18 00:23:27 +00:00
|
|
|
Models\User::observe(Observers\UserObserver::class);
|
|
|
|
Models\Server::observe(Observers\ServerObserver::class);
|
|
|
|
Models\Subuser::observe(Observers\SubuserObserver::class);
|
2017-04-28 02:28:01 +00:00
|
|
|
|
|
|
|
View::share('appVersion', $this->versionData()['version'] ?? 'undefined');
|
|
|
|
View::share('appIsGit', $this->versionData()['is_git'] ?? false);
|
2015-12-06 18:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
2017-03-15 23:47:44 +00:00
|
|
|
if ($this->app->environment() !== 'production') {
|
|
|
|
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
|
|
|
|
}
|
2017-04-14 21:10:01 +00:00
|
|
|
|
|
|
|
if (config('pterodactyl.auth.notifications')) {
|
2017-04-14 21:11:54 +00:00
|
|
|
$this->app->register(\DaneEveritt\LoginNotifications\NotificationServiceProvider::class);
|
2017-04-14 21:10:01 +00:00
|
|
|
}
|
2015-12-06 18:58:49 +00:00
|
|
|
}
|
2017-04-28 02:28:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return version information for the footer.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function versionData()
|
|
|
|
{
|
|
|
|
return Cache::remember('git-version', 5, function () {
|
|
|
|
if (file_exists(base_path('.git/HEAD'))) {
|
|
|
|
$head = explode(' ', file_get_contents(base_path('.git/HEAD')));
|
2017-07-23 22:55:38 +00:00
|
|
|
|
|
|
|
if (array_key_exists(1, $head)) {
|
|
|
|
$path = base_path('.git/' . trim($head[1]));
|
|
|
|
}
|
2017-04-28 02:28:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($path) && file_exists($path)) {
|
|
|
|
return [
|
|
|
|
'version' => substr(file_get_contents($path), 0, 8),
|
|
|
|
'is_git' => true,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
return [
|
|
|
|
'version' => config('app.version'),
|
|
|
|
'is_git' => false,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
2015-12-06 18:58:49 +00:00
|
|
|
}
|