Add video support

This commit is contained in:
Knah Tsaeb 2019-11-18 16:34:27 +01:00
parent 44703f20a4
commit c201d26a81
3 changed files with 134 additions and 30 deletions

View file

@ -1 +1,9 @@
Options -Indexes
AddType video/ogg .ogv
AddType video/ogg .ogg
AddType video/mp4 .mp4
AddType video/webm .webm
<FilesMatch "\.(mp4|m4v)$">
ForceType video/mp4
</FilesMatch>

108
index.php
View file

@ -1,5 +1,4 @@
<?php
/*
* This file is part of MinigalNano: https://github.com/sebsauvage/MinigalNano
*
@ -10,6 +9,25 @@
error_reporting(-1);
/**
* Améliore la sortie print
*
* @author Tatane http://www.tatane.info/index.php/print_rn
* @author http://www.blog.cactuscrew.com/77-print_rn.html
* @param $data (array) tableau ou variable à examiner
* @param $name (string) nom a afficher
* @return false affiche les clef valeur du tableau $data
* @example n_print($array, 'Tableau de valeur');
*/
function n_print($data, $name = '') {
$aBackTrace = debug_backtrace();
echo '<h2>', $name, '</h2>';
echo '<fieldset style="border: 1px solid orange; padding: 5px;color: #333; background-color: #fff;">';
echo '<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '</legend>';
echo '<pre>', htmlentities(print_r($data, 1)), '</pre>';
echo '</fieldset><br />';
}
// Do not edit below this section unless you know what you are doing!
header('Content-Type: text/html; charset=UTF-8'); // We use UTF-8 for proper international characters handling.
@ -17,7 +35,9 @@ $version = "0.4.0";
ini_set("memory_limit", "256M");
require "config-default.php";
include "config.php";
if(file_exists('user_config.php')){
include "user_config.php";
}
//-----------------------
// DEFINE VARIABLES
@ -57,7 +77,7 @@ function padstring($name, $length)
function getfirstImage($dirname)
{
$imageName = false;
$extensions = array("jpg", "png", "jpeg", "gif");
$extensions = array("jpg", "png", "jpeg", "gif", "bmp");
if ($handle = opendir($dirname)) {
while (false !== ($file = readdir($handle))) {
if ($file[0] == '.') {
@ -268,7 +288,6 @@ if (is_dir($current_dir) && $handle = opendir($current_dir)) {
}
}
}
// 3. LOAD FILES
if ($file != "." && $file != ".." && $file != "folder.jpg") {
if ($display_filename) {
@ -278,7 +297,11 @@ if (is_dir($current_dir) && $handle = opendir($current_dir)) {
}
// JPG, GIF and PNG
if (preg_match("/.jpg$|.gif$|.png$/i", $file)) {
if (preg_match("/.jpg$|.gif$|.bmp$|.png$/i", $file)) {
$path_parts = pathinfo($file);
if(file_exists($current_dir.'/'.$path_parts['filename'].'.mp4')){
continue;
}
//Read EXIF
if (!array_key_exists($file, $img_captions)) {
if ($display_exif == 1) {
@ -311,12 +334,36 @@ if (is_dir($current_dir) && $handle = opendir($current_dir)) {
} else {
$imgopts = "src=\"{$imgUrl}\"";
}
$files[] = array(
"name" => $file,
"date" => filemtime($current_dir . "/" . $file),
"size" => filesize($current_dir . "/" . $file),
"html" => "<li><a href=\"{$linkUrl}\" rel='lightbox[billeder]' title=\"" . htmlentities($img_captions[$file]) . "\"><img $imgopts alt='$label_loading' /></a>" . $filename_caption . "</li>");
"html" => "
<li>
<a href=\"{$linkUrl}\" rel='lightbox[billeder]' title=\"" . htmlentities($img_captions[$file]) . "\">
<img $imgopts alt='$label_loading' />
</a>" . $filename_caption . "
</li>");
}
if (preg_match("/\.ogv$|\.mp4$|\.mpg$|\.mpeg$|\.mov$|\.avi$|\.wmv$|\.flv$|\.webm$/i", $file)) {
$linkUrl = str_replace('%2F', '/', rawurlencode("$current_dir/$file"));
$path_parts = pathinfo($file);
if(file_exists($current_dir.'/'.$path_parts['filename'].'.jpg')){
$poster = $current_dir.'/'.$path_parts['filename'].'.jpg';
} else {
$poster = '';
}
$files[] = array(
"name" => $file,
"date" => filemtime($current_dir . "/" . $file),
"size" => filesize($current_dir . "/" . $file),
"html" => '<li>
<a href="'.$linkUrl.'" rel="lightbox[billeder]">
<video controls="true" width="370px" poster="'.$poster.'">
<source src="'.$current_dir . '/' . $file.'" type="video/mp4">
</video>
</a>' . $filename_caption . '
</li>');
}
// Other filetypes
$extension = "";
@ -352,21 +399,23 @@ if (is_dir($current_dir) && $handle = opendir($current_dir)) {
$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($current_dir . "/" . $file),
"size" => filesize($current_dir . "/" . $file),
"html" => "<li><a href='$current_dir/$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>");
"html" => "
<li>
<a href='$current_dir/$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>");
}
}
}
@ -378,7 +427,9 @@ if (is_dir($current_dir) && $handle = opendir($current_dir)) {
//-----------------------
// SORT FILES AND FOLDERS
//-----------------------
if (sizeof($dirs) > 0) {
$nbDir = count($dirs);
$nbFile = count($files);
if ($nbDir > 0) {
foreach ($dirs as $key => $row) {
if ($row["name"] == "") {
unset($dirs[$key]); //Delete empty array entries
@ -390,7 +441,7 @@ if (sizeof($dirs) > 0) {
@array_multisort($$sorting_folders, $sortdir_folders, $name, $sortdir_folders, $dirs);
}
if (sizeof($files) > 0) {
if ($nbFile > 0) {
foreach ($files as $key => $row) {
if ($row["name"] == "") {
unset($files[$key]); //Delete empty array entries
@ -412,28 +463,28 @@ if (!isset($_GET["page"])) {
$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 > $nbDir + $nbFile) {
$offset_end = $nbDir + $nbFile;
}
if ($_GET["page"] == "all" || $lazyload) {
$offset_start = 0;
$offset_end = sizeof($dirs) + sizeof($files);
$offset_end = $nbDir + $nbFile;
}
//-----------------------
// PAGE NAVIGATION
//-----------------------
if (!$lazyload && sizeof($dirs) + sizeof($files) > $thumbs_pr_page) {
if (!$lazyload && $nbDir + $nbFile > $thumbs_pr_page) {
$page_navigation .= "$label_page ";
for ($i = 1; $i <= ceil((sizeof($files) + sizeof($dirs)) / $thumbs_pr_page); $i++) {
for ($i = 1; $i <= ceil(($nbFile + $nbDir) / $thumbs_pr_page); $i++) {
if ($_GET["page"] == $i) {
$page_navigation .= "$i";
} else {
$page_navigation .= "<a href='?dir=" . $requestedDir . "&amp;page=" . ($i) . "'>" . $i . "</a>";
}
if ($i != ceil((sizeof($files) + sizeof($dirs)) / $thumbs_pr_page)) {
if ($i != ceil(($nbFile + $nbDir) / $thumbs_pr_page)) {
$page_navigation .= " | ";
}
@ -454,8 +505,8 @@ 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) {
for ($i = 0; $i < count($navitems); $i++) {
if ($i == count($navitems) - 1) {
$breadcrumb_navigation .= $navitems[$i];
} else {
$breadcrumb_navigation .= "<a href='?dir=";
@ -464,7 +515,6 @@ if ($requestedDir != "" && $requestedDir != "photos") {
if ($x < $i) {
$breadcrumb_navigation .= "/";
}
}
$breadcrumb_navigation .= "'>" . $navitems[$i] . "</a> $breadcrumb_separator ";
}
@ -473,14 +523,14 @@ if ($requestedDir != "" && $requestedDir != "photos") {
}
//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++) {
for ($y = 0; $y < $offset_start - $nbDir; $y++) {
$breadcrumb_navigation .= "<a href='" . $current_dir . "/" . $files[$y]["name"] . "' class='hidden' title='" . $img_captions[$files[$y]["name"]] . "'></a>";
}
//-----------------------
// DISPLAY FOLDERS
//-----------------------
if (count($dirs) + count($files) == 0) {
if ($nbDir + $nbFile == 0) {
$thumbnails .= "<div class=\"Empty\">$label_noimages</div> <div class=\"EmptyAdvice\">$label_noimages_advice</div>"; //Display 'no images' text
if ($current_dir == "photos") {
$messages =
@ -490,7 +540,7 @@ if (count($dirs) + count($files) == 0) {
}
}
$offset_current = $offset_start;
for ($x = $offset_start; $x < sizeof($dirs) && $x < $offset_end; $x++) {
for ($x = $offset_start; $x < $nbDir && $x < $offset_end; $x++) {
$offset_current++;
$thumbnails .= $dirs[$x]["html"];
}
@ -498,7 +548,7 @@ for ($x = $offset_start; $x < sizeof($dirs) && $x < $offset_end; $x++) {
//-----------------------
// DISPLAY FILES
//-----------------------
for ($i = $offset_start - sizeof($dirs); $i < $offset_end && $offset_current < $offset_end; $i++) {
for ($i = $offset_start - $nbDir; $i < $offset_end && $offset_current < $offset_end; $i++) {
if ($i >= 0) {
$offset_current++;
$thumbnails .= $files[$i]["html"];
@ -510,7 +560,7 @@ if ($i < 0) {
$i = 1;
}
for ($y = $i; $y < sizeof($files); $y++) {
for ($y = $i; $y < $nbFile; $y++) {
$page_navigation .= "<a href='" . $current_dir . "/" . $files[$y]["name"] . "' class='hidden' title='" . $img_captions[$files[$y]["name"]] . "'></a>";
}

46
user_config.php Normal file
View file

@ -0,0 +1,46 @@
<?php
/*
* This file is part of MinigalNano: https://github.com/sebsauvage/MinigalNano
*
* MiniGal Nano is based on an original work by Thomas Rybak (© 2010)
*
* MinigalNano is licensed under the AGPL v3 (https://gnu.org/licenses/agpl-3.0.txt).
*/
// EDIT SETTINGS BELOW TO CUSTOMIZE YOUR GALLERY
$thumbs_pr_page = "25"; // Number of thumbnails on a single page
$gallery_width = "80%"; // Gallery width. Eg: "500px" or "70%"
$backgroundcolor = "#262626"; // 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 = "kt"; // Template filename (must be placed in 'templates' folder)
$title = "Knah Tsaeb Gallery"; // Text to be displayed in browser titlebar
$author = "Knah Tsaeb";
$folder_color = "black"; // Color of folder icons: blue / black / vista / purple / green / grey
$sorting_folders = "name"; // Sort folders by: [name][date]
$sorting_files = "date"; // 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 = 0; // 0 is pagination, 1 is display all pictures on one page
$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
$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 = 320; // Time, in seconds, between two RSS refresh. for example, 3600 = 1update max per hour, 86400 = 1/day.
$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 = 1; // Show file names below the pictures
?>