merge to v0.8.2

This commit is contained in:
ok236449 2022-08-19 19:37:37 +02:00
commit 67ab374f07
25 changed files with 126 additions and 39 deletions

View file

@ -44,8 +44,17 @@ public function checkPteroClientkey(){
"pterodactyl-url" => "required|string",
"per-page-limit" => "required|min:0|integer",
"pterodactyl-admin-api-key" => "required|string",
"enable-upgrades" => "string",
]);
$validator->after(function ($validator) use ($request) {
// if enable-recaptcha is true then recaptcha-site-key and recaptcha-secret-key must be set
if ($request->get('enable-upgrades') == 'true' && (!$request->get('pterodactyl-admin-api-key'))) {
$validator->errors()->add('pterodactyl-admin-api-key', 'The admin api key is required when upgrades are enabled.');
}
});
if ($validator->fails()) {
return redirect(route('admin.settings.index') . '#system')->with('error', __('System settings have not been updated!'))->withErrors($validator)
->withInput();
@ -75,6 +84,7 @@ public function checkPteroClientkey(){
"SETTINGS::SYSTEM:PTERODACTYL:TOKEN" => "pterodactyl-api-key",
"SETTINGS::SYSTEM:ENABLE_LOGIN_LOGO" => "enable-login-logo",
"SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN" => "pterodactyl-admin-api-key",
"SETTINGS::SYSTEM:ENABLE_UPGRADE" => "enable-upgrade",
];

View file

@ -3,9 +3,12 @@
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
class LoginController extends Controller
{
@ -66,6 +69,9 @@ class LoginController extends Controller
}
if ($this->attemptLogin($request)) {
$user = Auth::user();
$user->last_seen = now();
$user->save();
return $this->sendLoginResponse($request);
}

View file

@ -268,7 +268,7 @@ class ServerController extends Controller
$serverAttributes = Pterodactyl::getServerAttributes($server->pterodactyl_id);
$serverRelationships = $serverAttributes['relationships'];
// Get node resource allocation info
// Get node resource allocation info
$nodeId = $serverRelationships['node']['attributes']['id'];
$node = Node::where('id', $nodeId)->firstOrFail();
$nodeName = $node->name;
@ -284,7 +284,7 @@ class ServerController extends Controller
if ($priceupgrade < $oldProduct->getHourlyPrice()) {
$priceupgrade = 0;
}
if ($user->credits >= $priceupgrade)
if ($user->credits >= $priceupgrade && $user->credits >= $newProduct->minimum_credits)
{
$server->product_id = $request->product_upgrade;

View file

@ -107,12 +107,30 @@ class AppServiceProvider extends ServiceProvider
Artisan::call('cache:clear');
}
try {
$stringfromfile = file(base_path().'/.git/HEAD');
$firstLine = $stringfromfile[0]; //get the string from the array
$explodedstring = explode("/", $firstLine, 3); //seperate out by the "/" in the string
$branchname = $explodedstring[2]; //get the one that is always the branch name
} catch (Exception $e) {
$branchname = "unknown";
Log::error($e);
}
config(['BRANCHNAME' => $branchname]);
// Set Discord-API Config
config(['services.discord.client_id' => config('SETTINGS::DISCORD:CLIENT_ID')]);
config(['services.discord.client_secret' => config('SETTINGS::DISCORD:CLIENT_SECRET')]);
} catch (Exception $e) {
error_log("Settings Error: Could not load settings from database");
Log::error("Settings Error: Could not load settings from database");
error_log("Settings Error: Could not load settings from database. The Installation probably is not done yet.");
error_log($e);
Log::error("Settings Error: Could not load settings from database. The Installation probably is not done yet.");
Log::error($e);
}
}
}

View file

