⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.142
Server IP:
217.76.53.76
Server:
Linux vmi1397931.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64
Server Software:
Apache
PHP Version:
8.2.27
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
www
/
wwwroot
/
whatxap.com
/
src
/
app
/
Jobs
/
View File Name :
ProcessWhatsapp.php
message = $message; $this->number = $number; $this->logId = $logId; $this->postData = $postData; } /** * Execute the job. * * @return void */ public function handle() { $whatsappLog = WhatsappLog::with('whatsappGateway')->find(trim($this->logId)); if(!$whatsappLog){ return false; } if($this->message != null){ $body = ['text'=>$this->message]; } if(array_key_exists('type', $this->postData)){ $url = $this->postData['url_file']; if (filter_var($url, FILTER_VALIDATE_URL)) { $media_url = $url; } else { $media_url = url($url); } if($this->postData['type'] == "image" ){ $body = [ 'image'=>[ 'url'=>$media_url ], 'mimetype' => 'image/jpeg', 'caption'=>$this->message, ]; } else if($this->postData['type'] == "audio" ){ $body = [ 'audio'=>[ 'url'=>$media_url ], 'caption'=>$this->message, ]; } else if($this->postData['type'] == "video" ){ $body = [ 'video'=>[ 'url'=>$media_url ], 'caption'=>$this->message, ]; } else if($this->postData['type'] == "document" ){ $body = [ 'document'=>[ 'url'=>$media_url ], 'mimetype' => 'application/pdf', 'fileName' => $this->postData['name'], 'caption' => $this->message, ]; } } //send api $response = null; try{ $apiURL = env('WP_SERVER_URL').'/message/send?id='.$whatsappLog->whatsappGateway->name; $postInput = [ 'receiver' => trim($this->number), 'message' => $body ]; $headers = [ 'Content-Type' => 'application/json', ]; $response = Http::withoutVerifying()->withHeaders($headers)->post($apiURL, $postInput); if ($response) { $res = json_decode($response->getBody(), true); if($res['success']){ $whatsappLog->status = WhatsappLog::SUCCESS; $whatsappLog->save(); if($whatsappLog->contact_id){ $status = "Success"; } }else{ $whatsappLog->status = WhatsappLog::FAILED; $whatsappLog->response_gateway = $res['message']; $whatsappLog->save(); $user = User::find($whatsappLog->user_id); if($whatsappLog->contact_id){ $status = "Fail"; } if($user){ $messages = str_split($whatsappLog->message,$whatsappLog->word_length); $totalcredit = count($messages); $user->whatsapp_credit += $totalcredit; $user->save(); $creditInfo = new WhatsappCreditLog(); $creditInfo->user_id = $whatsappLog->user_id; $creditInfo->type = "+"; $creditInfo->credit = $totalcredit; $creditInfo->trx_number = trxNumber(); $creditInfo->post_credit = $user->whatsapp_credit; $creditInfo->details = $totalcredit." Credit Return ".$whatsappLog->to." is Falied"; $creditInfo->save(); } } }else{ if($whatsappLog->contact_id){ $status = "Fail"; } $whatsappLog->status = WhatsappLog::FAILED; $whatsappLog->response_gateway = 'Error::2 Failed to send the message.'; $whatsappLog->save(); $user = User::find($whatsappLog->user_id); if($user){ $messages = str_split($whatsappLog->message,$whatsappLog->word_length); $totalcredit = count($messages); $user->whatsapp_credit += $totalcredit; $user->save(); $creditInfo = new WhatsappCreditLog(); $creditInfo->user_id = $whatsappLog->user_id; $creditInfo->type = "+"; $creditInfo->credit = $totalcredit; $creditInfo->trx_number = trxNumber(); $creditInfo->post_credit = $user->whatsapp_credit; $creditInfo->details = $totalcredit." Credit Return ".$whatsappLog->to." is Falied"; $creditInfo->save(); } } } catch(Exception $exception){ if($whatsappLog->contact_id){ $status = "Fail"; } } if($whatsappLog->contact_id){ CampaignContact::where('id',$whatsappLog->contact_id)->update([ "status" => $status ]); $whatsappLog->save(); } } }