function postie_get_mail() { require_once plugin_dir_path(__FILE__) . 'mimedecode.php'; if (!function_exists('file_get_html')) { require_once plugin_dir_path(__FILE__) . 'simple_html_dom.php'; } EchoInfo("Starting mail fetch"); postie_environment(); $wp_content_path = dirname(dirname(dirname(__FILE__))); DebugEcho("wp_content_path: {$wp_content_path}"); if (file_exists($wp_content_path . DIRECTORY_SEPARATOR . "filterPostie.php")) { DebugEcho("found filterPostie.php in {$wp_content_path}"); include_once $wp_content_path . DIRECTORY_SEPARATOR . "filterPostie.php"; } if (has_filter('postie_post')) { echo "Postie: filter 'postie_post' is depricated in favor of 'postie_post_before'"; } $test_email = null; $config = config_Read(); //extract($config); if (!array_key_exists('maxemails', $config)) { $config['maxemails'] = 0; } $emails = FetchMail($config['mail_server'], $config['mail_server_port'], $config['mail_userid'], $config['mail_password'], $config['input_protocol'], $config['time_offset'], $test_email, $config['delete_mail_after_processing'], $config['maxemails'], $config['email_tls']); $message = 'Done.'; EchoInfo(sprintf(__("There are %d messages to process", "postie"), count($emails))); if (function_exists('memory_get_usage')) { DebugEcho(__("memory at start of email processing:") . memory_get_usage()); } DebugDump($config); //loop through messages $message_number = 0; foreach ($emails as $email) { $message_number++; DebugEcho("{$message_number}: ------------------------------------"); //sanity check to see if there is any info in the message if ($email == NULL) { $message = __('Dang, message is empty!', 'postie'); EchoInfo("{$message_number}: {$message}"); continue; } else { if ($email == 'already read') { $message = __("Message is already marked 'read'.", 'postie'); EchoInfo("{$message_number}: {$message}"); continue; } } $mimeDecodedEmail = DecodeMIMEMail($email); DebugEmailOutput($email, $mimeDecodedEmail); //Check poster to see if a valid person $poster = ValidatePoster($mimeDecodedEmail, $config); if (!empty($poster)) { PostEmail($poster, $mimeDecodedEmail, $config); } else { EchoInfo("Ignoring email - not authorized."); } flush(); } EchoInfo("Mail fetch complete, {$message_number} emails"); if (function_exists('memory_get_usage')) { DebugEcho("memory at end of email processing:" . memory_get_usage()); } }
EchoInfo("Checking for mail manually with debug output"); if (!defined('POSTIE_DEBUG')) { define('POSTIE_DEBUG', true); } include 'get_mail.php'; exit; break; default: $message = 2; break; } } global $wpdb, $wp_roles; $title = __('Postie Options', 'postie'); $parent_file = 'options-general.php'; $config = config_Read(); if (empty($config)) { $config = config_ResetToDefault(); } $arrays = config_ArrayedSettings(); // some fields are stored as arrays, because that makes back-end processing much easier // and we need to convert those fields to strings here, for the options form foreach ($arrays as $sep => $fields) { foreach ($fields as $field) { $config[$field] = implode($sep, $config[$field]); } } extract($config); if (!isset($maxemails)) { DebugEcho("New setting: maxemails"); $maxemails = 0;
function postie_cron($interval = false) { //Do not echo output in filters, it seems to break some installs //error_log("postie_cron: setting up cron task: $interval"); //$schedules = wp_get_schedules(); //error_log("postie_cron\n" . print_r($schedules, true)); if (!$interval) { $config = config_Read(); $interval = $config['interval']; //error_log("postie_cron: setting up cron task from config: $interval"); } if (!$interval || $interval == '') { $interval = 'hourly'; //error_log("Postie: setting up cron task: defaulting to hourly"); } if ($interval == 'manual') { postie_decron(); //error_log("postie_cron: clearing cron (manual)"); } else { if ($interval != wp_get_schedule('check_postie_hook')) { postie_decron(); //remove existing //try to create the new schedule with the first run in 5 minutes if (false === wp_schedule_event(time() + 5 * 60, $interval, 'check_postie_hook')) { //error_log("postie_cron: Failed to set up cron task: $interval"); } else { //error_log("postie_cron: Set up cron task: $interval"); } } else { //error_log("postie_cron: OK: $interval"); //don't need to do anything, cron already scheduled } } }