b2evolution PHP Cross Reference Blogging Systems

Source: /inc/files/file_settings.ctrl.php - 234 lines - 8187 bytes - Text - Print

Description: This file implements the UI controller for file settings management. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the UI controller for file settings management.
   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   * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  10   * Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}.
  11   *
  12   * {@internal License choice
  13   * - If you have received this file as part of a package, please find the license.txt file in
  14   *   the same folder or the closest folder above for complete license terms.
  15   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  16   *   then you must choose one of the following licenses before using the file:
  17   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  18   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  19   * }}
  20   *
  21   * {@internal Open Source relicensing agreement:
  22   * Daniel HAHLER grants Francois PLANQUE the right to license
  23   * Daniel HAHLER's contributions to this file and the b2evolution project
  24   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  25   *
  26   * PROGIDISTRI S.A.S. grants Francois PLANQUE the right to license
  27   * PROGIDISTRI S.A.S.'s contributions to this file and the b2evolution project
  28   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  29   * }}
  30   *
  31   * @package admin
  32   *
  33   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  34   * @author fplanque: Francois PLANQUE.
  35   * @author blueyed: Daniel HAHLER.
  36   * @author mbruneau: Marc BRUNEAU / PROGIDISTRI
  37   *
  38   * @version $Id: file_settings.ctrl.php 6136 2014-03-08 07:59:48Z manuel $
  39   */
  40  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  41  
  42  
  43  // Check minimum permission:
  44  $current_User->check_perm( 'options', 'view', true );
  45  
  46  
  47  param( 'action', 'string' );
  48  
  49  if( $demo_mode && !empty($action) )
  50  {
  51      $Messages->add( 'You cannot make any edits on this screen while in demo mode.', 'error' );
  52      $action = '';
  53  }
  54  
  55  switch( $action )
  56  {
  57      case 'update':
  58          // Check that this action request is not a CSRF hacked request:
  59          $Session->assert_received_crumb( 'file' );
  60  
  61          // Check permission:
  62          $current_User->check_perm( 'options', 'edit', true );
  63  
  64          param( 'submit', 'array/string', array() );
  65          if( isset($submit['restore_defaults']) )
  66          {
  67              $Settings->delete_array( array(
  68                      'fm_enable_roots_blog',
  69                      'fm_enable_roots_user',
  70                      'fm_enable_roots_shared',
  71                      'fm_enable_roots_skins',
  72                      'fm_enable_create_dir',
  73                      'fm_default_chmod_dir',
  74                      'fm_enable_create_file',
  75                      'fm_default_chmod_file',
  76                      'upload_enabled',
  77                      'upload_maxkb',
  78                      'regexp_filename',
  79                      'exif_orientation',
  80                      'fm_resize_enable',
  81                      'fm_resize_width',
  82                      'fm_resize_height',
  83                      'fm_resize_quality' ) );
  84              if( $Settings->dbupdate() )
  85              {
  86                  $Messages->add( T_('Restored default values.'), 'success' );
  87              }
  88              else
  89              {
  90                  $Messages->add( T_('Settings have not changed.'), 'note' );
  91              }
  92          }
  93          else
  94          {
  95              // Filemanager
  96              param( 'fm_enable_roots_blog', 'integer', 0 );
  97              $Settings->set( 'fm_enable_roots_blog', $fm_enable_roots_blog );
  98  
  99              param( 'fm_enable_roots_user', 'integer', 0 );
 100              $Settings->set( 'fm_enable_roots_user', $fm_enable_roots_user );
 101  
 102              param( 'fm_enable_roots_shared', 'integer', 0 );
 103              $Settings->set( 'fm_enable_roots_shared', $fm_enable_roots_shared );
 104  
 105              param( 'fm_enable_roots_skins', 'integer', 0 );
 106              $Settings->set( 'fm_enable_roots_skins', $fm_enable_roots_skins );
 107  
 108              param( 'fm_enable_create_dir', 'integer', 0 );
 109              $Settings->set( 'fm_enable_create_dir', $fm_enable_create_dir );
 110  
 111              // Default dir CHMOD:
 112              if( param( 'fm_default_chmod_dir', 'string', NULL ) !== NULL )
 113              {
 114                  if( ! preg_match('~^[0-7]{3}$~', $fm_default_chmod_dir) )
 115                  {
 116                      param_error('fm_default_chmod_dir', T_('Invalid CHMOD value. Use 3 digits.'));
 117                  }
 118  
 119                  $Settings->set( 'fm_default_chmod_dir', $fm_default_chmod_dir );
 120              }
 121  
 122              param( 'fm_enable_create_file', 'integer', 0 );
 123              $Settings->set( 'fm_enable_create_file', $fm_enable_create_file );
 124  
 125              // Default files CHMOD:
 126              if( param( 'fm_default_chmod_file', 'string', NULL ) !== NULL )
 127              {
 128                  if( ! preg_match('~^[0-7]{3}$~', $fm_default_chmod_file) )
 129                  {
 130                      param_error('fm_default_chmod_file', T_('Invalid CHMOD value. Use 3 digits.'));
 131                  }
 132  
 133                  $Settings->set( 'fm_default_chmod_file', $fm_default_chmod_file );
 134              }
 135  
 136              // Upload
 137              param( 'upload_enabled', 'integer', 0 );
 138              $Settings->set( 'upload_enabled', $upload_enabled );
 139  
 140              param_integer_range( 'upload_maxkb', 1, $upload_maxmaxkb, T_('Maximum allowed filesize must be between %d and %d KB.') );
 141              $Settings->set( 'upload_maxkb', $upload_maxkb );
 142  
 143              // Advanced settings
 144              param( 'regexp_filename', 'string', '' );
 145              if( param_check_isregexp( 'regexp_filename', T_('Valid filename pattern is not a regular expression!') ) )
 146              {
 147                  $Settings->set( 'regexp_filename', $regexp_filename );
 148              }
 149              param( 'regexp_dirname', 'string', '' );
 150              if( param_check_isregexp( 'regexp_dirname', T_('Valid dirname pattern is not a regular expression!') ) )
 151              {
 152                  $Settings->set( 'regexp_dirname', $regexp_dirname );
 153              }
 154              param( 'evocache_foldername', 'string', '');
 155              $old_foldername = $Settings->get( 'evocache_foldername' );
 156              if( $old_foldername != $evocache_foldername)
 157              { // ?evocache folder name has changed
 158                  if( rename_cachefolders( $old_foldername, $evocache_foldername ) )
 159                  {
 160                      $Messages->add( sprintf( T_( 'All %s folders have been renamed to %s' ), $old_foldername, $evocache_foldername ), 'success' );
 161                  }
 162                  else
 163                  {
 164                      $Messages->add( sprintf( T_( 'Some %s folders could not be renamed to %s' ), $old_foldername, $evocache_foldername ), 'warning' );
 165                  }
 166                  $Settings->set( 'evocache_foldername', $evocache_foldername );
 167              }
 168  
 169              // Save Image options
 170              param( 'exif_orientation', 'integer', 0 );
 171              $Settings->set( 'exif_orientation', $exif_orientation );
 172              param( 'fm_resize_enable', 'integer', 0 );
 173              $Settings->set( 'fm_resize_enable', $fm_resize_enable );
 174              param( 'fm_resize_width', 'integer', 0 );
 175              $Settings->set( 'fm_resize_width', $fm_resize_width );
 176              param( 'fm_resize_height', 'integer', 0 );
 177              $Settings->set( 'fm_resize_height', $fm_resize_height );
 178              param_integer_range( 'fm_resize_quality', 0, 100, T_('The compression value must be between %d and %d.') );
 179              $Settings->set( 'fm_resize_quality', $fm_resize_quality );
 180  
 181              if( ! $Messages->has_errors() )
 182              {
 183                  if( $Settings->dbupdate() )
 184                  {
 185                      $Messages->add( T_('File settings updated.'), 'success' );
 186                  }
 187                  else
 188                  {
 189                      $Messages->add( T_('Settings have not changed.'), 'note' );
 190                  }
 191              }
 192          }
 193          // Redirect so that a reload doesn't write to the DB twice:
 194          header_redirect( '?ctrl=fileset', 303 ); // Will EXIT
 195          // We have EXITed already at this point!!
 196  
 197          break;
 198  }
 199  
 200  /**
 201   * We need make this call to build menu for all modules
 202   */
 203  $AdminUI->set_path( 'files' );
 204  
 205  file_controller_build_tabs();
 206  
 207  $AdminUI->set_path( 'files', 'settings', 'settings' );
 208  
 209  // fp> TODO: this here is a bit sketchy since we have Blog & fileroot not necessarilly in sync. Needs investigation / propositions.
 210  // Note: having both allows to post from any media dir into any blog.
 211  $AdminUI->breadcrumbpath_init( false );
 212  $AdminUI->breadcrumbpath_add( T_('Files'), '?ctrl=files&amp;blog=$blog$' );
 213  $AdminUI->breadcrumbpath_add( T_('Settings'), '?ctrl=fileset' );
 214  
 215  
 216  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
 217  $AdminUI->disp_html_head();
 218  
 219  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
 220  $AdminUI->disp_body_top();
 221  
 222  // Begin payload block:
 223  $AdminUI->disp_payload_begin();
 224  
 225  // Display VIEW:
 226  $AdminUI->disp_view( 'files/views/_file_settings.form.php' );
 227  
 228  // End payload block:
 229  $AdminUI->disp_payload_end();
 230  
 231  // Display body bottom, debug info and close </html>:
 232  $AdminUI->disp_global_footer();
 233  
 234  ?>

title

Description

title

Description

title

Description

title

title

Body