Maybe fixed the bugs in removing files in the vault?

This commit is contained in:
Karl Cordes 2009-06-30 11:25:25 +10:00
parent 0a069330d0
commit 38e512a4bb
4 changed files with 25 additions and 8 deletions

View file

@ -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);

View file

@ -27,6 +27,11 @@
<?php echo $contact['Contact']['phone']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Mobile'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $contact['Contact']['mobile']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Phone Extension'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $contact['Contact']['phone_extension']; ?>

View file

@ -107,9 +107,10 @@ foreach ($enquiries as $enquiry):
</td>
<td class="contactemail">
<?php if($enquiry['Contact']['direct_phone']) { echo $enquiry['Contact']['direct_phone']; }
else if($enquiry['Contact']['mobile']) { echo 'mob:'.$enquiry['Contact']['mobile']; }
else {
echo $enquiry['Contact']['phone'];
if($enquiry['Contact']['phone_extension']) {
if($enquiry['Contact']['phone_extension']) {
echo ' ext:'.$enquiry['Contact']['phone_extension'];
}
}

View file

@ -69,6 +69,7 @@
<ul>
<li><?php echo $html->link(__('Edit Product', true), array('action'=>'edit', $product['Product']['id'])); ?> </li>
</ul>
</div>
<div class="related">