コード例 #1
0
ファイル: preview.php プロジェクト: sonvq/2015_freelance6
    $files = $file->listFilesFiltered($fileFilter);
    //$files = $file->listFiles();
    $fileCount = 0;
    $dirCount = 0;
    $sizeSum = 0;
    foreach ($files as $file) {
        if ($file->isFile()) {
            $fileCount++;
        } else {
            $dirCount++;
        }
        $sizeSum += $file->length();
    }
    $data['files'] = $fileCount;
    $data['subdirs'] = $dirCount;
    $data['filessize'] = getSizeStr($sizeSum);
} else {
    $path = $file->getAbsolutePath();
    $wwwroot = removeTrailingSlash(toUnixPath(getWWWRoot($config)));
    $urlprefix = removeTrailingSlash(toUnixPath($config['preview.urlprefix']));
    $urlsuffix = toUnixPath($config['preview.urlsuffix']);
    $pos = strpos($path, $wwwroot);
    if ($pos !== false && $pos == 0) {
        $data['previewurl'] = $urlprefix . substr($path, strlen($wwwroot)) . $urlsuffix;
    }
}
// Redirect
if ($redirect == "true") {
    header('location: ' . $data['previewurl']);
    die;
}
コード例 #2
0
ファイル: unzip.php プロジェクト: sonvq/2015_freelance6
     }
     if ($fileFilter->accept($fileObject)) {
         $zippedfile['status'] = "Accepted";
     } else {
         $zippedfile['status_message'] = "Folder is excluded cause of configurated filters.";
         $zippedfile['status'] = "Denied";
         $excludedDirArray[] = removeTrailingSlash($zippedfile['filename']);
     }
 } else {
     if ($zippedfile['size'] != 0) {
         $zippedfile['ratio'] = abs(round($zippedfile['compressed_size'] / $zippedfile['size'] * 100) - 100);
     } else {
         $zippedfile['ratio'] = "0";
     }
     $zippedfile['size'] = getSizeStr($zippedfile['size']);
     $zippedfile['compressed_size'] = getSizeStr($zippedfile['compressed_size']);
     if ($zippedfile['status'] != "ok") {
         $zippedfile['status'] = "Denied";
         $zippedfile['status_message'] = "File not accepted cause of error in zip.";
         $excludedFileArray[] = $zippedfile['filename'];
         continue;
     }
     if ($fileFilter->accept($fileObject)) {
         if ($filepath != "") {
             if (!in_array($filepath, $excludedDirArray)) {
                 $zippedfile['status'] = "Accepted";
             } else {
                 $zippedfile['status_message'] = "Excluded cause of previous filters for folders.";
                 $zippedfile['status'] = "Denied";
                 $excludedFileArray[] = $zippedfile['filename'];
             }
コード例 #3
0
ファイル: ajax.php プロジェクト: stormlab/Stormlab
         $imageSize = imageResize($imageSize[0], $imageSize[1], $config['thumbnail.width'], $config['thumbnail.height']);
         $imageInfo['width'] = $imageSize['width'];
         $imageInfo['height'] = $imageSize['height'];
         $imageInfo['scale'] = $imageSize['scale'];
         // Calculate margin
         if ($config['thumbnail.height'] - $imageSize['height'] > 0) {
             $imageInfo['margin'] = ($config['thumbnail.height'] - $imageSize['height']) / 2;
         }
     } else {
         $imageInfo['width'] = $config['thumbnail.width'];
         $imageInfo['height'] = $config['thumbnail.height'];
         $imageInfo['scale'] = 0;
     }
     $imageInfo['name'] = basename($imageFile->getAbsolutePath());
     $imageInfo['path'] = $imageFile->getAbsolutePath();
     $imageInfo['size'] = getSizeStr($imageFile->length());
     $fileType = getFileType($imageFile->getAbsolutePath());
     $imageInfo['icon'] = $fileType['icon'];
     $imageInfo['type'] = $fileType['type'];
     $imageInfo['ext'] = $fileType['ext'];
     $data = '<img width="' . $imageInfo['real_width'] . '" height="' . $imageInfo['real_height'] . '" path="' . $imageInfo['path'] . '" scale="' . $imageInfo['scale'] . '" type="' . $imageInfo['type'] . '" size="' . $imageInfo['size'] . '" ext="' . $imageInfo['ext'] . '" icon="' . $imageInfo['icon'] . '" />';
     break;
 case "delete":
     $filename = getRequestParam("filename");
     $fileFactory =& new FileFactory($mcImageManagerConfig, $mcImageManagerConfig['filesystem.rootpath']);
     addFileEventListeners($fileFactory);
     $imageFile =& $fileFactory->getFile($path);
     $config = $imageFile->getConfig();
     $selectedFiles = array();
     foreach ($_REQUEST as $name => $value) {
         if (strpos($name, "file_") !== false || strpos($name, "dir_") !== false) {
コード例 #4
0
ファイル: filelist.php プロジェクト: sonvq/2015_freelance6
}
// List files
$accessFile = $config["filesystem.local.access_file_name"];
foreach ($files as $file) {
    if ($file->isDirectory()) {
        continue;
    }
    // Hide access files
    if ($file->getName() == $accessFile) {
        continue;
    }
    $fileItem = array();
    $name = $file->getAbsolutePath();
    $fileItem['name'] = basename($file->getAbsolutePath());
    $fileItem['path'] = $file->getAbsolutePath();
    $fileItem['size'] = getSizeStr($file->length());
    $fileItem['modificationdate'] = date($config['filesystem.datefmt'], $file->lastModified());
    $fileItem['isDir'] = false;
    $fileItem['isParent'] = false;
    $fileItem['isCut'] = false;
    $fileItem['even'] = $even;
    $fileItem['hasReadAccess'] = $file->canRead() && checkBool($config["filesystem.readable"]) ? "true" : "false";
    $fileItem['hasWriteAccess'] = $file->canWrite() && checkBool($config["filesystem.writable"]) ? "true" : "false";
    // Is in clipboard and is cut
    if (isset($_SESSION['MCFileManager_clipboardAction']) && $_SESSION['MCFileManager_clipboardAction'] == "cut") {
        $fileArray = $_SESSION['MCFileManager_clipboardFiles'];
        foreach ($fileArray as $tmpFilePath) {
            if ($file->getAbsolutePath() == $tmpFilePath) {
                $fileItem['isCut'] = true;
                break;
            }
コード例 #5
0
ファイル: upload.php プロジェクト: stormlab/Stormlab
$data['valid_extensions'] = implode(', ', $validExtArr);
// Check file size
$maxSize = preg_replace("/[^0-9]/", "", $config["upload.maxsize"]);
$maxSizeBytes = $maxSize;
$prefix = " bytes";
// Is KB
if (strpos(strtolower($config["upload.maxsize"]), "k") > 0) {
    $maxSizeBytes *= 1024;
    $prefix = " KB";
}
// Is MB
if (strpos(strtolower($config["upload.maxsize"]), "m") > 0) {
    $maxSizeBytes *= 1024 * 1024;
    $prefix = " MB";
}
$data['max_file_size'] = getSizeStr($maxSizeBytes);
// Always create a local file instance
for ($i = 0; isset($_FILES['file' . $i]['tmp_name']); $i++) {
    // Do nothing in demo mode
    if (checkBool($config['general.demo'])) {
        trigger_error($config['general.demo_msg'], FATAL);
    }
    // No access, tool disabled
    if (in_array("upload", explode(',', $config['general.disabled_tools']))) {
        trigger_error("You don't have access to perform the requested action.", FATAL);
    }
    $filename = getRequestParam("filename" . $i, false);
    $data['filename' . $i] = $filename;
    // Get the god damned extension
    $ext = "";
    if (strpos(basename($_FILES['file' . $i]['name']), ".") > 0) {
コード例 #6
0
ファイル: preview.php プロジェクト: stormlab/Stormlab
    }
    $prevItem = $fileItem;
    $count++;
}
function getInfo($filepath)
{
    $info = array();
    $imageSize = getimagesize($filepath);
    $info['width'] = $imageSize[0] ? $imageSize[0] : 0;
    $into['height'] = $imageSize[1] ? $imageSize[1] : 0;
    return $info;
}
$imageinfo = getimagesize($path);
$pos = strpos($path, $wwwroot);
if ($pos !== false && $pos == 0) {
    $data['previewurl'] = $urlprefix . substr($path, strlen($wwwroot)) . $urlsuffix;
} else {
    $data['previewurl'] = "";
}
$data['next'] = $next;
$data['previous'] = $previous;
$data['first'] = $first;
$data['last'] = $last;
$data['path'] = $path;
$data['name'] = basename($path);
$data['width'] = $imageinfo[0] ? $imageinfo[0] : 0;
$data['height'] = $imageinfo[1] ? $imageinfo[1] : 0;
$data['size'] = getSizeStr($targetFile->length());
$data['errorMsg'] = "";
// Render output
renderPage("preview.tpl.php", $data);