From 3a9625e2e3665c8ba019896dc7cef8e84e5965cd Mon Sep 17 00:00:00 2001 From: Kjartan Mannes Date: Thu, 29 Jan 2004 11:39:22 +0000 Subject: - Fixing extension splitting (was using the first dot instead of the last one). --- includes/file.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/file.inc b/includes/file.inc index 1169b02ef..cd9761088 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -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; -- cgit v1.2.3