@ -4,7 +4,7 @@ use App\Models\Settings;
return [
'version' => '0.8.1',
'version' => '0.8.2',
/*
|--------------------------------------------------------------------------

View file

@ -515,5 +515,12 @@ class SettingsSeeder extends Seeder
'type' => 'string',
'description' => 'The Client API Key of an Pterodactyl Admin Account'
]);
Settings::firstOrCreate([
'key' => 'SETTINGS::SYSTEM:ENABLE_UPGRADE',
], [
'value' =>"",
'type' => 'string',
'description' => 'Enables the updgrade/downgrade feature for servers'
]);
}
}

View file

@ -65,7 +65,7 @@
document.addEventListener("DOMContentLoaded", function () {
$('#datatable').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: true,

View file

@ -75,7 +75,7 @@ THIS FILE IS DEPRECATED
document.addEventListener("DOMContentLoaded", function () {
$('#datatable').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: true,

View file

@ -75,7 +75,7 @@ THIS FILE IS DEPRECATED
document.addEventListener("DOMContentLoaded", function () {
$('#datatable').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: true,

View file

@ -142,6 +142,21 @@
<span><i class="fas fa-sync mr-2"></i>{{__('Last updated :date', ['date' => $syncLastUpdate])}}</span>
</div>
</div>
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="card-title ">
<span><i class="fas fa-server mr-2"></i>{{__('Controlpanel.gg')}}</span>
</div>
</div>
<div class="card-body py-1">
</div>
<div class="card-footer">
<span><i class="fas fa-info mr-2"></i>{{__("Version")}} {{config("app.version")}} - {{config("BRANCHNAME")}}</span>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">

View file

@ -66,7 +66,7 @@
document.addEventListener("DOMContentLoaded", function() {
$('#datatable').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: true,

View file

@ -78,7 +78,7 @@
document.addEventListener("DOMContentLoaded", function () {
$("#datatable").DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: true,

View file

@ -23,7 +23,7 @@
document.addEventListener("DOMContentLoaded", function () {
$('#datatable').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: true,

View file

@ -102,6 +102,11 @@
<input x-model="pterodactyl-admin-api-key" id="pterodactyl-admin-api-key" name="pterodactyl-admin-api-key"
type="text" value="{{ config('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN') }}"
class="form-control @error('pterodactyl-admin-api-key') is-invalid @enderror" required>
@error('pterodactyl-admin-api-key')
<div class="text-danger">
{{$message}}
</div>
@enderror
</div>
<a href="{{route('admin.settings.checkPteroClientkey')}}"> <button type="button" class="btn btn-secondary">{{__("Test API")}}</button></a>
</div>
@ -189,6 +194,21 @@
<h1>{{ __('Server') }}</h1>
</div>
</div>
<div class="form-group">
<div class="custom-control mb-1 p-0">
<div class="col m-0 p-0 d-flex justify-content-between align-items-center">
<div>
<input value="true" id="enable-upgrade" name="enable-upgrade"
{{ config('SETTINGS::SYSTEM:ENABLE_UPGRADE') == 'true' ? 'checked' : '' }}
type="checkbox">
<label for="enable-upgrade">{{ __('Enable upgrade/downgrade of servers') }} </label>
</div>
<i data-toggle="popover" data-trigger="hover" data-html="true"
data-content="{{ __('Allow upgrade/downgrade to a new product for the given server') }}"
class="fas fa-info-circle"></i>
</div>
</div>
</div>
<div class="form-group">
<div class="custom-control mb-3 p-0">
<div class="col m-0 p-0 d-flex justify-content-between align-items-center">
@ -202,6 +222,8 @@
class="form-control @error('allocation-limit') is-invalid @enderror" required>
</div>
</div>
</div>
{{-- Design --}}

View file

@ -67,7 +67,7 @@
document.addEventListener("DOMContentLoaded", function () {
$('#datatable').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: true,

View file

@ -74,7 +74,7 @@
document.addEventListener("DOMContentLoaded", function () {
$('#datatable').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: false, //increases loading times too much? change back to "true" if it does

View file

@ -70,7 +70,7 @@
document.addEventListener("DOMContentLoaded", function () {
$('#datatable').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: true,

View file

@ -63,7 +63,7 @@
document.addEventListener("DOMContentLoaded", function() {
$('#datatable').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: true,

View file

@ -403,8 +403,10 @@
<strong>Copyright &copy; 2021-{{ date('Y') }} <a
href="{{ url('/') }}">{{ env('APP_NAME', 'Laravel') }}</a>.</strong>
All rights
reserved. Powered by <a href="https://controlpanel.gg">ControlPanel</a>. Version
<b>{{ config('app')['version'] }}</b>
reserved. Powered by <a href="https://controlpanel.gg">ControlPanel</a>.
@if(!str_contains(config("BRANCHNAME"),"main"))
Version <b>{{ config('app')['version'] }} - {{config("BRANCHNAME")}}</b>
@endif
</footer>
<!-- Control Sidebar -->

View file

@ -90,7 +90,7 @@
document.addEventListener("DOMContentLoaded", function () {
$('#datatable').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: true,

View file

@ -48,10 +48,10 @@
<tbody>
</tbody>
</table>
</div>
</div>
</div>
@ -63,7 +63,7 @@
document.addEventListener("DOMContentLoaded", function () {
$('#datatable').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: true,

View file

@ -51,6 +51,11 @@
@endif
</p>
<p><b>Created on:</b> {{ $ticket->created_at->diffForHumans() }}</p>
<form class="d-inline" method="post" action="{{route('moderator.ticket.close', ['ticket_id' => $ticket->ticket_id ])}}">
{{csrf_field()}}
{{method_field("POST") }}
<button data-content="{{__("Close")}}" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-times"></i>{{__("Close")}}</button>
</form>
</div>
</div>
</div>

View file

@ -221,16 +221,14 @@
<div class="card-footer">
<div class="col-md-12 text-center">
<!-- Upgrade Button trigger modal -->
@if(!config("SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN") and Auth::user()->role=="admin")
<i data-toggle="popover" data-trigger="hover"
data-content="{{ __('To enable the upgrade/downgrade system, please set your Ptero Admin-User API Key in the Settings!') }}"
class="fas fa-info-circle"></i>
@endif
<button type="button" data-toggle="modal" @if(!config("SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN")) disabled @endif data-target="#UpgradeModal{{ $server->id }}" target="__blank"
class="btn btn-info btn-md">
<i class="fas fa-upload mr-2"></i>
<span>{{ __('Upgrade / Downgrade') }}</span>
</button>
@if(config("SETTINGS::SYSTEM:ENABLE_UPGRADE"))
<button type="button" data-toggle="modal" data-target="#UpgradeModal{{ $server->id }}" target="__blank"
class="btn btn-info btn-md">
<i class="fas fa-upload mr-2"></i>
<span>{{ __('Upgrade / Downgrade') }}</span>
</button>
<!-- Upgrade Modal -->
@ -256,8 +254,9 @@
<select name="product_upgrade" id="product_upgrade" class="form-input2 form-control">
<option value="">{{__("Select the product")}}</option>
@foreach($products as $product)
@if(in_array($server->egg, $product->eggs) && $product->id != $server->product->id)
<option value="{{ $product->id }}">{{ $product->name }} [ {{ CREDITS_DISPLAY_NAME }} {{ $product->price }} ]</option>
@if(in_array($server->egg, $product->eggs) && $product->id != $server->product->id && $product->disabled == false)
<option value="{{ $product->id }}">{{ $product->name }} [ {{ CREDITS_DISPLAY_NAME }} {{ $product->price }} @if($product->minimum_credits!=-1) /
{{__("Required")}}: {{$product->minimum_credits}} {{ CREDITS_DISPLAY_NAME }}@endif ]</option>
@endif
@endforeach
</select>
@ -271,6 +270,7 @@
</div>
</div>
</div>
@endif
<!-- Delete Button trigger modal -->
<button type="button" data-toggle="modal" data-target="#DeleteModal" target="__blank"
class="btn btn-danger btn-md">
@ -313,12 +313,12 @@
</section>
<!-- END CONTENT -->
<script type="text/javascript">
$(".upgrade-form").submit(function (e) {
$(".upgrade-once").attr("disabled", true);
$(".upgrade-form").submit(function (e) {
$(".upgrade-once").attr("disabled", true);
return true;
})
</script>
@endsection

View file

@ -75,7 +75,7 @@
document.addEventListener("DOMContentLoaded", function () {
$('#datatable').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: true,

View file

@ -64,7 +64,9 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
Route::get('notifications/readAll',[NotificationController::class,'readAll'])->name('notifications.readAll');
Route::resource('notifications', NotificationController::class);
Route::resource('servers', ServerController::class);
Route::post('servers/{server}/upgrade', [ServerController::class,'upgrade'])->name('servers.upgrade');
if(config('SETTINGS::SYSTEM:ENABLE_UPGRADE')){
Route::post('servers/{server}/upgrade', [ServerController::class,'upgrade'])->name('servers.upgrade');
}
Route::resource('profile', ProfileController::class);
Route::resource('store', StoreController::class);