Commit 3a9625e2 authored by Kjartan's avatar Kjartan
Browse files

- Fixing extension splitting (was using the first dot instead of the last one).

parent c8daca07
......@@ -115,6 +115,7 @@ function file_check_upload($source) {
*/
function file_check_location($source, $directory = 0) {
$source = realpath($source);
$directory = realpath($directory);
if ($directory && strpos($source, $directory) !== 0) {
return 0;
}
......@@ -172,8 +173,9 @@ function file_copy(&$source, $dest = 0, $replace = 0) {
if (file_exists($dest) && !$replace) {
// Destination file already exists and we can't replace is so we try and
// and find a new filename.
list($name, $ext) = explode('.', $basename, 2);
$ext = $ext ? ".$ext" : '';
$pos = strrpos($basename, '.');
$name = substr($basename, 0, $pos);
$ext = substr($basename, $pos);
$counter = 0;
do {
$dest = $directory . FILE_SEPARATOR . $name .'_'. $counter++ . $ext;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment