b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (CVS HEAD) [ class tree: main ] [ index: main ] [ all elements ]

Source for file getmail.php

Documentation is available at getmail.php

  1. <?php
  2. /**
  3.  * pop3-2-b2 mail to blog
  4.  *
  5.  * modified for 2.4.1 by Stephan Knauss. Contact me by PM in {@link http://forums.b2evolution.net/} (user stephankn)
  6.  * or send a mail to stephankn at users.sourceforge.net
  7.  *
  8.  * Uses MIME E-mail message parser classes written by Manuel Lemos: {@link http://www.phpclasses.org/browse/package/3169.html}
  9.  *
  10.  * This script can be called with a parameter "test" to specify what
  11.  * should be done and what level of debug output to generate:
  12.  * <ul>
  13.  * <li>level 0: default. Process everything, no debug output, no html (called by cronjob)</li>
  14.  * <li>level 1: Test only connection to server, do not process messages</li>
  15.  * <li>level 2: additionally process messages, but do not post</li>
  16.  * <li>level 3: do everything with extended verbosity</li>
  17.  * </ul>
  18.  * Only messages for "level 0" should get marked for translation (using T_()).
  19.  *
  20.  * b2evolution - {@link http://b2evolution.net/}
  21.  * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  22.  *
  23.  * @author Stephan Knauss
  24.  * @author tblue246: Tilman Blumenbach
  25.  *
  26.  * @copyright (c)2003-2010 by Francois PLANQUE - {@link http://fplanque.net/}
  27.  *  This file built upon code from original b2 - http://cafelog.com/
  28.  *
  29.  * @todo check different encodings. only tested with iso-8859-1
  30.  * @todo try more exotic email clients like mobile phones
  31.  * @todo tested and working with thunderbird (text, html, signed), yahoo mail (text, html), outlook webmail, K800i
  32.  * @todo Allow the user to choose whether to upload attachments to the blog media folder or to his user root.
  33.  *
  34.  * @version $Id: getmail.php,v 1.44 2010/02/08 17:50:51 efy-yury Exp $
  35.  */
  36.  
  37. /**
  38.  * load b2evolution configuration
  39.  */
  40. require_once dirname__FILE__ '/../conf/_config.php';
  41. require_once $inc_path '_main.inc.php';
  42.  
  43. load_class'items/model/_itemlist.class.php''ItemList' );
  44. load_funcs('files/model/_file.funcs.php');
  45. load_class'_ext/mime_parser/rfc822_addresses.php''rfc822_addresses_class' );
  46. load_class'_ext/mime_parser/mime_parser.php''mime_parser_class' );
  47.  
  48. if!$Settings->get'eblog_enabled' ) )
  49. {
  50.     echo T_'Blog by email feature is not enabled.' );
  51.     debug_info();
  52.     exit();
  53. }
  54.  
  55. param'test''integer');
  56.  
  57. /**
  58.  * Subject of the current email message
  59.  *
  60.  * @global string $subject 
  61.  */
  62. $subject '';
  63.  
  64. /**
  65.  * post date of current message
  66.  *
  67.  * @global string $post_date 
  68.  */
  69. $post_date '';
  70.  
  71. /**
  72.  * message content of current email that is going to be posted
  73.  *
  74.  * @global string $content 
  75.  */
  76. $content '';
  77.  
  78. /**#@+
  79.  * define colour constants for messages
  80.  */
  81. define'INFO''black' );
  82. define'SUCCESS''green' );
  83. define'WARNING''orange' );
  84. define'ERROR''red' );
  85. /**#@-*/
  86.  
  87. // if it's not called by a logged in user override test settings
  88. if!isset$current_User || !$current_User->check_perm'options''edit'true ) )
  89. {
  90.     $test 0;
  91. }
  92.  
  93. /**
  94.  * Whether to do real posting.
  95.  *
  96.  * It is set to true if the setting eblog_test_mode is set to false *and*
  97.  * the test parameter is not set to 2.
  98.  */
  99. $do_real_posting (!$Settings->get'eblog_test_mode' && $test != 2);
  100. if$do_real_posting )
  101. {
  102.     echo_messageT_('You configured test mode in the settings or set $test to 2. Nothing will be posted to the database/mediastore nor will your inbox be altered.')WARNING);
  103. }
  104.  
  105. if$test )
  106. {
  107.     //error_reporting (0);
  108.  
  109.     $page_title T_'Blog by email' );
  110.     echo '<html><head><title>' $page_title '</title></head><body>';
  111. }
  112.  
  113. /**
  114.  * Print out a debugging message with optional HTML color added.
  115.  *
  116.  * This function only outputs any additional HTML (colors, <br />) if
  117.  * $test is greater than 0.
  118.  *
  119.  * @global integer The test level
  120.  * @param  string $strmessage The message to print
  121.  * @param  string $color optional colour so use
  122.  * @param  integer $level optional level to limit output to that level
  123.  */
  124. function echo_message$strmessage $color ''$level )
  125. {
  126.     global $test;
  127.  
  128.     if$level <= $test )
  129.     {
  130.         if$test && $color )
  131.         {
  132.             echo '<font color="'.$color.'">';
  133.         }
  134.  
  135.         echo $strmessage;
  136.  
  137.         if$test && $color )
  138.         {
  139.             echo '</font>';
  140.         }
  141.  
  142.         if$test )
  143.         {
  144.             echo '<br />';
  145.         }
  146.         echo "\n";
  147.     }
  148. }
  149.  
  150.  
  151. /**
  152.  * Provide sys_get_temp_dir for older versions of PHP (< 5.2.1).
  153.  *
  154.  * code posted on php.net by minghong at gmail dot com
  155.  * Based on {@link http://www.phpit.net/article/creating-zip-tar-archives-dynamically-php/2/}
  156.  *
  157.  * @return string path to system temporary directory
  158.  */
  159. if!function_exists'sys_get_temp_dir' ) )
  160. {
  161.     function sys_get_temp_dir()
  162.     {
  163.         // Try to get from environment variable
  164.         if!empty$_ENV['TMP') )
  165.         {
  166.             return realpath$_ENV['TMP');
  167.         }
  168.         else if!empty$_ENV['TMPDIR') )
  169.         {
  170.             return realpath$_ENV['TMPDIR');
  171.         }
  172.         else if!empty$_ENV['TEMP') )
  173.         {
  174.             return realpath$_ENV['TEMP');
  175.         }
  176.  
  177.         // Detect by creating a temporary file
  178.         else
  179.         {
  180.             // Try to use system's temporary directory
  181.             // as random name shouldn't exist
  182.             $temp_file tempnammd5uniqidrand()true ) )'' );
  183.             if$temp_file )
  184.             {
  185.                 $temp_dir realpathdirname$temp_file ) );
  186.                 unlink$temp_file );
  187.                 return $temp_dir;
  188.             }
  189.             else
  190.             {
  191.                 return false;
  192.             }
  193.         }
  194.     }
  195. }
  196.  
  197.  
  198. /**
  199.  * Create a new directory with unique name.
  200.  * This creates a new directory below the given path with the given prefix and a random number.
  201.  *
  202.  * @param  string $dir base path to new directory
  203.  * @param  string $prefix prefix random number with this
  204.  * @param  integer $mode permissions to use
  205.  * @return string path to created directory
  206.  */
  207. function tempdir$dir$prefix 'tmp'$mode 0700 )
  208. {
  209.     ifsubstr$dir-!= '/' $dir .= '/';
  210.  
  211.     do
  212.     {
  213.         $path $dir $prefix mt_rand();
  214.     while!mkdir$path$mode ) );
  215.  
  216.     return $path;
  217. }
  218.  
  219.  
  220.  
  221. /**
  222.  * Process Header information like subject and date of a mail.
  223.  *
  224.  * @global string The subject of the current message (write)
  225.  * @global string The post date of the current message (write)
  226.  * @global object b2evo settings (read)
  227.  * @global integer The test level (read)
  228.  * @param  array $header header as set by mime_parser_class::Analyze()
  229.  * @return bool true if valid subject prefix is detected
  230.  */
  231. function processHeader&$header )
  232. {
  233.     // write to these globals
  234.     global $subject$post_date;
  235.  
  236.     // read these globals
  237.     global $Settings$test;
  238.  
  239.     $subject $header['Subject'];
  240.     $ddate $header['Date'];
  241.  
  242.     $prefix $Settings->get'eblog_subject_prefix' );
  243.     echo_message'Subject: ' $subjectINFO);
  244.  
  245.     if(substr($subject0strlen($prefix)) !== $prefix)
  246.     {
  247.         echo_message'&#x2718; The subject prefix is not ' '"' $prefix '"'WARNING);
  248.         return false;
  249.     }
  250.  
  251.     // Parse Date.
  252.     // TODO: dh> use strftime (after format validation)? or strptime (PHP>=5.1.0)
  253.     // of the form '20 Mar 2002 20:32:37'
  254.     if(!preg_match('#^(.{3}, )?(\d{2}) (.{3}) (\d{4}) (\d{2}):(\d{2}):(\d{2})#'$ddate$match))
  255.     {
  256.         echo_message(T_('Could not parse date header!')ERROR0);
  257.         //pre_dump($ddate);
  258.         return false;
  259.     }
  260.  
  261.     $dmonths array(
  262.         'Jan' => 1,
  263.         'Feb' => 2,
  264.         'Mar' => 3,
  265.         'Apr' => 4,
  266.         'May' => 5,
  267.         'Jun' => 6,
  268.         'Jul' => 7,
  269.         'Aug' => 8,
  270.         'Sep' => 9,
  271.         'Oct' => 10,
  272.         'Nov' => 11,
  273.         'Dec' => 12,
  274.     );
  275.  
  276.     $ddate_H $match[5];
  277.     $ddate_i $match[6];
  278.     $ddate_s $match[7];
  279.  
  280.     ifisset$dmonths[$match[3]] ) )
  281.     {
  282.         echo_messageT_'Invalid month name in message date string.' )ERROR);
  283.         return false;
  284.     }
  285.     $ddate_m $dmonths[$match[3]];
  286.     $ddate_d $match[2];
  287.     $ddate_Y $match[4];
  288.  
  289.     $ddate_U mktime$ddate_H$ddate_i$ddate_s$ddate_m$ddate_d$ddate_Y );
  290.     $post_date date'Y-m-d H:i:s'$ddate_U );
  291.  
  292.     return true;
  293. }
  294.  
  295.  
  296.  
  297. /**
  298.  * process attachments by saving into media directory and optionally creating image tag in post
  299.  *
  300.  * @global string message content that is optionally manipulated by adding image tags
  301.  * @global bool do we really post?
  302.  * @global object global b2evo settings
  303.  * @param  array $mailAttachments array containing path to attachment files
  304.  * @param  string $mediadir path to media directory of blog as seen by file system
  305.  * @param  string $media_url url to media directory as seen by user
  306.  * @param  bool $add_img_tags should img tags be added (instead of adding a normal link)
  307.  * @return bool true for sucessfull execution
  308.  */
  309. function processAttachments$mailAttachments$mediadir$media_url$add_img_tags true )
  310. {
  311.     global $content;
  312.     global $do_real_posting;
  313.     global $Settings;
  314.  
  315.     $return true;
  316.  
  317.     echo_message'Processing attachments'INFO);
  318.  
  319.     foreach$mailAttachments as $attachment )
  320.     {
  321.         $filename strtolower$attachment['FileName');
  322.         if$filename == '' )
  323.         {
  324.             $filename tempnam$mediadir'upload' '.' $attachment['SubType'];
  325.             echo_message'&#x279C; ' sprintf('Attachment without name. Using "%s".'htmlspecialchars$filename ))WARNING);
  326.         }
  327.         $filename preg_replace'/[^a-z0-9\-_.]/''-'$filename );
  328.  
  329.         // Check valid filename/extension: (includes check for locked filenames)
  330.         if$error_filename validate_filename$filenamefalse ) )
  331.         {
  332.             echo_message'&#x2718; ' 'Invalid filename: '.$error_filenameWARNING);
  333.             $return false// return: at least one error. try with next attachment
  334.             continue;
  335.         }
  336.  
  337.         // if file exists count up a number
  338.         $cnt 0;
  339.         $prename substr$filename0strrpos$filename'.' ) ).'-';
  340.         $sufname strrchr$filename'.' );
  341.         whilefile_exists$mediadir $filename ) )
  342.         {
  343.             $filename $prename.$cnt.$sufname;
  344.             echo_message'&#x2718; file already exists. Changing filename to: ' $filename WARNING);
  345.             ++$cnt;
  346.         }
  347.  
  348.         if$do_real_posting )
  349.         {
  350.             echo_message'&#x279C; Saving file to: ' htmlspecialchars$mediadir $filename  )INFO);
  351.             if!rename$attachment['DataFile']$mediadir $filename ) )
  352.             {
  353.                 echo_message'&#x2718; Problem saving upload to ' htmlspecialchars$mediadir $filename )WARNING);
  354.                 $return false// return: at least one error. try with next attachment
  355.                 continue;
  356.             }
  357.  
  358.             // chmod uploaded file:
  359.             $chmod $Settings->get'fm_default_chmod_file' );
  360.             @chmod$mediadir $filenameoctdec$chmod ) );
  361.         }
  362.  
  363.         $imginfo @getimagesize($mediadir.$filename);
  364.         echo_message('Attachment is an image: '.(is_array($imginfoT_('yes'T_('no'))INFO);
  365.  
  366.         $content .= "\n";
  367.         if(is_array($imginfo&& $add_img_tags)
  368.         {
  369.             $content .= '<img src="'.$media_url.$filename.'" '.$imginfo[3].' />';
  370.         }
  371.         else
  372.         {
  373.             $content .= '<a href="'.$media_url.$filename.'">'.basename($filename).'</a>';
  374.         }
  375.         $content .= "\n";
  376.     }
  377.  
  378.     return $return;
  379. }
  380.  
  381. /**
  382.  * look inside message to get title for posting.
  383.  *
  384.  * The message could contain a xml-tag <code><title>sample title</title></code> to specify a title for the posting.
  385.  * If not tag is found there could be a global $post_default_title containing a global default title.
  386.  * If none of these is found then the specified alternate title line is used.
  387.  *
  388.  * @param string $content message to search for title tag
  389.  * @param string $alternate_title use this string if no title tag is found
  390.  * @return string title of posting
  391.  *
  392.  * @see $post_default_title
  393.  */
  394. function get_post_title$content$alternate_title )
  395. {
  396.     $title xmlrpc_getposttitle$content );
  397.     if$title == '' )
  398.     {
  399.         $title $alternate_title;
  400.     }
  401.  
  402.     return $title;
  403. }
  404.  
  405. ifextension_loaded'imap' ) )
  406. {
  407.     echo_messageT_'The php_imap extension is not available to PHP on this server. Please load it in php.ini or ask your hosting provider to do so.' )ERROR);
  408.     exit;
  409. }
  410. echo_message'Connecting and authenticating to mail server.'INFO);
  411.  
  412. /**
  413.  * Prepare the connection string.
  414.  */
  415. $mailserver '{' $Settings->get'eblog_server_host' ':' $Settings->get'eblog_server_port' );
  416. switch($Settings->get('eblog_encrypt'))
  417. {
  418.     case 'ssl':
  419.         $mailserver .= '/ssl';
  420.         break;
  421.     case 'tls':
  422.         $mailserver .= '/tls';
  423.         break;
  424.     case 'none':
  425.     default:
  426.         $mailserver .= '/notls';
  427.         break;
  428. }
  429. switch($Settings->get('eblog_method'))
  430. {
  431.     case 'pop3':
  432.     case 'pop3a':
  433.         $mailserver .= '/pop3';
  434.         break;
  435.     case 'imap':
  436.     default:
  437.         // imap needs no additional options
  438.         break;
  439. }
  440. if($Settings->get('eblog_novalidatecert'))
  441. {
  442.     $mailserver .= '/novalidate-cert';
  443. }
  444. $mailserver .= '}INBOX';
  445. //pre_dump($mailserver);
  446.  
  447. // Connect to mail server
  448. $mbox @imap_open$mailserver$Settings->get'eblog_username' )$Settings->get'eblog_password' ) );
  449. if$mbox )
  450. {
  451.     echo_messagesprintf/* TRANS: %s is the error message */ T_'Connection failed: %s' )imap_last_error())ERROR);
  452.     exit();
  453. }
  454. @imap_errors();
  455.  
  456. echo_message'&#x2714; Success'SUCCESS);
  457. if$test == )
  458. {
  459.     echo_message'All tests completed.'INFO);
  460.     imap_close$mbox );
  461.     exit();
  462. }
  463.  
  464.  
  465. // Read messages from server
  466. echo_message'Reading messages from server.'INFO);
  467. $imap_obj imap_check$mbox );
  468. echo_message' &#x279C; ' $imap_obj->Nmsgs ' ' 'messages'INFO);
  469.  
  470. $delMsgs 0;
  471. for $index 1$index <= $imap_obj->Nmsgs$index++ )
  472. {
  473.     echo_message'<strong>Message #' $index ':</strong>'INFO);
  474.  
  475.     $strbody '';
  476.     $hasAttachment false;
  477.  
  478.     // save mail to disk because with attachments could take up much RAM
  479.     if(!($tmpMIME tempnamsys_get_temp_dir()'b2evoMail' )))
  480.     {
  481.         echo_messageT_('Could not create temporary file.')ERROR);
  482.         continue;
  483.     }
  484.     imap_savebody$mbox$tmpMIME$index );
  485.  
  486.     $tmpDirMIME tempdirsys_get_temp_dir()'b2evo' );
  487.     $mimeParser new mime_parser_class;
  488.     $mimeParser->mbox 0// Set to 0 for parsing a single message file
  489.     $mimeParser->decode_bodies 1;
  490.     $mimeParser->ignore_syntax_errors 1;
  491.     $mimeParser->extract_addresses 0;
  492.     $MIMEparameters array(
  493.         'File' => $tmpMIME,
  494.         'SaveBody' => $tmpDirMIME// Save the message body parts to a directory
  495.         'SkipBody' => 1// Do not retrieve or save message body parts
  496.     );
  497.  
  498.     if!$mimeParser->Decode$MIMEparameters$decodedMIME ) )
  499.     {
  500.         echo_messagesprintf(T_('MIME message decoding error: %s at position %d.')$mimeParser->error$mimeParser->error_position)ERROR);
  501.         rmdir_r$tmpDirMIME );
  502.         unlink$tmpMIME );
  503.         continue;
  504.     }
  505.     else
  506.     {
  507.         echo_message'&#x2714; MIME message decoding successful.'INFO);
  508.         if$mimeParser->Analyze$decodedMIME[0]$parsedMIME ) )
  509.         {
  510.             echo_messagesprintf(T_('MIME message analyse error: %s')$mimeParser->error)ERROR);
  511.             // var_dump($parsedMIME);
  512.             rmdir_r$tmpDirMIME );
  513.             unlink$tmpMIME );
  514.             continue;
  515.         }
  516.  
  517.         // the following helps me debugging
  518.         //pre_dump($decodedMIME[0], $parsedMIME);
  519.  
  520.         if(!processHeader($parsedMIME))
  521.         {
  522.             rmdir_r$tmpDirMIME );
  523.             unlink($tmpMIME);
  524.             continue;
  525.         }
  526.  
  527.         // TODO: handle type == "message" recursively
  528.  
  529.         // mail is html
  530.         if$parsedMIME['Type'== 'html' ){
  531.             foreach $parsedMIME['Alternative'as $alternative ){
  532.                 if$alternative['Type'== 'text' ){
  533.                     echo_message'HTML alternative message part saved as ' $alternative['DataFile']INFO);
  534.                     $strbody imap_qprintfile_get_contents$alternative['DataFile') );
  535.                     break// stop after first alternative
  536.                 }
  537.             }
  538.         }
  539.  
  540.         // mail is plain text
  541.         elseif$parsedMIME['Type'== 'text' )
  542.         {
  543.             echo_message'Plain-text message part saved as ' $parsedMIME['DataFile']INFO);
  544.             $strbody imap_qprintfile_get_contents$parsedMIME['DataFile') );
  545.         }
  546.  
  547.         // Check for attachments
  548.         ifisset$parsedMIME['Attachments'&& count($parsedMIME['Attachments']) )
  549.         {
  550.             $hasAttachment true;
  551.             foreach$parsedMIME['Attachments'as $attachment )
  552.             {
  553.                 echo_message'Attachment: ' $attachment['FileName'' stored as ' $attachment['DataFile']INFO);
  554.             }
  555.         }
  556.  
  557.         $warning_count count$mimeParser->warnings );
  558.         if$warning_count )
  559.         {
  560.             echo_message'&#x2718; ' $warning_count ' warnings during decode: 'WARNING);
  561.             foreach ($mimeParser->warnings as $k => $v)
  562.             {
  563.                 echo_message'&#x2718; ' 'Warning: ' $v ' at position ' $kWARNING);
  564.             }
  565.         }
  566.     }
  567.     unlink$tmpMIME );
  568.  
  569.     // var_dump($strbody);
  570.     // process body. First fix different line-endings (dos, mac, unix), remove double newlines
  571.     $strbody str_replacearray("\r""\n\n")"\n"$strbody );
  572.  
  573.     $a_body explode"\n"$strbody);
  574.  
  575.     // tblue> splitting only into 2 parts allows colons in the user PW
  576.     $a_authentication explode':'$a_body[0]);
  577.     $content trim$a_body[1);
  578.  
  579.     echo_message'Message content:' ' <code>' htmlspecialchars$content '</code>'INFO);
  580.  
  581.     $user_login trim$a_authentication[0);
  582.     // TODO: dh> should the password really get trimmed here?!
  583.     $user_pass = isset($a_authentication[1]trim($a_authentication[1]null;
  584.  
  585.     // authenticate user
  586.     echo_message'Authenticating user: ' $user_loginINFO);
  587.     if!user_pass_ok$user_login$user_pass ) )
  588.     {
  589.         echo_messagesprintf(T_'Authentication failed for user %s.' )htmlspecialchars($user_login))ERROR);
  590.         echo_message'&#x2718; Wrong login or password. First line of text in email must be in the format "username:password".'ERROR);
  591.         rmdir_r$tmpDirMIME );
  592.         continue;
  593.     }
  594.     else
  595.     {
  596.         echo_message'&#x2714; Success.'SUCCESS);
  597.     }
  598.  
  599.     $subject trimsubstr($subjectstrlen($Settings->get'eblog_subject_prefix' ))) );
  600.  
  601.     // remove content after terminator
  602.     $eblog_terminator $Settings->get'eblog_body_terminator' );
  603.     if!empty$eblog_terminator &&
  604.          ($os_terminator strpos$content$eblog_terminator )) !== false)
  605.     {
  606.         $content substr$content0$os_terminator );
  607.     }
  608.  
  609.     // check_html_sanity needs local user set.
  610.     $UserCache get_UserCache();
  611.     $current_User $UserCache->get_by_login$user_login );
  612.  
  613.     $post_title get_post_title$content$subject );
  614.  
  615.     if$post_category xmlrpc_getpostcategory$content ) ) )
  616.     {
  617.         $post_category $Settings->get'eblog_default_category' );
  618.     }
  619.     echo_message'Category ID: ' htmlspecialchars$post_category )INFO);
  620.  
  621.     $content xmlrpc_removepostdata$content );
  622.     $blog_ID get_catblog$post_category )// TODO: should not die, if cat does not exist!
  623.     echo_message'Blog ID: ' $blog_IDINFO);
  624.  
  625.     $BlogCache get_BlogCache();
  626.     $Blog $BlogCache->get_by_ID$blog_IDfalsefalse );
  627.  
  628.     ifempty$Blog ) )
  629.     {
  630.         echo_messagesprintfT_('Blog #%d not found!')$blog_ID )ERROR);
  631.         rmdir_r$tmpDirMIME );
  632.         continue;
  633.     }
  634.  
  635.  
  636.     // Check permission:
  637.     echo_messagesprintf'Checking permissions for user &laquo;%s&raquo; to post to Blog #%d'$user_login$blog_ID )INFO);
  638.     if!$current_User->check_perm'blog_post!published''edit'false$blog_ID )
  639.     || $hasAttachment && !$current_User->check_perm'files''add'false$blog_ID ) )
  640.     )
  641.     {
  642.         echo_messageT_'Permission denied.' )ERROR);
  643.         rmdir_r$tmpDirMIME );
  644.         continue;
  645.     }
  646.     else
  647.     {
  648.         echo_message'&#x2714; Pass.'SUCCESS);
  649.     }
  650.  
  651.     // handle attachments
  652.     if$hasAttachment )
  653.     {
  654.         $mediadir $Blog->get_media_dir();
  655.         if$mediadir )
  656.         {
  657.             processAttachments$parsedMIME['Attachments']$mediadir$Blog->get_media_url()$Settings->get('eblog_add_imgtag') );
  658.         }
  659.         else
  660.         {
  661.             echo_messageT_'Unable to access media directory. No attachments processed.' )ERROR);
  662.         }
  663.     }
  664.  
  665.     // CHECK and FORMAT content
  666.     $post_title check_html_sanitytrim$post_title )'posting'false );
  667.     $content check_html_sanitytrim$content )'posting'$Settings->get'AutoBR' ) );
  668.  
  669.     if( ( $error $Messages->get_stringT_'Cannot post, please correct these errors:' )'''error' ) ) )
  670.     {
  671.         echo_message$errorERROR);
  672.         $Messages->clear'error' );
  673.         rmdir_r$tmpDirMIME );
  674.         continue;
  675.     }
  676.  
  677.     if$do_real_posting )
  678.     {
  679.         // INSERT NEW POST INTO DB:
  680.         $edited_Item new Item();
  681.  
  682.         $post_ID $edited_Item->insert$current_User->ID$post_title$content$post_date$post_categoryarray()'published'$current_User->locale );
  683.  
  684.         // Execute or schedule notifications & pings:
  685.         $edited_Item->handle_post_processing();
  686.     }
  687.  
  688.     echo_message'&#x2714; Message posting successful.'SUCCESS);
  689.     echo_message'&#x279C; Post title: ' htmlspecialchars$post_title )INFO);
  690.     echo_message'&#x279C; Post content: ' htmlspecialchars$content )INFO);
  691.  
  692.     rmdir_r$tmpDirMIME );
  693.  
  694.     echo_message'Marking message for deletion: '.$indexINFO);
  695.     imap_delete$mbox$index );
  696.     ++$delMsgs;
  697. }
  698.  
  699. if$do_real_posting )
  700. {
  701.     imap_expunge$mbox );
  702.     echo_messagesprintf('Deleted %d processed message(s) from inbox.'$delMsgs)INFO);
  703. }
  704.  
  705. imap_close$mbox );
  706.  
  707. if$test )
  708. {
  709.     echo '</body>';
  710. }
  711.  
  712.  
  713. /*
  714.  * $Log: getmail.php,v $
  715.  * Revision 1.44  2010/02/08 17:50:51  efy-yury
  716.  * copyright 2009 -> 2010
  717.  *
  718.  * Revision 1.43  2010/01/30 18:55:15  blueyed
  719.  * Fix "Assigning the return value of new by reference is deprecated" (PHP 5.3)
  720.  *
  721.  * Revision 1.42  2009/09/26 12:00:42  tblue246
  722.  * Minor/coding style
  723.  *
  724.  * Revision 1.41  2009/09/25 07:32:51  efy-cantor
  725.  * replace get_cache to get_*cache
  726.  *
  727.  * Revision 1.40  2009/09/14 14:02:20  efy-arrin
  728.  * Included the ClassName in load_class() call with proper UpperCase
  729.  *
  730.  * Revision 1.39  2009/08/29 12:23:54  tblue246
  731.  * - SECURITY:
  732.  *     - Implemented checking of previously (mostly) ignored blog_media_(browse|upload|change) permissions.
  733.  *     - files.ctrl.php: Removed redundant calls to User::check_perm().
  734.  *     - XML-RPC APIs: Added missing permission checks.
  735.  *     - items.ctrl.php: Check permission to edit item with current status (also checks user levels) for update actions.
  736.  * - XML-RPC client: Re-added check for zlib support (removed by update).
  737.  * - XML-RPC APIs: Corrected method signatures (return type).
  738.  * - Localization:
  739.  *     - Fixed wrong permission description in blog user/group permissions screen.
  740.  *     - Removed wrong TRANS comment
  741.  *     - de-DE: Fixed bad translation strings (double quotes + HTML attribute = mess).
  742.  * - File upload:
  743.  *     - Suppress warnings generated by move_uploaded_file().
  744.  *     - File browser: Hide link to upload screen if no upload permission.
  745.  * - Further code optimizations.
  746.  *
  747.  * Revision 1.38  2009/08/26 16:52:15  tblue246
  748.  * Minor
  749.  *
  750.  * Revision 1.37  2009/03/15 15:04:22  tblue246
  751.  * minor
  752.  *
  753.  * Revision 1.36  2009/03/08 23:57:35  fplanque
  754.  * 2009
  755.  *
  756.  * Revision 1.35  2009/03/05 19:20:30  blueyed
  757.  * getmail.php: drop T_ usage of uncommon messages (where level>0). This saves the translators 42(!) translations. Also fixed translations to use sprintf and markers for variables.
  758.  *
  759.  * Revision 1.34  2009/03/03 20:01:41  blueyed
  760.  * getmail.php: minor: whitespace fixes, mostly coding style.
  761.  *
  762.  * Revision 1.33  2009/03/03 20:00:27  blueyed
  763.  * getmail.php: doc, minor cleanup, TODOs
  764.  *
  765.  * Revision 1.32  2009/01/23 22:52:29  tblue246
  766.  * Blog by mail: Ensure the month name in the "Date" header is valid.
  767.  *
  768.  * Revision 1.31  2008/12/31 16:04:04  tblue246
  769.  * Moving external classes needed by the blog by mail feature to inc/_ext.
  770.  *
  771.  * Revision 1.30  2008/12/31 15:21:24  blueyed
  772.  * TODO: please move ext. libs
  773.  *
  774.  * Revision 1.29  2008/12/18 01:04:17  blueyed
  775.  * getmail.php: drop $newline param for echo_message, which was true always. Small translation fix. Whitespace fixes.
  776.  *
  777.  * Revision 1.28  2008/10/06 11:02:27  tblue246
  778.  * Blog by mail now supports POP3 & IMAP, SSL & TLS
  779.  *
  780.  */
  781. ?>

Documentation generated on Sat, 06 Mar 2010 03:52:37 +0100 by phpDocumentor 1.4.2. This site is hosted and maintained by Daniel HAHLER (Contact).