Whitelist instead blacklist extensions

This commit is contained in:
Tom Canac 2016-06-24 17:04:42 +02:00
parent 28e6cdf68e
commit 344e0cb5f0
3 changed files with 22 additions and 19 deletions

View File

@ -20,7 +20,7 @@ $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)
$skip_objects = 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
@ -36,11 +36,11 @@ $breadcrumb_separator = ">"; // Breadcrumb parts separator
$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
$keep_extensions = array('jpg', 'jpeg', 'png', 'gif'); //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
?>

View File

@ -7,8 +7,11 @@
* MinigalNano is licensed under the AGPL v3 (https://gnu.org/licenses/agpl-3.0.txt).
*/
// INSERT HERE YOUR CUSTOMIZED SETTINGS
// for the list of possible options, peruse config-default.php
/*
* INSERT HERE YOUR CUSTOMIZED SETTINGS
* for the list of options, check config-default.php
*/
$title = "Your Own MiniGal Nano";
// END
?>

20
rss.php
View File

@ -41,18 +41,18 @@ $gallery_link = $g_protocol . '://' . $g_host . $g_port . $g_path;
/*===================*/
# 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);
function listFiles(&$content, $folder, $keep_extensions, $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);
while (false !== ($current = readdir($dir))) {
if ($current != '.' && $current != '..' && in_array($current, $SkipObjects) === false) {
if (is_dir($folder . '/' . $current)) {
ListFiles($content, $folder . '/' . $current, $keep_extensions, $SkipObjects);
} else {
$FileExt = strtolower(substr(strrchr($Current, '.'), 1));
$file_ext = strtolower(substr(strrchr($current, '.'), 1));
// Should we display this extension ?
if (in_array($FileExt, $SkipFileExts) === false) {
$current_adress = $Folder . '/' . $Current;
if (in_array($file_ext, $keep_extensions)) {
$current_adress = $folder . '/' . $current;
array_push($content, $current_adress);
}
}
@ -96,7 +96,7 @@ include "config.php";
$folder = "photos";
$content = array();
$content = listFiles($content, $folder, $SkipExts, $SkipObjects);
$content = listFiles($content, $folder, $keep_extensions, $skip_objects);
usort($content, function ($a, $b) {return filemtime($a) < filemtime($b);});
if (is_writeable(".")) {