| 
      1
     | 
    
      <?php
 
     | 
  
  
    | 
      2
     | 
    
      /**
 
     | 
  
  
    | 
      3
     | 
    
       *
 
     | 
  
  
    | 
      4
     | 
    
       * @category        admin
 
     | 
  
  
    | 
      5
     | 
    
       * @package         admintools
 
     | 
  
  
    | 
      6
     | 
    
       * @author          Ryan Djurovich (2004-2009), WebsiteBaker Project
 
     | 
  
  
    | 
      7
     | 
    
       * @copyright       2009-2012, WebsiteBaker 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: index.php 1824 2012-11-20 17:41:22Z Luisehahne $
 
     | 
  
  
    | 
      13
     | 
    
       * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/media/index.php $
 
     | 
  
  
    | 
      14
     | 
    
       * @lastmodified    $Date: 2012-11-20 18:41:22 +0100 (Tue, 20 Nov 2012) $
 
     | 
  
  
    | 
      15
     | 
    
       *
 
     | 
  
  
    | 
      16
     | 
    
       */
 
     | 
  
  
    | 
      17
     | 
    
      
 
     | 
  
  
    | 
      18
     | 
    
      // Print admin header
 
     | 
  
  
    | 
      19
     | 
    
      if(!defined('WB_URL'))
     | 
  
  
    | 
      20
     | 
    
      {
     | 
  
  
    | 
      21
     | 
    
          $config_file = realpath('../../config.php');
     | 
  
  
    | 
      22
     | 
    
          if(file_exists($config_file) && !defined('WB_URL'))
     | 
  
  
    | 
      23
     | 
    
          {
     | 
  
  
    | 
      24
     | 
    
          	require($config_file);
 
     | 
  
  
    | 
      25
     | 
    
          }
 
     | 
  
  
    | 
      26
     | 
    
      }
 
     | 
  
  
    | 
      27
     | 
    
      if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
     | 
  
  
    | 
      28
     | 
    
      
 
     | 
  
  
    | 
      29
     | 
    
      $admin = new admin('Media', 'media');
     | 
  
  
    | 
      30
     | 
    
      
 
     | 
  
  
    | 
      31
     | 
    
      $starttime = explode(" ", microtime());
     | 
  
  
    | 
      32
     | 
    
      $starttime = $starttime[0]+$starttime[1];
 
     | 
  
  
    | 
      33
     | 
    
      include ('parameters.php');
     | 
  
  
    | 
      34
     | 
    
      
 
     | 
  
  
    | 
      35
     | 
    
      // Setup template object, parse vars to it, then parse it
 
     | 
  
  
    | 
      36
     | 
    
      // Create new template object
 
     | 
  
  
    | 
      37
     | 
    
      $template = new Template(dirname($admin->correct_theme_source('media.htt')));
     | 
  
  
    | 
      38
     | 
    
      $template->set_file('page', 'media.htt');
     | 
  
  
    | 
      39
     | 
    
      $template->set_block('page', 'main_block', 'main');
     | 
  
  
    | 
      40
     | 
    
      
 
     | 
  
  
    | 
      41
     | 
    
      // Include the WB functions file
 
     | 
  
  
    | 
      42
     | 
    
      if(!function_exists('directory_list')) { require(WB_PATH.'/framework/functions.php'); }
     | 
  
  
    | 
      43
     | 
    
      
 
     | 
  
  
    | 
      44
     | 
    
      // Target location
 
     | 
  
  
    | 
      45
     | 
    
      $requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
 
     | 
  
  
    | 
      46
     | 
    
      $directory = (isset(${$requestMethod}['dir'])) ? ${$requestMethod}['dir'] : '';
     | 
  
  
    | 
      47
     | 
    
      
 
     | 
  
  
    | 
      48
     | 
    
      $directory = ($directory == '/') ?  '' : $directory;
 
     | 
  
  
    | 
      49
     | 
    
      $dirlink = 'index.php?dir='.$directory;
 
     | 
  
  
    | 
      50
     | 
    
      $rootlink = 'index.php?dir=';
 
     | 
  
  
    | 
      51
     | 
    
      
 
     | 
  
  
    | 
      52
     | 
    
      // Get home folder not to show
 
     | 
  
  
    | 
      53
     | 
    
      $home_folders = (defined('HOME_FOLDERS') && HOME_FOLDERS) ? get_home_folders() : array();
     | 
  
  
    | 
      54
     | 
    
      
 
     | 
  
  
    | 
      55
     | 
    
      // Insert values
 
     | 
  
  
    | 
      56
     | 
    
      $template->set_block('main_block', 'dir_list_block', 'dir_list');
     | 
  
  
    | 
      57
     | 
    
      $dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
 
     | 
  
  
    | 
      58
     | 
    
      $currentHome = (defined('HOME_FOLDERS') && HOME_FOLDERS) ? $admin->get_home_folder() : '';
     | 
  
  
    | 
      59
     | 
    
      if ($currentHome!=''){
     | 
  
  
    | 
      60
     | 
    
      	$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY.$currentHome);
 
     | 
  
  
    | 
      61
     | 
    
      }
 
     | 
  
  
    | 
      62
     | 
    
      else
 
     | 
  
  
    | 
      63
     | 
    
      {
     | 
  
  
    | 
      64
     | 
    
      	$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
 
     | 
  
  
    | 
      65
     | 
    
      }
 
     | 
  
  
    | 
      66
     | 
    
      
 
     | 
  
  
    | 
      67
     | 
    
      $array_lowercase = array_map('strtolower', $dirs);
     | 
  
  
    | 
      68
     | 
    
      array_multisort($array_lowercase, SORT_ASC, SORT_STRING, $dirs);
 
     | 
  
  
    | 
      69
     | 
    
      foreach($dirs AS $name) {
     | 
  
  
    | 
      70
     | 
    
      
 
     | 
  
  
    | 
      71
     | 
    
      	if(!isset($home_folders[str_replace(WB_PATH.MEDIA_DIRECTORY, '', $name)]) || $currentHome =='' )
 
     | 
  
  
    | 
      72
     | 
    
          {
     | 
  
  
    | 
      73
     | 
    
      		$template->set_var('NAME', str_replace(WB_PATH, '', $name));
     | 
  
  
    | 
      74
     | 
    
      		$template->parse('dir_list', 'dir_list_block', true);
     | 
  
  
    | 
      75
     | 
    
      	}
 
     | 
  
  
    | 
      76
     | 
    
      }
 
     | 
  
  
    | 
      77
     | 
    
      
 
     | 
  
  
    | 
      78
     | 
    
      // Insert permissions values
 
     | 
  
  
    | 
      79
     | 
    
      if($admin->get_permission('media_create') != true) {
     | 
  
  
    | 
      80
     | 
    
      	$template->set_var('DISPLAY_CREATE', 'hide');
     | 
  
  
    | 
      81
     | 
    
      }
 
     | 
  
  
    | 
      82
     | 
    
      if($admin->get_permission('media_upload') != true) {
     | 
  
  
    | 
      83
     | 
    
      	$template->set_var('DISPLAY_UPLOAD', 'hide');
     | 
  
  
    | 
      84
     | 
    
      }
 
     | 
  
  
    | 
      85
     | 
    
      if ($_SESSION['GROUP_ID'] != 1 && (isset($pathsettings['global']['admin_only']) && $pathsettings['global']['admin_only'])) {
     | 
  
  
    | 
      86
     | 
    
          // Only show admin the settings link
 
     | 
  
  
    | 
      87
     | 
    
      	$template->set_var('DISPLAY_SETTINGS', 'hide');
     | 
  
  
    | 
      88
     | 
    
      }
 
     | 
  
  
    | 
      89
     | 
    
      // Workout if the up arrow should be shown
 
     | 
  
  
    | 
      90
     | 
    
      if(($dirs == '') or ($dirs==$currentHome) or (!array_key_exists('dir', $_GET))) {
     | 
  
  
    | 
      91
     | 
    
      	$display_up_arrow = 'hide';
 
     | 
  
  
    | 
      92
     | 
    
      } else {
     | 
  
  
    | 
      93
     | 
    
      	$display_up_arrow = '';
 
     | 
  
  
    | 
      94
     | 
    
      }
 
     | 
  
  
    | 
      95
     | 
    
      
 
     | 
  
  
    | 
      96
     | 
    
      // Insert language headings
 
     | 
  
  
    | 
      97
     | 
    
      $template->set_var(array(
 
     | 
  
  
    | 
      98
     | 
    
      					'HEADING_BROWSE_MEDIA' => $HEADING['BROWSE_MEDIA'],
 
     | 
  
  
    | 
      99
     | 
    
      					'HOME_DIRECTORY' => $currentHome,
 
     | 
  
  
    | 
      100
     | 
    
      //					'HOME_DIRECTORY' => ( $currentHome!='') ? $currentHome : $directory,
 
     | 
  
  
    | 
      101
     | 
    
      					'DISPLAY_UP_ARROW' => $display_up_arrow, // **!
 
     | 
  
  
    | 
      102
     | 
    
      					'HEADING_CREATE_FOLDER' => $HEADING['CREATE_FOLDER'],
 
     | 
  
  
    | 
      103
     | 
    
      					'HEADING_UPLOAD_FILES' => $HEADING['UPLOAD_FILES']
 
     | 
  
  
    | 
      104
     | 
    
      				)
 
     | 
  
  
    | 
      105
     | 
    
      			);
 
     | 
  
  
    | 
      106
     | 
    
      // insert urls
 
     | 
  
  
    | 
      107
     | 
    
      $template->set_var(array(
 
     | 
  
  
    | 
      108
     | 
    
      					'ADMIN_URL' => ADMIN_URL,
 
     | 
  
  
    | 
      109
     | 
    
      					'WB_URL' => WB_URL,
 
     | 
  
  
    | 
      110
     | 
    
      					'WB_PATH' => WB_PATH,
 
     | 
  
  
    | 
      111
     | 
    
      					'THEME_URL' => THEME_URL
 
     | 
  
  
    | 
      112
     | 
    
      				)
 
     | 
  
  
    | 
      113
     | 
    
      			);
 
     | 
  
  
    | 
      114
     | 
    
      // Insert language text and messages
 
     | 
  
  
    | 
      115
     | 
    
      $template->set_var(array(
 
     | 
  
  
    | 
      116
     | 
    
      					'MEDIA_DIRECTORY' => MEDIA_DIRECTORY,
 
     | 
  
  
    | 
      117
     | 
    
      //					'MEDIA_DIRECTORY' => ($currentHome!='') ? MEDIA_DIRECTORY : $currentHome,
 
     | 
  
  
    | 
      118
     | 
    
      					'TEXT_NAME' => $TEXT['TITLE'],
 
     | 
  
  
    | 
      119
     | 
    
      					'TEXT_RELOAD' => $TEXT['RELOAD'],
 
     | 
  
  
    | 
      120
     | 
    
      					'TEXT_TARGET_FOLDER' => $TEXT['TARGET_FOLDER'],
 
     | 
  
  
    | 
      121
     | 
    
      					'TEXT_OVERWRITE_EXISTING' => $TEXT['OVERWRITE_EXISTING'],
 
     | 
  
  
    | 
      122
     | 
    
      					'TEXT_FILES' => $TEXT['FILES'],
 
     | 
  
  
    | 
      123
     | 
    
      					'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'],
 
     | 
  
  
    | 
      124
     | 
    
      					'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'],
 
     | 
  
  
    | 
      125
     | 
    
      					'CHANGE_SETTINGS' => $TEXT['MODIFY_SETTINGS'],
 
     | 
  
  
    | 
      126
     | 
    
      					'OPTIONS' => $TEXT['OPTION'],
 
     | 
  
  
    | 
      127
     | 
    
      					'TEXT_UNZIP_FILE' => $TEXT['UNZIP_FILE'],
 
     | 
  
  
    | 
      128
     | 
    
      					'TEXT_DELETE_ZIP' => $TEXT['DELETE_ZIP'],
 
     | 
  
  
    | 
      129
     | 
    
      					'FTAN' => $admin->getFTAN()
 
     | 
  
  
    | 
      130
     | 
    
      				)
 
     | 
  
  
    | 
      131
     | 
    
      			);
 
     | 
  
  
    | 
      132
     | 
    
      
 
     | 
  
  
    | 
      133
     | 
    
      // Parse template object
 
     | 
  
  
    | 
      134
     | 
    
      $template->parse('main', 'main_block', false);
     | 
  
  
    | 
      135
     | 
    
      $template->pparse('output', 'page');
     | 
  
  
    | 
      136
     | 
    
      /*
 
     | 
  
  
    | 
      137
     | 
    
      $endtime=explode(" ", microtime());
     | 
  
  
    | 
      138
     | 
    
      $endtime=$endtime[0]+$endtime[1];
 
     | 
  
  
    | 
      139
     | 
    
      $debugVMsg = '';
 
     | 
  
  
    | 
      140
     | 
    
      if($admin->ami_group_member('1') ) {
     | 
  
  
    | 
      141
     | 
    
      	$debugVMsg  = "<p>Mask loaded in ".round($endtime - $starttime,6)." Sec,  ";
 
     | 
  
  
    | 
      142
     | 
    
      	$debugVMsg .= "Memory in use ".number_format(memory_get_usage(true), 0, ',', '.')." Byte,  ";
 
     | 
  
  
    | 
      143
     | 
    
      	$debugVMsg .= sizeof(get_included_files())." included files</p>";
 
     | 
  
  
    | 
      144
     | 
    
      	// $debugVMsg = print_message($debugVMsg,'#','debug',-1,false);
 
     | 
  
  
    | 
      145
     | 
    
      	print $debugVMsg.'<br />';
 
     | 
  
  
    | 
      146
     | 
    
       }
 
     | 
  
  
    | 
      147
     | 
    
      */
 
     | 
  
  
    | 
      148
     | 
    
      // Print admin
 
     | 
  
  
    | 
      149
     | 
    
      $admin->print_footer();
 
     |