rename variables
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
$path = "/path/to/your/files";
|
||||
$thumbs = "/var/tmp/sharing-gallery/thumbnails/";
|
||||
$imagepath = "/path/to/your/files";
|
||||
$thumbpath = "/var/tmp/sharing-gallery/thumbnails/";
|
||||
$max_validity_days = "30";
|
||||
?>
|
@@ -58,33 +58,33 @@
|
||||
return $header;
|
||||
}
|
||||
function checkPath($pathToCheck) {
|
||||
global $path, $subpath;
|
||||
$fullpath = $path.'/'.$pathToCheck
|
||||
global $imagepath, $subpath;
|
||||
$fullpath = $imagepath.'/'.$pathToCheck
|
||||
if ($fullpath==realpath($fullpath) && is_dir($fullpath)) {
|
||||
$subpath=$pathToCheck;
|
||||
$path = $fullpath;
|
||||
$imagepath = $fullpath;
|
||||
} else {
|
||||
error_die('path not allowed: '.htmlentities($pathToCheck));
|
||||
}
|
||||
}
|
||||
function checkFile($fileToCheck, $thumb = false) {
|
||||
global $path, $file, $subpath, $thumbs, $imgfile;
|
||||
if (!ereg('/', $fileToCheck) && is_file($path.'/'.$fileToCheck)) {
|
||||
global $imagepath, $file, $subpath, $thumbpath, $imgfile;
|
||||
if (!ereg('/', $fileToCheck) && is_file($imagepath.'/'.$fileToCheck)) {
|
||||
$imgfile = $fileToCheck;
|
||||
} else {
|
||||
error_die('file not found', '404 Not Found');
|
||||
}
|
||||
if ($thumb) { // image from thumbnail path
|
||||
$file = $thumbs.'/'.$subpath.'/'.$fileToCheck;
|
||||
if (!is_dir($thumbs.'/'.$subpath)) mkdir($thumbs.'/'.$subpath, 0777, true);
|
||||
$file = $thumbpath.'/'.$subpath.'/'.$fileToCheck;
|
||||
if (!is_dir($thumbpath.'/'.$subpath)) mkdir($thumbpath.'/'.$subpath, 0777, true);
|
||||
if (!is_file($file)) { // create thumbnail
|
||||
$image = new Imagick();
|
||||
$image->readImage($path.'/'.$fileToCheck);
|
||||
$image->readImage($imagepath.'/'.$fileToCheck);
|
||||
$image->thumbnailImage(200, 200, true);
|
||||
$image->writeImage($file);
|
||||
}
|
||||
} else {
|
||||
$file = $path.'/'.$fileToCheck;
|
||||
$file = $imagepath.'/'.$fileToCheck;
|
||||
}
|
||||
}
|
||||
function returnFile($file) {
|
||||
@@ -160,9 +160,9 @@
|
||||
if ($username=="") error_die('not authorized', '403 Forbidden');
|
||||
if (isset($_REQUEST['path'])) checkPath($_REQUEST['path']);
|
||||
if (isset($_REQUEST['folder']) && !ereg('/', $_REQUEST['folder'])) {
|
||||
$file = $thumbs.'/folders/'.$subpath.'/'.$_REQUEST['folder'].'.png';
|
||||
$file = $thumbpath.'/folders/'.$subpath.'/'.$_REQUEST['folder'].'.png';
|
||||
$type="image/png";
|
||||
if (!is_dir($thumbs.'/folders/'.$subpath)) mkdir($thumbs.'/folders/'.$subpath, 0777, true);
|
||||
if (!is_dir($thumbpath.'/folders/'.$subpath)) mkdir($thumbpath.'/folders/'.$subpath, 0777, true);
|
||||
if (!is_file($file)) { // create folder image
|
||||
$txt = wordwrap(preg_replace('/ +/', ' ', preg_replace('/-/', ' - ', preg_replace('/_/', " ", $_REQUEST['folder']))), 16, "\n", true);
|
||||
$image = new Imagick();
|
||||
@@ -315,7 +315,7 @@
|
||||
makelink('?path='.urlencode($subpath).'&file='.urlencode($f).'&view', '?path='.urlencode($subpath).'&file='.urlencode($f).'&thumb', $f);
|
||||
} else {
|
||||
if (isset($_REQUEST['view'])) { // view single image
|
||||
$objects = extractDir($path);
|
||||
$objects = extractDir($imagepath);
|
||||
$pos = array_search($imgfile, $objects['files']);
|
||||
if ($pos>0)
|
||||
echo '<a href="?path='.urlencode($subpath).'&file='.urlencode($objects['files'][$pos-1]).'&view"><img src="?folder=←" alt="previous"/></a>';
|
||||
@@ -348,7 +348,7 @@
|
||||
} elseif ($subpath!="") {
|
||||
echo '<a href="?"><img src="?folder=↑" alt="↑"/></a>';
|
||||
}
|
||||
$objects = extractDir($path);
|
||||
$objects = extractDir($imagepath);
|
||||
foreach ($objects['dirs'] as $f)
|
||||
makelink('?path='.urlencode($subpath.($subpath!=""?'/':'').$f), '?path='.urlencode($subpath).'&folder='.urlencode($f), $f);
|
||||
echo '</div><div class="images">';
|
||||
|
Reference in New Issue
Block a user