Example #1
0
    # make a directory recursively
    function _MakeDirectoryRecursively($path, $mode = 0777)
    {
        if (strlen($path) == 0) {
            return 0;
        }
        if (is_dir($path)) {
            return 1;
        } elseif ($this->_DirectoryName($path) == $path) {
            return 1;
        }
        return $this->_MakeDirectoryRecursively($this->_DirectoryName($path), $mode) and mkdir($path, $mode);
    }
    # I do not like PHP dirname
    function _DirectoryName($path = '')
    {
        $a = split('/', $path);
        $n = trim($a[count($a) - 1]) == '' ? count($a) - 2 : count($a) - 1;
        for ($dir = array(), $i = 0; $i < $n; $i++) {
            $dir[] = $a[$i];
        }
        return join('/', $dir);
    }
}
###################################################################
# MAIN SECTION - come on !
###################################################################
if (!isset($SMBWEBCLIENT_CLASS)) {
    $swc = new smbwebclient();
    $swc->Run(@$_REQUEST['path']);
}
    # make a directory recursively
    function _MakeDirectoryRecursively($path, $mode = 0777)
    {
        if (strlen($path) == 0) {
            return 0;
        }
        if (is_dir($path)) {
            return 1;
        } elseif ($this->_DirectoryName($path) == $path) {
            return 1;
        }
        return $this->_MakeDirectoryRecursively($this->_DirectoryName($path), $mode) and mkdir($path, $mode);
    }
    # I do not like PHP dirname
    function _DirectoryName($path = '')
    {
        $a = preg_split('/\\//', $path);
        $n = trim($a[count($a) - 1]) == '' ? count($a) - 2 : count($a) - 1;
        for ($dir = array(), $i = 0; $i < $n; $i++) {
            $dir[] = $a[$i];
        }
        return join('/', $dir);
    }
}
###################################################################
# MAIN SECTION - come on !
###################################################################
if (!isset($SMBWEBCLIENT_CLASS)) {
    $swc = new smbwebclient();
    $swc->Run();
}