Project

General

Profile

« Previous | Next » 

Revision 2098

Added by darkviper almost 11 years ago

! activate class Translate for all addons in admin/ (except pages/)
! class.admin >> add translation of the current theme to Translate

View differences:

rename2.php
23 23
    	require($config_file);
24 24
    }
25 25
}
26
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
26
//if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
27
$oTrans = Translate::getInstance();
28
$oTrans->enableAddon('admin\\media');
27 29

  
28 30
$admin = new admin('Media', 'media', false);
29 31

  
......
48 50

  
49 51
// first Check to see if it contains ..
50 52
if (!check_media_path($directory)) {
51
	$admin->print_error($MESSAGE['MEDIA_DIR_DOT_DOT_SLASH'],$rootlink, false);
53
	$admin->print_error($oTrans->MESSAGE_MEDIA_DIR_DOT_DOT_SLASH, $rootlink, false);
52 54
}
53 55

  
54 56
// Get the temp id
55 57
$file_id = intval($admin->checkIDKEY('id', false, $_SERVER['REQUEST_METHOD']));
56 58
if (!$file_id) {
57
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$dirlink, false);
59
	$admin->print_error($oTrans->MESSAGE_GENERIC_SECURITY_ACCESS, $dirlink, false);
58 60
}
59 61

  
60 62
// Check for potentially malicious files
......
106 108
$file_id = $admin->getIDKEY($file_id);
107 109

  
108 110
if(!isset($rename_file)) {
109
	$admin->print_error($MESSAGE['MEDIA_FILE_NOT_FOUND'], $dirlink, false);
111
	$admin->print_error($oTrans->MESSAGE_MEDIA_FILE_NOT_FOUND, $dirlink, false);
110 112
}
111 113

  
112 114
// Check if they entered a new name
113 115
if(media_filename($admin->get_post('name')) == "") {
114
	$admin->print_error($MESSAGE['MEDIA_BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false);
116
	$admin->print_error($oTrans->MESSAGE_MEDIA_BLANK_NAME, "rename.php?dir=$directory&id=$file_id", false);
115 117
} else {
116 118
	$old_name = $admin->get_post('old_name');
117 119
	$new_name =  media_filename($admin->get_post('name'));
......
120 122
// Check if they entered an extension
121 123
if($type == 'file') {
122 124
	if(media_filename($admin->get_post('extension')) == "") {
123
		$admin->print_error($MESSAGE['MEDIA_BLANK_EXTENSION'], "rename.php?dir=$directory&id=$file_id", false);
125
		$admin->print_error($oTrans->MESSAGE_MEDIA_BLANK_EXTENSION, "rename.php?dir=$directory&id=$file_id", false);
124 126
	} else {
125 127
		$extension = media_filename($admin->get_post('extension'));
126 128
	}
......
136 138
$dots = (substr($info['basename'], 0, 1) == '.') || (substr($info['basename'], -1, 1) == '.');
137 139

  
138 140
if( preg_match('/'.$forbidden_file_types.'$/i', $ext) || $dots == '.' ) {
139
	$admin->print_error($MESSAGE['MEDIA_CANNOT_RENAME'], "rename.php?dir=$directory&id=$file_id", false);
141
	$admin->print_error($oTrans->MESSAGE_MEDIA_CANNOT_RENAME, "rename.php?dir=$directory&id=$file_id", false);
140 142
}
141 143

  
142 144
// Check if the name contains ..
143 145
if(strstr($name, '..')) {
144
	$admin->print_error($MESSAGE['MEDIA_NAME_DOT_DOT_SLASH'], "rename.php?dir=$directory&id=$file_id", false);
146
	$admin->print_error($oTrans->MESSAGE_MEDIA_NAME_DOT_DOT_SLASH, "rename.php?dir=$directory&id=$file_id", false);
145 147
}
146 148

  
147 149
// Check if the name is index.php
148 150
if($name == 'index.php') {
149
	$admin->print_error($MESSAGE['MEDIA_NAME_INDEX_PHP'], "rename.php?dir=$directory&id=$file_id", false);
151
	$admin->print_error($oTrans->MESSAGE_MEDIA_NAME_INDEX_PHP, "rename.php?dir=$directory&id=$file_id", false);
150 152
}
151 153

  
152 154
// Check that the name still has a value
153 155
if($name == '') {
154
	$admin->print_error($MESSAGE['MEDIA_BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false);
156
	$admin->print_error($oTrans->MESSAGE_MEDIA_BLANK_NAME, "rename.php?dir=$directory&id=$file_id", false);
155 157
}
156 158

  
157 159
$info = pathinfo(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$rename_file);
......
159 161
$dots = (substr($info['basename'], 0, 1) == '.') || (substr($info['basename'], -1, 1) == '.');
160 162

  
161 163
if( preg_match('/'.$forbidden_file_types.'$/i', $ext) || $dots == '.' ) {
162
	$admin->print_error($MESSAGE['MEDIA_CANNOT_RENAME'], "rename.php?dir=$directory&id=$file_id", false);
164
	$admin->print_error($oTrans->MESSAGE_MEDIA_CANNOT_RENAME, "rename.php?dir=$directory&id=$file_id", false);
163 165
}
164 166

  
165 167
// Check if we should overwrite or not
166 168
if($admin->get_post('overwrite') != 'yes' AND file_exists(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$name) == true) {
167 169
	if($type == 'folder') {
168
		$admin->print_error($MESSAGE['MEDIA_DIR_EXISTS'], "rename.php?dir=$directory&id=$file_id", false);
170
		$admin->print_error($oTrans->MESSAGE_MEDIA_DIR_EXISTS, "rename.php?dir=$directory&id=$file_id", false);
169 171
	} else {
170
		$admin->print_error($MESSAGE['MEDIA_FILE_EXISTS'], "rename.php?dir=$directory&id=$file_id", false);
172
		$admin->print_error($oTrans->MESSAGE_MEDIA_FILE_EXISTS, "rename.php?dir=$directory&id=$file_id", false);
171 173
	}
172 174
}
173 175

  
......
177 179
    // feature freeze
178 180
	// require_once(ADMIN_PATH.'/media/dse.php');
179 181

  
180
	$admin->print_success($MESSAGE['MEDIA_RENAMED'], $dirlink);
182
	$admin->print_success($oTrans->MESSAGE_MEDIA_RENAMED, $dirlink);
181 183
} else {
182
	$admin->print_error($MESSAGE['MEDIA_CANNOT_RENAME'], "rename.php?dir=$directory&id=$file_id", false);
184
	$admin->print_error($oTrans->MESSAGE_MEDIA_CANNOT_RENAME, "rename.php?dir=$directory&id=$file_id", false);
183 185
}

Also available in: Unified diff