Project

General

Profile

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