Fix: $attachement is already true by default

Fix: remove deprecated code
This commit is contained in:
Regis Houssin 2012-09-03 17:01:03 +02:00
parent 14b1b1d6e5
commit fc29e7c432

View File

@ -78,36 +78,43 @@ else $type=dol_mimetype($original_file);
//print 'X'.$type.'-'.$original_file;exit; //print 'X'.$type.'-'.$original_file;exit;
// Define attachment (attachment=true to force choice popup 'open'/'save as') // Define attachment (attachment=true to force choice popup 'open'/'save as')
// TODO $attachment is already true by default
$attachment = true; $attachment = true;
// Text files // Text files
if (preg_match('/\.txt$/i',$original_file)) { $attachment = false; } if (preg_match('/\.txt$/i',$original_file)) {
if (preg_match('/\.csv$/i',$original_file)) { $attachment = true; } $attachment = false;
if (preg_match('/\.tsv$/i',$original_file)) { $attachment = true; } }
//if (preg_match('/\.csv$/i',$original_file)) { $attachment = true; }
//if (preg_match('/\.tsv$/i',$original_file)) { $attachment = true; }
// Documents MS office // Documents MS office
if (preg_match('/\.doc(x)?$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.doc(x)?$/i',$original_file)) { $attachment = true; }
if (preg_match('/\.dot(x)?$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.dot(x)?$/i',$original_file)) { $attachment = true; }
if (preg_match('/\.mdb$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.mdb$/i',$original_file)) { $attachment = true; }
if (preg_match('/\.ppt(x)?$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.ppt(x)?$/i',$original_file)) { $attachment = true; }
if (preg_match('/\.xls(x)?$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.xls(x)?$/i',$original_file)) { $attachment = true; }
// Documents Open office // Documents Open office
if (preg_match('/\.odp$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.odp$/i',$original_file)) { $attachment = true; }
if (preg_match('/\.ods$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.ods$/i',$original_file)) { $attachment = true; }
if (preg_match('/\.odt$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.odt$/i',$original_file)) { $attachment = true; }
// Misc // Misc
if (preg_match('/\.(html|htm)$/i',$original_file)) { $attachment = false; } if (preg_match('/\.(html|htm)$/i',$original_file)) {
if (preg_match('/\.pdf$/i',$original_file)) { $attachment = true; } $attachment = false;
if (preg_match('/\.sql$/i',$original_file)) { $attachment = true; } }
//if (preg_match('/\.pdf$/i',$original_file)) { $attachment = true; }
//if (preg_match('/\.sql$/i',$original_file)) { $attachment = true; }
// Images // Images
if (preg_match('/\.jpg$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.jpg$/i',$original_file)) { $attachment = true; }
if (preg_match('/\.jpeg$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.jpeg$/i',$original_file)) { $attachment = true; }
if (preg_match('/\.png$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.png$/i',$original_file)) { $attachment = true; }
if (preg_match('/\.gif$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.gif$/i',$original_file)) { $attachment = true; }
if (preg_match('/\.bmp$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.bmp$/i',$original_file)) { $attachment = true; }
if (preg_match('/\.tiff$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.tiff$/i',$original_file)) { $attachment = true; }
// Calendar // Calendar
if (preg_match('/\.vcs$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.vcs$/i',$original_file)) { $attachment = true; }
if (preg_match('/\.ics$/i',$original_file)) { $attachment = true; } //if (preg_match('/\.ics$/i',$original_file)) { $attachment = true; }
if (GETPOST("attachment")) { $attachment = true; } if (GETPOST("attachment")) {
$attachment = true;
}
if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
//print "XX".$attachment;exit; //print "XX".$attachment;exit;
@ -117,6 +124,12 @@ $original_file = str_replace("../","/", $original_file);
// find the subdirectory name as the reference // find the subdirectory name as the reference
$refname=basename(dirname($original_file)."/"); $refname=basename(dirname($original_file)."/");
// Suppression de la chaine de caractere ../ dans $original_file
$original_file = str_replace("../","/", $original_file);
// find the subdirectory name as the reference
$refname=basename(dirname($original_file)."/");
// Security check // Security check
$accessallowed=0; $accessallowed=0;
$sqlprotectagainstexternals=''; $sqlprotectagainstexternals='';
@ -382,6 +395,14 @@ if ($modulepart)
$original_file=$conf->admin->dir_output.'/'.$original_file; $original_file=$conf->admin->dir_output.'/'.$original_file;
} }
// Wrapping for upload file test
else if ($modulepart == 'admin_temp')
{
if ($user->admin)
$accessallowed=1;
$original_file=$conf->admin->dir_temp.'/'.$original_file;
}
// Wrapping pour BitTorrent // Wrapping pour BitTorrent
else if ($modulepart == 'bittorrent') else if ($modulepart == 'bittorrent')
{ {
@ -483,34 +504,7 @@ if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file))
exit; exit;
} }
// TODO Remove this. Some part of code still use it.
if ($action == 'remove_file') // Remove a file
{
clearstatcache();
dol_syslog("document.php remove $original_file $urlsource", LOG_DEBUG);
// This test should be useless. We keep it to find bug more easily
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
if (! file_exists($original_file_osencoded))
{
$file=basename($original_file); // Do no show plain path of original_file in shown error message
dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$file));
exit;
}
$ret=dol_delete_file($original_file);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
dol_syslog("document.php back to ".urldecode($urlsource), LOG_DEBUG);
header("Location: ".urldecode($urlsource));
return;
}
else // Open and return file
{
clearstatcache(); clearstatcache();
$filename = basename($original_file); $filename = basename($original_file);
@ -542,6 +536,5 @@ else // Open and return file
//flush(); //flush();
readfile($original_file_osencoded); readfile($original_file_osencoded);
}
?> ?>