[2] | 1 | <?php |
---|
[362] | 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | thumbnail.php | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
| 5 | // | application : PhpWebGallery <http://phpwebgallery.net> | |
---|
| 6 | // | branch : BSF (Best So Far) | |
---|
| 7 | // +-----------------------------------------------------------------------+ |
---|
| 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2004-02-11 23:20:38 +0000 (Wed, 11 Feb 2004) $ |
---|
| 10 | // | last modifier : $Author: z0rglub $ |
---|
| 11 | // | revision : $Revision: 362 $ |
---|
| 12 | // +-----------------------------------------------------------------------+ |
---|
| 13 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 14 | // | it under the terms of the GNU General Public License as published by | |
---|
| 15 | // | the Free Software Foundation | |
---|
| 16 | // | | |
---|
| 17 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 20 | // | General Public License for more details. | |
---|
| 21 | // | | |
---|
| 22 | // | You should have received a copy of the GNU General Public License | |
---|
| 23 | // | along with this program; if not, write to the Free Software | |
---|
| 24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 25 | // | USA. | |
---|
| 26 | // +-----------------------------------------------------------------------+ |
---|
[226] | 27 | include_once( './admin/include/isadmin.inc.php' ); |
---|
[26] | 28 | //------------------------------------------------------------------- functions |
---|
| 29 | // get_subdirs returns an array containing all sub directory names, |
---|
| 30 | // excepting : '.', '..' and 'thumbnail'. |
---|
| 31 | function get_subdirs( $dir ) |
---|
[2] | 32 | { |
---|
[26] | 33 | $sub_dirs = array(); |
---|
| 34 | if ( $opendir = opendir( $dir ) ) |
---|
[2] | 35 | { |
---|
[26] | 36 | while ( $file = readdir( $opendir ) ) |
---|
[2] | 37 | { |
---|
[26] | 38 | if ( $file != 'thumbnail' and $file != '.' |
---|
| 39 | and $file != '..' and is_dir( $dir.'/'.$file ) ) |
---|
[2] | 40 | { |
---|
[26] | 41 | array_push( $sub_dirs, $file ); |
---|
[2] | 42 | } |
---|
| 43 | } |
---|
| 44 | } |
---|
[26] | 45 | return $sub_dirs; |
---|
[2] | 46 | } |
---|
| 47 | |
---|
[26] | 48 | // get_images_without_thumbnail returns an array with all the picture names |
---|
| 49 | // that don't have associated thumbnail in the directory. Each picture name |
---|
| 50 | // is associated with the width, heigh and filesize of the picture. |
---|
[2] | 51 | function get_images_without_thumbnail( $dir ) |
---|
| 52 | { |
---|
[26] | 53 | $images = array(); |
---|
| 54 | if ( $opendir = opendir( $dir ) ) |
---|
[2] | 55 | { |
---|
[26] | 56 | while ( $file = readdir( $opendir ) ) |
---|
[2] | 57 | { |
---|
[26] | 58 | $path = $dir.'/'.$file; |
---|
| 59 | if ( is_image( $path, true ) ) |
---|
[2] | 60 | { |
---|
[26] | 61 | if ( !TN_exists( $dir, $file ) ) |
---|
[2] | 62 | { |
---|
[26] | 63 | $image_infos = getimagesize( $path ); |
---|
| 64 | $size = floor( filesize( $path ) / 1024 ). ' KB'; |
---|
| 65 | array_push( $images, array( 'name' => $file, |
---|
| 66 | 'width' => $image_infos[0], |
---|
| 67 | 'height' => $image_infos[1], |
---|
| 68 | 'size' => $size ) ); |
---|
[2] | 69 | } |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | return $images; |
---|
| 74 | } |
---|
[26] | 75 | |
---|
| 76 | // scandir scans a dir to find pictures without thumbnails. Once found, |
---|
| 77 | // creation of the thumbnails (RatioResizeImg). Only the first $_POST['n'] |
---|
| 78 | // pictures without thumbnails are treated. |
---|
| 79 | // scandir returns an array with the generation time of each thumbnail (for |
---|
| 80 | // statistics purpose) |
---|
| 81 | function scandir( $dir, $width, $height ) |
---|
[2] | 82 | { |
---|
[26] | 83 | global $conf; |
---|
| 84 | $stats = array(); |
---|
| 85 | if ( $opendir = opendir( $dir ) ) |
---|
[2] | 86 | { |
---|
[26] | 87 | while ( $file = readdir ( $opendir ) ) |
---|
[2] | 88 | { |
---|
[26] | 89 | $path = $dir.'/'.$file; |
---|
| 90 | if ( is_image( $path, true ) ) |
---|
[2] | 91 | { |
---|
[26] | 92 | if ( count( $stats ) < $_POST['n'] and !TN_exists( $dir, $file ) ) |
---|
[2] | 93 | { |
---|
[26] | 94 | $starttime = get_moment(); |
---|
| 95 | $info = RatioResizeImg( $file, $width, $height, $dir.'/', 'jpg' ); |
---|
| 96 | $endtime = get_moment(); |
---|
| 97 | $info['time'] = ( $endtime - $starttime ) * 1000; |
---|
| 98 | array_push( $stats, $info ); |
---|
[2] | 99 | } |
---|
| 100 | } |
---|
| 101 | } |
---|
| 102 | } |
---|
[26] | 103 | return $stats; |
---|
[2] | 104 | } |
---|
[26] | 105 | |
---|
| 106 | // RatioResizeImg creates a new picture (a thumbnail since it is supposed to |
---|
| 107 | // be smaller than original picture !) in the sub directory named |
---|
| 108 | // "thumbnail". |
---|
| 109 | function RatioResizeImg( $filename, $newWidth, $newHeight, $path, $tn_ext ) |
---|
[2] | 110 | { |
---|
[26] | 111 | global $conf, $lang; |
---|
| 112 | // full path to picture |
---|
| 113 | $filepath = $path.$filename; |
---|
| 114 | // extension of the picture filename |
---|
| 115 | $extension = get_extension( $filepath ); |
---|
| 116 | switch( $extension ) |
---|
[2] | 117 | { |
---|
[26] | 118 | case 'jpg': $srcImage = @imagecreatefromjpeg( $filepath ); break; |
---|
| 119 | case 'JPG': $srcImage = @imagecreatefromjpeg( $filepath ); break; |
---|
| 120 | case 'png': $srcImage = @imagecreatefrompng( $filepath ); break; |
---|
| 121 | case 'PNG': $srcImage = @imagecreatefrompng( $filepath ); break; |
---|
| 122 | default : unset( $extension ); break; |
---|
[2] | 123 | } |
---|
| 124 | |
---|
[26] | 125 | if ( isset( $srcImage ) ) |
---|
[2] | 126 | { |
---|
[26] | 127 | // width/height |
---|
| 128 | $srcWidth = imagesx( $srcImage ); |
---|
| 129 | $srcHeight = imagesy( $srcImage ); |
---|
| 130 | $ratioWidth = $srcWidth/$newWidth; |
---|
[2] | 131 | $ratioHeight = $srcHeight/$newHeight; |
---|
[26] | 132 | |
---|
| 133 | // maximal size exceeded ? |
---|
| 134 | if ( ( $ratioWidth > 1 ) or ( $ratioHeight > 1 ) ) |
---|
[2] | 135 | { |
---|
[26] | 136 | if ( $ratioWidth < $ratioHeight) |
---|
[2] | 137 | { |
---|
| 138 | $destWidth = $srcWidth/$ratioHeight; |
---|
| 139 | $destHeight = $newHeight; |
---|
| 140 | } |
---|
| 141 | else |
---|
| 142 | { |
---|
| 143 | $destWidth = $newWidth; |
---|
| 144 | $destHeight = $srcHeight/$ratioWidth; |
---|
| 145 | } |
---|
| 146 | } |
---|
| 147 | else |
---|
| 148 | { |
---|
| 149 | $destWidth = $srcWidth; |
---|
| 150 | $destHeight = $srcHeight; |
---|
| 151 | } |
---|
[26] | 152 | // according to the GD version installed on the server |
---|
| 153 | if ( $_POST['gd'] == 2 ) |
---|
[2] | 154 | { |
---|
[26] | 155 | // GD 2.0 or more recent -> good results (but slower) |
---|
[2] | 156 | $destImage = imagecreatetruecolor( $destWidth, $destHeight); |
---|
[26] | 157 | imagecopyresampled( $destImage, $srcImage, 0, 0, 0, 0, |
---|
| 158 | $destWidth,$destHeight,$srcWidth,$srcHeight ); |
---|
[2] | 159 | } |
---|
| 160 | else |
---|
| 161 | { |
---|
[26] | 162 | // GD prior to version 2 -> pretty bad results :-/ (but fast) |
---|
[2] | 163 | $destImage = imagecreate( $destWidth, $destHeight); |
---|
[26] | 164 | imagecopyresized( $destImage, $srcImage, 0, 0, 0, 0, |
---|
| 165 | $destWidth,$destHeight,$srcWidth,$srcHeight ); |
---|
[2] | 166 | } |
---|
| 167 | |
---|
| 168 | |
---|
[26] | 169 | if( !is_dir( $path.'thumbnail' ) ) |
---|
[2] | 170 | { |
---|
[26] | 171 | umask( 0000 ); |
---|
| 172 | mkdir( $path.'thumbnail', 0777 ); |
---|
[2] | 173 | } |
---|
[26] | 174 | $dest_file = $path.'thumbnail/'.$conf['prefix_thumbnail']; |
---|
| 175 | $dest_file.= get_filename_wo_extension( $filename ); |
---|
| 176 | $dest_file.= '.'.$tn_ext; |
---|
[2] | 177 | |
---|
[26] | 178 | // creation and backup of final picture |
---|
| 179 | imagejpeg( $destImage, $dest_file ); |
---|
| 180 | // freeing memory ressources |
---|
[2] | 181 | imagedestroy( $srcImage ); |
---|
| 182 | imagedestroy( $destImage ); |
---|
| 183 | |
---|
[26] | 184 | list( $width,$height ) = getimagesize( $filepath ); |
---|
| 185 | $size = floor( filesize( $filepath ) / 1024 ).' KB'; |
---|
| 186 | list( $tn_width,$tn_height ) = getimagesize( $dest_file ); |
---|
| 187 | $tn_size = floor( filesize( $dest_file ) / 1024 ).' KB'; |
---|
| 188 | $info = array( 'file' => $filename, |
---|
| 189 | 'width' => $width, |
---|
| 190 | 'height' => $height, |
---|
| 191 | 'size' => $size, |
---|
| 192 | 'tn_file' => $dest_file, |
---|
| 193 | 'tn_width' => $tn_width, |
---|
| 194 | 'tn_height' => $tn_height, |
---|
| 195 | 'tn_size' => $tn_size ); |
---|
[2] | 196 | return $info; |
---|
| 197 | } |
---|
[26] | 198 | // error |
---|
[2] | 199 | else |
---|
| 200 | { |
---|
| 201 | echo $lang['tn_no_support']." "; |
---|
[26] | 202 | if ( isset( $extenstion ) ) |
---|
[2] | 203 | { |
---|
[26] | 204 | echo $lang['tn_format'].' '.$extension; |
---|
[2] | 205 | } |
---|
| 206 | else |
---|
| 207 | { |
---|
| 208 | echo $lang['tn_thisformat']; |
---|
| 209 | } |
---|
| 210 | exit(); |
---|
| 211 | } |
---|
| 212 | } |
---|
[26] | 213 | |
---|
| 214 | // array_max returns the highest value of the given array |
---|
[2] | 215 | function array_max( $array ) |
---|
| 216 | { |
---|
[26] | 217 | sort( $array, SORT_NUMERIC ); |
---|
| 218 | return array_pop( $array ); |
---|
[2] | 219 | } |
---|
[26] | 220 | |
---|
| 221 | // array_min returns the lowest value of the given array |
---|
[2] | 222 | function array_min( $array ) |
---|
| 223 | { |
---|
[26] | 224 | sort( $array, SORT_NUMERIC ); |
---|
| 225 | return array_shift( $array ); |
---|
[2] | 226 | } |
---|
[26] | 227 | |
---|
| 228 | // array_avg returns the average value of the array |
---|
| 229 | function array_avg( $array ) |
---|
[2] | 230 | { |
---|
| 231 | return array_sum( $array ) / sizeof( $array ); |
---|
| 232 | } |
---|
| 233 | |
---|
[26] | 234 | // get_displayed_dirs builds the tree of dirs under "galleries". If a |
---|
| 235 | // directory contains pictures without thumbnails, the become linked to the |
---|
| 236 | // page of thumbnails creation. |
---|
| 237 | function get_displayed_dirs( $dir, $indent ) |
---|
[2] | 238 | { |
---|
[26] | 239 | global $conf,$lang,$vtp,$sub; |
---|
[2] | 240 | |
---|
[26] | 241 | $sub_dirs = get_subdirs( $dir ); |
---|
[2] | 242 | // write of the dirs |
---|
[26] | 243 | foreach ( $sub_dirs as $sub_dir ) { |
---|
| 244 | $pictures = get_images_without_thumbnail( $dir.'/'.$sub_dir ); |
---|
| 245 | $vtp->addSession( $sub, 'dir' ); |
---|
| 246 | $vtp->setVar( $sub, 'dir.indent', $indent ); |
---|
| 247 | if ( count( $pictures ) > 0 ) |
---|
[2] | 248 | { |
---|
[26] | 249 | $vtp->addSession( $sub, 'linked' ); |
---|
| 250 | $url = './admin.php?page=thumbnail&dir='.$dir."/".$sub_dir; |
---|
| 251 | $vtp->setVar( $sub, 'linked.url', add_session_id( $url ) ); |
---|
| 252 | $vtp->setVar( $sub, 'linked.name', $sub_dir ); |
---|
| 253 | $vtp->setVar( $sub, 'linked.nb_pic', count( $pictures ) ); |
---|
| 254 | $vtp->closeSession( $sub, 'linked' ); |
---|
[2] | 255 | } |
---|
[26] | 256 | else |
---|
[2] | 257 | { |
---|
[26] | 258 | $vtp->addSession( $sub, 'unlinked' ); |
---|
| 259 | $vtp->setVar( $sub, 'unlinked.name', $sub_dir ); |
---|
| 260 | $vtp->closeSession( $sub, 'unlinked' ); |
---|
[2] | 261 | } |
---|
[26] | 262 | $vtp->closeSession( $sub, 'dir' ); |
---|
| 263 | // recursive call |
---|
[345] | 264 | get_displayed_dirs( $dir.'/'.$sub_dir, |
---|
| 265 | $indent+30 ); |
---|
[2] | 266 | } |
---|
| 267 | } |
---|
[26] | 268 | //----------------------------------------------------- template initialization |
---|
[225] | 269 | $sub = $vtp->Open( './template/'.$user['template'].'/admin/thumbnail.vtp' ); |
---|
[26] | 270 | $tpl = array( |
---|
| 271 | 'tn_dirs_title','tn_dirs_alone','tn_params_title','tn_params_GD', |
---|
| 272 | 'tn_params_GD_info','tn_width','tn_params_width_info','tn_height', |
---|
| 273 | 'tn_params_height_info','tn_params_create','tn_params_create_info', |
---|
| 274 | 'tn_params_format','tn_params_format_info','submit','tn_alone_title', |
---|
| 275 | 'filesize','tn_picture','tn_results_title','thumbnail', |
---|
| 276 | 'tn_results_gen_time','tn_stats','tn_stats_nb','tn_stats_total', |
---|
| 277 | 'tn_stats_max','tn_stats_min','tn_stats_mean' ); |
---|
| 278 | templatize_array( $tpl, 'lang', $sub ); |
---|
[29] | 279 | $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); |
---|
[26] | 280 | //----------------------------------------------------- miniaturization results |
---|
| 281 | if ( isset( $_GET['dir'] ) ) |
---|
[2] | 282 | { |
---|
[26] | 283 | $pictures = get_images_without_thumbnail( $_GET['dir'] ); |
---|
| 284 | if ( count( $pictures ) == 0 ) |
---|
[2] | 285 | { |
---|
[26] | 286 | $vtp->addSession( $sub, 'warning' ); |
---|
| 287 | $vtp->closeSession( $sub, 'warning' ); |
---|
[2] | 288 | } |
---|
[26] | 289 | elseif ( isset( $_POST['submit'] ) ) |
---|
[2] | 290 | { |
---|
[26] | 291 | // checking criteria |
---|
| 292 | $errors = array(); |
---|
| 293 | if ( !ereg( "^[0-9]{2,3}$", $_POST['width'] ) or $_POST['width'] < 10 ) |
---|
[2] | 294 | { |
---|
[26] | 295 | array_push( $errors, $lang['tn_err_width'].' 10' ); |
---|
[2] | 296 | } |
---|
[26] | 297 | if ( !ereg( "^[0-9]{2,3}$", $_POST['height'] ) or $_POST['height'] < 10 ) |
---|
[2] | 298 | { |
---|
[26] | 299 | array_push( $errors, $lang['tn_err_height'].' 10' ); |
---|
[2] | 300 | } |
---|
[26] | 301 | // picture miniaturization |
---|
| 302 | if ( count( $errors ) == 0 ) |
---|
[2] | 303 | { |
---|
[26] | 304 | $vtp->addSession( $sub, 'results' ); |
---|
| 305 | $stats = scandir( $_GET['dir'], $_POST['width'], $_POST['height'] ); |
---|
| 306 | $times = array(); |
---|
| 307 | foreach ( $stats as $stat ) { |
---|
| 308 | array_push( $times, $stat['time'] ); |
---|
[2] | 309 | } |
---|
[26] | 310 | $max = array_max( $times ); |
---|
| 311 | $min = array_min( $times ); |
---|
| 312 | foreach ( $stats as $i => $stat ) { |
---|
| 313 | $vtp->addSession( $sub, 'picture' ); |
---|
| 314 | if ( $i % 2 == 1 ) |
---|
[2] | 315 | { |
---|
[26] | 316 | $vtp->setVar( $sub, 'picture.class', 'row2' ); |
---|
[2] | 317 | } |
---|
[26] | 318 | $vtp->setVar( $sub, 'picture.num', ($i+1) ); |
---|
| 319 | $vtp->setVar( $sub, 'picture.file', $stat['file'] ); |
---|
| 320 | $vtp->setVar( $sub, 'picture.filesize', $stat['size'] ); |
---|
| 321 | $vtp->setVar( $sub, 'picture.width', $stat['width'] ); |
---|
| 322 | $vtp->setVar( $sub, 'picture.height', $stat['height'] ); |
---|
| 323 | $vtp->setVar( $sub, 'picture.thumb_file', $stat['tn_file'] ); |
---|
| 324 | $vtp->setVar( $sub, 'picture.thumb_filesize', $stat['tn_size'] ); |
---|
| 325 | $vtp->setVar( $sub, 'picture.thumb_width', $stat['tn_width'] ); |
---|
| 326 | $vtp->setVar( $sub, 'picture.thumb_height', $stat['tn_height'] ); |
---|
| 327 | $vtp->setVar( $sub, 'picture.time', |
---|
| 328 | number_format( $stat['time'], 2, '.', ' ').' ms' ); |
---|
| 329 | if ( $stat['time'] == $max ) |
---|
[2] | 330 | { |
---|
[26] | 331 | $vtp->setVar( $sub, 'picture.color', 'red' ); |
---|
[2] | 332 | } |
---|
[26] | 333 | else if ( $stat['time'] == $min ) |
---|
[2] | 334 | { |
---|
[26] | 335 | $vtp->setVar( $sub, 'picture.color', 'green' ); |
---|
[2] | 336 | } |
---|
[26] | 337 | $vtp->closeSession( $sub, 'picture' ); |
---|
[2] | 338 | } |
---|
[26] | 339 | // general statistics |
---|
| 340 | $vtp->setVar( $sub, 'results.stats_nb', count( $stats ) ); |
---|
| 341 | $vtp->setVar( $sub, 'results.stats_total', |
---|
| 342 | number_format( array_sum( $times ), 2, '.', ' ').' ms' ); |
---|
| 343 | $vtp->setVar( $sub, 'results.stats_max', |
---|
| 344 | number_format( $max, 2, '.', ' ').' ms' ); |
---|
| 345 | $vtp->setVar( $sub, 'results.stats_min', |
---|
| 346 | number_format( $min, 2, '.', ' ').' ms' ); |
---|
| 347 | $vtp->setVar( $sub, 'results.stats_mean', |
---|
| 348 | number_format( array_avg( $times ), 2, '.', ' ').' ms' ); |
---|
| 349 | $vtp->closeSession( $sub, 'results' ); |
---|
[2] | 350 | } |
---|
| 351 | else |
---|
| 352 | { |
---|
[26] | 353 | $vtp->addSession( $sub, 'errors' ); |
---|
| 354 | foreach ( $errors as $error ) { |
---|
| 355 | $vtp->addSession( $sub, 'li' ); |
---|
| 356 | $vtp->setVar( $sub, 'li.li', $error ); |
---|
| 357 | $vtp->closeSession( $sub, 'li' ); |
---|
| 358 | } |
---|
| 359 | $vtp->closeSession( $sub, 'errors' ); |
---|
[2] | 360 | } |
---|
| 361 | } |
---|
[26] | 362 | //-------------------------------------------------- miniaturization parameters |
---|
| 363 | if ( sizeof( $pictures ) != 0 ) |
---|
[2] | 364 | { |
---|
[26] | 365 | $vtp->addSession( $sub, 'params' ); |
---|
| 366 | $url = './admin.php?page=thumbnail&dir='.$_GET['dir']; |
---|
| 367 | $vtp->setVar( $sub, 'params.action', add_session_id( $url ) ); |
---|
| 368 | // GD version selected... |
---|
[345] | 369 | if ( isset( $_POST['gd'] ) and $_POST['gd'] == 1 ) |
---|
[2] | 370 | { |
---|
[26] | 371 | $vtp->setVar( $sub, 'params.gd1_checked', ' checked="checked"' ); |
---|
[2] | 372 | } |
---|
[26] | 373 | else |
---|
[2] | 374 | { |
---|
[26] | 375 | $vtp->setVar( $sub, 'params.gd2_checked', ' checked="checked"' ); |
---|
[2] | 376 | } |
---|
[26] | 377 | // width values |
---|
| 378 | if ( isset( $_POST['width'] ) ) |
---|
| 379 | { |
---|
| 380 | $vtp->setVar( $sub, 'params.width_value', $_POST['width'] ); |
---|
| 381 | } |
---|
[2] | 382 | else |
---|
| 383 | { |
---|
[26] | 384 | $vtp->setVar( $sub, 'params.width_value', '128' ); |
---|
[2] | 385 | } |
---|
[26] | 386 | // height value |
---|
| 387 | if ( isset( $_POST['height'] ) ) |
---|
[2] | 388 | { |
---|
[26] | 389 | $vtp->setVar( $sub, 'params.height_value', $_POST['height'] ); |
---|
[2] | 390 | } |
---|
| 391 | else |
---|
| 392 | { |
---|
[26] | 393 | $vtp->setVar( $sub, 'params.height_value', '96' ); |
---|
[2] | 394 | } |
---|
[26] | 395 | // options for the number of picture to miniaturize : "n" |
---|
| 396 | $options = array( 5,10,20,40 ); |
---|
[345] | 397 | if ( isset( $_POST['n'] ) ) $n = $_POST['n']; |
---|
| 398 | else $n = 5; |
---|
[26] | 399 | foreach ( $options as $option ) { |
---|
| 400 | $vtp->addSession( $sub, 'n_option' ); |
---|
| 401 | $vtp->setVar( $sub, 'n_option.option', $option ); |
---|
[345] | 402 | if ( $option == $n ) |
---|
[2] | 403 | { |
---|
[26] | 404 | $vtp->setVar( $sub, 'n_option.selected', ' selected="selected"' ); |
---|
[2] | 405 | } |
---|
[26] | 406 | $vtp->closeSession( $sub, 'n_option' ); |
---|
[2] | 407 | } |
---|
[26] | 408 | $vtp->closeSession( $sub, 'params' ); |
---|
| 409 | //---------------------------------------------------------- remaining pictures |
---|
| 410 | $vtp->addSession( $sub, 'remainings' ); |
---|
| 411 | $pictures = get_images_without_thumbnail( $_GET['dir'] ); |
---|
| 412 | $vtp->setVar( $sub, 'remainings.total', count( $pictures ) ); |
---|
| 413 | foreach ( $pictures as $i => $picture ) { |
---|
| 414 | $vtp->addSession( $sub, 'remaining' ); |
---|
| 415 | if ( $i % 2 == 1 ) |
---|
| 416 | { |
---|
| 417 | $vtp->setVar( $sub, 'remaining.class', 'row2' ); |
---|
| 418 | } |
---|
| 419 | $vtp->setVar( $sub, 'remaining.num', ($i+1) ); |
---|
| 420 | $vtp->setVar( $sub, 'remaining.file', $picture['name'] ); |
---|
| 421 | $vtp->setVar( $sub, 'remaining.filesize', $picture['size'] ); |
---|
| 422 | $vtp->setVar( $sub, 'remaining.width', $picture['width'] ); |
---|
| 423 | $vtp->setVar( $sub, 'remaining.height', $picture['height'] ); |
---|
| 424 | $vtp->closeSession( $sub, 'remaining' ); |
---|
| 425 | } |
---|
| 426 | $vtp->closeSession( $sub, 'remainings' ); |
---|
[2] | 427 | } |
---|
| 428 | } |
---|
[26] | 429 | //-------------------------------------------------------------- directory list |
---|
[2] | 430 | else |
---|
| 431 | { |
---|
[26] | 432 | $vtp->addSession( $sub, 'directory_list' ); |
---|
[228] | 433 | get_displayed_dirs( './galleries', 60 ); |
---|
[26] | 434 | $vtp->closeSession( $sub, 'directory_list' ); |
---|
[2] | 435 | } |
---|
[26] | 436 | //----------------------------------------------------------- sending html code |
---|
| 437 | $vtp->Parse( $handle , 'sub', $sub ); |
---|
[362] | 438 | ?> |
---|