Example #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);
}
/**
 * This function handles updating the configuration 
 *@return boolean
 */
function UpdatePostieConfig($data)
{
    SetupConfiguration();
    $key_arrays = GetListOfArrayConfig();
    $config = GetDBConfig();
    foreach ($config as $key => $value) {
        if (isset($data[$key])) {
            if (in_array($key, $key_arrays)) {
                //This is stored as an array
                $data[$key] = trim($data[$key]);
                if (strstr($data[$key], "\n")) {
                    $delim = "\n";
                } else {
                    $delim = ',';
                }
                $config[$key] = array();
                $values = explode($delim, $data[$key]);
                foreach ($values as $item) {
                    if (trim($item)) {
                        $config[$key][] = trim($item);
                    }
                }
            } else {
                $config[$key] = FilterNewLines($data[$key]);
            }
        }
    }
    WriteConfig($config);
    UpdatePostiePermissions($data["ROLE_ACCESS"]);
    // If we are using cronless, we also update the cronless events
    if ($config['CRONLESS'] != '') {
        postie_decron();
        postie_cron();
    }
    return 1;
}
Example #3
0
/** 
 * this function determines excerpt for the post
 *
 */
function GetPostExcerpt(&$content, $filterNewLines, $convertNewLines)
{
    global $wpdb;
    $post_excerpt = '';
    if (preg_match('/:excerptstart ?(.*):excerptend/s', $content, $matches)) {
        $content = str_replace($matches[0], "", $content);
        $post_excerpt = $matches[1];
        if ($filterNewLines) {
            $post_excerpt = FilterNewLines($post_excerpt, $convertNewLines);
        }
    }
    return $post_excerpt;
}
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"];
    }
}