function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $postmodifiers) { $fulldebug = IsDebugMode(); $fulldebugdump = false; extract($config); $attachments = array("html" => array(), "cids" => array(), "image_files" => array()); if (array_key_exists('message-id', $mimeDecodedEmail->headers)) { DebugEcho("Message Id is :" . htmlentities($mimeDecodedEmail->headers["message-id"])); if ($fulldebugdump) { DebugDump($mimeDecodedEmail); } } filter_PreferedText($mimeDecodedEmail, $prefer_text_type); if ($fulldebugdump) { DebugDump($mimeDecodedEmail); } $content = GetContent($mimeDecodedEmail, $attachments, $post_id, $poster, $config); if ($fulldebug) { DebugEcho("the content is {$content}"); } $subject = GetSubject($mimeDecodedEmail, $content, $config); filter_RemoveSignature($content, $config); if ($fulldebug) { DebugEcho("post sig: {$content}"); } $post_excerpt = tag_Excerpt($content, $config); if ($fulldebug) { DebugEcho("post excerpt: {$content}"); } $postAuthorDetails = getPostAuthorDetails($subject, $content, $mimeDecodedEmail); if ($fulldebug) { DebugEcho("post author: {$content}"); } $message_date = NULL; if (array_key_exists("date", $mimeDecodedEmail->headers) && !empty($mimeDecodedEmail->headers["date"])) { $cte = ""; $cs = ""; if (property_exists($mimeDecodedEmail, 'content-transfer-encoding') && array_key_exists('content-transfer-encoding', $mimeDecodedEmail->headers)) { $cte = $mimeDecodedEmail->headers["content-transfer-encoding"]; } if (property_exists($mimeDecodedEmail, 'ctype_parameters') && array_key_exists('charset', $mimeDecodedEmail->ctype_parameters)) { $cs = $mimeDecodedEmail->ctype_parameters["charset"]; } $message_date = HandleMessageEncoding($cte, $cs, $mimeDecodedEmail->headers["date"], $message_encoding, $message_dequote); } $message_date = tag_Date($content, $message_date); list($post_date, $post_date_gmt, $delay) = filter_Delay($content, $message_date, $time_offset); if ($fulldebug) { DebugEcho("post date: {$content}"); } filter_Ubb2HTML($content); if ($fulldebug) { DebugEcho("post ubb: {$content}"); } $post_categories = tag_Categories($subject, $default_post_category, $category_match); if ($fulldebug) { DebugEcho("post category: {$content}"); } $post_tags = tag_Tags($content, $default_post_tags); if ($fulldebug) { DebugEcho("post tag: {$content}"); } $comment_status = tag_AllowCommentsOnPost($content); if ($fulldebug) { DebugEcho("post comment: {$content}"); } $post_status = tag_Status($content, $post_status); if ($fulldebug) { DebugEcho("post status: {$content}"); } if ($converturls) { $content = filter_Videos($content, $shortcode); //videos first so linkify doesn't mess with them if ($fulldebug) { DebugEcho("post video: {$content}"); } $content = filter_Linkify($content); if ($fulldebug) { DebugEcho("post linkify: {$content}"); } } filter_VodafoneHandler($content, $attachments, $config); if ($fulldebug) { DebugEcho("post vodafone: {$content}"); } filter_ReplaceImageCIDs($content, $attachments, $config); if ($fulldebug) { DebugEcho("post cid: {$content}"); } $customImages = tag_CustomImageField($content, $attachments, $config); if ($fulldebug) { DebugEcho("post custom: {$content}"); } $post_type = tag_PostType($subject, $postmodifiers, $config); if ($fulldebug) { DebugEcho("post type: {$content}"); } $id = GetParentPostForReply($subject); if (empty($id)) { $id = $post_id; $is_reply = false; if ($add_meta == 'yes') { if ($wrap_pre == 'yes') { $content = $postAuthorDetails['content'] . "<pre>\n" . $content . "</pre>\n"; $content = "<pre>\n" . $content . "</pre>\n"; } else { $content = $postAuthorDetails['content'] . $content; $content = $content; } } else { if ($wrap_pre == 'yes') { $content = "<pre>\n" . $content . "</pre>\n"; } } } else { DebugEcho("Reply detected"); $is_reply = true; // strip out quoted content $lines = explode("\n", $content); $newContents = ''; foreach ($lines as $line) { if (preg_match("/^>.*/i", $line) == 0 && preg_match("/^(from|subject|to|date):.*?/i", $line) == 0 && preg_match("/^-+.*?(from|subject|to|date).*?/i", $line) == 0 && preg_match("/^on.*?wrote:\$/i", $line) == 0 && preg_match("/^-+\\s*forwarded\\s*message\\s*-+/i", $line) == 0) { $newContents .= "{$line}\n"; } } $content = $newContents; wp_delete_post($post_id); } if ($delay != 0 && $post_status == 'publish') { $post_status = 'future'; } filter_Newlines($content, $config); if ($fulldebug) { DebugEcho("post newline: {$content}"); } filter_Start($content, $config); if ($fulldebug) { DebugEcho("post start: {$content}"); } filter_End($content, $config); if ($fulldebug) { DebugEcho("post end: {$content}"); } filter_ReplaceImagePlaceHolders($content, $attachments["html"], $config, $id, $config['image_placeholder'], true); if ($fulldebug) { DebugEcho("post body img: {$content}"); } if ($post_excerpt) { filter_ReplaceImagePlaceHolders($post_excerpt, $attachments["html"], $config, $id, "#eimg%#", false); if ($fulldebug) { DebugEcho("post excerpt img: {$content}"); } } DebugEcho("excerpt: {$post_excerpt}"); if (trim($subject) == "") { $subject = $default_title; DebugEcho("post parsing subject is blank using: {$default_title}"); } $details = array('post_author' => $poster, 'comment_author' => $postAuthorDetails['author'], 'comment_author_url' => $postAuthorDetails['comment_author_url'], 'user_ID' => $postAuthorDetails['user_ID'], 'email_author' => $postAuthorDetails['email'], 'post_date' => $post_date, 'post_date_gmt' => $post_date_gmt, 'post_content' => $content, 'post_title' => $subject, 'post_type' => $post_type, 'ping_status' => get_option('default_ping_status'), 'post_category' => $post_categories, 'tags_input' => $post_tags, 'comment_status' => $comment_status, 'post_name' => sanitize_title($subject), 'post_excerpt' => $post_excerpt, 'ID' => $id, 'customImages' => $customImages, 'post_status' => $post_status); return $details; }
EchoInfo("imap: installed"); } else { EchoInfo("Warning! Postie requires that imap be enabled if you are using IMAP, IMAP-SSL or POP3-SSL."); } if (HasMbStringInstalled()) { EchoInfo("mbstring: installed"); } else { EchoInfo("Warning! Postie requires that mbstring be enabled."); } ?> <h2>Clock Tests</h2> <p>This shows what time it would be if you posted right now</p> <?php $content = ""; $data = filter_Delay($content); EchoInfo("GMT: {$data['1']}"); EchoInfo("Current: {$data['0']}"); ?> <h2>Connect to Mail Host</h2> <?php if (!$mail_server || !$mail_server_port || !$mail_userid) { EchoInfo("NO - check server settings"); } else { DebugEcho("checking"); } switch (strtolower($config["input_protocol"])) { case 'imap': case 'imap-ssl':
LogInfo("non-admin tried to set options"); echo "<h2> Sorry only admin can run this file</h2>"; exit; } ?> <div class="wrap"> <h1>Postie Configuration Test</h1> <?php postie_environment(); ?> <h2>Clock Tests</h2> <p>This shows what time it would be if you posted right now</p> <?php $content = ""; $data = filter_Delay($content, null, $config['time_offset']); EchoInfo("Post time: {$data['0']}"); ?> <h2>Connect to Mail Host</h2> <?php if (!$mail_server || !$mail_server_port || !$mail_userid) { EchoInfo("FAIL - server settings not complete"); } else { DebugEcho("checking"); } switch (strtolower($config["input_protocol"])) { case 'imap': case 'imap-ssl': case 'pop3-ssl':
function postie_test_config() { $config = config_Read(); extract($config); get_currentuserinfo(); if (!current_user_can('manage_options')) { LogInfo("non-admin tried to set options"); echo "<h2> Sorry only admin can run this file</h2>"; exit; } ?> <div class="wrap"> <h1>Postie Configuration Test</h1> <?php postie_environment(); ?> <h2>Clock Tests</h2> <p>This shows what time it would be if you posted right now</p> <?php $content = ""; $data = filter_Delay($content, null, $config['time_offset']); EchoInfo("Post time: {$data['0']}"); ?> <h2>Connect to Mail Host</h2> <?php if (!$mail_server || !$mail_server_port || !$mail_userid) { EchoInfo("FAIL - server settings not complete"); } else { DebugEcho("checking"); } switch (strtolower($config["input_protocol"])) { case 'imap': case 'imap-ssl': case 'pop3-ssl': if (!HasIMAPSupport()) { EchoInfo("Sorry - you do not have IMAP php module installed - it is required for this mail setting."); } else { require_once "postieIMAP.php"; $mail_server =& PostieIMAP::Factory($config["input_protocol"]); if ($email_tls) { $mail_server->TLSOn(); } if (!$mail_server->connect($config["mail_server"], $config["mail_server_port"], $config["mail_userid"], $config["mail_password"])) { EchoInfo("Unable to connect. The server said:"); EchoInfo($mail_server->error()); } else { EchoInfo("Successful " . strtoupper($config['input_protocol']) . " connection on port {$config["mail_server_port"]}"); EchoInfo("# of waiting messages: " . $mail_server->getNumberOfMessages()); $mail_server->disconnect(); } } break; case 'pop3': default: require_once ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'class-pop3.php'; $pop3 = new POP3(); if (defined('POSTIE_DEBUG')) { $pop3->DEBUG = POSTIE_DEBUG; } if (!$pop3->connect($config["mail_server"], $config["mail_server_port"])) { EchoInfo("Unable to connect. The server said:" . $pop3->ERROR); } else { EchoInfo("Sucessful " . strtoupper($config['input_protocol']) . " connection on port {$config["mail_server_port"]}"); $msgs = $pop3->login($config["mail_userid"], $config["mail_password"]); if ($msgs === false) { //workaround for bug reported here Apr 12, 2013 //https://sourceforge.net/tracker/?func=detail&atid=100311&aid=3610701&group_id=311 //originally repoted here: //https://core.trac.wordpress.org/ticket/10587 if (empty($pop3->ERROR)) { EchoInfo("No waiting messages"); } else { EchoInfo("Unable to login. The server said:" . $pop3->ERROR); } } else { EchoInfo("# of waiting messages: {$msgs}"); } $pop3->quit(); } break; } ?> </div> <?php }
public function test_filter_Delay() { $content = "test"; $r = filter_Delay($content); $this->assertTrue(is_array($r)); $this->assertEquals(3, count($r)); $this->assertEquals(0, $r[2]); $this->assertEquals("test", $content); $content = "test delay:"; $r = filter_Delay($content); $this->assertEquals(0, $r[2]); $this->assertEquals("test delay:", $content); $content = "test delay:1h"; $r = filter_Delay($content); $this->assertEquals(3600, $r[2]); $this->assertEquals("test ", $content); $content = "test delay:1d"; $r = filter_Delay($content); $this->assertEquals(86400, $r[2]); $this->assertEquals("test ", $content); $content = "test delay:1m"; $r = filter_Delay($content); $this->assertEquals(60, $r[2]); $this->assertEquals("test ", $content); $content = "test delay:m"; $r = filter_Delay($content); $this->assertEquals(0, $r[2]); $this->assertEquals("test ", $content); $content = "test delay:dhm"; $r = filter_Delay($content); $this->assertEquals(0, $r[2]); $this->assertEquals("test ", $content); $content = "test delay:x"; $r = filter_Delay($content); $this->assertEquals(0, $r[2]); $this->assertEquals("test delay:x", $content); $content = "test delay:-1m"; $r = filter_Delay($content); $this->assertEquals(-60, $r[2]); $this->assertEquals("test ", $content); $content = "test delay:1d1h1m"; $r = filter_Delay($content); $this->assertEquals(90060, $r[2]); $this->assertEquals("test ", $content); $content = "test delay:d1hm"; $r = filter_Delay($content); $this->assertEquals(3600, $r[2]); $this->assertEquals("test ", $content); $content = "test"; $r = filter_Delay($content, '2012-11-20 08:00', 1); $this->assertEquals('2012-11-20 17:00:00', $r[0]); $this->assertEquals(0, $r[2]); $this->assertEquals("test", $content); }