Пример #1
0
     $fileItem['height'] = $config['thumbnail.height'];
 }
 $fileItem['name'] = basename($file->getAbsolutePath());
 $fileItem['path'] = $file->getAbsolutePath();
 $fileItem['modificationdate'] = date($config['filesystem.datefmt'], $file->lastModified());
 $fileItem['even'] = $even;
 $fileItem['hasReadAccess'] = $file->canRead() && checkBool($config["filesystem.readable"]) ? "true" : "false";
 $fileItem['hasWriteAccess'] = $file->canWrite() && checkBool($config["filesystem.writable"]) ? "true" : "false";
 // File info
 $fileType = getFileType($file->getAbsolutePath());
 $fileItem['icon'] = $fileType['icon'];
 $fileItem['type'] = $fileType['type'];
 $fileItem['ext'] = $fileType['ext'];
 $fileItem['editable'] = $isGD && ($fileType['ext'] == "gif" || $fileType['ext'] == "jpg" || $fileType['ext'] == "jpeg" || $fileType['ext'] == "png");
 // Preview path
 $wwwroot = removeTrailingSlash(toUnixPath(getWWWRoot($config)));
 $urlprefix = removeTrailingSlash(toUnixPath($config['preview.urlprefix']));
 $urlsuffix = toUnixPath($config['preview.urlsuffix']);
 $fileItem['previewurl'] = "";
 $pos = strpos($filepath, $wwwroot);
 if ($pos !== false && $pos == 0) {
     $fileItem['previewurl'] = $urlprefix . substr($filepath, strlen($wwwroot)) . $urlsuffix;
 } else {
     $fileItem['previewurl'] = "ERROR IN PATH";
 }
 if ($fileItem['editable'] == true and checkBool($config['thumbnail.gd.enabled']) == true) {
     $fileItem['url'] = "thumbnail.php?path=" . $fileItem['path'] . "&width=" . $fileItem['width'] . "&height=" . $fileItem['height'] . "&ext=" . $fileItem['ext'];
 } else {
     $fileItem['url'] = $fileItem['previewurl'];
 }
 $even = !$even;
Пример #2
0
/**
 * Sets the filesystem.path option value based on the url input value.
 *
 * @param $config Config name/value array to modify.
 */
function setupPathFromURL(&$root_paths, &$config)
{
    $url = getRequestParam("url", "");
    $wwwRoot = getWWWRoot($config);
    if ($url != "") {
        // Is absolute URL
        if (strpos($url, $config['preview.urlprefix']) === 0) {
            // Trim away prefix
            $path = substr($url, strlen($config['preview.urlprefix']) - 1);
            $path = toUnixPath($wwwRoot . $path);
            $rootPath = isChildPath($root_paths, $path);
            if ($rootPath) {
                // Try file
                if (file_exists($path)) {
                    $config['filesystem.path'] = $path;
                    $config['filesystem.rootpath'] = $rootPath;
                } else {
                    // Try the dir if the file wasn't found
                    $path = dirname($path);
                    if (file_exists($path)) {
                        $config['filesystem.path'] = $path;
                        $config['filesystem.rootpath'] = $rootPath;
                    }
                }
                return;
            }
        }
        // Is site absolute URL
        $path = toUnixPath($wwwRoot . $url);
        $rootPath = isChildPath($root_paths, $path);
        if ($rootPath) {
            // Try file
            if (file_exists($path)) {
                $config["filesystem.path"] = $path;
                $config['filesystem.rootpath'] = $rootPath;
            } else {
                // Try the dir if the file wasn't found
                $path = dirname($path);
                if (file_exists($path)) {
                    $config['filesystem.path'] = $path;
                    $config['filesystem.rootpath'] = $rootPath;
                }
            }
            return;
        }
    }
}