Ejemplo n.º 1
0
function ServerMapFolder($resourceType, $folderPath, $sCommand)
{
    // Get the resource type directory.
    $sResourceTypePath = GetResourceTypeDirectory($resourceType, $sCommand);
    // Ensure that the directory exists.
    $sErrorMsg = CreateServerFolder($sResourceTypePath);
    if ($sErrorMsg != '') {
        SendError(1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})");
    }
    // Return the resource type directory combined with the required path.
    return CombinePaths($sResourceTypePath, $folderPath);
}
Ejemplo n.º 2
0
function ServerMapFolder($resourceType, $folderPath, $sCommand)
{
    global $Config;
    // Get the resource type directory.
    $sResourceTypePath = GetResourceTypeDirectory($resourceType, $sCommand);
    // Ensure that the directory exists.
    $sErrorMsg = CreateServerFolder($sResourceTypePath);
    if ($sErrorMsg != '') {
        SendError(1, "Ошибка создания папки \"{$sResourceTypePath}\" ({$sErrorMsg})");
    }
    if ($Config['ThumbList'] && $resourceType == 'Image') {
        ServerMapFolder('ImageThumb', $folderPath, $sCommand);
    }
    // Return the resource type directory combined with the required path.
    return CombinePaths($sResourceTypePath, $folderPath);
}
Ejemplo n.º 3
0
function GetFoldersAndFiles($resourceType, $currentFolder)
{
    if (!isset($_GET)) {
        global $_GET;
    }
    global $Config;
    $isInternalLink = isset($_GET['DWFCK_Browser']) && $_GET['DWFCK_Browser'] == 'local' ? true : false;
    global $_FolderClass;
    global $Config;
    $currentFolder = encode_dir($currentFolder);
    $sess_id = session_id();
    if (!isset($sess_id) || $sess_id != $_COOKIE['FCK_NmSp_acl']) {
        session_id($_COOKIE['FCK_NmSp_acl']);
        session_start();
    }
    $acl_del = isset($_SESSION['dwfck_del']) ? $_SESSION['dwfck_del'] : 0;
    // Map the virtual path to the local server path.
    $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'GetFoldersAndFiles');
    if ($Config['osWindows']) {
        $sServerDir = normalizeWIN($sServerDir);
    }
    mkdir_rek($sServerDir);
    // Arrays that will hold the folders and files names.
    $aFolders = array();
    $aFiles = array();
    $sFile = '__AAAAAAAA__.AAA';
    $temp_folder = $currentFolder;
    $temp_folder = dwiki_encodeFN(trim($temp_folder, '/'));
    has_permission($temp_folder, $resourceType);
    if ($isInternalLink && $_FolderClass < 16) {
        $sfclass = 'r';
    } else {
        if ($acl_del) {
            $sfclass = $_FolderClass >= 16 ? 'u' : 'r';
        } else {
            $sfclass = $_FolderClass >= 8 || has_open_access() ? 'u' : 'r';
        }
        can_delete($sfclass);
    }
    if (!$_FolderClass) {
        return;
    }
    $aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" class="' . $sfclass . '" />';
    $sErrorNumber = 0;
    $sFolderPath = GetResourceTypeDirectory($resourceType, 'GetFoldersAndFiles');
    $absolute_path = $Config['UserFilesAbsolutePath'];
    $oCurrentFolder = @opendir($sServerDir);
    if ($oCurrentFolder !== false) {
        while ($sFile = readdir($oCurrentFolder)) {
            if ($sFile != '.' && $sFile != '..') {
                if (is_dir($sServerDir . $sFile)) {
                    if (has_permission(dwiki_encodeFN($currentFolder) . $sFile, $resourceType) || has_open_access()) {
                        if ($isInternalLink && $_FolderClass < 255) {
                            $class = 'r';
                        } else {
                            $class = $_FolderClass < 8 ? 'r' : 'u';
                            can_delete($class);
                        }
                        if ($_FolderClass) {
                            $aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" class="' . $class . '" />';
                        }
                    }
                } else {
                    $iFileSize = @filesize($sServerDir . $sFile);
                    if (!$iFileSize) {
                        $iFileSize = 0;
                    }
                    if ($iFileSize > 0) {
                        $iFileSize = round($iFileSize / 1024);
                        if ($iFileSize < 1) {
                            $iFileSize = 1;
                        }
                    }
                    if ($isInternalLink) {
                        if (!preg_match('/\\.txt$/', $sFile)) {
                            continue;
                        }
                        if (has_permission(dwiki_encodeFN($currentFolder) . $sFile, $resourceType, false)) {
                            $aFiles[] = '<File name="' . ConvertToXmlAttribute($sFile) . '" size="' . $iFileSize . '" />';
                        }
                    } else {
                        if ($resourceType == 'Image') {
                            list($width, $height, $type, $attr) = getimagesize($sServerDir . $sFile);
                            if (isset($width) && isset($height)) {
                                $iFileSize .= ";;{$width};;{$height}";
                            }
                        }
                        $aFiles[] = '<File name="' . ConvertToXmlAttribute($sFile) . '" size="' . $iFileSize . '" />';
                    }
                }
            }
        }
        closedir($oCurrentFolder);
    }
    // Send the folders
    natcasesort($aFolders);
    echo '<Folders>';
    foreach ($aFolders as $sFolder) {
        echo $sFolder;
    }
    echo '</Folders>';
    // Send the files
    natcasesort($aFiles);
    echo '<Files>';
    foreach ($aFiles as $sFiles) {
        echo $sFiles;
    }
    echo '</Files>';
}