!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/laravel-crm/packages/Webkul/Core/src/   drwxrwxrwx
Free 12.93 GB of 57.97 GB (22.3%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     Menu.php (4.7 KB)      -rw-rw-rw-
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

namespace Webkul\Core;

use 
Illuminate\Support\Arr;
use 
Illuminate\Support\Collection;
use 
Webkul\Core\Menu\MenuItem;

class 
Menu
{
    
/**
     * Menu items.
     */
    
private array $items = [];

    
/**
     * Config menu.
     */
    
private array $configMenu = [];

    
/**
     * Contains current item key.
     */
    
private string $currentKey '';

    
/**
     * Menu area for admin.
     */
    
const ADMIN 'admin';

    
/**
     * Menu area for customer.
     */
    
const CUSTOMER 'customer';

    
/**
     * Add a new menu item.
     */
    
public function addItem(MenuItem $menuItem): void
    
{
        
$this->items[] = $menuItem;
    }

    
/**
     * Get all menu items.
     */
    
public function getItems(?string $area nullstring $key ''): Collection
    
{
        if (! 
$area) {
            throw new 
\Exception('Area must be provided to get menu items.');
        }

        static 
$items;

        if (
$items) {
            return 
$items;
        }

        
$configMenu collect(config("menu.$area"))->map(function ($item) {
            return 
Arr::except([
                ...
$item,
                
'url' => route($item['route'], $item['params'] ?? []),
            ], [
'params']);
        });

        switch (
$area) {
            case 
self::ADMIN:
                
$this->configMenu $configMenu
                    
->filter(fn ($item) => bouncer()->hasPermission($item['key']))
                    ->
toArray();
                break;

            default:
                
$this->configMenu $configMenu->toArray();

                break;
        }

        if (! 
$this->items) {
            
$this->prepareMenuItems();
        }

        
$items collect($this->items)->sortBy(fn ($item) => $item->getPosition());

        return 
$items;
    }

    
/**
     * Get admin menu by key or keys.
     */
    
public function getAdminMenuByKey(array|string $keys): mixed
    
{
        
$items $this->getItems('admin');

        
$keysArray = (array) $keys;

        
$filteredItems $items->filter(fn ($item) => in_array($item->getKey(), $keysArray));

        return 
is_array($keys) ? $filteredItems $filteredItems->first();
    }

    
/**
     * Prepare menu items.
     */
    
private function prepareMenuItems(): void
    
{
        
$menuWithDotNotation = [];

        foreach (
$this->configMenu as $item) {
            if (
strpos(request()->url(), route($item['route'])) !== false) {
                
$this->currentKey $item['key'];
            }

            
$menuWithDotNotation[$item['key']] = $item;
        }

        
$menu Arr::undot(Arr::dot($menuWithDotNotation));

        foreach (
$menu as $menuItemKey => $menuItem) {
            
$this->addItem(new MenuItem(
                
key$menuItemKey,
                
nametrans($menuItem['name']),
                
route$menuItem['route'],
                
url$menuItem['url'],
                
sort$menuItem['sort'],
                
icon$menuItem['icon-class'],
                
infotrans($menuItem['info'] ?? ''),
                
children$this->processSubMenuItems($menuItem),
            ));
        }
    }

    
/**
     * Process sub menu items.
     */
    
private function processSubMenuItems($menuItem): Collection
    
{
        return 
collect($menuItem)
            ->
sortBy('sort')
            ->
filter(fn ($value) => is_array($value))
            ->
map(function ($subMenuItem) {
                
$subSubMenuItems $this->processSubMenuItems($subMenuItem);

                return new 
MenuItem(
                    
key$subMenuItem['key'],
                    
nametrans($subMenuItem['name']),
                    
route$subMenuItem['route'],
                    
url$subMenuItem['url'],
                    
sort$subMenuItem['sort'],
                    
icon$subMenuItem['icon-class'],
                    
infotrans($subMenuItem['info'] ?? ''),
                    
children$subSubMenuItems,
                );
            });
    }

    
/**
     * Get current active menu.
     */
    
public function getCurrentActiveMenu(?string $area null): ?MenuItem
    
{
        
$currentKey implode('.'array_slice(explode('.'$this->currentKey), 02));

        return 
$this->findMatchingItem($this->getItems($area), $currentKey);
    }

    
/**
     * Finding the matching item.
     */
    
private function findMatchingItem($items$currentKey): ?MenuItem
    
{
        foreach (
$items as $item) {
            if (
$item->key == $currentKey) {
                return 
$item;
            }

            if (
$item->haveChildren()) {
                
$matchingChild $this->findMatchingItem($item->getChildren(), $currentKey);

                if (
$matchingChild) {
                    return 
$matchingChild;
                }
            }
        }

        return 
null;
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0075 ]--