Revision 1818
Added by Dietmar about 12 years ago
rename2.php | ||
---|---|---|
3 | 3 |
* |
4 | 4 |
* @category admin |
5 | 5 |
* @package media |
6 |
* @author WebsiteBaker Project |
|
7 |
* @copyright 2004-2009, Ryan Djurovich |
|
8 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
6 |
* @author Ryan Djurovich (2004-2009), WebsiteBaker Project |
|
7 |
* @copyright 2009-2012, WebsiteBaker Org. e.V. |
|
9 | 8 |
* @link http://www.websitebaker2.org/ |
10 | 9 |
* @license http://www.gnu.org/licenses/gpl.html |
11 | 10 |
* @platform WebsiteBaker 2.8.x |
12 | 11 |
* @requirements PHP 5.2.2 and higher |
13 | 12 |
* @version $Id$ |
14 |
* @filesource $HeadURL: $
|
|
15 |
* @lastmodified $Date: $
|
|
13 |
* @filesource $HeadURL$ |
|
14 |
* @lastmodified $Date$ |
|
16 | 15 |
* |
17 | 16 |
*/ |
18 | 17 |
|
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); |
|
18 |
if(!defined('WB_URL')) |
|
19 |
{ |
|
20 |
$config_file = realpath('../../config.php'); |
|
21 |
if(file_exists($config_file) && !defined('WB_URL')) |
|
22 |
{ |
|
23 |
require($config_file); |
|
24 |
} |
|
25 |
} |
|
26 |
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); } |
|
23 | 27 |
|
28 |
$admin = new admin('Media', 'media', false); |
|
29 |
|
|
24 | 30 |
// Include the WB functions file |
25 | 31 |
require_once(WB_PATH.'/framework/functions.php'); |
26 | 32 |
|
... | ... | |
33 | 39 |
$rootlink = 'browse.php?dir='; |
34 | 40 |
// $file_id = intval($admin->get_post('id')); |
35 | 41 |
|
42 |
// Get the current dir |
|
43 |
$currentHome = $admin->get_home_folder(); |
|
44 |
// check for correct directory |
|
45 |
if ($currentHome && stripos(WB_PATH.MEDIA_DIRECTORY.$rootlink,WB_PATH.MEDIA_DIRECTORY.$currentHome)===false) { |
|
46 |
$rootlink = $currentHome; |
|
47 |
} |
|
48 |
|
|
36 | 49 |
// first Check to see if it contains .. |
37 | 50 |
if (!check_media_path($directory)) { |
38 |
$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH'],$rootlink, false);
|
|
51 |
$admin->print_error($MESSAGE['MEDIA_DIR_DOT_DOT_SLASH'],$rootlink, false);
|
|
39 | 52 |
} |
40 | 53 |
|
41 | 54 |
// Get the temp id |
... | ... | |
93 | 106 |
$file_id = $admin->getIDKEY($file_id); |
94 | 107 |
|
95 | 108 |
if(!isset($rename_file)) { |
96 |
$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], $dirlink, false);
|
|
109 |
$admin->print_error($MESSAGE['MEDIA_FILE_NOT_FOUND'], $dirlink, false);
|
|
97 | 110 |
} |
98 | 111 |
|
99 | 112 |
// Check if they entered a new name |
100 | 113 |
if(media_filename($admin->get_post('name')) == "") { |
101 |
$admin->print_error($MESSAGE['MEDIA']['BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false);
|
|
114 |
$admin->print_error($MESSAGE['MEDIA_BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false);
|
|
102 | 115 |
} else { |
103 | 116 |
$old_name = $admin->get_post('old_name'); |
104 | 117 |
$new_name = media_filename($admin->get_post('name')); |
... | ... | |
107 | 120 |
// Check if they entered an extension |
108 | 121 |
if($type == 'file') { |
109 | 122 |
if(media_filename($admin->get_post('extension')) == "") { |
110 |
$admin->print_error($MESSAGE['MEDIA']['BLANK_EXTENSION'], "rename.php?dir=$directory&id=$file_id", false);
|
|
123 |
$admin->print_error($MESSAGE['MEDIA_BLANK_EXTENSION'], "rename.php?dir=$directory&id=$file_id", false);
|
|
111 | 124 |
} else { |
112 | 125 |
$extension = media_filename($admin->get_post('extension')); |
113 | 126 |
} |
... | ... | |
123 | 136 |
$dots = (substr($info['basename'], 0, 1) == '.') || (substr($info['basename'], -1, 1) == '.'); |
124 | 137 |
|
125 | 138 |
if( preg_match('/'.$forbidden_file_types.'$/i', $ext) || $dots == '.' ) { |
126 |
$admin->print_error($MESSAGE['MEDIA']['CANNOT_RENAME'], "rename.php?dir=$directory&id=$file_id", false);
|
|
139 |
$admin->print_error($MESSAGE['MEDIA_CANNOT_RENAME'], "rename.php?dir=$directory&id=$file_id", false);
|
|
127 | 140 |
} |
128 | 141 |
|
129 | 142 |
// Check if the name contains .. |
130 | 143 |
if(strstr($name, '..')) { |
131 |
$admin->print_error($MESSAGE['MEDIA']['NAME_DOT_DOT_SLASH'], "rename.php?dir=$directory&id=$file_id", false);
|
|
144 |
$admin->print_error($MESSAGE['MEDIA_NAME_DOT_DOT_SLASH'], "rename.php?dir=$directory&id=$file_id", false);
|
|
132 | 145 |
} |
133 | 146 |
|
134 | 147 |
// Check if the name is index.php |
135 | 148 |
if($name == 'index.php') { |
136 |
$admin->print_error($MESSAGE['MEDIA']['NAME_INDEX_PHP'], "rename.php?dir=$directory&id=$file_id", false);
|
|
149 |
$admin->print_error($MESSAGE['MEDIA_NAME_INDEX_PHP'], "rename.php?dir=$directory&id=$file_id", false);
|
|
137 | 150 |
} |
138 | 151 |
|
139 | 152 |
// Check that the name still has a value |
140 | 153 |
if($name == '') { |
141 |
$admin->print_error($MESSAGE['MEDIA']['BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false);
|
|
154 |
$admin->print_error($MESSAGE['MEDIA_BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false);
|
|
142 | 155 |
} |
143 | 156 |
|
144 | 157 |
$info = pathinfo(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$rename_file); |
... | ... | |
146 | 159 |
$dots = (substr($info['basename'], 0, 1) == '.') || (substr($info['basename'], -1, 1) == '.'); |
147 | 160 |
|
148 | 161 |
if( preg_match('/'.$forbidden_file_types.'$/i', $ext) || $dots == '.' ) { |
149 |
$admin->print_error($MESSAGE['MEDIA']['CANNOT_RENAME'], "rename.php?dir=$directory&id=$file_id", false);
|
|
162 |
$admin->print_error($MESSAGE['MEDIA_CANNOT_RENAME'], "rename.php?dir=$directory&id=$file_id", false);
|
|
150 | 163 |
} |
151 | 164 |
|
152 | 165 |
// Check if we should overwrite or not |
153 | 166 |
if($admin->get_post('overwrite') != 'yes' AND file_exists(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$name) == true) { |
154 | 167 |
if($type == 'folder') { |
155 |
$admin->print_error($MESSAGE['MEDIA']['DIR_EXISTS'], "rename.php?dir=$directory&id=$file_id", false);
|
|
168 |
$admin->print_error($MESSAGE['MEDIA_DIR_EXISTS'], "rename.php?dir=$directory&id=$file_id", false);
|
|
156 | 169 |
} else { |
157 |
$admin->print_error($MESSAGE['MEDIA']['FILE_EXISTS'], "rename.php?dir=$directory&id=$file_id", false);
|
|
170 |
$admin->print_error($MESSAGE['MEDIA_FILE_EXISTS'], "rename.php?dir=$directory&id=$file_id", false);
|
|
158 | 171 |
} |
159 | 172 |
} |
160 | 173 |
|
... | ... | |
164 | 177 |
// feature freeze |
165 | 178 |
// require_once(ADMIN_PATH.'/media/dse.php'); |
166 | 179 |
|
167 |
$admin->print_success($MESSAGE['MEDIA']['RENAMED'], $dirlink);
|
|
180 |
$admin->print_success($MESSAGE['MEDIA_RENAMED'], $dirlink);
|
|
168 | 181 |
} else { |
169 |
$admin->print_error($MESSAGE['MEDIA']['CANNOT_RENAME'], "rename.php?dir=$directory&id=$file_id", false);
|
|
182 |
$admin->print_error($MESSAGE['MEDIA_CANNOT_RENAME'], "rename.php?dir=$directory&id=$file_id", false);
|
|
170 | 183 |
} |
171 | 184 |
Also available in: Unified diff
! update users, create username homefolder in media/homefolders