!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/jiff/app/Http/Controllers/   drwxr-xr-x
Free 13.13 GB of 57.97 GB (22.66%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

namespace App\Http\Controllers;
use 
App\Models\Product;
use 
App\Models\ProductTranslation;
use 
App\Models\Sale;
use 
App\Models\SaleItem;
use 
App\Models\Customer;
use 
App\Models\ShopSettings;

use 
Illuminate\Http\Request;
use 
Illuminate\Support\Facades\DB;
use 
Illuminate\Support\Facades\Validator;
use 
Carbon\Carbon;
use 
GuzzleHttp\Client;

use 
DateTime;

class 
CustomerController extends Controller
{
    
/**
     * Create a new controller instance.
     *
     * @return void
     */
    
public function __construct()
    {
        
//
    
}
    
// get customers
    
function index($vendor_id,Request $req)
    {   
        return 
response()->json("Not allowed",403);
        try{
            if (
count($req->query())===0) {
                
$customersCustomer::where("vendor_id",$vendor_id)->get();
                return 
response()->json(["data"=>$customers]);
                
            }else{

                
$pr= new Customer;
                
$table $pr->getTable();
        
                
$columns  \Schema::getColumnListing($table);
                
$customers Customer::query();
                
$params $req->query();
                foreach (
$params as $key => $value) {
                    if (
in_array($key,$columns,true)) {
                        if (!empty(
$value) || $value==0){
                            
$customers->where($key,$value);
                        }
                    }else{
                        return 
response()->json(['error' => 'true''message' =>"invalid parameter ".$key]);
                    }
                }
                
$customers=$customers->where("vendor_id",$vendor_id)->get();
                return 
response()->json(["data"=>$customers]);
            }
        } catch (
\Exception $exception) {
            return 
response()->json(['error' => 'true''message' =>$exception->getMessage()],500);
        }
    }
    public function 
create($vendor_id,Request $req)
    {   
        
// $validator = Validator::make($req->all(), [
        //     'name' => 'required|string|between:2,120',
        //     "price" => 'required',
        //     "supplier" => 'nullable|string|between:2,120',
        //     "visibility" => 'required|integer|in:0,1', 
        //     "inventory_check" => 'required|integer|in:0,1', 
        //     "inventory" =>'required|integer|between:0,3000'
        // ]);
        // if ($validator->fails()) {
        //     return response()->json(['error' => 'true', 'message' => $validator->errors()->all()],402);
        // }
        
$shop_id=ShopSettings::select('id')->where('page_id',$req->input("page_id"))->where('active',1)->first();
        
$shop_id=$shop_id->id;
        try {
            
DB::beginTransaction();
            if (empty(
$req->input("psid"))) {
                
$customer Customer::create([
                    
'page_id' => $req->input("page_id"),
                    
'psid' => $req->input("psid"),
                    
'shop_id' => $shop_id,
                    
'phone' => $req->input('phone'),
                    
'email' => $req->input('email'),
                    
'name' => $req->input('name'),
                    
'gender' => $req->input('gender'),
                    
'district' => $req->input('district'),
                    
'upazila' => $req->input('upazila'),
                    
'address' => $req->input('address'),
                    
'timezone' => $req->input('timezone'),
                    
'customer_type' => $req->input('customer_type'),
                    
'vendor_id' => $vendor_id,
                ]);
            }else {
                
$customer Customer::updateOrCreate(
                    [
                        
'page_id' => $req->input("page_id"),
                        
'psid' => $req->input("psid")
                    ],
                    [
                    
'shop_id' => $shop_id,
                    
'phone' => $req->input('phone'),
                    
'email' => $req->input('email'),
                    
'name' => $req->input('name'),
                    
'gender' => $req->input('gender'),
                    
'district' => $req->input('district'),
                    
'upazila' => $req->input('upazila'),
                    
'address' => $req->input('address'),
                    
'timezone' => $req->input('timezone'),
                    
'customer_type' => $req->input('customer_type'),
                    
'vendor_id' => $vendor_id,
                ]);
            }

        } catch (
\Exception $exception) {
            
DB::rollback();
            return 
response()->json(['error' => 'true''message' =>$exception->getMessage()],500);
        }
        if (
$customer) {
            
DB::commit();
            
$d = new DateTime();
            
$t=$d->format("ymdHisv");
            
$data=["customer_id"=>$customer->id,"_id"=>$t];
            
// $client = new Client();
            // $req_data = [
            //     'id' => strval($customer->id),
            //     "name": $req->input('name'),
            //     "page_id": strval($req->input("page_id")),
            //     "vendor_id": strval($vendor_id),
            //     "type": ($req->input("psid")=="")?"Regular":"Social"
            // ];
            
            // $res = $client->request('POST', 'http://157.245.155.94:3039/create-customer',[
            //     'json' => $req_data
                    
            // ]);
            // if ($res->getStatusCode()==200) {
            //     $customer=Customer::find($customer->id);
            //     $customer->is_synced= 1;
            //     $ven=$customer->save();
            // }
            
return response()->json(['message' => "Customer Added Successfully","data"=>$data]);
            
        } else {
            
DB::rollback();
            return 
response()->json(['error' => 'true','message' => "Customer not created"],500);
        }
    }
    public function 
updatePhone(Request $req)
    {
        
// $customer = Customer::where('page_id',$req->input('page_id'))->where('psid',$req->input('psid'))->update([
        //     'phone' => $req->input('phone')
        // ]);
        
try {
            
$customer Customer::where('page_id',$req->input('page_id'))->where('psid',$req->input('psid'))->update([
                
'phone' => $req->input('phone')
            ]);
            return 
response()->json(["message"=>"Phone Number Updated"]);
        } catch (
\Exception $exception) {
            return 
response()->json(['error' => 'true''message' =>$exception->getMessage()],500);
        }

    }
    function 
updateCustomer($customer_id,Request $req) {
        try {
            
$validator Validator::make($req->all(), [
                
'name' => 'required|string|between:2,120',
                
"address" => 'required|string|between:2,120',
                
"district" =>'required|integer|between:0,70'
            
]);
            if (
$validator->fails()) {
                return 
response()->json(['error' => 'true''message' => $validator->errors()->all()],402);
            }
            
$customer Customer::where('id',$customer_id)->update([
                
'name' => $req->input('name'),
                
// 'phone' => $req->input('phone'),
                
"email" => $req->input('email'),
                
'district' => $req->input('district'),
                
'upazila' => $req->input('upazila'),
                
'address' => $req->input('address')
            ]);
            return 
response()->json(['message' => "Customer Update Successfully"]);
        } catch (
\Exception $exception) {
            return 
response()->json(['error' => 'true''message' =>$exception->getMessage()],500);
        }
    }
    
// public function updatePosCustomer($customer_id,Request $req)
    // {
    //     // $customer = Customer::where('page_id',$req->input('page_id'))->where('psid',$req->input('psid'))->update([
    //     //     'phone' => $req->input('phone')
    //     // ]);

    //     try {
    //         $customer = Customer::where('id',$customer_id)->update([
    //             'name' => $req->input('name'),
    //             'phone' => $req->input('phone'),
    //             "email" => $req->input('email'),
    //             'district' => $req->input('district'),
    //             'upazila' => $req->input('upazila'),
    //             'address' => $req->input('address')
    //         ]);
    //         return response()->json(['message' => "Customer Update Successfully"]);
    //     } catch (\Exception $exception) {
    //         return response()->json(['error' => 'true', 'message' =>$exception->getMessage()],500);
    //     }
    // }

}

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