shell bypass 403

UnknownSec Shell


name : StatisticSettingsController.php
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\HomePageStatistic;
use App\Models\HomeSection;
use App\Models\Setting;
use App\Models\Translation\HomePageStatisticTranslation;
use App\Models\Translation\SettingTranslation;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class StatisticSettingsController extends Controller
{

    public function index()
    {
        $this->authorize('admin_settings_personalization');

        removeContentLocale();

        $name = 'statistics';
        $statistics = HomePageStatistic::orderBy('order', 'asc')->get();
        $settings = Setting::where('name', $name)->first();

        $values = null;

        if (!empty($settings)) {
            if (!empty($settings->value)) {
                $values = json_decode($settings->value, true);
            }
        }

        $data = [
            'pageTitle' => trans('admin/main.statistics'),
            'statistics' => $statistics,
            'values' => $values,
            'name' => 'statistics'
        ];

        return view('admin.settings.personalization', $data);
    }

    public function store(Request $request)
    {
        $this->authorize('admin_settings_personalization');
        $name = 'statistics';
        $page = 'personalization';

        $values = $request->get('value', null);

        if (!empty($values)) {
            $locale = Setting::$defaultSettingsLocale; // default is "en"

            $values = array_filter($values, function ($val) {
                if (is_array($val)) {
                    return array_filter($val);
                } else {
                    return !empty($val);
                }
            });

            $values = json_encode($values);
            $values = str_replace('record', rand(1, 600), $values);

            $settings = Setting::updateOrCreate(
                ['name' => $name],
                [
                    'page' => $page,
                    'updated_at' => time(),
                ]
            );

            SettingTranslation::updateOrCreate(
                [
                    'setting_id' => $settings->id,
                    'locale' => mb_strtolower($locale)
                ],
                [
                    'value' => $values,
                ]
            );

            cache()->forget('settings.' . $name);
        }


        return redirect()->back();
    }

    public function getForm()
    {
        $this->authorize('admin_settings_personalization');

        $data = [
            'locale' => mb_strtolower(app()->getLocale())
        ];

        $html = (string)view()->make('admin.settings.personalization.statistic_modal', $data);

        return response()->json([
            'code' => 200,
            'html' => $html,
        ]);
    }

    public function storeItem(Request $request)
    {
        $this->authorize('admin_settings_personalization');

        $data = $request->all();

        $validator = Validator::make($data, [
            "title" => "required",
            "description" => "required",
            "color" => "required",
            "icon" => "required",
            "count" => "required",
        ]);

        if ($validator->fails()) {
            return response([
                'code' => 422,
                'errors' => $validator->errors(),
            ], 422);
        }

        $order = HomePageStatistic::query()->count() + 1;

        $item = HomePageStatistic::query()->create([
            "icon" => $data['icon'],
            "color" => $data['color'],
            "count" => $data['count'],
            "order" => $order,
            "created_at" => time(),
        ]);

        HomePageStatisticTranslation::query()->updateOrCreate([
            'home_page_statistic_id' => $item->id,
            'locale' => mb_strtolower($data['locale'])
        ], [
            'title' => $data['title'],
            'description' => $data['description'],
        ]);

        return response()->json([
            'code' => 200
        ]);
    }

    public function editItem(Request $request, $id)
    {
        $this->authorize('admin_settings_personalization');

        $statistic = HomePageStatistic::findOrFail($id);

        $locale = $request->get('locale', app()->getLocale());
        storeContentLocale($locale, $statistic->getTable(), $statistic->id);

        $data = [
            'locale' => mb_strtolower($locale),
            'editStatistic' => $statistic
        ];

        $html = (string)view()->make('admin.settings.personalization.statistic_modal', $data);

        return response()->json([
            'code' => 200,
            'html' => $html,
        ]);
    }

    public function updateItem(Request $request, $id)
    {
        $this->authorize('admin_settings_personalization');

        $data = $request->all();

        $validator = Validator::make($data, [
            "title" => "required",
            "description" => "required",
            "color" => "required",
            "icon" => "required",
            "count" => "required",
        ]);

        if ($validator->fails()) {
            return response([
                'code' => 422,
                'errors' => $validator->errors(),
            ], 422);
        }

        $statistic = HomePageStatistic::findOrFail($id);

        $statistic->update([
            "icon" => $data['icon'],
            "color" => $data['color'],
            "count" => $data['count'],
            "order" => $statistic->order,
        ]);

        HomePageStatisticTranslation::query()->updateOrCreate([
            'home_page_statistic_id' => $statistic->id,
            'locale' => mb_strtolower($data['locale'])
        ], [
            'title' => $data['title'],
            'description' => $data['description'],
        ]);

        return response()->json([
            'code' => 200
        ]);
    }

    public function deleteItem($id)
    {
        $this->authorize('admin_settings_personalization');

        $statistic = HomePageStatistic::findOrFail($id);

        $statistic->delete();

        $allSections = HomePageStatistic::orderBy('order', 'asc')->get();

        $order = 1;
        foreach ($allSections as $allSection) {
            $allSection->update([
                'order' => $order
            ]);

            $order += 1;
        }

        return redirect()->back();
    }

    public function sort(Request $request)
    {
        $this->authorize('admin_settings_personalization');

        $data = $request->all();

        $validator = Validator::make($data, [
            'items' => 'required',
        ]);

        if ($validator->fails()) {
            return response([
                'code' => 422,
                'errors' => $validator->errors(),
            ], 422);
        }

        $itemIds = explode(',', $data['items']);

        foreach ($itemIds as $order => $id) {
            HomePageStatistic::where('id', $id)
                ->update(['order' => ($order + 1)]);
        }

        return response()->json([
            'title' => trans('public.request_success'),
            'msg' => trans('update.items_sorted_successful')
        ]);
    }
}

© 2025 UnknownSec
Courses | Anyleson - Learning Platform
INR (₹)
India Rupee
$
United States Dollar

Courses

17 Courses
Course
Full Stack Web Development

Full Stack Web Development

in Web Development
83:20 Hours
10 Oct 2024
₹28,318.82
Course
Installment and Secure Host

Installment and Secure Host

in Business Strategy
5.00
1:30 Hours
16 Mar 2023
₹118
Course
New Update Features

New Update Features

in Language
4.00
1:30 Hours
21 Jun 2022
Free
Not conducted
Bestseller
New In-App Live System

New In-App Live System

in Communications
5.00
2:30 Hours
1 Mar 2026
₹11.80
Featured
New Learning Page

New Learning Page

in Lifestyle
5.00
3:30 Hours
1 Mar 2022
Free
Finished
How to Travel Around the World

How to Travel Around the World

in Lifestyle
5.00
2:30 Hours
2 Mar 2022
₹29.50

Type

More options