root/releases/elgg0.8rc2/lib/phpthumb/phpThumb.config.php

Revision 842, 20.5 kB (checked in by ben, 2 years ago)

Removed hard limits on phpThumb output resolution

  • Property svn:eol-style set to native
Line 
1 <?php
2 //////////////////////////////////////////////////////////////
3 ///  phpThumb() by James Heinrich <info@silisoftware.com>   //
4 //        available at http://phpthumb.sourceforge.net     ///
5 //////////////////////////////////////////////////////////////
6 ///                                                         //
7 // See: phpthumb.readme.txt for usage instructions          //
8 //                                                         ///
9 //////////////////////////////////////////////////////////////
10
11 ob_start();
12 if (!file_exists(dirname(__FILE__).'/phpthumb.functions.php') || !include_once(dirname(__FILE__).'/phpthumb.functions.php')) {
13     ob_end_flush();
14     die('failed to include_once(phpthumb.functions.php) - realpath="'.realpath(dirname(__FILE__).'/phpthumb.functions.php').'"');
15 }
16 ob_end_clean();
17
18 // START USER CONFIGURATION SECTION:
19
20 // * DocumentRoot configuration
21 // phpThumb() depends on $_SERVER['DOCUMENT_ROOT'] to resolve path/filenames. This value is usually correct,
22 // but has been known to be broken on some servers. This value allows you to override the default value.
23 // Do not modify from the auto-detect default value unless you are having problems.
24 //$PHPTHUMB_CONFIG['document_root'] = '/home/httpd/httpdocs';
25 //$PHPTHUMB_CONFIG['document_root'] = 'c:\\webroot\\example.com\\www';
26 //$PHPTHUMB_CONFIG['document_root'] = $_SERVER['DOCUMENT_ROOT'];
27 //$PHPTHUMB_CONFIG['document_root'] = realpath((@$_SERVER['DOCUMENT_ROOT'] && file_exists(@$_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF'])) ? $_SERVER['DOCUMENT_ROOT'] : str_replace(dirname(@$_SERVER['PHP_SELF']), '', str_replace(DIRECTORY_SEPARATOR, '/', realpath('.'))));
28 //$PHPTHUMB_CONFIG['document_root'] = realpath((getenv('DOCUMENT_ROOT') && ereg('^'.preg_quote(realpath(getenv('DOCUMENT_ROOT'))), realpath(__FILE__))) ? getenv('DOCUMENT_ROOT') : str_replace(dirname(@$_SERVER['PHP_SELF']), '', str_replace(DIRECTORY_SEPARATOR, '/', dirname(__FILE__))));
29 $PHPTHUMB_CONFIG['document_root'] = path;
30
31
32 // * Cache directory configuration (choose only one of these - leave the other lines commented-out):
33 // Note: this directory must be writable (usually chmod 777 is neccesary) for caching to work.
34 // If the directory is not writable no error will be generated but caching will be disabled.
35 //$PHPTHUMB_CONFIG['cache_directory'] = dirname(__FILE__).'/cache/';                            // set the cache directory relative to the phpThumb() installation
36 //$PHPTHUMB_CONFIG['cache_directory'] = $PHPTHUMB_CONFIG['document_root'].'/phpthumb/cache/'; // set the cache directory to an absolute directory for all source images
37 //$PHPTHUMB_CONFIG['cache_directory'] = './cache/';                                           // set the cache directory relative to the source image - must start with '.' (will not work to cache URL- or database-sourced images, please use an absolute directory name)
38 //$PHPTHUMB_CONFIG['cache_directory'] = null;                                                 // disable thumbnail caching (not recommended)
39 $PHPTHUMB_CONFIG['cache_directory'] = $CFG->dataroot . 'cache/phpThumb/';
40
41 $PHPTHUMB_CONFIG['cache_disable_warning'] = false; // If [cache_directory] is non-existant or not writable, and [cache_disable_warning] is false, an error image will be generated warning to either set the cache directory or disable the warning (to avoid people not knowing about the cache)
42
43
44 // * Cache culling: phpThumb can automatically limit the contents of the cache directory
45 //   based on last-access date and/or number of files and/or total filesize.
46
47 $PHPTHUMB_CONFIG['cache_maxage'] = null;            // never delete cached thumbnails based on last-access time
48 //$PHPTHUMB_CONFIG['cache_maxage'] = 86400 * 90;        // delete cached thumbnails that haven't been accessed in more than [90 days] (value is maximum time since last access in seconds to avoid deletion)
49
50 //$PHPTHUMB_CONFIG['cache_maxsize'] = null;           // never delete cached thumbnails based on byte size of cache directory
51 $PHPTHUMB_CONFIG['cache_maxsize'] = 20 * 1024 * 1024; // delete least-recently-accessed cached thumbnails when more than [10MB] of cached files are present (value is maximum bytesize of all cached files)
52
53 //$PHPTHUMB_CONFIG['cache_maxfiles'] = null;          // never delete cached thumbnails based on number of cached files
54 $PHPTHUMB_CONFIG['cache_maxfiles'] = 10000;             // delete least-recently-accessed cached thumbnails when more than [500] cached files are present (value is maximum number of cached files to keep)
55
56
57 // * Source image cache configuration
58 $PHPTHUMB_CONFIG['cache_source_enabled']   = false;                               // if true, source images obtained via HTTP are cached to $PHPTHUMB_CONFIG['cache_source_directory']
59 $PHPTHUMB_CONFIG['cache_source_directory'] = dirname(__FILE__).'/cache/source/'// set the cache directory for unprocessed source images
60
61 // * cache source modification date configuration
62 $PHPTHUMB_CONFIG['cache_source_filemtime_ignore_local']  = false; // if true, local source images will not be checked for modification date and cached image will be used if available, even if source image is changed or removed
63 $PHPTHUMB_CONFIG['cache_source_filemtime_ignore_remote'] = true// if true, remote source images will not be checked for modification date and cached image will be used if available, even if source image is changed or removed. WARNING: cached performance MUCH slower if this is set to false.
64
65
66 // * Simplified cache filename configuration
67 // Instead of creating unique cache filenames for all parameter combinations, create "simple" cache files (eg: "pic_thumb.jpg")
68 // If cache_default_only_suffix is non-empty, GETstring parameters (except 'src') are ignored and only $PHPTHUMB_DEFAULTS
69 // parameters (set at the bottom of phpThumb.config.php) are used for processing.
70 // The '*' character MUST be used to represent the source image name
71 $PHPTHUMB_CONFIG['cache_default_only_suffix'] = '';           // cached in normal phpThumb manner
72 //$PHPTHUMB_CONFIG['cache_default_only_suffix'] = '*_thumb';  // cache 'pic.jpg' becomes 'pic_thumb.jpg' (or 'pic_thumb.png' if PNG output is selected, etc)
73 //$PHPTHUMB_CONFIG['cache_default_only_suffix'] = 'small-*';  // cache 'pic.jpg' becomes 'small-pic.jpg' (or 'small-pic.png' if PNG output is selected, etc)
74
75 //$PHPTHUMB_CONFIG['cache_prefix'] = 'phpThumb_cache_'.str_replace('www.', '', @$_SERVER['SERVER_NAME']);
76 $PHPTHUMB_CONFIG['cache_prefix'] = '';                         // allow phpThumb to share 1 set of cached files even if accessed under different servername/domains on same server
77
78 $PHPTHUMB_CONFIG['cache_force_passthru'] = true// if true, cached image data will always be passed to browser; if false, HTTP redirect will be used instead
79
80
81
82 // * Temp directory configuration
83 // phpThumb() may need to create temp files. Usually the system temp dir is writable and can be used.
84 // Leave this value as NULL in most cases. If you get errors about "failed to open <filename> for writing"
85 // you should change this to a full pathname to a directory you do have write access to.
86 //$PHPTHUMB_CONFIG['temp_directory'] = '/tmp/';
87 $PHPTHUMB_CONFIG['temp_directory'] = null;
88
89
90 // maximum number of pixels in source image to attempt to process entire image.
91 // If this is zero then no limit on source image dimensions.
92 // If this is nonzero then this is the maximum number of pixels the source image
93 // can have to be processed normally, otherwise the embedded EXIF thumbnail will
94 // be used (if available) or an "image too large" notice will be displayed.
95 // This is to be used for large source images (> 1600x1200) and low PHP memory
96 // limits. If PHP runs out of memory the script will usually just die with no output.
97 // To calculate this number, multiply the dimensions of the largest image
98 // you can process with your memory limitation (e.g. 1600 * 1200 = 1920000)
99 // As a general guideline, this number will be about 20% of your PHP memory
100 // configuration, so 8M = 1,677,722; 16M = 3,355,443; 32M = 6,710,886; etc.
101 if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.2', '>=') && !defined('memory_get_usage') && !@ini_get('memory_limit')) {
102     // memory_get_usage() will only be defined if your PHP is compiled with the --enable-memory-limit configuration option.
103     $PHPTHUMB_CONFIG['max_source_pixels'] = 0;         // no memory limit
104 } else {
105     // calculate default max_source_pixels as 20% of memory limit configuration
106     $PHPTHUMB_CONFIG['max_source_pixels'] = round(max(intval(ini_get('memory_limit')), intval(get_cfg_var('memory_limit'))) * 1048576 * 0.20);
107     //$PHPTHUMB_CONFIG['max_source_pixels'] = 0;       // no memory limit
108     //$PHPTHUMB_CONFIG['max_source_pixels'] = 1920000; // allow 1600x1200 images (2Mpx), no larger (about 10MB memory required)
109     //$PHPTHUMB_CONFIG['max_source_pixels'] = 3355443; // 16MB memory limit
110     //$PHPTHUMB_CONFIG['max_source_pixels'] = 3871488; // allow 2272x1704 images (4Mpx), no larger (about 16MB memory required)
111 }
112
113
114 // ImageMagick configuration
115 // If source image is larger than available memory limits as defined above in
116 // 'max_source_pixels' AND ImageMagick's "convert" program is available, phpThumb()
117 // will call ImageMagick to perform the thumbnailing of the source image to bypass
118 // the memory limitation. Leaving the value as NULL will cause phpThumb() to
119 // attempt to detect ImageMagick's presence with `which`
120 if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
121     // Windows: set absolute pathname
122     //$PHPTHUMB_CONFIG['imagemagick_path'] = 'C:/ImageMagick-6.2.5-Q16/convert.exe';
123     $PHPTHUMB_CONFIG['imagemagick_path'] = null;
124     $PHPTHUMB_CONFIG['prefer_imagemagick']           = false// If true, use ImageMagick to resize thumbnails if possible, since it is usually faster than GD functions; if false only use ImageMagick if PHP memory limit is too low.
125 } else {
126     // *nix: set absolute pathname to "convert", or leave as null if "convert" is in the path
127     //$PHPTHUMB_CONFIG['imagemagick_path'] = '/usr/local/bin/convert';
128     $PHPTHUMB_CONFIG['imagemagick_path'] = null;
129     $PHPTHUMB_CONFIG['prefer_imagemagick']           = true// If true, use ImageMagick to resize thumbnails if possible, since it is usually faster than GD functions; if false only use ImageMagick if PHP memory limit is too low.
130 }
131
132
133 // * Default output configuration:
134 $PHPTHUMB_CONFIG['output_format']    = 'jpeg'; // default output format ('jpeg', 'png' or 'gif') - thumbnail will be output in this format (if available in your version of GD). This is always overridden by ?f=___ GETstring parameter
135 //$PHPTHUMB_CONFIG['output_maxwidth']  = 100;      // default maximum thumbnail width.  If this is zero then default width  is the width  of the source image. This is always overridden by ?w=___ GETstring parameter
136 //$PHPTHUMB_CONFIG['output_maxheight'] = 100;      // default maximum thumbnail height. If this is zero then default height is the height of the source image. This is always overridden by ?h=___ GETstring parameter
137 $PHPTHUMB_CONFIG['output_interlace'] = true;   // if true: interlaced output for GIF/PNG, progressive output for JPEG; if false: non-interlaced for GIF/PNG, baseline for JPEG.
138
139 // * Error message configuration
140 $PHPTHUMB_CONFIG['error_image_width']           = 100;      // default width for error images
141 $PHPTHUMB_CONFIG['error_image_height']          = 100;      // default height for error images
142 $PHPTHUMB_CONFIG['error_message_image_default'] = '';       // Set this to the name of a generic error image (e.g. '/images/error.png') that you want displayed in place of any error message that may occur. This setting is overridden by the 'err' parameter, which does the same thing.
143 $PHPTHUMB_CONFIG['error_bgcolor']               = 'CCCCFF'; // background color of error message images
144 $PHPTHUMB_CONFIG['error_textcolor']             = 'FF0000'; // color of text in error messages
145 $PHPTHUMB_CONFIG['error_fontsize']              = 1;        // size of text in error messages, from 1 (smallest) to 5 (largest)
146 $PHPTHUMB_CONFIG['error_die_on_error']          = false;     // die with error message on any fatal error (recommended with standalone phpThumb.php)
147 $PHPTHUMB_CONFIG['error_silent_die_on_error']   = false;    // simply die with no output of any kind on fatal errors (not recommended)
148 $PHPTHUMB_CONFIG['error_die_on_source_failure'] = false;    // die with error message if source image cannot be processed by phpThumb() (usually because source image is corrupt in some way). If false the source image will be passed through unprocessed, if true (default) an error message will be displayed.
149
150 // * Off-server Thumbnailing Configuration:
151 $PHPTHUMB_CONFIG['nohotlink_enabled']           = true;                                     // If false will allow thumbnailing from any source domain
152 $PHPTHUMB_CONFIG['nohotlink_valid_domains']     = array(@$_SERVER['HTTP_HOST']);            // This is the list of domains for which thumbnails are allowed to be created. The default value of the current domain should be fine in most cases, but if neccesary you can add more domains in here, in the format 'www.example.com'
153 $PHPTHUMB_CONFIG['nohotlink_erase_image']       = true;                                     // if true thumbnail is covered up with $PHPTHUMB_CONFIG['nohotlink_fill_color'] before text is applied, if false text is written over top of thumbnail
154 $PHPTHUMB_CONFIG['nohotlink_text_message']      = 'Off-server thumbnailing is not allowed'; // text of error message
155
156 // * Off-server Linking Configuration:
157 $PHPTHUMB_CONFIG['nooffsitelink_enabled']       = false;                                       // If false will allow thumbnails to be linked to from any domain, if true only domains listed below in 'nooffsitelink_valid_domains' will be allowed.
158 $PHPTHUMB_CONFIG['nooffsitelink_valid_domains'] = array(@$_SERVER['HTTP_HOST']);              // This is the list of domains for which thumbnails are allowed to be created. The default value of the current domain should be fine in most cases, but if neccesary you can add more domains in here, in the format 'www.example.com'
159 $PHPTHUMB_CONFIG['nooffsitelink_require_refer'] = false;                                      // If false will allow standalone calls to phpThumb(). If true then only requests with a $_SERVER['HTTP_REFERER'] value in 'nooffsitelink_valid_domains' are allowed.
160 $PHPTHUMB_CONFIG['nooffsitelink_erase_image']   = true;                                       // if true thumbnail is covered up with $PHPTHUMB_CONFIG['nohotlink_fill_color'] before text is applied, if false text is written over top of thumbnail
161 $PHPTHUMB_CONFIG['nooffsitelink_text_message']  = 'Image taken from '.@$_SERVER['HTTP_HOST']; // text of error message
162
163
164 // * Border & Background default colors
165 $PHPTHUMB_CONFIG['border_hexcolor']     = '000000'; // Default border color - usual HTML-style hex color notation (overidden with 'bc' parameter)
166 $PHPTHUMB_CONFIG['background_hexcolor'] = 'FFFFFF'; // Default background color when thumbnail aspect ratio does not match fixed-dimension box - usual HTML-style hex color notation (overridden with 'bg' parameter)
167
168 // * Watermark configuration
169 $PHPTHUMB_CONFIG['ttf_directory'] = dirname(__FILE__).'/fonts'; // Base directory for TTF font files
170 //$PHPTHUMB_CONFIG['ttf_directory'] = 'c:/windows/fonts';
171
172
173 // * MySQL configuration
174 // You may want to pull data from a database rather than a physical file
175 // If so, modify the $PHPTHUMB_CONFIG['mysql_query'] line to suit your database structure
176 // Note: the data retrieved must be the actual binary data of the image, not a URL or filename
177 // see http://www.billy-corgan.com/blog/archive/000143.php for a brief tutorial on this section
178
179 $PHPTHUMB_CONFIG['mysql_query'] = '';
180 //$PHPTHUMB_CONFIG['mysql_query'] = 'SELECT `picture` FROM `products` WHERE (`id` = \''.mysql_escape_string(@$_GET['id']).'\')';
181
182 // These 4 values must be modified if $PHPTHUMB_CONFIG['mysql_query'] is not empty, but may be ignored if $PHPTHUMB_CONFIG['mysql_query'] is blank.
183 $PHPTHUMB_CONFIG['mysql_hostname'] = 'localhost';
184 $PHPTHUMB_CONFIG['mysql_username'] = '';
185 $PHPTHUMB_CONFIG['mysql_password'] = '';
186 $PHPTHUMB_CONFIG['mysql_database'] = '';
187
188
189 // * Security configuration
190 $PHPTHUMB_CONFIG['high_security_enabled']    = false// if enabled, requires 'high_security_password' set to at least 5 characters, and requires the use of phpThumbURL() function (at the bottom of phpThumb.config.php) to generate hashed URLs
191 $PHPTHUMB_CONFIG['high_security_password']   = '';     // required if 'high_security_enabled' is true, must be at least 5 characters long
192 $PHPTHUMB_CONFIG['disable_debug']            = false// prevent phpThumb from displaying any information about your system. If true, phpThumbDebug and error messages will be disabled
193 $PHPTHUMB_CONFIG['allow_src_above_docroot']  = true;   // if true, allow src to be anywhere in filesystem; if false (default) only allow src within document_root
194 $PHPTHUMB_CONFIG['allow_src_above_phpthumb'] = true;   // if true (default), allow src to be anywhere in filesystem; if false only allow src within sub-directory of phpThumb installation
195 $PHPTHUMB_CONFIG['allow_parameter_file']     = false// if true, allow use of 'file' parameter; if false (default) the 'file' parameter is disabled/ignored
196 $PHPTHUMB_CONFIG['allow_parameter_goto']     = false// if true, allow use of 'goto' parameter; if false (default) the 'goto' parameter is disabled/ignored
197
198
199 // * HTTP UserAgent configuration
200 //$PHPTHUMB_CONFIG['http_user_agent'] = '';                                                                                      // PHP default: none
201 //$PHPTHUMB_CONFIG['http_user_agent'] = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';                                    // Windows XP, Internet Explorer
202 $PHPTHUMB_CONFIG['http_user_agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7'; // Windows XP, Firefox
203
204
205 // * Compatability settings
206 $PHPTHUMB_CONFIG['disable_pathinfo_parsing']        = false// if true, $_SERVER[PATH_INFO] is not parsed. May be needed on some server configurations to allow normal behavior.
207 $PHPTHUMB_CONFIG['disable_imagecopyresampled']      = false// if true, ImageCopyResampled is replaced with ImageCopyResampleBicubic. May be needed for buggy versions of PHP-GD.
208 $PHPTHUMB_CONFIG['disable_onlycreateable_passthru'] = true;   // if true, any image that can be parsed by GetImageSize() can be passed through; if false, only images that can be converted to GD by ImageCreateFrom(JPEG|GIF|PNG) functions are allowed
209
210
211 // * Speed optimizations configuration
212 //$PHPTHUMB_CONFIG['prefer_imagemagick']           = false;  // If true, use ImageMagick to resize thumbnails if possible, since it is usually faster than GD functions; if false only use ImageMagick if PHP memory limit is too low.
213 $PHPTHUMB_CONFIG['use_exif_thumbnail_for_speed'] = true; // If true, and EXIF thumbnail is available, and is larger or equal to output image dimensions, use EXIF thumbnail rather than actual source image for generating thumbnail. Benefit is only speed, avoiding resizing large image.
214 $PHPTHUMB_CONFIG['allow_local_http_src']         = true; // If true, 'src' parameter can be "http://<thishostname>/path/image.ext" instead of just "/path/image.ext"; if false then display warning message to encourage more efficient local-filename calling.
215
216 // END USER CONFIGURATION SECTION
217
218 ///////////////////////////////////////////////////////////////////////////////
219
220 // START DEFAULT PARAMETERS SECTION
221 // If any parameters are constant across ALL images, you can set them here
222
223 $PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE = true// if true, any parameters in the URL will override the defaults set here; if false, any parameters set here cannot be overridden in the URL
224 $PHPTHUMB_DEFAULTS_DISABLEGETPARAMS  = false; // if true, GETstring parameters will be ignored (except for 'src') and only below default parameters will be used; if false, both default and GETstring parameters will be used (depending on $PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE). Will be auto-set true if !empty($PHPTHUMB_CONFIG['cache_default_only_suffix'])
225
226 //$PHPTHUMB_DEFAULTS['w']    = 100;
227 //$PHPTHUMB_DEFAULTS['fltr'] = array('blur|10');
228 //$PHPTHUMB_DEFAULTS['q']    =  90;
229
230
231 // END DEFAULT PARAMETERS SECTION
232
233
234
235 ///////////////////////////////////////////////////////////////////////////////
236 // Function for generating hashed calls to phpThumb if 'high_security_enabled'
237 // example:
238 //   require_once('phpThumb.config.php');
239 //   echo '<img src="'.phpThumbURL('src=pic.jpg&w=50').'">';
240
241 function phpThumbURL($ParameterString) {
242     global $PHPTHUMB_CONFIG;
243     return str_replace(@$PHPTHUMB_CONFIG['document_root'], '', dirname(__FILE__)).DIRECTORY_SEPARATOR.'phpThumb.php?'.$ParameterString.'&hash='.md5($ParameterString.@$PHPTHUMB_CONFIG['high_security_password']);
244 }
245
246 ///////////////////////////////////////////////////////////////////////////////
247
248 ?>
Note: See TracBrowser for help on using the browser.