Website Baker PHP Cross Reference Content Management Systems

Source: /admin/media/setparameter.php - 134 lines - 4846 bytes - Summary - Text - Print

   1  <?php
   2  /**
   3   *
   4   * @category        admin
   5   * @package         media
   6   * @author          Ryan Djurovich, WebsiteBaker Project
   7   * @copyright       2009-2011, Website Baker Org. e.V.
   8   * @link            http://www.websitebaker2.org/
   9   * @license         http://www.gnu.org/licenses/gpl.html
  10   * @platform        WebsiteBaker 2.8.x
  11   * @requirements    PHP 5.2.2 and higher
  12   * @version         $Id: setparameter.php 1625 2012-02-29 00:50:57Z Luisehahne $
  13   * @filesource        $HeadURL:  $
  14   * @lastmodified    $Date:  $
  15   *
  16   */
  17  
  18  require('../../config.php');
  19  require_once (WB_PATH.'/framework/class.admin.php');
  20  $admin = new admin('Media', 'media', false);
  21  // Include the WB functions file
  22  require_once (WB_PATH.'/framework/functions.php');
  23  
  24  // check if theme language file exists for the language set by the user (e.g. DE, EN)
  25  if(!file_exists(THEME_PATH .'/languages/'.LANGUAGE .'.php')) {
  26      // no theme language file exists for the language set by the user, include default theme language file EN.php
  27      require_once (THEME_PATH .'/languages/EN.php');
  28  } else {
  29      // a theme language file exists for the language defined by the user, load it
  30      require_once(THEME_PATH .'/languages/'.LANGUAGE .'.php');
  31  }
  32  
  33  //Save post vars to the parameters file
  34  if ( !is_null($admin->get_post_escaped("save"))) {
  35  /*
  36      if (!$admin->checkFTAN())
  37      {
  38          $admin->print_error('::'.$MESSAGE['GENERIC_SECURITY_ACCESS'],'browse.php',false);
  39      }
  40  */
  41  
  42      if(DEFAULT_THEME != ' wb_theme') {
  43          //Check for existing settings entry, if not existing, create a record first!
  44          if (!$database->query ( "SELECT * FROM ".TABLE_PREFIX."settings where `name`='mediasettings'" )) {
  45              $database->query ( "INSERT INTO ".TABLE_PREFIX."settings (`name`,`value`) VALUES ('mediasettings','')" );
  46          }
  47      } else {
  48          $pathsettings = array();
  49      }
  50  
  51      $dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
  52      $dirs[] = WB_PATH.MEDIA_DIRECTORY;
  53      foreach($dirs AS $name) {
  54          $r = str_replace(WB_PATH, '', $name);
  55          $r = str_replace(array('/',' '),'_',$r);
  56          $w = (int)$admin->get_post_escaped($r.'-w');
  57          $h = (int)$admin->get_post_escaped($r.'-h');
  58          $pathsettings[$r]['width']=$w; 
  59          $pathsettings[$r]['height']=$h;
  60      }
  61      $pathsettings['global']['admin_only'] = ($admin->get_post_escaped('admin_only')!=''?'checked':'');
  62      $pathsettings['global']['show_thumbs'] = ($admin->get_post_escaped('show_thumbs')!=''?'checked':'');
  63      $fieldSerialized = serialize($pathsettings);
  64      $database->query ( "UPDATE ".TABLE_PREFIX."settings SET `value` = '$fieldSerialized' WHERE `name`='mediasettings'" );
  65      header ("Location: browse.php");
  66  }
  67  
  68  include  ('parameters.php');
  69  if ($_SESSION['GROUP_ID'] != 1 && $pathsettings['global']['admin_only']) {
  70      echo "Sorry, settings not available";
  71      exit();
  72  }
  73  
  74  // Read data to display
  75  $caller = "setparameter";
  76  
  77  // Setup template object, parse vars to it, then parse it
  78  // Create new template object
  79  $template = new Template(dirname($admin->correct_theme_source('setparameter.htt')));
  80  $template->set_file('page', 'setparameter.htt');
  81  $template->set_block('page', 'main_block', 'main');
  82  if ($_SESSION['GROUP_ID'] != 1) {
  83      $template->set_var('DISPLAY_ADMIN', 'hide');
  84  }
  85  $template->set_var(array( 
  86                  'TEXT_HEADER' => $TEXT['TEXT_HEADER'],
  87                  'SAVE_TEXT' => $TEXT['SAVE'],
  88                  'BACK' => $TEXT['BACK'],
  89              )
  90          );
  91  
  92  $template->set_block('main_block', 'list_block', 'list');
  93  $row_bg_color = '';
  94  $dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
  95  $dirs[] = WB_PATH.MEDIA_DIRECTORY;
  96  
  97  $array_lowercase = array_map('strtolower', $dirs);
  98  array_multisort($array_lowercase, SORT_ASC, SORT_STRING, $dirs);
  99  
 100  foreach($dirs AS $name) {
 101      $relative = str_replace(WB_PATH, '', $name);
 102      $safepath = str_replace(array('/',' '),'_',$relative);
 103      $cur_width = $cur_height = '';
 104      if (isset($pathsettings[$safepath]['width'])) $cur_width = $pathsettings[$safepath]['width'];
 105      if (isset($pathsettings[$safepath]['height'])) $cur_height = $pathsettings[$safepath]['height'];
 106      $cur_width = ($cur_width ? (int)$cur_width : '-');
 107      $cur_height = ($cur_height ? (int)$cur_height : '-');
 108  
 109      if($row_bg_color == 'DEDEDE') $row_bg_color = 'EEEEEE';
 110      else $row_bg_color = 'DEDEDE';
 111  
 112      $template->set_var(array( 
 113                      'ADMIN_URL' => ADMIN_URL,
 114                      'PATH_NAME' => $relative,
 115                      'WIDTH' => $TEXT['WIDTH'],
 116                      'HEIGHT' => $TEXT['HEIGHT'],
 117                      'FIELD_NAME_W' => $safepath.'-w',
 118                      'FIELD_NAME_H' => $safepath.'-h',
 119                      'CUR_WIDTH' => $cur_width,
 120                      'CUR_HEIGHT' => $cur_height,
 121                      'SETTINGS' => $TEXT['SETTINGS'],
 122                      'ADMIN_ONLY' => $TEXT['ADMIN_ONLY'],
 123                      'ADMIN_ONLY_SELECTED' => $pathsettings['global']['admin_only'],
 124                      'NO_SHOW_THUMBS' => $TEXT['NO_SHOW_THUMBS'],
 125                      'NO_SHOW_THUMBS_SELECTED' => $pathsettings['global']['show_thumbs'],
 126                      'ROW_BG_COLOR' => $row_bg_color,
 127                      'FTAN' => $admin->getFTAN()
 128                  )
 129          );
 130      $template->parse('list', 'list_block', true);
 131  }
 132  
 133  $template->parse('main', 'main_block', false);
 134  $template->pparse('output', 'page');

title

Description

title

Description

title

Description

title

title

Body