芝麻web文件管理V1.00
编辑当前文件:/home/lekhnath/silverray.com.au/oldsite/app/Helpers/helper.php
getClientOriginalExtension(); $file_name = 'wsus-img' . date('-Y-m-d-h-i-s-') . rand(999, 9999) . '.' . $extention; $file_name = $path . $file_name; $file->move(public_path($path), $file_name); try { if ($oldFile && File::exists(public_path($oldFile))) { unlink(public_path($oldFile)); } if ($optimize) { ImageOptimizer::optimize(public_path($file_name)); } } catch (Exception $e) { Log::info($e->getMessage()); } return $file_name; } // file upload method if (!function_exists('allLanguages')) { function allLanguages() { $allLanguages = Cache::rememberForever('allLanguages', function () { return Language::select('code', 'name', 'direction', 'status')->get(); }); if (!$allLanguages) { $allLanguages = Language::select('code', 'name', 'direction', 'status')->get(); } return $allLanguages; } } if (! function_exists('getSessionLanguage')) { function getSessionLanguage(): string { if (! session()->has('lang')) { $is_default = Language::where('is_default', 1)->first(); if ($is_default) { $lang = session()->put('lang', $is_default->code); session()->forget('text_direction'); session()->put('text_direction', $is_default->direction); } else { $lang = session()->put('lang', config('app.locale')); session()->forget('text_direction'); session()->put('text_direction', 'ltr'); } } $lang = Session::get('lang'); return $lang; } } if (!function_exists('setLanguage')) { function setLanguage($code) { $lang = Language::whereCode($code)->first(); if (session()->has('lang')) { sessionForgetLangChang(); } if ($lang) { session()->put('lang', $lang->code); session()->put('text_direction', $lang->direction); return true; } session()->put('lang', config('app.locale')); return false; } } if (!function_exists('sessionForgetLangChang')) { function sessionForgetLangChang() { $sessionId = session()->getId(); $maniMenuKey = 'mainMenuGetBySlug_' . $sessionId; $footerMenuKey = 'footerMenuGetBySlug_' . $sessionId; $footerBottomMenuKey = 'footerBottomMenuGetBySlug_' . $sessionId; session()->forget('lang'); session()->forget('text_direction'); cache()->forget($maniMenuKey); cache()->forget($footerMenuKey); cache()->forget($footerBottomMenuKey); } } if (!function_exists('allCurrencies')) { function allCurrencies() { $allCurrencies = Cache::rememberForever('allCurrencies', function () { return MultiCurrency::all(); }); if (!$allCurrencies) { $allCurrencies = MultiCurrency::all(); } return $allCurrencies; } } if (!function_exists('getSessionCurrency')) { function getSessionCurrency(): string { if (!session()->has('currency_code') || !session()->has('currency_rate') || !session()->has('currency_position')) { $currency = allCurrencies()->where('is_default', 'yes')->first(); session()->put('currency_code', $currency->currency_code); session()->forget('currency_position'); session()->put('currency_position', $currency->currency_position); session()->forget('currency_icon'); session()->put('currency_icon', $currency->currency_icon); session()->forget('currency_rate'); session()->put('currency_rate', $currency->currency_rate); } return Session::get('currency_code'); } } function admin_lang() { return Session::get('admin_lang'); } // calculate currency function currency($price) { // currency information will be loaded by Session value $currency_icon = Session::get('currency_icon', '$'); $currency_code = Session::get('currency_code', 'USD'); $currency_rate = Session::get('currency_rate', 1.00); $currency_position = Session::get('currency_position', 'before_price'); $price = $price * $currency_rate; $price = number_format($price, 2, '.', ','); if ($currency_position == 'before_price') { $price = $currency_icon . $price; } elseif ($currency_position == 'before_price_with_space') { $price = $currency_icon . ' ' . $price; } elseif ($currency_position == 'after_price') { $price = $price . $currency_icon; } elseif ($currency_position == 'after_price_with_space') { $price = $price . ' ' . $currency_icon; } else { $price = $currency_icon . $price; } return $price; } // calculate currency // custom decode and encode input value function html_decode($text) { $after_decode = htmlspecialchars_decode($text, ENT_QUOTES); return $after_decode; } if (!function_exists('currectUrlWithQuery')) { function currectUrlWithQuery($code) { $currentUrlWithQuery = request()->fullUrl(); // Parse the query string $parsedQuery = parse_url($currentUrlWithQuery, PHP_URL_QUERY); // Check if the 'code' parameter already exists $codeExists = false; if ($parsedQuery) { parse_str($parsedQuery, $queryArray); $codeExists = isset($queryArray['code']); } if ($codeExists) { $updatedUrlWithQuery = preg_replace('/(\?|&)code=[^&]*/', '$1code=' . $code, $currentUrlWithQuery); } else { $updatedUrlWithQuery = $currentUrlWithQuery . ($parsedQuery ? '&' : '?') . http_build_query(['code' => $code]); } return $updatedUrlWithQuery; } } if (!function_exists('checkAdminHasPermission')) { function checkAdminHasPermission($permission): bool { return Auth::guard('admin')->user()->can($permission) ? true : false; } } if (!function_exists('checkAdminHasPermissionAndThrowException')) { function checkAdminHasPermissionAndThrowException($permission) { if (!checkAdminHasPermission($permission)) { if (request()->ajax()) { throw new AccessPermissionDeniedException('Permission Denied!'); } throw new AccessPermissionDeniedException(); } } } if (!function_exists('getSettingStatus')) { function getSettingStatus($key) { if (Cache::has('setting')) { $setting = Cache::get('setting'); if (!is_null($key)) { return $setting->$key == 'active' ? true : false; } } else { try { return Setting::where('key', $key)->first()?->value == 'active' ? true : false; } catch (Exception $e) { Log::info($e->getMessage()); return false; } } return false; } } if (!function_exists('checkCrentials')) { function checkCrentials() { if (Cache::has('setting') && $settings = Cache::get('setting')) { $checkCrentials = []; if ($settings->mail_host == 'mail_host' || $settings->mail_username == 'mail_username' || $settings->mail_password == 'mail_password' || $settings->mail_host == '' || $settings->mail_port == '' || $settings->mail_username == '' || $settings->mail_password == '') { $checkCrentials[] = (object) [ 'status' => true, 'message' => __('Mail credentails not found'), 'description' => __('This may create a problem while sending email. Please fill up the credential to avoid any problem.'), 'route' => 'admin.email-configuration', ]; } if ($settings->recaptcha_status !== 'inactive' && ($settings->recaptcha_site_key == 'recaptcha_site_key' || $settings->recaptcha_secret_key == 'recaptcha_secret_key' || $settings->recaptcha_site_key == '' || $settings->recaptcha_secret_key == '')) { $checkCrentials[] = (object) [ 'status' => true, 'message' => __('Google Recaptcha credentails not found'), 'description' => __('This may create a problem while submitting any form submission from website. Please fill up the credential from google account.'), 'route' => 'admin.crediential-setting', ]; } if ($settings->googel_tag_status !== 'inactive' && ($settings->googel_tag_id == 'googel_tag_id' || $settings->googel_tag_id == '')) { $checkCrentials[] = (object) [ 'status' => true, 'message' => __('Google Tag credentails not found'), 'description' => __('This may create a problem with analyzing your website through Google Tag Manager. Please fill in the credentials to avoid any issues.'), 'route' => 'admin.crediential-setting', ]; } if ($settings->pixel_status !== 'inactive' && ($settings->pixel_app_id == 'pixel_app_id' || $settings->pixel_app_id == '')) { $checkCrentials[] = (object) [ 'status' => true, 'message' => __('Facebook Pixel credentails not found'), 'description' => __('This may create a problem to analyze your website. Please fill up the credential to avoid any problem.'), 'route' => 'admin.crediential-setting', ]; } if ($settings->google_login_status !== 'inactive' && ($settings->gmail_client_id == 'google_client_id' || $settings->gmail_secret_id == 'google_secret_id' || $settings->gmail_client_id == '' || $settings->gmail_secret_id == '')) { $checkCrentials[] = (object) [ 'status' => true, 'message' => __('Google login credentails not found'), 'description' => __('This may create a problem while logging in using google. Please fill up the credential to avoid any problem.'), 'route' => 'admin.crediential-setting', ]; } if ($settings->google_analytic_status !== 'inactive' && ($settings->google_analytic_id == 'google_analytic_id' || $settings->google_analytic_id == '')) { $checkCrentials[] = (object) [ 'status' => true, 'message' => __('Google Analytic credentails not found'), 'description' => __('This may create a problem to analyze your website. Please fill up the credential to avoid any problem.'), 'route' => 'admin.crediential-setting', ]; } if ($settings->tawk_status !== 'inactive' && ($settings->tawk_chat_link == 'tawk_chat_link' || $settings->tawk_chat_link == '')) { $checkCrentials[] = (object) [ 'status' => true, 'message' => __('Tawk Chat Link credentails not found'), 'description' => __('This may create a problem to analyze your website. Please fill up the credential to avoid any problem.'), 'route' => 'admin.crediential-setting', ]; } if ($settings->pusher_status !== 'inactive' && ($settings->pusher_app_id == 'pusher_app_id' || $settings->pusher_app_key == 'pusher_app_key' || $settings->pusher_app_secret == 'pusher_app_secret' || $settings->pusher_app_cluster == 'pusher_app_cluster' || $settings->pusher_app_id == '' || $settings->pusher_app_key == '' || $settings->pusher_app_secret == '' || $settings->pusher_app_cluster == '')) { $checkCrentials[] = (object) [ 'status' => true, 'message' => __('Pusher credentails not found'), 'description' => __('This may create a problem while logging in using google. Please fill up the credential to avoid any problem.'), 'route' => 'admin.crediential-setting', ]; } return (object) $checkCrentials; } if (!Cache::has('basic_payment') && Module::isEnabled('BasicPayment')) { Cache::rememberForever('basic_payment', function () { $payment_info = BasicPayment::get(); $basic_payment = []; foreach ($payment_info as $payment_item) { $basic_payment[$payment_item->key] = $payment_item->value; } return (object) $basic_payment; }); } if (Cache::has('basic_payment') && $basicPayment = Cache::get('basic_payment')) { if ($basicPayment->stripe_status !== 'inactive' && ($basicPayment->stripe_key == 'stripe_key' || $basicPayment->stripe_secret == 'stripe_secret' || $basicPayment->stripe_key == '' || $basicPayment->stripe_secret == '')) { return (object) [ 'status' => true, 'message' => __('Stripe credentails not found'), 'description' => __('This may create a problem while making payment. Please fill up the credential to avoid any problem.'), 'route' => 'admin.basicpayment', ]; } if ($basicPayment->paypal_status !== 'inactive' && ($basicPayment->paypal_client_id == 'paypal_client_id' || $basicPayment->paypal_secret_key == 'paypal_secret_key' || $basicPayment->paypal_client_id == '' || $basicPayment->paypal_secret_key == '')) { return (object) [ 'status' => true, 'message' => __('Paypal credentails not found'), 'description' => __('This may create a problem while making payment. Please fill up the credential to avoid any problem.'), 'route' => 'admin.basicpayment', ]; } } if (!Cache::has('payment_setting') && Module::isEnabled('PaymentGateway')) { Cache::rememberForever('payment_setting', function () { $payment_info = PaymentGateway::get(); $payment_setting = []; foreach ($payment_info as $payment_item) { $payment_setting[$payment_item->key] = $payment_item->value; } return (object) $payment_setting; }); } if (Cache::has('payment_setting') && $paymentAddons = Cache::get('payment_setting')) { if ($paymentAddons->razorpay_status !== 'inactive' && ($paymentAddons->razorpay_key == 'razorpay_key' || $paymentAddons->razorpay_secret == 'razorpay_secret' || $paymentAddons->razorpay_key == '' || $paymentAddons->razorpay_secret == '')) { return (object) [ 'status' => true, 'message' => __('Razorpay credentails not found'), 'description' => __('This may create a problem while making payment. Please fill up the credential to avoid any problem.'), 'route' => 'admin.paymentgateway', ]; } if ($paymentAddons->flutterwave_status !== 'inactive' && ($paymentAddons->flutterwave_public_key == 'flutterwave_public_key' || $paymentAddons->flutterwave_secret_key == 'flutterwave_secret_key' || $paymentAddons->flutterwave_public_key == '' || $paymentAddons->flutterwave_secret_key == '')) { return (object) [ 'status' => true, 'message' => __('Flutterwave credentails not found'), 'description' => __('This may create a problem while making payment. Please fill up the credential to avoid any problem.'), 'route' => 'admin.paymentgateway', ]; } if ($paymentAddons->paystack_status !== 'inactive' && ($paymentAddons->paystack_public_key == 'paystack_public_key' || $paymentAddons->paystack_secret_key == 'paystack_secret_key' || $paymentAddons->paystack_public_key == '' || $paymentAddons->paystack_secret_key == '')) { return (object) [ 'status' => true, 'message' => __('Paystack credentails not found'), 'description' => __('This may create a problem while making payment. Please fill up the credential to avoid any problem.'), 'route' => 'admin.paymentgateway', ]; } if ($paymentAddons->mollie_status !== 'inactive' && ($paymentAddons->mollie_key == 'mollie_key' || $paymentAddons->mollie_key == '')) { return (object) [ 'status' => true, 'message' => __('Mollie credentails not found'), 'description' => __('This may create a problem while making payment. Please fill up the credential to avoid any problem.'), 'route' => 'admin.paymentgateway', ]; } if ($paymentAddons->instamojo_status !== 'inactive' && ($paymentAddons->instamojo_api_key == 'instamojo_api_key' || $paymentAddons->instamojo_auth_token == 'instamojo_auth_token' || $paymentAddons->instamojo_api_key == '' || $paymentAddons->instamojo_auth_token == '')) { return (object) [ 'status' => true, 'message' => __('Instamojo credentails not found'), 'description' => __('This may create a problem while making payment. Please fill up the credential to avoid any problem.'), 'route' => 'admin.paymentgateway', ]; } } return false; } } if (!function_exists('isRoute')) { function isRoute(string | array $route, string $returnValue = null) { if (is_array($route)) { foreach ($route as $value) { if (Route::is($value)) { return is_null($returnValue) ? true : $returnValue; } } return false; } if (Route::is($route)) { return is_null($returnValue) ? true : $returnValue; } return false; } } if (!function_exists('routeList')) { function routeList(): object { $route_list = [ (object) ['name' => __('Dashboard'), 'route' => route('admin.dashboard'), 'permission' => 'dashboard.view'], (object) ['name' => __('Agent Property'), 'route' => route('admin.agent-property'), 'permission' => 'property.view'], (object) ['name' => __('My Property'), 'route' => route('admin.property.index'), 'permission' => 'property.view'], (object) ['name' => __('Amenity'), 'route' => route('admin.amenity.index'), 'permission' => 'property.amenity.view'], (object) ['name' => __('Nearest Location'), 'route' => route('admin.nearest-location.index'), 'permission' => 'nearest.location.view'], (object) ['name' => __('Property Type'), 'route' => route('admin.property-type.index'), 'permission' => 'property.type.view'], (object) ['name' => __('Property Purpose'), 'route' => route('admin.property-purpose.index'), 'permission' => 'property.view'], (object) ['name' => __('Property Review'), 'route' => route('admin.review'), 'permission' => 'property.view'], (object) ['name' => __('Country'), 'route' => route('admin.country.index'), 'permission' => 'country.view'], (object) ['name' => __('Country State'), 'route' => route('admin.country-state.index'), 'permission' => 'state.view'], (object) ['name' => __('City'), 'route' => route('admin.city.index'), 'permission' => 'city.view'], (object) ['name' => __('Faqs'), 'route' => route('admin.faq.index'), 'permission' => 'faq.view'], (object) ['name' => __('Custom Pages'), 'route' => route('admin.custom-page.index'), 'permission' => 'custom.page.view'], (object) ['name' => __('Terms and Condition'), 'route' => route('admin.terms-and-condition'), 'permission' => 'terms.and.condition.view'], (object) ['name' => __('Privacy Policy'), 'route' => route('admin.privacy-policy'), 'permission' => 'privacy.policy.view'], (object) ['name' => __('Contact Us Page'), 'route' => route('admin.contact-us-page.index'), 'permission' => 'contact.us.view'], (object) ['name' => __('Slider Section'), 'route' => route('admin.slider.index'), 'permission' => 'slider.view'], (object) ['name' => __('Testimonial Section'), 'route' => route('admin.testimonial.index'), 'permission' => 'testimonial.view'], (object) ['name' => __('Our Team Section'), 'route' => route('admin.ourteam.index'), 'permission' => 'team.view'], (object) ['name' => __('Service Section'), 'route' => route('admin.service.index'), 'permission' => 'service.view'], (object) ['name' => __('Counter Section'), 'route' => route('admin.counter'), 'permission' => 'counter.view'], (object) ['name' => __('About Us Section'), 'route' => route('admin.about-us.index'), 'permission' => 'about.us.view'], (object) ['name' => __('Contact Information Section'), 'route' => route('admin.contact-information.index'), 'permission' => 'contact.information.view'], (object) ['name' => __('Blog Category'), 'route' => route('admin.blog-category.index'), 'permission' => 'blog.category.view'], (object) ['name' => __('Blog'), 'route' => route('admin.blogs.index'), 'permission' => 'blog.view'], (object) ['name' => __('Blog Comment'), 'route' => route('admin.blog-comment.index'), 'permission' => 'blog.comment.view'], (object) ['name' => __('Post Category'), 'route' => route('admin.blog-category.index'), 'permission' => 'blog.category.view'], (object) ['name' => __('Post'), 'route' => route('admin.blogs.index'), 'permission' => 'blog.view'], (object) ['name' => __('Post Comment'), 'route' => route('admin.blog-comment.index'), 'permission' => 'blog.comment.view'], (object) ['name' => __('Subscription Plan'), 'route' => route('admin.subscription-plan.index'), 'permission' => 'subscription.view'], (object) ['name' => __('Subscription History'), 'route' => route('admin.subscription-history'), 'permission' => 'subscription.view'], (object) ['name' => __('Transaction History'), 'route' => route('admin.plan-transaction-history'), 'permission' => 'subscription.view'], (object) ['name' => __('Pending Transaction'), 'route' => route('admin.pending-plan-transaction'), 'permission' => 'subscription.view'], (object) ['name' => __('Assign Plan'), 'route' => route('admin.assign-plan'), 'permission' => 'subscription.view'], (object) ['name' => __('Menu Builder'), 'route' => route('admin.custom-menu.index'), 'permission' => 'menu.view'], (object) ['name' => __('Career'), 'route' => route('admin.career.index'), 'permission' => 'career.view'], (object) ['name' => __('Job Offer'), 'route' => route('admin.career.index'), 'permission' => 'career.view'], (object) ['name' => __('Social Link'), 'route' => route('admin.social-link.index'), 'permission' => 'social.link.management'], (object) ['name' => __('All Users'), 'route' => route('admin.all-customers'), 'permission' => 'customer.view'], (object) ['name' => __('Active Users'), 'route' => route('admin.active-customers'), 'permission' => 'customer.view'], (object) ['name' => __('Non verified Users'), 'route' => route('admin.non-verified-customers'), 'permission' => 'customer.view'], (object) ['name' => __('Banned Users'), 'route' => route('admin.banned-customers'), 'permission' => 'customer.view'], (object) ['name' => __('Send bulk mail Users'), 'route' => route('admin.send-bulk-mail'), 'permission' => 'customer.view'], (object) ['name' => __('Subscriber List'), 'route' => route('admin.subscriber-list'), 'permission' => 'newsletter.view'], (object) ['name' => __('Subscriber Send bulk mail'), 'route' => route('admin.send-mail-to-newsletter'), 'permission' => 'newsletter.view'], (object) ['name' => __('Contact Messages'), 'route' => route('admin.contact-messages'), 'permission' => 'contect.message.view'], (object) ['name' => __('General Settings'), 'route' => route('admin.general-setting'), 'permission' => 'setting.view', 'tab'=>'general_tab'], (object) ['name' => __('Credential Settings'), 'route' => route('admin.crediential-setting'), 'permission' => 'setting.view'], (object) ['name' => __('Social Login'), 'route' => route('admin.crediential-setting'), 'permission' => 'setting.view'], (object) ['name' => __('Email Configuration'), 'route' => route('admin.email-configuration'), 'permission' => 'setting.view'], (object) ['name' => __('SEO Setup'), 'route' => route('admin.seo-setting'), 'permission' => 'setting.view'], (object) ['name' => __('Clear cache'), 'route' => route('admin.cache-clear'), 'permission' => 'setting.view'], (object) ['name' => __('Database Clear'), 'route' => route('admin.database-clear'), 'permission' => 'setting.view'], (object) ['name' => __('System Update'), 'route' => route('admin.system-update.index'), 'permission' => 'setting.view'], (object) ['name' => __('Manage Addons'), 'route' => route('admin.addons.view'), 'permission' => 'setting.view'], (object) ['name' => __('Manage Language'), 'route' => route('admin.languages.index'), 'permission' => 'language.view'], (object) ['name' => __('Basic Payment'), 'route' => route('admin.basicpayment'), 'permission' => 'basic.payment.view'], (object) ['name' => __('Multi Currency'), 'route' => route('admin.currency.index'), 'permission' => 'currency.view'], (object) ['name' => __('Manage Admin'), 'route' => route('admin.admin.index'), 'permission' => 'admin.view'], (object) ['name' => __('Role & Permissions'), 'route' => route('admin.role.index'), 'permission' => 'role.view'], ]; usort($route_list, function ($a, $b) { return strcmp($a->name, $b->name); }); return (object) $route_list; } }