<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
  <title>aC forum: Issues with creating subfolders in upload folder? Problems safe_mode and open_basedir restrictions?</title>
  <link>http://www.activecollab.com/forums/topic/1716/</link>
  <description>Recent posts on topic: Issues with creating subfolders in upload folder? Problems safe_mode and open_basedir restrictions?</description>
  <dc:language>en-us</dc:language>
  <pubDate>Sun, 06 Jul 2008 10:07:16 CDT</pubDate>
  
  <item>
    <link>http://www.activecollab.com/forums/post/8143/#post8143</link>
    <guid>http://www.activecollab.com/forums/post/8143/#post8143</guid>
    <title>Post #3 by davidz</title>
    <dc:creator>davidz</dc:creator>
    <description><![CDATA[<p>Ok, the following rewrite of force_mkdir() works on my web host with safe_mode and open_basedir enabled, where the code at http://www.activecollab.com/forums/topic/1499/ does not. Untested anywhere else.<br />
<br />
/upload still needs to be within the safe_mode jail, obviously. If it isn't, you'll get safe_mode warnings.<br />
<br />
If I run into anything else, I'll post it on this thread.<br />
<br />
<pre name="code" class="html">    /**
     * Force a path to exist
     *
     * Works it's way backwards up a path looking for a successful isdir().
     * By starting at the bottom and working up we hope to avoid bumping into
     * the safe_mode jail. 3rd parameter for mkdir() requires PHP &gt;= 5.0.0
     *
     * @see http://www.activecollab.com/forums/topic/1716/
     * @see http://www.activecollab.com/forums/topic/1499/
     * @access public
     * @param string $path path to create
     * @param int $chmod file permissions of created path, defaults to 0777, octal
     * @return bool true on success, false on failure
     */
    function force_mkdir($path, $chmod = 0777)
    {
        /* force path to use / not \ */
        $path = str_replace('\\', '/', $path);
        /* split path into parts */
        $path = explode('/', $path);

        /* work $i backwards up the path */
        for ($i = sizeof ($path) - 1; $i &gt; 0; $i--)
        {
            /* break path into two parts at $i */
            $pathA = implode (&quot;/&quot;,array_slice ($path, 0, $i));
            $pathB = implode (&quot;/&quot;,array_slice ($path, $i, sizeof($path)-$i));

            /* if first half of path is a directory */
            if (is_dir ($pathA))
            {
                /* at this point we're within the safe_mode jail */
                $here = getcwd();
                chdir ($pathA);
                mkdir ($pathB, $chmod, true);
                chdir ($here);
                return (true);
            }
        }
        return (false);
    } // force_mkdir()</pre></p>]]></description>
    <pubDate>Thu, 05 Jul 2007 13:35:58 CDT</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/8128/#post8128</link>
    <guid>http://www.activecollab.com/forums/post/8128/#post8128</guid>
    <title>Post #2 by methegeek</title>
    <dc:creator>methegeek</dc:creator>
    <description><![CDATA[<p>Cool! I was just about to post on this subject.<br />
<br />
We made a 0.7.1 demo available, hosted at a Godaddy Linux virtual dedicated server (It runs on plesk), and we can't upload files. I assume the issue is realted to this. I tried the few hacks I found here, and also marking 'safe_mode off', but still no luck.</p>]]></description>
    <pubDate>Wed, 04 Jul 2007 09:50:32 CDT</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/8127/#post8127</link>
    <guid>http://www.activecollab.com/forums/post/8127/#post8127</guid>
    <title>Post #1 by davidz</title>
    <dc:creator>davidz</dc:creator>
    <description><![CDATA[<p>Are there any plans to alter the codebase to work with safe_mode and open_basedir restrictions?<br />
<br />
If not, I'll make the changes myself and release them as diffs against 0.7.1.</p>]]></description>
    <pubDate>Wed, 04 Jul 2007 05:04:22 CDT</pubDate>
  </item>
</channel>
</rss>