Beispiel #1
0
/**
 * This is the main handler for all of the processing
 */
function PostEmail($poster, $mimeDecodedEmail)
{
    $config = GetConfig();
    $GLOBALS["POSTIE_IMAGE_ROTATION"] = 0;
    $attachments = array("html" => array(), "cids" => array(), "image_files" => array());
    print "<p>Message Id is :" . $mimeDecodedEmail->headers["message-id"] . "</p><br/>\n";
    print "<p>Email has following attachments:</p>";
    foreach ($mimeDecodedEmail->parts as $parts) {
        print "<p>" . $parts->ctype_primary . " " . $parts->ctype_secondary . "</p><br />\n";
    }
    FilterTextParts($mimeDecodedEmail);
    #print("<p>Email has following attachments after filtering:");
    #    foreach($mimeDecodedEmail->parts as $parts) {
    #        print("<p>".$parts->ctype_primary ." ".$parts->ctype_secondary) ."<br />\n";
    #    }
    $content = GetContent($mimeDecodedEmail, $attachments);
    $subject = GetSubject($mimeDecodedEmail, $content);
    $rotation = GetRotation($mimeDecodedEmail, $content);
    if ($rotation != "0" && count($attachments["image_files"])) {
        RotateImages($rotation, $attachments["image_files"]);
    }
    SpecialMessageParsing($content, $attachments);
    $message_date = NULL;
    if (array_key_exists("date", $mimeDecodedEmail->headers) && !empty($mimeDecodedEmail->headers["date"])) {
        $message_date = HandleMessageEncoding($mimeDecodedEmail->headers["content-transfer-encoding"], $mimeDecodedEmail->ctype_parameters["charset"], $mimeDecodedEmail->headers["date"]);
    }
    list($post_date, $post_date_gmt) = DeterminePostDate($content, $message_date);
    ubb2HTML($content);
    $content = FilterNewLines($content);
    $post_categories = GetPostCategories($subject);
    $comment_status = AllowCommentsOnPost($content);
    $details = array('post_author' => $poster, 'post_date' => $post_date, 'post_date_gmt' => $post_date_gmt, 'post_content' => preg_replace("/'/", "\\'", $content), 'post_title' => preg_replace("/'/", "\\'", $subject), 'post_modified' => $post_date, 'post_modified_gmt' => $post_date_gmt, 'ping_status' => get_option('default_ping_status'), 'post_category' => $post_categories, 'comment_status' => $comment_status, 'post_name' => sanitize_title($subject), 'post_status' => 'publish');
    DisplayEmailPost($details);
    PostToDB($details);
}
Beispiel #2
0
/**
 * This is the main handler for all of the processing
 */
