Login or Register

RSS IconRecent posts in this topic

avatar
davidz on Jul 4. 2007. 5:04 am
Are there any plans to alter the codebase to work with safe_mode and open_basedir restrictions?

If not, I'll make the changes myself and release them as diffs against 0.7.1.
avatar
methegeek on Jul 4. 2007. 9:50 am
Cool! I was just about to post on this subject.

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.
avatar
davidz on Jul 5. 2007. 1:35 pm
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.

/upload still needs to be within the safe_mode jail, obviously. If it isn't, you'll get safe_mode warnings.

If I run into anything else, I'll post it on this thread.

    /**
     * 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 >= 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 > 0; $i--)
        {
            /* break path into two parts at $i */
            $pathA = implode ("/",array_slice ($path, 0, $i));
            $pathB = implode ("/",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()
Topic is locked. If you have something important to say about issues discussed on this page please write at hi@a51dev.com.

RSS IconRecent posts in this topic