]> dev.renevier.net Git - syp.git/commitdiff
UTF-8 safe version of basename
authorarno <arenevier@fdn.fr>
Sun, 26 Jul 2009 14:16:25 +0000 (16:16 +0200)
committerarno <arenevier@fdn.fr>
Sun, 26 Jul 2009 15:39:12 +0000 (17:39 +0200)
api.php
inc/utils.php

diff --git a/api.php b/api.php
index 50e8bfe3cfa2cc5cc1fad902cc24cde9757d03e8..39c6319ab5c749d857665830e0bb040f5dfe30e3 100644 (file)
--- 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++;
index 04aeff9817cc424dc83b4060082e39bbfbbfc027..cee9d9a2a2d7e26650f144e351a214366f7396fc 100644 (file)
@@ -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;