svn.filsa.org wordpress_dev

Compare Revisions

Ignore whitespace Rev 19 → Rev 20

/tags/mail2wordpress-release-0.3/mail2wp.php
21,6 → 21,9
var $blog_gmt_offset;
var $options;
var $set_meta_image = true;
var $meta_image = '';
/**
* Process one mail message, and execute the post-by-mail.
* - handle attachments correctly.
37,6 → 40,7
*/
function process_message($msg_text, $result) {
//$this->log("process_message: start.");
$this->meta_image = '';
 
$parser = new mime_parser_class;
$parseparams = array ('Data'=>$msg_text);
60,6 → 64,27
$this->log(' - Parsing data from message titled: ' . $analyzed['Subject']);
// ------- DO AUTH CHECK -- at this point we have enough info to figure this out
//var_dump($analyzed);
$authorized = false;
$auth_emails = split(',', $this->options['auth_approved_senders']);
$this->log('==> Email Auth Check', 'INFO');
//var_dump($analyzed['From']);
//var_dump($auth_emails);
//$this->log('admin settings: auth_approved_senders:' . $this->options['auth_approved_senders']);
foreach($analyzed['From'] as $sender) {
$this->log('== Checking Sender: ' . $sender['address']);
if ( in_array($sender['address'], $auth_emails)) {
$authorized = true;
}
}
if ( ! $authorized) {
$this->log('No valid email found.', 'WARN');
return false;
}
//---- END AUTHORIZATION ----
//get headers
// 'post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status'
$post_author = $this->_get_post_author($msgparse);
106,6 → 131,11
$update = compact('post_content','post_title', 'post_status');
$update['ID'] = $post_ID;
$update_post_id = wp_update_post($update);
// add "image" meta tag to post. to support image templates in the mailcanvas theme.
if ($this->set_meta_image && !empty($this->meta_image))
add_post_meta($post_ID, 'image', $this->meta_image);
if ( 0 == $update_post_id ) {
$this->log(' WP Post failed after content update. Check for a new draft with no content.');
return False;
162,7 → 192,9
$mimetype = $attachment['Type'] . '/' . $attachment['SubType'];
$attachname = $this->_insert_attachment($fname, $post_id, $mimetype);
$urlpath = $this->upload_dir['url'] . '/' . $attachname['file'];
$attach_text .= '<img src="' . $urlpath .'" class="photomail attachments"/>'. "\n";
if (!$this->set_meta_image)
$attach_text .= '<img src="' . $urlpath .'" class="photomail attachments"/>'. "\n";
}
}
$attach_text .= "\n</div>\n";
218,6 → 250,8
}
$this->log(' - _insert_attachment is done, returning:' . $result['file']);
 
if ($this->set_meta_image) $this->meta_image = $this->upload_dir['url'] . '/' .$result['file'];
 
return $result;
}
309,7 → 343,7
}
}
$pop3->quit(); // comment out to prevent deletion of messages.
//$pop3->quit(); // comment out to prevent deletion of messages.
$this->shutdown();
 
}
318,6 → 352,7
$this->upload_dir = wp_upload_dir(date('Y/m'));
$this->blog_gmt_offset = absint(get_option('gmt_offset')) * 3600;
$this->options = get_option( 'm2wp_options' );
var_dump($this->options);
}
function shutdown() {
413,7 → 448,7
$photomail = new mail2wp();
 
$is_active = get_option('m2wp_enabled');
if (false /*! $is_active*/) {
if (false /*! $is_active*/) { // this doesnt seem to be working.
$photomail->log("Deactivated. Activate the mail2wordpress plugin to start processing emails.");
return true;
}
/tags/mail2wordpress-release-0.3/mail2wordpress.php
159,9 → 159,9
<tr valign="top">
<th scope="row">Approved Senders Addresses</th>
<td><fieldset><legend class="hidden">Approved Senders List</legend>
<p><label for="auth_approved_senders">When an email is processed, it will be checked to see if the sender is on this list. If they are not, the email will be discarded. Recommended setting. One email per line.</label></p>
<p><label for="auth_approved_senders">When an email is processed, it will be checked to see if the sender is on this list. If they are not, the email will be discarded. Recommended setting. Separate email addresses with commas</label></p>
<p>
<textarea name="auth_approved_senders" rows="10" cols="50" id="auth_approved_senders" class="large-text code"><?php echo $options['auth_approved_senders']; ?></textarea>
<textarea name="auth_approved_senders" rows="4" cols="50" id="auth_approved_senders" class="large-text code"><?php echo $options['auth_approved_senders']; ?></textarea>
</p>
</fieldset></td>
</tr>