function pbm_prepare_html_message($message) { pbm_msg('Message body (original): <pre style="font-size:10px">' . htmlspecialchars($message) . '</pre>'); $marker = 0; if (preg_match('~<body[^>]*>(.*?)</body>~is', $message, $result)) { // First see if we can get contents of <body> tag $content = $result[1]; $marker = 1; } elseif (preg_match('~<html[^>]*>(.*?)</html>~is', $message, $result)) { // <body> was not found, use <html> contents and delete <head> section from it $content = preg_replace('~<head[^>]*>(.*?)</head>~is', '', $result[1]); $marker = 1; } if (empty($marker)) { // None of the above methods worked, just use the original message body $content = $message; } // First fix different line-endings (dos, mac, unix), remove double newlines $content = str_replace(array("\r", "\n\n"), "\n", trim($content)); // Decode 'category', 'title' and 'auth' tags $content = preg_replace('~<(/)?(category|title|auth)>~i', '<\\1\\2>', $content); if (($auth = pbm_get_auth_tag($content)) === false) { // No 'auth' tag provided, exit pbm_msg(sprintf(T_('<auth> tag not found! Please add username and password in message body in format %s.'), '"<auth>username:password</auth>"'), true); return false; } // Balance tags $content = balance_tags($content); // Remove markup that cause validator errors $patterns = array('~ moz-do-not-send="true"~', '~ class="moz-signature" cols="\\d+"~', '~ goomoji="[^"]+"~'); $content = preg_replace($patterns, '', $content); pbm_msg('Message body (processed): <pre style="font-size:10px">' . htmlspecialchars($content) . '</pre>'); return array($auth, $content); }
} elseif ($action == 'test_2' || $action == 'test_3') { if ($mbox = pbm_connect()) { // Read messages from server pbm_msg('Reading messages from server'); $imap_obj = imap_check($mbox); pbm_msg('Found ' . $imap_obj->Nmsgs . ' messages'); if ($imap_obj->Nmsgs > 0) { if ($action == 'test_2') { // Pretend that we're in test mode. DO NOT save this setting! $eblog_saved_test_mode_value = $Settings->get('eblog_test_mode'); $Settings->set('eblog_test_mode', 1); } // We will read only 1 message from server in test mode pbm_process_messages($mbox, 1); } else { pbm_msg(T_('There are no messages in the mailbox')); } imap_close($mbox); } } $Messages->clear(); // Clear all messages if (!empty($pbm_messages)) { // We will display the output in a scrollable fieldset $eblog_test_output = implode("<br />\n", $pbm_messages); } break; } $AdminUI->breadcrumbpath_init(false); $AdminUI->breadcrumbpath_add(T_('System'), $admin_url . '?ctrl=system', T_('Global settings are shared between all blogs; see Blog settings for more granular settings.')); $AdminUI->breadcrumbpath_add(T_('Remote publishing'), $admin_url . '?ctrl=remotepublish');
pbm_msg(T_('There are no messages in the mailbox'), true); imap_close($mbox); return 1; // success } // Create posts pbm_process_messages($mbox, $imap_obj->Nmsgs, true); if (!$Settings->get('eblog_test_mode') && count($del_cntr) > 0) { // We want to delete processed emails from server imap_expunge($mbox); pbm_msg(sprintf(T_('Deleted %d processed message(s) from inbox.'), $del_cntr), true); } imap_close($mbox); // Send reports if ($post_cntr > 0) { pbm_msg(sprintf(T_('New posts created: %d'), $post_cntr), true); $UserCache =& get_UserCache(); foreach ($pbm_items as $Items) { // Send report to post author $to_user_ID = 0; foreach ($Items as $Item) { if ($to_user_ID == 0) { // Get author ID $to_user_ID = $Item->Author->ID; break; } } $email_template_params = array('Items' => $Items); $to_User = $UserCache->get_by_ID($to_user_ID); // Change locale here to localize the email subject and content locale_temp_switch($to_User->get('locale'));