PSR2 php style
This commit is contained in:
parent
7466c634f0
commit
08cbcbdc5f
7 changed files with 666 additions and 574 deletions
|
@ -4,49 +4,49 @@ MINIGAL NANO, a simple PHP/HTML/CSS based image gallery script
|
|||
|
||||
This script and included files are subject to licensing from Creative Commons (http://creativecommons.org/licenses/by-sa/2.5/)
|
||||
You may use, edit and redistribute this script, as long as you pay tribute to the original author by NOT removing the linkback to www.minigal.dk ("Powered by MiniGal Nano x.x.x")
|
||||
* Website : https://github.com/sebsauvage/MinigalNano/
|
||||
* Support : https://github.com/sebsauvage/MinigalNano/issues and by mail (contact [@] tomcanac [.] com)
|
||||
* Website : https://github.com/sebsauvage/MinigalNano/
|
||||
* Support : https://github.com/sebsauvage/MinigalNano/issues and by mail (contact [@] tomcanac [.] com)
|
||||
|
||||
MiniGal Nano is based on an original work by Thomas Rybak (© 2010)
|
||||
Original support board : www.minigal.dk and www.minigal.dk/forum
|
||||
|
||||
Please enjoy this free script!
|
||||
*/
|
||||
*/
|
||||
|
||||
// EDIT SETTINGS BELOW TO CUSTOMIZE YOUR GALLERY
|
||||
$thumbs_pr_page = "39"; // Number of thumbnails on a single page
|
||||
$gallery_width = "80%"; // Gallery width. Eg: "500px" or "70%"
|
||||
$backgroundcolor = "white"; // This provides a quick way to change your gallerys background to suit your website. Use either main colors like "black", "white", "yellow" etc. Or HEX colors, eg. "#AAAAAA"
|
||||
$templatefile = "board"; // Template filename (must be placed in 'templates' folder)
|
||||
$title = "MiniGal Nano"; // Text to be displayed in browser titlebar
|
||||
$author = "John Doe";
|
||||
$folder_color = "black"; // Color of folder icons: blue / black / vista / purple / green / grey
|
||||
$sorting_folders = "name"; // Sort folders by: [name][date]
|
||||
$sorting_files = "name"; // Sort files by: [name][date][size]
|
||||
$sortdir_folders = SORT_ASC; // Sort direction of folders: SORT_ASC / SORT_DESC
|
||||
$sortdir_files = SORT_ASC; // Sort direction of files: SORT_ASC / SORT_DESC
|
||||
$lazyload = 1; // 0 is pagination, 1 is display all pictures on one page
|
||||
$SkipObjects = array('aFolder', 'aFile.ext'); //Those files and folders will not be displayed (affects the page and the RSS feed)
|
||||
$thumbs_pr_page = "39"; // Number of thumbnails on a single page
|
||||
$gallery_width = "80%"; // Gallery width. Eg: "500px" or "70%"
|
||||
$backgroundcolor = "white"; // This provides a quick way to change your gallerys background to suit your website. Use either main colors like "black", "white", "yellow" etc. Or HEX colors, eg. "#AAAAAA"
|
||||
$templatefile = "board"; // Template filename (must be placed in 'templates' folder)
|
||||
$title = "MiniGal Nano"; // Text to be displayed in browser titlebar
|
||||
$author = "John Doe";
|
||||
$folder_color = "black"; // Color of folder icons: blue / black / vista / purple / green / grey
|
||||
$sorting_folders = "name"; // Sort folders by: [name][date]
|
||||
$sorting_files = "name"; // Sort files by: [name][date][size]
|
||||
$sortdir_folders = SORT_ASC; // Sort direction of folders: SORT_ASC / SORT_DESC
|
||||
$sortdir_files = SORT_ASC; // Sort direction of files: SORT_ASC / SORT_DESC
|
||||
$lazyload = 1; // 0 is pagination, 1 is display all pictures on one page
|
||||
$SkipObjects = array('aFolder', 'aFile.ext'); //Those files and folders will not be displayed (affects the page and the RSS feed)
|
||||
|
||||
//LANGUAGE STRINGS
|
||||
$label_home = "Home"; // Name of home link in breadcrumb navigation
|
||||
$label_new = "New"; // Text to display for new images. Use with $display_new variable
|
||||
$label_page = "Page"; // Text used for page navigation
|
||||
$label_all = "All"; // Text used for link to display all images in one page
|
||||
$label_noimages = "No images... yet !"; // Empty folder text
|
||||
$label_noimages_advice = "Use your FTP to upload some picture !";
|
||||
$label_loading = "Loading..."; // Thumbnail loading text
|
||||
$breadcrumb_separator = ">"; // Breadcrumb parts separator
|
||||
$label_home = "Home"; // Name of home link in breadcrumb navigation
|
||||
$label_new = "New"; // Text to display for new images. Use with $display_new variable
|
||||
$label_page = "Page"; // Text used for page navigation
|
||||
$label_all = "All"; // Text used for link to display all images in one page
|
||||
$label_noimages = "No images... yet !"; // Empty folder text
|
||||
$label_noimages_advice = "Use your FTP to upload some picture !";
|
||||
$label_loading = "Loading..."; // Thumbnail loading text
|
||||
$breadcrumb_separator = ">"; // Breadcrumb parts separator
|
||||
|
||||
//RSS SETTINGS
|
||||
$description = "MiniGal Nano";
|
||||
$nb_items_rss = 25; // Number of elements to display in the feed. If you add a lot of pictures at the time, consider increasing this number
|
||||
$rss_refresh_interval = 60;// Time, in seconds, between two RSS refresh. for example, 3600 = 1update max per hour, 86400 = 1/day.
|
||||
$SkipExts = array('html', 'txt', 'php', "gitignore"); //Files with one of this extension will not be displayed on the RSS feed
|
||||
$description = "MiniGal Nano";
|
||||
$nb_items_rss = 25; // Number of elements to display in the feed. If you add a lot of pictures at the time, consider increasing this number
|
||||
$rss_refresh_interval = 60; // Time, in seconds, between two RSS refresh. for example, 3600 = 1update max per hour, 86400 = 1/day.
|
||||
$SkipExts = array('html', 'txt', 'php', "gitignore"); //Files with one of this extension will not be displayed on the RSS feed
|
||||
|
||||
//ADVANCED SETTINGS
|
||||
$thumb_size = 320; //Thumbnail height/width (square thumbs). Changing this will most likely require manual altering of the template file to make it look properly!
|
||||
$label_max_length = 40; //Maximum chars of a folder name that will be displayed on the folder thumbnail
|
||||
$display_exif = 0; //Take care, even if not diplayed EXIF are still readable for visitors. May be a good idea to erase EXIF data...
|
||||
$display_filename = 0; //Show file names below the pictures
|
||||
$thumb_size = 320; //Thumbnail height/width (square thumbs). Changing this will most likely require manual altering of the template file to make it look properly!
|
||||
$label_max_length = 40; //Maximum chars of a folder name that will be displayed on the folder thumbnail
|
||||
$display_exif = 0; //Take care, even if not diplayed EXIF are still readable for visitors. May be a good idea to erase EXIF data...
|
||||
$display_filename = 0; //Show file names below the pictures
|
||||
?>
|
||||
|
|
|
@ -4,8 +4,8 @@ MINIGAL NANO, a simple PHP/HTML/CSS based image gallery script
|
|||
|
||||
This script and included files are subject to licensing from Creative Commons (http://creativecommons.org/licenses/by-sa/2.5/)
|
||||
You may use, edit and redistribute this script, as long as you pay tribute to the original author by NOT removing the linkback to www.minigal.dk ("Powered by MiniGal Nano x.x.x")
|
||||
* Website : https://github.com/sebsauvage/MinigalNano/
|
||||
* Support : https://github.com/sebsauvage/MinigalNano/issues and by mail (contact [@] tomcanac [.] com)
|
||||
* Website : https://github.com/sebsauvage/MinigalNano/
|
||||
* Support : https://github.com/sebsauvage/MinigalNano/issues and by mail (contact [@] tomcanac [.] com)
|
||||
|
||||
MiniGal Nano is based on an original work by Thomas Rybak (© 2010)
|
||||
Original support board : www.minigal.dk and www.minigal.dk/forum
|
||||
|
@ -15,7 +15,7 @@ Please enjoy this free script!
|
|||
Upgraded to https://github.com/sebsauvage/MinigalNano
|
||||
by Sébastien SAUVAGE.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
// INSERT HERE YOUR CUSTOMIZED SETTINGS
|
||||
// for the list of possible options, peruse config-default.php
|
||||
|
|
152
createthumb.php
152
createthumb.php
|
@ -15,23 +15,37 @@ Community: www.minigal.dk/forum
|
|||
Please enjoy this free script!
|
||||
|
||||
Version 0.3.5 modified by Sebastien SAUVAGE (sebsauvage.net):
|
||||
- Added thumbnail cache (reduces server CPU load, server bandwith and speeds up client page display).
|
||||
- Thumbnails are now always in JPEG even if the source image is PNG or GIF.
|
||||
- Added thumbnail cache (reduces server CPU load, server bandwith and speeds up client page display).
|
||||
- Thumbnails are now always in JPEG even if the source image is PNG or GIF.
|
||||
|
||||
USAGE EXAMPLE:
|
||||
File: createthumb.php
|
||||
Example: <img src="createthumb.php?filename=photo.jpg&size=100">
|
||||
*/
|
||||
*/
|
||||
|
||||
error_reporting(0);
|
||||
|
||||
$get_filename = $_GET['filename'];
|
||||
$get_size = @$_GET['size'];
|
||||
if (empty($get_size)) $get_size = 120;
|
||||
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";
|
||||
if (empty($get_size)) {
|
||||
$get_size = 120;
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -41,9 +55,8 @@ function flipVertical(&$img) {
|
|||
$size_x = imagesx($img);
|
||||
$size_y = imagesy($img);
|
||||
$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);
|
||||
if ($x)
|
||||
{
|
||||
$x = imagecopyresampled($temp, $img, 0, 0, 0, ($size_y - 1), $size_x, $size_y, $size_x, 0 - $size_y);
|
||||
if ($x) {
|
||||
$img = $temp;
|
||||
} else {
|
||||
die("Unable to flip image");
|
||||
|
@ -58,9 +71,8 @@ function flipHorizontal(&$img) {
|
|||
$size_x = imagesx($img);
|
||||
$size_y = imagesy($img);
|
||||
$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);
|
||||
if ($x)
|
||||
{
|
||||
$x = imagecopyresampled($temp, $img, 0, 0, ($size_x - 1), 0, $size_x, $size_y, 0 - $size_x, $size_y);
|
||||
if ($x) {
|
||||
$img = $temp;
|
||||
} else {
|
||||
die("Unable to flip image");
|
||||
|
@ -75,14 +87,13 @@ function sanitize($name) {
|
|||
}
|
||||
|
||||
// Make sure the "thumbs" directory exists.
|
||||
if (!is_dir('thumbs') && is_writable('.'))
|
||||
{
|
||||
mkdir('thumbs',0700);
|
||||
if (!is_dir('thumbs') && is_writable('.')) {
|
||||
mkdir('thumbs', 0700);
|
||||
}
|
||||
|
||||
// Thumbnail file name and path.
|
||||
// (We always put thumbnails in jpg for simplification)
|
||||
$thumbname = 'thumbs/'.sanitize($get_filename).'.jpg';
|
||||
$thumbname = 'thumbs/' . sanitize($get_filename) . '.jpg';
|
||||
|
||||
if (file_exists($thumbname)) // If thumbnail exists, serve it.
|
||||
{
|
||||
|
@ -90,7 +101,7 @@ if (file_exists($thumbname)) // If thumbnail exists, serve it.
|
|||
$cacheContent = fread($fd, filesize($thumbname));
|
||||
fclose($fd);
|
||||
header('Content-type: image/jpeg');
|
||||
echo($cacheContent);
|
||||
echo ($cacheContent);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -121,14 +132,13 @@ $yoord = 0;
|
|||
$imgsize = getimagesize($get_filename);
|
||||
$width = $imgsize[0];
|
||||
$height = $imgsize[1];
|
||||
if ($width > $height) // If the width is greater than the height it’s a horizontal picture
|
||||
{
|
||||
$xoord = ceil(($width-$height)/2);
|
||||
$width = $height; // Then we read a square frame that equals the width
|
||||
}
|
||||
else
|
||||
{
|
||||
$yoord = ceil(($height-$width)/2);
|
||||
// If the width is greater than the height it’s a horizontal picture
|
||||
if ($width > $height) {
|
||||
$xoord = ceil(($width - $height) / 2);
|
||||
// Then we read a square frame that equals the width
|
||||
$width = $height;
|
||||
} else {
|
||||
$yoord = ceil(($height - $width) / 2);
|
||||
$height = $width;
|
||||
}
|
||||
|
||||
|
@ -140,33 +150,33 @@ $degrees = 0;
|
|||
$flip = '';
|
||||
if (preg_match("/.jpg$|.jpeg$/i", $_GET['filename'])) {
|
||||
if (function_exists('exif_read_data') && function_exists('imagerotate')) {
|
||||
$exif = exif_read_data($_GET['filename'], 0, true);
|
||||
$ort = $exif['IFD0']['Orientation'];
|
||||
switch ($ort) {
|
||||
case 3: // 180 rotate right
|
||||
$degrees = 180;
|
||||
break;
|
||||
case 6: // 90 rotate right
|
||||
$degrees = 270;
|
||||
break;
|
||||
case 8: // 90 rotate left
|
||||
$degrees = 90;
|
||||
break;
|
||||
case 2: // flip vertical
|
||||
$flip = 'vertical';
|
||||
break;
|
||||
case 7: // flipped
|
||||
$degrees = 90;
|
||||
$flip = 'vertical';
|
||||
break;
|
||||
case 5: // flipped
|
||||
$degrees = 270;
|
||||
$flip = 'vertical';
|
||||
break;
|
||||
case 4: // flipped
|
||||
$degrees = 180;
|
||||
$flip = 'vertical';
|
||||
break;
|
||||
$exif = exif_read_data($_GET['filename'], 0, true);
|
||||
$ort = $exif['IFD0']['Orientation'];
|
||||
switch ($ort) {
|
||||
case 3: // 180 rotate right
|
||||
$degrees = 180;
|
||||
break;
|
||||
case 6: // 90 rotate right
|
||||
$degrees = 270;
|
||||
break;
|
||||
case 8: // 90 rotate left
|
||||
$degrees = 90;
|
||||
break;
|
||||
case 2: // flip vertical
|
||||
$flip = 'vertical';
|
||||
break;
|
||||
case 7: // flipped
|
||||
$degrees = 90;
|
||||
$flip = 'vertical';
|
||||
break;
|
||||
case 5: // flipped
|
||||
$degrees = 270;
|
||||
$flip = 'vertical';
|
||||
break;
|
||||
case 4: // flipped
|
||||
$degrees = 180;
|
||||
$flip = 'vertical';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,27 +184,33 @@ if (preg_match("/.jpg$|.jpeg$/i", $_GET['filename'])) {
|
|||
$target = imagecreatetruecolor($get_size, $get_size);
|
||||
|
||||
// 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);
|
||||
imagefill($target, 0, 0, $backgroundColor);
|
||||
}
|
||||
|
||||
if ($get_filename_type == "JPG") $source = imagecreatefromjpeg($get_filename);
|
||||
if ($get_filename_type == "GIF") $source = imagecreatefromgif($get_filename);
|
||||
if ($get_filename_type == "PNG") $source = imagecreatefrompng($get_filename);
|
||||
if ($get_filename_type == "JPG") {
|
||||
$source = imagecreatefromjpeg($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);
|
||||
imagedestroy($source);
|
||||
|
||||
//proper rotation by jan niggemann
|
||||
if ($degrees != 0)
|
||||
{
|
||||
if ($degrees != 0) {
|
||||
$target = imagerotate($target, $degrees, 0);
|
||||
}
|
||||
|
||||
//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);
|
||||
flipVertical($target);
|
||||
flipHorizontal($target);
|
||||
|
@ -208,12 +224,10 @@ imagedestroy($target);
|
|||
$cachedImage = ob_get_contents(); // Get the buffer content.
|
||||
ob_end_flush(); // End buffering
|
||||
|
||||
if (is_writable(dirname($thumbname)))
|
||||
{
|
||||
if (is_writable(dirname($thumbname))) {
|
||||
$fd = fopen($thumbname, "w"); // Save buffer to disk
|
||||
if ($fd)
|
||||
{
|
||||
fwrite($fd,$cachedImage);
|
||||
if ($fd) {
|
||||
fwrite($fd, $cachedImage);
|
||||
fclose($fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
725
index.php
725
index.php
|
@ -19,7 +19,7 @@ Please enjoy this free script!
|
|||
Upgraded to https://github.com/sebsauvage/MinigalNano
|
||||
by Sébastien SAUVAGE.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
error_reporting(-1);
|
||||
|
||||
|
@ -29,8 +29,8 @@ header('Content-Type: text/html; charset=UTF-8'); // We use UTF-8 for proper int
|
|||
$version = "0.3.7";
|
||||
ini_set("memory_limit", "256M");
|
||||
|
||||
require("config-default.php");
|
||||
include("config.php");
|
||||
require "config-default.php";
|
||||
include "config.php";
|
||||
|
||||
//-----------------------
|
||||
// DEFINE VARIABLES
|
||||
|
@ -48,122 +48,121 @@ $comment = "";
|
|||
// PHP ENVIRONMENT CHECK
|
||||
//-----------------------
|
||||
if (!function_exists('exif_read_data') && $display_exif == 1) {
|
||||
$display_exif = 0;
|
||||
$messages = "Error: PHP EXIF is not available. Set $display_exif = 0; in config.php to remove this message";
|
||||
$display_exif = 0;
|
||||
$messages = "Error: PHP EXIF is not available. Set $display_exif = 0; in config.php to remove this message";
|
||||
}
|
||||
|
||||
//-----------------------
|
||||
// FUNCTIONS
|
||||
//-----------------------
|
||||
function padstring($name, $length)
|
||||
{
|
||||
global $label_max_length;
|
||||
if (!isset($length)) {
|
||||
$length = $label_max_length;
|
||||
}
|
||||
if (strlen($name) > $length) {
|
||||
return substr($name, 0, $length) . "...";
|
||||
}
|
||||
return $name;
|
||||
function padstring($name, $length) {
|
||||
global $label_max_length;
|
||||
if (!isset($length)) {
|
||||
$length = $label_max_length;
|
||||
}
|
||||
if (strlen($name) > $length) {
|
||||
return substr($name, 0, $length) . "...";
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
function getfirstImage($dirname)
|
||||
{
|
||||
$imageName = false;
|
||||
$extensions = array("jpg", "png", "jpeg", "gif");
|
||||
if ($handle = opendir($dirname)) {
|
||||
while(false !== ($file = readdir($handle))) {
|
||||
if ($file[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
$pathinfo = pathinfo($file);
|
||||
if (empty($pathinfo['extension'])) {
|
||||
continue;
|
||||
}
|
||||
$ext = strtolower($pathinfo['extension']);
|
||||
if (in_array($ext, $extensions)) {
|
||||
$imageName = $file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
return $imageName;
|
||||
function getfirstImage($dirname) {
|
||||
$imageName = false;
|
||||
$extensions = array("jpg", "png", "jpeg", "gif");
|
||||
if ($handle = opendir($dirname)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
$pathinfo = pathinfo($file);
|
||||
if (empty($pathinfo['extension'])) {
|
||||
continue;
|
||||
}
|
||||
$ext = strtolower($pathinfo['extension']);
|
||||
if (in_array($ext, $extensions)) {
|
||||
$imageName = $file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
return $imageName;
|
||||
}
|
||||
|
||||
function parse_fraction($v, $round=0)
|
||||
{
|
||||
list($x, $y) = array_map('intval', explode('/', $v));
|
||||
if (empty($x) || empty($y)) {
|
||||
return $v;
|
||||
}
|
||||
if ($x % $y == 0) {
|
||||
return $x/$y;
|
||||
}
|
||||
if ($y % $x == 0) {
|
||||
return "1/" . $y/$x;
|
||||
}
|
||||
return round($x/$y, $round);
|
||||
function parse_fraction($v, $round = 0) {
|
||||
list($x, $y) = array_map('intval', explode('/', $v));
|
||||
if (empty($x) || empty($y)) {
|
||||
return $v;
|
||||
}
|
||||
if ($x % $y == 0) {
|
||||
return $x / $y;
|
||||
}
|
||||
if ($y % $x == 0) {
|
||||
return "1/" . $y / $x;
|
||||
}
|
||||
return round($x / $y, $round);
|
||||
}
|
||||
|
||||
function readEXIF($file)
|
||||
{
|
||||
$exif_arr = array();
|
||||
$exif_data = exif_read_data($file);
|
||||
function readEXIF($file) {
|
||||
$exif_arr = array();
|
||||
$exif_data = exif_read_data($file);
|
||||
|
||||
$exif_val = @$exif_data['Model'];
|
||||
if (!empty($exif_val)) {
|
||||
$exif_arr[] = $exif_val;
|
||||
}
|
||||
$exif_val = @$exif_data['Model'];
|
||||
if (!empty($exif_val)) {
|
||||
$exif_arr[] = $exif_val;
|
||||
}
|
||||
|
||||
$exif_val = @$exif_data['FocalLength'];
|
||||
if (!empty($exif_val)) {
|
||||
$exif_arr[] = parse_fraction($exif_val) . "mm";
|
||||
}
|
||||
$exif_val = @$exif_data['FocalLength'];
|
||||
if (!empty($exif_val)) {
|
||||
$exif_arr[] = parse_fraction($exif_val) . "mm";
|
||||
}
|
||||
|
||||
$exif_val = @$exif_data['ExposureTime'];
|
||||
if (!empty($exif_val)) {
|
||||
$exif_arr[] = parse_fraction($exif_val, 2) . "s";
|
||||
}
|
||||
$exif_val = @$exif_data['ExposureTime'];
|
||||
if (!empty($exif_val)) {
|
||||
$exif_arr[] = parse_fraction($exif_val, 2) . "s";
|
||||
}
|
||||
|
||||
$exif_val = @$exif_data['FNumber'];
|
||||
if (!empty($exif_val)) {
|
||||
$exif_arr[] = "f" . parse_fraction($exif_val);
|
||||
}
|
||||
$exif_val = @$exif_data['FNumber'];
|
||||
if (!empty($exif_val)) {
|
||||
$exif_arr[] = "f" . parse_fraction($exif_val);
|
||||
}
|
||||
|
||||
$exif_val = @$exif_data['ISOSpeedRatings'];
|
||||
if (!empty($exif_val)) {
|
||||
$exif_arr[] = "ISO " . $exif_val;
|
||||
}
|
||||
$exif_val = @$exif_data['ISOSpeedRatings'];
|
||||
if (!empty($exif_val)) {
|
||||
$exif_arr[] = "ISO " . $exif_val;
|
||||
}
|
||||
|
||||
if (count($exif_arr) > 0) {
|
||||
return "::" . implode(" | ", $exif_arr);
|
||||
}
|
||||
if (count($exif_arr) > 0) {
|
||||
return "::" . implode(" | ", $exif_arr);
|
||||
}
|
||||
}
|
||||
|
||||
function checkpermissions($file)
|
||||
{
|
||||
global $messages;
|
||||
function checkpermissions($file) {
|
||||
global $messages;
|
||||
|
||||
if (!is_readable($file)) {
|
||||
$messages = "At least one file or folder has wrong permissions. "
|
||||
. "Learn how to <a href='http://minigal.dk/faq-reader/items/"
|
||||
. "how-do-i-change-file-permissions-chmod.html' target='_blank'>"
|
||||
. "set file permissions</a>";
|
||||
}
|
||||
if (!is_readable($file)) {
|
||||
$messages = "At least one file or folder has wrong permissions. "
|
||||
. "Learn how to <a href='http://minigal.dk/faq-reader/items/"
|
||||
. "how-do-i-change-file-permissions-chmod.html' target='_blank'>"
|
||||
. "set file permissions</a>";
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined("GALLERY_ROOT")) {
|
||||
define("GALLERY_ROOT", "");
|
||||
}
|
||||
|
||||
if (!defined("GALLERY_ROOT"))
|
||||
define("GALLERY_ROOT", "");
|
||||
$requestedDir = '';
|
||||
if (!empty($_GET['dir']))
|
||||
$requestedDir = $_GET['dir'];
|
||||
if (!empty($_GET['dir'])) {
|
||||
$requestedDir = $_GET['dir'];
|
||||
}
|
||||
|
||||
$thumbdir = rtrim('photos/' . $requestedDir, '/');
|
||||
|
||||
//$thumbdir = str_replace('/..', '', $thumbdir); // Prevent directory traversal attacks.
|
||||
if (strstr($thumbdir, '..') !== false) {
|
||||
$requestedDir = '';
|
||||
$thumbdir = rtrim('photos/', '/');
|
||||
$requestedDir = '';
|
||||
$thumbdir = rtrim('photos/', '/');
|
||||
}
|
||||
|
||||
$currentdir = GALLERY_ROOT . $thumbdir;
|
||||
|
@ -175,333 +174,383 @@ $files = array();
|
|||
$dirs = array();
|
||||
$img_captions = array();
|
||||
if (is_dir($currentdir) && $handle = opendir($currentdir)) {
|
||||
// 1. LOAD CAPTIONS
|
||||
$caption_filename = "$currentdir/captions.txt";
|
||||
if (is_readable($caption_filename)) {
|
||||
$caption_handle = fopen($caption_filename, "rb");
|
||||
while (!feof($caption_handle)) {
|
||||
$caption_line = fgetss($caption_handle);
|
||||
if (empty($caption_line)) {
|
||||
continue;
|
||||
}
|
||||
list($img_file, $img_text) = explode('|', $caption_line);
|
||||
$img_captions[$img_file] = trim($img_text);
|
||||
}
|
||||
fclose($caption_handle);
|
||||
}
|
||||
// 1. LOAD CAPTIONS
|
||||
$caption_filename = "$currentdir/captions.txt";
|
||||
if (is_readable($caption_filename)) {
|
||||
$caption_handle = fopen($caption_filename, "rb");
|
||||
while (!feof($caption_handle)) {
|
||||
$caption_line = fgetss($caption_handle);
|
||||
if (empty($caption_line)) {
|
||||
continue;
|
||||
}
|
||||
list($img_file, $img_text) = explode('|', $caption_line);
|
||||
$img_captions[$img_file] = trim($img_text);
|
||||
}
|
||||
fclose($caption_handle);
|
||||
}
|
||||
|
||||
while (false !== ($file = readdir($handle)) && !in_array($file, $SkipObjects)) {
|
||||
// 2. LOAD FOLDERS
|
||||
if (is_dir($currentdir . "/" . $file)) {
|
||||
if ($file != "." && $file != "..") {
|
||||
checkpermissions($currentdir . "/" . $file); // Check for correct file permission
|
||||
// Set thumbnail to folder.jpg if found:
|
||||
if (file_exists($currentdir. '/' . $file . '/folder.jpg')) {
|
||||
$linkParams = http_build_query(
|
||||
array('dir' => ltrim("$requestedDir/$file", '/')),
|
||||
'',
|
||||
'&'
|
||||
);
|
||||
$linkUrl = "?$linkParams";
|
||||
while (false !== ($file = readdir($handle)) && !in_array($file, $SkipObjects)) {
|
||||
// 2. LOAD FOLDERS
|
||||
if (is_dir($currentdir . "/" . $file)) {
|
||||
if ($file != "." && $file != "..") {
|
||||
checkpermissions($currentdir . "/" . $file); // Check for correct file permission
|
||||
// Set thumbnail to folder.jpg if found:
|
||||
if (file_exists($currentdir . '/' . $file . '/folder.jpg')) {
|
||||
$linkParams = http_build_query(
|
||||
array('dir' => ltrim("$requestedDir/$file", '/')),
|
||||
'',
|
||||
'&'
|
||||
);
|
||||
$linkUrl = "?$linkParams";
|
||||
|
||||
$imgParams = http_build_query(
|
||||
array(
|
||||
'filename' => "$currentdir/$file/folder.jpg",
|
||||
'size' => $thumb_size
|
||||
),
|
||||
'',
|
||||
'&'
|
||||
);
|
||||
$imgUrl = GALLERY_ROOT . "createthumb.php?$imgParams";
|
||||
$imgParams = http_build_query(
|
||||
array(
|
||||
'filename' => "$currentdir/$file/folder.jpg",
|
||||
'size' => $thumb_size,
|
||||
),
|
||||
'',
|
||||
'&'
|
||||
);
|
||||
$imgUrl = GALLERY_ROOT . "createthumb.php?$imgParams";
|
||||
|
||||
$dirs[] = array(
|
||||
"name" => $file,
|
||||
"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>"
|
||||
);
|
||||
} else {
|
||||
// Set thumbnail to first image found (if any):
|
||||
unset($firstimage);
|
||||
$firstimage = getfirstImage("$currentdir/" . $file);
|
||||
$dirs[] = array(
|
||||
"name" => $file,
|
||||
"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>",
|
||||
);
|
||||
} else {
|
||||
// Set thumbnail to first image found (if any):
|
||||
unset($firstimage);
|
||||
$firstimage = getfirstImage("$currentdir/" . $file);
|
||||
|
||||
if ($firstimage != "") {
|
||||
$linkParams = http_build_query(
|
||||
array('dir' => ltrim("$requestedDir/$file", '/')),
|
||||
'',
|
||||
'&'
|
||||
);
|
||||
$linkUrl = "?$linkParams";
|
||||
if ($firstimage != "") {
|
||||
$linkParams = http_build_query(
|
||||
array('dir' => ltrim("$requestedDir/$file", '/')),
|
||||
'',
|
||||
'&'
|
||||
);
|
||||
$linkUrl = "?$linkParams";
|
||||
|
||||
$imgParams = http_build_query(
|
||||
array(
|
||||
'filename' => "$thumbdir/$file/$firstimage",
|
||||
'size' => $thumb_size
|
||||
),
|
||||
'',
|
||||
'&'
|
||||
);
|
||||
$imgUrl = GALLERY_ROOT . "createthumb.php?$imgParams";
|
||||
$imgParams = http_build_query(
|
||||
array(
|
||||
'filename' => "$thumbdir/$file/$firstimage",
|
||||
'size' => $thumb_size,
|
||||
),
|
||||
'',
|
||||
'&'
|
||||
);
|
||||
$imgUrl = GALLERY_ROOT . "createthumb.php?$imgParams";
|
||||
|
||||
$dirs[] = array(
|
||||
"name" => $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>"
|
||||
);
|
||||
} else {
|
||||
// If no folder.jpg or image is found, then display default icon:
|
||||
$linkParams = http_build_query(
|
||||
array('dir' => ltrim("$requestedDir/$file", '/')),
|
||||
'',
|
||||
'&'
|
||||
);
|
||||
$linkUrl = "?$linkParams";
|
||||
$imgUrl = GALLERY_ROOT . 'images/folder_' . strtolower($folder_color) . '.png';
|
||||
$dirs[] = array(
|
||||
"name" => $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>",
|
||||
);
|
||||
} else {
|
||||
// If no folder.jpg or image is found, then display default icon:
|
||||
$linkParams = http_build_query(
|
||||
array('dir' => ltrim("$requestedDir/$file", '/')),
|
||||
'',
|
||||
'&'
|
||||
);
|
||||
$linkUrl = "?$linkParams";
|
||||
$imgUrl = GALLERY_ROOT . 'images/folder_' . strtolower($folder_color) . '.png';
|
||||
|
||||
$dirs[] = array(
|
||||
"name" => $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>"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$dirs[] = array(
|
||||
"name" => $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>",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. LOAD FILES
|
||||
if ($file != "." && $file != ".." && $file != "folder.jpg") {
|
||||
if ($display_filename)
|
||||
$filename_caption = "<em>" . padstring($file, $label_max_length) . "</em>";
|
||||
else
|
||||
$filename_caption = "";
|
||||
// JPG, GIF and PNG
|
||||
if (preg_match("/.jpg$|.gif$|.png$/i", $file)) {
|
||||
//Read EXIF
|
||||
if (!array_key_exists($file, $img_captions)) {
|
||||
if ($display_exif == 1) {
|
||||
$exifReaden = readEXIF($currentdir . "/" . $file);
|
||||
//Add to the caption all the EXIF information
|
||||
$img_captions[$file] = $file.$exifReaden;
|
||||
} else {
|
||||
//If no EXIF, just use the filename as caption
|
||||
$img_captions[$file] = $file;
|
||||
}
|
||||
}
|
||||
// Read the optionnal image title and caption in html file (image.jpg --> image.jpg.html)
|
||||
// Format: title::caption
|
||||
// Example: My cat::My cat like to <i>roll</i> on the floor.
|
||||
// If file is not provided, image filename will be used instead.
|
||||
checkpermissions($currentdir . "/" . $file);
|
||||
// 3. LOAD FILES
|
||||
if ($file != "." && $file != ".." && $file != "folder.jpg") {
|
||||
if ($display_filename) {
|
||||
$filename_caption = "<em>" . padstring($file, $label_max_length) . "</em>";
|
||||
} else {
|
||||
$filename_caption = "";
|
||||
}
|
||||
|
||||
if (is_file($currentdir.'/'.$file.'.html'))
|
||||
$img_captions[$file] = $file.'::'.htmlspecialchars(file_get_contents($currentdir.'/'.$file.'.html'), ENT_QUOTES);
|
||||
$linkUrl = str_replace('%2F', '/', rawurlencode("$currentdir/$file"));
|
||||
$imgParams = http_build_query(
|
||||
array('filename' => "$thumbdir/$file", 'size' => $thumb_size),
|
||||
'',
|
||||
'&');
|
||||
$imgUrl = GALLERY_ROOT . "createthumb.php?$imgParams";
|
||||
if ($lazyload)
|
||||
$imgopts = "class=\"b-lazy\" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src=\"$imgUrl\"";
|
||||
else
|
||||
$imgopts = "src=\"{$imgUrl}\"";
|
||||
$files[] = array(
|
||||
"name" => $file,
|
||||
"date" => filemtime($currentdir . "/" . $file),
|
||||
"size" => filesize($currentdir . "/" . $file),
|
||||
"html" => "<li><a href=\"{$linkUrl}\" rel='lightbox[billeder]' title=\"".htmlentities($img_captions[$file])."\"><img $imgopts alt='$label_loading' /></a>" . $filename_caption . "</li>");
|
||||
}
|
||||
// Other filetypes
|
||||
$extension = "";
|
||||
if (preg_match("/\.pdf$/i", $file)) $extension = "PDF"; // PDF
|
||||
if (preg_match("/\.zip$/i", $file)) $extension = "ZIP"; // ZIP archive
|
||||
if (preg_match("/\.rar$|\.r[0-9]{2,}/i", $file)) $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
|
||||
// JPG, GIF and PNG
|
||||
if (preg_match("/.jpg$|.gif$|.png$/i", $file)) {
|
||||
//Read EXIF
|
||||
if (!array_key_exists($file, $img_captions)) {
|
||||
if ($display_exif == 1) {
|
||||
$exifReaden = readEXIF($currentdir . "/" . $file);
|
||||
//Add to the caption all the EXIF information
|
||||
$img_captions[$file] = $file . $exifReaden;
|
||||
} else {
|
||||
//If no EXIF, just use the filename as caption
|
||||
$img_captions[$file] = $file;
|
||||
}
|
||||
}
|
||||
// Read the optionnal image title and caption in html file (image.jpg --> image.jpg.html)
|
||||
// Format: title::caption
|
||||
// Example: My cat::My cat like to <i>roll</i> on the floor.
|
||||
// If file is not provided, image filename will be used instead.
|
||||
checkpermissions($currentdir . "/" . $file);
|
||||
|
||||
if ($extension != "") {
|
||||
$files[] = array(
|
||||
"name" => $file,
|
||||
"date" => filemtime($currentdir . "/" . $file),
|
||||
"size" => filesize($currentdir . "/" . $file),
|
||||
"html" => "<li><a href='$currentdir/$file' title='$file'><em-pdf>" . padstring($file, 20) . "</em-pdf><span></span><img src='" . GALLERY_ROOT . "images/filetype_" . $extension . ".png' width='$thumb_size' height='$thumb_size' alt='$file' /></a>$filename_caption</li>");
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
if (is_file($currentdir . '/' . $file . '.html')) {
|
||||
$img_captions[$file] = $file . '::' . htmlspecialchars(file_get_contents($currentdir . '/' . $file . '.html'), ENT_QUOTES);
|
||||
}
|
||||
|
||||
$linkUrl = str_replace('%2F', '/', rawurlencode("$currentdir/$file"));
|
||||
$imgParams = http_build_query(
|
||||
array('filename' => "$thumbdir/$file", 'size' => $thumb_size),
|
||||
'',
|
||||
'&');
|
||||
$imgUrl = GALLERY_ROOT . "createthumb.php?$imgParams";
|
||||
if ($lazyload) {
|
||||
$imgopts = "class=\"b-lazy\" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src=\"$imgUrl\"";
|
||||
} else {
|
||||
$imgopts = "src=\"{$imgUrl}\"";
|
||||
}
|
||||
|
||||
$files[] = array(
|
||||
"name" => $file,
|
||||
"date" => filemtime($currentdir . "/" . $file),
|
||||
"size" => filesize($currentdir . "/" . $file),
|
||||
"html" => "<li><a href=\"{$linkUrl}\" rel='lightbox[billeder]' title=\"" . htmlentities($img_captions[$file]) . "\"><img $imgopts alt='$label_loading' /></a>" . $filename_caption . "</li>");
|
||||
}
|
||||
// Other filetypes
|
||||
$extension = "";
|
||||
if (preg_match("/\.pdf$/i", $file)) {
|
||||
$extension = "PDF";
|
||||
}
|
||||
// PDF
|
||||
if (preg_match("/\.zip$/i", $file)) {
|
||||
$extension = "ZIP";
|
||||
}
|
||||
// ZIP archive
|
||||
if (preg_match("/\.rar$|\.r[0-9]{2,}/i", $file)) {
|
||||
$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 != "") {
|
||||
$files[] = array(
|
||||
"name" => $file,
|
||||
"date" => filemtime($currentdir . "/" . $file),
|
||||
"size" => filesize($currentdir . "/" . $file),
|
||||
"html" => "<li><a href='$currentdir/$file' title='$file'><em-pdf>" . padstring($file, 20) . "</em-pdf><span></span><img src='" . GALLERY_ROOT . "images/filetype_" . $extension . ".png' width='$thumb_size' height='$thumb_size' alt='$file' /></a>$filename_caption</li>");
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
} else {
|
||||
die("ERROR: Could not open ".htmlspecialchars(stripslashes($currentdir))." for reading!");
|
||||
die("ERROR: Could not open " . htmlspecialchars(stripslashes($currentdir)) . " for reading!");
|
||||
}
|
||||
|
||||
//-----------------------
|
||||
// SORT FILES AND FOLDERS
|
||||
//-----------------------
|
||||
if (sizeof($dirs) > 0) {
|
||||
foreach ($dirs as $key => $row) {
|
||||
if ($row["name"] == "") {
|
||||
unset($dirs[$key]); //Delete empty array entries
|
||||
continue;
|
||||
}
|
||||
$name[$key] = strtolower($row['name']);
|
||||
$date[$key] = strtolower($row['date']);
|
||||
}
|
||||
@array_multisort($$sorting_folders, $sortdir_folders, $name, $sortdir_folders, $dirs);
|
||||
foreach ($dirs as $key => $row) {
|
||||
if ($row["name"] == "") {
|
||||
unset($dirs[$key]); //Delete empty array entries
|
||||
continue;
|
||||
}
|
||||
$name[$key] = strtolower($row['name']);
|
||||
$date[$key] = strtolower($row['date']);
|
||||
}
|
||||
@array_multisort($$sorting_folders, $sortdir_folders, $name, $sortdir_folders, $dirs);
|
||||
}
|
||||
|
||||
if (sizeof($files) > 0) {
|
||||
foreach ($files as $key => $row) {
|
||||
if ($row["name"] == "") {
|
||||
unset($files[$key]); //Delete empty array entries
|
||||
continue;
|
||||
}
|
||||
$name[$key] = strtolower($row['name']);
|
||||
$date[$key] = strtolower($row['date']);
|
||||
$size[$key] = strtolower($row['size']);
|
||||
}
|
||||
@array_multisort($$sorting_files, $sortdir_files, $name, SORT_ASC, $files);
|
||||
foreach ($files as $key => $row) {
|
||||
if ($row["name"] == "") {
|
||||
unset($files[$key]); //Delete empty array entries
|
||||
continue;
|
||||
}
|
||||
$name[$key] = strtolower($row['name']);
|
||||
$date[$key] = strtolower($row['date']);
|
||||
$size[$key] = strtolower($row['size']);
|
||||
}
|
||||
@array_multisort($$sorting_files, $sortdir_files, $name, SORT_ASC, $files);
|
||||
}
|
||||
|
||||
//-----------------------
|
||||
// OFFSET DETERMINATION
|
||||
//-----------------------
|
||||
if (!isset($_GET["page"]))
|
||||
$_GET["page"] = 1;
|
||||
if (!isset($_GET["page"])) {
|
||||
$_GET["page"] = 1;
|
||||
}
|
||||
|
||||
$offset_start = ($_GET["page"] * $thumbs_pr_page) - $thumbs_pr_page;
|
||||
$offset_end = $offset_start + $thumbs_pr_page;
|
||||
if ($offset_end > sizeof($dirs) + sizeof($files))
|
||||
$offset_end = sizeof($dirs) + sizeof($files);
|
||||
if ($offset_end > sizeof($dirs) + sizeof($files)) {
|
||||
$offset_end = sizeof($dirs) + sizeof($files);
|
||||
}
|
||||
|
||||
if ($_GET["page"] == "all" || $lazyload) {
|
||||
$offset_start = 0;
|
||||
$offset_end = sizeof($dirs) + sizeof($files);
|
||||
$offset_start = 0;
|
||||
$offset_end = sizeof($dirs) + sizeof($files);
|
||||
}
|
||||
|
||||
//-----------------------
|
||||
// PAGE NAVIGATION
|
||||
//-----------------------
|
||||
if (!$lazyload && sizeof($dirs) + sizeof($files) > $thumbs_pr_page) {
|
||||
$page_navigation .= "$label_page ";
|
||||
for ($i = 1; $i <= ceil((sizeof($files) + sizeof($dirs)) / $thumbs_pr_page); $i++) {
|
||||
if ($_GET["page"] == $i)
|
||||
$page_navigation .= "$i";
|
||||
else
|
||||
$page_navigation .= "<a href='?dir=" . $requestedDir . "&page=" . ($i) . "'>" . $i . "</a>";
|
||||
if ($i != ceil((sizeof($files) + sizeof($dirs)) / $thumbs_pr_page))
|
||||
$page_navigation .= " | ";
|
||||
}
|
||||
//Insert link to view all images
|
||||
if ($_GET["page"] == "all")
|
||||
$page_navigation .= " | $label_all";
|
||||
else
|
||||
$page_navigation .= " | <a href='?dir=" . $requestedDir . "&page=all'>$label_all</a>";
|
||||
$page_navigation .= "$label_page ";
|
||||
for ($i = 1; $i <= ceil((sizeof($files) + sizeof($dirs)) / $thumbs_pr_page); $i++) {
|
||||
if ($_GET["page"] == $i) {
|
||||
$page_navigation .= "$i";
|
||||
} else {
|
||||
$page_navigation .= "<a href='?dir=" . $requestedDir . "&page=" . ($i) . "'>" . $i . "</a>";
|
||||
}
|
||||
|
||||
if ($i != ceil((sizeof($files) + sizeof($dirs)) / $thumbs_pr_page)) {
|
||||
$page_navigation .= " | ";
|
||||
}
|
||||
|
||||
}
|
||||
//Insert link to view all images
|
||||
if ($_GET["page"] == "all") {
|
||||
$page_navigation .= " | $label_all";
|
||||
} else {
|
||||
$page_navigation .= " | <a href='?dir=" . $requestedDir . "&page=all'>$label_all</a>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------
|
||||
// BREADCRUMB NAVIGATION
|
||||
//-----------------------
|
||||
if ($requestedDir != "" && $requestedDir != "photos") {
|
||||
$breadcrumb_navigation = "<div class=\"NavWrapper\">";
|
||||
$breadcrumb_navigation .= "<a href='?dir='>" . $label_home . "</a> $breadcrumb_separator ";
|
||||
$navitems = explode("/", htmlspecialchars($_REQUEST['dir']));
|
||||
for ($i = 0; $i < sizeof($navitems); $i++) {
|
||||
if ($i == sizeof($navitems)-1) {
|
||||
$breadcrumb_navigation .= $navitems[$i];
|
||||
} else {
|
||||
$breadcrumb_navigation .= "<a href='?dir=";
|
||||
for ($x = 0; $x <= $i; $x++) {
|
||||
$breadcrumb_navigation .= $navitems[$x];
|
||||
if ($x < $i)
|
||||
$breadcrumb_navigation .= "/";
|
||||
}
|
||||
$breadcrumb_navigation .= "'>" . $navitems[$i] . "</a> $breadcrumb_separator ";
|
||||
}
|
||||
}
|
||||
$breadcrumb_navigation .= "</div>";
|
||||
$breadcrumb_navigation = "<div class=\"NavWrapper\">";
|
||||
$breadcrumb_navigation .= "<a href='?dir='>" . $label_home . "</a> $breadcrumb_separator ";
|
||||
$navitems = explode("/", htmlspecialchars($_REQUEST['dir']));
|
||||
for ($i = 0; $i < sizeof($navitems); $i++) {
|
||||
if ($i == sizeof($navitems) - 1) {
|
||||
$breadcrumb_navigation .= $navitems[$i];
|
||||
} else {
|
||||
$breadcrumb_navigation .= "<a href='?dir=";
|
||||
for ($x = 0; $x <= $i; $x++) {
|
||||
$breadcrumb_navigation .= $navitems[$x];
|
||||
if ($x < $i) {
|
||||
$breadcrumb_navigation .= "/";
|
||||
}
|
||||
|
||||
}
|
||||
$breadcrumb_navigation .= "'>" . $navitems[$i] . "</a> $breadcrumb_separator ";
|
||||
}
|
||||
}
|
||||
$breadcrumb_navigation .= "</div>";
|
||||
}
|
||||
|
||||
//Include hidden links for all images BEFORE current page so lightbox is able to browse images on different pages
|
||||
for ($y = 0; $y < $offset_start - sizeof($dirs); $y++) {
|
||||
$breadcrumb_navigation .= "<a href='" . $currentdir . "/" . $files[$y]["name"] . "' class='hidden' title='" . $img_captions[$files[$y]["name"]] . "'></a>";
|
||||
$breadcrumb_navigation .= "<a href='" . $currentdir . "/" . $files[$y]["name"] . "' class='hidden' title='" . $img_captions[$files[$y]["name"]] . "'></a>";
|
||||
}
|
||||
|
||||
//-----------------------
|
||||
// DISPLAY FOLDERS
|
||||
//-----------------------
|
||||
if (count($dirs) + count($files) == 0) {
|
||||
$thumbnails .= "<div class=\"Empty\">$label_noimages</div> <div class=\"EmptyAdvice\">$label_noimages_advice</div>"; //Display 'no images' text
|
||||
if ($currentdir == "photos") {
|
||||
$messages =
|
||||
"It looks like you have just installed MiniGal Nano.
|
||||
$thumbnails .= "<div class=\"Empty\">$label_noimages</div> <div class=\"EmptyAdvice\">$label_noimages_advice</div>"; //Display 'no images' text
|
||||
if ($currentdir == "photos") {
|
||||
$messages =
|
||||
"It looks like you have just installed MiniGal Nano.
|
||||
Please run the <a href='system_check.php'>system check tool</a>. <br>
|
||||
And why not have a look to config.php and customize some values ?";
|
||||
}
|
||||
}
|
||||
}
|
||||
$offset_current = $offset_start;
|
||||
for ($x = $offset_start; $x < sizeof($dirs) && $x < $offset_end; $x++) {
|
||||
$offset_current++;
|
||||
$thumbnails .= $dirs[$x]["html"];
|
||||
$offset_current++;
|
||||
$thumbnails .= $dirs[$x]["html"];
|
||||
}
|
||||
|
||||
//-----------------------
|
||||
// DISPLAY FILES
|
||||
//-----------------------
|
||||
for ($i = $offset_start - sizeof($dirs); $i < $offset_end && $offset_current < $offset_end; $i++) {
|
||||
if ($i >= 0) {
|
||||
$offset_current++;
|
||||
$thumbnails .= $files[$i]["html"];
|
||||
}
|
||||
if ($i >= 0) {
|
||||
$offset_current++;
|
||||
$thumbnails .= $files[$i]["html"];
|
||||
}
|
||||
}
|
||||
|
||||
//Include hidden links for all images AFTER current page so lightbox is able to browse images on different pages
|
||||
if ($i < 0)
|
||||
$i = 1;
|
||||
if ($i < 0) {
|
||||
$i = 1;
|
||||
}
|
||||
|
||||
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>";
|
||||
}
|
||||
|
||||
//-----------------------
|
||||
// OUTPUT MESSAGES
|
||||
//-----------------------
|
||||
if ($messages != "") {
|
||||
$messages = $messages . "<div><a id=\"closeMessage\" class=\"closeMessage\" href=\"#\"><img src=\"images/close.png\" /></a><div>";
|
||||
$messages = $messages . "<div><a id=\"closeMessage\" class=\"closeMessage\" href=\"#\"><img src=\"images/close.png\" /></a><div>";
|
||||
}
|
||||
|
||||
// Read folder comment.
|
||||
$comment_filepath = $currentdir . $file . "/comment.html";
|
||||
if (file_exists($comment_filepath)) {
|
||||
$fd = fopen($comment_filepath, "r");
|
||||
$comment = "<div class=\"Comment\">" . fread($fd, filesize($comment_filepath)) . "</div>";
|
||||
fclose($fd);
|
||||
$fd = fopen($comment_filepath, "r");
|
||||
$comment = "<div class=\"Comment\">" . fread($fd, filesize($comment_filepath)) . "</div>";
|
||||
fclose($fd);
|
||||
}
|
||||
|
||||
//PROCESS TEMPLATE FILE
|
||||
if (GALLERY_ROOT != "")
|
||||
$templatefile = GALLERY_ROOT . "templates/integrate.html";
|
||||
else
|
||||
$templatefile = "templates/" . $templatefile . ".html";
|
||||
if (GALLERY_ROOT != "") {
|
||||
$templatefile = GALLERY_ROOT . "templates/integrate.html";
|
||||
} else {
|
||||
$templatefile = "templates/" . $templatefile . ".html";
|
||||
}
|
||||
|
||||
if (!$fd = fopen($templatefile, "r")) {
|
||||
echo "Template ".htmlspecialchars(stripslashes($templatefile))." not found!";
|
||||
exit();
|
||||
echo "Template " . htmlspecialchars(stripslashes($templatefile)) . " not found!";
|
||||
exit();
|
||||
} else {
|
||||
$template = fread($fd, filesize ($templatefile));
|
||||
fclose($fd);
|
||||
$template = stripslashes($template);
|
||||
$template = preg_replace("/<% title %>/", $title, $template);
|
||||
$template = preg_replace("/<% messages %>/", $messages, $template);
|
||||
$template = preg_replace("/<% author %>/", $author, $template);
|
||||
$template = preg_replace("/<% gallery_root %>/", GALLERY_ROOT, $template);
|
||||
$template = preg_replace("/<% images %>/", "$images", $template);
|
||||
$template = preg_replace("/<% thumbnails %>/", "$thumbnails", $template);
|
||||
$template = preg_replace("/<% breadcrumb_navigation %>/", "$breadcrumb_navigation", $template);
|
||||
$template = preg_replace("/<% page_navigation %>/", "$page_navigation", $template);
|
||||
$template = preg_replace("/<% folder_comment %>/", "$comment", $template);
|
||||
$template = preg_replace("/<% bgcolor %>/", "$backgroundcolor", $template);
|
||||
$template = preg_replace("/<% gallery_width %>/", "$gallery_width", $template);
|
||||
$template = preg_replace("/<% version %>/", "$version", $template);
|
||||
echo "$template";
|
||||
$template = fread($fd, filesize($templatefile));
|
||||
fclose($fd);
|
||||
$template = stripslashes($template);
|
||||
$template = preg_replace("/<% title %>/", $title, $template);
|
||||
$template = preg_replace("/<% messages %>/", $messages, $template);
|
||||
$template = preg_replace("/<% author %>/", $author, $template);
|
||||
$template = preg_replace("/<% gallery_root %>/", GALLERY_ROOT, $template);
|
||||
$template = preg_replace("/<% images %>/", "$images", $template);
|
||||
$template = preg_replace("/<% thumbnails %>/", "$thumbnails", $template);
|
||||
$template = preg_replace("/<% breadcrumb_navigation %>/", "$breadcrumb_navigation", $template);
|
||||
$template = preg_replace("/<% page_navigation %>/", "$page_navigation", $template);
|
||||
$template = preg_replace("/<% folder_comment %>/", "$comment", $template);
|
||||
$template = preg_replace("/<% bgcolor %>/", "$backgroundcolor", $template);
|
||||
$template = preg_replace("/<% gallery_width %>/", "$gallery_width", $template);
|
||||
$template = preg_replace("/<% version %>/", "$version", $template);
|
||||
echo "$template";
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
$path_to_minigalnano = "minigalnano/"; // <- Enter RELATIVE path to MiniGal Nano here (eg. "subfolder/minigalnano") - DO NOT END WITH /
|
||||
|
||||
|
||||
// DO NOT EDIT BELOW THIS LINE!
|
||||
define("GALLERY_ROOT", $path_to_minigalnano);
|
||||
require(GALLERY_ROOT . "index.php");
|
||||
require GALLERY_ROOT . "index.php";
|
||||
?>
|
224
rss.php
224
rss.php
|
@ -4,11 +4,11 @@
|
|||
/*============================*/
|
||||
|
||||
if (!empty($_SERVER['REQUEST_SCHEME'])) {
|
||||
$g_protocol = $_SERVER['REQUEST_SCHEME'];
|
||||
$g_protocol = $_SERVER['REQUEST_SCHEME'];
|
||||
} elseif (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
|
||||
$g_protocol = 'https';
|
||||
$g_protocol = 'https';
|
||||
} else {
|
||||
$g_protocol = 'http';
|
||||
$g_protocol = 'http';
|
||||
}
|
||||
$g_host = $_SERVER['HTTP_HOST'];
|
||||
$g_port = $_SERVER['SERVER_PORT'];
|
||||
|
@ -16,14 +16,14 @@ $g_path = dirname($_SERVER['REQUEST_URI']);
|
|||
|
||||
// remove default ports
|
||||
if (($g_protocol == 'https' && $g_port == '443') ||
|
||||
($g_protocol == 'http' && $g_port == '80')) {
|
||||
$g_port = '';
|
||||
($g_protocol == 'http' && $g_port == '80')) {
|
||||
$g_port = '';
|
||||
} else {
|
||||
$g_port = ':' . $g_port;
|
||||
$g_port = ':' . $g_port;
|
||||
}
|
||||
|
||||
if ($g_path[0] != '/') {
|
||||
$g_path = '/' . $g_path;
|
||||
$g_path = '/' . $g_path;
|
||||
}
|
||||
|
||||
$gallery_link = $g_protocol . '://' . $g_host . $g_port . $g_path;
|
||||
|
@ -32,115 +32,115 @@ $gallery_link = $g_protocol . '://' . $g_host . $g_port . $g_path;
|
|||
/* Functions */
|
||||
/*===================*/
|
||||
# Hardly inspired from here : codes-sources.commentcamarche.net/source/35937-creation-d-une-arborescenceI
|
||||
# Listing all files of a folder and sub folders.
|
||||
function listFiles(&$content, $Folder, $SkipFileExts, $SkipObjects)
|
||||
{
|
||||
$dir = opendir($Folder);
|
||||
// Loop on all contained on the folder
|
||||
while (false !== ($Current = readdir($dir))) {
|
||||
if ($Current !='.' && $Current != '..' && in_array($Current, $SkipObjects) === false) {
|
||||
if (is_dir($Folder.'/'.$Current)) {
|
||||
ListFiles($content, $Folder . '/' . $Current, $SkipFileExts, $SkipObjects);
|
||||
} else {
|
||||
$FileExt = strtolower(substr(strrchr($Current, '.'), 1));
|
||||
// Should we display this extension ?
|
||||
if (in_array($FileExt, $SkipFileExts) === false) {
|
||||
$current_adress = $Folder.'/'. $Current;
|
||||
array_push($content, $current_adress);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
return $content;
|
||||
# Listing all files of a folder and sub folders.
|
||||
function listFiles(&$content, $Folder, $SkipFileExts, $SkipObjects) {
|
||||
$dir = opendir($Folder);
|
||||
// Loop on all contained on the folder
|
||||
while (false !== ($Current = readdir($dir))) {
|
||||
if ($Current != '.' && $Current != '..' && in_array($Current, $SkipObjects) === false) {
|
||||
if (is_dir($Folder . '/' . $Current)) {
|
||||
ListFiles($content, $Folder . '/' . $Current, $SkipFileExts, $SkipObjects);
|
||||
} else {
|
||||
$FileExt = strtolower(substr(strrchr($Current, '.'), 1));
|
||||
// Should we display this extension ?
|
||||
if (in_array($FileExt, $SkipFileExts) === false) {
|
||||
$current_adress = $Folder . '/' . $Current;
|
||||
array_push($content, $current_adress);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
return $content;
|
||||
}
|
||||
|
||||
# Paul's Simple Diff Algorithm v 0.1 : http://paulbutler.org/archives/a-simple-diff-algorithm-in-php/
|
||||
function diff($old, $new)
|
||||
{
|
||||
$matrix = array();
|
||||
$maxlen = 0;
|
||||
foreach ($old as $oindex => $ovalue) {
|
||||
$nkeys = array_keys($new, $ovalue);
|
||||
foreach ($nkeys as $nindex) {
|
||||
$matrix[$oindex][$nindex] = isset($matrix[$oindex - 1][$nindex - 1]) ?
|
||||
$matrix[$oindex - 1][$nindex - 1] + 1 : 1;
|
||||
if ($matrix[$oindex][$nindex] > $maxlen) {
|
||||
$maxlen = $matrix[$oindex][$nindex];
|
||||
$omax = $oindex + 1 - $maxlen;
|
||||
$nmax = $nindex + 1 - $maxlen;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($maxlen == 0)
|
||||
return array(array('d'=>$old, 'i'=>$new));
|
||||
return array_merge(
|
||||
diff(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)),
|
||||
array_slice($new, $nmax, $maxlen),
|
||||
diff(array_slice($old, $omax + $maxlen), array_slice($new, $nmax + $maxlen)));
|
||||
function diff($old, $new) {
|
||||
$matrix = array();
|
||||
$maxlen = 0;
|
||||
foreach ($old as $oindex => $ovalue) {
|
||||
$nkeys = array_keys($new, $ovalue);
|
||||
foreach ($nkeys as $nindex) {
|
||||
$matrix[$oindex][$nindex] = isset($matrix[$oindex - 1][$nindex - 1]) ?
|
||||
$matrix[$oindex - 1][$nindex - 1] + 1 : 1;
|
||||
if ($matrix[$oindex][$nindex] > $maxlen) {
|
||||
$maxlen = $matrix[$oindex][$nindex];
|
||||
$omax = $oindex + 1 - $maxlen;
|
||||
$nmax = $nindex + 1 - $maxlen;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($maxlen == 0) {
|
||||
return array(array('d' => $old, 'i' => $new));
|
||||
}
|
||||
|
||||
return array_merge(
|
||||
diff(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)),
|
||||
array_slice($new, $nmax, $maxlen),
|
||||
diff(array_slice($old, $omax + $maxlen), array_slice($new, $nmax + $maxlen)));
|
||||
}
|
||||
|
||||
/*===================*/
|
||||
/* Variables */
|
||||
/*===================*/
|
||||
require("config-default.php");
|
||||
include("config.php");
|
||||
require "config-default.php";
|
||||
include "config.php";
|
||||
$folder = "photos";
|
||||
|
||||
$content = array();
|
||||
$content = listFiles($content, $folder, $SkipExts, $SkipObjects);
|
||||
usort($content, function ($a, $b) { return filemtime($a) < filemtime($b); });
|
||||
usort($content, function ($a, $b) {return filemtime($a) < filemtime($b);});
|
||||
|
||||
if (is_writeable(".")) {
|
||||
$to_store = "";
|
||||
$old_files_list = "db_old_files"; //list of files in ./photos
|
||||
$db_feed_source = "db_feed_source";
|
||||
$db_rss_timestamp = "db_rss_timestamp";
|
||||
$to_store = "";
|
||||
$old_files_list = "db_old_files"; //list of files in ./photos
|
||||
$db_feed_source = "db_feed_source";
|
||||
$db_rss_timestamp = "db_rss_timestamp";
|
||||
|
||||
// Init files
|
||||
if (!file_exists($old_files_list)) {
|
||||
file_put_contents($old_files_list, "");
|
||||
}
|
||||
if (!file_exists($db_feed_source)) {
|
||||
file_put_contents($db_feed_source, "");
|
||||
}
|
||||
if (!file_exists($db_rss_timestamp)) {
|
||||
file_put_contents($db_rss_timestamp, "");
|
||||
}
|
||||
// Init files
|
||||
if (!file_exists($old_files_list)) {
|
||||
file_put_contents($old_files_list, "");
|
||||
}
|
||||
if (!file_exists($db_feed_source)) {
|
||||
file_put_contents($db_feed_source, "");
|
||||
}
|
||||
if (!file_exists($db_rss_timestamp)) {
|
||||
file_put_contents($db_rss_timestamp, "");
|
||||
}
|
||||
|
||||
/*===================*/
|
||||
/* Computing */
|
||||
/*===================*/
|
||||
#Todo : ajouter une condition : dois-je regénérer le flux ou utiliser les anciens fichiers ?
|
||||
$temp = file_get_contents($db_feed_source);
|
||||
$last_rss_gen = file_get_contents($db_rss_timestamp);
|
||||
$current_time = time();
|
||||
// If the RSS generation is already launched, don't do a second generation at the same time
|
||||
if (($current_time - $last_rss_gen) > $rss_refresh_interval && file_exists("rss.locker") == false) {
|
||||
file_put_contents("rss.locker", "");
|
||||
file_put_contents($db_rss_timestamp, time());
|
||||
// Load the list from files.
|
||||
$old_files_list_content = explode("\n", file_get_contents($old_files_list));
|
||||
$new_files_list_content = $content; #debug
|
||||
// Generate and stock new elements
|
||||
$differences = diff($old_files_list_content, $new_files_list_content);
|
||||
for ($i=0; $i < count($differences); $i++) {
|
||||
if (is_array($differences[$i])) {
|
||||
for ($j=0; $j < count($differences[$i]["i"]); $j++) {
|
||||
if (strlen($differences[$i]["i"][$j]) > 2) {
|
||||
$to_store .= $differences[$i]["i"][$j] . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add new elements at the top of the feed's source
|
||||
$temp = $to_store . $temp;
|
||||
file_put_contents($db_feed_source, $temp);
|
||||
// Store the current file list for the next generation
|
||||
file_put_contents($old_files_list, join("/n", $content));
|
||||
unlink("rss.locker");
|
||||
}
|
||||
$content = explode("\n", $temp);
|
||||
/*===================*/
|
||||
/* Computing */
|
||||
/*===================*/
|
||||
#Todo : ajouter une condition : dois-je regénérer le flux ou utiliser les anciens fichiers ?
|
||||
$temp = file_get_contents($db_feed_source);
|
||||
$last_rss_gen = file_get_contents($db_rss_timestamp);
|
||||
$current_time = time();
|
||||
// If the RSS generation is already launched, don't do a second generation at the same time
|
||||
if (($current_time - $last_rss_gen) > $rss_refresh_interval && file_exists("rss.locker") == false) {
|
||||
file_put_contents("rss.locker", "");
|
||||
file_put_contents($db_rss_timestamp, time());
|
||||
// Load the list from files.
|
||||
$old_files_list_content = explode("\n", file_get_contents($old_files_list));
|
||||
$new_files_list_content = $content; #debug
|
||||
// Generate and stock new elements
|
||||
$differences = diff($old_files_list_content, $new_files_list_content);
|
||||
for ($i = 0; $i < count($differences); $i++) {
|
||||
if (is_array($differences[$i])) {
|
||||
for ($j = 0; $j < count($differences[$i]["i"]); $j++) {
|
||||
if (strlen($differences[$i]["i"][$j]) > 2) {
|
||||
$to_store .= $differences[$i]["i"][$j] . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add new elements at the top of the feed's source
|
||||
$temp = $to_store . $temp;
|
||||
file_put_contents($db_feed_source, $temp);
|
||||
// Store the current file list for the next generation
|
||||
file_put_contents($old_files_list, join("/n", $content));
|
||||
unlink("rss.locker");
|
||||
}
|
||||
$content = explode("\n", $temp);
|
||||
}
|
||||
|
||||
/*===================*/
|
||||
|
@ -152,16 +152,18 @@ echo "<rss version='2.0'>\n<channel>";
|
|||
echo "<title>$title</title>";
|
||||
echo "<link>$gallery_link</link>";
|
||||
echo "<description>$description</description>\n";
|
||||
for ($i=0; $i < $nb_items_rss && $i < count($content); $i++) {
|
||||
if (empty($content[$i]))
|
||||
continue;
|
||||
$link = $gallery_link . '/' . str_replace(' ', '%20', $content[$i]);
|
||||
echo "<item>\n";
|
||||
echo " <title>" . basename($link) . "</title>\n";
|
||||
echo " <link>". $link . "</link>\n";
|
||||
echo " <guid>". $link . "</guid>\n";
|
||||
echo " <description><![CDATA[ <img src='" . $link . "'> ]]></description>\n";
|
||||
echo " <pubDate>" . date ("D, j M Y H:i:s O", filemtime($content[$i])) . "</pubDate>";
|
||||
echo "</item>\n";
|
||||
for ($i = 0; $i < $nb_items_rss && $i < count($content); $i++) {
|
||||
if (empty($content[$i])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$link = $gallery_link . '/' . str_replace(' ', '%20', $content[$i]);
|
||||
echo "<item>\n";
|
||||
echo " <title>" . basename($link) . "</title>\n";
|
||||
echo " <link>" . $link . "</link>\n";
|
||||
echo " <guid>" . $link . "</guid>\n";
|
||||
echo " <description><![CDATA[ <img src='" . $link . "'> ]]></description>\n";
|
||||
echo " <pubDate>" . date("D, j M Y H:i:s O", filemtime($content[$i])) . "</pubDate>";
|
||||
echo "</item>\n";
|
||||
}
|
||||
echo "</channel></rss>\n";
|
||||
|
|
|
@ -1,11 +1,20 @@
|
|||
<?php
|
||||
ini_set("memory_limit","256M");
|
||||
$exif = "No";
|
||||
$gd = "No";
|
||||
$thumbs = "No";
|
||||
if (function_exists('exif_read_data')) $exif = "Yes";
|
||||
if (extension_loaded('gd') && function_exists('gd_info')) $gd = "Yes";
|
||||
if (is_dir('thumbs') && is_writable('thumbs')) $thumbs = "Yes";
|
||||
ini_set("memory_limit", "256M");
|
||||
$exif = "No";
|
||||
$gd = "No";
|
||||
$thumbs = "No";
|
||||
if (function_exists('exif_read_data')) {
|
||||
$exif = "Yes";
|
||||
}
|
||||
|
||||
if (extension_loaded('gd') && function_exists('gd_info')) {
|
||||
$gd = "Yes";
|
||||
}
|
||||
|
||||
if (is_dir('thumbs') && is_writable('thumbs')) {
|
||||
$thumbs = "Yes";
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -61,7 +70,7 @@
|
|||
display: inline-table;
|
||||
background-color: #eaf1ea;
|
||||
padding: 2px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -69,8 +78,13 @@
|
|||
<div class="left">
|
||||
PHP Version
|
||||
</div>
|
||||
<div class="<?php if(version_compare(phpversion(), "4.0", '>')) echo 'middle-yes'; else echo 'middle-no' ?>">
|
||||
<?php echo phpversion(); ?>
|
||||
<div class="<?php if (version_compare(phpversion(), "4.0", '>')) {
|
||||
echo 'middle-yes';
|
||||
} else {
|
||||
echo 'middle-no';
|
||||
}
|
||||
?>">
|
||||
<?php echo phpversion();?>
|
||||
</div>
|
||||
<div class="right">
|
||||
<a href="http://www.php.net/" target="_blank">PHP</a> scripting language version 4.0 or greater is needed.
|
||||
|
@ -80,8 +94,13 @@
|
|||
<div class="left">
|
||||
GD library support
|
||||
</div>
|
||||
<div class="<?php if($gd == "Yes") echo 'middle-yes'; else echo 'middle-no' ?>">
|
||||
<?php echo $gd; ?>
|
||||
<div class="<?php if ($gd == "Yes") {
|
||||
echo 'middle-yes';
|
||||
} else {
|
||||
echo 'middle-no';
|
||||
}
|
||||
?>">
|
||||
<?php echo $gd;?>
|
||||
</div>
|
||||
<div class="right">
|
||||
<a href="http://www.boutell.com/gd/" target="_blank">GD image manipulation</a> library is used to create thumbnails. Bundled since PHP 4.3.
|
||||
|
@ -91,8 +110,13 @@
|
|||
<div class="left">
|
||||
EXIF support
|
||||
</div>
|
||||
<div class="<?php if($exif == "Yes") echo 'middle-yes'; else echo 'middle-neutral' ?>">
|
||||
<?php echo $exif; ?>
|
||||
<div class="<?php if ($exif == "Yes") {
|
||||
echo 'middle-yes';
|
||||
} else {
|
||||
echo 'middle-neutral';
|
||||
}
|
||||
?>">
|
||||
<?php echo $exif;?>
|
||||
</div>
|
||||
<div class="right">
|
||||
Ability to extract and display <a href="http://en.wikipedia.org/wiki/Exif" target="_blank">EXIF information</a>. The script will work without it, but not display image information.
|
||||
|
@ -102,8 +126,13 @@
|
|||
<div class="left">
|
||||
Thumbnails caching
|
||||
</div>
|
||||
<div class="<?php if($thumbs == "Yes") echo 'middle-yes'; else echo 'middle-neutral' ?>">
|
||||
<?php echo $thumbs; ?>
|
||||
<div class="<?php if ($thumbs == "Yes") {
|
||||
echo 'middle-yes';
|
||||
} else {
|
||||
echo 'middle-neutral';
|
||||
}
|
||||
?>">
|
||||
<?php echo $thumbs;?>
|
||||
</div>
|
||||
<div class="right">
|
||||
You should let php create and use the 'thumbs" directory. MiniGal will be <b>much</b> faster.
|
||||
|
@ -114,13 +143,11 @@
|
|||
PHP memory limit
|
||||
</div>
|
||||
<div class="middle-neutral">
|
||||
<?php echo ini_get("memory_limit"); ?>
|
||||
<?php echo ini_get("memory_limit");?>
|
||||
</div>
|
||||
<div class="right">
|
||||
Memory is needed to create thumbnails. Bigger images uses more memory.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<footer role="contentinfo">
|
||||
<a href="https://github.com/sebsauvage/MinigalNano" title="Powered by MiniGal Nano" target="_blank">
|
||||
|
|
Loading…
Reference in a new issue