!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/Lead/src/Helpers/   drwxrwxrwx
Free 13.11 GB of 57.97 GB (22.62%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

namespace Webkul\Lead\Helpers;

use 
Illuminate\Support\Facades\Validator;
use 
Webkul\Admin\Http\Requests\LeadForm;

class 
MagicAI
{
    
/**
     * Const Variable of LEAD_ENTITY.
     */
    
const LEAD_ENTITY 'leads';

    
/**
     * Const Variable of PERSON_ENTITY.
     */
    
const PERSON_ENTITY 'persons';

    
/**
     * Mapped the receive Extracted AI data.
     */
    
public static function mapAIDataToLead($aiData)
    {
        if (! empty(
$aiData['error'])) {
            return 
self::errorHandler($aiData['error']);
        }

        
$content strip_tags($aiData['choices'][0]['message']['content']);

        if (empty(
$content)) {
            return 
self::errorHandler(trans('admin::app.leads.file.data-not-found'));
        }

        
preg_match('/\{.*\}/s'$content$matches);

        if (isset(
$matches[0])) {
            
$jsonString $matches[0];
        } else {
            return 
self::errorHandler(trans('admin::app.leads.file.invalid-response'));
        }

        
$finalData json_decode($jsonString);

        if (
json_last_error() !== JSON_ERROR_NONE) {
            return 
self::errorHandler(trans('admin::app.leads.file.invalid-format'));
        }

        try {
            
self::validateLeadData($finalData);

            
$validatedData app(LeadForm::class)->validated();

            return 
array_merge($validatedDataself::prepareLeadData($finalData));
        } catch (
\Exception $e) {
            return 
self::errorHandler($e->getMessage());
        }
    }

    
/**
     * Validate the lead data.
     */
    
private static function validateLeadData($data)
    {
        
$dataArray json_decode(json_encode($data), true);

        
$validator Validator::make($dataArray, [
            
'title'                         => 'required|string|max:255',
            
'lead_value'                    => 'required|numeric|min:0',
            
'person.name'                   => 'required|string|max:255',
            
'person.emails.value'           => 'required|email',
            
'person.contact_numbers.value'  => 'required|string|max:20',
        ]);

        if (
$validator->fails()) {
            throw new 
\Illuminate\Validation\ValidationException(
                
$validator,
                
response()->json(self::errorHandler($validator->errors()->getMessages()), 400)
            );
        }

        return 
$data;
    }

    
/**
     * Prepares the lead prompt data.
     */
    
private static function prepareLeadData($finalData)
    {
        return [
            
'status'              => 1,
            
'title'               => $finalData->title ?? 'N/A',
            
'description'         => $finalData->description ?? null,
            
'lead_source_id'      => 1,
            
'lead_type_id'        => 1,
            
'lead_value'          => $finalData->lead_value ?? 0,
            
'person'              => [
                
'name'            => $finalData->person->name ?? 'Unknown',
                
'emails'          => [
                    [
                        
'value' => $finalData->person->emails->value ?? null,
                        
'label' => $finalData->person->emails->label ?? 'work',
                    ],
                ],
                
'contact_numbers' => [
                    [
                        
'value' => $finalData->person->contact_numbers->value ?? null,
                        
'label' => $finalData->person->contact_numbers->label ?? 'work',
                    ],
                ],
                
'entity_type'     => self::PERSON_ENTITY,
            ],
            
'entity_type'         => self::LEAD_ENTITY,
        ];
    }

    
/**
     * Prepares method for error handler.
     */
    
public static function errorHandler($message)
    {
        return [
            
'status'  => 'error',
            
'message' => $message,
        ];
    }
}

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