Project

General

Profile

« Previous | Next » 

Revision 61

Added by stefan about 19 years ago

View differences:

rename2.php
32 32
// Include the basic header file
33 33
require(ADMIN_PATH.'/media/basic_header.html');
34 34

  
35
// Get list of file types to which we're supposed to append 'txt'
36
$get_result=$database->query("SELECT value FROM ".TABLE_PREFIX."settings WHERE name='rename_files_on_upload' LIMIT 1");
37
$file_extension_string='';
38
if ($get_result->numRows()>0) {
39
	$fetch_result=$get_result->fetchRow();
40
	$file_extension_string=$fetch_result['value'];
41
}
42
$file_extensions=explode(",",$file_extension_string);
43

  
44

  
35 45
// Get the current dir
36 46
$directory = $admin->get_post('dir');
37 47
if($directory == '/') {
......
129 139
	$admin->print_error($MESSAGE['MEDIA']['BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false);
130 140
}
131 141

  
142
// Check for potentially malicious files and append 'txt' to their name
143
foreach($file_extensions as $file_ext) {
144
	$file_ext_len=strlen($file_ext);
145
	if (substr($name,-$file_ext_len)==$file_ext) {
146
		$name.='.txt';
147
	}
148
}		
149

  
150

  
132 151
// Check if we should overwrite or not
133 152
if($admin->get_post('overwrite') != 'yes' AND file_exists(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$name) == true) {
134 153
	if($type == 'folder') {

Also available in: Unified diff