Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace VDV\Core\Task\Mail; use VDV\Core\Model\MailDb; use PHPMailer\PHPMailer\P..

Decoded Output download

<?php 
 namespace VDV\Core\Task\Mail; use VDV\Core\Model\MailDb; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; class Send extends \VDV\TaskMgr\Model\Task { const MSG_SEND = 1; const MSG_RECIPIENT = 2; const MSG_HANDLER = 3; const MSG_GENERATE = 4; const MSG_SENT = 5; const ERR_MISSING_ID = 100; const ERR_UNKNOWN_ID = 101; const ERR_SEND = 102; const ERR_HANDLER = 103; public static function name() : string { return get_text("Send E-Mail"); } public static function messages() : array { return [self::MSG_SEND => get_text("Sending email %d to %d recipients"), self::MSG_RECIPIENT => get_text("%s"), self::MSG_HANDLER => get_text("Using message handler %s"), self::MSG_GENERATE => get_text("Generating message"), self::MSG_SENT => get_text("Message sent"), self::ERR_MISSING_ID => get_text("Missing email ID parameter"), self::ERR_UNKNOWN_ID => get_text("Unknown email ID %d"), self::ERR_SEND => get_text("Error sending email: %s"), self::ERR_HANDLER => get_text("Handler class not found")]; } public function run($param) : bool { if (empty($param["id"])) { return $this->logError(self::ERR_MISSING_ID); } $emailDb = new MailDb(); $email = $emailDb->findById($param["id"]); if ($email === false) { return $this->logError(self::ERR_UNKNOWN_ID, $param["id"]); } $this->logInfo(self::MSG_SEND, $email["id"], count($email["recipient"])); $this->logPush(); foreach ($email["recipient"] as $recipient) { $this->logInfo(self::MSG_RECIPIENT, $recipient["email"]); } $this->logPop(); if (empty($email["messageHandler"])) { $messageHandler = "\VDV\Core\Model\MailMessage"; } else { $this->logInfo(self::MSG_HANDLER, $email["messageHandler"]); $messageHandler = $email["messageHandler"]; } if (!class_exists($messageHandler)) { return $this->logError(self::ERR_HANDLER); } $attachments = []; $emailSent = false; $mail = new PHPMailer(); try { $this->logInfo(self::MSG_GENERATE); $mailSettings = $emailDb->mailSettings(); $mail->IsSMTP(); $mail->SMTPDebug = $param["debug"] ?? 0; $mail->SMTPAuth = !empty($mailSettings["mail_server_user"]) && !empty($mailSettings["mail_server_password"]); $mail->Host = $mailSettings["mail_server"]; $mail->Port = $mailSettings["email_port"]; $mail->Username = $mailSettings["mail_server_user"]; $mail->Password = $mailSettings["mail_server_password"]; $mail->CharSet = "UTF-8"; $mail->Encoding = "base64"; if ($mailSettings["email_ssl"] == 1) { $mail->SMTPSecure = "ssl"; } if ($mailSettings["email_ssl"] == 2) { $mail->SMTPSecure = "tsl"; } if ($mailSettings["email_ssl_disable_verify"] == 1) { $mail->SMTPOptions = ["ssl" => ["verify_peer" => false, "verify_peer_name" => false, "allow_self_signed" => true]]; } $mail->SetFrom($mailSettings["return_address"], $mailSettings["return_address_name"]); $mail->AddReplyTo($mailSettings["return_address"], $mailSettings["return_address_name"]); $handler = new $messageHandler($email); $mail->Subject = $handler->subject(); $mail->MsgHTML($handler->htmlBody()); foreach ($handler->recipients() as $recipient) { $mail->AddAddress($recipient["email"], ''); } $attachments = $handler->attachments(); foreach ($attachments as $attachment) { $mail->AddAttachment($attachment); } foreach ($email["attachment"] as $attachment) { $mail->AddAttachment($attachment["path"], $attachment["name"]); } $emailSent = $mail->Send(); if ($emailSent === false) { $this->logError(self::ERR_SEND, $mail->ErrorInfo); } else { $this->logInfo(self::MSG_SENT); } } catch (Exception $e) { $this->logError(self::ERR_SEND, !empty($mail->ErrorInfo) ? $mail->ErrorInfo : $e->getMessage()); } $emailDb->updateStatus($email["id"], $emailSent ? MailDb::STATUS_SENT : MailDb::STATUS_FAILED); foreach ($attachments as $attachment) { unlink($attachment); } return $emailSent; } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace VDV\Core\Task\Mail; use VDV\Core\Model\MailDb; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; class Send extends \VDV\TaskMgr\Model\Task { const MSG_SEND = 1; const MSG_RECIPIENT = 2; const MSG_HANDLER = 3; const MSG_GENERATE = 4; const MSG_SENT = 5; const ERR_MISSING_ID = 100; const ERR_UNKNOWN_ID = 101; const ERR_SEND = 102; const ERR_HANDLER = 103; public static function name() : string { return get_text("\123\x65\156\x64\40\105\x2d\x4d\141\151\154"); } public static function messages() : array { return [self::MSG_SEND => get_text("\123\145\156\x64\x69\156\147\40\145\x6d\x61\151\154\x20\45\x64\40\x74\x6f\x20\x25\144\x20\x72\x65\143\151\x70\151\x65\156\x74\163"), self::MSG_RECIPIENT => get_text("\45\163"), self::MSG_HANDLER => get_text("\125\163\x69\156\147\x20\155\145\x73\x73\141\147\x65\40\x68\141\x6e\144\x6c\145\162\x20\45\163"), self::MSG_GENERATE => get_text("\107\x65\156\x65\162\141\164\x69\156\147\40\155\145\163\163\x61\147\145"), self::MSG_SENT => get_text("\115\x65\x73\x73\141\x67\145\40\x73\145\156\x74"), self::ERR_MISSING_ID => get_text("\115\151\x73\163\x69\x6e\147\x20\x65\x6d\141\151\x6c\x20\111\104\x20\160\141\x72\x61\x6d\145\164\145\162"), self::ERR_UNKNOWN_ID => get_text("\125\x6e\153\x6e\x6f\167\x6e\40\145\x6d\141\151\154\40\111\104\40\x25\144"), self::ERR_SEND => get_text("\x45\162\x72\x6f\x72\x20\x73\x65\156\x64\151\156\147\x20\145\155\141\x69\154\x3a\x20\x25\x73"), self::ERR_HANDLER => get_text("\x48\141\x6e\x64\154\x65\162\40\x63\154\141\163\163\40\156\157\x74\x20\x66\157\x75\x6e\x64")]; } public function run($param) : bool { if (empty($param["\x69\144"])) { return $this->logError(self::ERR_MISSING_ID); } $emailDb = new MailDb(); $email = $emailDb->findById($param["\151\x64"]); if ($email === false) { return $this->logError(self::ERR_UNKNOWN_ID, $param["\151\x64"]); } $this->logInfo(self::MSG_SEND, $email["\x69\144"], count($email["\x72\x65\x63\151\x70\151\145\156\164"])); $this->logPush(); foreach ($email["\x72\x65\x63\151\160\151\x65\x6e\164"] as $recipient) { $this->logInfo(self::MSG_RECIPIENT, $recipient["\x65\x6d\141\151\154"]); } $this->logPop(); if (empty($email["\x6d\145\x73\163\x61\147\x65\110\141\156\x64\154\x65\x72"])) { $messageHandler = "\134\126\x44\x56\134\x43\157\x72\145\134\x4d\x6f\144\x65\154\134\x4d\141\x69\154\x4d\145\163\163\141\x67\x65"; } else { $this->logInfo(self::MSG_HANDLER, $email["\x6d\145\163\x73\x61\147\x65\110\141\156\144\x6c\145\x72"]); $messageHandler = $email["\x6d\x65\x73\163\x61\x67\x65\110\x61\x6e\x64\154\145\x72"]; } if (!class_exists($messageHandler)) { return $this->logError(self::ERR_HANDLER); } $attachments = []; $emailSent = false; $mail = new PHPMailer(); try { $this->logInfo(self::MSG_GENERATE); $mailSettings = $emailDb->mailSettings(); $mail->IsSMTP(); $mail->SMTPDebug = $param["\x64\x65\x62\165\x67"] ?? 0; $mail->SMTPAuth = !empty($mailSettings["\x6d\141\151\154\137\x73\145\x72\x76\145\162\137\x75\x73\x65\162"]) && !empty($mailSettings["\x6d\x61\x69\x6c\137\163\145\162\x76\145\x72\x5f\160\141\163\163\167\x6f\x72\144"]); $mail->Host = $mailSettings["\x6d\x61\x69\154\x5f\163\x65\162\x76\x65\162"]; $mail->Port = $mailSettings["\x65\x6d\x61\x69\154\137\160\157\162\164"]; $mail->Username = $mailSettings["\155\x61\151\154\137\163\145\x72\166\145\x72\137\165\163\x65\x72"]; $mail->Password = $mailSettings["\x6d\x61\x69\154\137\x73\x65\162\166\x65\162\137\160\x61\x73\x73\x77\157\x72\x64"]; $mail->CharSet = "\x55\x54\x46\x2d\x38"; $mail->Encoding = "\x62\141\x73\x65\66\x34"; if ($mailSettings["\x65\x6d\x61\151\154\x5f\x73\x73\154"] == 1) { $mail->SMTPSecure = "\x73\163\x6c"; } if ($mailSettings["\x65\155\141\151\x6c\x5f\x73\163\154"] == 2) { $mail->SMTPSecure = "\x74\163\x6c"; } if ($mailSettings["\x65\x6d\141\x69\154\x5f\163\163\x6c\x5f\x64\x69\x73\141\142\154\x65\x5f\166\x65\162\x69\146\x79"] == 1) { $mail->SMTPOptions = ["\163\163\154" => ["\166\145\162\x69\x66\171\137\x70\x65\145\x72" => false, "\166\x65\x72\151\146\171\137\x70\x65\x65\x72\x5f\156\x61\x6d\145" => false, "\141\x6c\x6c\x6f\x77\137\163\x65\154\x66\x5f\163\151\x67\156\x65\144" => true]]; } $mail->SetFrom($mailSettings["\x72\x65\x74\165\162\156\x5f\141\144\144\x72\x65\x73\x73"], $mailSettings["\x72\x65\x74\165\x72\156\x5f\141\144\x64\162\x65\163\163\x5f\156\x61\155\x65"]); $mail->AddReplyTo($mailSettings["\x72\x65\x74\x75\x72\156\x5f\x61\144\144\x72\145\x73\163"], $mailSettings["\162\145\x74\x75\162\156\x5f\141\144\x64\162\x65\x73\x73\137\x6e\141\155\145"]); $handler = new $messageHandler($email); $mail->Subject = $handler->subject(); $mail->MsgHTML($handler->htmlBody()); foreach ($handler->recipients() as $recipient) { $mail->AddAddress($recipient["\145\x6d\141\x69\x6c"], ''); } $attachments = $handler->attachments(); foreach ($attachments as $attachment) { $mail->AddAttachment($attachment); } foreach ($email["\x61\x74\x74\x61\143\150\x6d\145\x6e\164"] as $attachment) { $mail->AddAttachment($attachment["\x70\141\164\x68"], $attachment["\x6e\141\155\x65"]); } $emailSent = $mail->Send(); if ($emailSent === false) { $this->logError(self::ERR_SEND, $mail->ErrorInfo); } else { $this->logInfo(self::MSG_SENT); } } catch (Exception $e) { $this->logError(self::ERR_SEND, !empty($mail->ErrorInfo) ? $mail->ErrorInfo : $e->getMessage()); } $emailDb->updateStatus($email["\151\x64"], $emailSent ? MailDb::STATUS_SENT : MailDb::STATUS_FAILED); foreach ($attachments as $attachment) { unlink($attachment); } return $emailSent; } }

Function Calls

None

Variables

None

Stats

MD5 3eeb80d171fdf2de80afdd1c1d760717
Eval Count 0
Decode Time 102 ms