| 1 | <?php
 | 
  
    | 2 | 
 | 
  
    | 3 | // $Id: index.php 1112 2009-08-08 14:28:54Z Ruebenwurzel $
 | 
  
    | 4 | 
 | 
  
    | 5 | /*
 | 
  
    | 6 | 
 | 
  
    | 7 |  Website Baker Project <http://www.websitebaker.org/>
 | 
  
    | 8 |  Copyright (C) 2004-2009, Ryan Djurovich
 | 
  
    | 9 | 
 | 
  
    | 10 |  Website Baker is free software; you can redistribute it and/or modify
 | 
  
    | 11 |  it under the terms of the GNU General Public License as published by
 | 
  
    | 12 |  the Free Software Foundation; either version 2 of the License, or
 | 
  
    | 13 |  (at your option) any later version.
 | 
  
    | 14 | 
 | 
  
    | 15 |  Website Baker is distributed in the hope that it will be useful,
 | 
  
    | 16 |  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
  
    | 17 |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
  
    | 18 |  GNU General Public License for more details.
 | 
  
    | 19 | 
 | 
  
    | 20 |  You should have received a copy of the GNU General Public License
 | 
  
    | 21 |  along with Website Baker; if not, write to the Free Software
 | 
  
    | 22 |  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
  
    | 23 | 
 | 
  
    | 24 | */
 | 
  
    | 25 | 
 | 
  
    | 26 | // Print admin header
 | 
  
    | 27 | require('../../config.php');
 | 
  
    | 28 | require_once(WB_PATH.'/framework/class.admin.php');
 | 
  
    | 29 | $admin = new admin('Media', 'media');
 | 
  
    | 30 | include ('parameters.php');
 | 
  
    | 31 | 
 | 
  
    | 32 | // Setup template object
 | 
  
    | 33 | $template = new Template(THEME_PATH.'/templates');
 | 
  
    | 34 | $template->set_file('page', 'media.htt');
 | 
  
    | 35 | $template->set_block('page', 'main_block', 'main');
 | 
  
    | 36 | 
 | 
  
    | 37 | // Include the WB functions file
 | 
  
    | 38 | require_once(WB_PATH.'/framework/functions.php');
 | 
  
    | 39 | 
 | 
  
    | 40 | // Get home folder not to show
 | 
  
    | 41 | $home_folders = get_home_folders();
 | 
  
    | 42 | 
 | 
  
    | 43 | // Insert values
 | 
  
    | 44 | $template->set_block('main_block', 'dir_list_block', 'dir_list');
 | 
  
    | 45 | $dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
 | 
  
    | 46 | $currentHome = $admin->get_home_folder();
 | 
  
    | 47 | 
 | 
  
    | 48 | if ($currentHome){
 | 
  
    | 49 | 	$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY.$currentHome);
 | 
  
    | 50 | }
 | 
  
    | 51 | else
 | 
  
    | 52 | {
 | 
  
    | 53 | 	$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
 | 
  
    | 54 | }
 | 
  
    | 55 | $array_lowercase = array_map('strtolower', $dirs);
 | 
  
    | 56 | array_multisort($array_lowercase, SORT_ASC, SORT_STRING, $dirs);
 | 
  
    | 57 | foreach($dirs AS $name) {
 | 
  
    | 58 | 	if(!isset($home_folders[str_replace(WB_PATH.MEDIA_DIRECTORY, '', $name)])) {
 | 
  
    | 59 | 		$template->set_var('NAME', str_replace(WB_PATH, '', $name));
 | 
  
    | 60 | 		$template->parse('dir_list', 'dir_list_block', true);
 | 
  
    | 61 | 	}
 | 
  
    | 62 | }
 | 
  
    | 63 | 
 | 
  
    | 64 | // Insert permissions values
 | 
  
    | 65 | if($admin->get_permission('media_create') != true) {
 | 
  
    | 66 | 	$template->set_var('DISPLAY_CREATE', 'hide');
 | 
  
    | 67 | }
 | 
  
    | 68 | if($admin->get_permission('media_upload') != true) {
 | 
  
    | 69 | 	$template->set_var('DISPLAY_UPLOAD', 'hide');
 | 
  
    | 70 | }
 | 
  
    | 71 | if ($_SESSION['GROUP_ID'] != 1 && $pathsettings['global']['admin_only']) { // Only show admin the settings link
 | 
  
    | 72 | 	$template->set_var('DISPLAY_SETTINGS', 'hide');
 | 
  
    | 73 | }
 | 
  
    | 74 | // Workout if the up arrow should be shown
 | 
  
    | 75 | if(($dirs == '') or ($dirs==$currentHome) or (!array_key_exists('dir', $_GET))) {
 | 
  
    | 76 | 	$display_up_arrow = 'hide';
 | 
  
    | 77 | } else {
 | 
  
    | 78 | 	$display_up_arrow = '';
 | 
  
    | 79 | }
 | 
  
    | 80 | 
 | 
  
    | 81 | // Insert language headings
 | 
  
    | 82 | $template->set_var(array(
 | 
  
    | 83 | 								'HEADING_BROWSE_MEDIA' => $HEADING['BROWSE_MEDIA'],
 | 
  
    | 84 | 								'HOME_DIRECTORY' => $currentHome,
 | 
  
    | 85 | 								'DISPLAY_UP_ARROW' => $display_up_arrow, // **!
 | 
  
    | 86 | 								'HEADING_CREATE_FOLDER' => $HEADING['CREATE_FOLDER'],
 | 
  
    | 87 | 								'HEADING_UPLOAD_FILES' => $HEADING['UPLOAD_FILES']
 | 
  
    | 88 | 								)
 | 
  
    | 89 | 						);
 | 
  
    | 90 | // insert urls
 | 
  
    | 91 | $template->set_var(array(
 | 
  
    | 92 | 								'ADMIN_URL' => ADMIN_URL,
 | 
  
    | 93 | 								'WB_URL' => WB_URL,
 | 
  
    | 94 | 								'WB_PATH' => WB_PATH,
 | 
  
    | 95 | 								'THEME_URL' => THEME_URL
 | 
  
    | 96 | 								)
 | 
  
    | 97 | 						);
 | 
  
    | 98 | // Insert language text and messages
 | 
  
    | 99 | $template->set_var(array(
 | 
  
    | 100 | 								'MEDIA_DIRECTORY' => MEDIA_DIRECTORY,
 | 
  
    | 101 | 								'TEXT_NAME' => $TEXT['TITLE'],
 | 
  
    | 102 | 								'TEXT_RELOAD' => $TEXT['RELOAD'],
 | 
  
    | 103 | 								'TEXT_TARGET_FOLDER' => $TEXT['TARGET_FOLDER'],
 | 
  
    | 104 | 								'TEXT_OVERWRITE_EXISTING' => $TEXT['OVERWRITE_EXISTING'],
 | 
  
    | 105 | 								'TEXT_FILES' => $TEXT['FILES'],
 | 
  
    | 106 | 								'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'],
 | 
  
    | 107 | 								'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'],
 | 
  
    | 108 | 								'CHANGE_SETTINGS' => $TEXT['MODIFY_SETTINGS'],
 | 
  
    | 109 | 								'OPTIONS' => $TEXT['OPTION'],
 | 
  
    | 110 | 								'TEXT_UNZIP_FILE' => $TEXT['UNZIP_FILE'],
 | 
  
    | 111 | 								'TEXT_DELETE_ZIP' => $TEXT['DELETE_ZIP']
 | 
  
    | 112 | 								)
 | 
  
    | 113 | 						);
 | 
  
    | 114 | 
 | 
  
    | 115 | // Parse template object
 | 
  
    | 116 | $template->parse('main', 'main_block', false);
 | 
  
    | 117 | $template->pparse('output', 'page');
 | 
  
    | 118 | 
 | 
  
    | 119 | // Print admin 
 | 
  
    | 120 | $admin->print_footer();
 | 
  
    | 121 | 
 | 
  
    | 122 | ?>
 |