Skip to content

Commit

Permalink
a bunch of updates switching out old admin_mail code with the new Mai…
Browse files Browse the repository at this point in the history
…l class adminMail call and optmizing things here and there as i go'
  • Loading branch information
detain committed Nov 16, 2019
1 parent 8e72bff commit 58d5371
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 70 deletions.
82 changes: 17 additions & 65 deletions src/GlobalSign.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'<br>'.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;
Expand All @@ -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.'<br>'.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;
Expand Down Expand Up @@ -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.'<br>'.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;
}
Expand All @@ -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.'<br>'.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;
}
Expand All @@ -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.'<br>'.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 {
Expand All @@ -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.'<br>'.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;
Expand All @@ -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.'<br>'.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';
Expand Down Expand Up @@ -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.'<br>'.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;
Expand All @@ -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.'<br>'.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;
Expand Down Expand Up @@ -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.'<br>'.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 {
Expand Down Expand Up @@ -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.'<br>'.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;
}
Expand All @@ -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.'<br>'.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 {
Expand Down Expand Up @@ -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.'<br>'.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.');
}
Expand Down Expand Up @@ -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.'<br>'.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');
}
Expand Down Expand Up @@ -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.'<br>'.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');
}
Expand All @@ -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.'<br>'.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');
}
Expand Down Expand Up @@ -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.'<br>'.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.');
}
Expand Down
6 changes: 1 addition & 5 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'<br>'.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;
}
Expand Down

0 comments on commit 58d5371

Please sign in to comment.