root/devel-backup/units/phpthumb/phpThumb.config.php

Revision 45, 14.3 kB (checked in by sven, 3 years ago)

dos2unix to clean line endings, set svn property eol-style native, some whitespace homogenisation

  • Property svn:eol-style set to native
Line 
1 <?php
2
3 require("../../includes.php");
4
5 //////////////////////////////////////////////////////////////
6 ///  phpThumb() by James Heinrich <info@silisoftware.com>   //
7 //        available at http://phpthumb.sourceforge.net     ///
8 //////////////////////////////////////////////////////////////
9 ///                                                         //
10 // See: phpthumb.readme.txt for usage instructions          //
11 //                                                         ///
12 //////////////////////////////////////////////////////////////
13
14 if (!file_exists('phpthumb.functions.php') || !include_once('phpthumb.functions.php')) {
15     die('failed to include_once(phpthumb.functions.php) - realpath="'.realpath('phpthumb.functions.php').'"');
16 }
17
18 // START USER CONFIGURATION SECTION:
19
20 // * DocumentRoot configuration
21 // phpThumb() depends on $_SERVER['DOCUMENT_ROOT'] to resolve path/filenames. This value is almost always correct,
22 // but has been known to be broken on rare occasion. This value allows you to override the default value.
23 // Do not modify from the default value of $_SERVER['DOCUMENT_ROOT'] unless you are having problems.
24 //$PHPTHUMB_CONFIG['document_root'] = '/home/httpd/httpdocs';
25 //$PHPTHUMB_CONFIG['document_root'] = 'c:\\webroot\\example.com\\www';
26 //echo @$_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF'].' = '.md5_file(@$_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']).'<br>';
27 //echo realpath('.').'/'.basename($_SERVER['PHP_SELF']).' = '.md5_file(realpath('.').'/'.basename($_SERVER['PHP_SELF'])).'<br>';
28 //exit;
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'] = path.'_files/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
40 $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)
41
42 // * Cache culling: phpThumb can automatically limit the contents of the cache directory
43 // based on last-access date and/or number of files and/or total filesize.
44 $PHPTHUMB_CONFIG['cache_maxage'] = null;         // never delete cached thumbnails based on last-access time
45 //$PHPTHUMB_CONFIG['cache_maxage'] = 86400 * 30; // delete cached thumbnails that haven't been accessed in more than [30 days] (value is maximum time since last access in seconds to avoid deletion)
46
47 //$PHPTHUMB_CONFIG['cache_maxsize'] = null;   // never delete cached thumbnails based on byte size of cache directory
48 $PHPTHUMB_CONFIG['cache_maxsize'] = 1048576000; // delete least-recently-accessed cached thumbnails when more than [10MB] of cached files are present (value is maximum bytesize of all cached files)
49
50 $PHPTHUMB_CONFIG['cache_maxfiles'] = null// never delete cached thumbnails based on number of cached files
51 //$PHPTHUMB_CONFIG['cache_maxfiles'] = 500; // delete least-recently-accessed cached thumbnails when more than [500] cached files are present (value is maximum number of cached files to keep)
52
53
54 // * Source image cache configuration
55 $PHPTHUMB_CONFIG['cache_source_enabled']   = false;                               // if true, source images obtained via HTTP are cached to $PHPTHUMB_CONFIG['cache_source_directory']
56 $PHPTHUMB_CONFIG['cache_source_directory'] = dirname(__FILE__).'/cache/source/'// set the cache directory for unprocessed source images
57
58
59 // * Temp directory configuration
60 // phpThumb() may need to create temp files. Usually the system temp dir is writable and can be used.
61 // Leave this value as NULL in most cases. If you get errors about "failed to open <filename> for writing"
62 // you should change this to a full pathname to a directory you do have write access to.
63 //$PHPTHUMB_CONFIG['temp_directory'] = '/tmp/';
64 $PHPTHUMB_CONFIG['temp_directory'] = null;
65
66
67 // maximum number of pixels in source image to attempt to process entire image.
68 // If this is zero then no limit on source image dimensions.
69 // If this is nonzero then this is the maximum number of pixels the source image
70 // can have to be processed normally, otherwise the embedded EXIF thumbnail will
71 // be used (if available) or an "image too large" notice will be displayed.
72 // This is to be used for large source images (> 1600x1200) and low PHP memory
73 // limits. If PHP runs out of memory the script will usually just die with no output.
74 // To calculate this number, multiply the dimensions of the largest image
75 // you can process with your memory limitation (e.g. 1600 * 1200 = 1920000)
76 // As a general guideline, this number will be about 20% of your PHP memory
77 // configuration, so 8M = 1,677,722; 16M = 3,355,443; 32M = 6,710,886; etc.
78 if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.2', '>=') && !defined('memory_get_usage') && !@ini_get('memory_limit')) {
79     // memory_get_usage() will only be defined if your PHP is compiled with the --enable-memory-limit configuration option.
80     $PHPTHUMB_CONFIG['max_source_pixels'] = 0;         // no memory limit
81 } else {
82     // calculate default max_source_pixels as 20% of memory limit configuration
83     $PHPTHUMB_CONFIG['max_source_pixels'] = round(max(intval(ini_get('memory_limit')), intval(get_cfg_var('memory_limit'))) * 1048576 * 0.20);
84     //$PHPTHUMB_CONFIG['max_source_pixels'] = 0;       // no memory limit
85     //$PHPTHUMB_CONFIG['max_source_pixels'] = 1920000; // allow 1600x1200 images (2Mpx), no larger (about 10MB memory required)
86     //$PHPTHUMB_CONFIG['max_source_pixels'] = 3355443; // 16MB memory limit
87     //$PHPTHUMB_CONFIG['max_source_pixels'] = 3871488; // allow 2272x1704 images (4Mpx), no larger (about 16MB memory required)
88 }
89
90
91 // ImageMagick configuration
92 // If source image is larger than available memory limits as defined above in
93 // 'max_source_pixels' AND ImageMagick's "convert" program is available, phpThumb()
94 // will call ImageMagick to perform the thumbnailing of the source image to bypass
95 // the memory limitation. Leaving the value as NULL will cause phpThumb() to
96 // attempt to detect ImageMagick's presence with `which`
97 if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
98     // Windows: set absolute pathname
99     $PHPTHUMB_CONFIG['imagemagick_path'] = 'C:\\Program Files\\ImageMagick-6.0.6-Q16\\convert.exe';
100 } else {
101     // *nix: set absolute pathname to "convert", or leave as null if "convert" is in the path
102     //$PHPTHUMB_CONFIG['imagemagick_path'] = '/usr/local/bin/convert';
103     $PHPTHUMB_CONFIG['imagemagick_path'] = null;
104 }
105
106
107 // * Default output configuration:
108 $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
109 $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
110 $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
111 $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.
112
113 // * Error message configuration
114 $PHPTHUMB_CONFIG['error_image_width']           = 100;      // default width for error images
115 $PHPTHUMB_CONFIG['error_image_height']          = 100;      // default height for error images
116 $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.
117 $PHPTHUMB_CONFIG['error_bgcolor']               = 'CCCCFF'; // background color of error message images
118 $PHPTHUMB_CONFIG['error_textcolor']             = 'FF0000'; // color of text in error messages
119 $PHPTHUMB_CONFIG['error_fontsize']              = 1;        // size of text in error messages, from 1 (smallest) to 5 (largest)
120 $PHPTHUMB_CONFIG['error_die_on_error']          = true;     // die with error message on any fatal error (recommended with standalone phpThumb.php)
121 $PHPTHUMB_CONFIG['error_silent_die_on_error']   = false;    // simply die with no output of any kind on fatal errors (not recommended)
122 $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 (default) the source image will be passed through unprocessed, if true an error message will be displayed.
123
124 // * Off-server Thumbnailing Configuration:
125 $PHPTHUMB_CONFIG['nohotlink_enabled']           = true;                                     // If false will allow thumbnailing from any source domain
126 $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'
127 $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
128 $PHPTHUMB_CONFIG['nohotlink_text_message']      = 'Off-server thumbnailing is not allowed'; // text of error message
129 // * Off-server Linking Configuration:
130 $PHPTHUMB_CONFIG['nooffsitelink_enabled']       = true;                                       // 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.
131 $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'
132 $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.
133 $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
134 $PHPTHUMB_CONFIG['nooffsitelink_text_message']  = 'Image taken from '.@$_SERVER['HTTP_HOST']; // text of error message
135
136 // * Border & Background default colors
137 $PHPTHUMB_CONFIG['border_hexcolor']     = '000000'; // Default border color - usual HTML-style hex color notation (overidden with 'bc' parameter)
138 $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)
139
140 // * Watermark configuration
141 $PHPTHUMB_CONFIG['ttf_directory'] = '.'; // Base directory for TTF font files
142 //$PHPTHUMB_CONFIG['ttf_directory'] = 'c:/windows/fonts';
143
144
145 $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
146 $PHPTHUMB_CONFIG['high_security_password'] = '';    // required if 'high_security_enabled' is true, must be at least 5 characters long
147 $PHPTHUMB_CONFIG['disable_debug']          = false; // Prevent phpThumb from displaying any information about your system. If true, phpThumbDebug and error messages will be disabled
148
149
150 $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.
151
152 // if true, and source image is smaller than 'w' & 'h' parameters or $PHPTHUMB_CONFIG['output_maxheight'] / $PHPTHUMB_CONFIG['output_maxwidth']
153 // will be enlarged to that size. If false then small images will not be enlarged beyond their original dimensions
154 $PHPTHUMB_CONFIG['output_allow_enlarging'] = (isset($_REQUEST['aoe']) ? (bool) $_REQUEST['aoe'] : false);
155
156 // END USER CONFIGURATION SECTION
157
158 ///////////////////////////////////////////////////////////////////////////////
159
160 // START DEFAULT PARAMETERS SECTION
161 // If any parameters are constant across ALL images, you can set them here
162
163 // If true, any parameters in the URL will override the defaults set here
164 // If false, any parameters set here cannot be overridden in the URL
165 $PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE = true;
166
167 //$PHPTHUMB_DEFAULTS['w']    = 200;
168 //$PHPTHUMB_DEFAULTS['fltr'] = array('wmi|/images/watermark.png');
169 //$PHPTHUMB_DEFAULTS['q']    =  90;
170
171
172 // END DEFAULT PARAMETERS SECTION
173
174
175
176 ///////////////////////////////////////////////////////////////////////////////
177 // function for generating hashed calls to phpThumb if 'high_security_enabled'
178 // echo '<img src="'.phpThumbURL('src=pic.jpg&w=50').'">';
179
180 function phpThumbURL($ParameterString) {
181     global $PHPTHUMB_CONFIG;
182     return 'phpThumb.php?'.$ParameterString.'&hash='.md5($ParameterString.$PHPTHUMB_CONFIG['high_security_password']);
183 }
184
185 ///////////////////////////////////////////////////////////////////////////////
186
187 s?>
Note: See TracBrowser for help on using the browser.