b2evolution PHP Cross Reference Blogging Systems

Source: /inc/settings/remotepublish.ctrl.php - 236 lines - 7360 bytes - Text - Print

Description: This file implements the UI controller for Remote Publishing.

   1  <?php
   2  /**
   3   * This file implements the UI controller for Remote Publishing.
   4   *
   5   * This file is part of the evoCore framework - {@link http://evocore.net/}
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   9   *
  10   * @package admin
  11   *
  12   * @version $Id: remotepublish.ctrl.php 6136 2014-03-08 07:59:48Z manuel $
  13   */
  14  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  15  
  16  // Check minimum permission:
  17  $current_User->check_perm( 'options', 'view', true );
  18  
  19  // Store/retrieve preferred tab from UserSettings:
  20  $UserSettings->param_Request( 'tab', 'pref_remotepublish_tab', 'string', 'eblog', true /* memorize */, true /* force */ );
  21  
  22  // Memorize this as the last "tab" used in the Blog Settings:
  23  $UserSettings->set( 'pref_glob_settings_tab', $ctrl );
  24  $UserSettings->dbupdate();
  25  
  26  $AdminUI->set_path( 'options', 'remotepublish' );
  27  
  28  param( 'action', 'string' );
  29  
  30  switch( $action )
  31  {
  32      case 'update':
  33          // Check that this action request is not a CSRF hacked request:
  34          $Session->assert_received_crumb( 'globalsettings' );
  35  
  36          // Check permission:
  37          $current_User->check_perm( 'options', 'edit', true );
  38  
  39          switch( $tab )
  40          {
  41              case 'eblog':
  42                  param( 'eblog_enabled', 'boolean', 0 );
  43                  $Settings->set( 'eblog_enabled', $eblog_enabled );
  44  
  45                  param( 'eblog_method', 'string', true );
  46                  $Settings->set( 'eblog_method', strtolower($eblog_method) );
  47  
  48                  param( 'eblog_encrypt', 'string', true );
  49                  $Settings->set( 'eblog_encrypt', $eblog_encrypt );
  50  
  51                  param( 'eblog_novalidatecert', 'boolean', 0 );
  52                  $Settings->set( 'eblog_novalidatecert', $eblog_novalidatecert );
  53  
  54                  param( 'eblog_server_host', 'string', true );
  55                  $Settings->set( 'eblog_server_host', evo_strtolower($eblog_server_host) );
  56  
  57                  param( 'eblog_server_port', 'integer', true );
  58                  $Settings->set( 'eblog_server_port', $eblog_server_port );
  59  
  60                  param( 'eblog_username', 'string', true );
  61                  $Settings->set( 'eblog_username', $eblog_username );
  62  
  63                  param( 'eblog_password', 'string', true );
  64                  $Settings->set( 'eblog_password', $eblog_password );
  65  
  66                  param( 'eblog_default_category', 'integer', true );
  67                  $Settings->set( 'eblog_default_category', $eblog_default_category );
  68  
  69                  param( 'eblog_default_title', 'string', true );
  70                  $Settings->set( 'eblog_default_title', $eblog_default_title );
  71  
  72                  param( 'eblog_subject_prefix', 'string', true );
  73                  $Settings->set( 'eblog_subject_prefix', $eblog_subject_prefix );
  74  
  75                  param( 'eblog_body_terminator', 'string', true );
  76                  $Settings->set( 'eblog_body_terminator', $eblog_body_terminator );
  77  
  78                  param( 'eblog_test_mode', 'boolean', 0 );
  79                  $Settings->set( 'eblog_test_mode', $eblog_test_mode );
  80  
  81                  param( 'eblog_add_imgtag', 'boolean', 0 );
  82                  $Settings->set( 'eblog_add_imgtag', $eblog_add_imgtag );
  83  
  84                  param( 'eblog_html_enabled', 'boolean', 0 );
  85                  $Settings->set( 'eblog_html_enabled', $eblog_html_enabled );
  86  
  87                  param( 'eblog_html_tag_limit', 'boolean', 0 );
  88                  $Settings->set( 'eblog_html_tag_limit', $eblog_html_tag_limit );
  89  
  90                  param( 'eblog_delete_emails', 'boolean', 0 );
  91                  $Settings->set( 'eblog_delete_emails', $eblog_delete_emails );
  92  
  93                  if( param( 'renderers_displayed', 'integer', 0 ) )
  94                  { // use "renderers" value only if it has been displayed (may be empty)
  95                      global $Plugins;
  96                      $autoselect_blog = autoselect_blog( 'blog_post_statuses', 'edit' );
  97                      $BlogCache = & get_BlogCache();
  98                      $setting_Blog = & $BlogCache->get_by_ID( $autoselect_blog );
  99                      $renderer_params = array( 'Blog' => & $setting_Blog, 'setting_name' => 'coll_apply_rendering' );
 100                      $renderers = $Plugins->validate_renderer_list( param( 'eblog_renderers', 'array/string', array() ), $renderer_params );
 101                      $Settings->set( 'eblog_renderers', $renderers );
 102                  }
 103                  break;
 104  
 105              case 'xmlrpc':
 106                  $Settings->set( 'general_xmlrpc', param( 'general_xmlrpc', 'integer', 0 ) );
 107  
 108                  param( 'xmlrpc_default_title', 'string', true );
 109                  $Settings->set( 'xmlrpc_default_title', $xmlrpc_default_title );
 110                  break;
 111          }
 112  
 113          if( ! $Messages->has_errors() )
 114          {
 115              $Settings->dbupdate();
 116              $Messages->add( T_('General settings updated.'), 'success' );
 117              // Redirect so that a reload doesn't write to the DB twice:
 118              header_redirect( '?ctrl=remotepublish', 303 ); // Will EXIT
 119              // We have EXITed already at this point!!
 120          }
 121          break;
 122  
 123      case 'test_1':
 124      case 'test_2':
 125      case 'test_3':
 126          // Check that this action request is not a CSRF hacked request:
 127          $Session->assert_received_crumb( 'globalsettings' );
 128  
 129          // Check permission:
 130          $current_User->check_perm( 'options', 'edit', true );
 131  
 132          load_funcs( 'cron/model/_post_by_mail.funcs.php');
 133          load_class( 'items/model/_itemlist.class.php', 'ItemList' );
 134          load_class( '_ext/mime_parser/rfc822_addresses.php', 'rfc822_addresses_class' );
 135          load_class( '_ext/mime_parser/mime_parser.php', 'mime_parser_class' );
 136  
 137          if( isset($GLOBALS['files_Module']) )
 138          {
 139              load_funcs( 'files/model/_file.funcs.php');
 140          }
 141  
 142          global $pbm_messages;
 143  
 144          if( $action == 'test_1' )
 145          {
 146              if( $mbox = pbm_connect() )
 147              {    // Close opened connection
 148                  imap_close( $mbox );
 149              }
 150          }
 151          elseif( $action == 'test_2' || $action == 'test_3' )
 152          {
 153              if( $mbox = pbm_connect() )
 154              {
 155                  // Read messages from server
 156                  pbm_msg('Reading messages from server');
 157                  $imap_obj = imap_check( $mbox );
 158                  pbm_msg('Found '.$imap_obj->Nmsgs.' messages');
 159  
 160                  if( $imap_obj->Nmsgs > 0 )
 161                  {
 162                      if( $action == 'test_2' )
 163                      {    // Pretend that we're in test mode. DO NOT save this setting!
 164                          $eblog_saved_test_mode_value = $Settings->get('eblog_test_mode');
 165                          $Settings->set('eblog_test_mode', 1);
 166                      }
 167  
 168                      // We will read only 1 message from server in test mode
 169                      pbm_process_messages( $mbox, 1 );
 170                  }
 171                  else
 172                  {
 173                      pbm_msg( T_('There are no messages in the mailbox') );
 174                  }
 175                  imap_close( $mbox );
 176              }
 177          }
 178  
 179          $Messages->clear(); // Clear all messages
 180  
 181          if( !empty($pbm_messages) )
 182          {    // We will display the output in a scrollable fieldset
 183              $eblog_test_output = implode( "<br />\n", $pbm_messages );
 184          }
 185          break;
 186  }
 187  
 188  $AdminUI->breadcrumbpath_init( false );
 189  $AdminUI->breadcrumbpath_add( T_('System'), '?ctrl=system',
 190          T_('Global settings are shared between all blogs; see Blog settings for more granular settings.') );
 191  $AdminUI->breadcrumbpath_add( T_('Remote publishing'), '?ctrl=remotepublish' );
 192  
 193  switch( $tab )
 194  {
 195      case 'eblog':
 196          $AdminUI->breadcrumbpath_add( T_('Post by Email'), '?ctrl=remotepublish&amp;tab='.$tab );
 197          break;
 198  
 199      case 'xmlrpc':
 200          $AdminUI->breadcrumbpath_add( T_('XML-RPC'), '?ctrl=remotepublish&amp;tab='.$tab );
 201          break;
 202  }
 203  
 204  if( !empty($tab) )
 205  {
 206      $AdminUI->append_path_level( $tab );
 207  }
 208  
 209  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
 210  $AdminUI->disp_html_head();
 211  
 212  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
 213  $AdminUI->disp_body_top();
 214  
 215  // Begin payload block:
 216  $AdminUI->disp_payload_begin();
 217  
 218  // Display VIEW:
 219  switch( $tab )
 220  {
 221      case 'eblog':
 222          $AdminUI->disp_view( 'settings/views/_eblog.form.php' );
 223          break;
 224  
 225      case 'xmlrpc':
 226          $AdminUI->disp_view( 'settings/views/_xmlrpc.form.php' );
 227          break;
 228  }
 229  
 230  // End payload block:
 231  $AdminUI->disp_payload_end();
 232  
 233  // Display body bottom, debug info and close </html>:
 234  $AdminUI->disp_global_footer();
 235  
 236  ?>

title

Description

title

Description

title

Description

title

title

Body