function PostEmail($poster, $mimeDecodedEmail)
{
    $config = GetConfig();
    $GLOBALS["POSTIE_IMAGE_ROTATION"] = 0;
    $attachments = array("html" => array(), "cids" => array(), "image_files" => array());
    print "<p>Message Id is :" . $mimeDecodedEmail->headers["message-id"] . "</p><br/>\n";
    print "<p>Email has following attachments:</p>";
    foreach ($mimeDecodedEmail->parts as $parts) {
        print "<p>" . $parts->ctype_primary . " " . $parts->ctype_secondary . "</p><br />\n";
    }
    FilterTextParts($mimeDecodedEmail);
    #print("<p>Email has following attachments after filtering:");
    #    foreach($mimeDecodedEmail->parts as $parts) {
    #        print("<p>".$parts->ctype_primary ." ".$parts->ctype_secondary) ."<br />\n";
    #    }
    $content = GetContent($mimeDecodedEmail, $attachments);
    $subject = GetSubject($mimeDecodedEmail, $content);
    echo "the subject is {$subject}, right after calling GetSubject\n";
    $rotation = GetRotation($mimeDecodedEmail, $content);
    if ($rotation != "0" && count($attachments["image_files"])) {
        RotateImages($rotation, $attachments["image_files"]);
    }
    SpecialMessageParsing($content, $attachments);
    $postAuthorDetails = getPostAuthorDetails($subject, $content, $mimeDecodedEmail);
    $message_date = NULL;
    if (array_key_exists("date", $mimeDecodedEmail->headers) && !empty($mimeDecodedEmail->headers["date"])) {
        HandleMessageEncoding($mimeDecodedEmail->headers["content-transfer-encoding"], $mimeDecodedEmail->ctype_parameters["charset"], $mimeDecodedEmail->headers["date"]);
        $message_date = $mimeDecodedEmail->headers['date'];
    }
    list($post_date, $post_date_gmt) = DeterminePostDate($content, $message_date);
    ubb2HTML($content);
    //$content = FilterNewLines($content);
    //$content = FixEmailQuotes($content);
    $id = checkReply($subject);
    $post_categories = GetPostCategories($subject);
    echo "the subject is {$subject}, right after calling GetPostCategories\n";
    $comment_status = AllowCommentsOnPost($content);
    if ((empty($id) || is_null($id)) && $config['ADD_META'] == 'yes') {
        if ($config['WRAP_PRE'] == 'yes') {
            $content = $postAuthorDetails['content'] . "<pre>\n" . $content . "</pre>\n";
        } else {
            $content = $postAuthorDetails['content'] . $content;
        }
        echo "id is empty\n";
    } else {
        if ($config['WRAP_PRE'] == 'yes') {
            $content = "<pre>\n" . $content . "</pre>\n";
        }
    }
    $details = array('post_author' => $poster, 'comment_author' => $postAuthorDetails['author'], 'email_author' => $postAuthorDetails['email'], 'post_date' => $post_date, 'post_date_gmt' => $post_date_gmt, 'post_content' => addslashes($content), 'post_title' => preg_replace("/'/", "\\'", $subject), 'post_modified' => $post_date, 'post_modified_gmt' => $post_date_gmt, 'ping_status' => get_option('default_ping_status'), 'post_category' => $post_categories, 'comment_status' => $comment_status, 'post_name' => sanitize_title($subject), 'ID' => $id, 'post_status' => 'publish');
    DisplayEmailPost($details);
    PostToDB($details);
}
Beispiel #3
0
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;
}
/**
 * This is the main handler for all of the processing
 */
