patch for organize.php in 1.0rc1 to handle '/' in path names

Matt McClure <[email protected]> Sat, 23 Aug 2003 20:46:49 -0400
Newsgroups gmane.comp.audio.netjuke.user
Organization me
Message-ID <[email protected]>
Organize.php had trouble if the destination path had any '/'s.  This
patch makes it remove '/'s before trying to copy the file.

-- 
Matt
http://www.faradic.net/~mmcclure/

    The whole genre of the one-bedroom apartment on the Lower East
    Side has escaped the [MTV] Cribs radar.
        -Mike Doughty
organize.php.slash_in_path.patch (text/plain, 1.8 KB)
--- organize.php.~1.14.~	2003-05-20 07:04:59.000000000 -0400
+++ organize.php	2003-08-23 19:11:10.000000000 -0400
@@ -202,6 +202,8 @@
 
         $format = preg_replace ($replace_tokens, $replace_fields, ORGANIZE_FORMAT);
 
+        $format = stripslashes($format);
+
         // Create directories if necessary, check permissions, move file
         $subdirs = split ('/', $format);
         array_pop ($subdirs);
@@ -220,10 +222,6 @@
 
         }
 
-        // Substitute back in the originals
-        $patterns = array_map ("make_pattern", $vals);
-        $format = preg_replace ($patterns, $farray, $format);
-
         // Everything looks good, copy the file
         if (!@is_writable ($dpath)) {
 
@@ -232,19 +230,21 @@
 
         }
 
-        if (! @file_exists(MUSIC_DIR . '/' . $format)) {
+        $newfile = MUSIC_DIR . '/' . $format;
+
+        if (! @file_exists($newfile)) {
 
           $size = filesize ($file);
-          $success = @copy ($file, stripslashes (MUSIC_DIR . '/' . $format));
+          $success = @copy ($file, $newfile);
           if ($success) {
 
             // Unlink original file, update db record with new location
-            if (file_exists(MUSIC_DIR . '/' . $format) && ($size == filesize (MUSIC_DIR . '/' . $format))) {
+            if (file_exists($newfile) && ($size == filesize ($newfile))) {
               @unlink ($file);
               $sql = "UPDATE netjuke_tracks SET location = '".specialUrlEncode($format)."' WHERE id = '".$dbrs->fields[0]."'";
               $dbconn->Execute ($sql);
 
-              echo "&raquo;" . ADMORG_COPY_1 . $file . ADMORG_COPY_2 . htmlspecialchars(stripslashes($format)) . "<br>\n";
+              echo "&raquo;" . ADMORG_COPY_1 . $file . ADMORG_COPY_2 . htmlspecialchars($format) . "<br>\n";
 
             } else {
signature.asc (application/pgp-signature, 252 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/SAr8rGgMpZIoLA8RAlOJAJ4zTEI9mDlPtOBRXuniQBy7yB0AWACg3nNk
fu6VBejGfubi/8MAktWBad8=
=TBHk
-----END PGP SIGNATURE-----