From: arno Date: Sun, 26 Jul 2009 14:16:25 +0000 (+0200) Subject: UTF-8 safe version of basename X-Git-Tag: v0.1~2 X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=commitdiff_plain;h=2342c1689c6155fc545c372e24dbcac27fcf21e9 UTF-8 safe version of basename --- 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;