This repository has been archived by the owner on Jul 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathslirconfigdefaults.class.php
executable file
·236 lines (213 loc) · 7.87 KB
/
slirconfigdefaults.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<?php
/**
* Configuration file for SLIR (Smart Lencioni Image Resizer)
*
* This file is part of SLIR (Smart Lencioni Image Resizer).
*
* Copyright (c) 2014 Joe Lencioni <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @copyright Copyright © 2014, Joe Lencioni
* @license MIT
* @since 2.0
* @package SLIR
*/
/**
* SLIR Config Class
*
* @since 2.0
* @author Joe Lencioni <[email protected]>
* @package SLIR
*/
class SLIRConfigDefaults
{
/**
* Path to default the source image to if the requested image cannot be found.
*
* This should match the style of path you would normally pass to SLIR in the URL (not the full path on the filesystem).
*
* For example, if your website was http://mysite.com and your document root was /var/www/, and your default image was at http://mysite.com/images/default.png, you would set $defaultImagePath = '/images/default.png';
*
* If null, SLIR will throw an exception if the requested image cannot be found.
*
* @since 2.0
* @var string
*/
public static $defaultImagePath = null;
/**
* Default quality setting to use if quality is not specified in the request. Ranges from 0 (worst quality, smaller file) to 100 (best quality, largest filesize).
*
* @since 2.0
* @var integer
*/
public static $defaultQuality = 80;
/**
* Default setting for whether JPEGs should be progressive JPEGs (interlaced) or not.
*
* @since 2.0
* @var boolean
*/
public static $defaultProgressiveJPEG = true;
/**
* How long (in seconds) the web browser should use its cached copy of the image
* before checking with the server for a new version
*
* @since 2.0
* @var integer
*/
public static $browserCacheTTL = 604800; // 7 days = 7 * 24 * 60 * 60
/**
* If true, enables the faster, symlink-based request cache as a first-line cache. If false, the request cache is disabled.
*
* The request cache seems to have issues on some Windows servers.
*
* @since 2.0
* @var boolean
*/
public static $enableRequestCache = true;
/**
* How much memory (in megabytes) SLIR is allowed to allocate for memory-intensive processes such as rendering and cropping.
*
* @since 2.0
* @var integer
*/
public static $maxMemoryToAllocate = 100;
/**
* Default crop mode setting to use if crop mode is not specified in the request.
*
* Possible values are:
* SLIR::CROP_CLASS_CENTERED
* SLIR::CROP_CLASS_TOP_CENTERED
* SLIR::CROP_CLASS_SMART
*
* @since 2.0
* @var string
*/
public static $defaultCropper = SLIR::CROP_CLASS_CENTERED;
/**
* If true, SLIR will generate and output images from error messages. If false, error messages will be plaintext.
*
* @since 2.0
* @var boolean
*/
public static $enableErrorImages = true;
/**
* Absolute path to the web root (location of files when visiting http://example.com/) (no trailing slash).
*
* For example, if the files for your website are located in /var/www/ on your server, this should be '/var/www'.
*
* By default, this is dyanmically determined, so it is set in the init() function and hopefully will not need to be overwritten. However, if SLIR isn't working correctly, it might not be determining your document root correctly and you might need to set this manually in your configuration file.
*
* @since 2.0
* @var string
*/
public static $documentRoot = null;
/**
* Absolute path to SLIR (no trailing slash) from the root directory on your server's filesystem.
*
* For example, if the files on your website are in /var/www/ and slir is accessible at http://example.com/slir/, then the value of this setting should be '/var/www/slir'.
*
* By default, this is dyanmically determined, so it is set in the init() function and hopefully will not need to be overwritten. However, if SLIR isn't working correctly, it might not be determining the path to SLIR correctly and you might need to set this manually in your configuration file.
*
* @since 2.0
* @var string
*/
public static $pathToSLIR = null;
/**
* Absolute path to cache directory (no trailing slash). This directory must be world-readable, writable by the web server. Ideally, this directory should be located outside of the web tree for security reasons.
*
* By default, this is dynamically determined in the init() function and it defaults to /path/to/slir/cache (or $pathToSlir . '/cache') which is the cache directory inside the directory SLIR is located.
*
* @var string
*/
public static $pathToCacheDir = null;
/**
* Path to the error log file. Needs to be writable by the web server. Ideally, this should be located outside of the web tree.
*
* If not specified, defaults to 'slir-error-log' in the directory SLIR is located.
*
* @since 2.0
* @var string
*/
public static $pathToErrorLog = null;
/**
* If true, forces SLIR to always use the query string for parameters instead of mod_rewrite.
*
* @since 2.0
* @var boolean
*/
public static $forceQueryString = false;
/**
* In conjunction with $garbageCollectDivisor is used to manage probability that the garbage collection routine is started.
*
* @since 2.0
* @var integer
*/
public static $garbageCollectProbability = 1;
/**
* Coupled with $garbageCollectProbability defines the probability that the garbage collection process is started on every request.
*
* The probability is calculated by using $garbageCollectProbability/$garbageCollectDivisor, e.g. 1/100 means there is a 1% chance that the garbage collection process starts on each request.
*
* @since 2.0
* @var integer
*/
public static $garbageCollectDivisor = 200;
/**
* Specifies the number of seconds after which data will be seen as 'garbage' and potentially cleaned up (deleted from the cache).
*
* @since 2.0
* @var integer
*/
public static $garbageCollectFileCacheMaxLifetime = 604800; // 7 days = 7 * 24 * 60 * 60
/**
* If true, SLIR will copy EXIF information should from the source image to the rendered image.
*
* This can be particularly useful (necessary?) if you use an embedded color profile.
*
* @since 2.0
* @var boolean
*/
public static $copyEXIF = false;
/**
* Initialize variables that require some dynamic processing.
*
* @since 2.0
* @return void
*/
public static function init()
{
if (!defined('__DIR__')) {
define('__DIR__', dirname(__FILE__));
}
if (self::$documentRoot === null) {
self::$documentRoot = $_SERVER['DOCUMENT_ROOT'];
}
if (self::$pathToSLIR === null) {
self::$pathToSLIR = realpath(__DIR__ . '/../');
}
if (self::$pathToCacheDir === null) {
self::$pathToCacheDir = self::$pathToSLIR . '/cache';
}
if (self::$pathToErrorLog === null) {
self::$pathToErrorLog = self::$pathToSLIR . '/slir-error-log';
}
}
}