changeset 880:6db8ef2bb1b5

Changed stMakePath() API.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 26 Nov 2014 16:30:49 +0200
parents a1dd3102b52a
children 7c805dccd4f7
files faptool.php msite.inc.php
diffstat 2 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/faptool.php	Wed Nov 26 16:10:17 2014 +0200
+++ b/faptool.php	Wed Nov 26 16:30:49 2014 +0200
@@ -28,12 +28,11 @@
   echo "Checking for missing directories ...\n";
   stMakeDir($setEntryPath, $setEntryPathPerms);
   stMakeDir($setPreviewPath, $setPrevPathPerms);
+  stMakeDir(stMakePath(FALSE, FALSE, array($setPreviewPath, $setThumbDir)), $setPrevPathPerms);
 
   foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo)
   {
     stMakeDir(stMakePath(FALSE, FALSE, array($setEntryPath, $compo["cpath"])), $setEntryPathPerms);
-    stMakeDir(stMakePath(FALSE, FALSE, array($setPreviewPath, $compo["cpath"])), $setPrevPathPerms);
-    stMakeDir(stMakePath(FALSE, FALSE, array($setPreviewPath, $compo["cpath"], $setThumbDir)), $setPrevPathPerms);
   }
 }
 
--- a/msite.inc.php	Wed Nov 26 16:10:17 2014 +0200
+++ b/msite.inc.php	Wed Nov 26 16:30:49 2014 +0200
@@ -857,7 +857,7 @@
 }
 
 
-function stMakePath($isURL, $components)
+function stMakePath($isURL, $hasFilename, $components)
 {
   $res = array();
 
@@ -873,7 +873,7 @@
   // Handle each path component
   if (count($components) > 0)
   {
-    for ($i = 0; $i < count($components) - 1; $i++)
+    for ($i = 0; $i < count($components); $i++)
     foreach (explode("/", $components[$i]) as $item)
     {
       if ($item == "..")
@@ -883,7 +883,6 @@
         $res[] = stFilterPathComponent($item);
       $first = FALSE;
     }
-    $res[] = $components[$i];  
   }
 
   return implode("/", $res);
@@ -1137,7 +1136,7 @@
       "Compo does not exist??");
 
   // Check target path existence / writability
-  $dstPath = stMakePath(FALSE, array(stGetSetting("entryPath"), $compo["cpath"]));
+  $dstPath = stMakePath(FALSE, FALSE, array(stGetSetting("entryPath"), $compo["cpath"]));
   if (!file_exists($dstPath))
     return stFileError($userID,
       "Path '".$dstPath."' for compo ID #".$entry["compo_id"]." does not exist.",
@@ -1244,7 +1243,7 @@
       "Internal error. Could not set permissions for uploaded file. Contact site admins.");
 
   // Move file to its destination
-  $dstFilename = stMakePath(FALSE, array(stGetSetting("entryPath"), $compo["cpath"], $fentry["filename"]));
+  $dstFilename = stMakePath(FALSE, TRUE, array(stGetSetting("entryPath"), $compo["cpath"], $fentry["filename"]));
   if (@move_uploaded_file($tmpFilename, $dstFilename) === false)
     return stFileError($userID,
       "Could not move uploaded file '".$tmpFilename."' to '".$dstFilename."'.",