From 58d5371b87aa7f31b4c92f178191e3e9257fe1dd Mon Sep 17 00:00:00 2001 From: Joe Huss Date: Sat, 16 Nov 2019 10:48:34 -0500 Subject: [PATCH] a bunch of updates switching out old admin_mail code with the new Mail class adminMail call and optmizing things here and there as i go' --- src/GlobalSign.php | 82 ++++++++++------------------------------------ src/Plugin.php | 6 +--- 2 files changed, 18 insertions(+), 70 deletions(-) diff --git a/src/GlobalSign.php b/src/GlobalSign.php index d71f914..a663c89 100644 --- a/src/GlobalSign.php +++ b/src/GlobalSign.php @@ -801,11 +801,7 @@ public function create_alphassl($fqdn, $csr, $firstname, $lastname, $phone, $ema $this->extra['error'] = 'Error In order'; // return $this->extra; $subject = 'GlobalSign SSL Error While Getting ApproverList for Registering '.$fqdn; - $headers = ''; - $headers .= 'MIME-Version: 1.0'.EMAIL_NEWLINE; - $headers .= 'Content-type: text/html; charset=UTF-8'.EMAIL_NEWLINE; - $headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.EMAIL_NEWLINE; - admin_mail($subject, $subject.'
'.print_r($res, true), $headers, false, 'admin_email_ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); return false; } $orderId = $res->Response->OrderID; @@ -825,11 +821,7 @@ public function create_alphassl($fqdn, $csr, $firstname, $lastname, $phone, $ema } else { $subject = 'GlobalSign SSL Error While Registering '.$fqdn; } - $headers = ''; - $headers .= 'MIME-Version: 1.0'.EMAIL_NEWLINE; - $headers .= 'Content-type: text/html; charset=UTF-8'.EMAIL_NEWLINE; - $headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.EMAIL_NEWLINE; - admin_mail($subject, $subject.'
'.print_r($res, true), $headers, false, 'admin_email_ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); return false; } else { $this->extra['finished'] = 1; @@ -860,11 +852,7 @@ public function create_domainssl($fqdn, $csr, $firstname, $lastname, $phone, $em $this->extra['ValidateOrderParameters'] = obj2array($res); if ($res->Response->OrderResponseHeader->SuccessCode != 0) { $subject = 'GlobalSign SSL Error while validating order '.$fqdn; - $headers = ''; - $headers .= 'MIME-Version: 1.0'.EMAIL_NEWLINE; - $headers .= 'Content-type: text/html; charset=UTF-8'.EMAIL_NEWLINE; - $headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.EMAIL_NEWLINE; - admin_mail($subject, $subject.'
'.print_r($res, true), $headers, false, 'admin_email_ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); myadmin_log('ssl', 'info', 'create_domainssl returned: '.json_encode($res), __LINE__, __FILE__); return false; } @@ -875,11 +863,7 @@ public function create_domainssl($fqdn, $csr, $firstname, $lastname, $phone, $em $this->extra['GetDVApproverList'] = obj2array($res); if ($res->Response->QueryResponseHeader->SuccessCode != 0) { $subject = 'GlobalSign SSL Error while processing order '.$fqdn; - $headers = ''; - $headers .= 'MIME-Version: 1.0'.EMAIL_NEWLINE; - $headers .= 'Content-type: text/html; charset=UTF-8'.EMAIL_NEWLINE; - $headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.EMAIL_NEWLINE; - admin_mail($subject, $subject.'
'.print_r($res, true), $headers, false, 'admin_email_ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); myadmin_log('ssl', 'info', 'create_domainssl returned: '.json_encode($res), __LINE__, __FILE__); return false; } @@ -899,11 +883,7 @@ public function create_domainssl($fqdn, $csr, $firstname, $lastname, $phone, $em } else { $subject = 'GlobalSign SSL Error While Registering '.$fqdn; } - $headers = ''; - $headers .= 'MIME-Version: 1.0'.EMAIL_NEWLINE; - $headers .= 'Content-type: text/html; charset=UTF-8'.EMAIL_NEWLINE; - $headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.EMAIL_NEWLINE; - admin_mail($subject, $subject.'
'.print_r($res, true), $headers, false, 'admin_email_ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); myadmin_log('ssl', 'info', 'create_domainssl returned: '.json_encode($res), __LINE__, __FILE__); return false; } else { @@ -929,11 +909,7 @@ public function create_domainssl_autocsr($fqdn, $firstname, $lastname, $phone, $ $res = $this->GetDVApproverList($fqdn); if ($res->Response->QueryResponseHeader->SuccessCode != 0) { $subject = 'GlobalSign SSL Error processing Registering '.$fqdn; - $headers = ''; - $headers .= 'MIME-Version: 1.0'.EMAIL_NEWLINE; - $headers .= 'Content-type: text/html; charset=UTF-8'.EMAIL_NEWLINE; - $headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.EMAIL_NEWLINE; - admin_mail($subject, $subject.'
'.print_r($res, true), $headers, false, 'admin_email_ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); return false; } $orderId = $res->Response->OrderID; @@ -950,11 +926,7 @@ public function create_domainssl_autocsr($fqdn, $firstname, $lastname, $phone, $ $subject = 'GlobalSign SSL Error While Registering '.$fqdn; } myadmin_log('ssl', 'info', 'create_domainssl_autocsrf returned: '.json_encode($res), __LINE__, __FILE__); - $headers = ''; - $headers .= 'MIME-Version: 1.0'.EMAIL_NEWLINE; - $headers .= 'Content-type: text/html; charset=UTF-8'.EMAIL_NEWLINE; - $headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.EMAIL_NEWLINE; - admin_mail($subject, $subject.'
'.print_r($res, true), $headers, false, 'admin_email_ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); return false; } else { echo 'Your Order Has Been Completed'; @@ -990,11 +962,7 @@ public function create_organizationssl($fqdn, $csr, $firstname, $lastname, $phon if ($res->Response->OrderResponseHeader->SuccessCode != 0) { myadmin_log('ssl', 'info', 'create_organizationssl returned: '.json_encode($res), __LINE__, __FILE__); $subject = 'GlobalSign SSL Error While processing order '.$fqdn; - $headers = ''; - $headers .= 'MIME-Version: 1.0'.EMAIL_NEWLINE; - $headers .= 'Content-type: text/html; charset=UTF-8'.EMAIL_NEWLINE; - $headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.EMAIL_NEWLINE; - admin_mail($subject, $subject.'
'.print_r($res, true), $headers, false, 'admin_email_ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); return false; } $orderId = $res->Response->OrderID; @@ -1009,11 +977,7 @@ public function create_organizationssl($fqdn, $csr, $firstname, $lastname, $phon $subject = 'GlobalSign SSL Error While Registering '.$fqdn; } myadmin_log('ssl', 'info', 'create_organizationssl returned: '.json_encode($res), __LINE__, __FILE__); - $headers = ''; - $headers .= 'MIME-Version: 1.0'.EMAIL_NEWLINE; - $headers .= 'Content-type: text/html; charset=UTF-8'.EMAIL_NEWLINE; - $headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.EMAIL_NEWLINE; - admin_mail($subject, $subject.'
'.print_r($res, true), $headers, false, 'admin_email_ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); return false; } else { $this->extra['finished'] = 1; @@ -1050,11 +1014,7 @@ public function create_organizationssl_autocsr($fqdn, $firstname, $lastname, $ph } else { $subject = 'GlobalSign SSL Error While Registering '.$fqdn; } - $headers = ''; - $headers .= 'MIME-Version: 1.0'.EMAIL_NEWLINE; - $headers .= 'Content-type: text/html; charset=UTF-8'.EMAIL_NEWLINE; - $headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.EMAIL_NEWLINE; - admin_mail($subject, $subject.'
'.print_r($res, true), $headers, false, 'admin_email_ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); myadmin_log('ssl', 'info', 'create_organizationalssl_autocsr returned: '.json_encode($res), __LINE__, __FILE__); return false; } else { @@ -1095,11 +1055,7 @@ public function create_extendedssl($fqdn, $csr, $firstname, $lastname, $phone, $ } else { $subject = 'GlobalSign SSL Error While Registering '.$fqdn; } - $headers = ''; - $headers .= 'MIME-Version: 1.0'.EMAIL_NEWLINE; - $headers .= 'Content-type: text/html; charset=UTF-8'.EMAIL_NEWLINE; - $headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.EMAIL_NEWLINE; - admin_mail($subject, $subject.'
'.print_r($res, true), $headers, false, 'admin_email_ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); myadmin_log('ssl', 'info', 'create_extendedssl returned: '.json_encode($res), __LINE__, __FILE__); return false; } @@ -1115,11 +1071,7 @@ public function create_extendedssl($fqdn, $csr, $firstname, $lastname, $phone, $ } else { $subject = 'GlobalSign SSL Error While Registering '.$fqdn; } - $headers = ''; - $headers .= 'MIME-Version: 1.0'.EMAIL_NEWLINE; - $headers .= 'Content-type: text/html; charset=UTF-8'.EMAIL_NEWLINE; - $headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.EMAIL_NEWLINE; - admin_mail($subject, $subject.'
'.print_r($res, true), $headers, false, 'admin_email_ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); myadmin_log('ssl', 'info', 'create_extendedssl returned: '.json_encode($res), __LINE__, __FILE__); return false; } else { @@ -1162,7 +1114,7 @@ public function renewAlphaDomain($fqdn, $csr, $firstname, $lastname, $phone, $em if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team.'); $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - admin_mail($subject, $subject.'
'.print_r($res, true), false, false, 'admin/ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); } else { dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team.'); } @@ -1194,7 +1146,7 @@ public function renewAlphaDomain($fqdn, $csr, $firstname, $lastname, $phone, $em if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - admin_mail($subject, $subject.'
'.print_r($res, true), false, false, 'admin/ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); } else { dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); } @@ -1382,7 +1334,7 @@ public function renewOrganizationSSL($fqdn, $csr, $firstname, $lastname, $phone, if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - admin_mail($subject, $subject.'
'.print_r($res, true), false, false, 'admin/ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); } else { dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); } @@ -1398,7 +1350,7 @@ public function renewOrganizationSSL($fqdn, $csr, $firstname, $lastname, $phone, if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - admin_mail($subject, $subject.'
'.print_r($res, true), false, false, 'admin/ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); } else { dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); } @@ -1558,7 +1510,7 @@ public function renewExtendedSSL($fqdn, $csr, $firstname, $lastname, $phone, $em if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team.'); $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - admin_mail($subject, $subject.'
'.print_r($res, true), false, false, 'admin/ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); } else { dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team.'); } diff --git a/src/Plugin.php b/src/Plugin.php index 32f670f..9788470 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -112,12 +112,8 @@ public static function getActivate(GenericEvent $event) } if (!isset($orderId)) { dialog('Error Registering Cert', 'The order process did not complete successfully. Please contact support so they can get it registered.'); - $headers = ''; - $headers .= 'MIME-Version: 1.0'.PHP_EOL; - $headers .= 'Content-type: text/html; charset=UTF-8'.PHP_EOL; - $headers .= 'From: '.TITLE.' <'.EMAIL_FROM.'>'.PHP_EOL; $subject = 'Error Registering SSL Certificate '.$serviceClass->getHostname(); - admin_mail($subject, $subject.'
'.print_r($res, true), $headers, false, 'admin/ssl_error.tpl'); + (new MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); myadmin_log('ssl', 'info', $subject, __LINE__, __FILE__, self::$module, $serviceClass->getId()); $event['success'] = false; }