Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/syn.corals.io/Corals/core/Activity/HttpLogger/Jobs/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/syn.corals.io/Corals/core/Activity/HttpLogger/Jobs/PurgeHttpLogTable.php
<?php


namespace Corals\Activity\HttpLogger\Jobs;


use Carbon\Carbon;
use Corals\Activity\HttpLogger\Models\HttpLog;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class PurgeHttpLogTable implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function handle()
    {
        try {
            logger('Purge Http Logger');

            $maxAgeInDays = config('http_logger.delete_records_older_than_days', 15);

            $cutOffDate = Carbon::now()->subDays($maxAgeInDays)->format('Y-m-d H:i:s');

            $totalDeleted = 0;

            $maxTries = 10000;

            do {
                $amountDeleted = HttpLog::where('created_at', '<', $cutOffDate)
                    ->take(1000)
                    ->delete();

                $totalDeleted += $amountDeleted;

                logger('Partial Purge: ' . $amountDeleted);

                if ($maxTries === 0) {
                    logger('Reached Max Tries');
                    break;
                }

                $maxTries--;
            } while ($amountDeleted > 0);

            logger('Total Purged: ' . $totalDeleted);
            logger('Purge Http Logger Completed');
        } catch (\Exception $exception) {
            report($exception);
        }
    }
}

Spamworldpro Mini