Dev no encrypt in DEV
This commit is contained in:
commit
66039d1739
|
@ -1,5 +1,5 @@
|
|||
### --- App Settings --- ###
|
||||
APP_NAME=Controlpanel.gg
|
||||
APP_NAME=CtrlPanel.gg
|
||||
APP_ENV=production
|
||||
APP_KEY=
|
||||
APP_DEBUG=false
|
||||
|
@ -64,4 +64,4 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
|||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
# Settings Cache
|
||||
SETTINGS_CACHE_ENABLED=true
|
||||
SETTINGS_CACHE_ENABLED=true
|
||||
|
|
2
.github/ISSUE_TEMPLATE/config.yml
vendored
2
.github/ISSUE_TEMPLATE/config.yml
vendored
|
@ -5,4 +5,4 @@ contact_links:
|
|||
about: Please visit our Discord for help with your installation.
|
||||
- name: ❓ General Question
|
||||
url: https://discord.gg/4Y6HjD2uyU
|
||||
about: Please visit our Discord for general questions about the ControlPanel.
|
||||
about: Please visit our Discord for general questions about the CtrlPanel.
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2021 ControlPanel.gg
|
||||
Copyright (c) 2021 CtrlPanel.gg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
10
README.md
10
README.md
|
@ -17,19 +17,19 @@
|
|||
- Theme Support
|
||||
- and so much more!
|
||||
|
||||
# ControlPanel-gg
|
||||
# CtrlPanel-gg
|
||||
|
||||
![controlpanel](https://user-images.githubusercontent.com/67899387/214684708-739c1d21-06e8-4dec-a4f1-81533a46cc7e.png)
|
||||
![ctrlpanel](https://user-images.githubusercontent.com/67899387/214684708-739c1d21-06e8-4dec-a4f1-81533a46cc7e.png)
|
||||
|
||||
|
||||
![](https://img.shields.io/endpoint?label=v0.9%20Installations&url=https%3A%2F%2Fmarket.ctrlpanel.gg%2Fcallhome.php%3Fgetinstalls)
|
||||
![](https://img.shields.io/badge/Overall%20Installations-5000%2B-green)
|
||||
![](https://img.shields.io/github/stars/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/forks/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/tag/ControlPanel-gg/dashboard) [![Crowdin](https://badges.crowdin.net/controlpanelgg/localized.svg)](https://crowdin.com/project/controlpanelgg) ![](https://img.shields.io/github/issues/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/license/ControlPanel-gg/dashboard) ![](https://img.shields.io/discord/787829714483019826)
|
||||
![](https://img.shields.io/github/stars/ctrlpanel-gg/dashboard) ![](https://img.shields.io/github/forks/ctrlpanel-gg/panel) ![](https://img.shields.io/github/tag/ctrlpanel-gg/panel) [![Crowdin](https://badges.crowdin.com/project/controlpanelgg/localized.svg)](https://crowdin.com/project/controlpanelgg) ![](https://img.shields.io/github/issues/ctrlpanel-gg/panel) ![](https://img.shields.io/github/license/ctrlpanel-gg/panel) ![](https://img.shields.io/discord/787829714483019826)
|
||||
## About
|
||||
|
||||
ControlPanel's Dashboard is a dashboard application designed to offer clients a management tool to manage their pterodactyl servers. This dashboard comes with a credit-based billing solution that credits users hourly for each server they have and suspends them if they run out of credits.
|
||||
CtrlPanel's Dashboard is a dashboard application designed to offer clients a management tool to manage their pterodactyl servers. This dashboard comes with a credit-based billing solution that credits users hourly for each server they have and suspends them if they run out of credits.
|
||||
|
||||
This dashboard offers an easy to use and free billing solution for all starting and experienced hosting providers. This dashboard has many customisation options and added discord Oauth verification to offer a solid link between your discord server and your dashboard. You can check our [Demo here](https://demo.controlpanel.gg "Demo").
|
||||
This dashboard offers an easy to use and free billing solution for all starting and experienced hosting providers. This dashboard has many customisation options and added discord Oauth verification to offer a solid link between your discord server and your dashboard. You can check our [Demo here](https://demo.CtrlPanel.gg "Demo").
|
||||
|
||||
### [Installation](https://ctrlpanel.gg/docs/intro "Installation")
|
||||
|
||||
|
|
|
@ -266,6 +266,7 @@ class PterodactylClient
|
|||
'docker_image' => $egg->docker_image,
|
||||
'startup' => $egg->startup,
|
||||
'environment' => $egg->getEnvironmentVariables(),
|
||||
'oom_disabled' => !$server->product->oom_killer,
|
||||
'limits' => [
|
||||
'memory' => $server->product->memory,
|
||||
'swap' => $server->product->swap,
|
||||
|
@ -378,6 +379,7 @@ class PterodactylClient
|
|||
'io' => $product->io,
|
||||
'cpu' => $product->cpu,
|
||||
'threads' => null,
|
||||
'oom_disabled' => !$server->product->oom_killer,
|
||||
'feature_limits' => [
|
||||
'databases' => $product->databases,
|
||||
'backups' => $product->backups,
|
||||
|
|
|
@ -32,7 +32,7 @@ class GetGithubVersion extends Command
|
|||
public function handle()
|
||||
{
|
||||
try{
|
||||
$latestVersion = Http::get('https://api.github.com/repos/controlpanel-gg/dashboard/tags')->json()[0]['name'];
|
||||
$latestVersion = Http::get('https://api.github.com/repos/ctrlpanel-gg/panel/tags')->json()[0]['name'];
|
||||
Storage::disk('local')->put('latestVersion', $latestVersion);
|
||||
} catch (Exception $e) {
|
||||
Storage::disk('local')->put('latestVersion', "unknown");
|
||||
|
|
|
@ -101,6 +101,8 @@ class MakeUserCommand extends Command
|
|||
['Referral code', $user->referral_code],
|
||||
]);
|
||||
|
||||
$user->syncRoles(1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,12 +15,7 @@ class MollieSettings extends Settings
|
|||
return 'mollie';
|
||||
}
|
||||
|
||||
public static function encrypted(): array
|
||||
{
|
||||
return [
|
||||
'api_key',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public static function getOptionInputData()
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ class CreateMollieSettings extends SettingsMigration
|
|||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->migrator->addEncrypted('mollie.api_key', null);
|
||||
$this->migrator->add('mollie.api_key', null);
|
||||
$this->migrator->add('mollie.enabled', false);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ class PayPalExtension extends AbstractExtension
|
|||
"application_context" => [
|
||||
"cancel_url" => route('payment.Cancel'),
|
||||
"return_url" => route('payment.PayPalSuccess', ['payment' => $payment->id]),
|
||||
'brand_name' => config('app.name', 'Controlpanel.GG'),
|
||||
'brand_name' => config('app.name', 'CtrlPanel.GG'),
|
||||
'shipping_preference' => 'NO_SHIPPING'
|
||||
]
|
||||
|
||||
|
|
|
@ -18,15 +18,7 @@ class PayPalSettings extends Settings
|
|||
}
|
||||
|
||||
|
||||
public static function encrypted(): array
|
||||
{
|
||||
return [
|
||||
'client_id',
|
||||
'client_secret',
|
||||
'sandbox_client_id',
|
||||
'sandbox_client_secret'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of optionInputData array
|
||||
|
|
|
@ -11,10 +11,10 @@ class CreatePayPalSettings extends SettingsMigration
|
|||
$table_exists = DB::table('settings_old')->exists();
|
||||
|
||||
|
||||
$this->migrator->addEncrypted('paypal.client_id', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID') : null);
|
||||
$this->migrator->addEncrypted('paypal.client_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SECRET') : null);
|
||||
$this->migrator->addEncrypted('paypal.sandbox_client_id', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID') : null);
|
||||
$this->migrator->addEncrypted('paypal.sandbox_client_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET') : null);
|
||||
$this->migrator->add('paypal.client_id', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID') : null);
|
||||
$this->migrator->add('paypal.client_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SECRET') : null);
|
||||
$this->migrator->add('paypal.sandbox_client_id', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID') : null);
|
||||
$this->migrator->add('paypal.sandbox_client_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET') : null);
|
||||
$this->migrator->add('paypal.enabled', false);
|
||||
}
|
||||
|
||||
|
@ -77,6 +77,10 @@ class CreatePayPalSettings extends SettingsMigration
|
|||
// Always get the first value of the key.
|
||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||
|
||||
if (is_null($old_value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Handle the old values to return without it being a string in all cases.
|
||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||
if (is_null($old_value->value)) {
|
||||
|
|
|
@ -19,15 +19,7 @@ class StripeSettings extends Settings
|
|||
return 'stripe';
|
||||
}
|
||||
|
||||
public static function encrypted(): array
|
||||
{
|
||||
return [
|
||||
"secret_key",
|
||||
"endpoint_secret",
|
||||
"test_secret_key",
|
||||
"test_endpoint_secret"
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public static function getOptionInputData()
|
||||
{
|
||||
|
|
|
@ -9,10 +9,10 @@ class CreateStripeSettings extends SettingsMigration
|
|||
{
|
||||
$table_exists = DB::table('settings_old')->exists();
|
||||
|
||||
$this->migrator->addEncrypted('stripe.secret_key', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:SECRET') : null);
|
||||
$this->migrator->addEncrypted('stripe.endpoint_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') : null);
|
||||
$this->migrator->addEncrypted('stripe.test_secret_key', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:TEST_SECRET') : null);
|
||||
$this->migrator->addEncrypted('stripe.test_endpoint_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET') : null);
|
||||
$this->migrator->add('stripe.secret_key', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:SECRET') : null);
|
||||
$this->migrator->add('stripe.endpoint_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') : null);
|
||||
$this->migrator->add('stripe.test_secret_key', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:TEST_SECRET') : null);
|
||||
$this->migrator->add('stripe.test_endpoint_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET') : null);
|
||||
$this->migrator->add('stripe.enabled', false);
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,10 @@ class CreateStripeSettings extends SettingsMigration
|
|||
// Always get the first value of the key.
|
||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||
|
||||
if (is_null($old_value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Handle the old values to return without it being a string in all cases.
|
||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||
if (is_null($old_value->value)) {
|
||||
|
|
|
@ -18,8 +18,9 @@ class ExtensionHelper
|
|||
foreach ($extensionNamespaces as $extensionNamespace) {
|
||||
$extensions = array_merge($extensions, glob($extensionNamespace . '/*', GLOB_ONLYDIR));
|
||||
}
|
||||
|
||||
// remove base path from every extension but keep app/Extensions/...
|
||||
$extensions = array_map(fn ($item) => str_replace('/', '\\', str_replace(app_path() . '/', 'App/', $item)), $extensions);
|
||||
$extensions = array_map(fn ($item) => str_replace(app_path() . '/', 'App/', $item), $extensions);
|
||||
|
||||
return $extensions;
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ class ExtensionHelper
|
|||
{
|
||||
$extensions = glob(app_path() . '/Extensions/' . $namespace . '/*', GLOB_ONLYDIR);
|
||||
// remove base path from every extension but keep app/Extensions/...
|
||||
$extensions = array_map(fn ($item) => str_replace('/', '\\', str_replace(app_path() . '/', 'App/', $item)), $extensions);
|
||||
$extensions = array_map(fn ($item) => str_replace(app_path() . '/', 'App/', $item), $extensions);
|
||||
|
||||
return $extensions;
|
||||
}
|
||||
|
@ -60,7 +61,10 @@ class ExtensionHelper
|
|||
public static function getAllExtensionClasses()
|
||||
{
|
||||
$extensions = self::getAllExtensions();
|
||||
// add the ExtensionClass to the end of the namespace
|
||||
|
||||
// replace all slashes with backslashes
|
||||
$extensions = array_map(fn ($item) => str_replace('/', '\\', $item), $extensions);
|
||||
// add the ExtensionClass to the end of the namespace
|
||||
$extensions = array_map(fn ($item) => $item . '\\' . basename($item) . 'Extension', $extensions);
|
||||
// filter out non existing extension classes
|
||||
$extensions = array_filter($extensions, fn ($item) => class_exists($item));
|
||||
|
@ -76,6 +80,9 @@ class ExtensionHelper
|
|||
public static function getAllExtensionClassesByNamespace(string $namespace)
|
||||
{
|
||||
$extensions = self::getAllExtensionsByNamespace($namespace);
|
||||
|
||||
// replace all slashes with backslashes
|
||||
$extensions = array_map(fn ($item) => str_replace('/', '\\', $item), $extensions);
|
||||
// add the ExtensionClass to the end of the namespace
|
||||
$extensions = array_map(fn ($item) => $item . '\\' . basename($item) . 'Extension', $extensions);
|
||||
// filter out non existing extension classes
|
||||
|
@ -97,7 +104,7 @@ class ExtensionHelper
|
|||
if (!(basename($extension) == $extensionName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$extension = str_replace('/', '\\', $extension);
|
||||
$extensionClass = $extension . '\\' . $extensionName . 'Extension';
|
||||
return $extensionClass;
|
||||
}
|
||||
|
@ -177,10 +184,13 @@ class ExtensionHelper
|
|||
{
|
||||
$extensions = self::getAllExtensions();
|
||||
|
||||
|
||||
$settings = [];
|
||||
foreach ($extensions as $extension) {
|
||||
|
||||
$extensionName = basename($extension);
|
||||
|
||||
// replace all slashes with backslashes
|
||||
$extension = str_replace('/', '\\', $extension);
|
||||
$settingsClass = $extension . '\\' . $extensionName . 'Settings';
|
||||
if (class_exists($settingsClass)) {
|
||||
$settings[] = $settingsClass;
|
||||
|
@ -193,6 +203,9 @@ class ExtensionHelper
|
|||
public static function getExtensionSettings(string $extensionName)
|
||||
{
|
||||
$extension = self::getExtension($extensionName);
|
||||
// replace all slashes with backslashes
|
||||
$extension = str_replace('/', '\\', $extension);
|
||||
|
||||
$settingClass = $extension . '\\' . $extensionName . 'Settings';
|
||||
|
||||
if (class_exists($settingClass)) {
|
||||
|
@ -207,6 +220,6 @@ class ExtensionHelper
|
|||
*/
|
||||
private static function extensionNameToPath(string $extensionName)
|
||||
{
|
||||
return app_path() . '/' . str_replace('\\', '/', str_replace('App\\', '', $extensionName));
|
||||
return app_path() . '/' . str_replace('App/', '', $extensionName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ use Spatie\Activitylog\Models\Activity;
|
|||
|
||||
class ActivityLogController extends Controller
|
||||
{
|
||||
const VIEW_PERMISSION = "admin.logs.read";
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
@ -21,6 +22,9 @@ class ActivityLogController extends Controller
|
|||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->checkPermission(self::VIEW_PERMISSION);
|
||||
|
||||
|
||||
$cronLogs = Storage::disk('logs')->exists('cron.log') ? Storage::disk('logs')->get('cron.log') : null;
|
||||
|
||||
if ($request->input('search')) {
|
||||
|
|
|
@ -16,6 +16,8 @@ use Illuminate\Http\Response;
|
|||
|
||||
class ApplicationApiController extends Controller
|
||||
{
|
||||
const READ_PERMISSION = "admin.api.read";
|
||||
const WRITE_PERMISSION = "admin.api.write";
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
@ -23,6 +25,8 @@ class ApplicationApiController extends Controller
|
|||
*/
|
||||
public function index(LocaleSettings $locale_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
return view('admin.api.index', [
|
||||
'locale_datatables' => $locale_settings->datatables
|
||||
]);
|
||||
|
@ -35,6 +39,8 @@ class ApplicationApiController extends Controller
|
|||
*/
|
||||
public function create()
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
return view('admin.api.create');
|
||||
}
|
||||
|
||||
|
@ -76,6 +82,7 @@ class ApplicationApiController extends Controller
|
|||
*/
|
||||
public function edit(ApplicationApi $applicationApi)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
return view('admin.api.edit', [
|
||||
'applicationApi' => $applicationApi,
|
||||
]);
|
||||
|
@ -107,6 +114,8 @@ class ApplicationApiController extends Controller
|
|||
*/
|
||||
public function destroy(ApplicationApi $applicationApi)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
$applicationApi->delete();
|
||||
|
||||
return redirect()->back()->with('success', __('api key has been removed!'));
|
||||
|
|
|
@ -10,6 +10,8 @@ use Qirolab\Theme\Theme;
|
|||
|
||||
class LegalController extends Controller
|
||||
{
|
||||
const READ_PERMISSION = "admin.legal.read";
|
||||
const WRITE_PERMISSION = "admin.legal.write";
|
||||
/**
|
||||
* Display
|
||||
*
|
||||
|
@ -17,6 +19,8 @@ class LegalController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
$tos = File::get(Theme::path($path = 'views', "default") . '/information/tos-content.blade.php');
|
||||
$privacy = File::get(Theme::path($path = 'views', "default") . '/information/privacy-content.blade.php');
|
||||
$imprint = File::get(Theme::path($path = 'views', "default") . '/information/imprint-content.blade.php');
|
||||
|
@ -29,6 +33,8 @@ class LegalController extends Controller
|
|||
}
|
||||
|
||||
public function update(Request $request){
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
$tos = $request->tos;
|
||||
$privacy = $request->privacy;
|
||||
$imprint = $request->imprint;
|
||||
|
|
|
@ -19,6 +19,8 @@ use Carbon\Carbon;
|
|||
|
||||
class OverViewController extends Controller
|
||||
{
|
||||
const READ_PERMISSION = "admin.overview.read";
|
||||
const SYNC_PERMISSION = "admin.overview.sync";
|
||||
public const TTL = 86400;
|
||||
|
||||
private $pterodactyl;
|
||||
|
@ -27,9 +29,11 @@ class OverViewController extends Controller
|
|||
{
|
||||
$this->pterodactyl = new PterodactylClient($ptero_settings);
|
||||
}
|
||||
|
||||
|
||||
public function index(GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
//Get counters
|
||||
$counters = collect();
|
||||
//Set basic variables in the collection
|
||||
|
@ -225,6 +229,8 @@ class OverViewController extends Controller
|
|||
*/
|
||||
public function syncPterodactyl()
|
||||
{
|
||||
$this->checkPermission(self::SYNC_PERMISSION);
|
||||
|
||||
Node::syncNodes();
|
||||
Egg::syncEggs();
|
||||
|
||||
|
|
|
@ -11,8 +11,12 @@ use Illuminate\Http\Request;
|
|||
|
||||
class PartnerController extends Controller
|
||||
{
|
||||
const READ_PERMISSION = "admin.partners.read";
|
||||
const WRITE_PERMISSION = "admin.partners.write";
|
||||
public function index(LocaleSettings $locale_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
return view('admin.partners.index', [
|
||||
'locale_datatables' => $locale_settings->datatables
|
||||
]);
|
||||
|
@ -25,6 +29,8 @@ class PartnerController extends Controller
|
|||
*/
|
||||
public function create()
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
return view('admin.partners.create', [
|
||||
'partners' => PartnerDiscount::get(),
|
||||
'users' => User::orderBy('name')->get(),
|
||||
|
@ -62,6 +68,8 @@ class PartnerController extends Controller
|
|||
*/
|
||||
public function edit(PartnerDiscount $partner)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
return view('admin.partners.edit', [
|
||||
'partners' => PartnerDiscount::get(),
|
||||
'partner' => $partner,
|
||||
|
@ -98,6 +106,8 @@ class PartnerController extends Controller
|
|||
*/
|
||||
public function destroy(PartnerDiscount $partner)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
$partner->delete();
|
||||
|
||||
return redirect()->back()->with('success', __('partner has been removed!'));
|
||||
|
|
|
@ -23,11 +23,16 @@ use App\Settings\LocaleSettings;
|
|||
|
||||
class PaymentController extends Controller
|
||||
{
|
||||
const BUY_PERMISSION = 'user.shop.buy';
|
||||
const VIEW_PERMISSION = "admin.payments.read";
|
||||
/**
|
||||
* @return Application|Factory|View
|
||||
*/
|
||||
public function index(LocaleSettings $locale_settings)
|
||||
{
|
||||
$this->checkPermission(self::VIEW_PERMISSION);
|
||||
|
||||
|
||||
return view('admin.payments.index')->with([
|
||||
'payments' => Payment::paginate(15),
|
||||
'locale_datatables' => $locale_settings->datatables
|
||||
|
@ -41,6 +46,8 @@ class PaymentController extends Controller
|
|||
*/
|
||||
public function checkOut(ShopProduct $shopProduct, GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::BUY_PERMISSION);
|
||||
|
||||
$discount = PartnerDiscount::getDiscount();
|
||||
$price = $shopProduct->price - ($shopProduct->price * $discount / 100);
|
||||
|
||||
|
|
|
@ -19,6 +19,10 @@ use Illuminate\Http\Request;
|
|||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
const READ_PERMISSION = "admin.products.read";
|
||||
const WRITE_PERMISSION = "admin.products.write";
|
||||
const EDIT_PERMISSION = "admin.products.edit";
|
||||
const DELETE_PERMISSION = "admin.products.delete";
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
@ -26,6 +30,8 @@ class ProductController extends Controller
|
|||
*/
|
||||
public function index(LocaleSettings $locale_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
return view('admin.products.index', [
|
||||
'locale_datatables' => $locale_settings->datatables
|
||||
]);
|
||||
|
@ -38,6 +44,7 @@ class ProductController extends Controller
|
|||
*/
|
||||
public function create(GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
return view('admin.products.create', [
|
||||
'locations' => Location::with('nodes')->get(),
|
||||
'nests' => Nest::with('eggs')->get(),
|
||||
|
@ -47,6 +54,8 @@ class ProductController extends Controller
|
|||
|
||||
public function clone(Product $product)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
return view('admin.products.create', [
|
||||
'product' => $product,
|
||||
'locations' => Location::with('nodes')->get(),
|
||||
|
@ -78,6 +87,7 @@ class ProductController extends Controller
|
|||
'nodes.*' => 'required|exists:nodes,id',
|
||||
'eggs.*' => 'required|exists:eggs,id',
|
||||
'disabled' => 'nullable',
|
||||
'oom_killer' => 'nullable',
|
||||
]);
|
||||
|
||||
$disabled = ! is_null($request->input('disabled'));
|
||||
|
@ -98,6 +108,8 @@ class ProductController extends Controller
|
|||
*/
|
||||
public function show(Product $product, UserSettings $user_settings, GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
return view('admin.products.show', [
|
||||
'product' => $product,
|
||||
'minimum_credits' => $user_settings->min_credits_to_make_server,
|
||||
|
@ -113,6 +125,8 @@ class ProductController extends Controller
|
|||
*/
|
||||
public function edit(Product $product, GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::EDIT_PERMISSION);
|
||||
|
||||
return view('admin.products.edit', [
|
||||
'product' => $product,
|
||||
'locations' => Location::with('nodes')->get(),
|
||||
|
@ -146,6 +160,7 @@ class ProductController extends Controller
|
|||
'nodes.*' => 'required|exists:nodes,id',
|
||||
'eggs.*' => 'required|exists:eggs,id',
|
||||
'disabled' => 'nullable',
|
||||
'oom_killer' => 'nullable',
|
||||
]);
|
||||
|
||||
$disabled = ! is_null($request->input('disabled'));
|
||||
|
@ -167,6 +182,8 @@ class ProductController extends Controller
|
|||
*/
|
||||
public function disable(Product $product)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
$product->update(['disabled' => ! $product->disabled]);
|
||||
|
||||
return redirect()->route('admin.products.index')->with('success', 'Product has been updated!');
|
||||
|
@ -180,6 +197,8 @@ class ProductController extends Controller
|
|||
*/
|
||||
public function destroy(Product $product)
|
||||
{
|
||||
$this->checkPermission(self::DELETE_PERMISSION);
|
||||
|
||||
$servers = $product->servers()->count();
|
||||
if ($servers > 0) {
|
||||
return redirect()->back()->with('error', "Product cannot be removed while it's linked to {$servers} servers");
|
||||
|
@ -239,6 +258,9 @@ class ProductController extends Controller
|
|||
->editColumn('minimum_credits', function (Product $product, UserSettings $user_settings) {
|
||||
return $product->minimum_credits==-1 ? $user_settings->min_credits_to_make_server : $product->minimum_credits;
|
||||
})
|
||||
->editColumn('oom_killer', function (Product $product, UserSettings $user_settings) {
|
||||
return $product->oom_killer ? __("enabled") : __("disabled");
|
||||
})
|
||||
->editColumn('created_at', function (Product $product) {
|
||||
return $product->created_at ? $product->created_at->diffForHumans() : '';
|
||||
})
|
||||
|
|
220
app/Http/Controllers/Admin/RoleController.php
Normal file
220
app/Http/Controllers/Admin/RoleController.php
Normal file
|
@ -0,0 +1,220 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class RoleController extends Controller
|
||||
{
|
||||
|
||||
const READ_PERMISSION = "admin.roles.read";
|
||||
const CREATE_PERMISSION = "admin.roles.create";
|
||||
const EDIT_PERMISSION = "admin.roles.edit";
|
||||
const DELETE_PERMISSION = "admin.roles.delete";
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
//datatables
|
||||
if ($request->ajax()) {
|
||||
return $this->dataTableQuery();
|
||||
}
|
||||
|
||||
$html = $this->dataTable();
|
||||
return view('admin.roles.index', compact('html'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Application|Factory|View
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$this->checkPermission(self::CREATE_PERMISSION);
|
||||
|
||||
$permissions = Permission::all();
|
||||
|
||||
return view('admin.roles.edit', compact('permissions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->checkPermission(self::CREATE_PERMISSION);
|
||||
|
||||
$role = Role::create([
|
||||
'name' => $request->name,
|
||||
'color' => $request->color,
|
||||
'power' => $request->power
|
||||
]);
|
||||
|
||||
if ($request->permissions) {
|
||||
$role->givePermissionTo($request->permissions);
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('admin.roles.index')
|
||||
->with('success', __('Role saved'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
abort(404);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param Role $role
|
||||
* @return Application|Factory|View
|
||||
*/
|
||||
public function edit(Role $role)
|
||||
{
|
||||
$this->checkPermission(self::EDIT_PERMISSION);
|
||||
|
||||
if(Auth::user()->roles[0]->power < $role->power){
|
||||
return back()->with("error","You dont have enough Power to edit that Role");
|
||||
}
|
||||
|
||||
$permissions = Permission::all();
|
||||
|
||||
return view('admin.roles.edit', compact('role', 'permissions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Role $role
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function update(Request $request, Role $role)
|
||||
{
|
||||
$this->checkPermission(self::EDIT_PERMISSION);
|
||||
|
||||
if(Auth::user()->roles[0]->power < $role->power){
|
||||
return back()->with("error","You dont have enough Power to edit that Role");
|
||||
}
|
||||
|
||||
if ($request->permissions) {
|
||||
if($role->id != 1){ //disable admin permissions change
|
||||
$role->syncPermissions($request->permissions);
|
||||
}
|
||||
}
|
||||
|
||||
//if($role->id == 1 || $role->id == 3 || $role->id == 4){ //dont let the user change the names of these roles
|
||||
// $role->update([
|
||||
// 'color' => $request->color
|
||||
// ]);
|
||||
//}else{
|
||||
$role->update([
|
||||
'name' => $request->name,
|
||||
'color' => $request->color
|
||||
]);
|
||||
//}
|
||||
|
||||
//if($role->id == 1){
|
||||
// return redirect()->route('admin.roles.index')->with('success', __('Role updated. Name and Permissions of this Role cannot be changed'));
|
||||
//}elseif($role->id == 4 || $role->id == 3){
|
||||
// return redirect()->route('admin.roles.index')->with('success', __('Role updated. Name of this Role cannot be changed'));
|
||||
// }else{
|
||||
return redirect()
|
||||
->route('admin.roles.index')
|
||||
->with('success', __('Role saved'));
|
||||
//}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function destroy(Role $role)
|
||||
{
|
||||
$this->checkPermission(self::DELETE_PERMISSION);
|
||||
|
||||
if($role->id == 1 || $role->id == 3 || $role->id == 4){ //cannot delete the hard coded roles
|
||||
return back()->with("error","You cannot delete that role");
|
||||
}
|
||||
|
||||
$users = User::role($role)->get();
|
||||
|
||||
foreach($users as $user){
|
||||
//$user->syncRoles(['Member']);
|
||||
$user->syncRoles(4);
|
||||
}
|
||||
|
||||
$role->delete();
|
||||
|
||||
return redirect()
|
||||
->route('admin.roles.index')
|
||||
->with('success', __('Role removed'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function dataTable()
|
||||
{
|
||||
$query = Role::query()->withCount(['users', 'permissions']);
|
||||
|
||||
|
||||
return datatables($query)
|
||||
->editColumn('id', function (Role $role) {
|
||||
return $role->id;
|
||||
})
|
||||
->addColumn('actions', function (Role $role) {
|
||||
return '
|
||||
<a title="Edit" href="'.route("admin.roles.edit", $role).'" class="btn btn-sm btn-info"><i
|
||||
class="fa fas fa-edit"></i></a>
|
||||
<form class="d-inline" method="post" action="'.route("admin.roles.destroy", $role).'">
|
||||
' . csrf_field() . '
|
||||
' . method_field("DELETE") . '
|
||||
<button title="Delete" type="submit" class="btn btn-sm btn-danger confirm"><i
|
||||
class="fa fas fa-trash"></i></button>
|
||||
</form>
|
||||
';
|
||||
})
|
||||
|
||||
->editColumn('name', function (Role $role) {
|
||||
return "<span style=\"color: $role->color\">$role->name</span>";
|
||||
})
|
||||
->editColumn('usercount', function ($query) {
|
||||
return $query->users_count;
|
||||
})
|
||||
->editColumn('permissionscount', function ($query){
|
||||
return $query->permissions_count;
|
||||
})
|
||||
->editColumn('power', function (Role $role){
|
||||
return $role->power;
|
||||
})
|
||||
->rawColumns(['actions', 'name'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
|
@ -20,6 +20,13 @@ use Illuminate\Support\Facades\Log;
|
|||
|
||||
class ServerController extends Controller
|
||||
{
|
||||
|
||||
const READ_PERMISSION = "admin.servers.read";
|
||||
const WRITE_PERMISSION = "admin.servers.write";
|
||||
const SUSPEND_PERMISSION = "admin.servers.suspend";
|
||||
const CHANGEOWNER_PERMISSION = "admin.servers.write.owner";
|
||||
const CHANGE_IDENTIFIER_PERMISSION ="admin.servers.write.identifier";
|
||||
const DELETE_PERMISSION = "admin.servers.delete";
|
||||
private $pterodactyl;
|
||||
|
||||
public function __construct(PterodactylSettings $ptero_settings)
|
||||
|
@ -34,6 +41,8 @@ class ServerController extends Controller
|
|||
*/
|
||||
public function index(LocaleSettings $locale_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
return view('admin.servers.index', [
|
||||
'locale_datatables' => $locale_settings->datatables
|
||||
]);
|
||||
|
@ -47,6 +56,8 @@ class ServerController extends Controller
|
|||
*/
|
||||
public function edit(Server $server)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
// get all users from the database
|
||||
$users = User::all();
|
||||
|
||||
|
@ -70,7 +81,7 @@ class ServerController extends Controller
|
|||
]);
|
||||
|
||||
|
||||
if ($request->get('user_id') != $server->user_id) {
|
||||
if ($request->get('user_id') != $server->user_id && $this->can(self::CHANGEOWNER_PERMISSION)) {
|
||||
// find the user
|
||||
$user = User::findOrFail($request->get('user_id'));
|
||||
|
||||
|
@ -89,7 +100,10 @@ class ServerController extends Controller
|
|||
}
|
||||
|
||||
// update the identifier
|
||||
$server->identifier = $request->get('identifier');
|
||||
if($this->can(self::CHANGE_IDENTIFIER_PERMISSION)) {
|
||||
|
||||
$server->identifier = $request->get('identifier');
|
||||
}
|
||||
$server->save();
|
||||
|
||||
return redirect()->route('admin.servers.index')->with('success', 'Server updated!');
|
||||
|
@ -103,6 +117,7 @@ class ServerController extends Controller
|
|||
*/
|
||||
public function destroy(Server $server)
|
||||
{
|
||||
$this->checkPermission(self::DELETE_PERMISSION);
|
||||
try {
|
||||
$server->delete();
|
||||
|
||||
|
@ -118,6 +133,8 @@ class ServerController extends Controller
|
|||
*/
|
||||
public function toggleSuspended(Server $server)
|
||||
{
|
||||
$this->checkPermission(self::SUSPEND_PERMISSION);
|
||||
|
||||
try {
|
||||
$server->isSuspended() ? $server->unSuspend() : $server->suspend();
|
||||
} catch (Exception $exception) {
|
||||
|
|
|
@ -15,6 +15,8 @@ use Qirolab\Theme\Theme;
|
|||
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
@ -23,6 +25,7 @@ class SettingsController extends Controller
|
|||
public function index()
|
||||
{
|
||||
|
||||
|
||||
// get all other settings in app/Settings directory
|
||||
// group items by file name like $categories
|
||||
$settings = collect();
|
||||
|
@ -92,6 +95,9 @@ class SettingsController extends Controller
|
|||
public function update(Request $request)
|
||||
{
|
||||
$category = request()->get('category');
|
||||
|
||||
$this->checkPermission("settings.".strtolower($category).".write");
|
||||
|
||||
$settings_class = request()->get('settings_class');
|
||||
|
||||
if (method_exists($settings_class, 'getValidations')) {
|
||||
|
@ -113,16 +119,20 @@ class SettingsController extends Controller
|
|||
$rp = new \ReflectionProperty($settingsClass, $key);
|
||||
$rpType = $rp->getType();
|
||||
|
||||
|
||||
if ($rpType == 'bool') {
|
||||
$settingsClass->$key = $request->has($key);
|
||||
continue;
|
||||
}
|
||||
if ($rp->name == 'available') {
|
||||
$settingsClass->$key = implode(",",$request->$key);
|
||||
continue;
|
||||
}
|
||||
|
||||
$nullable = $rpType->allowsNull();
|
||||
if ($nullable) $settingsClass->$key = $request->input($key) ?? null;
|
||||
else $settingsClass->$key = $request->input($key);
|
||||
}
|
||||
|
||||
$settingsClass->save();
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ShopProduct;
|
||||
use App\Settings\GeneralSettings;
|
||||
use App\Settings\LocaleSettings;
|
||||
|
@ -11,12 +12,15 @@ use Illuminate\Contracts\View\View;
|
|||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ShopProductController extends Controller
|
||||
{
|
||||
|
||||
const READ_PERMISSION = 'admin.store.read';
|
||||
const WRITE_PERMISSION = 'admin.store.write';
|
||||
const DISABLE_PERMISSION = 'admin.store.disable';
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
@ -24,6 +28,8 @@ class ShopProductController extends Controller
|
|||
*/
|
||||
public function index(LocaleSettings $locale_settings, GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
$isStoreEnabled = $general_settings->store_enabled;
|
||||
|
||||
|
||||
|
@ -40,6 +46,8 @@ class ShopProductController extends Controller
|
|||
*/
|
||||
public function create(GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
return view('admin.store.create', [
|
||||
'currencyCodes' => config('currency_codes'),
|
||||
'credits_display_name' => $general_settings->credits_display_name
|
||||
|
@ -78,6 +86,8 @@ class ShopProductController extends Controller
|
|||
*/
|
||||
public function edit(ShopProduct $shopProduct, GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
return view('admin.store.edit', [
|
||||
'currencyCodes' => config('currency_codes'),
|
||||
'shopProduct' => $shopProduct,
|
||||
|
@ -117,6 +127,8 @@ class ShopProductController extends Controller
|
|||
*/
|
||||
public function disable(ShopProduct $shopProduct)
|
||||
{
|
||||
$this->checkPermission(self::DISABLE_PERMISSION);
|
||||
|
||||
$shopProduct->update(['disabled' => !$shopProduct->disabled]);
|
||||
|
||||
return redirect()->route('admin.store.index')->with('success', __('Product has been updated!'));
|
||||
|
@ -130,6 +142,7 @@ class ShopProductController extends Controller
|
|||
*/
|
||||
public function destroy(ShopProduct $shopProduct)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
$shopProduct->delete();
|
||||
|
||||
return redirect()->back()->with('success', __('Store item has been removed!'));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Moderation;
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Ticket;
|
||||
|
@ -9,15 +9,20 @@ use Illuminate\Http\Request;
|
|||
|
||||
class TicketCategoryController extends Controller
|
||||
{
|
||||
const READ_PERMISSION = "admin.tickets.read";
|
||||
const WRITE_PERMISSION = "admin.tickets.write";
|
||||
/**
|
||||
*
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
$categories = TicketCategory::all();
|
||||
return view('moderator.ticket.category')->with("categories",$categories);
|
||||
return view('admin.ticket.category')->with("categories",$categories);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,6 +33,8 @@ class TicketCategoryController extends Controller
|
|||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:191',
|
||||
]);
|
||||
|
@ -35,7 +42,7 @@ class TicketCategoryController extends Controller
|
|||
TicketCategory::create($request->all());
|
||||
|
||||
|
||||
return redirect(route("moderator.ticket.category.index"))->with("success",__("Category created"));
|
||||
return redirect(route("admin.ticket.category.index"))->with("success",__("Category created"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,6 +53,8 @@ class TicketCategoryController extends Controller
|
|||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
$request->validate([
|
||||
'category' => 'required|int',
|
||||
'name' => 'required|string|max:191',
|
||||
|
@ -68,6 +77,8 @@ class TicketCategoryController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
$category = TicketCategory::where("id",$id)->firstOrFail();
|
||||
|
||||
if($category->id == 5 ){ //cannot delete "other" category
|
||||
|
@ -84,7 +95,7 @@ class TicketCategoryController extends Controller
|
|||
$category->delete();
|
||||
|
||||
return redirect()
|
||||
->route('moderator.ticket.category.index')
|
||||
->route('admin.ticket.category.index')
|
||||
->with('success', __('Category removed'));
|
||||
}
|
||||
|
||||
|
@ -101,7 +112,7 @@ class TicketCategoryController extends Controller
|
|||
})
|
||||
->addColumn('actions', function (TicketCategory $category) {
|
||||
return '
|
||||
<form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('moderator.ticket.category.destroy', $category->id).'">
|
||||
<form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('admin.ticket.category.destroy', $category->id).'">
|
||||
'.csrf_field().'
|
||||
'.method_field('DELETE').'
|
||||
<button data-content="'.__('Delete').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
|
@ -1,8 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Moderation;
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Moderation\Exception;
|
||||
use App\Models\Server;
|
||||
use App\Models\Ticket;
|
||||
use App\Models\TicketBlacklist;
|
||||
|
@ -17,9 +18,16 @@ use Illuminate\Support\Facades\Auth;
|
|||
|
||||
class TicketsController extends Controller
|
||||
{
|
||||
const READ_PERMISSION = "admin.tickets.read";
|
||||
const WRITE_PERMISSION = "admin.tickets.write";
|
||||
|
||||
const BLACKLIST_READ_PERMISSION ='admin.ticket_blacklist.read';
|
||||
const BLACKLIST_WRITE_PERMISSION ='admin.ticket_blacklist.write';
|
||||
public function index(LocaleSettings $locale_settings)
|
||||
{
|
||||
return view('moderator.ticket.index', [
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
return view('admin.ticket.index', [
|
||||
'tickets' => Ticket::orderBy('id', 'desc')->paginate(10),
|
||||
'ticketcategories' => TicketCategory::all(),
|
||||
'locale_datatables' => $locale_settings->datatables
|
||||
|
@ -28,6 +36,7 @@ class TicketsController extends Controller
|
|||
|
||||
public function show($ticket_id, PterodactylSettings $ptero_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
try {
|
||||
$ticket = Ticket::where('ticket_id', $ticket_id)->firstOrFail();
|
||||
} catch (Exception $e)
|
||||
|
@ -39,11 +48,12 @@ class TicketsController extends Controller
|
|||
$server = Server::where('id', $ticket->server)->first();
|
||||
$pterodactyl_url = $ptero_settings->panel_url;
|
||||
|
||||
return view('moderator.ticket.show', compact('ticket', 'ticketcategory', 'ticketcomments', 'server', 'pterodactyl_url'));
|
||||
return view('admin.ticket.show', compact('ticket', 'ticketcategory', 'ticketcomments', 'server', 'pterodactyl_url'));
|
||||
}
|
||||
|
||||
public function changeStatus($ticket_id)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
try {
|
||||
$ticket = Ticket::where('ticket_id', $ticket_id)->firstOrFail();
|
||||
} catch(Exception $e)
|
||||
|
@ -65,6 +75,7 @@ class TicketsController extends Controller
|
|||
|
||||
public function delete($ticket_id)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
try {
|
||||
$ticket = Ticket::where('ticket_id', $ticket_id)->firstOrFail();
|
||||
} catch (Exception $e)
|
||||
|
@ -80,6 +91,9 @@ class TicketsController extends Controller
|
|||
|
||||
public function reply(Request $request)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
|
||||
$this->validate($request, ['ticketcomment' => 'required']);
|
||||
try {
|
||||
$ticket = Ticket::where('id', $request->input('ticket_id'))->firstOrFail();
|
||||
|
@ -114,7 +128,7 @@ class TicketsController extends Controller
|
|||
return $tickets->ticketcategory->name;
|
||||
})
|
||||
->editColumn('title', function (Ticket $tickets) {
|
||||
return '<a class="text-info" href="'.route('moderator.ticket.show', ['ticket_id' => $tickets->ticket_id]).'">'.'#'.$tickets->ticket_id.' - '.htmlspecialchars($tickets->title).'</a>';
|
||||
return '<a class="text-info" href="'.route('admin.ticket.show', ['ticket_id' => $tickets->ticket_id]).'">'.'#'.$tickets->ticket_id.' - '.htmlspecialchars($tickets->title).'</a>';
|
||||
})
|
||||
->editColumn('user_id', function (Ticket $tickets) {
|
||||
return '<a href="'.route('admin.users.show', $tickets->user->id).'">'.$tickets->user->name.'</a>';
|
||||
|
@ -125,13 +139,13 @@ class TicketsController extends Controller
|
|||
$statusButtonText = ($tickets->status == "Closed") ? __('Reopen') : __('Close');
|
||||
|
||||
return '
|
||||
<a data-content="'.__('View').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('moderator.ticket.show', ['ticket_id' => $tickets->ticket_id]).'" class="btn btn-sm text-white btn-info mr-1"><i class="fas fa-eye"></i></a>
|
||||
<form class="d-inline" method="post" action="'.route('moderator.ticket.changeStatus', ['ticket_id' => $tickets->ticket_id]).'">
|
||||
<a data-content="'.__('View').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.ticket.show', ['ticket_id' => $tickets->ticket_id]).'" class="btn btn-sm text-white btn-info mr-1"><i class="fas fa-eye"></i></a>
|
||||
<form class="d-inline" method="post" action="'.route('admin.ticket.changeStatus', ['ticket_id' => $tickets->ticket_id]).'">
|
||||
'.csrf_field().'
|
||||
'.method_field('POST').'
|
||||
<button data-content="'.__($statusButtonText).'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white '.$statusButtonColor.' mr-1"><i class="fas '.$statusButtonIcon.'"></i></button>
|
||||
</form>
|
||||
<form class="d-inline" method="post" action="'.route('moderator.ticket.delete', ['ticket_id' => $tickets->ticket_id]).'">
|
||||
<form class="d-inline" method="post" action="'.route('admin.ticket.delete', ['ticket_id' => $tickets->ticket_id]).'">
|
||||
'.csrf_field().'
|
||||
'.method_field('POST').'
|
||||
<button data-content="'.__('Delete').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
||||
|
@ -170,13 +184,17 @@ class TicketsController extends Controller
|
|||
|
||||
public function blacklist(LocaleSettings $locale_settings)
|
||||
{
|
||||
return view('moderator.ticket.blacklist', [
|
||||
$this->checkPermission(self::BLACKLIST_READ_PERMISSION);
|
||||
|
||||
return view('admin.ticket.blacklist', [
|
||||
'locale_datatables' => $locale_settings->datatables
|
||||
]);
|
||||
}
|
||||
|
||||
public function blacklistAdd(Request $request)
|
||||
{
|
||||
$this->checkPermission(self::BLACKLIST_WRITE_PERMISSION);
|
||||
|
||||
try {
|
||||
$user = User::where('id', $request->user_id)->firstOrFail();
|
||||
$check = TicketBlacklist::where('user_id', $user->id)->first();
|
||||
|
@ -202,6 +220,8 @@ class TicketsController extends Controller
|
|||
|
||||
public function blacklistDelete($id)
|
||||
{
|
||||
$this->checkPermission(self::BLACKLIST_WRITE_PERMISSION);
|
||||
|
||||
$blacklist = TicketBlacklist::where('id', $id)->first();
|
||||
$blacklist->delete();
|
||||
|
||||
|
@ -210,6 +230,8 @@ class TicketsController extends Controller
|
|||
|
||||
public function blacklistChange($id)
|
||||
{
|
||||
$this->checkPermission(self::BLACKLIST_WRITE_PERMISSION);
|
||||
|
||||
try {
|
||||
$blacklist = TicketBlacklist::where('id', $id)->first();
|
||||
}
|
||||
|
@ -254,12 +276,12 @@ class TicketsController extends Controller
|
|||
})
|
||||
->addColumn('actions', function (TicketBlacklist $blacklist) {
|
||||
return '
|
||||
<form class="d-inline" method="post" action="'.route('moderator.ticket.blacklist.change', ['id' => $blacklist->id]).'">
|
||||
<form class="d-inline" method="post" action="'.route('admin.ticket.blacklist.change', ['id' => $blacklist->id]).'">
|
||||
'.csrf_field().'
|
||||
'.method_field('POST').'
|
||||
<button data-content="'.__('Change Status').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-sync-alt"></i></button>
|
||||
</form>
|
||||
<form class="d-inline" method="post" action="'.route('moderator.ticket.blacklist.delete', ['id' => $blacklist->id]).'">
|
||||
<form class="d-inline" method="post" action="'.route('admin.ticket.blacklist.delete', ['id' => $blacklist->id]).'">
|
||||
'.csrf_field().'
|
||||
'.method_field('POST').'
|
||||
<button data-content="'.__('Delete').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
|
@ -15,6 +15,8 @@ use Illuminate\Http\Response;
|
|||
|
||||
class UsefulLinkController extends Controller
|
||||
{
|
||||
const READ_PERMISSION = "admin.useful_links.read";
|
||||
const WRITE_PERMISSION = "admin.useful_links.write";
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
@ -22,6 +24,7 @@ class UsefulLinkController extends Controller
|
|||
*/
|
||||
public function index(LocaleSettings $locale_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
return view('admin.usefullinks.index', [
|
||||
'locale_datatables' => $locale_settings->datatables
|
||||
]);
|
||||
|
@ -34,6 +37,7 @@ class UsefulLinkController extends Controller
|
|||
*/
|
||||
public function create()
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
$positions = UsefulLinkLocation::cases();
|
||||
return view('admin.usefullinks.create')->with('positions', $positions);
|
||||
}
|
||||
|
@ -84,6 +88,8 @@ class UsefulLinkController extends Controller
|
|||
*/
|
||||
public function edit(UsefulLink $usefullink)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
$positions = UsefulLinkLocation::cases();
|
||||
return view('admin.usefullinks.edit', [
|
||||
'link' => $usefullink,
|
||||
|
@ -126,6 +132,7 @@ class UsefulLinkController extends Controller
|
|||
*/
|
||||
public function destroy(UsefulLink $usefullink)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
$usefullink->delete();
|
||||
|
||||
return redirect()->back()->with('success', __('product has been removed!'));
|
||||
|
|
|
@ -26,9 +26,24 @@ use Illuminate\Support\HtmlString;
|
|||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
const READ_PERMISSION = "admin.users.read";
|
||||
const WRITE_PERMISSION = "admin.users.write";
|
||||
const SUSPEND_PERMISSION = "admin.users.suspend";
|
||||
const CHANGE_EMAIL_PERMISSION = "admin.users.write.email";
|
||||
const CHANGE_CREDITS_PERMISSION = "admin.users.write.credits";
|
||||
const CHANGE_USERNAME_PERMISSION = "admin.users.write.username";
|
||||
const CHANGE_PASSWORD_PERMISSION = "admin.users.write.password";
|
||||
const CHANGE_ROLE_PERMISSION ="admin.users.write.role";
|
||||
const CHANGE_REFERAL_PERMISSION ="admin.users.write.referal";
|
||||
const CHANGE_PTERO_PERMISSION = "admin.users.write.pterodactyl";
|
||||
const DELETE_PERMISSION = "admin.users.delete";
|
||||
const NOTIFY_PERMISSION = "admin.users.notify";
|
||||
const LOGIN_PERMISSION = "admin.users.login_as";
|
||||
|
||||
private $pterodactyl;
|
||||
|
||||
public function __construct(PterodactylSettings $ptero_settings)
|
||||
|
@ -44,6 +59,8 @@ class UserController extends Controller
|
|||
*/
|
||||
public function index(LocaleSettings $locale_settings, GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
return view('admin.users.index', [
|
||||
'locale_datatables' => $locale_settings->datatables,
|
||||
'credits_display_name' => $general_settings->credits_display_name
|
||||
|
@ -58,6 +75,8 @@ class UserController extends Controller
|
|||
*/
|
||||
public function show(User $user, LocaleSettings $locale_settings, GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
//QUERY ALL REFERRALS A USER HAS
|
||||
//i am not proud of this at all.
|
||||
$allReferals = [];
|
||||
|
@ -108,9 +127,13 @@ class UserController extends Controller
|
|||
*/
|
||||
public function edit(User $user, GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
|
||||
$roles = Role::all();
|
||||
return view('admin.users.edit')->with([
|
||||
'user' => $user,
|
||||
'credits_display_name' => $general_settings->credits_display_name
|
||||
'credits_display_name' => $general_settings->credits_display_name,
|
||||
'roles' => $roles
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -131,17 +154,21 @@ class UserController extends Controller
|
|||
'email' => 'required|string|email',
|
||||
'credits' => 'required|numeric|min:0|max:99999999',
|
||||
'server_limit' => 'required|numeric|min:0|max:1000000',
|
||||
'role' => Rule::in(['admin', 'moderator', 'client', 'member']),
|
||||
'referral_code' => "required|string|min:2|max:32|unique:users,referral_code,{$user->id}",
|
||||
]);
|
||||
|
||||
//update roles
|
||||
if ($request->roles && $this->can(self::CHANGE_ROLE_PERMISSION)) {
|
||||
$user->syncRoles($request->roles);
|
||||
}
|
||||
|
||||
if (isset($this->pterodactyl->getUser($request->input('pterodactyl_id'))['errors'])) {
|
||||
throw ValidationException::withMessages([
|
||||
'pterodactyl_id' => [__("User does not exists on pterodactyl's panel")],
|
||||
]);
|
||||
}
|
||||
|
||||
if (!is_null($request->input('new_password'))) {
|
||||
if (!is_null($request->input('new_password')) && $this->can(self::CHANGE_PASSWORD_PERMISSION)) {
|
||||
$request->validate([
|
||||
'new_password' => 'required|string|min:8',
|
||||
'new_password_confirmation' => 'required|same:new_password',
|
||||
|
@ -152,7 +179,24 @@ class UserController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
$user->update($request->all());
|
||||
if($this->can(self::CHANGE_USERNAME_PERMISSION)){
|
||||
$user->name = $request->name;
|
||||
}
|
||||
if($this->can(self::CHANGE_CREDITS_PERMISSION)){
|
||||
$user->credits = $request->credits;
|
||||
}
|
||||
if($this->can(self::CHANGE_PTERO_PERMISSION)){
|
||||
$user->pterodactyl_id = $request->pterodactyl_id;
|
||||
}
|
||||
if($this->can(self::CHANGE_REFERAL_PERMISSION)){
|
||||
$user->referral_code = $request->referral_code;
|
||||
}
|
||||
if($this->can(self::CHANGE_EMAIL_PERMISSION)){
|
||||
$user->email = $request->email;
|
||||
}
|
||||
|
||||
$user->save();
|
||||
|
||||
event(new UserUpdateCreditsEvent($user));
|
||||
|
||||
return redirect()->route('admin.users.index')->with('success', 'User updated!');
|
||||
|
@ -166,7 +210,9 @@ class UserController extends Controller
|
|||
*/
|
||||
public function destroy(User $user)
|
||||
{
|
||||
if ($user->role === 'admin' && User::query()->where('role', 'admin')->count() === 1) {
|
||||
$this->checkPermission(self::DELETE_PERMISSION);
|
||||
|
||||
if ($user->hasRole(1) && User::role(1)->count() === 1) {
|
||||
return redirect()->back()->with('error', __('You can not delete the last admin!'));
|
||||
}
|
||||
|
||||
|
@ -195,6 +241,8 @@ class UserController extends Controller
|
|||
*/
|
||||
public function loginAs(Request $request, User $user)
|
||||
{
|
||||
$this->checkPermission(self::LOGIN_PERMISSION);
|
||||
|
||||
$request->session()->put('previousUser', Auth::user()->id);
|
||||
Auth::login($user);
|
||||
|
||||
|
@ -207,6 +255,7 @@ class UserController extends Controller
|
|||
*/
|
||||
public function logBackIn(Request $request)
|
||||
{
|
||||
|
||||
Auth::loginUsingId($request->session()->get('previousUser'), true);
|
||||
$request->session()->remove('previousUser');
|
||||
|
||||
|
@ -221,6 +270,8 @@ class UserController extends Controller
|
|||
*/
|
||||
public function notifications()
|
||||
{
|
||||
$this->checkPermission(self::NOTIFY_PERMISSION);
|
||||
|
||||
return view('admin.users.notifications');
|
||||
}
|
||||
|
||||
|
@ -235,6 +286,8 @@ class UserController extends Controller
|
|||
*/
|
||||
public function notify(Request $request)
|
||||
{
|
||||
$this->checkPermission(self::NOTIFY_PERMISSION);
|
||||
|
||||
$data = $request->validate([
|
||||
'via' => 'required|min:1|array',
|
||||
'via.*' => 'required|string|in:mail,database',
|
||||
|
@ -275,6 +328,8 @@ class UserController extends Controller
|
|||
*/
|
||||
public function toggleSuspended(User $user)
|
||||
{
|
||||
$this->checkPermission(self::SUSPEND_PERMISSION);
|
||||
|
||||
try {
|
||||
!$user->isSuspended() ? $user->suspend() : $user->unSuspend();
|
||||
} catch (Exception $exception) {
|
||||
|
@ -329,22 +384,13 @@ class UserController extends Controller
|
|||
';
|
||||
})
|
||||
->editColumn('role', function (User $user) {
|
||||
switch ($user->role) {
|
||||
case 'admin':
|
||||
$badgeColor = 'badge-danger';
|
||||
break;
|
||||
case 'moderator':
|
||||
$badgeColor = 'badge-info';
|
||||
break;
|
||||
case 'client':
|
||||
$badgeColor = 'badge-success';
|
||||
break;
|
||||
default:
|
||||
$badgeColor = 'badge-secondary';
|
||||
break;
|
||||
$html = '';
|
||||
|
||||
foreach ($user->roles as $role) {
|
||||
$html .= "<span style='background-color: $role->color' class='badge'>$role->name</span>";
|
||||
}
|
||||
|
||||
return '<span class="badge ' . $badgeColor . '">' . $user->role . '</span>';
|
||||
return $html;
|
||||
})
|
||||
->editColumn('last_seen', function (User $user) {
|
||||
return $user->last_seen ? $user->last_seen->diffForHumans() : __('Never');
|
||||
|
|
|
@ -19,6 +19,8 @@ use Illuminate\Validation\ValidationException;
|
|||
|
||||
class VoucherController extends Controller
|
||||
{
|
||||
const READ_PERMISSION = "admin.voucher.read";
|
||||
const WRITE_PERMISSION = "admin.voucher.write";
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
@ -26,6 +28,8 @@ class VoucherController extends Controller
|
|||
*/
|
||||
public function index(LocaleSettings $locale_settings, GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
return view('admin.vouchers.index', [
|
||||
'locale_datatables' => $locale_settings->datatables,
|
||||
'credits_display_name' => $general_settings->credits_display_name
|
||||
|
@ -39,6 +43,7 @@ class VoucherController extends Controller
|
|||
*/
|
||||
public function create(GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
return view('admin.vouchers.create', [
|
||||
'credits_display_name' => $general_settings->credits_display_name
|
||||
]);
|
||||
|
@ -84,6 +89,7 @@ class VoucherController extends Controller
|
|||
*/
|
||||
public function edit(Voucher $voucher, GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
return view('admin.vouchers.edit', [
|
||||
'voucher' => $voucher,
|
||||
'credits_display_name' => $general_settings->credits_display_name
|
||||
|
@ -120,6 +126,7 @@ class VoucherController extends Controller
|
|||
*/
|
||||
public function destroy(Voucher $voucher)
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
$voucher->delete();
|
||||
|
||||
return redirect()->back()->with('success', __('voucher has been removed!'));
|
||||
|
@ -127,6 +134,8 @@ class VoucherController extends Controller
|
|||
|
||||
public function users(Voucher $voucher, LocaleSettings $locale_settings, GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
|
||||
return view('admin.vouchers.users', [
|
||||
'voucher' => $voucher,
|
||||
'locale_datatables' => $locale_settings->datatables,
|
||||
|
|
155
app/Http/Controllers/Api/RoleController.php
Normal file
155
app/Http/Controllers/Api/RoleController.php
Normal file
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
|
||||
class RoleController extends Controller
|
||||
{
|
||||
const ALLOWED_INCLUDES = ['permissions', 'users'];
|
||||
|
||||
const ALLOWED_FILTERS = ['name'];
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = QueryBuilder::for(Role::class)
|
||||
->allowedIncludes(self::ALLOWED_INCLUDES)
|
||||
->allowedFilters(self::ALLOWED_FILTERS);
|
||||
|
||||
return $query->paginate($request->input('per_page') ?? 50);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'nullable|string|max:191',
|
||||
'color' => [
|
||||
'required',
|
||||
'regex:/^#([a-f0-9]{6}|[a-f0-9]{3})$/i'
|
||||
],
|
||||
'power' => 'required',
|
||||
]);
|
||||
|
||||
$role = Role::create([
|
||||
'name' => $request->name,
|
||||
'color' => $request->color,
|
||||
'power' => $request->power,
|
||||
]);
|
||||
|
||||
if ($request->permissions) {
|
||||
$role->givePermissionTo($request->permissions);
|
||||
}
|
||||
|
||||
return $role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Role|Collection|Model
|
||||
*/
|
||||
public function show(int $id)
|
||||
{
|
||||
$query = QueryBuilder::for(Role::class)
|
||||
->where('id', '=', $id)
|
||||
->allowedIncludes(self::ALLOWED_INCLUDES);
|
||||
|
||||
return $query->firstOrFail();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Request $request, int $id)
|
||||
{
|
||||
$role = Role::findOrFail($id);
|
||||
|
||||
$request->validate([
|
||||
'name' => 'nullable|string|max:191',
|
||||
'color' => [
|
||||
'required',
|
||||
'regex:/^#([a-f0-9]{6}|[a-f0-9]{3})$/i'
|
||||
],
|
||||
'power' => 'required',
|
||||
]);
|
||||
|
||||
if ($request->permissions) {
|
||||
$role->givePermissionTo($request->permissions);
|
||||
}
|
||||
|
||||
$role->update($request->all());
|
||||
//TODO PERMISSIONS?
|
||||
return $role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$role = Role::findOrFail($id);
|
||||
|
||||
if($role->id == 1 || $role->id == 3|| $role->id == 4){ //cannot delete admin and User role
|
||||
return response()->json([
|
||||
'error' => 'Not allowed to delete Admin, Client or Member'], 400);
|
||||
}
|
||||
|
||||
$users = User::role($role)->get();
|
||||
|
||||
foreach($users as $user){
|
||||
$user->syncRoles([4]);
|
||||
}
|
||||
$role->delete();
|
||||
|
||||
return $role;
|
||||
}
|
||||
}
|
|
@ -2,16 +2,12 @@
|
|||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Classes\Pterodactyl;
|
||||
use App\Events\UserUpdateCreditsEvent;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\DiscordUser;
|
||||
use App\Models\User;
|
||||
use App\Notifications\ReferralNotification;
|
||||
use App\Traits\Referral;
|
||||
use App\Settings\PterodactylSettings;
|
||||
use App\Classes\PterodactylClient;
|
||||
use App\Settings\ReferralSettings;
|
||||
use App\Settings\UserSettings;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
@ -31,18 +27,9 @@ use Spatie\QueryBuilder\QueryBuilder;
|
|||
|
||||
class UserController extends Controller
|
||||
{
|
||||
use Referral;
|
||||
const ALLOWED_INCLUDES = ['servers', 'notifications', 'payments', 'vouchers', 'roles', 'discordUser'];
|
||||
|
||||
const ALLOWED_INCLUDES = ['servers', 'notifications', 'payments', 'vouchers', 'discordUser'];
|
||||
|
||||
const ALLOWED_FILTERS = ['name', 'server_limit', 'email', 'pterodactyl_id', 'role', 'suspended'];
|
||||
|
||||
private $pterodactyl;
|
||||
|
||||
public function __construct(PterodactylSettings $ptero_settings)
|
||||
{
|
||||
$this->pterodactyl = new PterodactylClient($ptero_settings);
|
||||
}
|
||||
const ALLOWED_FILTERS = ['name', 'server_limit', 'email', 'pterodactyl_id', 'suspended'];
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
|
@ -98,14 +85,13 @@ class UserController extends Controller
|
|||
'email' => 'sometimes|string|email',
|
||||
'credits' => 'sometimes|numeric|min:0|max:1000000',
|
||||
'server_limit' => 'sometimes|numeric|min:0|max:1000000',
|
||||
'role' => ['sometimes', Rule::in(['admin', 'moderator', 'client', 'member'])],
|
||||
]);
|
||||
|
||||
event(new UserUpdateCreditsEvent($user));
|
||||
|
||||
//Update Users Password on Pterodactyl
|
||||
//Username,Mail,First and Lastname are required aswell
|
||||
$response = $this->pterodactyl->application->patch('/application/users/' . $user->pterodactyl_id, [
|
||||
$response = Pterodactyl::client()->patch('/application/users/'.$user->pterodactyl_id, [
|
||||
'username' => $request->name,
|
||||
'first_name' => $request->name,
|
||||
'last_name' => $request->name,
|
||||
|
@ -213,7 +199,7 @@ class UserController extends Controller
|
|||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function suspend(int $id)
|
||||
public function suspend(Request $request, int $id)
|
||||
{
|
||||
$discordUser = DiscordUser::find($id);
|
||||
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
||||
|
@ -237,12 +223,12 @@ class UserController extends Controller
|
|||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function unsuspend(int $id)
|
||||
public function unsuspend(Request $request, int $id)
|
||||
{
|
||||
$discordUser = DiscordUser::find($id);
|
||||
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
||||
|
||||
if (!$user->isSuspended()) {
|
||||
if (! $user->isSuspended()) {
|
||||
throw ValidationException::withMessages([
|
||||
'error' => 'You cannot unsuspend an User who is not suspended.',
|
||||
]);
|
||||
|
@ -253,10 +239,25 @@ class UserController extends Controller
|
|||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a unique Referral Code for User
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createReferralCode()
|
||||
{
|
||||
$referralcode = STR::random(8);
|
||||
if (User::where('referral_code', '=', $referralcode)->exists()) {
|
||||
$this->createReferralCode();
|
||||
}
|
||||
|
||||
return $referralcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function store(Request $request, UserSettings $user_settings, ReferralSettings $referral_settings)
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:30', 'min:4', 'alpha_num', 'unique:users'],
|
||||
|
@ -265,7 +266,7 @@ class UserController extends Controller
|
|||
]);
|
||||
|
||||
// Prevent the creation of new users via API if this is enabled.
|
||||
if (!$user_settings->creation_enabled) {
|
||||
if (! config('SETTINGS::SYSTEM:CREATION_OF_NEW_USERS', 'true')) {
|
||||
throw ValidationException::withMessages([
|
||||
'error' => 'The creation of new users has been blocked by the system administrator.',
|
||||
]);
|
||||
|
@ -274,13 +275,13 @@ class UserController extends Controller
|
|||
$user = User::create([
|
||||
'name' => $request->input('name'),
|
||||
'email' => $request->input('email'),
|
||||
'credits' => $user_settings->initial_credits,
|
||||
'server_limit' => $user_settings->initial_server_limit,
|
||||
'credits' => config('SETTINGS::USER:INITIAL_CREDITS', 150),
|
||||
'server_limit' => config('SETTINGS::USER:INITIAL_SERVER_LIMIT', 1),
|
||||
'password' => Hash::make($request->input('password')),
|
||||
'referral_code' => $this->createReferralCode(),
|
||||
]);
|
||||
|
||||
$response = $this->pterodactyl->application->post('/application/users', [
|
||||
$response = Pterodactyl::client()->post('/application/users', [
|
||||
'external_id' => App::environment('local') ? Str::random(16) : (string) $user->id,
|
||||
'username' => $user->name,
|
||||
'email' => $user->email,
|
||||
|
@ -303,12 +304,12 @@ class UserController extends Controller
|
|||
'pterodactyl_id' => $response->json()['attributes']['id'],
|
||||
]);
|
||||
//INCREMENT REFERRAL-USER CREDITS
|
||||
if (!empty($request->input('referral_code'))) {
|
||||
if (! empty($request->input('referral_code'))) {
|
||||
$ref_code = $request->input('referral_code');
|
||||
$new_user = $user->id;
|
||||
if ($ref_user = User::query()->where('referral_code', '=', $ref_code)->first()) {
|
||||
if ($referral_settings->mode === 'register' || $referral_settings->mode === 'both') {
|
||||
$ref_user->increment('credits', $referral_settings->reward);
|
||||
if (config('SETTINGS::REFERRAL:MODE') == 'register' || config('SETTINGS::REFERRAL:MODE') == 'both') {
|
||||
$ref_user->increment('credits', config('SETTINGS::REFERRAL::REWARD'));
|
||||
$ref_user->notify(new ReferralNotification($ref_user->id, $new_user));
|
||||
}
|
||||
//INSERT INTO USER_REFERRALS TABLE
|
||||
|
|
|
@ -139,6 +139,8 @@ class RegisterController extends Controller
|
|||
|
||||
]);
|
||||
|
||||
$user->syncRoles(4);
|
||||
|
||||
$response = $this->pterodactyl->application->post('/application/users', [
|
||||
'external_id' => $user->pterodactyl_id,
|
||||
'username' => $user->name,
|
||||
|
|
|
@ -2,12 +2,44 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
/**
|
||||
* Check if user has permissions
|
||||
* Abort 403 if the user doesn't have the required permission
|
||||
*
|
||||
* @param string $permission
|
||||
* @return void
|
||||
*/
|
||||
public function checkPermission(string $permission)
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->can($permission)) {
|
||||
abort(403, __('User does not have the right permissions.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user has permissions
|
||||
*
|
||||
* @param string $permission
|
||||
* @return bool
|
||||
*/
|
||||
public function can(string $permission): bool
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
|
||||
return $user->can($permission);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class HomeController extends Controller
|
|||
if (Storage::exists('callHome')) {
|
||||
return;
|
||||
}
|
||||
Http::asForm()->post('https://market.controlpanel.gg/callhome.php', [
|
||||
Http::asForm()->post('https://market.CtrlPanel.gg/callhome.php', [
|
||||
'id' => Hash::make(URL::current()),
|
||||
]);
|
||||
Storage::put('callHome', 'This is only used to count the installations of cpgg.');
|
||||
|
|
|
@ -26,27 +26,12 @@ class ProfileController extends Controller
|
|||
/** Display a listing of the resource. */
|
||||
public function index(UserSettings $user_settings, DiscordSettings $discord_settings, ReferralSettings $referral_settings)
|
||||
{
|
||||
switch (Auth::user()->role) {
|
||||
case 'admin':
|
||||
$badgeColor = 'badge-danger';
|
||||
break;
|
||||
case 'mod':
|
||||
$badgeColor = 'badge-info';
|
||||
break;
|
||||
case 'client':
|
||||
$badgeColor = 'badge-success';
|
||||
break;
|
||||
default:
|
||||
$badgeColor = 'badge-secondary';
|
||||
break;
|
||||
}
|
||||
|
||||
return view('profile.index')->with([
|
||||
'user' => Auth::user(),
|
||||
'credits_reward_after_verify_discord' => $user_settings->credits_reward_after_verify_discord,
|
||||
'force_email_verification' => $user_settings->force_email_verification,
|
||||
'force_discord_verification' => $user_settings->force_discord_verification,
|
||||
'badgeColor' => $badgeColor,
|
||||
'discord_client_id' => $discord_settings->client_id,
|
||||
'discord_client_secret' => $discord_settings->client_secret,
|
||||
'referral_enabled' => $referral_settings->enabled,
|
||||
|
@ -57,7 +42,7 @@ class ProfileController extends Controller
|
|||
public function selfDestroyUser()
|
||||
{
|
||||
$user = Auth::user();
|
||||
if ($user->role == "admin") return back()->with("error", "You cannot delete yourself as an admin!");
|
||||
if ($user->hasRole("Admin")) return back()->with("error", "You cannot delete yourself as an admin!");
|
||||
|
||||
$user->delete();
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ use App\Settings\PterodactylSettings;
|
|||
use App\Classes\PterodactylClient;
|
||||
use App\Settings\GeneralSettings;
|
||||
use Exception;
|
||||
use GuzzleHttp\Promise\Create;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
@ -24,6 +25,9 @@ use Illuminate\Support\Facades\Request as FacadesRequest;
|
|||
|
||||
class ServerController extends Controller
|
||||
{
|
||||
const CREATE_PERMISSION = 'user.server.create';
|
||||
const UPGRADE_PERMISSION = 'user.server.upgrade';
|
||||
|
||||
private $pterodactyl;
|
||||
|
||||
public function __construct(PterodactylSettings $ptero_settings)
|
||||
|
@ -81,6 +85,8 @@ class ServerController extends Controller
|
|||
/** Show the form for creating a new resource. */
|
||||
public function create(UserSettings $user_settings, ServerSettings $server_settings, GeneralSettings $general_settings)
|
||||
{
|
||||
$this->checkPermission(self::CREATE_PERMISSION);
|
||||
|
||||
$validate_configuration = $this->validateConfigurationRules($user_settings, $server_settings);
|
||||
|
||||
if (!is_null($validate_configuration)) {
|
||||
|
@ -316,6 +322,8 @@ class ServerController extends Controller
|
|||
|
||||
public function upgrade(Server $server, Request $request)
|
||||
{
|
||||
$this->checkPermission(self::UPGRADE_PERMISSION);
|
||||
|
||||
if ($server->user_id != Auth::user()->id) {
|
||||
return redirect()->route('servers.index');
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ use Illuminate\Support\Str;
|
|||
|
||||
class TicketsController extends Controller
|
||||
{
|
||||
const READ_PERMISSION = 'user.ticket.read';
|
||||
const WRITE_PERMISSION = 'user.ticket.write';
|
||||
public function index(LocaleSettings $locale_settings)
|
||||
{
|
||||
return view('ticket.index', [
|
||||
|
@ -39,6 +41,7 @@ class TicketsController extends Controller
|
|||
'ticketcategory' => 'required',
|
||||
'priority' => 'required',
|
||||
'message' => 'required',
|
||||
'g-recaptcha-response' => ['required', 'recaptcha'],
|
||||
]
|
||||
);
|
||||
$ticket = new Ticket(
|
||||
|
@ -55,17 +58,13 @@ class TicketsController extends Controller
|
|||
);
|
||||
$ticket->save();
|
||||
$user = Auth::user();
|
||||
switch ($ticket_settings->notify) {
|
||||
case 'all':
|
||||
$admin = User::where('role', 'admin')->orWhere('role', 'mod')->get();
|
||||
Notification::send($admin, new AdminCreateNotification($ticket, $user));
|
||||
case 'admin':
|
||||
$admin = User::where('role', 'admin')->get();
|
||||
Notification::send($admin, new AdminCreateNotification($ticket, $user));
|
||||
case 'moderator':
|
||||
$admin = User::where('role', 'mod')->get();
|
||||
Notification::send($admin, new AdminCreateNotification($ticket, $user));
|
||||
|
||||
$staffNotify = User::permission('admin.tickets.get_notification')->get();
|
||||
foreach($staffNotify as $staff){
|
||||
Notification::send($staff, new AdminCreateNotification($ticket, $user));
|
||||
}
|
||||
|
||||
|
||||
$user->notify(new CreateNotification($ticket));
|
||||
|
||||
return redirect()->route('ticket.index')->with('success', __('A ticket has been opened, ID: #') . $ticket->ticket_id);
|
||||
|
@ -73,6 +72,7 @@ class TicketsController extends Controller
|
|||
|
||||
public function show($ticket_id, PterodactylSettings $ptero_settings)
|
||||
{
|
||||
$this->checkPermission(self::READ_PERMISSION);
|
||||
try {
|
||||
$ticket = Ticket::where('ticket_id', $ticket_id)->firstOrFail();
|
||||
} catch (Exception $e) {
|
||||
|
@ -108,15 +108,19 @@ class TicketsController extends Controller
|
|||
'message' => $request->input('message'),
|
||||
]);
|
||||
$user = Auth::user();
|
||||
$admin = User::where('role', 'admin')->orWhere('role', 'mod')->get();
|
||||
$newmessage = $request->input('ticketcomment');
|
||||
Notification::send($admin, new AdminReplyNotification($ticket, $user, $newmessage));
|
||||
|
||||
$staffNotify = User::permission('admin.tickets.get_notification')->get();
|
||||
foreach($staffNotify as $staff){
|
||||
Notification::send($staff, new AdminReplyNotification($ticket, $user, $newmessage));
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', __('Your comment has been submitted'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->checkPermission(self::WRITE_PERMISSION);
|
||||
//check in blacklist
|
||||
$check = TicketBlacklist::where('user_id', Auth::user()->id)->first();
|
||||
if ($check && $check->status == 'True') {
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace App\Http;
|
|||
|
||||
use App\Http\Middleware\ApiAuthToken;
|
||||
use App\Http\Middleware\CheckSuspended;
|
||||
use App\Http\Middleware\GlobalNames;
|
||||
use App\Http\Middleware\isAdmin;
|
||||
use App\Http\Middleware\isMod;
|
||||
use App\Http\Middleware\LastSeen;
|
||||
|
@ -27,6 +26,7 @@ class Kernel extends HttpKernel
|
|||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -43,14 +43,12 @@ class Kernel extends HttpKernel
|
|||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
LastSeen::class,
|
||||
GlobalNames::class,
|
||||
\App\Http\Middleware\SetLocale::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
GlobalNames::class,
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -76,5 +74,9 @@ class Kernel extends HttpKernel
|
|||
'moderator' => isMod::class,
|
||||
'api.token' => ApiAuthToken::class,
|
||||
'checkSuspended' => CheckSuspended::class,
|
||||
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
|
||||
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
|
||||
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class GlobalNames
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$unsupported_lang_array = explode(',', config('app.unsupported_locales'));
|
||||
$unsupported_lang_array = array_map('strtolower', $unsupported_lang_array);
|
||||
define('UNSUPPORTED_LANGS', $unsupported_lang_array);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class isAdmin
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if (Auth::user() && Auth::user()->role == 'admin') {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class isMod
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if (Auth::user() && Auth::user()->role == 'moderator' || Auth::user() && Auth::user()->role == 'admin') {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ class UserPayment
|
|||
$this->referral_always_give_commission = $referral_settings->always_give_commission;
|
||||
$this->credits_display_name = $general_settings->credits_display_name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
|
@ -79,8 +79,8 @@ class UserPayment
|
|||
}
|
||||
}
|
||||
//update role give Referral-reward
|
||||
if ($user->role == 'member') {
|
||||
$user->update(['role' => 'client']);
|
||||
if ($user->hasRole(4)) {
|
||||
$user->syncRoles(3);
|
||||
|
||||
//give referral commission only on first purchase
|
||||
if (($this->referral_mode === "commission" || $this->referral_mode === "both") && $shopProduct->type == "Credits" && !$this->referral_always_give_commission) {
|
||||
|
|
|
@ -69,6 +69,8 @@ class Server extends Model
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$ptero_settings = new PterodactylSettings();
|
||||
$this->pterodactyl = new PterodactylClient($ptero_settings);
|
||||
}
|
||||
|
|
|
@ -18,13 +18,14 @@ use Illuminate\Notifications\Notifiable;
|
|||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\CausesActivity;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
*/
|
||||
class User extends Authenticatable implements MustVerifyEmail
|
||||
{
|
||||
use HasFactory, Notifiable, LogsActivity, CausesActivity;
|
||||
use HasFactory, Notifiable, LogsActivity, CausesActivity, HasRoles;
|
||||
|
||||
private PterodactylClient $pterodactyl;
|
||||
|
||||
|
@ -92,6 +93,8 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$ptero_settings = new PterodactylSettings();
|
||||
$this->pterodactyl = new PterodactylClient($ptero_settings);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,21 @@ class AppServiceProvider extends ServiceProvider
|
|||
URL::forceScheme('https');
|
||||
}
|
||||
|
||||
//get the Github Branch the panel is running on
|
||||
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::notice($e);
|
||||
}
|
||||
config(['BRANCHNAME' => $branchname]);
|
||||
|
||||
// Do not run this code if no APP_KEY is set
|
||||
if (config('app.key') == null) return;
|
||||
|
||||
|
@ -75,5 +90,6 @@ class AppServiceProvider extends ServiceProvider
|
|||
|
||||
$settings = $this->app->make(MailSettings::class);
|
||||
$settings->setConfig();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,14 +18,7 @@ class DiscordSettings extends Settings
|
|||
return 'discord';
|
||||
}
|
||||
|
||||
public static function encrypted(): array
|
||||
{
|
||||
return [
|
||||
'bot_token',
|
||||
'client_id',
|
||||
'client_secret'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of validations array
|
||||
|
|
|
@ -24,13 +24,7 @@ class GeneralSettings extends Settings
|
|||
return 'general';
|
||||
}
|
||||
|
||||
public static function encrypted(): array
|
||||
{
|
||||
return [
|
||||
'recaptcha_site_key',
|
||||
'recaptcha_secret_key'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of validations array
|
||||
|
|
|
@ -21,12 +21,7 @@ class MailSettings extends Settings
|
|||
return 'mail';
|
||||
}
|
||||
|
||||
public static function encrypted(): array
|
||||
{
|
||||
return [
|
||||
'mail_password'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function setConfig()
|
||||
{
|
||||
|
|
|
@ -16,13 +16,7 @@ class PterodactylSettings extends Settings
|
|||
return 'pterodactyl';
|
||||
}
|
||||
|
||||
public static function encrypted(): array
|
||||
{
|
||||
return [
|
||||
'admin_token',
|
||||
'user_token'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get url with ensured ending backslash
|
||||
|
|
|
@ -6,7 +6,6 @@ use Spatie\LaravelSettings\Settings;
|
|||
|
||||
class ReferralSettings extends Settings
|
||||
{
|
||||
public string $allowed;
|
||||
public bool $always_give_commission;
|
||||
public bool $enabled;
|
||||
public ?float $reward;
|
||||
|
@ -43,19 +42,10 @@ class ReferralSettings extends Settings
|
|||
{
|
||||
return [
|
||||
'category_icon' => 'fas fa-user-friends',
|
||||
'allowed' => [
|
||||
'label' => 'Allowed',
|
||||
'type' => 'select',
|
||||
'description' => 'Who is allowed to see their referral-URL',
|
||||
'options' => [
|
||||
'everyone' => 'Everyone',
|
||||
'clients' => 'Clients',
|
||||
],
|
||||
],
|
||||
'always_give_commission' => [
|
||||
'label' => 'Always Give Commission',
|
||||
'type' => 'boolean',
|
||||
'description' => 'Always give commission to the referrer.',
|
||||
'description' => 'Always give commission to the referrer or only on the first Purchase.',
|
||||
],
|
||||
'enabled' => [
|
||||
'label' => 'Enabled',
|
||||
|
|
|
@ -7,7 +7,6 @@ use Spatie\LaravelSettings\Settings;
|
|||
class TicketSettings extends Settings
|
||||
{
|
||||
public bool $enabled;
|
||||
public string $notify;
|
||||
|
||||
public static function group(): string
|
||||
{
|
||||
|
@ -22,7 +21,6 @@ class TicketSettings extends Settings
|
|||
{
|
||||
return [
|
||||
'enabled' => 'nullable|boolean',
|
||||
'notify' => 'nullable|string',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -40,17 +38,6 @@ class TicketSettings extends Settings
|
|||
'type' => 'boolean',
|
||||
'description' => 'Enable or disable the ticket system.',
|
||||
],
|
||||
'notify' => [
|
||||
'label' => 'Notify',
|
||||
'type' => 'select',
|
||||
'description' => 'Who will receive an E-Mail when a new Ticket is created.',
|
||||
'options' => [
|
||||
'admin' => 'Admins',
|
||||
'moderator' => 'Moderators',
|
||||
'all' => 'Admins and Moderators',
|
||||
'none' => 'Nobody',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
"qirolab/laravel-themer": "^2.0.2",
|
||||
"socialiteproviders/discord": "^4.1.2",
|
||||
"spatie/laravel-activitylog": "^4.7.3",
|
||||
"spatie/laravel-permission": "^5.10",
|
||||
"spatie/laravel-query-builder": "^5.1.2",
|
||||
"spatie/laravel-settings": "^2.7",
|
||||
"spatie/laravel-validation-rules": "^3.2.2",
|
||||
|
|
612
composer.lock
generated
612
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Facade;
|
|||
|
||||
return [
|
||||
|
||||
'version' => '0.9.4',
|
||||
'version' => '0.10',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -17,7 +17,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Controlpanel.gg'),
|
||||
'name' => env('APP_NAME', 'CtrlPanel.gg'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -93,7 +93,7 @@ return [
|
|||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', 'ControlPanel'),
|
||||
'name' => env('MAIL_FROM_NAME', 'CtrlPanel'),
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
161
config/permission.php
Normal file
161
config/permission.php
Normal file
|
@ -0,0 +1,161 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'models' => [
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your permissions. Of course, it
|
||||
* is often just the "Permission" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Permission model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Permission` contract.
|
||||
*/
|
||||
|
||||
'permission' => Spatie\Permission\Models\Permission::class,
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your roles. Of course, it
|
||||
* is often just the "Role" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Role model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Role` contract.
|
||||
*/
|
||||
|
||||
'role' => Spatie\Permission\Models\Role::class,
|
||||
|
||||
],
|
||||
|
||||
'table_names' => [
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'roles' => 'roles',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your permissions. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'permissions' => 'permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_permissions' => 'model_has_permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models roles. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_roles' => 'model_has_roles',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'role_has_permissions' => 'role_has_permissions',
|
||||
],
|
||||
|
||||
'column_names' => [
|
||||
/*
|
||||
* Change this if you want to name the related pivots other than defaults
|
||||
*/
|
||||
'role_pivot_key' => null, //default 'role_id',
|
||||
'permission_pivot_key' => null, //default 'permission_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to name the related model primary key other than
|
||||
* `model_id`.
|
||||
*
|
||||
* For example, this would be nice if your primary keys are all UUIDs. In
|
||||
* that case, name this `model_uuid`.
|
||||
*/
|
||||
|
||||
'model_morph_key' => 'model_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to use the teams feature and your related model's
|
||||
* foreign key is other than `team_id`.
|
||||
*/
|
||||
|
||||
'team_foreign_key' => 'team_id',
|
||||
],
|
||||
|
||||
/*
|
||||
* When set to true, the method for checking permissions will be registered on the gate.
|
||||
* Set this to false, if you want to implement custom logic for checking permissions.
|
||||
*/
|
||||
|
||||
'register_permission_check_method' => true,
|
||||
|
||||
/*
|
||||
* When set to true the package implements teams using the 'team_foreign_key'. If you want
|
||||
* the migrations to register the 'team_foreign_key', you must set this to true
|
||||
* before doing the migration. If you already did the migration then you must make a new
|
||||
* migration to also add 'team_foreign_key' to 'roles', 'model_has_roles', and
|
||||
* 'model_has_permissions'(view the latest version of package's migration file)
|
||||
*/
|
||||
|
||||
'teams' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required permission names are added to the exception
|
||||
* message. This could be considered an information leak in some contexts, so
|
||||
* the default setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_permission_in_exception' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required role names are added to the exception
|
||||
* message. This could be considered an information leak in some contexts, so
|
||||
* the default setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_role_in_exception' => false,
|
||||
|
||||
/*
|
||||
* By default wildcard permission lookups are disabled.
|
||||
*/
|
||||
|
||||
'enable_wildcard_permission' => true,
|
||||
|
||||
'cache' => [
|
||||
|
||||
/*
|
||||
* By default all permissions are cached for 24 hours to speed up performance.
|
||||
* When permissions or roles are updated the cache is flushed automatically.
|
||||
*/
|
||||
|
||||
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
|
||||
|
||||
/*
|
||||
* The cache key used to store all permissions.
|
||||
*/
|
||||
|
||||
'key' => 'spatie.permission.cache',
|
||||
|
||||
/*
|
||||
* You may optionally indicate a specific cache driver to use for permission and
|
||||
* role caching using any of the `store` drivers listed in the cache.php config
|
||||
* file. Using 'default' here means to use the `default` set in cache.php.
|
||||
*/
|
||||
|
||||
'store' => 'default',
|
||||
],
|
||||
];
|
130
config/permissions_web.php
Normal file
130
config/permissions_web.php
Normal file
|
@ -0,0 +1,130 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'*',
|
||||
|
||||
/*
|
||||
* Permissions for admin
|
||||
*/
|
||||
|
||||
'admin.roles.read',
|
||||
'admin.roles.create',
|
||||
'admin.roles.edit',
|
||||
'admin.roles.delete',
|
||||
|
||||
|
||||
'admin.ticket.read',
|
||||
'admin.tickets.write',
|
||||
'admin.tickets.get_notification',
|
||||
|
||||
'admin.ticket_blacklist.read',
|
||||
'admin.ticket_blacklist.write',
|
||||
|
||||
'admin.overview.read',
|
||||
'admin.overview.sync',
|
||||
|
||||
'admin.api.read',
|
||||
'admin.api.write',
|
||||
|
||||
'admin.users.read',
|
||||
'admin.users.write',
|
||||
'admin.users.suspend',
|
||||
'admin.users.write.credits',
|
||||
'admin.users.write.username',
|
||||
'admin.users.write.password',
|
||||
'admin.users.write.role',
|
||||
'admin.users.write.referal',
|
||||
'admin.users.write.pterodactyl',
|
||||
'admin.users.write.email',
|
||||
'admin.users.notify',
|
||||
'admin.users.login_as',
|
||||
'admin.users.delete',
|
||||
|
||||
'admin.servers.read',
|
||||
'admin.servers.write',
|
||||
'admin.servers.suspend',
|
||||
'admin.servers.write.owner',
|
||||
'admin.servers.write.identifier',
|
||||
'admin.servers.delete',
|
||||
|
||||
'admin.products.read',
|
||||
'admin.products.create',
|
||||
'admin.products.edit',
|
||||
'admin.products.delete',
|
||||
|
||||
'admin.store.read',
|
||||
'admin.store.write',
|
||||
'admin.store.disable',
|
||||
|
||||
'admin.voucher.read',
|
||||
'admin.voucher.write',
|
||||
|
||||
'admin.useful_links.read',
|
||||
'admin.useful_links.write',
|
||||
|
||||
'admin.legal.read',
|
||||
'admin.legal.write',
|
||||
|
||||
'admin.payments.read',
|
||||
|
||||
'admin.partners.read',
|
||||
'admin.partners.write',
|
||||
|
||||
'admin.logs.read',
|
||||
|
||||
/*
|
||||
* Settings Permissions
|
||||
*/
|
||||
'settings.discord.read',
|
||||
'settings.discord.write',
|
||||
|
||||
'settings.general.read',
|
||||
'settings.general.write',
|
||||
|
||||
'settings.invoice.read',
|
||||
'settings.invoice.write',
|
||||
|
||||
'settings.locale.read',
|
||||
'settings.locale.write',
|
||||
|
||||
'settings.mail.read',
|
||||
'settings.mail.write',
|
||||
|
||||
'settings.pterodactyl.read',
|
||||
'settings.pterodactyl.write',
|
||||
|
||||
'settings.referral.read',
|
||||
'settings.referral.write',
|
||||
|
||||
'settings.server.read',
|
||||
'settings.server.write',
|
||||
|
||||
'settings.ticket.read',
|
||||
'settings.ticket.write',
|
||||
|
||||
'settings.user.read',
|
||||
'settings.user.write',
|
||||
|
||||
'settings.website.read',
|
||||
'settings.website.write',
|
||||
|
||||
'settings.paypal.read',
|
||||
'settings.paypal.write',
|
||||
|
||||
'settings.stripe.read',
|
||||
'settings.stripe.write',
|
||||
|
||||
'settings.mollie.read',
|
||||
'settings.mollie.write',
|
||||
|
||||
|
||||
/*
|
||||
* Permissions for users
|
||||
*/
|
||||
'user.server.create',
|
||||
'user.server.upgrade',
|
||||
'user.shop.buy',
|
||||
'user.ticket.read',
|
||||
'user.ticket.write',
|
||||
'user.referral',
|
||||
];
|
|
@ -26,7 +26,7 @@ return new class extends Migration
|
|||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->integer('pterodactyl_id')->nullable->change();
|
||||
$table->integer('pterodactyl_id')->nullable()->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Spatie\Permission\PermissionRegistrar;
|
||||
|
||||
class CreatePermissionTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
$teams = config('permission.teams');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
}
|
||||
if ($teams && empty($columnNames['team_foreign_key'] ?? null)) {
|
||||
throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
}
|
||||
|
||||
Schema::create($tableNames['permissions'], function (Blueprint $table) {
|
||||
$table->bigIncrements('id'); // permission id
|
||||
$table->string('name'); // For MySQL 8.0 use string('name', 125);
|
||||
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) {
|
||||
$table->bigIncrements('id'); // role id
|
||||
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||
}
|
||||
$table->string('name'); // For MySQL 8.0 use string('name', 125);
|
||||
$table->string('color')->nullable()->default('#485460'); // For MySQL 8.0 use string('name', 125);
|
||||
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
|
||||
$table->timestamps();
|
||||
if ($teams || config('permission.testing')) {
|
||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||
} else {
|
||||
$table->unique(['name', 'guard_name']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
|
||||
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||
|
||||
$table->foreign(PermissionRegistrar::$pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
} else {
|
||||
$table->primary([PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
|
||||
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||
|
||||
$table->foreign(PermissionRegistrar::$pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
} else {
|
||||
$table->primary([PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
|
||||
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
|
||||
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
|
||||
|
||||
$table->foreign(PermissionRegistrar::$pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign(PermissionRegistrar::$pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
}
|
||||
|
||||
Schema::drop($tableNames['role_has_permissions']);
|
||||
Schema::drop($tableNames['model_has_roles']);
|
||||
Schema::drop($tableNames['model_has_permissions']);
|
||||
Schema::drop($tableNames['roles']);
|
||||
Schema::drop($tableNames['permissions']);
|
||||
}
|
||||
}
|
32
database/migrations/2023_05_05_090127_role_power.php
Normal file
32
database/migrations/2023_05_05_090127_role_power.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('roles', function (Blueprint $table) {
|
||||
$table->integer('power')->after("color")->default(50);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('roles', function (Blueprint $table) {
|
||||
$table->dropColumn('power');
|
||||
});
|
||||
}
|
||||
};
|
32
database/migrations/2023_05_05_103834_oom_killer.php
Normal file
32
database/migrations/2023_05_05_103834_oom_killer.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->boolean('oom_killer')->after("allocations")->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropColumn('oom_killer');
|
||||
});
|
||||
}
|
||||
};
|
79
database/seeders/PermissionsSeeder.php
Normal file
79
database/seeders/PermissionsSeeder.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class PermissionsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
$this->createPermissions();
|
||||
$this->createRoles();
|
||||
|
||||
|
||||
$users = User::all();
|
||||
foreach($users as $user){
|
||||
$user->assignRole(4);
|
||||
}
|
||||
|
||||
$admins = User::where("role","admin")->get();
|
||||
foreach($admins as $admin) {
|
||||
$admin->syncRoles(1);
|
||||
}
|
||||
|
||||
$mods = User::where("role","moderator")->get();
|
||||
foreach($mods as $mod) {
|
||||
$mod->syncRoles(2);
|
||||
}
|
||||
|
||||
$clients = User::where("role","client")->get();
|
||||
foreach($clients as $client) {
|
||||
$client->syncRoles(3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function createPermissions()
|
||||
{
|
||||
foreach (config('permissions_web') as $name) {
|
||||
Permission::findOrCreate($name);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO run only once
|
||||
public function createRoles()
|
||||
{
|
||||
$userPermissions=[
|
||||
'user.server.create',
|
||||
'user.server.upgrade',
|
||||
'user.shop.buy',
|
||||
'user.ticket.read',
|
||||
'user.ticket.write',
|
||||
'user.referral',
|
||||
];
|
||||
/** @var Role $adminRole */
|
||||
$adminRole = Role::updateOrCreate(["name"=>"Admin","color"=>"#fa0000", "power"=>100]);
|
||||
$supportRole = Role::updateOrCreate(["name"=>"Support-Team","color"=>"#00b0b3","power"=>50]);
|
||||
$clientRole = Role::updateOrCreate(["name"=>"Client","color"=>"#008009","power"=>10]);
|
||||
$userRole = Role::updateOrCreate(["name"=>"User","color"=>"#0052a3","power"=>10]);
|
||||
|
||||
$adminRole->givePermissionTo(Permission::findByName('*'));
|
||||
|
||||
$userRole->syncPermissions($userPermissions);
|
||||
$clientRole->syncPermissions($userPermissions);
|
||||
}
|
||||
}
|
|
@ -12,8 +12,8 @@ class CreateGeneralSettings extends SettingsMigration
|
|||
// Get the user-set configuration values from the old table.
|
||||
$this->migrator->add('general.store_enabled', true);
|
||||
$this->migrator->add('general.credits_display_name', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') : 'Credits');
|
||||
$this->migrator->addEncrypted('general.recaptcha_site_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SITE_KEY") : env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'));
|
||||
$this->migrator->addEncrypted('general.recaptcha_secret_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SECRET_KEY") : env('RECAPTCHA_SECRET_KEY', '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'));
|
||||
$this->migrator->add('general.recaptcha_site_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SITE_KEY") : env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'));
|
||||
$this->migrator->add('general.recaptcha_secret_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SECRET_KEY") : env('RECAPTCHA_SECRET_KEY', '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'));
|
||||
$this->migrator->add('general.recaptcha_enabled', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:ENABLED") : true);
|
||||
$this->migrator->add('general.phpmyadmin_url', $table_exists ? $this->getOldValue("SETTINGS::MISC:PHPMYADMIN:URL") : env('PHPMYADMIN_URL', ''));
|
||||
$this->migrator->add('general.alert_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_ENABLED") : false);
|
||||
|
|
|
@ -10,8 +10,8 @@ class CreatePterodactylSettings extends SettingsMigration
|
|||
$table_exists = DB::table('settings_old')->exists();
|
||||
|
||||
// Get the user-set configuration values from the old table.
|
||||
$this->migrator->addEncrypted('pterodactyl.admin_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN') : env('PTERODACTYL_TOKEN', ''));
|
||||
$this->migrator->addEncrypted('pterodactyl.user_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN') : '');
|
||||
$this->migrator->add('pterodactyl.admin_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN') : env('PTERODACTYL_TOKEN', ''));
|
||||
$this->migrator->add('pterodactyl.user_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN') : '');
|
||||
$this->migrator->add('pterodactyl.panel_url', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:URL') : env('PTERODACTYL_URL', ''));
|
||||
$this->migrator->add('pterodactyl.per_page_limit', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT') : 200);
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ class CreateMailSettings extends SettingsMigration
|
|||
$this->migrator->add('mail.mail_host', $table_exists ? $this->getOldValue('SETTINGS::MAIL:HOST') : env('MAIL_HOST', 'localhost'));
|
||||
$this->migrator->add('mail.mail_port', $table_exists ? $this->getOldValue('SETTINGS::MAIL:PORT') : env('MAIL_PORT', 25));
|
||||
$this->migrator->add('mail.mail_username', $table_exists ? $this->getOldValue('SETTINGS::MAIL:USERNAME') : env('MAIL_USERNAME', ''));
|
||||
$this->migrator->addEncrypted('mail.mail_password', $table_exists ? $this->getOldValue('SETTINGS::MAIL:PASSWORD') : env('MAIL_PASSWORD', ''));
|
||||
$this->migrator->add('mail.mail_password', $table_exists ? $this->getOldValue('SETTINGS::MAIL:PASSWORD') : env('MAIL_PASSWORD', ''));
|
||||
$this->migrator->add('mail.mail_encryption', $table_exists ? $this->getOldValue('SETTINGS::MAIL:ENCRYPTION') : env('MAIL_ENCRYPTION', 'tls'));
|
||||
$this->migrator->add('mail.mail_from_address', $table_exists ? $this->getOldValue('SETTINGS::MAIL:FROM_ADDRESS') : env('MAIL_FROM_ADDRESS', 'example@example.com'));
|
||||
$this->migrator->add('mail.mail_from_name', $table_exists ? $this->getOldValue('SETTINGS::MAIL:FROM_NAME') : env('APP_NAME', 'ControlPanel.gg'));
|
||||
$this->migrator->add('mail.mail_from_name', $table_exists ? $this->getOldValue('SETTINGS::MAIL:FROM_NAME') : env('APP_NAME', 'CtrlPanel.gg'));
|
||||
$this->migrator->add('mail.mail_mailer', $table_exists ? $this->getOldValue('SETTINGS::MAIL:MAILER') : env('MAIL_MAILER', 'smtp'));
|
||||
$this->migrator->add('mail.mail_enabled', true);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class CreateInvoiceSettings extends SettingsMigration
|
|||
$this->migrator->add('invoice.company_phone', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_PHONE') : '');
|
||||
$this->migrator->add('invoice.company_vat', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_VAT') : '');
|
||||
$this->migrator->add('invoice.company_website', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_WEBSITE') : '');
|
||||
$this->migrator->add('invoice.enabled', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:ENABLED') : true);
|
||||
$this->migrator->add('invoice.enabled', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:ENABLED') : false);
|
||||
$this->migrator->add('invoice.prefix', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:PREFIX') : 'INV');
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ class CreateDiscordSettings extends SettingsMigration
|
|||
$table_exists = DB::table('settings_old')->exists();
|
||||
|
||||
// Get the user-set configuration values from the old table.
|
||||
$this->migrator->addEncrypted('discord.bot_token', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN') : '');
|
||||
$this->migrator->addEncrypted('discord.client_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_ID') : '');
|
||||
$this->migrator->addEncrypted('discord.client_secret', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_SECRET') : '');
|
||||
$this->migrator->add('discord.bot_token', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN') : '');
|
||||
$this->migrator->add('discord.client_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_ID') : '');
|
||||
$this->migrator->add('discord.client_secret', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_SECRET') : '');
|
||||
$this->migrator->add('discord.guild_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:GUILD_ID') : '');
|
||||
$this->migrator->add('discord.invite_url', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:INVITE_URL') : '');
|
||||
$this->migrator->add('discord.role_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:ROLE_ID') : '');
|
||||
|
|
|
@ -10,7 +10,6 @@ class CreateReferralSettings extends SettingsMigration
|
|||
$table_exists = DB::table('settings_old')->exists();
|
||||
|
||||
// Get the user-set configuration values from the old table.
|
||||
$this->migrator->add('referral.allowed', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ALLOWED') : 'client');
|
||||
$this->migrator->add('referral.always_give_commission', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION') : false);
|
||||
$this->migrator->add('referral.enabled', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ENABLED') : false);
|
||||
$this->migrator->add('referral.reward', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::REWARD') : 100);
|
||||
|
|
|
@ -14,16 +14,15 @@ class CreateWebsiteSettings extends SettingsMigration
|
|||
$this->migrator->add(
|
||||
'website.motd_message',
|
||||
$table_exists ? $this->getOldValue("SETTINGS::SYSTEM:MOTD_MESSAGE") :
|
||||
'<h1 style="text-align: center;"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://controlpanel.gg/img/controlpanel.png" alt="" width="200" height="200"><span style="font-size: 36pt;">Controlpanel.gg</span></h1>
|
||||
<p><span style="font-size: 18pt;">Thank you for using our Software</span></p>
|
||||
<p><span style="font-size: 18pt;">If you have any questions, make sure to join our <a href="https://discord.com/invite/4Y6HjD2uyU" target="_blank" rel="noopener">Discord</a></span></p>
|
||||
<p><span style="font-size: 10pt;">(you can change this message in the <a href="admin/settings#system">Settings</a> )</span></p>'
|
||||
);
|
||||
"<h1 style='text-align: center;'><img style='display: block; margin-left: auto; margin-right: auto;' src='https://ctrlpanel.gg/img/controlpanel.png' alt=' width='200' height='200'><span style='font-size: 36pt;'>CtrlPanel.gg</span></h1>
|
||||
<p><span style='font-size: 18pt;'>Thank you for using our Software</span></p>
|
||||
<p><span style='font-size: 18pt;'>If you have any questions, make sure to join our <a href='https://discord.com/invite/4Y6HjD2uyU' target='_blank' rel='noopener'>Discord</a></span></p>
|
||||
<p><span style='font-size: 10pt;'>(you can change this message in the <a href='admin/settings#system'>Settings</a> )</span></p>");
|
||||
$this->migrator->add('website.show_imprint', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_IMPRINT") : false);
|
||||
$this->migrator->add('website.show_privacy', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_PRIVACY") : false);
|
||||
$this->migrator->add('website.show_tos', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_TOS") : false);
|
||||
$this->migrator->add('website.useful_links_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:USEFULLINKS_ENABLED") : true);
|
||||
$this->migrator->add('website.seo_title', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SEO_TITLE") : 'ControlPanel.gg');
|
||||
$this->migrator->add('website.seo_title', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SEO_TITLE") : 'CtrlPanel.gg');
|
||||
$this->migrator->add('website.seo_description', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SEO_DESCRIPTION") : 'Billing software for Pterodactyl Panel.');
|
||||
$this->migrator->add('website.enable_login_logo', true);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
"Support server": "Discord Server",
|
||||
"Documentation": "Dokumentation",
|
||||
"Github": "Github",
|
||||
"Support ControlPanel": "Unterstütze Controlpanel.gg",
|
||||
"Support ControlPanel": "Unterstütze CtrlPanel.gg",
|
||||
"Servers": "Server",
|
||||
"Total": "Gesamt",
|
||||
"Payments": "Zahlungen",
|
||||
|
|
|
@ -177,7 +177,7 @@
|
|||
"Title": "Title",
|
||||
"User": "User",
|
||||
"Last updated": "Last updated",
|
||||
"Controlpanel.gg": "Controlpanel.gg",
|
||||
"CtrlPanel.gg": "CtrlPanel.gg",
|
||||
"Version": "Version",
|
||||
"Individual nodes": "Individual nodes",
|
||||
"You reached the Pterodactyl perPage limit. Please make sure to set it higher than your server count.": "You reached the Pterodactyl perPage limit. Please make sure to set it higher than your server count.",
|
||||
|
@ -654,4 +654,4 @@
|
|||
"sv": "Swedish",
|
||||
"sk": "Slovakish",
|
||||
"hu": "Hungarian"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
@ -32,7 +35,7 @@ if (isset($_POST['checkDB'])) {
|
|||
header('LOCATION: index.php?step=2&message=' . $e->getMessage());
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach ($values as $key => $value) {
|
||||
$param = $_POST[$value];
|
||||
|
@ -76,6 +79,7 @@ if (isset($_POST['feedDB'])) {
|
|||
$logs .= run_console('php artisan storage:link');
|
||||
$logs .= run_console('php artisan migrate --seed --force');
|
||||
$logs .= run_console('php artisan db:seed --class=ExampleItemsSeeder --force');
|
||||
$logs .= run_console('php artisan db:seed --class=PermissionsSeeder --force');
|
||||
|
||||
wh_log($logs, 'debug');
|
||||
|
||||
|
@ -131,7 +135,7 @@ if (isset($_POST['checkSMTP'])) {
|
|||
'mail_host' => $_POST['host'],
|
||||
'mail_port' => $_POST['port'],
|
||||
'mail_username' => $_POST['user'],
|
||||
'mail_password' => encryptSettingsValue($_POST['pass']),
|
||||
'mail_password' => $_POST['pass'],
|
||||
'mail_encryption' => $_POST['encryption'],
|
||||
'mail_from_address' => $_POST['user'],
|
||||
];
|
||||
|
@ -196,8 +200,8 @@ if (isset($_POST['checkPtero'])) {
|
|||
wh_log('Pterodactyl Settings are correct', 'debug');
|
||||
wh_log('Updating Database', 'debug');
|
||||
|
||||
$key = encryptSettingsValue($key);
|
||||
$clientkey = encryptSettingsValue($clientkey);
|
||||
$key = $key;
|
||||
$clientkey = $clientkey;
|
||||
|
||||
$query1 = 'UPDATE `' . getenv('DB_DATABASE') . "`.`settings` SET `payload` = '" . json_encode($url) . "' WHERE (`name` = 'panel_url' AND `group` = 'pterodactyl')";
|
||||
$query2 = 'UPDATE `' . getenv('DB_DATABASE') . "`.`settings` SET `payload` = '" . json_encode($key) . "' WHERE (`name` = 'admin_token' AND `group` = 'pterodactyl')";
|
||||
|
@ -234,10 +238,10 @@ if (isset($_POST['createUser'])) {
|
|||
$repass = $_POST['repass'];
|
||||
|
||||
$key = $db->query('SELECT `payload` FROM `' . getenv('DB_DATABASE') . "`.`settings` WHERE `name` = 'admin_token' AND `group` = 'pterodactyl'")->fetch_assoc();
|
||||
$key = encryptSettingsValue($key['value']);
|
||||
$key = removeQuotes($key['payload']);
|
||||
$pterobaseurl = $db->query('SELECT `payload` FROM `' . getenv('DB_DATABASE') . "`.`settings` WHERE `name` = 'panel_url' AND `group` = 'pterodactyl'")->fetch_assoc();
|
||||
|
||||
$pteroURL = $pterobaseurl['value'] . '/api/application/users/' . $pteroID;
|
||||
$pteroURL = removeQuotes($pterobaseurl['payload']) . '/api/application/users/' . $pteroID;
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $pteroURL);
|
||||
|
@ -264,7 +268,7 @@ if (isset($_POST['createUser'])) {
|
|||
$name = $result['attributes']['username'];
|
||||
$pass = password_hash($pass, PASSWORD_DEFAULT);
|
||||
|
||||
$pteroURL = $pterobaseurl['value'] . '/api/application/users/' . $pteroID;
|
||||
$pteroURL = removeQuotes($pterobaseurl['payload']) . '/api/application/users/' . $pteroID;
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $pteroURL);
|
||||
|
@ -272,7 +276,7 @@ if (isset($_POST['createUser'])) {
|
|||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Accept: application/json',
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $key['value'],
|
||||
'Authorization: Bearer ' . $key,
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, [
|
||||
'email' => $mail,
|
||||
|
@ -291,13 +295,14 @@ if (isset($_POST['createUser'])) {
|
|||
}
|
||||
|
||||
$random = generateRandomString();
|
||||
$query1 = 'INSERT INTO `' . getenv('DB_DATABASE') . "`.`users` (`name`, `role`, `credits`, `server_limit`, `pterodactyl_id`, `email`, `password`, `created_at`, `referral_code`) VALUES ('$name', 'admin', '250', '1', '$pteroID', '$mail', '$pass', CURRENT_TIMESTAMP, '$random')";
|
||||
|
||||
if ($db->query($query1)) {
|
||||
$query1 = 'INSERT INTO `' . getenv('DB_DATABASE') . "`.`users` (`name`, `role`, `credits`, `server_limit`, `pterodactyl_id`, `email`, `password`, `created_at`, `referral_code`) VALUES ('$name', 'admin', '250', '1', '$pteroID', '$mail', '$pass', CURRENT_TIMESTAMP, '$random')";
|
||||
$query2 = "INSERT INTO `" . getenv('DB_DATABASE') . "`.`model_has_roles` (`role_id`, `model_type`, `model_id`) VALUES ('1', 'App\\\Models\\\User', '1')";
|
||||
if ($db->query($query1) && $db->query($query2)) {
|
||||
wh_log('Created user with Email ' . $mail . ' and pterodactyl ID ' . $pteroID, 'info');
|
||||
header('LOCATION: index.php?step=7');
|
||||
} else {
|
||||
wh_log($db->error, 'error');
|
||||
header('LOCATION: index.php?step=6&message=Something went wrong when communicating with the Database');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,6 +150,10 @@ function checkExtensions(): array
|
|||
return $not_ok;
|
||||
}
|
||||
|
||||
function removeQuotes($string){
|
||||
return str_replace('"', "", $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the environment variable into the env file
|
||||
* @param string $envKey The environment key to set or modify
|
||||
|
|
|
@ -9,7 +9,7 @@ function cardStart($title, $subtitle = null)
|
|||
{
|
||||
return "
|
||||
<div class='flex flex-col gap-4 sm:w-auto w-full sm:min-w-[550px] my-6'>
|
||||
<h1 class='text-center font-bold text-3xl'>ControlPanel.gg Installation</h1>
|
||||
<h1 class='text-center font-bold text-3xl'>CtrlPanel.gg Installation</h1>
|
||||
<div class='border-4 border-[#2E373B] bg-[#242A2E] rounded-2xl p-6 pt-3 mx-2'>
|
||||
<h2 class='text-xl text-center mb-2'>$title</h2>"
|
||||
. (isset($subtitle) ? "<p class='text-neutral-400 mb-1'>$subtitle</p>" : "");
|
||||
|
@ -19,7 +19,7 @@ function cardStart($title, $subtitle = null)
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<title>Controlpanel.gg installer Script</title>
|
||||
<title>CtrlPanel.gg installer Script</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="/install/styles.css" rel="stylesheet">
|
||||
|
@ -68,7 +68,7 @@ function cardStart($title, $subtitle = null)
|
|||
// Getting started
|
||||
if (!isset($_GET['step']) || $_GET['step'] == 1) {
|
||||
?>
|
||||
<?php echo cardStart($title = "Mandatory Checks before Installation", $subtitle = "This installer will lead you through the most crucial Steps of Controlpanel.gg's setup"); ?>
|
||||
<?php echo cardStart($title = "Mandatory Checks before Installation", $subtitle = "This installer will lead you through the most crucial Steps of CtrlPanel.gg's setup"); ?>
|
||||
|
||||
<ul class="list-none mb-2">
|
||||
|
||||
|
@ -327,7 +327,7 @@ function cardStart($title, $subtitle = null)
|
|||
<div class="flex flex-col mb-3">
|
||||
|
||||
<label for="url">Pterodactyl URL</label>
|
||||
<input id="url" name="url" type="text" required value="https://ptero.example.com" class="px-2 py-1 bg-[#1D2125] border-2 focus:border-sky-500 box-border rounded-md border-transparent outline-none">
|
||||
<input id="url" name="url" type="text" required placeholder="https://ptero.example.com" class="px-2 py-1 bg-[#1D2125] border-2 focus:border-sky-500 box-border rounded-md border-transparent outline-none">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
5
public/plugins/alpinejs/3.12.0_cdn.min.js
vendored
Normal file
5
public/plugins/alpinejs/3.12.0_cdn.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
15383
public/plugins/datatables/jquery.dataTables.js
vendored
15383
public/plugins/datatables/jquery.dataTables.js
vendored
File diff suppressed because it is too large
Load diff
1
public/plugins/datatables/jquery.dataTables.min.css
vendored
Normal file
1
public/plugins/datatables/jquery.dataTables.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
172
public/plugins/datatables/jquery.dataTables.min.js
vendored
172
public/plugins/datatables/jquery.dataTables.min.js
vendored
File diff suppressed because one or more lines are too long
0
public/plugins/datatables/v1.13.4
Normal file
0
public/plugins/datatables/v1.13.4
Normal file
File diff suppressed because one or more lines are too long
|
@ -13,16 +13,17 @@ use App\Http\Controllers\Admin\OverViewController;
|
|||
use App\Http\Controllers\Admin\PartnerController;
|
||||
use App\Http\Controllers\Admin\PaymentController;
|
||||
use App\Http\Controllers\Admin\ProductController;
|
||||
use App\Http\Controllers\Admin\RoleController;
|
||||
use App\Http\Controllers\Admin\ServerController as AdminServerController;
|
||||
use App\Http\Controllers\Admin\SettingsController;
|
||||
use App\Http\Controllers\Admin\ShopProductController;
|
||||
use App\Http\Controllers\Admin\TicketCategoryController;
|
||||
use App\Http\Controllers\Admin\TicketsController as AdminTicketsController;
|
||||
use App\Http\Controllers\Admin\UsefulLinkController;
|
||||
use App\Http\Controllers\Admin\UserController;
|
||||
use App\Http\Controllers\Admin\VoucherController;
|
||||
use App\Http\Controllers\Auth\SocialiteController;
|
||||
use App\Http\Controllers\HomeController;
|
||||
use App\Http\Controllers\Moderation\TicketCategoryController;
|
||||
use App\Http\Controllers\Moderation\TicketsController as ModTicketsController;
|
||||
use App\Http\Controllers\NotificationController;
|
||||
use App\Http\Controllers\ProductController as FrontProductController;
|
||||
use App\Http\Controllers\ProfileController;
|
||||
|
@ -112,12 +113,14 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
|
|||
Route::post('ticket/new', [TicketsController::class, 'store'])->middleware(['throttle:ticket-new'])->name('ticket.new.store');
|
||||
Route::get('ticket/show/{ticket_id}', [TicketsController::class, 'show'])->name('ticket.show');
|
||||
Route::post('ticket/reply', [TicketsController::class, 'reply'])->middleware(['throttle:ticket-reply'])->name('ticket.reply');
|
||||
Route::post('ticket/close/{ticket_id}', [TicketsController::class, 'close'])->name('ticket.close');
|
||||
Route::post('ticket/status/{ticket_id}', [TicketsController::class, 'changeStatus'])->name('ticket.changeStatus');
|
||||
|
||||
|
||||
//admin
|
||||
Route::prefix('admin')->name('admin.')->middleware('admin')->group(function () {
|
||||
|
||||
Route::prefix('admin')->name('admin.')->group(function () {
|
||||
//Roles
|
||||
Route::get('roles/datatable', [RoleController::class, 'datatable'])->name('roles.datatable');
|
||||
Route::resource('roles', RoleController::class);
|
||||
//overview
|
||||
Route::get('legal', [OverViewController::class, 'index'])->name('overview.index');
|
||||
|
||||
|
@ -196,29 +199,28 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
|
|||
Route::resource('api', ApplicationApiController::class)->parameters([
|
||||
'api' => 'applicationApi',
|
||||
]);
|
||||
});
|
||||
|
||||
//mod
|
||||
Route::prefix('moderator')->name('moderator.')->middleware('moderator')->group(function () {
|
||||
//ticket moderation
|
||||
Route::get('ticket', [ModTicketsController::class, 'index'])->name('ticket.index');
|
||||
Route::get('ticket/datatable', [ModTicketsController::class, 'datatable'])->name('ticket.datatable');
|
||||
Route::get('ticket/show/{ticket_id}', [ModTicketsController::class, 'show'])->name('ticket.show');
|
||||
Route::post('ticket/reply', [ModTicketsController::class, 'reply'])->name('ticket.reply');
|
||||
Route::post('ticket/status/{ticket_id}', [ModTicketsController::class, 'changeStatus'])->name('ticket.changeStatus');
|
||||
Route::post('ticket/delete/{ticket_id}', [ModTicketsController::class, 'delete'])->name('ticket.delete');
|
||||
Route::get('ticket', [AdminTicketsController::class, 'index'])->name('ticket.index');
|
||||
Route::get('ticket/datatable', [AdminTicketsController::class, 'datatable'])->name('ticket.datatable');
|
||||
Route::get('ticket/show/{ticket_id}', [AdminTicketsController::class, 'show'])->name('ticket.show');
|
||||
Route::post('ticket/reply', [AdminTicketsController::class, 'reply'])->name('ticket.reply');
|
||||
Route::post('ticket/status/{ticket_id}', [AdminTicketsController::class, 'changeStatus'])->name('ticket.changeStatus');
|
||||
Route::post('ticket/delete/{ticket_id}', [AdminTicketsController::class, 'delete'])->name('ticket.delete');
|
||||
//ticket moderation blacklist
|
||||
Route::get('ticket/blacklist', [ModTicketsController::class, 'blacklist'])->name('ticket.blacklist');
|
||||
Route::post('ticket/blacklist', [ModTicketsController::class, 'blacklistAdd'])->name('ticket.blacklist.add');
|
||||
Route::post('ticket/blacklist/delete/{id}', [ModTicketsController::class, 'blacklistDelete'])->name('ticket.blacklist.delete');
|
||||
Route::post('ticket/blacklist/change/{id}', [ModTicketsController::class, 'blacklistChange'])->name('ticket.blacklist.change');
|
||||
Route::get('ticket/blacklist/datatable', [ModTicketsController::class, 'dataTableBlacklist'])->name('ticket.blacklist.datatable');
|
||||
Route::get('ticket/blacklist', [AdminTicketsController::class, 'blacklist'])->name('ticket.blacklist');
|
||||
Route::post('ticket/blacklist', [AdminTicketsController::class, 'blacklistAdd'])->name('ticket.blacklist.add');
|
||||
Route::post('ticket/blacklist/delete/{id}', [AdminTicketsController::class, 'blacklistDelete'])->name('ticket.blacklist.delete');
|
||||
Route::post('ticket/blacklist/change/{id}', [AdminTicketsController::class, 'blacklistChange'])->name('ticket.blacklist.change');
|
||||
Route::get('ticket/blacklist/datatable', [AdminTicketsController::class, 'dataTableBlacklist'])->name('ticket.blacklist.datatable');
|
||||
|
||||
|
||||
Route::get('ticket/category/datatable', [TicketCategoryController::class, 'datatable'])->name('ticket.category.datatable');
|
||||
Route::resource("ticket/category", TicketCategoryController::class, ['as' => 'ticket']);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Route::get('/home', [HomeController::class, 'index'])->name('home');
|
||||
});
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@
|
|||
src="{{ \Illuminate\Support\Facades\Storage::disk('public')->exists('icon.png') ? asset('storage/icon.png') : asset('images/controlpanel_logo.png') }}"
|
||||
alt="{{ config('app.name', 'Laravel') }} Logo" class="brand-image img-circle"
|
||||
style="opacity: .8">
|
||||
<span class="brand-text font-weight-light">{{ config('app.name', 'Controlpanel.gg') }}</span>
|
||||
<span class="brand-text font-weight-light">{{ config('app.name', 'CtrlPanel.gg') }}</span>
|
||||
</a>
|
||||
|
||||
<!-- Sidebar -->
|
||||
|
@ -253,26 +253,26 @@
|
|||
</li>
|
||||
@endif
|
||||
|
||||
@if ((Auth::user()->role == 'admin' || Auth::user()->role == 'moderator') && config('SETTINGS::TICKET:ENABLED'))
|
||||
@if ((Auth::user()->hasRole("Admin") || Auth::user()->role == 'moderator') && config('SETTINGS::TICKET:ENABLED'))
|
||||
<li class="nav-header">{{ __('Moderation') }}</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a href="{{ route('moderator.ticket.index') }}"
|
||||
class="nav-link @if (Request::routeIs('moderator.ticket.index')) active @endif">
|
||||
<a href="{{ route('admin.ticket.index') }}"
|
||||
class="nav-link @if (Request::routeIs('admin.ticket.index')) active @endif">
|
||||
<i class="nav-icon fas fa-ticket-alt"></i>
|
||||
<p>{{ __('Ticket List') }}</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="{{ route('moderator.ticket.blacklist') }}"
|
||||
class="nav-link @if (Request::routeIs('moderator.ticket.blacklist')) active @endif">
|
||||
<a href="{{ route('admin.ticket.blacklist') }}"
|
||||
class="nav-link @if (Request::routeIs('admin.ticket.blacklist')) active @endif">
|
||||
<i class="nav-icon fas fa-user-times"></i>
|
||||
<p>{{ __('Ticket Blacklist') }}</p>
|
||||
</a>
|
||||
</li>
|
||||
@endif
|
||||
|
||||
@if (Auth::user()->role == 'admin')
|
||||
@if (Auth::user()->hasRole("Admin"))
|
||||
<li class="nav-header">{{ __('Administration') }}</li>
|
||||
|
||||
<li class="nav-item">
|
||||
|
@ -441,7 +441,7 @@
|
|||
<strong>Copyright © 2021-{{ date('Y') }} <a
|
||||
href="{{ url('/') }}">{{ env('APP_NAME', 'Laravel') }}</a>.</strong>
|
||||
All rights
|
||||
reserved. Powered by <a href="https://controlpanel.gg">ControlPanel</a>. | Theme by <a href="https://2icecube.de/cpgg">2IceCube</a>
|
||||
reserved. Powered by <a href="https://CtrlPanel.gg">ControlPanel</a>. | Theme by <a href="https://2icecube.de/cpgg">2IceCube</a>
|
||||
@if (!str_contains(config('BRANCHNAME'), 'main') && !str_contains(config('BRANCHNAME'), 'unknown'))
|
||||
Version <b>{{ config('app')['version'] }} - {{ config('BRANCHNAME') }}</b>
|
||||
@endif
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
@else
|
||||
<div class="callout callout-danger">
|
||||
<h4>{{ __('No recent activity from cronjobs')}}</h4>
|
||||
<p>{{ __('Are cronjobs running?')}} <a class="text-primary" target="_blank" href="https://controlpanel.gg/docs/Installation/getting-started#crontab-configuration">{{ __('Check the docs for it here')}}</a></p>
|
||||
<p>{{ __('Are cronjobs running?')}} <a class="text-primary" target="_blank" href="https://CtrlPanel.gg/docs/Installation/getting-started#crontab-configuration">{{ __('Check the docs for it here')}}</a></p>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<b><i class="fas fa-shield-alt"></i> {{__("Version Outdated:")}}</b></br>
|
||||
{{__("You are running on")}} v{{config("app.version")}}-{{config("BRANCHNAME")}}.
|
||||
{{__("The latest Version is")}} v{{Storage::get('latestVersion')}}</br>
|
||||
<a href="https://controlpanel.gg/docs/Installation/updating">{{__("Consider updating now")}}</a>
|
||||
<a href="https://CtrlPanel.gg/docs/Installation/updating">{{__("Consider updating now")}}</a>
|
||||
</div>
|
||||
@endif
|
||||
</section>
|
||||
|
@ -39,7 +39,7 @@
|
|||
class="fab fa-discord mr-2"></i> {{__('Support server')}}</a>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<a href="https://controlpanel.gg/docs/intro" class="btn btn-dark btn-block px-3"><i
|
||||
<a href="https://CtrlPanel.gg/docs/intro" class="btn btn-dark btn-block px-3"><i
|
||||
class="fas fa-link mr-2"></i> {{__('Documentation')}}</a>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
|
@ -47,8 +47,8 @@
|
|||
class="fab fa-github mr-2"></i> {{__('Github')}}</a>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<a href="https://controlpanel.gg/docs/Contributing/donating" class="btn btn-dark btn-block px-3"><i
|
||||
class="fas fa-money-bill mr-2"></i> {{__('Support ControlPanel')}}</a>
|
||||
<a href="https://CtrlPanel.gg/docs/Contributing/donating" class="btn btn-dark btn-block px-3"><i
|
||||
class="fas fa-money-bill mr-2"></i> {{__('Support CtrlPanel')}}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -183,7 +183,7 @@
|
|||
|
||||
@foreach($tickets as $ticket_id => $ticket)
|
||||
<tr>
|
||||
<td><a class="text-info" href="{{route('moderator.ticket.show', ['ticket_id' => $ticket_id])}}">#{{$ticket_id}} - {{$ticket->title}}</td>
|
||||
<td><a class="text-info" href="{{route('admin.ticket.show', ['ticket_id' => $ticket_id])}}">#{{$ticket_id}} - {{$ticket->title}}</td>
|
||||
<td><a href="{{route('admin.users.show', $ticket->user_id)}}">{{$ticket->user}}</a></td>
|
||||
<td><span class="badge {{$ticket->statusBadgeColor}}">{{$ticket->status}}</span></td>
|
||||
<td>{{$ticket->last_updated}}</td>
|
||||
|
@ -199,7 +199,7 @@
|
|||
<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>
|
||||
<span><i class="fas fa-server mr-2"></i>{{__('CtrlPanel.gg')}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body py-1">
|
||||
|
@ -227,7 +227,7 @@
|
|||
<p class="mb-2">
|
||||
{{ __('You reached the Pterodactyl perPage limit. Please make sure to set it higher than your server count.') }}<br>
|
||||
{{ __('You can do that in settings.') }}<br><br>
|
||||
{{ __('Note') }}: {{ __('If this error persists even after changing the limit, it might mean a server was deleted on Pterodactyl, but not on ControlPanel. Try clicking the button below.') }}
|
||||
{{ __('Note') }}: {{ __('If this error persists even after changing the limit, it might mean a server was deleted on Pterodactyl, but not on CtrlPanel. Try clicking the button below.') }}
|
||||
</p>
|
||||
<a href="{{route('admin.servers.sync')}}" class="btn btn-primary btn-md"><i
|
||||
class="fas fa-sync mr-2"></i>{{__('Sync servers')}}</a>
|
||||
|
|
|
@ -131,7 +131,15 @@
|
|||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="checkbox" value="1" id="oom" name="oom_killer"
|
||||
class="">
|
||||
|
||||
<label for="oom_killer">{{__('OOM Killer')}} <i
|
||||
data-toggle="popover" data-trigger="hover"
|
||||
data-content="{{__('Enable or Disable the OOM Killer for this Product.')}}"
|
||||
class="fas fa-info-circle"></i></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
|
|
|
@ -139,6 +139,16 @@
|
|||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="checkbox" @if($product->oom_killer) checked @endif value="1" id="oom" name="oom_killer"
|
||||
class="">
|
||||
|
||||
<label for="oom_killer">{{__('OOM Killer')}} <i
|
||||
data-toggle="popover" data-trigger="hover"
|
||||
data-content="{{__('Enable or Disable the OOM Killer for this Product.')}}"
|
||||
class="fas fa-info-circle"></i></label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
<th>{{__('Nodes')}}</th>
|
||||
<th>{{__('Eggs')}}</th>
|
||||
<th>{{__('Min Credits')}}</th>
|
||||
<th>{{__('OOM Killer')}}</th>
|
||||
<th>{{__('Servers')}}</th>
|
||||
<th>{{__('Created at')}}</th>
|
||||
<th>{{ __('Actions') }}</th>
|
||||
|
@ -101,6 +102,7 @@
|
|||
{data: "nodes", sortable: false},
|
||||
{data: "eggs", sortable: false},
|
||||
{data: "minimum_credits"},
|
||||
{data: "oom_killer"},
|
||||
{data: "servers", sortable: false},
|
||||
{data: "created_at"},
|
||||
{data: "actions", sortable: false}
|
||||
|
|
61
themes/default/views/admin/roles/edit.blade.php
Normal file
61
themes/default/views/admin/roles/edit.blade.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
@extends('layouts.main')
|
||||
|
||||
@section('content')
|
||||
<div class="main py-4">
|
||||
|
||||
<div class="card card-body border-0 shadow table-wrapper table-responsive">
|
||||
<h2 class="mb-4 h5">{{ isset($role) ? __('Edit role') : __('Create role') }}</h2>
|
||||
|
||||
<form method="post"
|
||||
action="{{isset($role) ? route('admin.roles.update', $role->id) : route('admin.roles.store')}}">
|
||||
@csrf
|
||||
@isset($role)
|
||||
@method('PATCH')
|
||||
@endisset
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
|
||||
<x-input.text label="{{(__('Name'))}}"
|
||||
name="name"
|
||||
value="{{ isset($role) ? $role->name : null}}"/>
|
||||
|
||||
<x-input.text label="{{(__('Badge color'))}}"
|
||||
type="color"
|
||||
name="color"
|
||||
value="{{ isset($role) ? $role->color : null}}"/>
|
||||
|
||||
<x-input.number label="{{(__('Power'))}}"
|
||||
name="power"
|
||||
min="1"
|
||||
max="100"
|
||||
step="1"
|
||||
value="{{ isset($role) ? $role->power : 10}}"/>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
|
||||
<x-input.select
|
||||
label="{{(__('Permissions'))}}"
|
||||
name="permissions"
|
||||
style="height: 200px"
|
||||
multiple>
|
||||
@foreach($permissions as $permission)
|
||||
<option @if(isset($role) && $role->permissions->contains($permission)) selected
|
||||
@endif value="{{$permission->id}}">{{$permission->name}}</option>
|
||||
@endforeach
|
||||
</x-input.select>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group d-flex justify-content-end mt-3">
|
||||
<button name="submit" type="submit" class="btn btn-primary">{{__('Submit')}}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endsection
|
62
themes/default/views/admin/roles/index.blade.php
Normal file
62
themes/default/views/admin/roles/index.blade.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
@extends('layouts.main')
|
||||
|
||||
@section('content')
|
||||
<div class="main py-4">
|
||||
|
||||
@can('admin.roles.write')
|
||||
<div class="d-flex justify-content-end my-3">
|
||||
<a href="{{route('admin.roles.create')}}" class="btn btn-primary"><i
|
||||
class="fa fas fa-shield-alt pe-2"></i>{{__('Create role')}}</a>
|
||||
</div>
|
||||
@endcan
|
||||
|
||||
<div class="card card-body border-0 shadow table-wrapper table-responsive">
|
||||
<h2 class="mb-4 h5">{{ __('Roles') }}</h2>
|
||||
|
||||
<div class="card-body table-responsive">
|
||||
|
||||
<table id="datatable" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{__("ID")}}</th>
|
||||
<th>{{__("Name")}}</th>
|
||||
<th>{{__("User count")}}</th>
|
||||
<th>{{__("Permissions count")}}</th>
|
||||
<th>{{__("Power")}}</th>
|
||||
<th>{{__("Actions")}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
<script>
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
$('#datatable').DataTable({
|
||||
language: {
|
||||
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
|
||||
},
|
||||
processing: true,
|
||||
serverSide: true, //increases loading times too much? change back to "true" if it does
|
||||
stateSave: true,
|
||||
ajax: "{{route('admin.roles.datatable')}}",
|
||||
columns: [
|
||||
{data: 'id'},
|
||||
{data: 'name'},
|
||||
{data: 'usercount'},
|
||||
{data: 'permissionscount'},
|
||||
{data: 'power'},
|
||||
{data: 'actions' , sortable : false},
|
||||
],
|
||||
fnDrawCallback: function( oSettings ) {
|
||||
$('[data-toggle="popover"]').popover();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
<div class="form-group">
|
||||
<label for="identifier">{{ __('Server identifier') }}
|
||||
<i data-toggle="popover" data-trigger="hover"
|
||||
data-content="{{ __('Change the server identifier on controlpanel to match a pterodactyl server.') }}"
|
||||
data-content="{{ __('Change the server identifier on CtrlPanel to match a pterodactyl server.') }}"
|
||||
class="fas fa-info-circle"></i>
|
||||
</label>
|
||||
<input value="{{ $server->identifier }}" id="identifier" name="identifier"
|
||||
|
@ -59,7 +59,7 @@
|
|||
<div class="form-group">
|
||||
<label for="user_id">{{ __('Server owner') }}
|
||||
<i data-toggle="popover" data-trigger="hover"
|
||||
data-content="{{ __('Change the current server owner on controlpanel and pterodactyl.') }}"
|
||||
data-content="{{ __('Change the current server owner on CtrlPanel and pterodactyl.') }}"
|
||||
class="fas fa-info-circle"></i>
|
||||
</label>
|
||||
<select name="user_id" id="user_id" class="form-control">
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="tablist"
|
||||
data-accordion="false">
|
||||
@foreach ($settings as $category => $options)
|
||||
@canany(["settings.".strtolower($category).".read","settings.".strtolower($category).".write"])
|
||||
<li class="nav-item border-bottom-0">
|
||||
<a href="#{{ $category }}"
|
||||
class="nav-link {{ $loop->first ? 'active' : '' }}" data-toggle="pill"
|
||||
|
@ -56,6 +57,7 @@
|
|||
</p>
|
||||
</a>
|
||||
</li>
|
||||
@endcanany
|
||||
@endforeach
|
||||
</ul>
|
||||
</nav>
|
||||
|
@ -65,6 +67,7 @@
|
|||
<div class="col-10 p-0">
|
||||
<div class="tab-content ml-3" style="width: 100%;">
|
||||
@foreach ($settings as $category => $options)
|
||||
@canany(["settings.".strtolower($category).".read","settings.".strtolower($category).".write"])
|
||||
<div container class="tab-pane fade container {{ $loop->first ? 'active show' : '' }}"
|
||||
id="{{ $category }}" role="tabpanel">
|
||||
|
||||
|
@ -129,11 +132,11 @@
|
|||
|
||||
@case($value['type'] == 'multiselect')
|
||||
<select id="{{ $key }}"
|
||||
class="custom-select w-100" name="{{ $key }}"
|
||||
class="custom-select w-100" name="{{ $key }}[]"
|
||||
multiple>
|
||||
@foreach ($value['options'] as $option)
|
||||
<option value="{{ $option }}"
|
||||
{{ $value['value'] == $option ? 'selected' : '' }}>
|
||||
{{ strpos($value['value'],$option) !== false ? 'selected' : '' }}>
|
||||
{{ __($option) }}
|
||||
</option>
|
||||
@endforeach
|
||||
|
@ -158,7 +161,34 @@
|
|||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endforeach
|
||||
|
||||
<!-- TODO: Display this only on the General tab
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4 d-flex align-items-center">
|
||||
<label for="recaptcha_preview">{{__("ReCAPTCHA Preview")}}</label>
|
||||
</div>
|
||||
|
||||
<div class="col-8">
|
||||
|
||||
<div class="w-100">
|
||||
<div class="input-group mb-3">
|
||||
{!! htmlScriptTagJsApi() !!}
|
||||
{!! htmlFormSnippet() !!}
|
||||
@error('g-recaptcha-response')
|
||||
<span class="text-danger" role="alert">
|
||||
<small><strong>{{ $message }}</strong></small>
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 d-flex align-items-center justify-content-end">
|
||||
<button type="submit"
|
||||
|
@ -169,6 +199,7 @@
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endcanany
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">{{ __('Dashboard') }}</a></li>
|
||||
<li class="breadcrumb-item"><a class="text-muted"
|
||||
href="{{ route('moderator.ticket.blacklist') }}">{{ __('Ticket Blacklist') }}</a>
|
||||
href="{{ route('admin.ticket.blacklist') }}">{{ __('Ticket Blacklist') }}</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
@ -60,7 +60,7 @@
|
|||
class="fas fa-info-circle"></i></h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{route('moderator.ticket.blacklist.add')}}" method="POST" class="ticket-form">
|
||||
<form action="{{route('admin.ticket.blacklist.add')}}" method="POST" class="ticket-form">
|
||||
@csrf
|
||||
<div class="custom-control mb-3 p-0">
|
||||
<label for="user_id">{{ __('User') }}:
|
||||
|
@ -95,7 +95,7 @@
|
|||
processing: true,
|
||||
serverSide: true,
|
||||
stateSave: true,
|
||||
ajax: "{{route('moderator.ticket.blacklist.datatable')}}",
|
||||
ajax: "{{route('admin.ticket.blacklist.datatable')}}",
|
||||
columns: [
|
||||
{data: 'user' , name : 'user.name'},
|
||||
{data: 'status'},
|
|
@ -12,7 +12,7 @@
|
|||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">{{ __('Dashboard') }}</a></li>
|
||||
<li class="breadcrumb-item"><a class="text-muted"
|
||||
href="{{ route("moderator.ticket.category.index") }}">{{ __('Ticket Categories') }}</a>
|
||||
href="{{ route("admin.ticket.category.index") }}">{{ __('Ticket Categories') }}</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
@ -56,7 +56,7 @@
|
|||
<h5 class="card-title">{{__('Add Category')}}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{route("moderator.ticket.category.store")}}" method="POST" class="ticket-form">
|
||||
<form action="{{route("admin.ticket.category.store")}}" method="POST" class="ticket-form">
|
||||
@csrf
|
||||
<div class="form-group ">
|
||||
<label for="name" class="control-label">{{__("Name")}}</label>
|
||||
|
@ -73,7 +73,7 @@
|
|||
<h5 class="card-title">{{__('Edit Category')}}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{route("moderator.ticket.category.update","1")}}" method="POST" class="ticket-form">
|
||||
<form action="{{route("admin.ticket.category.update","1")}}" method="POST" class="ticket-form">
|
||||
@csrf
|
||||
@method('PATCH')
|
||||
<select id="category" style="width:100%" class="custom-select" name="category"
|
||||
|
@ -109,7 +109,7 @@
|
|||
processing: true,
|
||||
serverSide: true,
|
||||
stateSave: true,
|
||||
ajax: "{{route('moderator.ticket.category.datatable')}}",
|
||||
ajax: "{{route('admin.ticket.category.datatable')}}",
|
||||
columns: [
|
||||
{data: 'id'},
|
||||
{data: 'name'},
|
|
@ -12,7 +12,7 @@
|
|||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="{{route('home')}}">{{__('Dashboard')}}</a></li>
|
||||
<li class="breadcrumb-item"><a class="text-muted"
|
||||
href="{{route('moderator.ticket.index')}}">{{__('Ticket List')}}</a></li>
|
||||
href="{{route('admin.ticket.index')}}">{{__('Ticket List')}}</a></li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -30,7 +30,7 @@
|
|||
<div class="d-flex justify-content-between">
|
||||
<h5 class="card-title"><i class="fas fa-ticket-alt mr-2"></i>{{__('Ticket List')}}</h5>
|
||||
</div>
|
||||
<a href="{{route("moderator.ticket.category.index")}}"><button class="btn btn-primary float-right">+ {{__("Add Category")}}</button></a>
|
||||
<a href="{{route("admin.ticket.category.index")}}"><button class="btn btn-primary float-right">+ {{__("Add Category")}}</button></a>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -72,7 +72,7 @@
|
|||
processing: true,
|
||||
serverSide: true,
|
||||
stateSave: true,
|
||||
ajax: "{{route('moderator.ticket.datatable')}}",
|
||||
ajax: "{{route('admin.ticket.datatable')}}",
|
||||
order: [[ 4, "desc" ]],
|
||||
columns: [
|
||||
{data: 'category'},
|
|
@ -12,7 +12,7 @@
|
|||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">{{ __('Dashboard') }}</a></li>
|
||||
<li class="breadcrumb-item"><a class="text-muted"
|
||||
href="{{ route('moderator.ticket.index') }}">{{ __('Ticket') }}</a>
|
||||
href="{{ route('admin.ticket.index') }}">{{ __('Ticket') }}</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
@ -74,7 +74,7 @@
|
|||
<p><b>{{__("Created on")}}:</b> {{ $ticket->created_at->diffForHumans() }}</p>
|
||||
@if($ticket->status=='Closed')
|
||||
<form class="d-inline" method="post"
|
||||
action="{{route('moderator.ticket.changeStatus', ['ticket_id' => $ticket->ticket_id ])}}">
|
||||
action="{{route('admin.ticket.changeStatus', ['ticket_id' => $ticket->ticket_id ])}}">
|
||||
{{csrf_field()}}
|
||||
{{method_field("POST") }}
|
||||
<button data-content="{{__("Reopen")}}" data-toggle="popover"
|
||||
|
@ -84,7 +84,7 @@
|
|||
</form>
|
||||
@else
|
||||
<form class="d-inline" method="post"
|
||||
action="{{route('moderator.ticket.changeStatus', ['ticket_id' => $ticket->ticket_id ])}}">
|
||||
action="{{route('admin.ticket.changeStatus', ['ticket_id' => $ticket->ticket_id ])}}">
|
||||
{{csrf_field()}}
|
||||
{{method_field("POST") }}
|
||||
<button data-content="{{__("Close")}}" data-toggle="popover"
|
||||
|
@ -112,15 +112,9 @@
|
|||
src="https://www.gravatar.com/avatar/{{ md5(strtolower($ticket->user->email)) }}?s=25"
|
||||
class="user-image" alt="User Image">
|
||||
<a href="/admin/users/{{$ticket->user->id}}">{{ $ticket->user->name }}</a>
|
||||
@if($ticket->user->role === "member")
|
||||
<span class="badge badge-secondary"> Member </span>
|
||||
@elseif ($ticket->user->role === "client")
|
||||
<span class="badge badge-success"> Client </span>
|
||||
@elseif ($ticket->user->role === "moderator")
|
||||
<span class="badge badge-info"> Moderator </span>
|
||||
@elseif ($ticket->user->role === "admin")
|
||||
<span class="badge badge-danger"> Admin </span>
|
||||
@endif
|
||||
@foreach ($ticket->user->roles as $role)
|
||||
<span style='background-color: {{$role->color}}' class='badge'>{{$role->name}}</span>
|
||||
@endforeach
|
||||
</h5>
|
||||
<span class="badge badge-primary">{{ $ticket->created_at->diffForHumans() }}</span>
|
||||
</div>
|
||||
|
@ -135,15 +129,9 @@
|
|||
src="https://www.gravatar.com/avatar/{{ md5(strtolower($ticketcomment->user->email)) }}?s=25"
|
||||
class="user-image" alt="User Image">
|
||||
<a href="/admin/users/{{$ticketcomment->user->id}}">{{ $ticketcomment->user->name }}</a>
|
||||
@if($ticketcomment->user->role === "member")
|
||||
<span class="badge badge-secondary"> Member </span>
|
||||
@elseif ($ticketcomment->user->role === "client")
|
||||
<span class="badge badge-success"> Client </span>
|
||||
@elseif ($ticketcomment->user->role === "moderator")
|
||||
<span class="badge badge-info"> Moderator </span>
|
||||
@elseif ($ticketcomment->user->role === "admin")
|
||||
<span class="badge badge-danger"> Admin </span>
|
||||
@endif
|
||||
@foreach ($ticketcomment->user->roles as $role)
|
||||
<span style='background-color: {{$role->color}}' class='badge'>{{$role->name}}</span>
|
||||
@endforeach
|
||||
</h5>
|
||||
<span class="badge badge-primary">{{ $ticketcomment->created_at->diffForHumans() }}</span>
|
||||
</div>
|
||||
|
@ -152,7 +140,7 @@
|
|||
</div>
|
||||
@endforeach
|
||||
<div class="comment-form">
|
||||
<form action="{{ route('moderator.ticket.reply')}}" method="POST" class="form">
|
||||
<form action="{{ route('admin.ticket.reply')}}" method="POST" class="form">
|
||||
{!! csrf_field() !!}
|
||||
<input type="hidden" name="ticket_id" value="{{ $ticket->id }}">
|
||||
<div class="form-group{{ $errors->has('ticketcomment') ? ' has-error' : '' }}">
|
|
@ -97,25 +97,15 @@
|
|||
<div class="form-group">
|
||||
<label for="role">{{__('Role')}}</label>
|
||||
<div>
|
||||
<select id="role" name="role"
|
||||
<select id="roles" name="roles"
|
||||
class="custom-select @error('role') is-invalid @enderror"
|
||||
required="required">
|
||||
<option @if($user->role == 'admin') selected @endif class="text-danger"
|
||||
value="admin">
|
||||
{{__(' Administrator')}}
|
||||
</option>
|
||||
<option @if($user->role == 'moderator') selected @endif class="text-info" value="moderator">
|
||||
{{__('Moderator')}}
|
||||
</option>
|
||||
<option @if($user->role == 'client') selected @endif class="text-success"
|
||||
value="client">
|
||||
{{__('Client')}}
|
||||
</option>
|
||||
<option @if($user->role == 'member') selected @endif class="text-secondary"
|
||||
value="member">
|
||||
{{__('Member')}}
|
||||
</option>
|
||||
</select>
|
||||
@foreach($roles as $role)
|
||||
<option style="color: {{$role->color}}"
|
||||
@if(isset($user) && $user->roles->contains($role)) selected
|
||||
@endif value="{{$role->id}}">{{$role->name}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
|
@ -74,18 +74,9 @@
|
|||
<label>{{ __('Role') }}</label>
|
||||
</div>
|
||||
<div class="col-lg-8">
|
||||
<span style="max-width: 250px;"
|
||||
class="d-inline-block text-truncate badge
|
||||
@if ($user->role == 'admin') badge-danger
|
||||
@elseif ($user->role == 'moderator')
|
||||
badge-info
|
||||
@elseif ($user->role == 'client')
|
||||
badge-success
|
||||
@else
|
||||
badge-secondary @endif
|
||||
">
|
||||
{{ $user->role }}
|
||||
</span>
|
||||
@foreach ($user->roles as $role)
|
||||
<span style='background-color: {{$role->color}}' class='badge'>{{$role->name}}</span>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
<div class="card-header text-center">
|
||||
<a href="{{ route('welcome') }}" class="h1 mb-2"><b
|
||||
class="mr-1">{{ config('app.name', 'Laravel') }}</b></a>
|
||||
@if ($website_settings->enable_login_logo)
|
||||
@if ($website_settings->enable_login_logo)
|
||||
<img src="{{ \Illuminate\Support\Facades\Storage::disk('public')->exists('logo.png') ? asset('storage/logo.png') : asset('images/controlpanel_logo.png') }}"
|
||||
alt="{{ config('app.name', 'Controlpanel.gg') }} Logo" style="opacity: .8; max-width:100%; height: 150px; margin-top: 10px;">
|
||||
alt="{{ config('app.name', 'CtrlPanel.gg') }} Logo" style="opacity: .8; max-width:100%; height: 150px; margin-top: 10px;">
|
||||
@endif
|
||||
</div>
|
||||
<div class="card-body pt-0">
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue