From c201d26a8142e4faac6939460ff3874c89c582fe Mon Sep 17 00:00:00 2001 From: Knah Tsaeb Date: Mon, 18 Nov 2019 16:34:27 +0100 Subject: [PATCH] Add video support --- .htaccess | 10 ++++- index.php | 108 +++++++++++++++++++++++++++++++++++------------- user_config.php | 46 +++++++++++++++++++++ 3 files changed, 134 insertions(+), 30 deletions(-) create mode 100644 user_config.php diff --git a/.htaccess b/.htaccess index 7d9c8eb..f62c3ae 100644 --- a/.htaccess +++ b/.htaccess @@ -1 +1,9 @@ -Options -Indexes \ No newline at end of file +Options -Indexes +AddType video/ogg .ogv +AddType video/ogg .ogg +AddType video/mp4 .mp4 +AddType video/webm .webm + + + ForceType video/mp4 + \ No newline at end of file diff --git a/index.php b/index.php index 83bfde4..a4284fa 100755 --- a/index.php +++ b/index.php @@ -1,5 +1,4 @@ ', $name, ''; + echo '
'; + echo '', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], ''; + echo '
', htmlentities(print_r($data, 1)), '
'; + echo '

'; + } + // 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" => "
  • $label_loading" . $filename_caption . "
  • "); + "html" => " +
  • + + $label_loading + " . $filename_caption . " +
  • "); + } + 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" => '
  • + + + ' . $filename_caption . ' +
  • '); } // 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" => "
  • " . padstring($file, 20) . "$file$filename_caption
  • "); + "html" => " +
  • + + " . padstring($file, 20) . " + + $file + $filename_caption +
  • "); } } } @@ -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 .= "" . $i . ""; } - 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 = "
    "; $breadcrumb_navigation .= "" . $label_home . " $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 .= "" . $navitems[$i] . " $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 .= ""; } //----------------------- // DISPLAY FOLDERS //----------------------- -if (count($dirs) + count($files) == 0) { +if ($nbDir + $nbFile == 0) { $thumbnails .= "
    $label_noimages
    $label_noimages_advice
    "; //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 .= ""; } diff --git a/user_config.php b/user_config.php new file mode 100644 index 0000000..c7115a8 --- /dev/null +++ b/user_config.php @@ -0,0 +1,46 @@ +"; // 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 +?>