October 2, 2022

Gallery

$value) { $ini[$key] = $value; } unset($ini_override); }//if (@is_readable( }//while (count($possible_ini_places unset($possible_ini_places, $current_search_path, $current_config); }//if ($ini[‘enable_nested_ini’] //set default options if it absent in ini file of file doesn’t exists if (!isset($ini[‘cols’])) { $ini[‘cols’] = 4; } if (!isset($ini[‘rows’])) { $ini[‘rows’] = 6; } if (!isset($ini[‘enable_albums_listing’])) { $ini[‘enable_albums_listing’] = 1; } if (!isset($ini[‘enable_albums_thumbs’])) { $ini[‘enable_albums_thumbs’] = 1; } if (!isset($ini[‘albums_thumbs_index’])) { $ini[‘albums_thumbs_index’] = “index”; } if (!isset($ini[‘enable_index_image_hide’])) { $ini[‘enable_index_image_hide’] = 1; } if (!isset($ini[‘albums_cols’])) { $ini[‘albums_cols’] = 2; } if (!isset($ini[‘enable_albums_mtime_sort’])) { $ini[‘enable_albums_mtime_sort’] = 0; } if (!isset($ini[‘enable_albums_reverse_sort’])) { $ini[‘enable_albums_reverse_sort’] = 0; } if (!isset($ini[‘enable_files_mtime_sort’])) { $ini[‘enable_files_mtime_sort’] = 0; } if (!isset($ini[‘enable_files_reverse_sort’])) { $ini[‘enable_files_reverse_sort’] = 0; } if (!isset($ini[‘albums’])) { $ini[‘albums’] = 50; } if (!isset($ini[‘enable_additional_listing’])) { $ini[‘enable_additional_listing’] = 1; } if (!isset($ini[‘additionals’])) { $ini[‘additionals’] = 20; } if (!isset($ini[‘enable_album_zip’])) { $ini[‘enable_album_zip’] = 0; } if (!isset($ini[‘enable_new_window’])) { $ini[‘enable_new_window’] = 0; } if (!isset($ini[‘enable_size_lookup’])) { $ini[‘enable_size_lookup’] = 1; } if (!isset($ini[‘enable_description’])) { $ini[‘enable_description’] = 1; } if (!isset($ini[‘enable_exif’])) { $ini[‘enable_exif’] = 1; } if (!isset($ini[‘enable_exif_date’])) { $ini[‘enable_exif_date’] = 0; } if (!isset($ini[‘enable_cell_border’])) { $ini[‘enable_cell_border’] = 1; } if (!isset($ini[‘enable_albums_edging’])) { $ini[‘enable_albums_edging’] = -1; } if (!isset($ini[‘description_filename’])) { $ini[‘description_filename’] = ‘desc.txt’; } if (!isset($ini[‘description_delimiter’])) { $ini[‘description_delimiter’] = ‘ ‘; } if (!isset($ini[‘enable_omit_ext’])) { $ini[‘enable_omit_ext’] = 1; } if (!isset($ini[‘enable_filename_display’])) { $ini[‘enable_filename_display’] = 1; } if (!isset($ini[‘enable_filename_cleaning’])) { $ini[‘enable_filename_cleaning’] = 1; } if (!isset($ini[‘enable_html_container’])) { $ini[‘enable_html_container’] = 1; } if (!isset($ini[‘enable_slideshow’])) { $ini[‘enable_slideshow’] = 1; } if (!isset($ini[‘slideshow_delay’])) { $ini[‘slideshow_delay’] = 3; } if (!isset($ini[‘charset’])) { $ini[‘charset’] = ‘windows-1251’; } if (!isset($ini[‘jpeg_quality’])) { $ini[‘jpeg_quality’] = 80; } if (!isset($ini[‘hidden_prefix’])) { $ini[‘hidden_prefix’] = ‘.’; } if (!isset($ini[‘enable_custom_container’])) { $ini[‘enable_custom_container’] = 0; } if (!isset($ini[‘cache_dir’])) { $ini[‘cache_dir’] = “weatimages-cache”; } if (!isset($ini[‘external_css’])) { $ini[‘external_css’] = ”; } if (!isset($ini[‘langpack’])) { $ini[‘langpack’] = ”; } if (!isset($ini[‘enable_compatibility_mode’])) { $ini[‘enable_compatibility_mode’] = 0; } if (!isset($ini[‘thumb_size’])) { $ini[‘thumb_size’] = 150; } if (!isset($ini[‘enable_thumbs_cache’])) { $ini[‘enable_thumbs_cache’] = 1; } if (!isset($ini[‘enable_resize’])) { $ini[‘enable_resize’] = 1; } if (!isset($ini[‘resize_size’])) { $ini[‘resize_size’] = 800; } if (!isset($ini[‘enable_smart_resize’])) { $ini[‘enable_smart_resize’] = 1; } if (!isset($ini[‘default_size_resize’])) { $ini[‘default_size_resize’] = 1; } if (!isset($ini[‘enable_resize_cache’])) { $ini[‘enable_resize_cache’] = 1; } //proccess options dependences // if ‘enable_resize’ disabled, we should to disable remaining resizing options if (!$ini[‘enable_resize’]) { $ini[‘resize_size’] = 0; $ini[‘enable_smart_resize’] = 0; $ini[‘default_size_resize’] = 0; $ini[‘enable_resize_cache’] = 0; } //’enable_smart_resize’ feature requires ‘enable_size_lookup’ option enabled if (!$ini[‘enable_size_lookup’]) { $ini[‘enable_smart_resize’] = 0; } //’enable_omit_ext’ feature is reasonable only when descriptions enabled if (!$ini[‘enable_description’]) { $ini[‘enable_omit_ext’] = 0; } //turn off exif lookup if exif module not found if ($ini[‘enable_exif’] && !extension_loaded(‘exif’)) { $ini[‘enable_exif’] = 0; $ini[‘enable_exif_date’] = 0; } if (!$ini[‘enable_html_container’]) { $ini[‘enable_slideshow’] = 0; } //Check for GD2 lib if (!function_exists(imagecopyresampled)) { echo “Fatal error: GD2 library is not presented”; exit; } //advanced options which aren’t included in ini file //Assume that thumbnail creation supported for next file extensions $ini[‘thumbnailable_exts’] = ‘jpg|jpeg|gif|png’; //Always ignore files with next extensions $ini[‘ignore_exts’] = ‘php|css|htm|html|sem’; //Array containing list of filenames which should be omitted during directory loading. Wildcards aren’t allowed. $ini[‘ignore_files’] = array(‘.’, ‘..’, $ini_ini_filename, $ini[‘description_filename’], $ini[‘cache_dir’], basename($_SERVER[‘SCRIPT_NAME’]), ‘.htaccess’, ‘.htpasswd’, ‘Thumbs.db’, ‘error_log’, ‘access_log’, ‘cgi-bin’, ‘_notes’); //EXIF comment strings which must be not shown. $ini[‘exif_comment_ignore_strings’] = array(‘MINOLTA DIGITAL CAMERA’, ‘KONICA MINOLTA DIGITAL CAMERA’, ‘OLYMPUS DIGITAL CAMERA’, ‘SAMSUNG DIGITAL CAMERA’, ‘DIGITAL CAMERA’, ‘SANYO DIGITAL CAMERA’, ‘Digital Camera’, ‘Toshiba Digital Camera’); //Formatting of the timestamp taken from EXIF tags $ini[‘exif_date_format’] = ‘d.m.Y H:i’; //Load langpack file if (” != $ini[‘langpack’] && ‘thumb’ != $_GET[‘action’] && ‘resize’ != $_GET[‘action’]) { @include($ini[‘langpack’]); } //begin html page function html_begin($title, $start, $header, $comment) { global $ini, $langpack; if (!$title || ‘.’ == $title) { $title = $langpack[‘albums’]; } ?> <?php echo $title ?> /pics/weatimages.css) $css_external_path = (‘/’ != dirname($_SERVER[‘SCRIPT_NAME’]) ? dirname($_SERVER[‘SCRIPT_NAME’]) : ” ) . ‘/’ . $css_external_path; $css_is_external = TRUE; } } if ( $css_is_external ) { print(‘‘); } else { //output built-in css ?> ‘ . $header . ‘
‘); } if ($comment) { print(‘
‘ . $comment . ‘
‘); } }//function html_begin( function html_end() { global $ini, $langpack; //You should not to remove the following software signature ?> $imagesize[1]) { //if width > height $resizedsize[0] = $max_size; //width $resizedsize[1] = ceil( ($imagesize[1] / $imagesize[0]) * $resizedsize[0] ); //calculate height } else { //if height > width $resizedsize[1] = $max_size; $resizedsize[0] = ceil( ($imagesize[0] / $imagesize[1]) * $resizedsize[1] ); } return $resizedsize; }//function calc_size_after_resize( //immediate image resizing function function resize_image ($image_input, $image_output, $max_size, $jpeg_quality) { //$image_input – path to file with original image //$image_output – path to file in which this function must to save resized image. if it empty then output image directly to browser //$max_size – maximal dimension of resulting image in pixels //$jpeg_quality – quality of resulting jpeg image $imagesize = getimagesize($image_input); if (!$imagesize) { fatal_error(“Fatal error: getimagesize($image_input) failed”); } if (0 == $imagesize[0] || 0 == $imagesize[1]) { fatal_error(“Fatal error: zero size happened”); } $resizedsize = calc_size_after_resize($imagesize, $max_size); //create image from source file $image_type_string = NULL; // image type = gif|jpeg|png switch ($imagesize[2]) { //find out a format of source image case 1: //gif $image = imagecreatefromgif($image_input); $image_type_string = ‘gif’; break; case 2: //jpg $image = imagecreatefromjpeg($image_input); $image_type_string = ‘jpeg’; break; case 3: //png $image = imagecreatefrompng($image_input); $image_type_string = ‘png’; break; default: //unknown image type fatal_error(“Fatal error: unsupported file type”); $image_type_string = ‘unknown’; } if (!$image) { fatal_error(“Fatal error: cannot create image from source”); } $resized = imagecreatetruecolor($resizedsize[0], $resizedsize[1]); @imagealphablending($resized, false); @imagesavealpha($resized, true); imagecopyresampled($resized, $image, 0, 0, 0, 0, $resizedsize[0], $resizedsize[1], $imagesize[0], $imagesize[1]); if (!$image_output) { //in this case we output image directly to the browser header(‘Content-Type: image/’.$image_type_string); } switch ($imagesize[2]) { case 1: //gif @imagegif($resized, $image_output); break; case 2: //jpg @imagejpeg($resized, $image_output, $jpeg_quality); break; case 3: //png @imagepng($resized, $image_output); break; } }//function resize_image ( //manages images resizing proccess and perform caching of resized images function resize_manager($image_input, $max_size, $cache_suffix, $is_cache_enabled) { //$image_input – path to file with original image //$max_size – maximal dimension of resulting image in pixels //$cache_suffix – suffix used to get filename of cached thumbnail from source image filename //$is_cache_enabled – indicates enabled or disabled caching of resized images global $ini; if (!@is_readable($image_input)) { fatal_error(“Fatal error: requested image is not readable”); } $is_resized_sent = FALSE; if ($is_cache_enabled) { $file_cache = $ini[‘cache_dir’] . ‘/’ . $image_input . $cache_suffix; if (!@is_readable($file_cache)) { //thumbnail file still don’t exists $file_cache_dir = dirname($file_cache); if (!@is_dir($file_cache_dir)) { //we need to create a copy of directories tree under cache directory $dirs_must_exist = array($file_cache_dir); while (‘.’ != $dirs_must_exist[count($dirs_must_exist)-1] && ‘/’ != $dirs_must_exist[count($dirs_must_exist)-1]) { array_push( $dirs_must_exist, dirname($dirs_must_exist[count($dirs_must_exist)-1]) ); } array_pop($dirs_must_exist); while (count($dirs_must_exist) > 0) { $tmp_dir_new = array_pop($dirs_must_exist); if (@is_dir($tmp_dir_new)) { continue; } @mkdir($tmp_dir_new, 0777); @chmod($tmp_dir_new, 0777); clearstatcache(); } } if (@is_writable(dirname($file_cache))) { $file_mutex = $ini[‘cache_dir’] . ‘/’ . ‘weatimages-mutex’;//we allow only single image resizing proccess in a time to avoid memory issues on the server $FP = @fopen($file_mutex, ‘r’); if (FALSE === $FP) { $FP = @fopen($file_mutex, ‘w’); @chmod($file_mutex, 0666); } @flock($FP, LOCK_EX); resize_image($image_input, $file_cache, $max_size, $ini[‘jpeg_quality’]); @chmod($file_cache, 0666); @flock($FP, LOCK_UN); @fclose($FP); } clearstatcache(); }//if (!@is_readable($file_cache)) { if (@is_readable($file_cache)) { //check that we successfully created thumbnail file at the previous step header(‘Content-Type: image/jpeg’); readfile($file_cache); $is_resized_sent = TRUE; }//if (@is_readable($file_cache)) { } if (!$is_resized_sent) { //we still don’t have cached image. Let’s resize image and output result to user’s browser resize_image($image_input, NULL, $max_size, $ini[‘jpeg_quality’]); } }//function resize_manager( //show pages-navigation-bar on thumbnails page if there are more then one page function show_pages_navigator($objects_count, $objects_on_page, $page_current, $page_query_string) { //$objects_count – total objects amount //$objects_on_page – amount of objects on a single page //$page_current – current page number //$page_query_string – string used as pagenumber variable name in http query global $ini, $langpack, $SERVER_PHP_SELF; if ($objects_count > $objects_on_page) { print(‘
‘ . $langpack[‘page’] . ‘:  ‘); //print link to previous page if current page isn’t first if (1 != $page_current) { print(‘‹  ‘); } for ($i = 1; $objects_count > ($i-1)*$objects_on_page; $i++) { if ($i != $page_current) { print(‘ ‘ . $i . ‘ ‘); } else { print(‘ ‘ . $i . ‘ ‘); } } //print link to next page if current page isn’t last if ( $objects_count > ($page_current*$objects_on_page) ) { print(‘  ›‘); } print(‘
‘); } }//function show_pages_navigator( //load descriptions from desc file if feature enabled and file exists function load_descriptions($REQUEST_PATH) { global $ini; $descs = array(); if ($ini[‘enable_description’]) { $desc_filefullname = $REQUEST_PATH . ‘/’ . $ini[‘description_filename’]; if (@is_readable($desc_filefullname)) { $desc_file = file($desc_filefullname); if (is_array($desc_file)) { foreach ($desc_file as $line) { list($filename, $desc) = explode($ini[‘description_delimiter’], trim($line), 2); $descs[$filename] = $desc; }//foreach ($desc_file as $line) { unset($desc_file); }//if (!is_array($desc_file) { }//if (@is_readable($desc_filefullname)) { }//if ($ini[‘enable_description’]) { return $descs; } //read directory contents and descriptions function load_directory($REQUEST_PATH, $include_index_image) { global $ini; if ( FALSE == ($dir = opendir($REQUEST_PATH)) ) { fatal_error(“Fatal error: path cannot be loaded”); } $pictures = $others = $dirs = array(); $pictures_mtime = $others_mtime = $dirs_mtime = array(); $descs = load_descriptions($REQUEST_PATH); //read directory – get arrays with names of objects situated in that directory $pictures_count = 0; $others_count = 0; $dirs_count = 0; while (FALSE !== ($file = readdir($dir))) { //sift out directory record which are not necessary images if (‘.’ == $file || ‘..’ == $file) { continue; } //sift out current directory and parental directory if (in_array($file, $ini[‘ignore_files’])) { continue; } //sift out descriptions file //don’t include hidden objects if ( $ini[‘hidden_prefix’] == substr($file, 0, strlen($ini[‘hidden_prefix’])) ) { continue; } if (is_dir($REQUEST_PATH . ‘/’ . $file)) { //we got an directory in directory contents listing if ($ini[‘enable_albums_mtime_sort’]) { $dirs_mtime[$dirs_count] = filemtime($REQUEST_PATH.’/’.$file); } $dirs[$dirs_count++] = $file; continue; } //try to find image description (for file without extension) for substituting to absent description (for file with extension) if ($ini[‘enable_omit_ext’]) { $filename_without_ext = preg_replace(‘/\.[^\.]+$/’, ”, $file); if (!array_key_exists($file, $descs)) { if (array_key_exists($filename_without_ext, $descs)) { $descs[$file] = $descs[$filename_without_ext]; } } if (!array_key_exists($file.’.’, $descs)) { if (array_key_exists($filename_without_ext.’.’, $descs)) { $descs[$file.’.’] = $descs[$filename_without_ext.’.’]; } } }//if ($ini[‘enable_description’] && !array_key_exists($pictures[$i], $descs)) { if (preg_match(‘/\.(‘ . $ini[‘thumbnailable_exts’] . ‘)$/i’, $file)) {//include files with image extensions only if ($ini[‘enable_files_mtime_sort’]) { $pictures_mtime[$pictures_count] = filemtime($REQUEST_PATH.’/’.$file); } if ((!$include_index_image && $ini[‘enable_index_image_hide’]) && ($ini[‘albums_thumbs_index’].’.jpg’ == $file || $ini[‘albums_thumbs_index’].’.jpeg’ == $file || $ini[‘albums_thumbs_index’].’.png’ == $file || $ini[‘albums_thumbs_index’].’.gif’ == $file) ) { continue; } $pictures[$pictures_count++] = $file; continue; } if (preg_match(‘/\.(‘ . $ini[‘ignore_exts’] . ‘)$/i’, $file)) {//ignore files with always-dont-show extensions continue; } if ($ini[‘enable_files_mtime_sort’]) { $others_mtime[$others_count] = filemtime($REQUEST_PATH.’/’.$file); } $others[$others_count++] = $file; //we got an non-image (not thumbnailable) and non-directory item }//while (FALSE !== ($file = readdir($dir))) { closedir($dir); //sort images and other files if ($ini[‘enable_files_mtime_sort’]) { array_multisort($pictures_mtime, SORT_NUMERIC, (!$ini[‘enable_files_reverse_sort’])?SORT_ASC:SORT_DESC, $pictures, SORT_STRING, SORT_ASC); array_multisort($others_mtime, SORT_NUMERIC, (!$ini[‘enable_files_reverse_sort’])?SORT_ASC:SORT_DESC, $others, SORT_STRING, SORT_ASC); } else { if (!$ini[‘enable_files_reverse_sort’]) { sort($pictures, SORT_STRING); sort($others, SORT_STRING); } else { rsort($pictures, SORT_STRING); rsort($others, SORT_STRING); } } //sort albums if ($ini[‘enable_albums_mtime_sort’]) { array_multisort($dirs_mtime, SORT_NUMERIC, (!$ini[‘enable_albums_reverse_sort’])?SORT_ASC:SORT_DESC, $dirs, SORT_STRING, SORT_ASC); } else { if (!$ini[‘enable_albums_reverse_sort’]) { sort($dirs, SORT_STRING); } else { rsort($dirs, SORT_STRING); } } return array($pictures, $others, $dirs, $descs); }//function load_directory($REQUEST_PATH) { //checks exif comment text function is_exif_text_bad(&$exif_text) { global $ini; $exif_text = preg_replace(‘/^[\x00\s]+/’, ”, $exif_text);//cut spaces at the beginning $exif_text = preg_replace(‘/[\x00\s]+$/’, ”, $exif_text);//cut trailing spaces $search_result = array_search($exif_text, $ini[‘exif_comment_ignore_strings’]); if ( false !== $search_result && NULL !== $search_result) { $exif_text = ”; }//array_search in php<4.2 returns NULL instead of false if not found if ( preg_match('/[\.,:\-\?\S\x00]/', $exif_text) ) { return false; } else { return true; } } //get image size, size after resize, resize expediency, and EXIF data //returns array($filesize_kb, $imagesize, $resizesize, $is_resize_senseless); function get_image_sizes($image_path) { global $ini; $exif_string = ''; $filesize_kb = 0; $imagesize = array(); if ($ini['enable_exif'] && preg_match('/\.(jpg|jpeg|tif|tiff)$/i', $image_path)){ $exif_desc = ''; $exif_comment = ''; $exif_data = @exif_read_data($image_path, false, true, false); //try to get description from exif. it may be contained in various exif sections if ( is_exif_text_bad($exif_desc) && isset($exif_data['IFD0']['Title']) && extension_loaded('mbstring') ) { //Title given by Windows Explorer, UNICODE $exif_desc = @mb_convert_encoding($exif_data['IFD0']['Title'], strtoupper($ini['charset']), 'UCS-2LE'); } if ( is_exif_text_bad($exif_comment) && isset($exif_data['IFD0']['Comments']) && extension_loaded('mbstring') ) { //Comment given by Windows Explorer, UNICODE $exif_comment = @mb_convert_encoding($exif_data['IFD0']['Comments'], strtoupper($ini['charset']), 'UCS-2LE'); } if ( is_exif_text_bad($exif_comment) && isset($exif_data['EXIF']['UserComment']) && extension_loaded('mbstring') ) { //UserComment given by ACDSee, UNICODE $comment_field = $exif_data['EXIF']['UserComment']; if (is_array($comment_field)) { $comment_field = ''; } // there was one occurence of getting array from UserComment, ignoring such data to not get php warnings for next line if (preg_match('/^([^\0]+?)\0(.+)$/', $comment_field, $matches) ) { //now $matches[1] contains encoding of the comment (unicode most likely), $matches[2] - comment in this encoding if ('UNICODE' == $matches[1]) { $matches[1] = 'UCS-2LE'; } $exif_comment = @mb_convert_encoding($matches[2], strtoupper($ini['charset']), $matches[1]); } } if ( is_exif_text_bad($exif_desc) && isset($exif_data['IFD0']['ImageDescription']) ) { //ImageDescription given by ACDSee, non-UNICODE, international characters saved $exif_desc = $exif_data['IFD0']['ImageDescription']; } if ( is_exif_text_bad($exif_desc) && isset($exif_data['WINXP']['Title']) ) { //Title given by Windows Explorer, non-UNICODE $exif_desc = $exif_data['WINXP']['Title']; } if ( is_exif_text_bad($exif_comment) && isset($exif_data['WINXP']['Comments']) ) { //Comment given by Windows Explorer, non-UNICODE $exif_comment = $exif_data['WINXP']['Comments']; } if ( is_exif_text_bad($exif_comment) && isset($exif_data['COMPUTED']['UserComment']) ) { //UserComment given by ACDSee, autoconverted to ASCII probably with national characters loss $exif_comment = $exif_data['COMPUTED']['UserComment']; } if (!is_exif_text_bad($exif_desc) && !is_exif_text_bad($exif_comment)) { $exif_string = $exif_desc . '
‘ . $exif_comment; } else if (!is_exif_text_bad($exif_desc)) { $exif_string = $exif_desc; } else if (!is_exif_text_bad($exif_comment)) { $exif_string = $exif_comment; } //try to get filesize from exif if ( isset($exif_data[‘FILE’][‘FileSize’]) ) { $filesize_kb = $exif_data[‘FILE’][‘FileSize’]; } //try to get image dimensions from exif if ( isset($exif_data[‘COMPUTED’][‘Width’]) && isset($exif_data[‘COMPUTED’][‘Height’]) ) { $imagesize[0] = $exif_data[‘COMPUTED’][‘Width’]; $imagesize[1] = $exif_data[‘COMPUTED’][‘Height’]; } //try to get date picture taken if ( $ini[‘enable_exif_date’] && isset($exif_data[‘EXIF’][‘DateTimeOriginal’]) && preg_match(‘/^(\d\d\d\d):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)$/’, $exif_data[‘EXIF’][‘DateTimeOriginal’], $matches) ) { $unixtime = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); if ($unixtime > 0) { $exif_string = (is_exif_text_bad($exif_string)?”:$exif_string.’
‘) . date($ini[‘exif_date_format’], $unixtime); } } } if (!$filesize_kb) { $filesize_kb = @filesize($image_path); } $filesize_kb = ceil($filesize_kb / 1024); if (0 == $imagesize[0] || 0 == $imagesize[1]) { $imagesize = @getimagesize($image_path); } $resizesize = calc_size_after_resize($imagesize, $ini[‘resize_size’]); $is_resize_senseless = FALSE; if (($resizesize[0] >= $imagesize[0]) && $ini[‘enable_smart_resize’]) { $is_resize_senseless = TRUE; } return array($filesize_kb, $imagesize, $resizesize, $is_resize_senseless, $exif_string); }//function get_image_sizes( //output cell with thumbnail and image info function show_thumbnail_cell($uri_original, $uri_resize, $uri_thumb, $filesize_kb, $imagesize, $resizesize, $is_resize_senseless, $filename, $desc) { global $ini, $langpack; $thumbsize = 0; if ($ini[‘enable_size_lookup’]) {//get thumbnail width and height $thumbsize = calc_size_after_resize($imagesize, $ini[‘thumb_size’]); } if ($ini[‘enable_size_lookup’] && $ini[‘default_size_resize’] && $is_resize_senseless) { $uri_original .= ‘&preferredsize=resize’; } print(‘‘ . ‘‘ . ‘' . $filename . '‘ . ‘‘ . ($ini[‘enable_filename_display’] ? ‘
‘ . wordwrap(clean_filename($filename), 30, ‘
‘, 1) . ‘
‘ : ”) . ( ($ini[‘enable_resize’] || $ini[‘enable_size_lookup’]) ? ‘‘ : ” )//( ($ini[‘enable_resize’] || $ini[‘enable_size_lookup’]) ? . (($ini[‘enable_description’] && $desc) ? ‘
‘ . $desc . ‘
‘ : ”) . ‘‘ );//print(‘ ‘ . $langpack[‘return_to_album’] . ‘‘); } }//function print_expanded_album_link( //Prints navigation bar for expanded view function print_expanded_navigation($album_path, &$pictures, $i) { //$album_path – relative path to album //&$pictures – referencr to array containing picture filenames //$i – index of current image in array global $ini, $langpack; //show links to first and last images, and to thumbnail page print(‘
‘); //create link to first image in album, only if current image isn’t first if ($ini[‘enable_slideshow’]) { echo ‘‘; //create link to thumbnail page (exactly to page number on which located current image) echo ‘‘; //create link to last image in album, if current image isn’t last echo ‘‘; echo ‘‘; }//if ($ini[‘enable_slideshow’]) { //create link to previous image, if exists echo ‘‘; //container for slideshow controller if ($ini[‘enable_slideshow’]) { echo ‘‘; } else {//create link to thumbnail page echo ‘‘; } //create link to next image, if it exists echo ‘‘; print(‘
‘; if (0 != $i) {//if current image is not the first image, we’ll create link to first print(‘‘); print(‘‹‹  ‘ . $langpack[‘first_image’] . ‘ ‘); }//if (0 != $i) { echo ‘‘; $album_page = ceil(($i+1) / ($ini[‘cols’]*$ini[‘rows’])); //number of album page which contains thumbnail of current image print_expanded_album_link($album_path, $album_page, $pictures[$i]); echo ‘‘; $i_last = count($pictures) – 1; if ($i < $i_last) { print(' ‘ . $langpack[‘last_image’] . ‘  ››‘); print(‘‘); }//if ($pictures[$i+1]) { echo ‘
‘; if ($pictures[$i-1]) {//if previous image exists, we’ll create link to it print(‘‘); print(‘‹  ‘ . $langpack[‘previous_image’] . ‘ ‘); }//if ($pictures[$i-1]) { echo ‘ ‘; $album_page = ceil(($i+1) / ($ini[‘cols’]*$ini[‘rows’])); //number of album page which contains thumbnail of current image print_expanded_album_link($album_path, $album_page, $pictures[$i]); echo ‘‘; if ($pictures[$i+1]) { print(‘ ‘ . $langpack[‘next_image’] . ‘  ›‘); print(‘‘); }//if ($pictures[$i+1]) { echo ‘
‘); }//function print_expanded_navigation( //Output slideshow javascript code to the browser function print_slideshow() { global $ini, $langpack; if ($ini[‘enable_slideshow’]) { ?> ‘ . clean_filename($pictures[$i]) . ‘
‘); print(‘
‘ . $descs[$pictures[$i]] . ‘
‘); } else { print(‘
‘ . $descs[$pictures[$i]] . ‘
‘); } //show big image if (!$ini[‘enable_resize’]) { $is_resize_senseless_current = TRUE; }//resize really senseless when resize completely disabled list($uri_original, $uri_resize, /* $uri_thumb */) = get_image_urls(dirname($REQUEST_PATH), basename($REQUEST_PATH), FALSE); list($uri_original_contained, $uri_resize_contained, /* $uri_thumb */) = get_image_urls(dirname($REQUEST_PATH), basename($REQUEST_PATH), TRUE); print(‘
‘); if (‘original’ == $_GET[‘size’]) { print(‘' . $pictures[$i] . '‘); } else { print(‘' . $pictures[$i] . '‘); } print(‘
‘); if (!$is_resize_senseless_current) { print(‘
‘); if (‘original’ == $_GET[‘size’]) { print(‘‘ . $langpack[‘switch_size_toresized’] . ‘‘); } else { print(‘‘ . $langpack[‘switch_size_tofullsize’] . ‘‘); } print(‘
‘); } //Show last description if ($descs[$pictures[$i].’.’]) { print(‘
‘ . $descs[$pictures[$i].’.’] . ‘
‘); } html_end(); }//function page_big( function zip_directory($path) { global $ini; if (‘.’ != $path) { $zip_filename = preg_replace(‘|/|’, ‘-‘, $path) . ‘.zip’; } else { $zip_filename = ‘Album.zip’; } $zip_fullpath = dirname(__FILE__) . ‘/’ . $ini[‘cache_dir’] . ‘/’ . $zip_filename; $zip_url = (isset($_SERVER[‘HTTPS’]) ? ‘https://’ : ‘http://’) . $_SERVER[“HTTP_HOST”] . dirname($_SERVER[‘SCRIPT_NAME’]) . ‘/’ . $ini[‘cache_dir’] . ‘/’ . $zip_filename; if (!is_file($zip_fullpath)) { if (is_writable($ini[‘cache_dir’])) { exec(‘zip -1Dj “‘ . $zip_fullpath . ‘” “‘ . dirname(__FILE__) . ‘/’ . $path . ‘/”* -x \*.php \*.css \*.ini \*.db’); } else { fatal_error(‘Cannot create archive within cache directory.’); } } header(‘Location: ‘ . $zip_url); }//function zip_directory($path) { if (‘thumb’ == $_GET[‘action’]) { //expected that in $REQUEST_PATH variable relative path to source image stored resize_manager($REQUEST_PATH, $ini[‘thumb_size’], ‘.thumb_’ . $ini[‘thumb_size’] . ‘_’ . $ini[‘jpeg_quality’] . ‘.cache’, $ini[‘enable_thumbs_cache’]); }//if (‘thumb’ == $_GET[‘action’]) { if (‘resize’ == $_GET[‘action’]) { //expected that in $REQUEST_PATH variable relative path to source image stored if (!$ini[‘enable_resize’]) { fatal_error(“Fatal error: operation not permitted”); } resize_manager($REQUEST_PATH, $ini[‘resize_size’], ‘.resize_’ . $ini[‘resize_size’] . ‘_’ . $ini[‘jpeg_quality’] . ‘.cache’, $ini[‘enable_resize_cache’]); }//if (‘resize’ == $_GET[‘action’]) { if (‘noimage’ == $_GET[‘action’]) { $image = imagecreatetruecolor($ini[‘thumb_size’], floor(0.75*$ini[‘thumb_size’])); $color_bg = imagecolorallocate($image, 255, 255, 255); imagefill($image, 0, 0, $color_bg); header(“Content-Type: image/png”); imagepng($image); imagedestroy($image); }//if (‘noimage’ == $_GET[‘action’]) { //show big image inside html page if (‘big’ == $_GET[‘action’]) { page_big(); }//if (‘big’ == $_GET[‘action’]) { if (‘zip’ == $_GET[‘action’]) { if ($ini[‘enable_album_zip’] && is_dir($REQUEST_PATH)) { zip_directory($REQUEST_PATH); } else { fatal_error(‘Operation not permitted’); } }//if (‘zip’ == $_GET[‘action’]) { //show page with thumbnails if correct path requested if (” == $_GET[‘action’]) { //do some simple checks if (!is_dir($REQUEST_PATH)) { fatal_error(‘Album not found’, $ini[‘enable_albums_listing’] ? ‘Try to start browsing from the root album.’ : ‘Check the album name and then try again.’); } //read directory contents and descriptions list($pictures, $others, $dirs, $descs) = load_directory($REQUEST_PATH, FALSE); $pictures_count = count($pictures); $others_count = count($others); $dirs_count = count($dirs); if (‘.’ != $REQUEST_PATH && !$descs[‘.’] && !$descs[‘..’]) {//try to get album description from descs-file in parental directory $parent_descs = load_descriptions(dirname($REQUEST_PATH)); $descs[‘.’] = $parent_descs[basename($REQUEST_PATH)]; } //show navigational links to all parental directories if ($ini[‘enable_albums_listing’] && ‘.’ != $REQUEST_PATH) { $link = ‘  /  ‘ . clean_filename(basename($REQUEST_PATH)); for ($path = dirname($REQUEST_PATH); ‘.’ != $path; $path = dirname($path)) { $link = ‘  /  ‘ . clean_filename(basename($path)) . ‘ ‘ . $link; } $link = ‘ ‘ . $langpack[‘albums’] . ‘ ‘ . $link; $link = ‘
‘ . $link; $link .= ‘
‘; }//if (‘.’ != $REQUEST_PATH) html_begin($descs[‘.’] ? $descs[‘.’] : basename($REQUEST_PATH), $link, ($descs[‘.’] || $ini[‘enable_albums_listing’]) ? $descs[‘.’] : basename($REQUEST_PATH), $descs[‘..’]); //show nested albums if ($ini[‘enable_albums_listing’] && $dirs_count > 0) { if ($_GET[‘page’] < 2 && $_GET['addspage'] < 2) {//show other items only if it is first thumbnails page $albumspage = ($_GET['albumspage'] > 0) ? $_GET[‘albumspage’] : 1; show_pages_navigator($dirs_count, $ini[‘albums’], $albumspage, ‘albumspage’); $bound_low = $ini[‘albums’] * ($albumspage – 1); //lowest index of $pictures[] which should be shown on current page $bound_high = ($ini[‘albums’] * $albumspage) – 1; //highest index of $pictures[] which should be shown on current page print(‘‘); print(‘‘ );//print( print(‘
‘ . ‘‘ . ‘‘ . ‘
‘ . $langpack[‘albums’] .’ 
‘ );//print(‘ print(‘‘); for ($i = 0; $i < $dirs_count; $i++) { if ($i < $bound_low) { continue; } //we still don't reached file which must be first on current page if ($i > $bound_high) { break; } //last file on current page was shown on previous iteration $uri_target = url_compat($SERVER_PHP_SELF . $dirs[$i]); if (0 == $i%$ini[‘albums_cols’]) { print(‘‘); } if ($ini[‘enable_albums_thumbs’]) { $nested_uri_thumb = get_album_thumb(‘./’.$REQUEST_PATH.’/’.$dirs[$i]); if (!$nested_uri_thumb[0]) { $nested_uri_thumb[0] = $SERVER_PHP_SELF . ‘?action=noimage’; $nested_uri_thumb[1][0] = $ini[‘thumb_size’]; $nested_uri_thumb[1][1] = ceil(0.75*$ini[‘thumb_size’]); } print(‘‘ );//print( } //if (!$ini[‘enable_albums_thumbs’]) { else { print(‘‘ );//print( } //if (!$ini[‘enable_albums_thumbs’]) { ELSE if ((0 == ($i+1)%$ini[‘albums_cols’]) || ($i == $dirs_count-1)) { print(‘‘); } }//for ($i = 0; $i < $others_count; $i++) { print('
‘ . ‘'.$dirs[$i].'‘ . ‘‘.clean_filename($dirs[$i]).’
‘.$descs[$dirs[$i]].’
‘ . ‘‘ . ‘‘ . ( $descs[$dirs[$i]] ? ‘‘ : ”) . ‘
» ‘ . clean_filename($dirs[$i]) . ‘ : ‘ . $descs[$dirs[$i]] . ‘
‘ . ‘
‘ . ‘
‘ . ‘
‘); show_pages_navigator($dirs_count, $ini[‘albums’], $albumspage, ‘albumspage’); print(‘
‘); }//if ($_GET[‘page’] < 2) else {//it is not first thumbnails page, so we only mention about other items existence print('‘); print(‘‘); } //get image sizes if size indication enabled if ($ini[‘enable_size_lookup’]) { list($filesize_kb, $imagesize, $resizesize, $is_resize_senseless, $exif_comment) = get_image_sizes($REQUEST_PATH . ‘/’ . $pictures[$i]); }//if ($ini[‘enable_size_lookup’]) { if (!$descs[$pictures[$i]] && $exif_comment) { $descs[$pictures[$i]] = $exif_comment; } list($uri_original, $uri_resize, $uri_thumb) = get_image_urls($REQUEST_PATH, $pictures[$i], $ini[‘enable_html_container’]); if ($ini[‘enable_html_container’]) {//tell html container that it can return to thumbnails page simply using history.back() javascript call $uri_original .= ‘&fromthumbnail=true’; $uri_resize .= ‘&fromthumbnail=true’; } show_thumbnail_cell($uri_original, $uri_resize, $uri_thumb, $filesize_kb, $imagesize, $resizesize, $is_resize_senseless, $pictures[$i], $descs[$pictures[$i]]); if ($new_row_indicator == $ini[‘cols’] || $i == $pictures_count – 1) { //we need to close row if number of columns reached or it was last image print(‘‘); $new_row_indicator = 0; } }//for ($i = 0; $i < $pictures_count; $i++) { print('
‘ . ‘‘); $bound_low = $images_on_page * ($page – 1); //lowest index of $pictures[] which should be shown on current page $bound_high = ($images_on_page * $page) – 1; //highest index of $pictures[] which should be shown on current page $new_row_indicator = 0; //counter for decision when new row must be started for ($i = 0; $i < $pictures_count; $i++) { if ($i < $bound_low) { continue; } //we still don't reached file which must be first on current page if ($i > $bound_high) { break; } //last file on current page was shown on previous iteration if (0 == $new_row_indicator++) {//we need to begin new table row print(‘
‘); show_pages_navigator($pictures_count, $images_on_page, $page, ‘page’); }//if ($pictures_count > 0) { if ($ini[‘enable_album_zip’] && ($pictures_count > 0 || ($ini[‘enable_additional_listing’] && $others_count > 0))) { print (‘‘ ); } //show links to non-thumbnailable items if ($ini[‘enable_additional_listing’] && $others_count > 0) { print(‘‘); if ($_GET[‘page’] < 2 && $_GET['albumspage'] < 2) {//show other items only if it is first thumbnails page $addspage = ($_GET['addspage'] > 0) ? $_GET[‘addspage’] : 1; $bound_low = $ini[‘additionals’] * ($addspage – 1); //lowest index of $pictures[] which should be shown on current page $bound_high = ($ini[‘additionals’] * $addspage) – 1; //highest index of $pictures[] which should be shown on current page print(‘‘ );//print( }//if ($_GET[‘page’] < 2 && $_GET['albumspage'] < 2) { else {//it is not first thumbnails page, so we only mention about other items existence print('
‘ . ‘‘ . ‘‘ . ‘
‘ . $langpack[‘additional_items’] . ‘ 
‘ );//print(‘ print(‘‘); for ($i = 0; $i < $others_count; $i++) { if ($i < $bound_low) { continue; } //we still don't reached file which must be first on current page if ($i > $bound_high) { break; } //last file on current page was shown on previous iteration list($uri_original, /* $uri_resize */, /* $uri_thumb */) = get_image_urls($REQUEST_PATH, $others[$i], FALSE); $filesize_kb = ceil(filesize($REQUEST_PATH . ‘/’ . $others[$i]) / 1024); print(‘‘ );//print( }//for ($i = 0; $i < $others_count; $i++) { print('
‘ . ‘‘ . ‘‘ . ( $descs[$others[$i]] ? ‘‘ : ”) . ‘
» ‘ . $others[$i] . ‘ (‘ . $filesize_kb . $langpack[‘kilobytes’] . ‘)’ . ‘ : ‘ . $descs[$others[$i]] . ‘
‘ . ‘
‘ . ‘
‘ . ‘
‘ . ‘