From 2342c1689c6155fc545c372e24dbcac27fcf21e9 Mon Sep 17 00:00:00 2001 From: arno Date: Sun, 26 Jul 2009 16:16:25 +0200 Subject: [PATCH] UTF-8 safe version of basename --- api.php | 4 ++-- inc/utils.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api.php b/api.php index 50e8bfe..39c6319 100644 --- a/api.php +++ b/api.php @@ -99,7 +99,7 @@ function save_uploaded_file ($file, $con) { server_error (); } } - return basename($dest); + return basename_safe ($dest); } function img_check_upload ($file) { @@ -148,7 +148,7 @@ function unique_file ($dirname, $relpath, $con) { while ($counter < 1000) { if (!file_exists ($filename) && - !($con->imgpath_exists (basename ($filename)))) { + !($con->imgpath_exists (basename_safe ($filename)))) { return $filename; } else { $counter++; diff --git a/inc/utils.php b/inc/utils.php index 04aeff9..cee9d9a 100644 --- a/inc/utils.php +++ b/inc/utils.php @@ -14,6 +14,10 @@ function gethost() { return $host; } +function basename_safe ($path) { + return end (explode ("/", $path)); +} + function unquote($gpc_str) { if (!isset ($gpc_str)) { return $gpc_str; -- 2.39.5