public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Homepage: http://chyrp.net/
Clone URL: git://github.com/vito/chyrp.git
Click here to lend your support to: chyrp and make a donation at www.pledgie.com !
* Added an "uploaded" Twig filter for referencing an uploaded file.
* Fixed upload() and custom paths.
vito (author)
Sat Nov 15 15:30:09 -0800 2008
commit  311a2bf6645405323c51da7564880d83f0a44375
tree    34bbd9d12ee38f9e65da0a9b49e792288a92d228
parent  7266ecf9e8350a23eb169ace2817abfce6713520
...
73
74
75
 
76
77
78
...
73
74
75
76
77
78
79
0
@@ -73,6 +73,7 @@ $twig_filters = array(
0
     // debugging
0
     'inspect' =>          'twig_inspect_filter',
0
 
0
+    'uploaded' =>         'uploaded',
0
     'fallback' =>         'oneof',
0
     'selected' =>         'twig_selected_filter',
0
     'checked' =>          'twig_checked_filter',
...
929
930
931
932
 
933
934
935
...
969
970
971
972
 
973
974
975
 
976
977
 
978
979
980
...
929
930
931
 
932
933
934
935
...
969
970
971
 
972
973
974
 
975
976
 
977
978
979
980
0
@@ -929,7 +929,7 @@
0
      */
0
     function upload($file, $extension = null, $path = "", $put = false) {
0
         $file_split = explode(".", $file['name']);
0
-        $dir = MAIN_DIR.Config::current()->uploads_path.$path;
0
+        $dir = rtrim(MAIN_DIR.Config::current()->uploads_path.$path, "/");
0
 
0
         if (!file_exists($dir))
0
             mkdir($dir);
0
@@ -969,12 +969,12 @@
0
         $file_clean = sanitize($file_clean, false).".".$file_ext;
0
         $filename = unique_filename($file_clean, $path);
0
 
0
-        $message = __("Couldn't upload file. CHMOD <code>".MAIN_DIR.Config::current()->uploads_path."</code> to 777 and try again. If this problem persists, it's probably timing out; in which case, you must contact your system administrator to increase the maximum POST and upload sizes.");
0
+        $message = __("Couldn't upload file. CHMOD <code>".$dir."</code> to 777 and try again. If this problem persists, it's probably timing out; in which case, you must contact your system administrator to increase the maximum POST and upload sizes.");
0
 
0
         if ($put) {
0
-            if (!@copy($file['tmp_name'], $dir.$filename))
0
+            if (!@copy($file['tmp_name'], $dir."/".$filename))
0
                 error(__("Error"), $message);
0
-        } elseif (!@move_uploaded_file($file['tmp_name'], $dir.$filename))
0
+        } elseif (!@move_uploaded_file($file['tmp_name'], $dir."/".$filename))
0
             error(__("Error"), $message);
0
 
0
         return $filename;

Comments