From c39d6b18b2094d80743b1e2f6c2aa5b2254e5775 Mon Sep 17 00:00:00 2001 From: IceToast Date: Fri, 10 Feb 2023 00:32:00 +0100 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=94=A5=20Remove=20old=20Settings?= =?UTF-8?q?=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Classes/Settings/Invoices.php | 47 ------ app/Classes/Settings/Language.php | 56 ------- app/Classes/Settings/Misc.php | 107 ------------ app/Classes/Settings/Payments.php | 58 ------- app/Classes/Settings/System.php | 154 ------------------ .../Settings/GeneralSettingsController.php | 85 ---------- 6 files changed, 507 deletions(-) delete mode 100644 app/Classes/Settings/Invoices.php delete mode 100644 app/Classes/Settings/Language.php delete mode 100644 app/Classes/Settings/Misc.php delete mode 100644 app/Classes/Settings/Payments.php delete mode 100644 app/Classes/Settings/System.php delete mode 100644 app/Http/Controllers/Admin/Settings/GeneralSettingsController.php diff --git a/app/Classes/Settings/Invoices.php b/app/Classes/Settings/Invoices.php deleted file mode 100644 index 72a809da..00000000 --- a/app/Classes/Settings/Invoices.php +++ /dev/null @@ -1,47 +0,0 @@ -validate([ - 'logo' => 'nullable|max:10000|mimes:jpg,png,jpeg', - ]); - - $values = [ - //SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form) - 'SETTINGS::INVOICE:COMPANY_NAME' => 'company-name', - 'SETTINGS::INVOICE:COMPANY_ADDRESS' => 'company-address', - 'SETTINGS::INVOICE:COMPANY_PHONE' => 'company-phone', - 'SETTINGS::INVOICE:COMPANY_MAIL' => 'company-mail', - 'SETTINGS::INVOICE:COMPANY_VAT' => 'company-vat', - 'SETTINGS::INVOICE:COMPANY_WEBSITE' => 'company-web', - 'SETTINGS::INVOICE:PREFIX' => 'invoice-prefix', - 'SETTINGS::INVOICE:ENABLED' => 'enable-invoices', - ]; - - foreach ($values as $key => $value) { - $param = $request->get($value); - - Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]); - Cache::forget('setting'.':'.$key); - } - - if ($request->hasFile('logo')) { - $request->file('logo')->storeAs('public', 'logo.png'); - } - - return redirect(route('admin.settings.index').'#invoices')->with('success', __('Invoice settings updated!')); - } -} diff --git a/app/Classes/Settings/Language.php b/app/Classes/Settings/Language.php deleted file mode 100644 index 4e2bc3c2..00000000 --- a/app/Classes/Settings/Language.php +++ /dev/null @@ -1,56 +0,0 @@ -all(), [ - 'autotranslate' => 'string', - 'canClientChangeLanguage' => 'string', - 'defaultLanguage' => 'required|string', - 'languages' => 'required|array', - 'languages.*' => 'required|string', - 'datatable-language' => 'required|string', - ]); - - if ($validator->fails()) { - return redirect(route('admin.settings.index').'#language')->with('error', __('Language settings have not been updated!'))->withErrors($validator); - } - - $values = [ - //SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form) - 'SETTINGS::LOCALE:DEFAULT' => 'defaultLanguage', - 'SETTINGS::LOCALE:DYNAMIC' => 'autotranslate', - 'SETTINGS::LOCALE:CLIENTS_CAN_CHANGE' => 'canClientChangeLanguage', - 'SETTINGS::LOCALE:AVAILABLE' => 'languages', - 'SETTINGS::LOCALE:DATATABLES' => 'datatable-language', - ]; - - foreach ($values as $key => $value) { - $param = $request->get($value); - - if (is_array($param)) { - $param = implode(',', $param); - } - - Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]); - Cache::forget('setting'.':'.$key); - Session::remove('locale'); - } - - return redirect(route('admin.settings.index').'#language')->with('success', __('Language settings updated!')); - } -} diff --git a/app/Classes/Settings/Misc.php b/app/Classes/Settings/Misc.php deleted file mode 100644 index d7563a90..00000000 --- a/app/Classes/Settings/Misc.php +++ /dev/null @@ -1,107 +0,0 @@ -all(), [ - 'icon' => 'nullable|max:10000|mimes:jpg,png,jpeg', - 'favicon' => 'nullable|max:10000|mimes:ico', - 'discord-bot-token' => 'nullable|string', - 'discord-client-id' => 'nullable|string', - 'discord-client-secret' => 'nullable|string', - 'discord-guild-id' => 'nullable|string', - 'discord-invite-url' => 'nullable|string', - 'discord-role-id' => 'nullable|string', - 'recaptcha-site-key' => 'nullable|string', - 'recaptcha-secret-key' => 'nullable|string', - 'enable-recaptcha' => 'nullable|string', - 'mailservice' => 'nullable|string', - 'mailhost' => 'nullable|string', - 'mailport' => 'nullable|string', - 'mailusername' => 'nullable|string', - 'mailpassword' => 'nullable|string', - 'mailencryption' => 'nullable|string', - 'mailfromadress' => 'nullable|string', - 'mailfromname' => 'nullable|string', - 'enable_referral' => 'nullable|string', - 'referral_reward' => 'nullable|numeric', - 'referral_allowed' => 'nullable|string', - 'always_give_commission' => 'nullable|string', - 'referral_percentage' => 'nullable|numeric', - 'referral_mode' => 'nullable|string', - 'ticket_enabled' => 'nullable|string', - 'ticket_notify' => 'string', - ]); - - $validator->after(function ($validator) use ($request) { - // if enable-recaptcha is true then recaptcha-site-key and recaptcha-secret-key must be set - if ($request->get('enable-recaptcha') == 'true' && (! $request->get('recaptcha-site-key') || ! $request->get('recaptcha-secret-key'))) { - $validator->errors()->add('recaptcha-site-key', 'The site key is required if recaptcha is enabled.'); - $validator->errors()->add('recaptcha-secret-key', 'The secret key is required if recaptcha is enabled.'); - } - }); - - if ($validator->fails()) { - return redirect(route('admin.settings.index').'#misc')->with('error', __('Misc settings have not been updated!'))->withErrors($validator) - ->withInput(); - } - - if ($request->hasFile('icon')) { - $request->file('icon')->storeAs('public', 'icon.png'); - } - if ($request->hasFile('favicon')) { - $request->file('favicon')->storeAs('public', 'favicon.ico'); - } - - $values = [ - 'SETTINGS::DISCORD:BOT_TOKEN' => 'discord-bot-token', - 'SETTINGS::DISCORD:CLIENT_ID' => 'discord-client-id', - 'SETTINGS::DISCORD:CLIENT_SECRET' => 'discord-client-secret', - 'SETTINGS::DISCORD:GUILD_ID' => 'discord-guild-id', - 'SETTINGS::DISCORD:INVITE_URL' => 'discord-invite-url', - 'SETTINGS::DISCORD:ROLE_ID' => 'discord-role-id', - 'SETTINGS::RECAPTCHA:SITE_KEY' => 'recaptcha-site-key', - 'SETTINGS::RECAPTCHA:SECRET_KEY' => 'recaptcha-secret-key', - 'SETTINGS::RECAPTCHA:ENABLED' => 'enable-recaptcha', - 'SETTINGS::MAIL:MAILER' => 'mailservice', - 'SETTINGS::MAIL:HOST' => 'mailhost', - 'SETTINGS::MAIL:PORT' => 'mailport', - 'SETTINGS::MAIL:USERNAME' => 'mailusername', - 'SETTINGS::MAIL:PASSWORD' => 'mailpassword', - 'SETTINGS::MAIL:ENCRYPTION' => 'mailencryption', - 'SETTINGS::MAIL:FROM_ADDRESS' => 'mailfromadress', - 'SETTINGS::MAIL:FROM_NAME' => 'mailfromname', - 'SETTINGS::REFERRAL::ENABLED' => 'enable_referral', - 'SETTINGS::REFERRAL::REWARD' => 'referral_reward', - 'SETTINGS::REFERRAL::ALLOWED' => 'referral_allowed', - 'SETTINGS::REFERRAL:MODE' => 'referral_mode', - 'SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION' => 'always_give_commission', - 'SETTINGS::REFERRAL:PERCENTAGE' => 'referral_percentage', - 'SETTINGS::TICKET:ENABLED' => 'ticket_enabled', - 'SETTINGS::TICKET:NOTIFY' => 'ticket_notify', - - ]; - - foreach ($values as $key => $value) { - $param = $request->get($value); - - Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]); - Cache::forget('setting'.':'.$key); - } - - return redirect(route('admin.settings.index').'#misc')->with('success', __('Misc settings updated!')); - } -} diff --git a/app/Classes/Settings/Payments.php b/app/Classes/Settings/Payments.php deleted file mode 100644 index 0139abc6..00000000 --- a/app/Classes/Settings/Payments.php +++ /dev/null @@ -1,58 +0,0 @@ -all(), [ - 'paypal-client_id' => 'nullable|string', - 'paypal-client-secret' => 'nullable|string', - 'paypal-sandbox-secret' => 'nullable|string', - 'stripe-secret-key' => 'nullable|string', - 'stripe-endpoint-secret' => 'nullable|string', - 'stripe-test-secret-key' => 'nullable|string', - 'stripe-test-endpoint-secret' => 'nullable|string', - 'stripe-methods' => 'nullable|string', - 'sales-tax' => 'nullable|numeric', - ]); - if ($validator->fails()) { - return redirect(route('admin.settings.index').'#payment')->with('error', __('Payment settings have not been updated!'))->withErrors($validator) - ->withInput(); - } - - $values = [ - //SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form) - 'SETTINGS::PAYMENTS:PAYPAL:SECRET' => 'paypal-client-secret', - 'SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID' => 'paypal-client-id', - 'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET' => 'paypal-sandbox-secret', - 'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID' => 'paypal-sandbox-id', - 'SETTINGS::PAYMENTS:STRIPE:SECRET' => 'stripe-secret', - 'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET' => 'stripe-endpoint-secret', - 'SETTINGS::PAYMENTS:STRIPE:TEST_SECRET' => 'stripe-test-secret', - 'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET' => 'stripe-endpoint-test-secret', - 'SETTINGS::PAYMENTS:STRIPE:METHODS' => 'stripe-methods', - 'SETTINGS::PAYMENTS:SALES_TAX' => 'sales-tax', - ]; - - foreach ($values as $key => $value) { - $param = $request->get($value); - - Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]); - Cache::forget('setting'.':'.$key); - } - - return redirect(route('admin.settings.index').'#payment')->with('success', __('Payment settings updated!')); - } -} diff --git a/app/Classes/Settings/System.php b/app/Classes/Settings/System.php deleted file mode 100644 index e213c794..00000000 --- a/app/Classes/Settings/System.php +++ /dev/null @@ -1,154 +0,0 @@ -failed()) { - return redirect()->back()->with('error', __('Your Key or URL is not correct')); - } - - return redirect()->back()->with('success', __('Everything is good!')); - } - - public function updateSettings(Request $request) - { - $validator = Validator::make($request->all(), [ - 'register-ip-check' => 'string', - 'server-create-charge-first-hour' => 'string', - 'credits-display-name' => 'required|string', - 'allocation-limit' => 'required|min:0|integer', - 'force-email-verification' => 'string', - 'force-discord-verification' => 'string', - 'initial-credits' => 'required|min:0|integer', - 'initial-server-limit' => 'required|min:0|integer', - 'credits-reward-amount-discord' => 'required|min:0|integer', - 'credits-reward-amount-email' => 'required|min:0|integer', - 'server-limit-discord' => 'required|min:0|integer', - 'server-limit-email' => 'required|min:0|integer', - 'server-limit-purchase' => 'required|min:0|integer', - 'pterodactyl-api-key' => 'required|string', - 'pterodactyl-url' => 'required|string', - 'per-page-limit' => 'required|min:0|integer', - 'pterodactyl-admin-api-key' => 'required|string', - 'enable-upgrades' => 'string', - 'enable-disable-servers' => 'string', - 'enable-disable-new-users' => 'string', - 'show-imprint' => 'string', - 'show-privacy' => 'string', - 'show-tos' => 'string', - 'alert-enabled' => 'string', - 'alter-type' => 'string', - 'alert-message' => 'string|nullable', - 'motd-enabled' => 'string', - 'usefullinks-enabled' => 'string', - 'motd-message' => 'string|nullable', - 'seo-title' => 'string|nullable', - 'seo-description' => 'string|nullable', - ]); - - $validator->after(function ($validator) use ($request) { - // if enable-recaptcha is true then recaptcha-site-key and recaptcha-secret-key must be set - if ($request->get('enable-upgrades') == 'true' && (! $request->get('pterodactyl-admin-api-key'))) { - $validator->errors()->add('pterodactyl-admin-api-key', 'The admin api key is required when upgrades are enabled.'); - } - }); - - if ($validator->fails()) { - return redirect(route('admin.settings.index').'#system')->with('error', __('System settings have not been updated!'))->withErrors($validator) - ->withInput(); - } - - // update Icons from request - $this->updateIcons($request); - - $values = [ - - "SETTINGS::SYSTEM:REGISTER_IP_CHECK" => "register-ip-check", - "SETTINGS::SYSTEM:SERVER_CREATE_CHARGE_FIRST_HOUR" => "server-create-charge-first-hour", - "SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME" => "credits-display-name", - "SETTINGS::SERVER:ALLOCATION_LIMIT" => "allocation-limit", - "SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER" => "minimum-credits", - "SETTINGS::USER:FORCE_DISCORD_VERIFICATION" => "force-discord-verification", - "SETTINGS::USER:FORCE_EMAIL_VERIFICATION" => "force-email-verification", - "SETTINGS::USER:INITIAL_CREDITS" => "initial-credits", - "SETTINGS::USER:INITIAL_SERVER_LIMIT" => "initial-server-limit", - "SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD" => "credits-reward-amount-discord", - "SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL" => "credits-reward-amount-email", - "SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD" => "server-limit-discord", - "SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL" => "server-limit-email", - "SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE" => "server-limit-purchase", - "SETTINGS::MISC:PHPMYADMIN:URL" => "phpmyadmin-url", - "SETTINGS::SYSTEM:PTERODACTYL:URL" => "pterodactyl-url", - 'SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT' => "per-page-limit", - "SETTINGS::SYSTEM:PTERODACTYL:TOKEN" => "pterodactyl-api-key", - "SETTINGS::SYSTEM:ENABLE_LOGIN_LOGO" => "enable-login-logo", - "SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN" => "pterodactyl-admin-api-key", - "SETTINGS::SYSTEM:ENABLE_UPGRADE" => "enable-upgrade", - "SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS" => "enable-disable-servers", - "SETTINGS::SYSTEM:CREATION_OF_NEW_USERS" => "enable-disable-new-users", - "SETTINGS::SYSTEM:SHOW_IMPRINT" => "show-imprint", - "SETTINGS::SYSTEM:SHOW_PRIVACY" => "show-privacy", - "SETTINGS::SYSTEM:SHOW_TOS" => "show-tos", - "SETTINGS::SYSTEM:ALERT_ENABLED" => "alert-enabled", - "SETTINGS::SYSTEM:ALERT_TYPE" => "alert-type", - "SETTINGS::SYSTEM:ALERT_MESSAGE" => "alert-message", - "SETTINGS::SYSTEM:THEME" => "theme", - "SETTINGS::SYSTEM:MOTD_ENABLED" => "motd-enabled", - "SETTINGS::SYSTEM:MOTD_MESSAGE" => "motd-message", - "SETTINGS::SYSTEM:USEFULLINKS_ENABLED" => "usefullinks-enabled", - "SETTINGS::SYSTEM:SEO_TITLE" => "seo-title", - "SETTINGS::SYSTEM:SEO_DESCRIPTION" => "seo-description", - ]; - - foreach ($values as $key => $value) { - $param = $request->get($value); - - Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]); - Cache::forget('setting'.':'.$key); - } - - //SET THEME - $theme = $request->get('theme'); - Theme::set($theme); - - - return redirect(route('admin.settings.index').'#system')->with('success', __('System settings updated!')); - } - - private function updateIcons(Request $request) - { - $request->validate([ - 'icon' => 'nullable|max:10000|mimes:jpg,png,jpeg', - 'logo' => 'nullable|max:10000|mimes:jpg,png,jpeg', - 'favicon' => 'nullable|max:10000|mimes:ico', - ]); - - if ($request->hasFile('icon')) { - $request->file('icon')->storeAs('public', 'icon.png'); - } - if ($request->hasFile('logo')) { - $request->file('logo')->storeAs('public', 'logo.png'); - } - if ($request->hasFile('favicon')) { - $request->file('favicon')->storeAs('public', 'favicon.ico'); - } - } -} diff --git a/app/Http/Controllers/Admin/Settings/GeneralSettingsController.php b/app/Http/Controllers/Admin/Settings/GeneralSettingsController.php deleted file mode 100644 index 8acb438e..00000000 --- a/app/Http/Controllers/Admin/Settings/GeneralSettingsController.php +++ /dev/null @@ -1,85 +0,0 @@ -