From 38e512a4bb86ed4571b40f625e6e9ec3d8ef8354 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Tue, 30 Jun 2009 11:25:25 +1000 Subject: [PATCH] Maybe fixed the bugs in removing files in the vault? --- vendors/shells/vault.php | 24 +++++++++++++++++------- views/contacts/view.ctp | 5 +++++ views/elements/enquiry_table.ctp | 3 ++- views/products/view.ctp | 1 + 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/vendors/shells/vault.php b/vendors/shells/vault.php index 6234780c..60927a50 100644 --- a/vendors/shells/vault.php +++ b/vendors/shells/vault.php @@ -13,24 +13,30 @@ class VaultShell extends Shell { /****************************************************** * Config Variables * *****************************************************/ - $testing = 0; //Whether to actually move the emails. 1=test, 0=production + $testing = 1; //Whether to actually move the emails. 1=test, 0=production /* Setup Connection to the IMAP server */ $username = 'vault'; $password = 'xjdYOsmJWc37'; /* The password for the account to be checked */ $email_dir = '/var/www/cakephp/app/emails/working'; $temp_filename = 'temp.eml'; - + + if($testing == 1) { + $email_dir = '/var/www/quotenik1.2/app/emails/working'; + } + $mbox = imap_open("{saturn:143/novalidate-cert}INBOX", $username, $password) or die("can't connect: " . imap_last_error()); $MC = imap_check($mbox); $number_of_messages = $MC->Nmsgs; - echo "Number of messages to Process ".$number_of_messages; + + echo "Number of messages to Process ".$number_of_messages."\n"; /* Loop through the messages and sort them into ones to be processed or discarded */ for ($i=1; $i <= $number_of_messages; $i++) { $this_header = imap_headerinfo($mbox, $i); $message = $this->getMessage($mbox, $i, $this_header); $enquiry = $this->checkIfValidEnquiry($message['subject'], $testing); if($enquiry) { - //Process it and store the message and its attachments. + //Process it and store the message and its attachments. + $this->Email->create(); $this->data['Email']['enquiry_id'] = $enquiry['Enquiry']['id']; $this->data['Email']['to'] = $message['to']; @@ -94,11 +100,12 @@ class VaultShell extends Shell { echo "Something went wrong saving the file to the DB\n"; } } + unlink($email_dir.'/'.$attachment['name']); #Delete this attachment now we're done with it. } } - } + } 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. } @@ -106,7 +113,8 @@ class VaultShell extends Shell { if($attachments != 1) { - $this->clearEmailAttachmentDirs($email_dir, $temp_filename, $attachments); + //$this->clearEmailAttachmentDirs($email_dir, $temp_filename, $attachments); + unlink($email_dir.'/'.$temp_filename); #remove the temp email. start again } @@ -156,6 +164,8 @@ function fetchBodyAttachments($mailbox, $msg_number, $filename, $email_dir) { $email_file = $email_dir.'/'.$filename; imap_savebody($mailbox, $email_file, $msg_number); $command = "/usr/local/bin/ripmime -i $email_file -d $email_dir -v --verbose-contenttype --paranoid --prefix $msg_number"; + + // $command = "/usr/local/bin/ripmime -i $email_file -d $email_dir --verbose-contenttype --paranoid --prefix $msg_number"; $output = array(); exec($command, $output, $status); diff --git a/views/contacts/view.ctp b/views/contacts/view.ctp index d57feb07..5de16f18 100755 --- a/views/contacts/view.ctp +++ b/views/contacts/view.ctp @@ -27,6 +27,11 @@   + > + > + +   + > > diff --git a/views/elements/enquiry_table.ctp b/views/elements/enquiry_table.ctp index 85376f10..abb2f3ec 100644 --- a/views/elements/enquiry_table.ctp +++ b/views/elements/enquiry_table.ctp @@ -107,9 +107,10 @@ foreach ($enquiries as $enquiry):
  • link(__('Edit Product', true), array('action'=>'edit', $product['Product']['id'])); ?>
  • +