function PostEmail($poster, $mimeDecodedEmail, $config)
{
    $debug = true;
    $attachments = array("html" => array(), "cids" => array(), "image_files" => array());
    print "<p>Message Id is :" . htmlentities($mimeDecodedEmail->headers["message-id"]) . "</p><br/>\n";
    print "<p>Email has following attachments:</p>";
    //foreach($mimeDecodedEmail->parts as $parts) {
    // print("<p>".$parts->ctype_primary ." ".$parts->ctype_secondary) ."</p>\n";
    //}
    FilterTextParts($mimeDecodedEmail, $config['PREFER_TEXT_TYPE']);
    $tmpPost = array('post_title' => 'tmptitle', 'post_content' => 'tmpPost');
    /* in order to do attachments correctly, we need to associate the
      attachments with a post. So we add the post here, then update it 
      */
    $post_id = wp_insert_post($tmpPost);
    if ($debug) {
        echo "the id is {$post_id}\n";
    }
    $content = GetContent($mimeDecodedEmail, $attachments, $post_id, $config);
    if ($debug) {
        echo "the content is {$content}\n";
    }
    $subject = GetSubject($mimeDecodedEmail, $content, $config);
    if ($debug) {
        echo "the subject is {$subject}, right after calling GetSubject\n";
    }
    $customImages = SpecialMessageParsing($content, $attachments, $config);
    $post_excerpt = GetPostExcerpt($content, $config['FILTERNEWLINES'], $config['CONVERTNEWLINE']);
    $postAuthorDetails = getPostAuthorDetails($subject, $content, $mimeDecodedEmail);
    $message_date = NULL;
    if (array_key_exists("date", $mimeDecodedEmail->headers) && !empty($mimeDecodedEmail->headers["date"])) {
        $message_date = HandleMessageEncoding($mimeDecodedEmail->headers["content-transfer-encoding"], $mimeDecodedEmail->ctype_parameters["charset"], $mimeDecodedEmail->headers["date"], $config['MESSAGE_ENCODING'], $config['MESSAGE_DEQUOTE']);
        //$message_date = $mimeDecodedEmail->headers['date'];
    }
    list($post_date, $post_date_gmt, $delay) = DeterminePostDate($content, $message_date, $config['TIME_OFFSET']);
    ubb2HTML($content);
    if ($config['CONVERTURLS']) {
        $content = clickableLink($content, $config['SHORTCODE']);
    }
    //$content = FixEmailQuotes($content);
    $id = checkReply($subject);
    $post_categories = GetPostCategories($subject, $config['DEFAULT_POST_CATEGORY']);
    $post_tags = postie_get_tags($content, $config['DEFAULT_POST_TAGS']);
    $comment_status = AllowCommentsOnPost($content);
    if (empty($id) || is_null($id)) {
        $id = $post_id;
        $isReply = false;
        if ($config['ADD_META'] == 'yes') {
            if ($config['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 ($config['WRAP_PRE'] == 'yes') {
                $content = "<pre>\n" . $content . "</pre>\n";
            }
        }
    } else {
        $isReply = true;
        // strip out quoted content
        $lines = explode("\n", $content);
        //$lines=preg_split('/([\r\n]|<br \/>)/',$content);
        $newContents = '';
        foreach ($lines as $line) {
            //$match=preg_match("/^>.*/i",$line);
            //echo "line=$line,  match=$match";
            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 ($config['FILTERNEWLINES']) {
        $content = FilterNewLines($content, $config['CONVERTNEWLINE']);
    }
    if ($delay != 0 && $config['POST_STATUS'] == 'publish') {
        $post_status = 'future';
    } else {
        $post_status = $config['POST_STATUS'];
    }
    $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_content' => apply_filters('content_save_pre', $content), 'post_title' => $subject, '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);
    $details = apply_filters('postie_post', $details);
    DisplayEmailPost($details);
    PostToDB($details, $isReply, $config['POST_TO_DB'], $config['CUSTOM_IMAGE_FIELD']);
    if ($config['CONFIRMATION_EMAIL']) {
        MailToRecipients($mimeDecodedEmail, false, array($postAuthorDetails['email']), false, false);
    }
}
Beispiel #5
0
/**
 * This is the main handler for all of the processing
 */
function PostEmail($poster, $mimeDecodedEmail, $config)
{
    extract($config);
    $post_to_db = true;
    $attachments = array("html" => array(), "cids" => array(), "image_files" => array());
    print "<p>Message Id is :" . htmlentities($mimeDecodedEmail->headers["message-id"]) . "</p><br/>\n";
    if (defined('POSTIE_DEBUG')) {
        foreach ($mimeDecodedEmail->parts as $parts) {
            print "<p>" . $parts->ctype_primary . " " . $parts->ctype_secondary . "</p>\n";
        }
        echo "<p>Email is:</p>";
        var_dump($mimeDecodedEmail);
    }
    FilterTextParts($mimeDecodedEmail, $prefer_text_type);
    $tmpPost = array('post_title' => 'tmptitle', 'post_content' => 'tmpPost');
    /* in order to do attachments correctly, we need to associate the
      attachments with a post. So we add the post here, then update it 
      */
    $post_id = wp_insert_post($tmpPost);
    if (defined('POSTIE_DEBUG')) {
        echo "the id is {$post_id}\n";
    }
    $content = GetContent($mimeDecodedEmail, $attachments, $post_id, $poster, $config);
    if (defined('POSTIE_DEBUG')) {
        echo "the content is {$content}\n";
    }
    $subject = GetSubject($mimeDecodedEmail, $content, $config);
    if (defined('POSTIE_DEBUG')) {
        echo "the subject is {$subject}, right after calling GetSubject\n";
    }
    $customImages = SpecialMessageParsing($content, $attachments, $config);
    $post_excerpt = GetPostExcerpt($content, $filternewlines, $convertnewline);
    $postAuthorDetails = getPostAuthorDetails($subject, $content, $mimeDecodedEmail);
    $message_date = NULL;
    if (array_key_exists("date", $mimeDecodedEmail->headers) && !empty($mimeDecodedEmail->headers["date"])) {
        $message_date = HandleMessageEncoding($mimeDecodedEmail->headers["content-transfer-encoding"], $mimeDecodedEmail->ctype_parameters["charset"], $mimeDecodedEmail->headers["date"], $message_encoding, $message_dequote);
        //$message_date = $mimeDecodedEmail->headers['date'];
    }
    list($post_date, $post_date_gmt, $delay) = DeterminePostDate($content, $message_date, $time_offset);
    ubb2HTML($content);
    if ($converturls) {
        $content = clickableLink($content, $shortcode);
    }
    //$content = FixEmailQuotes($content);
    $id = checkReply($subject);
    $post_categories = GetPostCategories($subject, $default_post_category);
    $post_tags = postie_get_tags($content, $default_post_tags);
    $comment_status = AllowCommentsOnPost($content);
    if (empty($id) || is_null($id)) {
        $id = $post_id;
        $isReply = 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 {
        $isReply = true;
        // strip out quoted content
        $lines = explode("\n", $content);
        //$lines=preg_split('/([\r\n]|<br \/>)/',$content);
        $newContents = '';
        foreach ($lines as $line) {
            //$match=preg_match("/^>.*/i",$line);
            //echo "line=$line,  match=$match";
            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 ($filternewlines) {
        $content = FilterNewLines($content, $convertnewline);
    }
    if ($delay != 0 && $post_status == 'publish') {
        $post_status = 'future';
    } else {
        $post_status = $post_status;
    }
    /* 
     * Added by Raam Dev <*****@*****.**>
     * Adds support for handling Custom Post Types by adding the
     * Custom Post Type name to the email subject separated by
     * $custom_post_type_delim, e.g. "Movies // My Favorite Movie"
     */
    $custom_post_type_delim = "//";
    if (strpos($subject, $custom_post_type_delim) !== FALSE) {
        // Captures the custom post type in the subject before $custom_post_type_delim
        $separated_subject = explode($custom_post_type_delim, $subject);
        $custom_post_type = $separated_subject[0];
        $subject = $separated_subject[1];
        $custom_post_type = trim(strtolower($custom_post_type));
        // Check if custom post type exists, if not, set default post type of 'post'
        $known_post_types = get_post_types();
        if (in_array($custom_post_type, $known_post_types)) {
            $post_type = $custom_post_type;
        } else {
            $post_type = 'post';
        }
    } else {
        $post_type = 'post';
    }
    /* --------- end by Raam Dev <*****@*****.**> */
    // DEBUG
    $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_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);
    $details = apply_filters('postie_post', $details);
    if (empty($details)) {
        // It is possible that the filter has removed the post, in which case, it should not be posted.
        // And if we created a placeholder post (because this was not a reply to an existing post),
        // then it should be removed
        if (!$is_reply) {
            wp_delete_post($post_id);
        }
    } else {
        DisplayEmailPost($details);
        PostToDB($details, $isReply, $post_to_db, $custom_image_field);
        if ($confirmation_email != '') {
            if ($confirmation_email == 'sender') {
                $recipients = array($postAuthorDetails['email']);
            } elseif ($confirmation_email == 'admin') {
                $recipients = array(get_option("admin_email"));
            } elseif ($confirmation_email == 'both') {
                $recipients = array($postAuthorDetails['email'], get_option("admin_email"));
            }
            MailToRecipients($mimeDecodedEmail, false, $recipients, false, false);
        }
    }
}
function PostEmail($poster, $mimeDecodedEmail)
{
    $config = GetConfig();
    $GLOBALS["POSTIE_IMAGE_ROTATION"] = 0;
    $attachments = array("html" => array(), "cids" => array(), "image_files" => array());
    print "<p>Message Id is :" . $mimeDecodedEmail->headers["message-id"] . "</p><br/>\n";
    print "<p>Email has following attachments:</p>";
    foreach ($mimeDecodedEmail->parts as $parts) {
        print "<p>" . $parts->ctype_primary . " " . $parts->ctype_secondary . "</p><br />\n";
    }
    FilterTextParts($mimeDecodedEmail);
    #print("<p>Email has following attachments after filtering:");
    #    foreach($mimeDecodedEmail->parts as $parts) {
    #        print("<p>".$parts->ctype_primary ." ".$parts->ctype_secondary) ."<br />\n";
    #    }
    $content = GetContent($mimeDecodedEmail, $attachments);
    //$content = $content;
    // replace emails and links that are identifiable BF-CHANGED
    $patterns[] = '/<a\\b[^>]*>.*?(ubscribe|eave|rofile|pdate|[Pp]references).*?<\\/a>/';
    //remove unsubscribe stuff
    $patterns[] = '/<a\\b([^>]+)(ubscribe|eave|rofile|pdate|[Pp]references)([^>]+)>.*?<\\/a>/si';
    //remove unsubscribe stuff
    $patterns[] = '/(http).*?(evite).*?(email)/';
    //remove evite
    $patterns[] = '/(href=)?["\']?(http:\\S+www\\.evite\\.com)\\S+["\'\\b]/';
    //evite
    $patterns[] = '/inviteId\\S+\\b/';
    //evite
    $patterns[] = '/iid=\\S+\\b/';
    //evite
    $patterns[] = '/No virus found in this outgoing message\\./';
    //remove avg stuff
    $patterns[] = '/Checked by AVG\\./';
    //remove avg stuff
    $patterns[] = '/Version.+?Virus.+?Release.+?AM/';
    //remove avg stuff
    $patterns[] = '/No virus found in this incoming message\\./';
    //remove avg stuff
    $patterns[] = '/<span\\b[^>]*>.*(_,_).*(_,_).*<\\/span>/si';
    //remove yahoo stuff
    $content = preg_replace($patterns, '', $content);
    // end BF-CHANGED
    //
    $subject = GetSubject($mimeDecodedEmail, $content);
    $subject = $subject;
    //BF-CHANGED
    $rotation = GetRotation($mimeDecodedEmail, $content);
    if ($rotation != "0" && count($attachments["image_files"])) {
        RotateImages($rotation, $attachments["image_files"]);
    }
    SpecialMessageParsing($content, $attachments);
    $message_date = NULL;
    if (array_key_exists("date", $mimeDecodedEmail->headers) && !empty($mimeDecodedEmail->headers["date"])) {
        $message_date = HandleMessageEncoding($mimeDecodedEmail->headers["content-transfer-encoding"], $mimeDecodedEmail->ctype_parameters["charset"], $mimeDecodedEmail->headers["date"]);
    }
    list($post_date, $post_date_gmt) = DeterminePostDate($content, $message_date);
    ubb2HTML($content);
    $content = FilterNewLines($content);
    $post_categories = GetPostCategories($subject);
    $comment_status = AllowCommentsOnPost($content);
    if (PURIFIER == "on") {
        $purifier_ref =& $purifier;
        $content = addslashes(getpurified()->purify($content));
    } else {
        $content = addslashes($content);
    }
    $details = array('post_author' => $poster, 'post_date' => $post_date, 'post_date_gmt' => $post_date_gmt, 'post_content' => $content, 'post_title' => addslashes($subject), 'post_modified' => $post_date, 'post_modified_gmt' => $post_date_gmt, 'ping_status' => get_option('default_ping_status'), 'post_category' => $post_categories, 'comment_status' => $comment_status, 'post_name' => sanitize_title($subject), 'post_status' => $config["POST_TYPE"], 'tags_input' => $config["DEFAULT_TAG"]);
    DisplayEmailPost($details, $config["AJAX_SELECT"]);
    if ($config["AJAX_SELECT"] == "0") {
        PostToDB($details);
        //print 'AJAX0'.$config["AJAX_SELECT"];
    }
}