From 1c59964dffbf3134c456df23b13eb1c2734c0bf3 Mon Sep 17 00:00:00 2001 From: z0rglub Date: Tue, 13 Jan 2004 22:36:56 +0000 Subject: Adding functions to retrieve all files from a directory into an array : - get_picture_files : returns an array with all picture files according to $conf['picture_ext'] - get_thumb_files : returns an array with all thumbnails according to $conf['picture_ext'] and $conf['prefix_thumbnail'] git-svn-id: http://piwigo.org/svn/branches/release-1_3@277 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/include/functions.php | 53 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'admin') diff --git a/admin/include/functions.php b/admin/include/functions.php index 0207bd9b8..ecab3782f 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -53,7 +53,58 @@ function is_image( $filename, $create_thumbnail = false ) } return false; } - + +/** + * returns an array with all picture files according to $conf['picture_ext'] + * + * @param string $dir + * @return array + */ +function get_picture_files( $dir ) +{ + global $conf; + + $pictures = array(); + if ( $opendir = opendir( $dir ) ) + { + while ( $file = readdir( $opendir ) ) + { + if ( in_array( get_extension( $file ), $conf['picture_ext'] ) ) + { + array_push( $pictures, $file ); + } + } + } + return $pictures; +} + +/** + * returns an array with all thumbnails according to $conf['picture_ext'] + * and $conf['prefix_thumbnail'] + * + * @param string $dir + * @return array + */ +function get_thumb_files( $dir ) +{ + global $conf; + + $prefix_length = strlen( $conf['prefix_thumbnail'] ); + + $thumbnails = array(); + if ( $opendir = @opendir( $dir ) ) + { + while ( $file = readdir( $opendir ) ) + { + if ( in_array( get_extension( $file ), $conf['picture_ext'] ) + and substr($file,0,$prefix_length) == $conf['prefix_thumbnail'] ) + { + array_push( $thumbnails, $file ); + } + } + } + return $thumbnails; +} function TN_exists( $dir, $file ) { -- cgit v1.2.3