\n \n Invalid request.\n \n"); } /*# +----------------------------------------------------------------------+ | Qdig - A Quick Digital Image Gallery | | Qdig is an easy-to-use script that dynamically creates an image | gallery or set of galleries from image files stored on a web server's | filesystem. Qdig supports subdirectory navigation for organized | presentation of any size image collection. Qdig also supports image | captions, and can generate thumbnail images and smaller resampled | versions of large images such as digital camera photos. Qdig is | simple to install, just drop it in a directory with images and/or | subdirectories that contain images. Converting (resampling) images | requires either Image Magick or PHP's GD extensions and some quick- | and-simple additional setup. There are dozens of configurable options | for customizing your galleries. The script runs stand-alone, or a | gallery may be included within another page. Enjoy! +----------------------------------------------------------------------+ | Copyright 2002, 2003, 2004, 2005, 2006 Hagan Fox | This program is distributed under the terms of the | GNU General Public License, Version 2 | | This program is free software; you can redistribute it and/or modify | it under the terms of the GNU General Public License, Version 2 as | published by the Free Software Foundation. | | This program is distributed in the hope that it will be useful, | but WITHOUT ANY WARRANTY; without even the implied warranty of | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | GNU General Public License for more details. | | You should have received a copy of the GNU General Public License, | Version 2 along with this program; if not, visit GNU's Home Page | http://www.gnu.org/ +----------------------------------------------------------------------+ CVS: $Id: index.php,v 1.123 2006/04/14 01:14:33 haganfox Exp $# */# $qdig_version = '20060414'; $mtime = microtime(); $mtime = explode(' ', $mtime); $start_time = $mtime[1] + $mtime[0]; define('Qdig', TRUE); // TODO Stabilize width of names view. // TODO CSS hilite for sidebar. /* +------------+ | Settings | +------------+ */ // Site Settings ------------------------------------------------------+ // See http://qdig.sourceforge.net/Settings/SiteSettings // The (optional) Site Link is a location (URL) and the title is the link text. $site_link['title'] = 'Home Page'; // Link text $site_link['url'] = ''; // URL - Using '' will disable the Site Link. // If Copyright text is set, the text will appear at the bottom of your gallery. // See http://www.whatiscopyright.org/ for information about copyrights. // $copyright['txt'] = 'Images copyright © 2004, 2005, 2006 original creators or assignees. All rights reserved.';# // The link to the admin script for editing captions is in the copyright area. $admin['ena'] = TRUE; // Safe to leave true if admin.php is not installed. // Layout Settings ----------------------------------------------------+ // These are in roughly the same order as they appear in the output. // See http://qdig.sourceforge.net/Settings/LayoutSettings /** * HTML Header * * These work for stand-alone mode only, since othewise headers are suppressed. */ $header['force_ena'] = FALSE; // Force HTML headers to be produced. $header['force_disa'] = FALSE; // Force HTML headers to be suppressed. $header['title_text_1'] = 'Image Gallery'; // Leading text in title (lang)# $header['title_delim'] = '|'; // Delimiter character(s) $header['title_cntr'] = TRUE; // Include an 'x of y' counter. $header['title_text_2'] = ''; // Trailing text in title $header['img_name'] = TRUE; // Include image name in title. $header['strip_ext'] = TRUE; // Strip the extension from it. $header['nav_links'] = TRUE; // Include nav. links in html header. $header['icon'] = TRUE; // Use the qdig-camera icon. $header['preload_next'] = TRUE; // Enable the preload-next-image function. /** * Default width * * The gallery table may end up wider than this. */ $default_nav_width = 560; // Default navigation element for gallery/directory // navigation rows and thumbnail/text link rows $width_margin_pct = 2.4; // Some "width margin" as a percentage (0 to 20) /** * Directory Navigation (Contains pwd and subdirectories.) */ $dir_nav['enable'] = TRUE; // Enable Directory Navigation. If disabled, // subdirectories will be isolated galleries. $dir_nav['small'] = FALSE; // Use small text for Dir. Navigation row. $dir_nav['fname_ena'] = FALSE; // Display the filename. $dir_nav['cntr_ena'] = TRUE; // Display the counter. $dir_nav['path_delim'] = '>'; // Delimiter between path elements $dir_nav['dir_is_new'] = 0 * 24 * 60 * 60; // New if less than this many seconds $dir_nav_lang_new = 'New';# $dir_nav['new_flag'] = "   $dir_nav_lang_new "; // String to display with dir name if "new" $dir_nav['sort_age'] = FALSE; // Sort directories by time-since-modified // (most recent first) rather than by alpha. $dir_nav['sort_rev'] = FALSE; // Reverse the sort order of directories. $dir_nav['icon'] = FALSE; // Display a camera icon in directory links. $dir_nav['updir_ena'] = TRUE; // Display an up-one-level link. $dir_nav['start_thm'] = FALSE; // Start in a dir with thumbs-only display (if // enabled), else jump to the first image. // The next two are for subdirectories-only pages $dir_nav['align_dirs'] = 'center'; // Text alignment (left/center/right). $dir_nav['size_of_image'] = TRUE; // Expand area to image-display size. /** * Control Bar (Contains visitor preferences: links style and default view) */ $ctrl_bar['enable'] = TRUE; // Enable control bar. $dir_nav['prefs_ena'] = TRUE; // Display a Preferences link, which toggles // the Control Bar for a more compact gallery. $ctrl_bar['vw_ctrl'] = TRUE; // Enable control bar Links Style chooser. $ctrl_bar['def_size'] = FALSE; // Enable control bar Default Size chooser. $ctrl_bar['small'] = TRUE; // Use small text for control bar. /** * Image Links Placement and Sorting */ $img_links['above'] = FALSE; // Locate image links (numerals, thumbnails) // above the image. Sensible default is below. $img_links['sort_date'] = FALSE; // Sort images by date, not alphabetically. $img_links['sort_rev'] = FALSE; // Sort images in reverse order. /** * Thumbnail Image Links */ $thumbs['enable'] = TRUE; // Enable thumbs view. Safe to leave TRUE. $thumbs['default'] = TRUE; // Default to thumbs view if thumbs-capable. $thumbs['onfly'] = TRUE; // Create thumbnails 'on the fly' in their // own request so pages load more quickly. // Wrapping -- Don't wrap only one or two thumbnails. $thmb_row['maxwidth'] = 0; // Approx. max. width of thumbnails row (0=default) $thmb_row['softwrap'] = 84; // A percentage, 80 to 99 // NEW! Thumbs-only View of Gallery Directories $thumbs['thm_only'] = TRUE; // Folder is thumbs-only if more than... $thumbs['t_o_imgs'] = 999; // ...this many images, or... $thumbs['t_o_rows'] = 2; // ...this many rows, whichever is smaller. $thumbs['t_o_h2w'] = 0.75; // Height-to-width ratio of an average image. // NEW! Vicinity Thumbs -- Show only a single row of thumbnail links. $thumbs['vicinity'] = TRUE; // Show only thumbs for "nearby" images. $thumbs['shift_by'] = 0; // Adjust the number of vicinity lead-in images. // TODO shift to right is limited. /** * Filename and Numeral Text Image Links */ $txtlinks_default = 'none'; // If no text-link type is specified, default // to name, num, or none. $namelinks['disa'] = FALSE; // Disable 'names' view option in the Control // Bar size chooser. (Avoids the sidebar.) $namelinks['small'] = TRUE; // Use small text for filename links. $namelinks['trunc'] = 15; // Number of filename characters to display // Numeral Text Image Links $nmrl_row['small'] = TRUE; // Use small text for numeral links. $nmrl_row['pad_top'] = '2px'; // padding above rows of numeral links // Wrapping -- Don't wrap only one or two links. $nmrl_row['maxcount'] = 20; // maximum number of numeral links per row $nmrl_row['softwrap'] = 85; // percentage, 80 to 100 /** * Upper Gallery Navigation Row immediately above the image * * If nothing on the row is enabled, the navigation row is omitted. */ $upr_nav['enable'] = TRUE; $upr_nav['tmp_size'] = FALSE; // Show resizing links. Overrides 'full_link'. $upr_nav['full_link'] = FALSE; // Show `Full Size' link if image is resized. $upr_nav['prv_next'] = TRUE; // Show `Previous' / `Next' links. $upr_nav['wrap'] = FALSE; // Wrap Next / Prev. at the last / first image. $upr_nav['frst_last'] = TRUE; // Show ` |<< ' and ` >>| ' links. $upr_nav['cntr'] = FALSE; // Show `x of y' counter if no $dir_nav counter. $upr_nav['cntr_bold'] = FALSE; // Bold font for `x of y' message $upr_nav['sml_txt'] = FALSE; // Use small text. $upr_nav['width'] = 0; // Width of this navRow's table (0=default) $upr_nav['padding'] = '1px 0px 2px 0px'; // CSS Padding for the row /** * Image Display */ // TODO External captions $caption['padding'] = '3px'; // CSS padding around caption text $caption['nl2br'] = FALSE; // Automatically insert
tags in captions. $caption['left_just'] = FALSE; // Left-justify caption (otherwise centered). $caption['above'] = FALSE; // Place caption above the image, not below it. // Settings for making the displayed image an active link $img_link['next'] = TRUE; // Link to the next image from the one displayed. $img_link['wrap'] = FALSE; // Link back to first image from the last one. $img_link['wrap_up'] = TRUE; // Link the last image to the directory above. $img_link['th_page'] = FALSE; // Link to all-thumbs view if available... $img_link['t_p_few'] = FALSE; // ...even in directories with few images. $img_link['few_limit'] = 9; // How many is "few" for $img_link['t_p_few']? // Other scripts have the following, so some people must like it. $img_link['full'] = FALSE; // If the image is a resized version, link to the // full sized version. Disables 'next' and 'wrap'. $img_link['file'] = FALSE; // Cause the link to go directly to the image file. // Image Metadata settings $exif['ena'] = TRUE; // Include a line of EXIF data below the image. (experimental) TODO: Disable by default in stable release /** * Lower Gallery Navigation Row below the image and caption * * If nothing on the row is enabled, the navigation row is omitted. */ $lwr_nav['enable'] = TRUE; $lwr_nav['tmp_size'] = FALSE; // Show resizing links. Overrides 'full_link'. $lwr_nav['full_link'] = TRUE; // Show `Full Size' link if image is resized. $lwr_nav['prv_next'] = TRUE; // Show `previous' / `next' links. $lwr_nav['wrap'] = FALSE; // Wrap Next / Prev. at the last / first image. $lwr_nav['frst_last'] = TRUE; // Show ` |<< ' and ` >>| ' links. $lwr_nav['cntr'] = TRUE; // Show `x of y' counter if no $dir_nav counter. $lwr_nav['cntr_bold'] = TRUE; // Bold font for `x of y' message $lwr_nav['sml_txt'] = FALSE; // Use small text for this navigation row. $lwr_nav['width'] = 0; // Width of this navRow's table (0=default) $lwr_nav['padding'] = '1px 0px 2px 0px'; // CSS Padding for the row /** * Gallery Footer Row */ $footer['pad_top'] = '5px'; // Extra space above the footer line $site_link['font_size'] = '0.75em'; // Font size for Site Link $copyright['fnt_size'] = '0.75em'; // Font size for Copyright Message $qdig_homelink['ena'] = TRUE; // Show the Qdig Home link. $qdig_homelink['fnt_size'] = '0.75em'; // Qdig Home link Font size // Color and CSS Style Settings ---------------------------------------+ // See http://qdig.sourceforge.net/Qdig/ColorSchemes // Contribute a color scheme in the Qdig General Discussion forum. // HTML Header CSS settings are only effective for stand-alone Qdig. $header['css_bgcolor'] = '#f8f8f8'; // Page Background $header['css_text_color'] = '#333333'; // Text $header['css_link_color'] = '#004080'; // Link $header['css_visit_color'] = '#006699'; // Visited Link $header['css_bg_img_url'] = ''; // URL of a tiled background image. // Example: '../images/qdig-bg.jpg' $header['css_bg_logo'] = FALSE; // Use a background logo. $header['css_logo_url'] = ''; // URL of logo image, else use cam-icon $header['css_logo_pos'] = '99% 99%'; // CSS position of the bg_logo. $header['css_img_bg'] = '#eeeeee'; // Image background (when loading) // 'transparent' is a valid "color". $header['css_img_border'] = '#cccccc'; // Displayed-image border $header['css_img_brdr_w'] = '1px'; // Width of displayed-image border $header['css_thm_border'] = '#cccccc'; // Thumbnail images' border $header['css_thm_brdr_w'] = '0px'; // Width of thumbnail-image border $header['css_thm_opacity'] = '60'; // Setting of 1 to 99 fades thumbs. // (Opacity may slow rendering speed.) $header['css_opacity_moz'] = FALSE; // Opacity for older gecko browsers $header['css_thm_hilite'] = '#f9f99f'; // Hilight border for current-thumb. $header['css_thm_hl_w'] = '2px'; // Width of highlight border $header['css_user_def'] = ''; // User-defined CSS rules // Settings beyond here can be set to '' to use the page default. // Gallery Table and Image Table (Important for an embedded gallery) $gallery_table_bg_clr = ''; // Background color of the gallery table. $image_table_bg_clr = ''; // Background color of image area. $sidebar['bg_clr'] = '#f3f3f3'; // Sidebar background $sidebar['margin_top'] = '4px'; // Margin above the sidebar $sidebar['height'] = ''; // '' is "auto". example: '350px' // TODO auto-set based on image size? $copyright['color'] = '#cccccc'; // Copyright text $admin['color'] = '#cccccc'; // Admin link text $qdig_homelink['color'] = '#cccccc'; // Qdig Home Link text $grayout_color = '#999999'; // Grayed-out text // Image Conversion and Alternate-size Settings -----------------------+ // Thumbnail settings are in the Layout Settings section. /** * Writable Directories * * Folders containing your original images may be read-only by the web server * daemon, but the script needs write permissions to write empty caption .txt * files and converted-image files (thumbnail and alternate-sized images). */ $qdig_files = 'qdig-files/'; // The root of the writable tree. Setup is easy: (lang)# // Create the directory. Give it 2777 permissions // (`chmod 2777'). Visit the gallery once. Then // change the permissions to something sane (0755). $convrtd_subdir = 'converted-images/'; // Subdir for resampled images (lang)# $caption_subdir = 'captions'; // Subdir for captions (lang)# $touch_captions = TRUE; // Create empty caption .txt files, if found missing. /** * Image Magick and GD Settings * * If you have both Image Magick and GD, Qdig uses IM except on a Win32 server. * To use the one that isn't the default, set the default one to FALSE. */ $convert_magick = TRUE; // Use Image Magick, if available, to convert images. $convert_cmd = '/usr/bin/convert'; // Full pathname to IM's `convert' $convert_nice = TRUE; // Modify priority with nice(1) command if available. $nice_command = '/bin/nice -n 18 '; // Example $convert_cmd for Win32 users: //$convert_cmd = '"C:\\Program Files\\ImageMagick-5.5.3-Q16\\convert.exe"'; $convert_GD = TRUE; // Use PHP GD, if available, to convert images. $convert_GD_ver = ''; // '' is auto-detect (recommended). Else '1' or '2'. /** * Sizes to convert / display * * Enable or disable any of the alternate sizes. * Old Defaults: FALSE,TRUE,TRUE,TRUE,TRUE,FALSE * Basic: FALSE,FALSE,TRUE,FALSE,FALSE,TRUE */ $disp_size[0] = FALSE; // 'XS' | These cause resizing $disp_size[1] = TRUE; // 'S' | links in the Control $disp_size[2] = FALSE; // 'M' | Bar and Navigation $disp_size[3] = FALSE; // 'L' | Bar to disappear $disp_size[4] = FALSE; // 'XL' | if set to FALSE and $disp_size[5] = TRUE; // 'FS' | appear if set to TRUE. // If no size is specified, default to the following size. $default_img_size = '2'; // '1' is Small. Must be an enabled size. /** * Thumbnail Image Conversion Settings */ $cnvrt_thmb['size'] = 50; // Thunbnail image height in pixels. // Sizes: 10 is tiny, 20 is small, 35 is medium, // 50 is large, 75 is jumbo $cnvrt_thmb['qual'] = 60; // Thumbnail image quality. Large thumbnails // may look better, but will have increased file // size, if you increase this a bit. $cnvrt_thmb['sharpen'] = '0.6x0.6'; // Level of sharpening for thumbnails. $cnvrt_thmb['single'] = FALSE; // Convert a thumb in a singleton directory. $cnvrt_thmb['mesg_on'] = FALSE; // Produce a message when a thunbnail image // is auto-generated. $cnvrt_thmb['no_prof'] = FALSE; // Strip image profile data to reduce size. // (May be incompatible with some servers.) $cnvrt_thmb['prefix'] = // Filename prefix for thumbnail images. # "thm{$cnvrt_thmb['size']}_"; // The default includes the thumb file size. # //$cnvrt_thmb['prefix'] = 'thm_'; // Uncomment for 'thm_' (w/o file size). # /** * Alternate-sized Image Conversion Settings * * ['prefix'] is the filename prefix for the generated file. * ['sharpen'] is the sharpen pramater passed to ImageMagick. * ['maxwid'] is the size setting. Other dimensions are calculated. * ['qual'] is the compression quality level. * ['txt'] is the image size text used inline in a message. (Language Setting) * ['label'] is the text used for a link. (Language Setting) */ $cnvrt_alt['indiv'] = TRUE; // Convert alternates one-at-a-time rather than // all the images in a directory at once. $cnvrt_alt['mesg_on'] = TRUE; // Produce a message when an image is converted. $cnvrt_alt['no_prof'] = FALSE; // Strip image profile data to reduce size. // (May be incompatible with some servers.) $cnvrt_alt['aspect'] = 0.75; // Default inverted aspect ratio (H/W). // TODO (experimental) $cnvrt_alt['by_height'] = TRUE; // Convert by height, not "height or width"... $cnvrt_alt['bh_letterbox'] = TRUE; // ...except extra-wide images. // x-small $cnvrt_size[0]['prefix'] = 'xsm_';# $cnvrt_size[0]['sharpen'] = '0.6x0.7'; $cnvrt_size[0]['maxwid'] = 420; $cnvrt_size[0]['qual'] = 87; // small $cnvrt_size[1]['prefix'] = 'sml_';# $cnvrt_size[1]['sharpen'] = '0.6x0.8'; $cnvrt_size[1]['maxwid'] = 544; $cnvrt_size[1]['qual'] = 87; // medium $cnvrt_size[2]['prefix'] = 'med_';# $cnvrt_size[2]['sharpen'] = '0.6x0.8'; $cnvrt_size[2]['maxwid'] = 640; $cnvrt_size[2]['qual'] = 89; // large $cnvrt_size[3]['prefix'] = 'lrg_';# $cnvrt_size[3]['sharpen'] = '0.6x0.9'; $cnvrt_size[3]['maxwid'] = 800; $cnvrt_size[3]['qual'] = 90; // x-large $cnvrt_size[4]['prefix'] = 'xlg_';# $cnvrt_size[4]['sharpen'] = '0.6x0.9'; $cnvrt_size[4]['maxwid'] = 1024; $cnvrt_size[4]['qual'] = 91; // actual $cnvrt_size[5]['prefix'] = '../'; // Language Settings --------------------------------------------------+ // Text that appears in the output may be configured here. // htmlHeader() # $header['lang_code'] = 'en';# $header['charset'] = 'iso-8859-1';# $header['keywords'] = ''; // e.g. 'foo,bar' # // dirNav() # $dir_nav['main_txt'] = 'Main';# $dir_nav['choose_main_txt'] = 'Choose a gallery:';# $dir_nav['choose_main_title_txt'] = 'Please choose a gallery.';# $dir_nav['choose_sub_txt'] = '';# $dir_nav['choose_sub_title_txt'] = 'Please choose a gallery.';# $dir_nav['empty_dir_txt'] = 'No gallery!';# $dir_nav['empty_dir_title_txt'] = 'Sorry, no gallery here.';# $dir_nav['image_txt'] = 'Image '; // Using '#' is shorter.# $dir_nav['go_to_txt'] = 'Go to';# $dir_nav['thumbs'] = 'thumbnails';# $dir_nav['up_level_txt'] = 'Up a level..';# $dir_nav['up_title_txt'] = 'Go up one level';# $dir_nav['current_txt'] = 'Current location:';# $dir_nav['prefs_title_txt'] = 'Change your visitor preferences';# $dir_nav['prefs_title_txt2'] = 'Keep your current visitor preferences';# //$dir_nav['prefs_txt'] = 'Preferences';# $dir_nav['prefs_txt'] = '+';# $dir_nav['prefs_txt2'] = '–';# // Navigation Links: imageThumbsLinks(), imageTextLinks(), displayImage(), # // prevLink(), nextLink(), lastLink(), firstLink(), navRow() # $nav_lnk['prv_txt'] = '<< Previous';# $nav_lnk['prv_msg'] = 'Previous Image';# $nav_lnk['next_txt'] = 'Next >>';# $nav_lnk['next_msg'] = 'Next Image';# $nav_lnk['last_txt1'] = '<< Last';# $nav_lnk['last_txt2'] = '>>|';# $nav_lnk['last_msg'] = 'Last Image';# $nav_lnk['frst_txt1'] = 'First >>';# $nav_lnk['frst_txt2'] = '|<<';# $nav_lnk['frst_msg'] = 'First Image';# $nav_lnk['Image'] = 'Image';# $nav_lnk['Gallery Navigation'] = 'Gallery Navigation';# // controlView() # $ctrl_links_mesg['links_style'] = 'Links Style:';# $ctrl_links_mesg['thumbs_txt'] = 'Thumbs';# $ctrl_links_mesg['names_txt'] = 'Names';# $ctrl_links_mesg['nums_txt'] = 'Numbers';# $ctrl_links_mesg['none_txt'] = 'None';# $ctrl_links_mesg['thumbs_msg'] = 'Switch to Thumbnail Links';# $ctrl_links_mesg['names_msg'] = 'Switch to Filename Links';# $ctrl_links_mesg['nums_msg'] = 'Switch to Calendar-Style Links';# $ctrl_links_mesg['none_msg'] = 'Disable Direct Image Links';# $img_sz_labels['ctrl']['Default Size'] = 'Default Size:';# $img_sz_labels['ctrl']['Change def'] = 'Change the default image size to ';# // displayImage(), captionBlock() # $lang['Close Window'] = 'Close Window';# $caption['lang Caption'] = 'Caption';# // Image size: displayImage(), navSize(), navFull() $cnvrt_size[0]['label'] = 'XS';# $cnvrt_size[1]['label'] = 'S';# $cnvrt_size[2]['label'] = 'M';# $cnvrt_size[3]['label'] = 'L';# $cnvrt_size[4]['label'] = 'XL';# $cnvrt_size[5]['label'] = 'FS';# $img_sz_labels['nav']['See the'] = 'See the ';# $img_sz_labels['nav']['Return to'] = 'Return to the ';# $cnvrt_size[0]['txt'] = 'Extra Small';# $cnvrt_size[1]['txt'] = 'Small';# $cnvrt_size[2]['txt'] = 'Medium';# $cnvrt_size[3]['txt'] = 'Large';# $cnvrt_size[4]['txt'] = 'Extra Large';# $cnvrt_size[5]['txt'] = 'Full Size';# $cnvrt_size[5]['txt2'] = 'default';# $img_sz_labels['ctrl']['str2'] = '.';# $img_sz_labels['nav']['version of'] = ' version of this image.';# // imageCounter() # $lang['nav_cntr_txt'] = ' of '; // "x of n" counter # // createThumbs(), resizeImage() # $cnvrt_mesgs['Generated'] = 'Generated a new ';# $cnvrt_mesgs['Generating'] = 'Generating a new ';# $cnvrt_mesgs['thumb'] = 'thumbnail';# $cnvrt_mesgs['converted'] = ' converted';# $cnvrt_mesgs['image for'] = ' image for ';# $cnvrt_mesgs['using IM'] = " using 'convert'";# $cnvrt_mesgs['using GD'] = ' using GD';# $cnvrt_mesgs['on-the-fly'] = ''; // was: ' (on-the-fly)'# // footerRow() # $footer['summary_txt'] = 'Gallery Footer';# $copyright['title_txt'] = 'Copyright Notice';# $qdig_homelink['div_title'] = 'Gallery by Qdig';# // adminLink() # $admin['link_title'] = 'Edit Caption';# $admin['link_text'] = 'Admin';# $admin['before_link'] = '(';# $admin['after_link'] = ')';# // Misc. # $lang['Diag Messages'] = 'Diagnostic Messages';# $lang['Image Gallery'] = 'Image Gallery';# $lang['Control Bar'] = 'Control Bar';# $lang['Img Disp Area'] = 'Image Display Area';# $lang['Empty gallery'] = 'Empty gallery!';# $lang['Forbidden'] = 'Forbidden';# // Security Settings ------------------------------------------------+ // Formerly most of these were grouped as "Paranoia Settings". $only_embed_qdig = FALSE; // Only allow included Qdig, not stand-alone. $safe_captions = TRUE; // Disable HTML in Captions. Convert special // characters (<>&"') to "HTML entities" $check_security = TRUE; // Perform a security check for world-writability. $ignore_dir_links = TRUE; // Ignore gallery directories if they're symlinks. $ignore_img_links = TRUE; // Ignore image files if they're symlinks. $pathname_maxlen = 100; // Max. number of characters in a pathname. $imgname_maxlen = 100; // Max. number of characters in an image filename. $extra_paranoia = FALSE; // Do extra-strict checking for '..' and more. umask(0002); // File creation mask if $extra_paranoia is TRUE // Examples: umask(0002); // `drwxrwxr-x' and `-rw-rw-r--' (world readable) // umask(0007); // `drwxrwx---' and `-rw-rw----' (not world readable) // umask(0000); // `drwxrwxrwx' and `-rw-rw-rw-' (world writable) $ignore_dotfiles = FALSE; // Ignore files that start with '.'. $ignore_dotdirs = FALSE; // Ignore directories that start with '.'. // HTML Header settings are only effective for stand-alone Qdig. $header['zap_frames'] = FALSE; // Break out of a frameset. $header['ie_imgbar_off'] = TRUE; // Suppress IE6's image toolbar. // TODO s/b in Header CSS section? // Miscellaneous Settings ---------------------------------------------+ /** * Server Compatibility */ // Disable use of certain PHP functions for compatibility with some servers. $is_readable_disa = FALSE; // Set to TRUE if is_readable() causes trouble. $file_exists_disa = FALSE; // Set to TRUE if file_exists() causes trouble. $max_exec_time = 30; // Max. execution time in seconds $compat_quote = TRUE; // Add and extra "s to exec() command on Win32. // For Win98 this should be set to FALSE. $exclude_gif = FALSE; // Exclude GIF images. // HTML Header settings are only effective for stand-alone Qdig. $header['meta_cache'] = FALSE; // Use a Cache-Control meta tag. For servers // TODO: Public / Private? // that cause repeated reloading of thumbs. $header['cache_sec'] = '3600'; // Number of seconds for the cache to expire. /** * Path Settings (Override defaults.) */ // These two are the same location; as a URL and as a filesystem path. $url_base_path = ''; // Base URL path to the images (not the script) // Examples: '/photos/' or '/~someuser/qdig/' $fs_base_path = ''; // Filesystem path to the root dir of the gallery. // Ex.: '/home/someuser/public_html/qdig/' or '../qdig' $admin['script_url'] = 'admin.php'; // URL path to the Gallery Management // Script. Example: '/photos/admin.php' $chroot_dir = ''; // The topmost directory of the gallery tree. // Note: You may also want to add the path to the $qdig_files location // (Example: For 'images' $qdig_files might be 'images/qdig-files/'.) // See http://qdig.sourceforge.net/Support/ChrootDirectory $qdig_url = ''; // Self-referring URL path. Examples: '/photos/' or // '/photos/qdig.php' or '/~someuser/qdig/index.php' /** * Et-cetera */ $excl_dirs[] = 'Private'; // | Ignore a directory with its name $excl_dirs[] = 'qdig-converted'; // | included here. Do not end these $excl_dirs[] = ''; // | name(s) with '/'. $excl_dir_preg = '/^priv_/'; // Ignore dirs by perl-compatible regex. // TODO Strip string from dir name? $excl_imgs[] = 'qdig-bg.jpg'; // | Ignore any image with its name $excl_imgs[] = 'favicon.png'; // | included here. Add as many of $excl_imgs[] = ''; // | these as you wish. $excl_img_preg = '/^thumb_/'; // Ignore images by perl-compatible regex. $excl_img_pattern = '_thumb'; // Don't display files containing this string. $excl_main = FALSE; // Exclude all images in the root (Main) directory. $extra_param = ''; // Extra parameter(s) to include in URLs. // Examples: 'incl=qdig.php&' 'a=foo&b=bar&' $keep_params = FALSE; // Retain extra GET parameters in Qdig URLs. Allows // Qdig to "share" the query string when embedded. // TODO: Set limits (#/size)? Rename? $anchor = ''; // Include an intra-page anchor in URLs. For embedded // galleries, use '#qdig' to jump down to the gallery. /** * Debugging Setting */ $diag_messages = FALSE; // Produce diagnostic messages. This will also enable // verbose PHP error reporting. /** * Get External Settings */ if (function_exists('qdig_settings')) { qdig_settings($qdig_version); } // External Language Settings //@include_once('./lang-xx.php'); // Uncomment and change xx to a country code. // End of Settings ----------------------------------------------------+ /* +-------------------+ | Adapt to Server | +-------------------+ */ // Get global variables regardless of PHP version or register_globals setting. $server_vars = ($_SERVER) ? $_SERVER : $HTTP_SERVER_VARS; $get_vars = ($_GET) ? $_GET : $HTTP_GET_VARS; $php_self = @$server_vars['PHP_SELF']; $script_name = @$server_vars['SCRIPT_NAME']; if (! $request_uri = @$server_vars['REQUEST_URI']) { // Not provided by IIS. $request_uri = @$php_self.'?'.@$server_vars['argv'][0]; // Close enough } // Suppress harmless Notices and annoying warnings. They're restored at the end. if (!isset($orig_err_rep_level)) { $orig_err_rep_level = ($diag_messages == TRUE) ? error_reporting(E_ALL) : error_reporting(E_ALL ^E_NOTICE ^E_WARNING); } // Establish self-referring URL. if (empty($qdig_url)) { $tmp = explode('?', @$request_uri); $qdig_url = @$tmp[0]; unset($tmp); } if (empty($qdig_url)) { $qdig_url = @$script_name; } // Safe mode? if (ini_get('safe_mode')) { $safe_mode = TRUE; } else { $safe_mode = FALSE; @ini_set('max_execution_time', $max_exec_time); } // Which OS? if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $platform = 'Win32'; } elseif (strtoupper(substr(PHP_OS, 0, 3)) == 'LIN') { $platform = 'Linux'; } elseif (strtoupper(substr(PHP_OS, 0, 3)) == 'MAC') { $platform = 'Macintosh'; } elseif (strtoupper(substr(PHP_OS, 0, 5)) == 'FREEB') { $platform = 'FreeBSD'; } else { $platform = 'Unix'; } // Included Qdig? if (function_exists('qdig_settings')) { $is_included = TRUE; } elseif (__FILE__ == realpath(@$server_vars['SCRIPT_FILENAME']) || ! $tmp = get_included_files()) { $is_included = FALSE; } else { $is_included = TRUE; } if ($only_embed_qdig == TRUE && $is_included == FALSE) { securityExit('Direct access is disabled.'); } if (!function_exists('exif_read_data')) { $exif['ena'] = FALSE; } /* +-------------+ | Functions | +-------------+ */ // http://qdig.sourceforge.net/Qdig/FunctionsList /** * The encoded icon image. */ function cam_icon() { header('Content-type: image/png'); header('Content-length: 346'); echo base64_decode( 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAALHRFWHRDcmVhdGlvbiBUaW1lAFRo'. 'dSAyNiBEZWMgMjAwMiAxMToxOTowNiAtMDcwMOKR1KkAAAAHdElNRQfSDBoSGhzS+Jz0AAAACXBI'. 'WXMAAAsSAAALEgHS3X78AAAABGdBTUEAALGPC/xhBQAAACdQTFRF////ZmZmMzMzZjMzM2ZmM2Yz'. 'ZjNmzMzMmZnMmZmZmZn/zP//ZmbMVprHTAAAAAF0Uk5TAEDm2GYAAABxSURBVHjaVU+LEsAgCAqr'. 'pbb//95Be9OdHoRSpSwAMKC8wCT+Qv6FJod9HZVbbgd0E0A8XAmt8rCLDyKChVF0QxS5IyQwyRbP'. 'mRbauxzkUuQdeIS8BY54E68u4VpaPZty1ohiHfCTm35u4KtY+9a3cgC4QwQQbFlZCQAAAABJRU5E'. 'rkJggg=='); } // End cam_icon() /** * An encoded transparent 1x1 image. */ function clear_dot() { header('Content-type: image/gif'); header('Content-length: 43'); echo base64_decode( 'R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='); } // end clear_dot() /** * Security Exit */ function securityExit($mesg = 'Unspecified Error') { global $lang; header('HTTP/1.0 403 Forbidden'); exit("\n 403 {$lang['Forbidden']} {$lang['Forbidden']}: $mesg\n"); } // End securityExit() /** * Return 'TRUE' or 'FALSE' string based on a variable's status. */ function trueFalse($data, $true = 'TRUE', $false = 'FALSE') { if (@$data == TRUE) { return $true; } else { return $false; } } // End trueFalse() /** * Return non-Qdig GET parameters, ready for prepending to a query string. */ function keepParams() { global $get_vars, $extra_param; if (!empty($extra_param) || empty($get_vars) ) { return; } foreach ($get_vars as $param => $value) { if (! preg_match('!^(Qwd|Qif|Qiv|Qis|Qtmp|Qimg|Makethumb)$!', $param)) { $params .= $param.'='.$value.'&'; } } return $params; } /** * Get the names of image files in a directory. */ function getImageFilenames($path) { global $rootdir, $is_readable_disa, $convert_GD, $ignore_img_links, $img_links, $imgname_maxlen, $exclude_gif, $excl_main, $excl_imgs, $excl_img_pattern, $excl_img_preg, $extra_paranoia, $ignore_dotfiles; if ($excl_main == TRUE && $path == $rootdir) { return; } $img_exts = ($convert_GD == TRUE) ? '\.jpg$|\.jpeg$|\.jpe$|\.png$' : '\.jpg$|\.jpeg$|\.jpe$|\.png$|\.bmp$'; if ($exclude_gif == FALSE) { $img_exts .= '|\.gif$'; } $pwd_handle = opendir($path); $i = 100; while (($file = readdir($pwd_handle)) != false) { if ($file == '.' || $file == '..') { continue; } if ($extra_paranoia == TRUE && is_file($path.'/'.$file)) { if (strpos(stripslashes(rawurldecode($file)), '..') || ($file[0] == '.' && $file[1] == '.')) { securityExit('Updir ("..") is not allowed in a filename.'); } if (strlen($file) > $imgname_maxlen) { securityExit('Filename length exceed. Increase $imgname_maxlen?'); } } if ($ignore_dotfiles == TRUE && $file[0] == '.') { continue; } if (in_array($file, $excl_imgs)) { continue; } if (preg_match($excl_img_preg, $file)) { continue; } if (strpos('*'.$file, $excl_img_pattern)) { continue; } if (is_file($path.'/'.$file) && ($is_readable_disa == TRUE || is_readable($path.'/'.$file)) && ! ($ignore_img_links == TRUE && is_link($path.'/'.$file)) && eregi($img_exts, $file)) { $mod_date = filemtime($path.'/'.$file).$i; $img_files[$mod_date] = $file; $i++; } } closedir($pwd_handle); if (isset($img_files)) { ($img_links['sort_date'] == TRUE) ? ksort($img_files) : natcasesort($img_files); foreach ($img_files as $img) { $sorted_files[] = $img; } return ($img_links['sort_rev'] == TRUE) ? array_reverse($sorted_files) : $sorted_files; } } // End getImageFilenames() /** * Check to see if at least one potential gallery directory exists. */ function checkForDirs($path) { global $qdig_files_topdir, $is_readable_disa, $ignore_dir_links, $excl_dirs, $excl_dir_preg, $ignore_dotdirs; $pwd_handle = opendir($path); while (($file = readdir($pwd_handle)) != FALSE) { if($file == '.' || $file == '..' || $file == $qdig_files_topdir || @in_array($file, $excl_dirs) || preg_match($excl_dir_preg, $file) || ! ($is_readable_disa == TRUE || @is_readable($path.'/'.$file)) || ($ignore_dir_links == TRUE && is_link($path.'/'.$file))) { continue; } if ($ignore_dotdirs == TRUE && $file[0] == '.') { continue; } if (is_dir($path.'/'.$file)) { $has_dir = TRUE; closedir($pwd_handle); return $has_dir; } } closedir($pwd_handle); } // End checkForDirs() /** * Check for existence of at least one image file in a directory. */ function checkForImgs($path) { global $is_readable_disa, $ignore_img_links, $ignore_dotfiles; $pwd_handle = opendir($path); while (($file = readdir($pwd_handle)) != FALSE) { if($file == '.' || $file == '..' || ! ($is_readable_disa == TRUE || @is_readable($path.'/'.$file)) || is_dir($path.'/'.$file) || ($ignore_img_links == TRUE && is_link($path.'/'.$file))) { continue; } if ($ignore_dotfiles == TRUE && $file[0] == '.') { continue; } if (eregi('\.jpg$|\.jpeg$|\.jpe$|\.png$|\.gif$|\.bmp$', $file)) { $has_img = TRUE; closedir($pwd_handle); return $has_img; } } closedir($pwd_handle); } // End checkForImgs() /** * Get the names of gallery directories in a directory. * * A gallery directory is one that contains at least one image or potential * gallery directory. Returns an array with the dirname and its age. */ function getDirNames($path) { global $qdig_files_topdir, $is_readable_disa, $dir_nav, $ignore_dir_links, $excl_dirs, $excl_dir_preg, $ignore_dotdirs; $dir_handle = opendir($path); while (($file = readdir($dir_handle)) != false) { if($file == '.' || $file == '..' || ! is_dir($path.'/'.$file) || ($ignore_dir_links == TRUE && is_link($path.'/'.$file)) || ! ($is_readable_disa == TRUE || is_readable($path.'/'.$file)) || @in_array($file, $excl_dirs) || preg_match($excl_dir_preg, $file) || $file == $qdig_files_topdir) { continue; } if ($ignore_dotdirs == TRUE && $file[0] == '.') { continue; } $dirs[] = $file; } closedir($dir_handle); if (isset($dirs)) { $timeofday = gettimeofday(); $unixtime = $timeofday['sec']; $i = 0; natcasesort($dirs); foreach ($dirs as $dir) { if (checkForImgs($path.'/'.$dir) || checkForDirs($path.'/'.$dir) && ($is_readable_disa == TRUE || is_readable($path))) { $dirmodified = filemtime($path.'/'.$dir); $dir_age = 1000 * ($unixtime - $dirmodified) + $i; $sorted_dirs[$dir] = $dir_age; $i++; } } if (isset($sorted_dirs)) { return ($dir_nav['sort_rev'] == TRUE) ? array_reverse($sorted_dirs) : $sorted_dirs; } } } // End getDirNames() /* * Get the image number and filename of the requested image. * * If none is requested or the file is non-existent, default to the first image. */ function getReqdImage() { global $pwd, $imgs, $get_vars, $imgname_maxlen, $extra_paranoia; if (empty($imgs)) { return; } if (!empty($get_vars['Qif'])) { $imagefile = stripslashes(rawurldecode($get_vars['Qif'])); if (strlen($imagefile) > $imgname_maxlen || ($imagefile[0] == '.' && $imagefile[1] == '.')) { securityExit('Filename (Qif=) is too long or starts with "..".'); } // Redundant, but what the heck. if ($extra_paranoia == TRUE && strpos(stripslashes(rawurldecode($imagefile)), '..')) { securityExit('Updir ("..") not allowed in a filename.'); } } if (isset($imagefile) && is_file($pwd.'/'.$imagefile)) { $reqd_img_file = $imagefile; // Look up the image's index number $imgs_flip = array_flip($imgs); $reqd_img_num = $imgs_flip[$imagefile]; } else { $reqd_img_file = $imgs[0]; $reqd_img_num = 0; } return array('file' => $reqd_img_file, 'num' => $reqd_img_num); } // End getReqdImage() /** * Convert a string to a useful path starting with './'. * * click/buzz/./pop//boom/../bam/ becomes ./click/buzz/pop/boom/bam */ function cleanPath($path) { $path = stripslashes(rawurldecode($path)); $path_array = explode('/', $path); $clean_path = '.'; foreach ($path_array as $dir) { if ($dir == '' || $dir == '.' || $dir == '..' || $dir == '...') { continue; } $clean_path .='/'.$dir; } return $clean_path; } // End cleanPath() /** * rawurlencode() a file's path but keep slashes, tildes. */ function urlPath($path) { $decoded = rawurldecode($path); // Decode if encoded $cleaned = cleanPath($decoded); $encoded = rawurlencode($cleaned); // Encode $encoded_path = str_replace('%2F', '/', $encoded); // replace slashes $encoded_path = str_replace('%7E', '~', $encoded_path); // replace tildes return $encoded_path; } // End rawurlencodePath() /** * Build an 'x of n' counter. */ function imageCounter($image_num) { global $imgs, $lang; $num_imgs = count($imgs); $img_num = $image_num + 1; if ($num_imgs > 0) { $str = "$img_num{$lang['nav_cntr_txt']}$num_imgs"; return $str; } } // End imageCounter() /** * Get which version of GD is installed, if any. * * Returns the version (1 or 2) of the GD extension. */ function gdVersion() { global $convert_GD_ver; if (! extension_loaded('gd')) { return; } static $gd_ver = 0; // Accept a user-defined setting if it's 1. if ($convert_GD_ver == 1) { $gd_ver = 1; return 1; } // Use the static variable if function was called previously. if ($convert_GD_ver !=2 && $gd_ver > 0) { return $gd_ver; } // Use the gd_info() function if possible. if (function_exists('gd_info')) { $ver_info = gd_info(); preg_match('/\d/', $ver_info['GD Version'], $match); $gd_ver = $match[0]; return $match[0]; } // If phpinfo() is disabled use a specified / fail-safe choice... if (preg_match('/phpinfo/', ini_get('disable_functions'))) { if ($convert_GD_ver == 2) { $gd_ver = 2; return 2; } else { $gd_ver = 1; return 1; } } // ...otherwise use phpinfo(). ob_start(); phpinfo(8); $info = ob_get_contents(); ob_end_clean(); $info = stristr($info, 'gd version'); preg_match('/\d/', $info, $match); $gd_ver = $match[0]; return $match[0]; } // End gdVersion() /** * Fix permissions of a file or directory. * * Adjusts permissions so both the script and account owner can modify / delete. * Adapted from PmWiki's fixperms() function copyright by Patrick R. Michaud. */ function fixPerms($file) { global $extra_paranoia; if ($extra_paranoia == TRUE) { return; } clearstatcache(); if (!file_exists($file)) { return; } $bp = 0; if (fileowner($file)!=@fileowner('.')) { $bp = (is_dir($file)) ? 007 : 006; } if (filegroup($file)==@filegroup('.')) { $bp <<= 3; } if ($bp && (fileperms($file) & $bp) != $bp) { chmod($file, fileperms($file)|$bp); } } // end of fixPerms() /** * Create a directory recursively (like `mkdir -p $dir'). */ function mkRecursiveDir($dir) { global $file_exists_disa, $base_dir; $path_array = explode('/', $dir); $path = $base_dir; foreach ($path_array as $dir) { if ($dir == '' || $dir == '.' || $dir == '..' || $dir == '...') { continue; } $path .= '/'.$dir; if ((($file_exists_disa == TRUE && ! is_file($path)) || ! file_exists($path)) && is_writable(dirname($path))) { mkdir($path, 0777); fixPerms($path); } } } // End mkRecursiveDir() /** * Generate thumbnail images for images that do not have thumbnails yet. */ function createThumbs($cnvrt_thmb) { global $platform, $pwd, $imgs, $convert_magick, $cnvrt_path, $convert_cmd, $convert_GD, $thmbs_ena, $convert_writable, $caption_path, $touch_captions, $cnvrt_mesgs, $file_exists_disa, $compat_quote; if ($thmbs_ena == FALSE || empty($imgs) || $convert_writable == FALSE) { return; } if ($cnvrt_thmb['single'] == FALSE && count($imgs) < 2) { return; } // one-image gallery if ($convert_GD == TRUE && ! ($gd_version = gdVersion())) { return; } if (! isset($cnvrt_thmb['size'])) { $cnvrt_thmb['size'] = 35; } if (! isset($cnvrt_thmb['qual'])) { $cnvrt_thmb['qual'] = 65; } if ($cnvrt_thmb['mesg_on'] == TRUE) { $str = ''; } if ($convert_magick == TRUE) { $strip_prof = ($cnvrt_thmb['no_prof'] == TRUE) ? ' +profile "*"' : ''; $winquote = ($platform == 'Win32' && $compat_quote == TRUE) ? '"' : ''; } foreach ($imgs as $img_file) { if ($touch_captions == TRUE && is_dir($caption_path)) { $caption_file = $caption_path.'/'.$img_file.'.txt'; if (($file_exists_disa == TRUE && ! is_file($caption_file)) || ! file_exists($caption_file)) { touch($caption_file); fixPerms($caption_file); } } $orig_img = $pwd.'/'.$img_file; $cnvrtd_img = $cnvrt_path.'/'.$cnvrt_thmb['prefix'].$img_file; if (($file_exists_disa == TRUE && ! is_file($cnvrtd_img)) || ! file_exists($cnvrtd_img)) { $img_size = GetImageSize($orig_img); $height = $img_size[1]; $th_maxdim = $height; $cnvt_percent = round(($cnvrt_thmb['size'] / $th_maxdim) * 100, 2); // convert it if ($convert_magick == TRUE) { // Image Magick image conversion exec($winquote.$convert_cmd .' -geometry '.$cnvt_percent.'%' .' -quality '.$cnvrt_thmb['qual'] .' -sharpen '.$cnvrt_thmb['sharpen'].$strip_prof .' "'.$orig_img.'"'.' "'.$cnvrtd_img.'"'.$winquote); fixPerms($cnvrtd_img); $using = $cnvrt_mesgs['using IM']; } elseif ($convert_GD == TRUE) { // GD image conversion if (eregi('\.jpg$|\.jpeg$', $img_file) == TRUE && (imageTypes() & IMG_JPG) == TRUE) { $src_img = imageCreateFromJpeg($orig_img); } elseif (eregi('\.png$', $img_file) == TRUE && (imageTypes() & IMG_PNG) == TRUE) { $src_img = imageCreateFromPng($orig_img); } elseif (eregi('\.gif$', $img_file) == TRUE && (imageTypes() & IMG_GIF) == TRUE) { $src_img = imageCreateFromGif($orig_img); } else { continue; } $src_width = imageSx($src_img); $src_height = imageSy($src_img); $dest_width = $src_width * ($cnvt_percent / 100); $dest_height = $src_height * ($cnvt_percent / 100); if ($gd_version >= 2) { $dst_img = imageCreateTruecolor($dest_width, $dest_height); imageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height); } else { $dst_img = imageCreate($dest_width, $dest_height); imageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height); } imagedestroy($src_img); if (eregi('\.jpg$|\.jpeg$', $img_file) == TRUE && (imageTypes() & IMG_JPG) == TRUE) { imageJpeg($dst_img, $cnvrtd_img, $cnvrt_thmb['qual']); } elseif (eregi('\.png$', $img_file) == TRUE && (imageTypes() & IMG_PNG) == TRUE) { imagePng($dst_img, $cnvrtd_img); } elseif (eregi('\.gif$', $img_file) == TRUE && (imageTypes() & IMG_GIF) == TRUE) { imageGif($dst_img, $cnvrtd_img); } imagedestroy($dst_img); fixPerms($cnvrtd_img); $using = $cnvrt_mesgs['using GD'].$gd_version; } if ($cnvrt_thmb['mesg_on'] == TRUE && is_file($cnvrtd_img)) { $str .= " \n" .' '.$cnvrt_mesgs['Generated'] .$cnvrt_mesgs['thumb'].$cnvrt_mesgs['image for'] .$img_file.$using.".\n" ." \n
\n"; } } } if (isset($str)) { return $str; } } // End createThumbs() /** * Figure out how big a thumb will be, based on input image */ function predictThumbSize($orig_img) { global $cnvrt_thmb; $img_size = GetImageSize($orig_img); $width = $img_size[0]; $height = $img_size[1]; $th_maxdim = $height; $cnvt_percent = round(($cnvrt_thmb['size'] / $th_maxdim) * 100, 2); $dest_width = round($width * ($cnvt_percent / 100)); $dest_height = round($height * ($cnvt_percent / 100)); $attr = sprintf("height=\"%s\" width=\"%s\"", $dest_height, $dest_width); return array($dest_width, $dest_height, $img_size[2], $attr); } // End predictThumbSize() /** * Generate images of alternate sizes. */ function resizeImage($cnvrt_arry) { global $platform, $imgs, $cnvrt_path, $reqd_image, $convert_writable, $convert_magick, $convert_GD, $convert_cmd, $cnvrt_alt, $cnvrt_mesgs, $compat_quote, $exif; if (empty($imgs) || $convert_writable == FALSE) { return; } if ($convert_GD == TRUE && ! ($gd_version = gdVersion())) {return; } if ($convert_magick == TRUE) { $strip_prof = ($cnvrt_alt['no_prof'] == TRUE) ? ' +profile "*"' : ''; $winquote = ($platform == 'Win32' && $compat_quote == TRUE) ? '"' : ''; } if ($cnvrt_alt['mesg_on'] == TRUE) { $str = ''; } if (@$cnvrt_alt['aspect'] < 0.59 || @$cnvrt_alt['aspect'] > 0.81) { $cnvrt_alt['aspect'] = 0.75; } foreach ($imgs as $img_file) { if ($cnvrt_alt['indiv'] == TRUE && $img_file != $reqd_image['file']) { continue; } $orig_img = $reqd_image['pwd'].'/'.$img_file; $cnvrtd_img = $cnvrt_path.'/'.$cnvrt_arry['prefix'].$img_file; if (! is_file($cnvrtd_img)) { $img_size = GetImageSize($orig_img); $height = $img_size[1]; $width = $img_size[0]; $area = $height * $width; $maxarea = $cnvrt_arry['maxwid'] * $cnvrt_arry['maxwid'] * 0.9; $maxheight = ($cnvrt_arry['maxwid'] * $cnvrt_alt['aspect'] + 1); // TODO: ratio setting? if (($width + 1.2) / $height > 1 / $cnvrt_alt['aspect']) { // TODO Make wider-than-just-wide images w/ EXIF resample to a slightly wider width. $factor = 1; if ($cnvrt_alt['bh_letterbox']) $cnvrt_alt['by_height'] = FALSE; } else { $factor = 0.9375; } // Make room for EXIF line. // TODO Leave it in? $ext = strrchr($orig_img, '.'); if (preg_match('!\\.(jpg|jpeg|jpe)$!', strtolower($ext)) && $exif['ena']) { $exif_data = exif_read_data($orig_img, 'EXIF' , true); } // TODO make room for EXIF line if (@$exif_data['EXIF']) { $cnvrt_arry['maxwid'] -= 26; } if ($area > $maxarea || $width > $cnvrt_arry['maxwid'] || $height > $maxheight) { if (($width / $cnvrt_arry['maxwid']) >= ($height / $maxheight)) { $dim = 'W'; } if (($height / $maxheight) >= ($width / $cnvrt_arry['maxwid']) || $cnvrt_alt['by_height'] == TRUE) { $dim = 'H'; } if ($dim == 'W') { $cnvt_percent = round((($factor * $cnvrt_arry['maxwid']) / $width) * 100, 2); } if ($dim == 'H') { $cnvt_percent = round((($cnvrt_alt['aspect'] * $cnvrt_arry['maxwid']) / $height) * 100, 2); } // convert it if ($convert_magick == TRUE) { // Image Magick image conversion exec($winquote.$convert_cmd .' -geometry '.$cnvt_percent.'%' .' -quality '.$cnvrt_arry['qual'] .' -sharpen '.$cnvrt_arry['sharpen'].$strip_prof .' "'.$orig_img.'"'.' "'.$cnvrtd_img.'"'.$winquote); fixPerms($cnvrtd_img); $using = $cnvrt_mesgs['using IM']; } elseif ($convert_GD == TRUE) { // GD image conversion if (eregi('\.jpg$|\.jpeg$', $img_file) == TRUE && (imageTypes() & IMG_JPG) == TRUE) { $src_img = imageCreateFromJpeg($orig_img); } elseif (eregi('\.png$', $img_file) == TRUE && (imageTypes() & IMG_PNG) == TRUE) { $src_img = imageCreateFromPng($orig_img); } elseif (eregi('\.gif$', $img_file) == TRUE && (imageTypes() & IMG_GIF) == TRUE) { $src_img = imageCreateFromGif($orig_img); } else { continue; } $src_width = imageSx($src_img); $src_height = imageSy($src_img); $dest_width = $src_width * ($cnvt_percent / 100); $dest_height = $src_height * ($cnvt_percent / 100); if ($gd_version >= 2) { $dst_img = imageCreateTruecolor($dest_width, $dest_height); imageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height); } else { $dst_img = imageCreate($dest_width, $dest_height); imageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height); } imageDestroy($src_img); if (eregi('\.jpg$|\.jpeg$', $img_file) == TRUE && (imageTypes() & IMG_JPG) == TRUE) { imageJpeg($dst_img, $cnvrtd_img, $cnvrt_arry['qual']); } elseif (eregi('\.png$', $img_file) == TRUE && (imageTypes() & IMG_PNG) == TRUE) { imagePng($dst_img, $cnvrtd_img); } elseif (eregi('\.gif$', $img_file) == TRUE && (imageTypes() & IMG_GIF) == TRUE) { imageGif($dst_img, $cnvrtd_img); } imageDestroy($dst_img); fixPerms($cnvrtd_img); $using = $cnvrt_mesgs['using GD'].$gd_version; } if ($cnvrt_alt['mesg_on'] == TRUE && is_file($cnvrtd_img)) { $str .= " \n" .' '.$cnvrt_mesgs['Generated'].$cnvrt_arry['txt'].$cnvrt_mesgs['converted'] .$cnvrt_mesgs['image for'].$img_file.$using.".\n" ." \n
\n"; } } } } if (isset($str)) { return $str; } } //End resizeImage() /** * Produce the HTML header for a stand-alone gallery. * * Only produce a header if this is a stand-alone gallery. */ function htmlHeader($header) { global $is_included, $imgs, $qdig_url, $request_uri, $anchor, $extra_param, $subdirs, $reqd_image, $is_readable_disa, $dir_nav, $cnvrt_size, $cnvrt_path; if ($header['force_disa'] == TRUE) { return ''; } $str = ''; if ($header['force_ena'] == TRUE || $is_included == FALSE) { if (!empty($header['title_text_1'])) { $title = $header['title_text_1']; } $title_loc = basename($reqd_image['pwd']); if ($title_loc != '.') { // TODO: s/b $rootdir? $title .= " {$header['title_delim']} $title_loc"; } elseif (isset($subdirs)) { $title .= " {$header['title_delim']} {$dir_nav['main_txt']}"; } if ($header['title_cntr'] == TRUE && isset($reqd_image['num']) && $title_cntr = imageCounter($reqd_image['num'])) { $title .= " {$header['title_delim']} $title_cntr"; } if (!empty($header['title_text_2'])) { $title .= " {$header['title_delim']} {$header['title_text_2']}"; } if ($header['img_name'] == TRUE && isset($reqd_image['file'])) { $img_name = $reqd_image['file']; if ($header['strip_ext'] == TRUE) { $ext = strrchr($reqd_image['file'], '.'); $img_name = substr($reqd_image['file'], 0, -strlen($ext)); } $title .= " {$header['title_delim']} $img_name"; } $meta_cache = ($header['meta_cache'] == TRUE) ? '\n " : ''; if (!empty($header['css_bg_img_url'])) { $bg_image = 'body { background-image:url("' .$header['css_bg_img_url'].'"); background-attachment:fixed; }'."\n "; } elseif ($header['css_bg_logo'] == TRUE) { // TODO hide from old browsers $icon = (empty($header['css_logo_url'])) ? "$qdig_url?Qimg=cam-icon" : $header['css_logo_url']; $bg_image = "body { background-image:url(\"$icon\");" ."background-position:{$header['css_logo_pos']};\n" ." background-repeat:no-repeat; background-attachment:fixed; }\n "; } else { $bg_image = ''; } $ie_imgtoolbar = ($header['ie_imgbar_off'] == TRUE) ? ''."\n " : ''; $keywords = (empty($header['keywords'])) ? 'qdig,image gallery,photo album,online gallery,web photo album,' .'digital image gallery,web gallery,photos,images,album,' .'gallery,digital images,digital camera,digital photos,' .'digicam photos,digital camera photos,presentation' : $header['keywords']; $num_imgs = count($imgs); if ($header['preload_next'] == TRUE && !empty($imgs) && $reqd_image['num'] + 1 != $num_imgs) { foreach ($cnvrt_size as $size_info) { if ($reqd_image['size'] == $size_info['label']) { $next_num = $reqd_image['num'] + 1; $next_file = $imgs[$next_num]; $next_path = $cnvrt_path.'/'.$size_info['prefix'].$imgs[$next_num]; if (! is_file($next_path) || ! ($is_readable_disa == TRUE || is_readable($next_path))) { $next_url = $reqd_image['pwd_url'].'/'.$imgs[$next_num]; } else { $next_url = urlPath($next_path); } } } $preload = ' \n"; $onload = " onload='preloadNext()'"; } else { $preload=''; $onload=''; } $zap_frames = ($header['zap_frames'] == TRUE) ? ' \n" : ''; $str = << $meta_cache $ie_imgtoolbar \n EOT; if ($header['nav_links'] == TRUE) { if ($reqd_image['pwd'] != '.') { // TODO: s/b $rootdir? $str .= ' '."\n"; $up_one = urlPath(dirname($reqd_image['pwd'])); $str .= ' ' ."\n"; } if (!empty($imgs) && $reqd_image['num'] != 0) { $first_img = rawurlencode($imgs[0]); $str .= ' '."\n"; $prev_img = rawurlencode($imgs[$reqd_image['num'] - 1]); $str .= ' '."\n"; } $num_imgs = count($imgs); if (!empty($imgs) && $reqd_image['num'] + 1 != $num_imgs) { $next_img = rawurlencode($imgs[$reqd_image['num'] + 1]); $str .= ' '."\n"; $last_img = rawurlencode($imgs[$num_imgs - 1]); $str .= ' '."\n"; } } if ($header['css_thm_opacity'] > 0 && $header['css_thm_opacity'] < 100) { $alpha = $header['css_thm_opacity']; $opacity = $alpha / 100; if ($header['css_opacity_moz'] == TRUE) { $moz_opacity = " -moz-opacity:$opacity;"; $moz_opacity_cur = ' -moz-opacity:100;'; } else { $moz_opacity = ''; $moz_opacity_cur = ''; } $thm_opacity = " filter:alpha(opacity=$alpha);$moz_opacity opacity:$opacity;"; $thm_opacity_curr = " filter:alpha(opacity=100);$moz_opacity_cur opacity:1.0;"; } else { $thm_opacity = ''; $thm_opacity_curr = ''; } if ($header['icon'] == TRUE) { $str .= <<