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