1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-23 01:22:30 +01:00

Fix links in admin area

This commit is contained in:
Dane Everitt 2019-12-22 14:03:49 -08:00
parent 52ea0f2d0a
commit 6276a03a4e
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
2 changed files with 33 additions and 32 deletions

View File

@ -1,25 +1,22 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Services\Helpers;
use stdClass;
use Exception;
use GuzzleHttp\Client;
use Cake\Chronos\Chronos;
use Illuminate\Support\Arr;
use Illuminate\Contracts\Cache\Repository as CacheRepository;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Pterodactyl\Exceptions\Service\Helper\CdnVersionFetchingException;
class SoftwareVersionService
{
const VERSION_CACHE_KEY = 'pterodactyl:versions';
const VERSION_CACHE_KEY = 'pterodactyl:versioning_data';
/**
* @var array
*/
private static $result;
/**
* @var \Illuminate\Contracts\Cache\Repository
@ -31,28 +28,20 @@ class SoftwareVersionService
*/
protected $client;
/**
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;
/**
* SoftwareVersionService constructor.
*
* @param \Illuminate\Contracts\Cache\Repository $cache
* @param \GuzzleHttp\Client $client
* @param \Illuminate\Contracts\Config\Repository $config
*/
public function __construct(
CacheRepository $cache,
Client $client,
ConfigRepository $config
Client $client
) {
$this->cache = $cache;
$this->client = $client;
$this->config = $config;
$this->cacheVersionData();
self::$result = $this->cacheVersionData();
}
/**
@ -62,7 +51,7 @@ class SoftwareVersionService
*/
public function getPanel()
{
return object_get($this->cache->get(self::VERSION_CACHE_KEY), 'panel', 'error');
return Arr::get(self::$result, 'panel') ?? 'error';
}
/**
@ -72,7 +61,7 @@ class SoftwareVersionService
*/
public function getDaemon()
{
return object_get($this->cache->get(self::VERSION_CACHE_KEY), 'daemon', 'error');
return Arr::get(self::$result, 'daemon') ?? 'error';
}
/**
@ -82,7 +71,17 @@ class SoftwareVersionService
*/
public function getDiscord()
{
return object_get($this->cache->get(self::VERSION_CACHE_KEY), 'discord', 'https://pterodactyl.io/discord');
return Arr::get(self::$result, 'discord') ?? 'https://pterodactyl.io/discord';
}
/**
* Get the URL for donations.
*
* @return string
*/
public function getDonations()
{
return Arr::get(self::$result, 'donations') ?? 'https://paypal.me/PterodactylSoftware';
}
/**
@ -92,11 +91,11 @@ class SoftwareVersionService
*/
public function isLatestPanel()
{
if ($this->config->get('app.version') === 'canary') {
if (config()->get('app.version') === 'canary') {
return true;
}
return version_compare($this->config->get('app.version'), $this->getPanel()) >= 0;
return version_compare(config()->get('app.version'), $this->getPanel()) >= 0;
}
/**
@ -116,20 +115,22 @@ class SoftwareVersionService
/**
* Keeps the versioning cache up-to-date with the latest results from the CDN.
*
* @return array
*/
protected function cacheVersionData()
{
$this->cache->remember(self::VERSION_CACHE_KEY, Chronos::now()->addMinutes(config('pterodactyl.cdn.cache_time')), function () {
return $this->cache->remember(self::VERSION_CACHE_KEY, Chronos::now()->addMinutes(config()->get('pterodactyl.cdn.cache_time', 60)), function () {
try {
$response = $this->client->request('GET', $this->config->get('pterodactyl.cdn.url'));
$response = $this->client->request('GET', config()->get('pterodactyl.cdn.url'));
if ($response->getStatusCode() === 200) {
return json_decode($response->getBody());
return json_decode($response->getBody(), true);
}
throw new CdnVersionFetchingException;
} catch (Exception $exception) {
return new stdClass();
return [];
}
});
}

View File

@ -45,14 +45,14 @@
<a href="{{ $version->getDiscord() }}"><button class="btn btn-warning" style="width:100%;"><i class="fa fa-fw fa-support"></i> Get Help <small>(via Discord)</small></button></a>
</div>
<div class="col-xs-6 col-sm-3 text-center">
<a href="https://docs.pterodactyl.io"><button class="btn btn-primary" style="width:100%;"><i class="fa fa-fw fa-link"></i> Documentation</button></a>
<a href="https://pterodactyl.io"><button class="btn btn-primary" style="width:100%;"><i class="fa fa-fw fa-link"></i> Documentation</button></a>
</div>
<div class="clearfix visible-xs-block">&nbsp;</div>
<div class="col-xs-6 col-sm-3 text-center">
<a href="https://github.com/Pterodactyl/Panel"><button class="btn btn-primary" style="width:100%;"><i class="fa fa-fw fa-support"></i> Github</button></a>
<a href="https://github.com/pterodactyl/panel"><button class="btn btn-primary" style="width:100%;"><i class="fa fa-fw fa-support"></i> Github</button></a>
</div>
<div class="col-xs-6 col-sm-3 text-center">
<a href="https://donorbox.org/pterodactyl"><button class="btn btn-success" style="width:100%;"><i class="fa fa-fw fa-money"></i> Support the Project</button></a>
<a href="{{ $version->getDonations() }}"><button class="btn btn-success" style="width:100%;"><i class="fa fa-fw fa-money"></i> Support the Project</button></a>
</div>
</div>
@endsection