shell bypass 403

UnknownSec Shell


name : TranslatorController.php
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Mixins\Lang\TranslateService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class TranslatorController extends Controller
{

    public function index(Request $request)
    {
        $this->authorize("admin_translator");

        $dir = base_path('lang/en');
        $langFiles = $this->getLangFolderFilesList($dir);

        $data = [
            'pageTitle' => trans('update.translator'),
            'langFiles' => $langFiles
        ];

        return view('admin.translator.index', $data);
    }

    public function translate(Request $request)
    {
        $this->authorize("admin_translator");
        $data = $request->all();

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

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

        $language = mb_strtolower($data['language']);
        $error = null;

        $specificFilesPath = [];
        if (!empty($data['specific_file']) and !empty($data['lang_files']) and is_array($data['lang_files'])) {
            $specificFilesPath = $this->getSelectedFilesPath($data['lang_files']);
        }

        try {
            $translateService = (new TranslateService());

            if (count($specificFilesPath)) {
                foreach ($specificFilesPath as $filePath) {
                    $translateService->to($language)->from($filePath, false, 'en')->translate();
                }
            } else {
                $translateService->to($language)->from('en')->translate();
            }
        } catch (\Exception $exception) {
            $error = "Error: " . $exception->getMessage();
        }

        return response()->json([
            'code' => 200,
            'error' => $error,
            'msg' => ' - Finished translation! (go to lang/' . $language . ' folder) ',
        ]);
    }

    private function getSelectedFilesPath($items, $folder = null)
    {
        $filesPath = [];

        foreach ($items as $key => $item) {
            if (is_array($item)) {
                $folder .= "/$key";

                $filesPathTmp = $this->getSelectedFilesPath($item, $folder);

                $filesPath = array_merge($filesPath, $filesPathTmp);
            } else {
                $filesPath[] = 'en' . ($folder ? "{$folder}/" : '/') . "{$item}.php";
            }
        }

        return $filesPath;
    }

    private function getLangFolderFilesList($dir)
    {
        $result = [];

        if (is_dir($dir)) {
            // Open the directory
            if ($dh = opendir($dir)) {
                // Read files and directories inside the directory
                while (($file = readdir($dh)) !== false) {
                    // Skip '.' and '..'
                    if ($file != "." && $file != "..") {
                        // Check if it's a directory
                        if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
                            $result[$file] = $this->getLangFolderFilesList($dir . DIRECTORY_SEPARATOR . $file);
                        } else {
                            // It's a file
                            $result[] = pathinfo($file, PATHINFO_FILENAME);
                        }
                    }
                }

                // Close the directory
                closedir($dh);
            }
        }

        return $result;
    }

}

© 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