Skip to content

Commit 6276a03

Browse files
committed
Fix links in admin area
1 parent 52ea0f2 commit 6276a03

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

app/Services/Helpers/SoftwareVersionService.php

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Services\Helpers;
114

12-
use stdClass;
135
use Exception;
146
use GuzzleHttp\Client;
157
use Cake\Chronos\Chronos;
8+
use Illuminate\Support\Arr;
169
use Illuminate\Contracts\Cache\Repository as CacheRepository;
17-
use Illuminate\Contracts\Config\Repository as ConfigRepository;
1810
use Pterodactyl\Exceptions\Service\Helper\CdnVersionFetchingException;
1911

2012
class SoftwareVersionService
2113
{
22-
const VERSION_CACHE_KEY = 'pterodactyl:versions';
14+
const VERSION_CACHE_KEY = 'pterodactyl:versioning_data';
15+
16+
/**
17+
* @var array
18+
*/
19+
private static $result;
2320

2421
/**
2522
* @var \Illuminate\Contracts\Cache\Repository
@@ -31,28 +28,20 @@ class SoftwareVersionService
3128
*/
3229
protected $client;
3330

34-
/**
35-
* @var \Illuminate\Contracts\Config\Repository
36-
*/
37-
protected $config;
38-
3931
/**
4032
* SoftwareVersionService constructor.
4133
*
4234
* @param \Illuminate\Contracts\Cache\Repository $cache
4335
* @param \GuzzleHttp\Client $client
44-
* @param \Illuminate\Contracts\Config\Repository $config
4536
*/
4637
public function __construct(
4738
CacheRepository $cache,
48-
Client $client,
49-
ConfigRepository $config
39+
Client $client
5040
) {
5141
$this->cache = $cache;
5242
$this->client = $client;
53-
$this->config = $config;
5443

55-
$this->cacheVersionData();
44+
self::$result = $this->cacheVersionData();
5645
}
5746

5847
/**
@@ -62,7 +51,7 @@ public function __construct(
6251
*/
6352
public function getPanel()
6453
{
65-
return object_get($this->cache->get(self::VERSION_CACHE_KEY), 'panel', 'error');
54+
return Arr::get(self::$result, 'panel') ?? 'error';
6655
}
6756

6857
/**
@@ -72,7 +61,7 @@ public function getPanel()
7261
*/
7362
public function getDaemon()
7463
{
75-
return object_get($this->cache->get(self::VERSION_CACHE_KEY), 'daemon', 'error');
64+
return Arr::get(self::$result, 'daemon') ?? 'error';
7665
}
7766

7867
/**
@@ -82,7 +71,17 @@ public function getDaemon()
8271
*/
8372
public function getDiscord()
8473
{
85-
return object_get($this->cache->get(self::VERSION_CACHE_KEY), 'discord', 'https://pterodactyl.io/discord');
74+
return Arr::get(self::$result, 'discord') ?? 'https://pterodactyl.io/discord';
75+
}
76+
77+
/**
78+
* Get the URL for donations.
79+
*
80+
* @return string
81+
*/
82+
public function getDonations()
83+
{
84+
return Arr::get(self::$result, 'donations') ?? 'https://paypal.me/PterodactylSoftware';
8685
}
8786

8887
/**
@@ -92,11 +91,11 @@ public function getDiscord()
9291
*/
9392
public function isLatestPanel()
9493
{
95-
if ($this->config->get('app.version') === 'canary') {
94+
if (config()->get('app.version') === 'canary') {
9695
return true;
9796
}
9897

99-
return version_compare($this->config->get('app.version'), $this->getPanel()) >= 0;
98+
return version_compare(config()->get('app.version'), $this->getPanel()) >= 0;
10099
}
101100

102101
/**
@@ -116,20 +115,22 @@ public function isLatestDaemon($version)
116115

117116
/**
118117
* Keeps the versioning cache up-to-date with the latest results from the CDN.
118+
*
119+
* @return array
119120
*/
120121
protected function cacheVersionData()
121122
{
122-
$this->cache->remember(self::VERSION_CACHE_KEY, Chronos::now()->addMinutes(config('pterodactyl.cdn.cache_time')), function () {
123+
return $this->cache->remember(self::VERSION_CACHE_KEY, Chronos::now()->addMinutes(config()->get('pterodactyl.cdn.cache_time', 60)), function () {
123124
try {
124-
$response = $this->client->request('GET', $this->config->get('pterodactyl.cdn.url'));
125+
$response = $this->client->request('GET', config()->get('pterodactyl.cdn.url'));
125126

126127
if ($response->getStatusCode() === 200) {
127-
return json_decode($response->getBody());
128+
return json_decode($response->getBody(), true);
128129
}
129130

130131
throw new CdnVersionFetchingException;
131132
} catch (Exception $exception) {
132-
return new stdClass();
133+
return [];
133134
}
134135
});
135136
}

resources/views/admin/index.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@
4545
<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>
4646
</div>
4747
<div class="col-xs-6 col-sm-3 text-center">
48-
<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>
48+
<a href="https://pterodactyl.io"><button class="btn btn-primary" style="width:100%;"><i class="fa fa-fw fa-link"></i> Documentation</button></a>
4949
</div>
5050
<div class="clearfix visible-xs-block">&nbsp;</div>
5151
<div class="col-xs-6 col-sm-3 text-center">
52-
<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>
52+
<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>
5353
</div>
5454
<div class="col-xs-6 col-sm-3 text-center">
55-
<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>
55+
<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>
5656
</div>
5757
</div>
5858
@endsection

0 commit comments

Comments
 (0)