Exemplo n.º 1
0
function CreateFolder($resourceType, $currentFolder)
{
    if (!isset($_GET)) {
        global $_GET;
    }
    $sErrorNumber = '0';
    $sErrorMsg = '';
    if (isset($_GET['NewFolderName'])) {
        $sNewFolderName = $_GET['NewFolderName'];
        $sNewFolderName = SanitizeFolderName($sNewFolderName);
        if (strpos($sNewFolderName, '..') !== FALSE) {
            $sErrorNumber = '102';
        } else {
            // Map the virtual path to the local server path of the current folder.
            $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'CreateFolder');
            if (is_writable($sServerDir)) {
                $sServerDir .= $sNewFolderName;
                $sErrorMsg = CreateServerFolder($sServerDir);
                switch ($sErrorMsg) {
                    case '':
                        $sErrorNumber = '0';
                        break;
                    case 'Invalid argument':
                    case 'No such file or directory':
                        $sErrorNumber = '102';
                        // Path too long.
                        break;
                    default:
                        $sErrorNumber = '110';
                        break;
                }
            } else {
                $sErrorNumber = '103';
            }
        }
    } else {
        $sErrorNumber = '102';
    }
    // Create the "Error" node.
    echo '<Error number="' . $sErrorNumber . '" originalDescription="' . ConvertToXmlAttribute($sErrorMsg) . '" />';
}
Exemplo n.º 2
0
function CreateFolder($resourceType, $currentFolder)
{
    if (!isset($_GET)) {
        global $_GET;
    }
    $sErrorNumber = '0';
    $sErrorMsg = '';
    if (isset($_GET['NewFolderName'])) {
        $sNewFolderName = $_GET['NewFolderName'];
        $sNewFolderName = SanitizeFolderName($sNewFolderName);
        if (strpos($sNewFolderName, '..') !== FALSE) {
            $sErrorNumber = '102';
        } else {
            $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'CreateFolder');
            if (is_writable($sServerDir)) {
                $sServerDir .= $sNewFolderName;
                $sErrorMsg = CreateServerFolder($sServerDir);
                switch ($sErrorMsg) {
                    case '':
                        $sErrorNumber = '0';
                        break;
                    case 'Invalid argument':
                    case 'No such file or directory':
                        $sErrorNumber = '102';
                        break;
                    default:
                        $sErrorNumber = '110';
                        break;
                }
            } else {
                $sErrorNumber = '103';
            }
        }
    } else {
        $sErrorNumber = '102';
    }
    echo '<Error number="' . $sErrorNumber . '" />';
}