PSR2 php style
This commit is contained in:
parent
7466c634f0
commit
08cbcbdc5f
7 changed files with 666 additions and 574 deletions
|
@ -27,11 +27,25 @@ error_reporting(0);
|
||||||
|
|
||||||
$get_filename = $_GET['filename'];
|
$get_filename = $_GET['filename'];
|
||||||
$get_size = @$_GET['size'];
|
$get_size = @$_GET['size'];
|
||||||
if (empty($get_size)) $get_size = 120;
|
if (empty($get_size)) {
|
||||||
if (preg_match("/^\/.*/i", $get_filename)) die("Unauthorized access !");
|
$get_size = 120;
|
||||||
if (preg_match("/.jpe?g$/i", $get_filename)) $get_filename_type = "JPG";
|
}
|
||||||
if (preg_match("/.gif$/i", $get_filename)) $get_filename_type = "GIF";
|
|
||||||
if (preg_match("/.png$/i", $get_filename)) $get_filename_type = "PNG";
|
if (preg_match("/^\/.*/i", $get_filename)) {
|
||||||
|
die("Unauthorized access !");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match("/.jpe?g$/i", $get_filename)) {
|
||||||
|
$get_filename_type = "JPG";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match("/.gif$/i", $get_filename)) {
|
||||||
|
$get_filename_type = "GIF";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match("/.png$/i", $get_filename)) {
|
||||||
|
$get_filename_type = "PNG";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vertical flip
|
* Vertical flip
|
||||||
|
@ -42,8 +56,7 @@ function flipVertical(&$img) {
|
||||||
$size_y = imagesy($img);
|
$size_y = imagesy($img);
|
||||||
$temp = imagecreatetruecolor($size_x, $size_y);
|
$temp = imagecreatetruecolor($size_x, $size_y);
|
||||||
$x = imagecopyresampled($temp, $img, 0, 0, 0, ($size_y - 1), $size_x, $size_y, $size_x, 0 - $size_y);
|
$x = imagecopyresampled($temp, $img, 0, 0, 0, ($size_y - 1), $size_x, $size_y, $size_x, 0 - $size_y);
|
||||||
if ($x)
|
if ($x) {
|
||||||
{
|
|
||||||
$img = $temp;
|
$img = $temp;
|
||||||
} else {
|
} else {
|
||||||
die("Unable to flip image");
|
die("Unable to flip image");
|
||||||
|
@ -59,8 +72,7 @@ function flipHorizontal(&$img) {
|
||||||
$size_y = imagesy($img);
|
$size_y = imagesy($img);
|
||||||
$temp = imagecreatetruecolor($size_x, $size_y);
|
$temp = imagecreatetruecolor($size_x, $size_y);
|
||||||
$x = imagecopyresampled($temp, $img, 0, 0, ($size_x - 1), 0, $size_x, $size_y, 0 - $size_x, $size_y);
|
$x = imagecopyresampled($temp, $img, 0, 0, ($size_x - 1), 0, $size_x, $size_y, 0 - $size_x, $size_y);
|
||||||
if ($x)
|
if ($x) {
|
||||||
{
|
|
||||||
$img = $temp;
|
$img = $temp;
|
||||||
} else {
|
} else {
|
||||||
die("Unable to flip image");
|
die("Unable to flip image");
|
||||||
|
@ -75,8 +87,7 @@ function sanitize($name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the "thumbs" directory exists.
|
// Make sure the "thumbs" directory exists.
|
||||||
if (!is_dir('thumbs') && is_writable('.'))
|
if (!is_dir('thumbs') && is_writable('.')) {
|
||||||
{
|
|
||||||
mkdir('thumbs', 0700);
|
mkdir('thumbs', 0700);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,13 +132,12 @@ $yoord = 0;
|
||||||
$imgsize = getimagesize($get_filename);
|
$imgsize = getimagesize($get_filename);
|
||||||
$width = $imgsize[0];
|
$width = $imgsize[0];
|
||||||
$height = $imgsize[1];
|
$height = $imgsize[1];
|
||||||
if ($width > $height) // If the width is greater than the height it’s a horizontal picture
|
// If the width is greater than the height it’s a horizontal picture
|
||||||
{
|
if ($width > $height) {
|
||||||
$xoord = ceil(($width - $height) / 2);
|
$xoord = ceil(($width - $height) / 2);
|
||||||
$width = $height; // Then we read a square frame that equals the width
|
// Then we read a square frame that equals the width
|
||||||
}
|
$width = $height;
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
$yoord = ceil(($height - $width) / 2);
|
$yoord = ceil(($height - $width) / 2);
|
||||||
$height = $width;
|
$height = $width;
|
||||||
}
|
}
|
||||||
|
@ -174,27 +184,33 @@ if (preg_match("/.jpg$|.jpeg$/i", $_GET['filename'])) {
|
||||||
$target = imagecreatetruecolor($get_size, $get_size);
|
$target = imagecreatetruecolor($get_size, $get_size);
|
||||||
|
|
||||||
// if the picture can be transparent, add a white background
|
// if the picture can be transparent, add a white background
|
||||||
if (in_array($get_filename_type, array("GIF", "PNG")))
|
if (in_array($get_filename_type, array("GIF", "PNG"))) {
|
||||||
{
|
|
||||||
$backgroundColor = imagecolorallocate($target, 255, 255, 255);
|
$backgroundColor = imagecolorallocate($target, 255, 255, 255);
|
||||||
imagefill($target, 0, 0, $backgroundColor);
|
imagefill($target, 0, 0, $backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($get_filename_type == "JPG") $source = imagecreatefromjpeg($get_filename);
|
if ($get_filename_type == "JPG") {
|
||||||
if ($get_filename_type == "GIF") $source = imagecreatefromgif($get_filename);
|
$source = imagecreatefromjpeg($get_filename);
|
||||||
if ($get_filename_type == "PNG") $source = imagecreatefrompng($get_filename);
|
}
|
||||||
|
|
||||||
|
if ($get_filename_type == "GIF") {
|
||||||
|
$source = imagecreatefromgif($get_filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($get_filename_type == "PNG") {
|
||||||
|
$source = imagecreatefrompng($get_filename);
|
||||||
|
}
|
||||||
|
|
||||||
imagecopyresampled($target, $source, 0, 0, $xoord, $yoord, $get_size, $get_size, $width, $height);
|
imagecopyresampled($target, $source, 0, 0, $xoord, $yoord, $get_size, $get_size, $width, $height);
|
||||||
imagedestroy($source);
|
imagedestroy($source);
|
||||||
|
|
||||||
//proper rotation by jan niggemann
|
//proper rotation by jan niggemann
|
||||||
if ($degrees != 0)
|
if ($degrees != 0) {
|
||||||
{
|
|
||||||
$target = imagerotate($target, $degrees, 0);
|
$target = imagerotate($target, $degrees, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//proper mirror (aka flip) by jan niggemann
|
//proper mirror (aka flip) by jan niggemann
|
||||||
if ($flip == 'vertical')
|
if ($flip == 'vertical') {
|
||||||
{
|
|
||||||
//only in php >= 5.5.0 ImageJPEG(imageflip($target, IMG_FLIP_VERTICAL),null,80);
|
//only in php >= 5.5.0 ImageJPEG(imageflip($target, IMG_FLIP_VERTICAL),null,80);
|
||||||
flipVertical($target);
|
flipVertical($target);
|
||||||
flipHorizontal($target);
|
flipHorizontal($target);
|
||||||
|
@ -208,11 +224,9 @@ imagedestroy($target);
|
||||||
$cachedImage = ob_get_contents(); // Get the buffer content.
|
$cachedImage = ob_get_contents(); // Get the buffer content.
|
||||||
ob_end_flush(); // End buffering
|
ob_end_flush(); // End buffering
|
||||||
|
|
||||||
if (is_writable(dirname($thumbname)))
|
if (is_writable(dirname($thumbname))) {
|
||||||
{
|
|
||||||
$fd = fopen($thumbname, "w"); // Save buffer to disk
|
$fd = fopen($thumbname, "w"); // Save buffer to disk
|
||||||
if ($fd)
|
if ($fd) {
|
||||||
{
|
|
||||||
fwrite($fd, $cachedImage);
|
fwrite($fd, $cachedImage);
|
||||||
fclose($fd);
|
fclose($fd);
|
||||||
}
|
}
|
||||||
|
|
139
index.php
139
index.php
|
@ -29,8 +29,8 @@ header('Content-Type: text/html; charset=UTF-8'); // We use UTF-8 for proper int
|
||||||
$version = "0.3.7";
|
$version = "0.3.7";
|
||||||
ini_set("memory_limit", "256M");
|
ini_set("memory_limit", "256M");
|
||||||
|
|
||||||
require("config-default.php");
|
require "config-default.php";
|
||||||
include("config.php");
|
include "config.php";
|
||||||
|
|
||||||
//-----------------------
|
//-----------------------
|
||||||
// DEFINE VARIABLES
|
// DEFINE VARIABLES
|
||||||
|
@ -55,8 +55,7 @@ if (!function_exists('exif_read_data') && $display_exif == 1) {
|
||||||
//-----------------------
|
//-----------------------
|
||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
//-----------------------
|
//-----------------------
|
||||||
function padstring($name, $length)
|
function padstring($name, $length) {
|
||||||
{
|
|
||||||
global $label_max_length;
|
global $label_max_length;
|
||||||
if (!isset($length)) {
|
if (!isset($length)) {
|
||||||
$length = $label_max_length;
|
$length = $label_max_length;
|
||||||
|
@ -67,8 +66,7 @@ function padstring($name, $length)
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getfirstImage($dirname)
|
function getfirstImage($dirname) {
|
||||||
{
|
|
||||||
$imageName = false;
|
$imageName = false;
|
||||||
$extensions = array("jpg", "png", "jpeg", "gif");
|
$extensions = array("jpg", "png", "jpeg", "gif");
|
||||||
if ($handle = opendir($dirname)) {
|
if ($handle = opendir($dirname)) {
|
||||||
|
@ -91,8 +89,7 @@ function getfirstImage($dirname)
|
||||||
return $imageName;
|
return $imageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse_fraction($v, $round=0)
|
function parse_fraction($v, $round = 0) {
|
||||||
{
|
|
||||||
list($x, $y) = array_map('intval', explode('/', $v));
|
list($x, $y) = array_map('intval', explode('/', $v));
|
||||||
if (empty($x) || empty($y)) {
|
if (empty($x) || empty($y)) {
|
||||||
return $v;
|
return $v;
|
||||||
|
@ -106,8 +103,7 @@ function parse_fraction($v, $round=0)
|
||||||
return round($x / $y, $round);
|
return round($x / $y, $round);
|
||||||
}
|
}
|
||||||
|
|
||||||
function readEXIF($file)
|
function readEXIF($file) {
|
||||||
{
|
|
||||||
$exif_arr = array();
|
$exif_arr = array();
|
||||||
$exif_data = exif_read_data($file);
|
$exif_data = exif_read_data($file);
|
||||||
|
|
||||||
|
@ -141,8 +137,7 @@ function readEXIF($file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkpermissions($file)
|
function checkpermissions($file) {
|
||||||
{
|
|
||||||
global $messages;
|
global $messages;
|
||||||
|
|
||||||
if (!is_readable($file)) {
|
if (!is_readable($file)) {
|
||||||
|
@ -153,11 +148,15 @@ function checkpermissions($file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined("GALLERY_ROOT"))
|
if (!defined("GALLERY_ROOT")) {
|
||||||
define("GALLERY_ROOT", "");
|
define("GALLERY_ROOT", "");
|
||||||
|
}
|
||||||
|
|
||||||
$requestedDir = '';
|
$requestedDir = '';
|
||||||
if (!empty($_GET['dir']))
|
if (!empty($_GET['dir'])) {
|
||||||
$requestedDir = $_GET['dir'];
|
$requestedDir = $_GET['dir'];
|
||||||
|
}
|
||||||
|
|
||||||
$thumbdir = rtrim('photos/' . $requestedDir, '/');
|
$thumbdir = rtrim('photos/' . $requestedDir, '/');
|
||||||
|
|
||||||
//$thumbdir = str_replace('/..', '', $thumbdir); // Prevent directory traversal attacks.
|
//$thumbdir = str_replace('/..', '', $thumbdir); // Prevent directory traversal attacks.
|
||||||
|
@ -207,7 +206,7 @@ if (is_dir($currentdir) && $handle = opendir($currentdir)) {
|
||||||
$imgParams = http_build_query(
|
$imgParams = http_build_query(
|
||||||
array(
|
array(
|
||||||
'filename' => "$currentdir/$file/folder.jpg",
|
'filename' => "$currentdir/$file/folder.jpg",
|
||||||
'size' => $thumb_size
|
'size' => $thumb_size,
|
||||||
),
|
),
|
||||||
'',
|
'',
|
||||||
'&'
|
'&'
|
||||||
|
@ -217,7 +216,7 @@ if (is_dir($currentdir) && $handle = opendir($currentdir)) {
|
||||||
$dirs[] = array(
|
$dirs[] = array(
|
||||||
"name" => $file,
|
"name" => $file,
|
||||||
"date" => filemtime($currentdir . "/" . $file . "/folder.jpg"),
|
"date" => filemtime($currentdir . "/" . $file . "/folder.jpg"),
|
||||||
"html" => "<li><a href=\"{$linkUrl}\"><em>" . padstring($file, $label_max_length) . "</em><span></span><img src=\"{$imgUrl}\" alt=\"$label_loading\" /></a></li>"
|
"html" => "<li><a href=\"{$linkUrl}\"><em>" . padstring($file, $label_max_length) . "</em><span></span><img src=\"{$imgUrl}\" alt=\"$label_loading\" /></a></li>",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Set thumbnail to first image found (if any):
|
// Set thumbnail to first image found (if any):
|
||||||
|
@ -235,7 +234,7 @@ if (is_dir($currentdir) && $handle = opendir($currentdir)) {
|
||||||
$imgParams = http_build_query(
|
$imgParams = http_build_query(
|
||||||
array(
|
array(
|
||||||
'filename' => "$thumbdir/$file/$firstimage",
|
'filename' => "$thumbdir/$file/$firstimage",
|
||||||
'size' => $thumb_size
|
'size' => $thumb_size,
|
||||||
),
|
),
|
||||||
'',
|
'',
|
||||||
'&'
|
'&'
|
||||||
|
@ -245,7 +244,7 @@ if (is_dir($currentdir) && $handle = opendir($currentdir)) {
|
||||||
$dirs[] = array(
|
$dirs[] = array(
|
||||||
"name" => $file,
|
"name" => $file,
|
||||||
"date" => filemtime($currentdir . "/" . $file),
|
"date" => filemtime($currentdir . "/" . $file),
|
||||||
"html" => "<li><a href=\"{$linkUrl}\"><em>" . padstring($file, $label_max_length) . "</em><span></span><img src=\"{$imgUrl}\" alt='$label_loading' /></a></li>"
|
"html" => "<li><a href=\"{$linkUrl}\"><em>" . padstring($file, $label_max_length) . "</em><span></span><img src=\"{$imgUrl}\" alt='$label_loading' /></a></li>",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// If no folder.jpg or image is found, then display default icon:
|
// If no folder.jpg or image is found, then display default icon:
|
||||||
|
@ -260,7 +259,7 @@ if (is_dir($currentdir) && $handle = opendir($currentdir)) {
|
||||||
$dirs[] = array(
|
$dirs[] = array(
|
||||||
"name" => $file,
|
"name" => $file,
|
||||||
"date" => filemtime($currentdir . "/" . $file),
|
"date" => filemtime($currentdir . "/" . $file),
|
||||||
"html" => "<li><a href=\"{$linkUrl}\"><em>" . padstring($file, $label_max_length) . "</em><span></span><img src=\"{$imgUrl}\" width='$thumb_size' height='$thumb_size' alt='$label_loading' /></a></li>"
|
"html" => "<li><a href=\"{$linkUrl}\"><em>" . padstring($file, $label_max_length) . "</em><span></span><img src=\"{$imgUrl}\" width='$thumb_size' height='$thumb_size' alt='$label_loading' /></a></li>",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,10 +268,12 @@ if (is_dir($currentdir) && $handle = opendir($currentdir)) {
|
||||||
|
|
||||||
// 3. LOAD FILES
|
// 3. LOAD FILES
|
||||||
if ($file != "." && $file != ".." && $file != "folder.jpg") {
|
if ($file != "." && $file != ".." && $file != "folder.jpg") {
|
||||||
if ($display_filename)
|
if ($display_filename) {
|
||||||
$filename_caption = "<em>" . padstring($file, $label_max_length) . "</em>";
|
$filename_caption = "<em>" . padstring($file, $label_max_length) . "</em>";
|
||||||
else
|
} else {
|
||||||
$filename_caption = "";
|
$filename_caption = "";
|
||||||
|
}
|
||||||
|
|
||||||
// JPG, GIF and PNG
|
// JPG, GIF and PNG
|
||||||
if (preg_match("/.jpg$|.gif$|.png$/i", $file)) {
|
if (preg_match("/.jpg$|.gif$|.png$/i", $file)) {
|
||||||
//Read EXIF
|
//Read EXIF
|
||||||
|
@ -292,18 +293,22 @@ if (is_dir($currentdir) && $handle = opendir($currentdir)) {
|
||||||
// If file is not provided, image filename will be used instead.
|
// If file is not provided, image filename will be used instead.
|
||||||
checkpermissions($currentdir . "/" . $file);
|
checkpermissions($currentdir . "/" . $file);
|
||||||
|
|
||||||
if (is_file($currentdir.'/'.$file.'.html'))
|
if (is_file($currentdir . '/' . $file . '.html')) {
|
||||||
$img_captions[$file] = $file . '::' . htmlspecialchars(file_get_contents($currentdir . '/' . $file . '.html'), ENT_QUOTES);
|
$img_captions[$file] = $file . '::' . htmlspecialchars(file_get_contents($currentdir . '/' . $file . '.html'), ENT_QUOTES);
|
||||||
|
}
|
||||||
|
|
||||||
$linkUrl = str_replace('%2F', '/', rawurlencode("$currentdir/$file"));
|
$linkUrl = str_replace('%2F', '/', rawurlencode("$currentdir/$file"));
|
||||||
$imgParams = http_build_query(
|
$imgParams = http_build_query(
|
||||||
array('filename' => "$thumbdir/$file", 'size' => $thumb_size),
|
array('filename' => "$thumbdir/$file", 'size' => $thumb_size),
|
||||||
'',
|
'',
|
||||||
'&');
|
'&');
|
||||||
$imgUrl = GALLERY_ROOT . "createthumb.php?$imgParams";
|
$imgUrl = GALLERY_ROOT . "createthumb.php?$imgParams";
|
||||||
if ($lazyload)
|
if ($lazyload) {
|
||||||
$imgopts = "class=\"b-lazy\" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src=\"$imgUrl\"";
|
$imgopts = "class=\"b-lazy\" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src=\"$imgUrl\"";
|
||||||
else
|
} else {
|
||||||
$imgopts = "src=\"{$imgUrl}\"";
|
$imgopts = "src=\"{$imgUrl}\"";
|
||||||
|
}
|
||||||
|
|
||||||
$files[] = array(
|
$files[] = array(
|
||||||
"name" => $file,
|
"name" => $file,
|
||||||
"date" => filemtime($currentdir . "/" . $file),
|
"date" => filemtime($currentdir . "/" . $file),
|
||||||
|
@ -312,16 +317,46 @@ if (is_dir($currentdir) && $handle = opendir($currentdir)) {
|
||||||
}
|
}
|
||||||
// Other filetypes
|
// Other filetypes
|
||||||
$extension = "";
|
$extension = "";
|
||||||
if (preg_match("/\.pdf$/i", $file)) $extension = "PDF"; // PDF
|
if (preg_match("/\.pdf$/i", $file)) {
|
||||||
if (preg_match("/\.zip$/i", $file)) $extension = "ZIP"; // ZIP archive
|
$extension = "PDF";
|
||||||
if (preg_match("/\.rar$|\.r[0-9]{2,}/i", $file)) $extension = "RAR"; // RAR Archive
|
}
|
||||||
if (preg_match("/\.tar$/i", $file)) $extension = "TAR"; // TARball archive
|
// PDF
|
||||||
if (preg_match("/\.gz$/i", $file)) $extension = "GZ"; // GZip archive
|
if (preg_match("/\.zip$/i", $file)) {
|
||||||
if (preg_match("/\.doc$|\.docx$/i", $file)) $extension = "DOCX"; // Word
|
$extension = "ZIP";
|
||||||
if (preg_match("/\.ppt$|\.pptx$/i", $file)) $extension = "PPTX"; //Powerpoint
|
}
|
||||||
if (preg_match("/\.xls$|\.xlsx$/i", $file)) $extension = "XLXS"; // Excel
|
// ZIP archive
|
||||||
if (preg_match("/\.ogv$|\.mp4$|\.mpg$|\.mpeg$|\.mov$|\.avi$|\.wmv$|\.flv$|\.webm$/i", $file)) $extension = "VIDEO"; // video files
|
if (preg_match("/\.rar$|\.r[0-9]{2,}/i", $file)) {
|
||||||
if (preg_match("/\.aiff$|\.aif$|\.wma$|\.aac$|\.flac$|\.mp3$|\.ogg$|\.m4a$/i", $file)) $extension = "AUDIO"; // audio files
|
$extension = "RAR";
|
||||||
|
}
|
||||||
|
// RAR Archive
|
||||||
|
if (preg_match("/\.tar$/i", $file)) {
|
||||||
|
$extension = "TAR";
|
||||||
|
}
|
||||||
|
// TARball archive
|
||||||
|
if (preg_match("/\.gz$/i", $file)) {
|
||||||
|
$extension = "GZ";
|
||||||
|
}
|
||||||
|
// GZip archive
|
||||||
|
if (preg_match("/\.doc$|\.docx$/i", $file)) {
|
||||||
|
$extension = "DOCX";
|
||||||
|
}
|
||||||
|
// Word
|
||||||
|
if (preg_match("/\.ppt$|\.pptx$/i", $file)) {
|
||||||
|
$extension = "PPTX";
|
||||||
|
}
|
||||||
|
//Powerpoint
|
||||||
|
if (preg_match("/\.xls$|\.xlsx$/i", $file)) {
|
||||||
|
$extension = "XLXS";
|
||||||
|
}
|
||||||
|
// Excel
|
||||||
|
if (preg_match("/\.ogv$|\.mp4$|\.mpg$|\.mpeg$|\.mov$|\.avi$|\.wmv$|\.flv$|\.webm$/i", $file)) {
|
||||||
|
$extension = "VIDEO";
|
||||||
|
}
|
||||||
|
// video files
|
||||||
|
if (preg_match("/\.aiff$|\.aif$|\.wma$|\.aac$|\.flac$|\.mp3$|\.ogg$|\.m4a$/i", $file)) {
|
||||||
|
$extension = "AUDIO";
|
||||||
|
}
|
||||||
|
// audio files
|
||||||
|
|
||||||
if ($extension != "") {
|
if ($extension != "") {
|
||||||
$files[] = array(
|
$files[] = array(
|
||||||
|
@ -368,12 +403,15 @@ if (sizeof($files) > 0) {
|
||||||
//-----------------------
|
//-----------------------
|
||||||
// OFFSET DETERMINATION
|
// OFFSET DETERMINATION
|
||||||
//-----------------------
|
//-----------------------
|
||||||
if (!isset($_GET["page"]))
|
if (!isset($_GET["page"])) {
|
||||||
$_GET["page"] = 1;
|
$_GET["page"] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
$offset_start = ($_GET["page"] * $thumbs_pr_page) - $thumbs_pr_page;
|
$offset_start = ($_GET["page"] * $thumbs_pr_page) - $thumbs_pr_page;
|
||||||
$offset_end = $offset_start + $thumbs_pr_page;
|
$offset_end = $offset_start + $thumbs_pr_page;
|
||||||
if ($offset_end > sizeof($dirs) + sizeof($files))
|
if ($offset_end > sizeof($dirs) + sizeof($files)) {
|
||||||
$offset_end = sizeof($dirs) + sizeof($files);
|
$offset_end = sizeof($dirs) + sizeof($files);
|
||||||
|
}
|
||||||
|
|
||||||
if ($_GET["page"] == "all" || $lazyload) {
|
if ($_GET["page"] == "all" || $lazyload) {
|
||||||
$offset_start = 0;
|
$offset_start = 0;
|
||||||
|
@ -386,20 +424,26 @@ if ($_GET["page"] == "all" || $lazyload) {
|
||||||
if (!$lazyload && sizeof($dirs) + sizeof($files) > $thumbs_pr_page) {
|
if (!$lazyload && sizeof($dirs) + sizeof($files) > $thumbs_pr_page) {
|
||||||
$page_navigation .= "$label_page ";
|
$page_navigation .= "$label_page ";
|
||||||
for ($i = 1; $i <= ceil((sizeof($files) + sizeof($dirs)) / $thumbs_pr_page); $i++) {
|
for ($i = 1; $i <= ceil((sizeof($files) + sizeof($dirs)) / $thumbs_pr_page); $i++) {
|
||||||
if ($_GET["page"] == $i)
|
if ($_GET["page"] == $i) {
|
||||||
$page_navigation .= "$i";
|
$page_navigation .= "$i";
|
||||||
else
|
} else {
|
||||||
$page_navigation .= "<a href='?dir=" . $requestedDir . "&page=" . ($i) . "'>" . $i . "</a>";
|
$page_navigation .= "<a href='?dir=" . $requestedDir . "&page=" . ($i) . "'>" . $i . "</a>";
|
||||||
if ($i != ceil((sizeof($files) + sizeof($dirs)) / $thumbs_pr_page))
|
}
|
||||||
|
|
||||||
|
if ($i != ceil((sizeof($files) + sizeof($dirs)) / $thumbs_pr_page)) {
|
||||||
$page_navigation .= " | ";
|
$page_navigation .= " | ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
//Insert link to view all images
|
//Insert link to view all images
|
||||||
if ($_GET["page"] == "all")
|
if ($_GET["page"] == "all") {
|
||||||
$page_navigation .= " | $label_all";
|
$page_navigation .= " | $label_all";
|
||||||
else
|
} else {
|
||||||
$page_navigation .= " | <a href='?dir=" . $requestedDir . "&page=all'>$label_all</a>";
|
$page_navigation .= " | <a href='?dir=" . $requestedDir . "&page=all'>$label_all</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------
|
//-----------------------
|
||||||
// BREADCRUMB NAVIGATION
|
// BREADCRUMB NAVIGATION
|
||||||
//-----------------------
|
//-----------------------
|
||||||
|
@ -414,9 +458,11 @@ if ($requestedDir != "" && $requestedDir != "photos") {
|
||||||
$breadcrumb_navigation .= "<a href='?dir=";
|
$breadcrumb_navigation .= "<a href='?dir=";
|
||||||
for ($x = 0; $x <= $i; $x++) {
|
for ($x = 0; $x <= $i; $x++) {
|
||||||
$breadcrumb_navigation .= $navitems[$x];
|
$breadcrumb_navigation .= $navitems[$x];
|
||||||
if ($x < $i)
|
if ($x < $i) {
|
||||||
$breadcrumb_navigation .= "/";
|
$breadcrumb_navigation .= "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
$breadcrumb_navigation .= "'>" . $navitems[$i] . "</a> $breadcrumb_separator ";
|
$breadcrumb_navigation .= "'>" . $navitems[$i] . "</a> $breadcrumb_separator ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,8 +503,10 @@ for ($i = $offset_start - sizeof($dirs); $i < $offset_end && $offset_current < $
|
||||||
}
|
}
|
||||||
|
|
||||||
//Include hidden links for all images AFTER current page so lightbox is able to browse images on different pages
|
//Include hidden links for all images AFTER current page so lightbox is able to browse images on different pages
|
||||||
if ($i < 0)
|
if ($i < 0) {
|
||||||
$i = 1;
|
$i = 1;
|
||||||
|
}
|
||||||
|
|
||||||
for ($y = $i; $y < sizeof($files); $y++) {
|
for ($y = $i; $y < sizeof($files); $y++) {
|
||||||
$page_navigation .= "<a href='" . $currentdir . "/" . $files[$y]["name"] . "' class='hidden' title='" . $img_captions[$files[$y]["name"]] . "'></a>";
|
$page_navigation .= "<a href='" . $currentdir . "/" . $files[$y]["name"] . "' class='hidden' title='" . $img_captions[$files[$y]["name"]] . "'></a>";
|
||||||
}
|
}
|
||||||
|
@ -479,10 +527,11 @@ if (file_exists($comment_filepath)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//PROCESS TEMPLATE FILE
|
//PROCESS TEMPLATE FILE
|
||||||
if (GALLERY_ROOT != "")
|
if (GALLERY_ROOT != "") {
|
||||||
$templatefile = GALLERY_ROOT . "templates/integrate.html";
|
$templatefile = GALLERY_ROOT . "templates/integrate.html";
|
||||||
else
|
} else {
|
||||||
$templatefile = "templates/" . $templatefile . ".html";
|
$templatefile = "templates/" . $templatefile . ".html";
|
||||||
|
}
|
||||||
|
|
||||||
if (!$fd = fopen($templatefile, "r")) {
|
if (!$fd = fopen($templatefile, "r")) {
|
||||||
echo "Template " . htmlspecialchars(stripslashes($templatefile)) . " not found!";
|
echo "Template " . htmlspecialchars(stripslashes($templatefile)) . " not found!";
|
||||||
|
|
|
@ -3,5 +3,5 @@ $path_to_minigalnano = "minigalnano/"; // <- Enter RELATIVE path to MiniGal
|
||||||
|
|
||||||
// DO NOT EDIT BELOW THIS LINE!
|
// DO NOT EDIT BELOW THIS LINE!
|
||||||
define("GALLERY_ROOT", $path_to_minigalnano);
|
define("GALLERY_ROOT", $path_to_minigalnano);
|
||||||
require(GALLERY_ROOT . "index.php");
|
require GALLERY_ROOT . "index.php";
|
||||||
?>
|
?>
|
18
rss.php
18
rss.php
|
@ -33,8 +33,7 @@ $gallery_link = $g_protocol . '://' . $g_host . $g_port . $g_path;
|
||||||
/*===================*/
|
/*===================*/
|
||||||
# Hardly inspired from here : codes-sources.commentcamarche.net/source/35937-creation-d-une-arborescenceI
|
# Hardly inspired from here : codes-sources.commentcamarche.net/source/35937-creation-d-une-arborescenceI
|
||||||
# Listing all files of a folder and sub folders.
|
# Listing all files of a folder and sub folders.
|
||||||
function listFiles(&$content, $Folder, $SkipFileExts, $SkipObjects)
|
function listFiles(&$content, $Folder, $SkipFileExts, $SkipObjects) {
|
||||||
{
|
|
||||||
$dir = opendir($Folder);
|
$dir = opendir($Folder);
|
||||||
// Loop on all contained on the folder
|
// Loop on all contained on the folder
|
||||||
while (false !== ($Current = readdir($dir))) {
|
while (false !== ($Current = readdir($dir))) {
|
||||||
|
@ -56,8 +55,7 @@ function listFiles(&$content, $Folder, $SkipFileExts, $SkipObjects)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Paul's Simple Diff Algorithm v 0.1 : http://paulbutler.org/archives/a-simple-diff-algorithm-in-php/
|
# Paul's Simple Diff Algorithm v 0.1 : http://paulbutler.org/archives/a-simple-diff-algorithm-in-php/
|
||||||
function diff($old, $new)
|
function diff($old, $new) {
|
||||||
{
|
|
||||||
$matrix = array();
|
$matrix = array();
|
||||||
$maxlen = 0;
|
$maxlen = 0;
|
||||||
foreach ($old as $oindex => $ovalue) {
|
foreach ($old as $oindex => $ovalue) {
|
||||||
|
@ -72,8 +70,10 @@ function diff($old, $new)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($maxlen == 0)
|
if ($maxlen == 0) {
|
||||||
return array(array('d' => $old, 'i' => $new));
|
return array(array('d' => $old, 'i' => $new));
|
||||||
|
}
|
||||||
|
|
||||||
return array_merge(
|
return array_merge(
|
||||||
diff(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)),
|
diff(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)),
|
||||||
array_slice($new, $nmax, $maxlen),
|
array_slice($new, $nmax, $maxlen),
|
||||||
|
@ -83,8 +83,8 @@ function diff($old, $new)
|
||||||
/*===================*/
|
/*===================*/
|
||||||
/* Variables */
|
/* Variables */
|
||||||
/*===================*/
|
/*===================*/
|
||||||
require("config-default.php");
|
require "config-default.php";
|
||||||
include("config.php");
|
include "config.php";
|
||||||
$folder = "photos";
|
$folder = "photos";
|
||||||
|
|
||||||
$content = array();
|
$content = array();
|
||||||
|
@ -153,8 +153,10 @@ echo "<title>$title</title>";
|
||||||
echo "<link>$gallery_link</link>";
|
echo "<link>$gallery_link</link>";
|
||||||
echo "<description>$description</description>\n";
|
echo "<description>$description</description>\n";
|
||||||
for ($i = 0; $i < $nb_items_rss && $i < count($content); $i++) {
|
for ($i = 0; $i < $nb_items_rss && $i < count($content); $i++) {
|
||||||
if (empty($content[$i]))
|
if (empty($content[$i])) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$link = $gallery_link . '/' . str_replace(' ', '%20', $content[$i]);
|
$link = $gallery_link . '/' . str_replace(' ', '%20', $content[$i]);
|
||||||
echo "<item>\n";
|
echo "<item>\n";
|
||||||
echo " <title>" . basename($link) . "</title>\n";
|
echo " <title>" . basename($link) . "</title>\n";
|
||||||
|
|
|
@ -3,9 +3,18 @@
|
||||||
$exif = "No";
|
$exif = "No";
|
||||||
$gd = "No";
|
$gd = "No";
|
||||||
$thumbs = "No";
|
$thumbs = "No";
|
||||||
if (function_exists('exif_read_data')) $exif = "Yes";
|
if (function_exists('exif_read_data')) {
|
||||||
if (extension_loaded('gd') && function_exists('gd_info')) $gd = "Yes";
|
$exif = "Yes";
|
||||||
if (is_dir('thumbs') && is_writable('thumbs')) $thumbs = "Yes";
|
}
|
||||||
|
|
||||||
|
if (extension_loaded('gd') && function_exists('gd_info')) {
|
||||||
|
$gd = "Yes";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_dir('thumbs') && is_writable('thumbs')) {
|
||||||
|
$thumbs = "Yes";
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
@ -69,7 +78,12 @@
|
||||||
<div class="left">
|
<div class="left">
|
||||||
PHP Version
|
PHP Version
|
||||||
</div>
|
</div>
|
||||||
<div class="<?php if(version_compare(phpversion(), "4.0", '>')) echo 'middle-yes'; else echo 'middle-no' ?>">
|
<div class="<?php if (version_compare(phpversion(), "4.0", '>')) {
|
||||||
|
echo 'middle-yes';
|
||||||
|
} else {
|
||||||
|
echo 'middle-no';
|
||||||
|
}
|
||||||
|
?>">
|
||||||
<?php echo phpversion();?>
|
<?php echo phpversion();?>
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
|
@ -80,7 +94,12 @@
|
||||||
<div class="left">
|
<div class="left">
|
||||||
GD library support
|
GD library support
|
||||||
</div>
|
</div>
|
||||||
<div class="<?php if($gd == "Yes") echo 'middle-yes'; else echo 'middle-no' ?>">
|
<div class="<?php if ($gd == "Yes") {
|
||||||
|
echo 'middle-yes';
|
||||||
|
} else {
|
||||||
|
echo 'middle-no';
|
||||||
|
}
|
||||||
|
?>">
|
||||||
<?php echo $gd;?>
|
<?php echo $gd;?>
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
|
@ -91,7 +110,12 @@
|
||||||
<div class="left">
|
<div class="left">
|
||||||
EXIF support
|
EXIF support
|
||||||
</div>
|
</div>
|
||||||
<div class="<?php if($exif == "Yes") echo 'middle-yes'; else echo 'middle-neutral' ?>">
|
<div class="<?php if ($exif == "Yes") {
|
||||||
|
echo 'middle-yes';
|
||||||
|
} else {
|
||||||
|
echo 'middle-neutral';
|
||||||
|
}
|
||||||
|
?>">
|
||||||
<?php echo $exif;?>
|
<?php echo $exif;?>
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
|
@ -102,7 +126,12 @@
|
||||||
<div class="left">
|
<div class="left">
|
||||||
Thumbnails caching
|
Thumbnails caching
|
||||||
</div>
|
</div>
|
||||||
<div class="<?php if($thumbs == "Yes") echo 'middle-yes'; else echo 'middle-neutral' ?>">
|
<div class="<?php if ($thumbs == "Yes") {
|
||||||
|
echo 'middle-yes';
|
||||||
|
} else {
|
||||||
|
echo 'middle-neutral';
|
||||||
|
}
|
||||||
|
?>">
|
||||||
<?php echo $thumbs;?>
|
<?php echo $thumbs;?>
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
|
@ -120,8 +149,6 @@
|
||||||
Memory is needed to create thumbnails. Bigger images uses more memory.
|
Memory is needed to create thumbnails. Bigger images uses more memory.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<footer role="contentinfo">
|
<footer role="contentinfo">
|
||||||
<a href="https://github.com/sebsauvage/MinigalNano" title="Powered by MiniGal Nano" target="_blank">
|
<a href="https://github.com/sebsauvage/MinigalNano" title="Powered by MiniGal Nano" target="_blank">
|
||||||
Made with miniGal by sebsauvage.
|
Made with miniGal by sebsauvage.
|
||||||
|
|
Loading…
Reference in a new issue