Revision 8
Added by stefan about 19 years ago
rename.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id: rename.php,v 1.4 2005/04/04 00:56:30 rdjurovich Exp $ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2005, 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 |
// Create admin object |
|
27 |
require('../../config.php'); |
|
28 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
29 |
$admin = new admin('Media', 'media_rename', false); |
|
30 |
|
|
31 |
// Include the WB functions file |
|
32 |
require_once(WB_PATH.'/framework/functions.php'); |
|
33 |
|
|
34 |
// Include the basic header file |
|
35 |
require(ADMIN_PATH.'/media/basic_header.html'); |
|
36 |
|
|
37 |
// Get the current dir |
|
38 |
$directory = $admin->get_get('dir'); |
|
39 |
if($directory == '/') { |
|
40 |
$directory = ''; |
|
41 |
} |
|
42 |
// Check to see if it contains ../ |
|
43 |
if(strstr($directory, '../')) { |
|
44 |
$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH'], "rename.php?dir=$directory&id=$file_id", false); |
|
45 |
} |
|
46 |
|
|
47 |
// Get the temp id |
|
48 |
if(!is_numeric($admin->get_get('id'))) { |
|
49 |
header("Location: browse.php?dir=$directory"); |
|
50 |
} else { |
|
51 |
$file_id = $admin->get_get('id'); |
|
52 |
} |
|
53 |
|
|
54 |
// Get home folder not to show |
|
55 |
$home_folders = get_home_folders(); |
|
56 |
|
|
57 |
// Figure out what folder name the temp id is |
|
1 |
<?php
|
|
2 |
|
|
3 |
// $Id: rename.php,v 1.4 2005/04/04 00:56:30 rdjurovich Exp $
|
|
4 |
|
|
5 |
/*
|
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/>
|
|
8 |
Copyright (C) 2004-2005, 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 |
// Create admin object
|
|
27 |
require('../../config.php');
|
|
28 |
require_once(WB_PATH.'/framework/class.admin.php');
|
|
29 |
$admin = new admin('Media', 'media_rename', false);
|
|
30 |
|
|
31 |
// Include the WB functions file
|
|
32 |
require_once(WB_PATH.'/framework/functions.php');
|
|
33 |
|
|
34 |
// Include the basic header file
|
|
35 |
require(ADMIN_PATH.'/media/basic_header.html');
|
|
36 |
|
|
37 |
// Get the current dir
|
|
38 |
$directory = $admin->get_get('dir');
|
|
39 |
if($directory == '/') {
|
|
40 |
$directory = '';
|
|
41 |
}
|
|
42 |
// Check to see if it contains ../
|
|
43 |
if(strstr($directory, '../')) {
|
|
44 |
$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH'], "rename.php?dir=$directory&id=$file_id", false);
|
|
45 |
}
|
|
46 |
|
|
47 |
// Get the temp id
|
|
48 |
if(!is_numeric($admin->get_get('id'))) {
|
|
49 |
header("Location: browse.php?dir=$directory");
|
|
50 |
} else {
|
|
51 |
$file_id = $admin->get_get('id');
|
|
52 |
}
|
|
53 |
|
|
54 |
// Get home folder not to show
|
|
55 |
$home_folders = get_home_folders();
|
|
56 |
|
|
57 |
// Figure out what folder name the temp id is
|
|
58 | 58 |
if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) { |
59 |
// Loop through the files and dirs an add to list |
|
59 |
// Loop through the files and dirs an add to list
|
|
60 | 60 |
while (false !== ($file = readdir($handle))) { |
61 |
if(substr($file, 0, 1) != '.' AND $file != 'CVS' AND $file != 'index.php') {
|
|
62 |
if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) { |
|
61 |
if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
|
|
62 |
if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
|
|
63 | 63 |
if(!isset($home_folders[$directory.'/'.$file])) { |
64 |
$DIR[] = $file; |
|
65 |
} |
|
66 |
} else { |
|
67 |
$FILE[] = $file; |
|
68 |
} |
|
69 |
} |
|
70 |
} |
|
71 |
$temp_id = 0; |
|
72 |
if(isset($DIR)) { |
|
73 |
foreach($DIR AS $name) { |
|
74 |
$temp_id++; |
|
75 |
if($file_id == $temp_id) { |
|
76 |
$rename_file = $name; |
|
77 |
$type = 'folder'; |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
if(isset($FILE)) { |
|
82 |
foreach($FILE AS $name) { |
|
83 |
$temp_id++; |
|
84 |
if($file_id == $temp_id) { |
|
85 |
$rename_file = $name; |
|
86 |
$type = 'file'; |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
if(!isset($rename_file)) { |
|
93 |
$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false); |
|
94 |
} |
|
95 |
|
|
96 |
// Setup template object |
|
97 |
$template = new Template(ADMIN_PATH.'/media'); |
|
98 |
$template->set_file('page', 'rename.html'); |
|
99 |
$template->set_block('page', 'main_block', 'main'); |
|
100 |
//echo WB_PATH.'/media/'.$directory.'/'.$rename_file; |
|
101 |
if($type == 'folder') { |
|
102 |
$template->set_var('DISPlAY_EXTENSION', 'hide'); |
|
103 |
$extension = ''; |
|
104 |
} else { |
|
105 |
$template->set_var('DISPlAY_EXTENSION', ''); |
|
106 |
$extension = strstr($rename_file, '.'); |
|
107 |
} |
|
108 |
|
|
109 |
if($type == 'folder') { |
|
110 |
$type = $TEXT['FOLDER']; |
|
111 |
} else { |
|
112 |
$type = $TEXT['FILE']; |
|
113 |
} |
|
114 |
|
|
115 |
$template->set_var(array( |
|
116 |
'FILENAME' => $rename_file, |
|
117 |
'DIR' => $directory, |
|
118 |
'FILE_ID' => $file_id, |
|
119 |
'TYPE' => $type, |
|
120 |
'EXTENSION' => $extension |
|
121 |
) |
|
122 |
); |
|
123 |
|
|
124 |
|
|
125 |
// Insert language text and messages |
|
126 |
$template->set_var(array( |
|
127 |
'TEXT_TO' => $TEXT['TO'], |
|
128 |
'TEXT_RENAME' => $TEXT['RENAME'], |
|
129 |
'TEXT_CANCEL' => $TEXT['CANCEL'], |
|
130 |
'TEXT_UP' => $TEXT['UP'], |
|
131 |
'TEXT_OVERWRITE_EXISTING' => $TEXT['OVERWRITE_EXISTING'] |
|
132 |
) |
|
133 |
); |
|
134 |
|
|
135 |
// Parse template object |
|
136 |
$template->parse('main', 'main_block', false); |
|
137 |
$template->pparse('output', 'page'); |
|
138 |
|
|
139 |
?> |
|
64 |
$DIR[] = $file; |
|
65 |
} |
|
66 |
} else { |
|
67 |
$FILE[] = $file; |
|
68 |
} |
|
69 |
} |
|
70 |
} |
|
71 |
$temp_id = 0; |
|
72 |
if(isset($DIR)) { |
|
73 |
foreach($DIR AS $name) { |
|
74 |
$temp_id++; |
|
75 |
if($file_id == $temp_id) { |
|
76 |
$rename_file = $name; |
|
77 |
$type = 'folder'; |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
if(isset($FILE)) { |
|
82 |
foreach($FILE AS $name) { |
|
83 |
$temp_id++; |
|
84 |
if($file_id == $temp_id) { |
|
85 |
$rename_file = $name; |
|
86 |
$type = 'file'; |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
if(!isset($rename_file)) { |
|
93 |
$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false); |
|
94 |
} |
|
95 |
|
|
96 |
// Setup template object |
|
97 |
$template = new Template(ADMIN_PATH.'/media'); |
|
98 |
$template->set_file('page', 'rename.html'); |
|
99 |
$template->set_block('page', 'main_block', 'main'); |
|
100 |
//echo WB_PATH.'/media/'.$directory.'/'.$rename_file; |
|
101 |
if($type == 'folder') { |
|
102 |
$template->set_var('DISPlAY_EXTENSION', 'hide'); |
|
103 |
$extension = ''; |
|
104 |
} else { |
|
105 |
$template->set_var('DISPlAY_EXTENSION', ''); |
|
106 |
$extension = strstr($rename_file, '.'); |
|
107 |
} |
|
108 |
|
|
109 |
if($type == 'folder') { |
|
110 |
$type = $TEXT['FOLDER']; |
|
111 |
} else { |
|
112 |
$type = $TEXT['FILE']; |
|
113 |
} |
|
114 |
|
|
115 |
$template->set_var(array( |
|
116 |
'FILENAME' => $rename_file, |
|
117 |
'DIR' => $directory, |
|
118 |
'FILE_ID' => $file_id, |
|
119 |
'TYPE' => $type, |
|
120 |
'EXTENSION' => $extension |
|
121 |
) |
|
122 |
); |
|
123 |
|
|
124 |
|
|
125 |
// Insert language text and messages |
|
126 |
$template->set_var(array( |
|
127 |
'TEXT_TO' => $TEXT['TO'], |
|
128 |
'TEXT_RENAME' => $TEXT['RENAME'], |
|
129 |
'TEXT_CANCEL' => $TEXT['CANCEL'], |
|
130 |
'TEXT_UP' => $TEXT['UP'], |
|
131 |
'TEXT_OVERWRITE_EXISTING' => $TEXT['OVERWRITE_EXISTING'] |
|
132 |
) |
|
133 |
); |
|
134 |
|
|
135 |
// Parse template object |
|
136 |
$template->parse('main', 'main_block', false); |
|
137 |
$template->pparse('output', 'page'); |
|
138 |
|
|
139 |
?> |
Also available in: Unified diff
All occurrences of "CVS" in the code are replace by ".svn"