From d1b05865acf71d5a10ac4f8b36116d4ee7c0a441 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Fri, 10 Dec 2021 16:08:14 +0100 Subject: [PATCH] copr-be: fixup the php directory generator - avoid using globals if not necessary - when opendir then closedir - drop the undefined SERVER_SOFTWARE env use This reverts commit 35d389a9fa98287bb0c840d7b9e5b77f648c896b. Fixes: https://pagure.io/copr/copr/issue/2009 --- .../templates/lighttpd/dir-generator.php.j2 | 19 ++++++++----------- .../backend/templates/lighttpd/lighttpd.conf | 16 ++++++++-------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/roles/copr/backend/templates/lighttpd/dir-generator.php.j2 b/roles/copr/backend/templates/lighttpd/dir-generator.php.j2 index b149c7606c..f70047015b 100755 --- a/roles/copr/backend/templates/lighttpd/dir-generator.php.j2 +++ b/roles/copr/backend/templates/lighttpd/dir-generator.php.j2 @@ -42,13 +42,6 @@ $VERSION = "0.3"; $show_hidden_files = true; $calculate_folder_size = false; -// Various file type associations -$movie_types = array('mpg','mpeg','avi','asf','mp3','wav','mp4','wma','aif','aiff','ram', 'midi','mid','asf','au','flac'); -$image_types = array('jpg','jpeg','gif','png','tif','tiff','bmp','ico'); -$archive_types = array('zip','cab','7z','gz','tar.bz2','tar.gz','tar','rar',); -$document_types = array('txt','text','doc','docx','abw','odt','pdf','rtf','tex','texinfo',); -$font_types = array('ttf','otf','abf','afm','bdf','bmf','fnt','fon','mgf','pcf','ttc','tfm','snf','sfd'); - // Get the path (cut out the query string from the request_uri) list($path) = explode('?', $_SERVER['REQUEST_URI']); @@ -114,7 +107,12 @@ function format_bytes($size, $precision=0) { // This function returns the mime type of $file. // function get_file_type($file) { - global $image_types, $movie_types; + // Various file type associations + $movie_types = array('mpg','mpeg','avi','asf','mp3','wav','mp4','wma','aif','aiff','ram', 'midi','mid','asf','au','flac'); + $image_types = array('jpg','jpeg','gif','png','tif','tiff','bmp','ico'); + $archive_types = array('zip','cab','7z','gz','tar.bz2','tar.gz','tar','rar',); + $document_types = array('txt','text','doc','docx','abw','odt','pdf','rtf','tex','texinfo',); + $font_types = array('ttf','otf','abf','afm','bdf','bmf','fnt','fon','mgf','pcf','ttc','tfm','snf','sfd'); $pos = strrpos($file, "."); if ($pos === false) { @@ -208,7 +206,7 @@ if($handle = @opendir($path)) { ); } } - fclose($handle); + closedir($handle); } // Show sort methods @@ -221,7 +219,7 @@ $header['size'] = "Size"; $header['file_type'] = "Type"; foreach($header as $key=>$item) { - if($_GET['sort'] == $key) { + if(@$_GET['sort'] == $key) { print "".$item.""; } else { print "".$item.""; @@ -285,7 +283,6 @@ print "
Lighttpd Enhanced Directory Listing Script
".$frontend_url_text."
-
". $_ENV['SERVER_SOFTWARE'] . "