Vault fixed
This commit is contained in:
parent
8f7d1a1022
commit
33318da076
47
vendors/shells/vault.php
vendored
47
vendors/shells/vault.php
vendored
|
|
@ -11,6 +11,8 @@ class VaultShell extends Shell {
|
||||||
|
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
|
||||||
|
$testing = 1; //Whether to actually move the emails.
|
||||||
/* Setup Connection to the IMAP server */
|
/* Setup Connection to the IMAP server */
|
||||||
$username = 'vault';
|
$username = 'vault';
|
||||||
$password = 'xjdYOsmJWc37'; /* The password for the account to be checked */
|
$password = 'xjdYOsmJWc37'; /* The password for the account to be checked */
|
||||||
|
|
@ -34,8 +36,10 @@ class VaultShell extends Shell {
|
||||||
$enquiry = $this->Enquiry->findByTitle($fetched_enquirynumber);
|
$enquiry = $this->Enquiry->findByTitle($fetched_enquirynumber);
|
||||||
|
|
||||||
if($enquiry['Enquiry']['id'] == NULL) { //It passes the Regex - but we don't find an Enquiry for it in the MER.
|
if($enquiry['Enquiry']['id'] == NULL) { //It passes the Regex - but we don't find an Enquiry for it in the MER.
|
||||||
|
if($testing == 0) { //testing mode.
|
||||||
imap_mail_move($mbox, $i, 'INBOX/Discarded'); //Discard it.
|
imap_mail_move($mbox, $i, 'INBOX/Discarded'); //Discard it.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else { //Process it and store the message and its attachments.
|
else { //Process it and store the message and its attachments.
|
||||||
|
|
||||||
|
|
@ -71,7 +75,10 @@ class VaultShell extends Shell {
|
||||||
|
|
||||||
}
|
}
|
||||||
echo "Email stored in the DB under enquiry ".$enquiry['Enquiry']['title']." Will be moved to the stored folder\n";
|
echo "Email stored in the DB under enquiry ".$enquiry['Enquiry']['title']." Will be moved to the stored folder\n";
|
||||||
|
|
||||||
|
if($testing == 0) { //Testing Mode. Don't actually move these emails unless we're in production.
|
||||||
imap_mail_move($mbox, $i, 'INBOX/Stored'); //Move it to the stored folder.
|
imap_mail_move($mbox, $i, 'INBOX/Stored'); //Move it to the stored folder.
|
||||||
|
}
|
||||||
$this->clearEmailAttachmentDirs($email_dir, $temp_filename, $attachment_dir, $attachment_files);
|
$this->clearEmailAttachmentDirs($email_dir, $temp_filename, $attachment_dir, $attachment_files);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -84,6 +91,8 @@ class VaultShell extends Shell {
|
||||||
/* Can't find a valid-looking CMC Enquiry Number. Move the message to the discarded folder
|
/* Can't find a valid-looking CMC Enquiry Number. Move the message to the discarded folder
|
||||||
* I may change this to simply delete the emails. This will do for now, but it's doubling up on the storage for useless files.
|
* I may change this to simply delete the emails. This will do for now, but it's doubling up on the storage for useless files.
|
||||||
* */
|
* */
|
||||||
|
if($testing == 0) {
|
||||||
|
|
||||||
if(imap_mail_move($mbox, $i, 'INBOX/Discarded')) {
|
if(imap_mail_move($mbox, $i, 'INBOX/Discarded')) {
|
||||||
echo "Message Number $i contains no valid Enquiry number. Has been discarded\n";
|
echo "Message Number $i contains no valid Enquiry number. Has been discarded\n";
|
||||||
}
|
}
|
||||||
|
|
@ -91,6 +100,7 @@ class VaultShell extends Shell {
|
||||||
echo "Message Number $i contains no valid Enquiry number. But could not be discarded\n";
|
echo "Message Number $i contains no valid Enquiry number. But could not be discarded\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,9 +234,38 @@ function getBody($mbox, $msgnumber) {
|
||||||
function getParts($parts, $mbox, $msgnumber) {
|
function getParts($parts, $mbox, $msgnumber) {
|
||||||
for ($i = 0, $j = count($parts); $i < $j; $i++) {
|
for ($i = 0, $j = count($parts); $i < $j; $i++) {
|
||||||
$part = $parts[$i];
|
$part = $parts[$i];
|
||||||
|
$bodystruct = imap_bodystruct($mbox, $msgnumber, $i+1);
|
||||||
|
|
||||||
if ($part->subtype == 'HTML') { /* Find the HTML component of the body */
|
if ($part->subtype == 'HTML') { /* Find the HTML component of the body */
|
||||||
|
$body = imap_fetchbody($mbox, $msgnumber, $i+1);
|
||||||
|
|
||||||
|
if($bodystruct->subtype != 'HTML') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if($bodystruct->subtype == 'HTML') {
|
||||||
|
break; //Found HTML (preferred) So end the loop.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif($part->subtype == 'PLAIN') {
|
||||||
|
$body = imap_fetchbody($mbox, $msgnumber, $i+1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
elseif(isset($part->parts)) {
|
||||||
|
$body = getParts($part->parts, $mbox, $msgnumber); /* Handle these goddamn Outlook messages */
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $body;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
function getParts($parts, $mbox, $msgnumber) {
|
||||||
|
for ($i = 0, $j = count($parts); $i < $j; $i++) {
|
||||||
|
$part = $parts[$i];
|
||||||
|
|
||||||
|
|
||||||
|
if ($part->subtype == 'HTML') { /* Find the HTML component of the body
|
||||||
$body = imap_fetchbody($mbox, $msgnumber, $i+1);
|
$body = imap_fetchbody($mbox, $msgnumber, $i+1);
|
||||||
break; //Found HTML (preferred) So end the loop.
|
break; //Found HTML (preferred) So end the loop.
|
||||||
}
|
}
|
||||||
|
|
@ -235,14 +274,14 @@ function getParts($parts, $mbox, $msgnumber) {
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif(isset($part->parts)) {
|
elseif(isset($part->parts)) {
|
||||||
$body = $this->getParts($part->parts, $mbox, $msgnumber); /* Handle these goddamn Outlook messages */
|
$body = $this->getParts($part->parts, $mbox, $msgnumber); /* Handle these goddamn Outlook messages
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $body;
|
return $body;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue