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_folders = SORT_ASC; // Sort direction of folders: SORT_ASC / SORT_DESC
$sortdir_files = SORT_ASC; // Sort direction of files: 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 $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 //LANGUAGE STRINGS
$label_home = "Home"; // Name of home link in breadcrumb navigation $label_home = "Home"; // Name of home link in breadcrumb navigation
@ -36,7 +36,7 @@ $breadcrumb_separator = ">"; // Breadcrumb parts separator
$description = "MiniGal Nano"; $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 $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. $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 //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! $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!

View file

@ -7,8 +7,11 @@
* MinigalNano is licensed under the AGPL v3 (https://gnu.org/licenses/agpl-3.0.txt). * 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"; $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 # 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, $keep_extensions, $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))) {
if ($Current != '.' && $Current != '..' && in_array($Current, $SkipObjects) === false) { if ($current != '.' && $current != '..' && in_array($current, $SkipObjects) === false) {
if (is_dir($Folder . '/' . $Current)) { if (is_dir($folder . '/' . $current)) {
ListFiles($content, $Folder . '/' . $Current, $SkipFileExts, $SkipObjects); ListFiles($content, $folder . '/' . $current, $keep_extensions, $SkipObjects);
} else { } else {
$FileExt = strtolower(substr(strrchr($Current, '.'), 1)); $file_ext = strtolower(substr(strrchr($current, '.'), 1));
// Should we display this extension ? // Should we display this extension ?
if (in_array($FileExt, $SkipFileExts) === false) { if (in_array($file_ext, $keep_extensions)) {
$current_adress = $Folder . '/' . $Current; $current_adress = $folder . '/' . $current;
array_push($content, $current_adress); array_push($content, $current_adress);
} }
} }
@ -96,7 +96,7 @@ include "config.php";
$folder = "photos"; $folder = "photos";
$content = array(); $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);}); usort($content, function ($a, $b) {return filemtime($a) < filemtime($b);});
if (is_writeable(".")) { if (is_writeable(".")) {