Project

General

Profile

1 238 stefan
<?php
2 1400 FrankH
/**
3
 *
4
 * @category        admin
5
 * @package         admintools
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id$
14
 * @filesource		$HeadURL:  $
15
 * @lastmodified    $Date:  $
16
 *
17
 */
18 238 stefan
19
// Create admin object
20
require('../../config.php');
21
require_once(WB_PATH.'/framework/class.admin.php');
22
$admin = new admin('Media', 'media_rename', false);
23
24
// Include the WB functions file
25
require_once(WB_PATH.'/framework/functions.php');
26
27
// Get the current dir
28
$directory = $admin->get_get('dir');
29
if($directory == '/') {
30
	$directory = '';
31
}
32 1400 FrankH
33
// Check to see if it contains ..
34
if (!check_media_path($directory)) {
35 1457 Luisehahne
	$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH'], "browse.php?dir=$directory", false);
36 238 stefan
}
37
38
// Get the temp id
39 1400 FrankH
$file_id = $admin->checkIDKEY('id', false, 'GET');
40
if (!$file_id) {
41 1425 Luisehahne
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
42 238 stefan
}
43
44
// Get home folder not to show
45
$home_folders = get_home_folders();
46
47
// Figure out what folder name the temp id is
48
if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) {
49
	// Loop through the files and dirs an add to list
50
   while (false !== ($file = readdir($handle))) {
51
		if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
52
			if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
53
				if(!isset($home_folders[$directory.'/'.$file])) {
54
					$DIR[] = $file;
55
				}
56
			} else {
57
				$FILE[] = $file;
58
			}
59
		}
60
	}
61
	$temp_id = 0;
62
	if(isset($DIR)) {
63 384 Ruebenwurz
		sort($DIR);
64 238 stefan
		foreach($DIR AS $name) {
65
			$temp_id++;
66
			if($file_id == $temp_id) {
67
				$rename_file = $name;
68
				$type = 'folder';
69
			}
70
		}
71
	}
72
	if(isset($FILE)) {
73 384 Ruebenwurz
		sort($FILE);
74 238 stefan
		foreach($FILE AS $name) {
75
			$temp_id++;
76
			if($file_id == $temp_id) {
77
				$rename_file = $name;
78
				$type = 'file';
79
			}
80
		}
81
	}
82
}
83
84
if(!isset($rename_file)) {
85
	$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false);
86
}
87
88
// Setup template object
89 944 Ruebenwurz
$template = new Template(THEME_PATH.'/templates');
90
$template->set_file('page', 'media_rename.htt');
91 238 stefan
$template->set_block('page', 'main_block', 'main');
92
//echo WB_PATH.'/media/'.$directory.'/'.$rename_file;
93
if($type == 'folder') {
94
	$template->set_var('DISPlAY_EXTENSION', 'hide');
95
	$extension = '';
96
} else {
97
	$template->set_var('DISPlAY_EXTENSION', '');
98
	$extension = strstr($rename_file, '.');
99
}
100
101
if($type == 'folder') {
102
	$type = $TEXT['FOLDER'];
103
} else {
104
	$type = $TEXT['FILE'];
105
}
106
107
$template->set_var(array(
108 1457 Luisehahne
					'THEME_URL' => THEME_URL,
109
					'FILENAME' => $rename_file,
110
					'DIR' => $directory,
111
					'FILE_ID' => $admin->getIDKEY($file_id),
112
					'TYPE' => $type,
113
					'EXTENSION' => $extension,
114
					'FTAN' => $admin->getFTAN()
115
				)
116
			);
117 238 stefan
118
119
// Insert language text and messages
120
$template->set_var(array(
121 1457 Luisehahne
					'TEXT_TO' => $TEXT['TO'],
122
					'TEXT_RENAME' => $TEXT['RENAME'],
123
					'TEXT_CANCEL' => $TEXT['CANCEL'],
124
					'TEXT_UP' => $TEXT['UP'],
125
					'TEXT_OVERWRITE_EXISTING' => $TEXT['OVERWRITE_EXISTING']
126
				)
127
			);
128 238 stefan
129
// Parse template object
130
$template->parse('main', 'main_block', false);
131
$template->pparse('output', 'page');