!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)

/uploads/script/app/Http/Controllers/Seller/   drwxr-xr-x
Free 13.21 GB of 57.97 GB (22.78%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

namespace App\Http\Controllers\Seller;

use 
App\Http\Controllers\Controller;
use 
Illuminate\Http\Request;
use 
App\Category;
use 
App\Categorymeta;
use 
Auth;
use 
Str;
class 
CategoryController extends Controller
{
    
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    
public function index()
    {
        
$posts=Category::where('user_id',Auth::id())->where('type','category')->with('preview')->latest()->paginate(20);
        return 
view('seller.category.index',compact('posts'));
    }

    
/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    
public function create()
    {
        return 
view('seller.category.create');
    }

    
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    
public function store(Request $request)
    {
          
$limit=user_limit();
         
$posts_count=\App\Category::where('user_id',Auth::id())->where('type','category')->count();
         if (
$limit['category_limit'] <= $posts_count) {
        
         
$error['errors']['error']='Maximum category limit exceeded';
         return 
response()->json($error,401);
        }

         if (
$limit['storage'] <= str_replace(','''folderSize('uploads/'.Auth::id()))) {
         
\Session::flash('error''Maximum storage limit exceeded');
         
$error['errors']['error']='Maximum storage limit exceeded';
         return 
response()->json($error,401);
        }

        
$validated $request->validate([
            
'name' => 'required|max:255',
            
'file' => 'image|max:500',
        ]);

        
$slug=Str::slug($request->name);
        
        
$user_id=Auth::id();

        
$category= new Category;
        
$category->name=$request->name;
        
$category->slug=$slug;
        if (
$request->p_id) {
           
$category->p_id=$request->p_id;
        }
       
        
$category->featured=$request->featured;
        
$category->menu_status=$request->menu_status;
        
$category->user_id=$user_id;
        
$category->save();

        if(
$request->file){

            
$fileName time().'.'.$request->file->extension();  
            
$path='uploads/'.$user_id.'/'.date('y/m');
            
$request->file->move($path$fileName);
            
$name=$path.'/'.$fileName;

            
$meta= new Categorymeta;
            
$meta->category_id =$category->id;
            
$meta->type="preview";
            
$meta->content=$name;
            
$meta->save();

        }

        return 
response()->json(['Category Created']);
    }

    
/**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    
public function show($id)
    {
        
//
    
}

    
/**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    
public function edit($id)
    {
        
$infoCategory::where('user_id',Auth::id())->findOrFail($id);
        return 
view('seller.category.edit',compact('info'));
    }

    
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    
public function update(Request $request$id)
    {
        
$validated $request->validate([
            
'name' => 'required|max:255',
            
'file' => 'image|max:500',
        ]);
        
$user_id=Auth::id();

        
$categoryCategory::where('user_id',$user_id)->with('preview')->findOrFail($id);
        
$category->name=$request->name;
       
        if (
$request->p_id) {
           
$category->p_id=$request->p_id;
        }
        else{
            
$category->p_id=null;
        }
       
        
$category->featured=$request->featured;
        
$category->menu_status=$request->menu_status;
        
$category->save();

        if(
$request->file){
            
$limit=user_limit();
            if (
$limit['storage'] <= str_replace(','''folderSize('uploads/'.Auth::id()))) {
               
\Session::flash('error''Maximum storage limit exceeded');
               
$error['errors']['error']='Maximum storage limit exceeded';
               return 
response()->json($error,401);
            }

            if(!empty(
$category->preview)){
                if(
file_exists($category->preview->content)){
                    
unlink($category->preview->content);
                }
            }

            
$fileName time().'.'.$request->file->extension();  
            
$path='uploads/'.$user_id.'/'.date('y/m');
            
$request->file->move($path$fileName);
            
$name=$path.'/'.$fileName;
            
$meta =  Categorymeta::where('category_id',$category->id)->where('type','preview')->first();
            if (empty(
$meta)){
              
$meta= new Categorymeta;  
            }
            
            
$meta->category_id =$category->id;
            
$meta->type="preview";
            
$meta->content=$name;
            
$meta->save();

        }

        return 
response()->json(['Category Updated']);
    }

    
/**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    
public function destroy(Request $request)
    {
        if (
$request->type=='delete') {
            foreach (
$request->ids as $key => $row) {
                
$id=base64_decode($row);
                
$categoryCategory::where('user_id',Auth::id())->where('id',$id)->with('preview')->first();
                if (!empty(
$category->preview)) {
                    if (!empty(
$category->preview->content)) {
                        if (
file_exists($category->preview->content)) {
                            
unlink($category->preview->content);
                        }
                    }
                }
                
$category->delete();
            }
        }

        return 
response()->json(['Category Deleted']);
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

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

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