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,17 +13,22 @@ class VaultShell extends Shell {
/****************************************************** /******************************************************
* Config Variables * 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 */ /* 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 */
$email_dir = '/var/www/cakephp/app/emails/working'; $email_dir = '/var/www/cakephp/app/emails/working';
$temp_filename = 'temp.eml'; $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()); $mbox = imap_open("{saturn:143/novalidate-cert}INBOX", $username, $password) or die("can't connect: " . imap_last_error());
$MC = imap_check($mbox); $MC = imap_check($mbox);
$number_of_messages = $MC->Nmsgs; $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 */ /* Loop through the messages and sort them into ones to be processed or discarded */
for ($i=1; $i <= $number_of_messages; $i++) { for ($i=1; $i <= $number_of_messages; $i++) {
$this_header = imap_headerinfo($mbox, $i); $this_header = imap_headerinfo($mbox, $i);
@ -31,6 +36,7 @@ class VaultShell extends Shell {
$enquiry = $this->checkIfValidEnquiry($message['subject'], $testing); $enquiry = $this->checkIfValidEnquiry($message['subject'], $testing);
if($enquiry) { if($enquiry) {
//Process it and store the message and its attachments. //Process it and store the message and its attachments.
$this->Email->create(); $this->Email->create();
$this->data['Email']['enquiry_id'] = $enquiry['Enquiry']['id']; $this->data['Email']['enquiry_id'] = $enquiry['Enquiry']['id'];
$this->data['Email']['to'] = $message['to']; $this->data['Email']['to'] = $message['to'];
@ -94,6 +100,7 @@ class VaultShell extends Shell {
echo "Something went wrong saving the file to the DB\n"; 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.
} }
} }
} }
@ -106,7 +113,8 @@ class VaultShell extends Shell {
if($attachments != 1) { 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; $email_file = $email_dir.'/'.$filename;
imap_savebody($mailbox, $email_file, $msg_number); 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 -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(); $output = array();
exec($command, $output, $status); exec($command, $output, $status);

View file

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

View file

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

View file

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