b2evolution PHP Cross Reference Blogging Systems

Source: /inc/cron/jobs/_decode_returned_emails.job.php - 98 lines - 2981 bytes - Text - Print

Description: This file implements the return path inbox cron job

   1  <?php
   2  /**

   3   * This file implements the return path inbox cron job

   4   *

   5   * Uses MIME E-mail message parser classes written by Manuel Lemos: {@link http://www.phpclasses.org/browse/package/3169.html}

   6   *

   7   * @author Stephan Knauss

   8   * @author tblue246: Tilman Blumenbach

   9   * @author sam2kb: Alex

  10   *

  11   * TODO:

  12   * - Try more exotic email clients like mobile phones

  13   * - TODO Tested and working with thunderbird (text, html, signed), yahoo mail (text, html), outlook webmail, K800i

  14   * - Allow the user to choose whether to upload attachments to the blog media folder or to his user root.

  15   * - Create a copy of check_html_sanity function and clean up dangerous HTML code

  16   * - Add support for shortcodes instead of <tags> similar to:

  17   *    [title Your post title]

  18   *    [category x,y,z]

  19   *    [excerpt]some excerpt[/excerpt]

  20   *    [tags x,y,z]

  21   *    [delay +1 hour]

  22   *    [comments on | off]

  23   *    [status publish | pending | draft | private]

  24   *    [slug some-url-name]

  25   *    [end]  everything after this shortcode is ignored (i.e. signatures)

  26   *    [more]  more tag

  27   *    [nextpage]  pagination

  28   *

  29   * @version $Id: _decode_returned_emails.job.php 460 2011-12-01 10:09:16Z yura $

  30   */
  31  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  32  
  33  global $Settings, $DB, $result_message;
  34  global $dre_messages, $dre_emails, $email_cntr, $del_cntr, $is_cron_mode;
  35  
  36  // Are we in cron job mode?

  37  $is_cron_mode = 'yes';
  38  
  39  load_funcs( 'cron/model/_decode_returned_emails.funcs.php' );
  40  
  41  if( ! $Settings->get( 'repath_enabled' ) )
  42  {
  43      dre_msg( T_('Return path processing feature is not enabled.'), true );
  44      return 2; // error

  45  }
  46  
  47  if( ! extension_loaded('imap') )
  48  {
  49      dre_msg( T_('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.'), true );
  50      return 2; // error

  51  }
  52  
  53  load_funcs( '_core/_param.funcs.php' );
  54  load_class( '_ext/mime_parser/rfc822_addresses.php', 'rfc822_addresses_class' );
  55  load_class( '_ext/mime_parser/mime_parser.php', 'mime_parser_class' );
  56  
  57  if( isset($GLOBALS['files_Module']) )
  58  {
  59      load_funcs( 'files/model/_file.funcs.php');
  60  }
  61  
  62  if( ! $mbox = dre_connect() )
  63  {    // We couldn't connect to the mail server
  64      return 2; // error

  65  }
  66  
  67  // Read messages from server

  68  dre_msg('Reading messages from server');
  69  $imap_obj = imap_check( $mbox );
  70  dre_msg('Found '.$imap_obj->Nmsgs.' messages');
  71  
  72  if( $imap_obj->Nmsgs == 0 )
  73  {
  74      dre_msg( T_('There are no messages in the mailbox'), true );
  75      imap_close( $mbox );
  76      return 1; // success

  77  }
  78  
  79  // Create posts

  80  dre_process_messages( $mbox, $imap_obj->Nmsgs );
  81  
  82  if( count($del_cntr) > 0 )
  83  {    // We want to delete processed emails from server
  84      imap_expunge( $mbox );
  85      dre_msg( sprintf('Deleted %d processed message(s) from inbox.', $del_cntr) );
  86  }
  87  
  88  imap_close( $mbox );
  89  
  90  // Show reports

  91  if( $email_cntr > 0 )
  92  {
  93      dre_msg( sprintf( T_('New emails saved: %d'), $email_cntr ), true );
  94  }
  95  
  96  return 1; // success

  97  
  98  ?>

title

Description

title

Description

title

Description

title

title

Body