1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* JPGraph v4.0.3 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* // File: config.inc.php |
9
|
|
|
* // Description: Configuration constants and settings for JpGraph library |
10
|
|
|
* // Created: 2004-03-27 |
11
|
|
|
* // Ver: $Id: jpg-config.inc.php 1871 2009-09-29 05:56:39Z ljp $ |
12
|
|
|
* // |
13
|
|
|
* // Copyright (c) Asial Corporation. All rights reserved. |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
// check if jpgraph is the root folder |
17
|
1 |
|
if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) { |
18
|
1 |
|
defined('ROOT_PATH') || define('ROOT_PATH', dirname(__DIR__)); |
19
|
|
|
} elseif (file_exists(dirname(dirname(dirname(dirname(__DIR__)))) . '/vendor/autoload.php')) { |
20
|
|
|
// otherwise, jpgraph was required as a composer dependency |
21
|
|
|
defined('ROOT_PATH') || define('ROOT_PATH', dirname(dirname(dirname(dirname(__DIR__))))); |
22
|
|
|
} |
23
|
1 |
|
require_once ROOT_PATH . '/vendor/autoload.php'; |
24
|
|
|
|
25
|
|
|
use Amenadiel\JpGraph\Util\ErrMsgText; |
26
|
|
|
|
27
|
1 |
|
if (is_readable(ROOT_PATH . '/.env') && class_exists('\Symfony\Component\Dotenv\Dotenv')) { |
28
|
|
|
$dotenv = new \Symfony\Component\Dotenv\Dotenv(); |
29
|
|
|
$dotenv->load(ROOT_PATH . '/.env'); |
30
|
|
|
} |
31
|
|
|
|
32
|
1 |
|
if (getenv('JPGRAPH_DEBUGMODE') && !defined('DEBUGMODE')) { |
33
|
|
|
define('DEBUGMODE', getenv('JPGRAPH_DEBUGMODE')); |
34
|
|
|
} |
35
|
|
|
// Sets DEBUGMODE for the app. Set this to true to enable debugging outputs |
36
|
1 |
|
defined('DEBUGMODE') || define('DEBUGMODE', false); |
37
|
|
|
|
38
|
1 |
|
ini_set('display_errors', (int) DEBUGMODE); |
39
|
1 |
|
ini_set('display_startup_errors', (int) DEBUGMODE); |
40
|
1 |
|
if (DEBUGMODE) { |
41
|
|
|
error_reporting(E_ALL); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/* |
45
|
|
|
* Directories for cache and font directory. |
46
|
|
|
* Define these constants explicitly or read them from environment vars |
47
|
|
|
* |
48
|
|
|
* CACHE_DIR: |
49
|
|
|
* The full absolute name of the directory to be used to store the |
50
|
|
|
* cached image files. This directory will not be used if the USE_CACHE |
51
|
|
|
* define (further down) is false. If you enable the cache please note that |
52
|
|
|
* this directory MUST be readable and writable for the process running PHP. |
53
|
|
|
* Must end with '/' |
54
|
|
|
* |
55
|
|
|
* TTF_DIR: |
56
|
|
|
* Directory where TTF fonts can be found. Must end with '/' |
57
|
|
|
* |
58
|
|
|
* The default values used if these defines are left commented out are: |
59
|
|
|
* |
60
|
|
|
* UNIX: |
61
|
|
|
* CACHE_DIR /tmp/jpgraph_cache/ |
62
|
|
|
* TTF_DIR /usr/share/fonts/truetype/ |
63
|
|
|
* MBTTF_DIR /usr/share/fonts/truetype/ |
64
|
|
|
* |
65
|
|
|
* WINDOWS: |
66
|
|
|
* CACHE_DIR $SERVER_TEMP/jpgraph_cache/ |
67
|
|
|
* TTF_DIR $SERVER_SYSTEMROOT/fonts/ |
68
|
|
|
* MBTTF_DIR $SERVER_SYSTEMROOT/fonts/ |
69
|
|
|
* |
70
|
|
|
*/ |
71
|
|
|
|
72
|
|
|
// Define these constants explicitly |
73
|
|
|
// define('CACHE_DIR','/tmp/jpgraph_cache/'); |
74
|
|
|
// define('TTF_DIR','/usr/share/fonts/TrueType/'); |
75
|
|
|
// define('MBTTF_DIR','/usr/share/fonts/TrueType/'); |
76
|
|
|
// |
77
|
|
|
// Or read them from environment variables |
78
|
1 |
|
if (getenv('JPGRAPH_CACHE_DIR')) { |
79
|
|
|
define('CACHE_DIR', getenv('JPGRAPH_CACHE_DIR')); |
80
|
|
|
} |
81
|
1 |
|
if (getenv('JPGRAPH_TTF_DIR')) { |
82
|
|
|
define('TTF_DIR', getenv('JPGRAPH_TTF_DIR')); |
83
|
|
|
} |
84
|
1 |
|
if (getenv('JPGRAPH_MBTTF_DIR')) { |
85
|
|
|
define('MBTTF_DIR', getenv('JPGRAPH_MBTTF_DIR')); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/* |
89
|
|
|
* Cache directory specification for use with CSIM graphs that are |
90
|
|
|
* // using the cache. |
91
|
|
|
* // The directory must be the filesysystem name as seen by PHP |
92
|
|
|
* // and the 'http' version must be the same directory but as |
93
|
|
|
* // seen by the HTTP server relative to the 'htdocs' ddirectory. |
94
|
|
|
* // If a relative path is specified it is taken to be relative from where |
95
|
|
|
* // the image script is executed. |
96
|
|
|
* // Note: The default setting is to create a subdirectory in the |
97
|
|
|
* // directory from where the image script is executed and store all files |
98
|
|
|
* // there. As ususal this directory must be writeable by the PHP process. |
99
|
|
|
*/ |
100
|
1 |
|
define('CSIMCACHE_DIR', 'csimcache/'); |
101
|
1 |
|
define('CSIMCACHE_HTTP_DIR', 'csimcache/'); |
102
|
|
|
|
103
|
|
|
/* |
104
|
|
|
* Various JpGraph Settings. Adjust accordingly to your |
105
|
|
|
* // preferences. Note that cache functionality is turned off by |
106
|
|
|
* // default (Enable by setting USE_CACHE to true) |
107
|
|
|
*/ |
108
|
|
|
// Deafult locale for error messages. |
109
|
|
|
// This defaults to English = 'en' |
110
|
1 |
|
define('DEFAULT_ERR_LOCALE', 'en'); |
111
|
|
|
|
112
|
|
|
// Deafult graphic format set to 'auto' which will automatically |
113
|
|
|
// choose the best available format in the order png,gif,jpeg |
114
|
|
|
// (The supported format depends on what your PHP installation supports) |
115
|
1 |
|
define('DEFAULT_GFORMAT', 'auto'); |
116
|
|
|
|
117
|
|
|
// Should the cache be used at all? By setting this to false no |
118
|
|
|
// files will be generated in the cache directory. |
119
|
|
|
// The difference from READ_CACHE being that setting READ_CACHE to |
120
|
|
|
// false will still create the image in the cache directory |
121
|
|
|
// just not use it. By setting USE_CACHE=false no files will even |
122
|
|
|
// be generated in the cache directory. |
123
|
1 |
|
if (!defined('USE_CACHE')) { |
124
|
1 |
|
define('USE_CACHE', getenv('JPGRAPH_USE_CACHE') ? getenv('JPGRAPH_USE_CACHE') : false); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
// Should we try to find an image in the cache before generating it? |
128
|
|
|
// Set this define to false to bypass the reading of the cache and always |
129
|
|
|
// regenerate the image. Note that even if reading the cache is |
130
|
|
|
// disabled the cached will still be updated with the newly generated |
131
|
|
|
// image. Set also 'USE_CACHE' below. |
132
|
1 |
|
if (!defined('READ_CACHE')) { |
133
|
1 |
|
define('READ_CACHE', true); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
// Determine if the error handler should be image based or purely |
137
|
|
|
// text based. Image based makes it easier since the script will |
138
|
|
|
// always return an image even in case of errors. |
139
|
1 |
|
define('USE_IMAGE_ERROR_HANDLER', true); |
140
|
|
|
|
141
|
|
|
// Should the library examine the global php_errmsg string and convert |
142
|
|
|
// any error in it to a graphical representation. This is handy for the |
143
|
|
|
// occasions when, for example, header files cannot be found and this results |
144
|
|
|
// in the graph not being created and just a 'red-cross' image would be seen. |
145
|
|
|
// This should be turned off for a production site. |
146
|
1 |
|
define('CATCH_PHPERRMSG', true); |
147
|
|
|
|
148
|
|
|
// Determine if the library should also setup the default PHP |
149
|
|
|
// error handler to generate a graphic error mesage. This is useful |
150
|
|
|
// during development to be able to see the error message as an image |
151
|
|
|
// instead as a 'red-cross' in a page where an image is expected. |
152
|
1 |
|
define('INSTALL_PHP_ERR_HANDLER', false); |
153
|
|
|
|
154
|
|
|
// Should usage of deprecated functions and parameters give a fatal error? |
155
|
|
|
// (Useful to check if code is future proof.) |
156
|
1 |
|
define('ERR_DEPRECATED', true); |
157
|
|
|
|
158
|
|
|
// The builtin GD function imagettfbbox() fuction which calculates the bounding box for |
159
|
|
|
// text using TTF fonts is buggy. By setting this define to true the library |
160
|
|
|
// uses its own compensation for this bug. However this will give a |
161
|
|
|
// slightly different visual apparance than not using this compensation. |
162
|
|
|
// Enabling this compensation will in general give text a bit more space to more |
163
|
|
|
// truly reflect the actual bounding box which is a bit larger than what the |
164
|
|
|
// GD function thinks. |
165
|
1 |
|
define('USE_LIBRARY_IMAGETTFBBOX', true); |
166
|
|
|
|
167
|
|
|
/* |
168
|
|
|
* The following constants should rarely have to be changed ! |
169
|
|
|
*/ |
170
|
|
|
// What group should the cached file belong to |
171
|
|
|
// (Set to '' will give the default group for the 'PHP-user') |
172
|
|
|
// Please note that the Apache user must be a member of the |
173
|
|
|
// specified group since otherwise it is impossible for Apache |
174
|
|
|
// to set the specified group. |
175
|
1 |
|
define('CACHE_FILE_GROUP', 'www'); |
176
|
|
|
|
177
|
|
|
// What permissions should the cached file have |
178
|
|
|
// (Set to '' will give the default persmissions for the 'PHP-user') |
179
|
1 |
|
define('CACHE_FILE_MOD', 0664); |
180
|
|
|
|
181
|
|
|
// Default theme class name |
182
|
1 |
|
defined('DEFAULT_THEME_CLASS') || define('DEFAULT_THEME_CLASS', 'UniversalTheme'); |
183
|
|
|
|
184
|
1 |
|
define('SUPERSAMPLING', true); |
185
|
1 |
|
define('SUPERSAMPLING_SCALE', 1); |
186
|
|
|
|
187
|
|
|
// TTF Font families |
188
|
1 |
|
define('FF_COURIER', 10); |
189
|
1 |
|
define('FF_VERDANA', 11); |
190
|
1 |
|
define('FF_TIMES', 12); |
191
|
1 |
|
define('FF_COMIC', 14); |
192
|
1 |
|
define('FF_ARIAL', 15); |
193
|
1 |
|
define('FF_GEORGIA', 16); |
194
|
1 |
|
define('FF_TREBUCHE', 17); |
195
|
|
|
|
196
|
|
|
// Gnome Vera font |
197
|
|
|
// Available from http://www.gnome.org/fonts/ |
198
|
1 |
|
define('FF_VERA', 18); |
199
|
1 |
|
define('FF_VERAMONO', 19); |
200
|
1 |
|
define('FF_VERASERIF', 20); |
201
|
|
|
|
202
|
|
|
// Chinese font |
203
|
1 |
|
define('FF_SIMSUN', 30); |
204
|
1 |
|
define('FF_CHINESE', 31); |
205
|
1 |
|
define('FF_BIG5', 32); |
206
|
|
|
|
207
|
|
|
// Japanese font |
208
|
1 |
|
define('FF_MINCHO', 40); |
209
|
1 |
|
define('FF_PMINCHO', 41); |
210
|
1 |
|
define('FF_GOTHIC', 42); |
211
|
1 |
|
define('FF_PGOTHIC', 43); |
212
|
|
|
|
213
|
|
|
// Hebrew fonts |
214
|
1 |
|
define('FF_DAVID', 44); |
215
|
1 |
|
define('FF_MIRIAM', 45); |
216
|
1 |
|
define('FF_AHRON', 46); |
217
|
|
|
|
218
|
|
|
// Dejavu-fonts http://sourceforge.net/projects/dejavu |
219
|
1 |
|
define('FF_DV_SANSSERIF', 47); |
220
|
1 |
|
define('FF_DV_SERIF', 48); |
221
|
1 |
|
define('FF_DV_SANSSERIFMONO', 49); |
222
|
1 |
|
define('FF_DV_SERIFCOND', 50); |
223
|
1 |
|
define('FF_DV_SANSSERIFCOND', 51); |
224
|
|
|
|
225
|
|
|
// Extra fonts |
226
|
|
|
// Download fonts from |
227
|
|
|
// http://www.webfontlist.com |
228
|
|
|
// http://www.webpagepublicity.com/free-fonts.html |
229
|
|
|
// http://www.fontonic.com/fonts.asp?width=d&offset=120 |
230
|
|
|
// http://www.fontspace.com/category/famous |
231
|
|
|
|
232
|
|
|
// define("FF_SPEEDO",71); // This font is also known as Bauer (Used for development gauge fascia) |
233
|
1 |
|
define('FF_DIGITAL', 72); // Digital readout font |
234
|
1 |
|
define('FF_COMPUTER', 73); // The classic computer font |
235
|
1 |
|
define('FF_CALCULATOR', 74); // Triad font |
236
|
|
|
|
237
|
1 |
|
define('FF_USERFONT', 90); |
238
|
1 |
|
define('FF_USERFONT1', 90); |
239
|
1 |
|
define('FF_USERFONT2', 91); |
240
|
1 |
|
define('FF_USERFONT3', 92); |
241
|
|
|
|
242
|
|
|
// Limits for fonts |
243
|
1 |
|
define('_FIRST_FONT', 10); |
244
|
1 |
|
define('_LAST_FONT', 99); |
245
|
|
|
|
246
|
|
|
// TTF Font styles |
247
|
1 |
|
define('FS_NORMAL', 9001); |
248
|
1 |
|
define('FS_BOLD', 9002); |
249
|
1 |
|
define('FS_ITALIC', 9003); |
250
|
1 |
|
define('FS_BOLDIT', 9004); |
251
|
1 |
|
define('FS_BOLDITALIC', 9004); |
252
|
|
|
|
253
|
|
|
//Definitions for internal font |
254
|
1 |
|
define('FF_FONT0', 1); |
255
|
1 |
|
define('FF_FONT1', 2); |
256
|
1 |
|
define('FF_FONT2', 4); |
257
|
|
|
|
258
|
|
|
/* |
259
|
|
|
* Defines for font setup |
260
|
|
|
*/ |
261
|
|
|
// Actual name of the TTF file used together with FF_CHINESE aka FF_BIG5 |
262
|
|
|
// This is the TTF file being used when the font family is specified as |
263
|
|
|
// either FF_CHINESE or FF_BIG5 |
264
|
1 |
|
define('CHINESE_TTF_FONT', 'bkai00mp.ttf'); |
265
|
|
|
|
266
|
|
|
// Special unicode greek language support |
267
|
1 |
|
define('LANGUAGE_GREEK', false); |
268
|
|
|
|
269
|
|
|
// If you are setting this config to true the conversion of greek characters |
270
|
|
|
// will assume that the input text is windows 1251 |
271
|
1 |
|
define('GREEK_FROM_WINDOWS', false); |
272
|
|
|
|
273
|
|
|
// Special unicode cyrillic language support |
274
|
1 |
|
define('LANGUAGE_CYRILLIC', false); |
275
|
|
|
|
276
|
|
|
// If you are setting this config to true the conversion |
277
|
|
|
// will assume that the input text is windows 1251, if |
278
|
|
|
// false it will assume koi8-r |
279
|
1 |
|
define('CYRILLIC_FROM_WINDOWS', false); |
280
|
|
|
|
281
|
|
|
// The following constant is used to auto-detect |
282
|
|
|
// whether cyrillic conversion is really necessary |
283
|
|
|
// if enabled. Just replace 'windows-1251' with a variable |
284
|
|
|
// containing the input character encoding string |
285
|
|
|
// of your application calling jpgraph. |
286
|
|
|
// A typical such string would be 'UTF-8' or 'utf-8'. |
287
|
|
|
// The comparison is case-insensitive. |
288
|
|
|
// If this charset is not a 'koi8-r' or 'windows-1251' |
289
|
|
|
// derivate then no conversion is done. |
290
|
|
|
// |
291
|
|
|
// This constant can be very important in multi-user |
292
|
|
|
// multi-language environments where a cyrillic conversion |
293
|
|
|
// could be needed for some cyrillic people |
294
|
|
|
// and resulting in just erraneous conversions |
295
|
|
|
// for not-cyrillic language based people. |
296
|
|
|
// |
297
|
|
|
// Example: In the free project management |
298
|
|
|
// software dotproject.net $locale_char_set is dynamically |
299
|
|
|
// set by the language environment the user has chosen. |
300
|
|
|
// |
301
|
|
|
// Usage: define('LANGUAGE_CHARSET', $locale_char_set); |
302
|
|
|
// |
303
|
|
|
// where $locale_char_set is a GLOBAL (string) variable |
304
|
|
|
// from the application including JpGraph. |
305
|
|
|
// |
306
|
1 |
|
define('LANGUAGE_CHARSET', null); |
307
|
|
|
|
308
|
|
|
// Japanese TrueType font used with FF_MINCHO, FF_PMINCHO, FF_GOTHIC, FF_PGOTHIC |
309
|
|
|
// Standard fonts from Infomation-technology Promotion Agency (IPA) |
310
|
|
|
// See http://mix-mplus-ipa.sourceforge.jp/ |
311
|
1 |
|
define('MINCHO_TTF_FONT', 'ipam.ttf'); |
312
|
1 |
|
define('PMINCHO_TTF_FONT', 'ipamp.ttf'); |
313
|
1 |
|
define('GOTHIC_TTF_FONT', 'ipag.ttf'); |
314
|
1 |
|
define('PGOTHIC_TTF_FONT', 'ipagp.ttf'); |
315
|
|
|
|
316
|
|
|
// Assume that Japanese text have been entered in EUC-JP encoding. |
317
|
|
|
// If this define is true then conversion from EUC-JP to UTF8 is done |
318
|
|
|
// automatically in the library using the mbstring module in PHP. |
319
|
1 |
|
define('ASSUME_EUCJP_ENCODING', false); |
320
|
|
|
|
321
|
|
|
// Default font family |
322
|
1 |
|
define('FF_DEFAULT', FF_DV_SANSSERIF); |
323
|
|
|
|
324
|
|
|
// Line styles |
325
|
1 |
|
define('LINESTYLE_SOLID', 1); |
326
|
1 |
|
define('LINESTYLE_DOTTED', 2); |
327
|
1 |
|
define('LINESTYLE_DASHED', 3); |
328
|
1 |
|
define('LINESTYLE_LONGDASH', 4); |
329
|
|
|
|
330
|
|
|
// The DEFAULT_GFORMAT sets the default graphic encoding format, i.e. |
331
|
|
|
// PNG, JPG or GIF depending on what is installed on the target system |
332
|
|
|
// in that order. |
333
|
1 |
|
if (!defined('DEFAULT_GFORMAT')) { |
334
|
|
|
define('DEFAULT_GFORMAT', 'auto'); |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
// Styles for gradient color fill |
338
|
1 |
|
define('GRAD_VER', 1); |
339
|
1 |
|
define('GRAD_VERT', 1); |
340
|
1 |
|
define('GRAD_HOR', 2); |
341
|
1 |
|
define('GRAD_MIDHOR', 3); |
342
|
1 |
|
define('GRAD_MIDVER', 4); |
343
|
1 |
|
define('GRAD_CENTER', 5); |
344
|
1 |
|
define('GRAD_WIDE_MIDVER', 6); |
345
|
1 |
|
define('GRAD_WIDE_MIDHOR', 7); |
346
|
1 |
|
define('GRAD_LEFT_REFLECTION', 8); |
347
|
1 |
|
define('GRAD_RIGHT_REFLECTION', 9); |
348
|
1 |
|
define('GRAD_RAISED_PANEL', 10); |
349
|
1 |
|
define('GRAD_DIAGONAL', 11); |
350
|
1 |
|
define('_DEFAULT_LPM_SIZE', 8); // Default Legend Plot Mark size |
351
|
|
|
|
352
|
|
|
// Version info |
353
|
1 |
|
define('JPG_VERSION', '3.5.0b1'); |
354
|
|
|
|
355
|
|
|
// Minimum required PHP version |
356
|
1 |
|
define('MIN_PHPVERSION', '5.1.0'); |
357
|
|
|
|
358
|
|
|
// Special file name to indicate that we only want to calc |
359
|
|
|
// the image map in the call to Graph::Stroke() used |
360
|
|
|
// internally from the GetHTMLCSIM() method. |
361
|
1 |
|
define('_CSIM_SPECIALFILE', '_csim_special_'); |
362
|
|
|
|
363
|
|
|
// HTTP GET argument that is used with image map |
364
|
|
|
// to indicate to the script to just generate the image |
365
|
|
|
// and not the full CSIM HTML page. |
366
|
1 |
|
define('_CSIM_DISPLAY', '_jpg_csimd'); |
367
|
|
|
|
368
|
|
|
// Special filename for Graph::Stroke(). If this filename is given |
369
|
|
|
// then the image will NOT be streamed to browser of file. Instead the |
370
|
|
|
// Stroke call will return the handler for the created GD image. |
371
|
1 |
|
define('_IMG_HANDLER', '__handle'); |
372
|
|
|
|
373
|
|
|
// Special filename for Graph::Stroke(). If this filename is given |
374
|
|
|
// the image will be stroked to a file with a name based on the script name. |
375
|
1 |
|
define('_IMG_AUTO', 'auto'); |
376
|
|
|
|
377
|
|
|
// Tick density |
378
|
1 |
|
define('TICKD_DENSE', 1); |
379
|
1 |
|
define('TICKD_NORMAL', 2); |
380
|
1 |
|
define('TICKD_SPARSE', 3); |
381
|
1 |
|
define('TICKD_VERYSPARSE', 4); |
382
|
|
|
|
383
|
|
|
// Side for ticks and labels. |
384
|
1 |
|
define('SIDE_LEFT', -1); |
385
|
1 |
|
define('SIDE_RIGHT', 1); |
386
|
1 |
|
define('SIDE_DOWN', -1); |
387
|
1 |
|
define('SIDE_BOTTOM', -1); |
388
|
1 |
|
define('SIDE_UP', 1); |
389
|
1 |
|
define('SIDE_TOP', 1); |
390
|
|
|
|
391
|
|
|
// Legend type stacked vertical or horizontal |
392
|
1 |
|
define('LEGEND_VERT', 0); |
393
|
1 |
|
define('LEGEND_HOR', 1); |
394
|
|
|
|
395
|
|
|
// Mark types for plot marks |
396
|
1 |
|
define('MARK_SQUARE', 1); |
397
|
1 |
|
define('MARK_UTRIANGLE', 2); |
398
|
1 |
|
define('MARK_DTRIANGLE', 3); |
399
|
1 |
|
define('MARK_DIAMOND', 4); |
400
|
1 |
|
define('MARK_CIRCLE', 5); |
401
|
1 |
|
define('MARK_FILLEDCIRCLE', 6); |
402
|
1 |
|
define('MARK_CROSS', 7); |
403
|
1 |
|
define('MARK_STAR', 8); |
404
|
1 |
|
define('MARK_X', 9); |
405
|
1 |
|
define('MARK_LEFTTRIANGLE', 10); |
406
|
1 |
|
define('MARK_RIGHTTRIANGLE', 11); |
407
|
1 |
|
define('MARK_FLASH', 12); |
408
|
1 |
|
define('MARK_IMG', 13); |
409
|
1 |
|
define('MARK_FLAG1', 14); |
410
|
1 |
|
define('MARK_FLAG2', 15); |
411
|
1 |
|
define('MARK_FLAG3', 16); |
412
|
1 |
|
define('MARK_FLAG4', 17); |
413
|
|
|
|
414
|
|
|
// Builtin images |
415
|
1 |
|
define('MARK_IMG_PUSHPIN', 50); |
416
|
1 |
|
define('MARK_IMG_SPUSHPIN', 50); |
417
|
1 |
|
define('MARK_IMG_LPUSHPIN', 51); |
418
|
1 |
|
define('MARK_IMG_DIAMOND', 52); |
419
|
1 |
|
define('MARK_IMG_SQUARE', 53); |
420
|
1 |
|
define('MARK_IMG_STAR', 54); |
421
|
1 |
|
define('MARK_IMG_BALL', 55); |
422
|
1 |
|
define('MARK_IMG_SBALL', 55); |
423
|
1 |
|
define('MARK_IMG_MBALL', 56); |
424
|
1 |
|
define('MARK_IMG_LBALL', 57); |
425
|
1 |
|
define('MARK_IMG_BEVEL', 58); |
426
|
|
|
|
427
|
|
|
// Inline defines |
428
|
1 |
|
define('INLINE_YES', 1); |
429
|
1 |
|
define('INLINE_NO', 0); |
430
|
|
|
|
431
|
|
|
// Format for background images |
432
|
1 |
|
define('BGIMG_FILLPLOT', 1); |
433
|
1 |
|
define('BGIMG_FILLFRAME', 2); |
434
|
1 |
|
define('BGIMG_COPY', 3); |
435
|
1 |
|
define('BGIMG_CENTER', 4); |
436
|
1 |
|
define('BGIMG_FREE', 5); |
437
|
|
|
|
438
|
|
|
// Depth of objects |
439
|
1 |
|
define('DEPTH_BACK', 0); |
440
|
1 |
|
define('DEPTH_FRONT', 1); |
441
|
|
|
|
442
|
|
|
// Direction |
443
|
1 |
|
define('VERTICAL', 1); |
444
|
1 |
|
define('HORIZONTAL', 0); |
445
|
|
|
|
446
|
|
|
// Axis styles for scientific style axis |
447
|
1 |
|
define('AXSTYLE_SIMPLE', 1); |
448
|
1 |
|
define('AXSTYLE_BOXIN', 2); |
449
|
1 |
|
define('AXSTYLE_BOXOUT', 3); |
450
|
1 |
|
define('AXSTYLE_YBOXIN', 4); |
451
|
1 |
|
define('AXSTYLE_YBOXOUT', 5); |
452
|
|
|
|
453
|
|
|
// Style for title backgrounds |
454
|
1 |
|
define('TITLEBKG_STYLE1', 1); |
455
|
1 |
|
define('TITLEBKG_STYLE2', 2); |
456
|
1 |
|
define('TITLEBKG_STYLE3', 3); |
457
|
1 |
|
define('TITLEBKG_FRAME_NONE', 0); |
458
|
1 |
|
define('TITLEBKG_FRAME_FULL', 1); |
459
|
1 |
|
define('TITLEBKG_FRAME_BOTTOM', 2); |
460
|
1 |
|
define('TITLEBKG_FRAME_BEVEL', 3); |
461
|
1 |
|
define('TITLEBKG_FILLSTYLE_HSTRIPED', 1); |
462
|
1 |
|
define('TITLEBKG_FILLSTYLE_VSTRIPED', 2); |
463
|
1 |
|
define('TITLEBKG_FILLSTYLE_SOLID', 3); |
464
|
|
|
|
465
|
|
|
// Styles for axis labels background |
466
|
1 |
|
define('LABELBKG_NONE', 0); |
467
|
1 |
|
define('LABELBKG_XAXIS', 1); |
468
|
1 |
|
define('LABELBKG_YAXIS', 2); |
469
|
1 |
|
define('LABELBKG_XAXISFULL', 3); |
470
|
1 |
|
define('LABELBKG_YAXISFULL', 4); |
471
|
1 |
|
define('LABELBKG_XYFULL', 5); |
472
|
1 |
|
define('LABELBKG_XY', 6); |
473
|
|
|
|
474
|
|
|
// Style for background gradient fills |
475
|
1 |
|
define('BGRAD_FRAME', 1); |
476
|
1 |
|
define('BGRAD_MARGIN', 2); |
477
|
1 |
|
define('BGRAD_PLOT', 3); |
478
|
|
|
|
479
|
|
|
// Width of tab titles |
480
|
1 |
|
define('TABTITLE_WIDTHFIT', 0); |
481
|
1 |
|
define('TABTITLE_WIDTHFULL', -1); |
482
|
|
|
|
483
|
|
|
// Defines for 3D skew directions |
484
|
1 |
|
define('SKEW3D_UP', 0); |
485
|
1 |
|
define('SKEW3D_DOWN', 1); |
486
|
1 |
|
define('SKEW3D_LEFT', 2); |
487
|
1 |
|
define('SKEW3D_RIGHT', 3); |
488
|
|
|
|
489
|
|
|
// For internal use only |
490
|
1 |
|
define('_JPG_DEBUG', false); |
491
|
1 |
|
define('_FORCE_IMGTOFILE', false); |
492
|
1 |
|
define('_FORCE_IMGDIR', '/tmp/jpgimg/'); |
493
|
|
|
|
494
|
|
|
// |
495
|
|
|
// Automatic settings of path for cache and font directory |
496
|
|
|
// if they have not been previously specified |
497
|
|
|
// |
498
|
1 |
|
if (strstr(PHP_OS, 'WIN')) { |
499
|
|
|
define('SYSTEMROOT', getenv('SystemRoot')); |
500
|
|
|
} |
501
|
1 |
|
if (USE_CACHE) { |
502
|
|
|
if (!defined('CACHE_DIR')) { |
503
|
|
|
if (strstr(PHP_OS, 'WIN')) { |
504
|
|
|
if (empty($_SERVER['TEMP'])) { |
505
|
|
|
$t = new ErrMsgText(); |
506
|
|
|
$msg = $t->Get(11, $file, $lineno); |
507
|
|
|
die($msg); |
508
|
|
|
} |
509
|
|
|
define('CACHE_DIR', $_SERVER['TEMP'] . '/'); |
510
|
|
|
} else { |
511
|
|
|
define('CACHE_DIR', '/tmp/jpgraph_cache/'); |
512
|
|
|
} |
513
|
|
|
} |
514
|
1 |
|
} elseif (!defined('CACHE_DIR')) { |
515
|
1 |
|
define('CACHE_DIR', ''); |
516
|
|
|
} |
517
|
|
|
|
518
|
|
|
// |
519
|
|
|
// Setup path for western/latin TTF fonts |
520
|
|
|
// |
521
|
1 |
|
if (!defined('TTF_DIR')) { |
522
|
1 |
|
if (strstr(PHP_OS, 'WIN')) { |
523
|
|
|
if (empty(SYSTEMROOT)) { |
524
|
|
|
$t = new ErrMsgText(); |
525
|
|
|
$msg = $t->Get(12, $file, $lineno); |
526
|
|
|
die($msg); |
527
|
|
|
} |
528
|
|
|
define('TTF_DIR', SYSTEMROOT . '/fonts/'); |
529
|
|
|
} else { |
530
|
1 |
|
define('TTF_DIR', '/usr/share/fonts/truetype/'); |
531
|
|
|
} |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
// |
535
|
|
|
// Setup path for MultiByte TTF fonts (japanese, chinese etc.) |
536
|
|
|
// |
537
|
1 |
|
if (!defined('MBTTF_DIR')) { |
538
|
1 |
|
if (strstr(PHP_OS, 'WIN')) { |
539
|
|
|
if (empty(SYSTEMROOT)) { |
540
|
|
|
$t = new ErrMsgText(); |
541
|
|
|
$msg = $t->Get(12, $file, $lineno); |
542
|
|
|
die($msg); |
543
|
|
|
} |
544
|
|
|
define('MBTTF_DIR', SYSTEMROOT . '/fonts/'); |
545
|
|
|
} else { |
546
|
1 |
|
define('MBTTF_DIR', '/usr/share/fonts/truetype/'); |
547
|
|
|
} |
548
|
|
|
} |
549
|
|
|
|
550
|
|
|
// |
551
|
|
|
// Make sure PHP version is high enough |
552
|
|
|
// |
553
|
1 |
|
if (version_compare(PHP_VERSION, MIN_PHPVERSION) < 0) { |
554
|
|
|
Amenadiel\JpGraph\Util\JpGraphError::RaiseL(13, PHP_VERSION, MIN_PHPVERSION); |
555
|
|
|
die(); |
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
// |
559
|
|
|
// Make GD sanity check |
560
|
|
|
// |
561
|
1 |
|
if (!function_exists('imagetypes') || !function_exists('imagecreatefromstring')) { |
562
|
|
|
Amenadiel\JpGraph\Util\JpGraphError::RaiseL(25001); |
563
|
|
|
//("This PHP installation is not configured with the GD library. Please recompile PHP with GD support to run JpGraph. (Neither function imagetypes() nor imagecreatefromstring() does exist)"); |
564
|
|
|
} |
565
|
|
|
|
566
|
1 |
|
if (INSTALL_PHP_ERR_HANDLER) { |
567
|
|
|
set_error_handler('\Amenadiel\JpGraph\Util\Helper::phpErrorHandler'); |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
// |
571
|
|
|
// Check if there were any warnings, perhaps some wrong includes by the user. In this |
572
|
|
|
// case we raise it immediately since otherwise the image will not show and makes |
573
|
|
|
// debugging difficult. This is controlled by the user setting CATCH_PHPERRMSG |
574
|
|
|
// |
575
|
1 |
|
if (isset($GLOBALS['php_errormsg']) && CATCH_PHPERRMSG && !preg_match('/|Deprecated|/i', $GLOBALS['php_errormsg'])) { |
576
|
|
|
Amenadiel\JpGraph\Util\JpGraphError::RaiseL(25004, $GLOBALS['php_errormsg']); |
577
|
|
|
} |
578
|
|
|
|
579
|
|
|
// Constants for types of static bands in plot area |
580
|
1 |
|
define('BAND_RDIAG', 1); // Right diagonal lines |
581
|
1 |
|
define('BAND_LDIAG', 2); // Left diagonal lines |
582
|
1 |
|
define('BAND_SOLID', 3); // Solid one color |
583
|
1 |
|
define('BAND_VLINE', 4); // Vertical lines |
584
|
1 |
|
define('BAND_HLINE', 5); // Horizontal lines |
585
|
1 |
|
define('BAND_3DPLANE', 6); // "3D" Plane |
586
|
1 |
|
define('BAND_HVCROSS', 7); // Vertical/Hor crosses |
587
|
1 |
|
define('BAND_DIAGCROSS', 8); // Diagonal crosses |
588
|
|
|
|
589
|
|
|
// Maximum size for Automatic Gantt chart |
590
|
1 |
|
define('MAX_GANTTIMG_SIZE_W', 8000); |
591
|
1 |
|
define('MAX_GANTTIMG_SIZE_H', 5000); |
592
|
|
|
|
593
|
|
|
// Scale Header types |
594
|
1 |
|
define('GANTT_HDAY', 1); |
595
|
1 |
|
define('GANTT_HWEEK', 2); |
596
|
1 |
|
define('GANTT_HMONTH', 4); |
597
|
1 |
|
define('GANTT_HYEAR', 8); |
598
|
1 |
|
define('GANTT_HHOUR', 16); |
599
|
1 |
|
define('GANTT_HMIN', 32); |
600
|
|
|
|
601
|
|
|
// Bar patterns |
602
|
1 |
|
define('GANTT_RDIAG', BAND_RDIAG); // Right diagonal lines |
603
|
1 |
|
define('GANTT_LDIAG', BAND_LDIAG); // Left diagonal lines |
604
|
1 |
|
define('GANTT_SOLID', BAND_SOLID); // Solid one color |
605
|
1 |
|
define('GANTT_VLINE', BAND_VLINE); // Vertical lines |
606
|
1 |
|
define('GANTT_HLINE', BAND_HLINE); // Horizontal lines |
607
|
1 |
|
define('GANTT_3DPLANE', BAND_3DPLANE); // "3D" Plane |
608
|
1 |
|
define('GANTT_HVCROSS', BAND_HVCROSS); // Vertical/Hor crosses |
609
|
1 |
|
define('GANTT_DIAGCROSS', BAND_DIAGCROSS); // Diagonal crosses |
610
|
|
|
|
611
|
|
|
// Conversion constant |
612
|
1 |
|
define('HOURADJ_1', 0 + 30); |
613
|
1 |
|
define('HOURADJ_2', 1 + 30); |
614
|
1 |
|
define('HOURADJ_3', 2 + 30); |
615
|
1 |
|
define('HOURADJ_4', 3 + 30); |
616
|
1 |
|
define('HOURADJ_6', 4 + 30); |
617
|
1 |
|
define('HOURADJ_12', 5 + 30); |
618
|
|
|
|
619
|
1 |
|
define('MINADJ_1', 0 + 20); |
620
|
1 |
|
define('MINADJ_5', 1 + 20); |
621
|
1 |
|
define('MINADJ_10', 2 + 20); |
622
|
1 |
|
define('MINADJ_15', 3 + 20); |
623
|
1 |
|
define('MINADJ_30', 4 + 20); |
624
|
|
|
|
625
|
1 |
|
define('SECADJ_1', 0); |
626
|
1 |
|
define('SECADJ_5', 1); |
627
|
1 |
|
define('SECADJ_10', 2); |
628
|
1 |
|
define('SECADJ_15', 3); |
629
|
1 |
|
define('SECADJ_30', 4); |
630
|
|
|
|
631
|
1 |
|
define('YEARADJ_1', 0 + 30); |
632
|
1 |
|
define('YEARADJ_2', 1 + 30); |
633
|
1 |
|
define('YEARADJ_5', 2 + 30); |
634
|
|
|
|
635
|
1 |
|
define('MONTHADJ_1', 0 + 20); |
636
|
1 |
|
define('MONTHADJ_6', 1 + 20); |
637
|
|
|
|
638
|
1 |
|
define('DAYADJ_1', 0); |
639
|
1 |
|
define('DAYADJ_WEEK', 1); |
640
|
1 |
|
define('DAYADJ_7', 1); |
641
|
|
|
|
642
|
1 |
|
define('SECPERYEAR', 31536000); |
643
|
1 |
|
define('SECPERDAY', 86400); |
644
|
1 |
|
define('SECPERHOUR', 3600); |
645
|
1 |
|
define('SECPERMIN', 60); |
646
|
|
|
|
647
|
|
|
// Locales. ONLY KEPT FOR BACKWARDS COMPATIBILITY |
648
|
|
|
// You should use the proper locale strings directly |
649
|
|
|
// from now on. |
650
|
1 |
|
define('LOCALE_EN', 'en_UK'); |
651
|
1 |
|
define('LOCALE_SV', 'sv_SE'); |
652
|
|
|
|
653
|
|
|
// Layout of bars |
654
|
1 |
|
define('GANTT_EVEN', 1); |
655
|
1 |
|
define('GANTT_FROMTOP', 2); |
656
|
|
|
|
657
|
|
|
// Style for minute header |
658
|
1 |
|
define('MINUTESTYLE_MM', 0); // 15 |
659
|
1 |
|
define('MINUTESTYLE_CUSTOM', 2); // Custom format |
660
|
|
|
|
661
|
|
|
// Style for hour header |
662
|
1 |
|
define('HOURSTYLE_HM24', 0); // 13:10 |
663
|
1 |
|
define('HOURSTYLE_HMAMPM', 1); // 1:10pm |
664
|
1 |
|
define('HOURSTYLE_H24', 2); // 13 |
665
|
1 |
|
define('HOURSTYLE_HAMPM', 3); // 1pm |
666
|
1 |
|
define('HOURSTYLE_CUSTOM', 4); // User defined |
667
|
|
|
|
668
|
|
|
// Style for day header |
669
|
1 |
|
define('DAYSTYLE_ONELETTER', 0); // "M" |
670
|
1 |
|
define('DAYSTYLE_LONG', 1); // "Monday" |
671
|
1 |
|
define('DAYSTYLE_LONGDAYDATE1', 2); // "Monday 23 Jun" |
672
|
1 |
|
define('DAYSTYLE_LONGDAYDATE2', 3); // "Monday 23 Jun 2003" |
673
|
1 |
|
define('DAYSTYLE_SHORT', 4); // "Mon" |
674
|
1 |
|
define('DAYSTYLE_SHORTDAYDATE1', 5); // "Mon 23/6" |
675
|
1 |
|
define('DAYSTYLE_SHORTDAYDATE2', 6); // "Mon 23 Jun" |
676
|
1 |
|
define('DAYSTYLE_SHORTDAYDATE3', 7); // "Mon 23" |
677
|
1 |
|
define('DAYSTYLE_SHORTDATE1', 8); // "23/6" |
678
|
1 |
|
define('DAYSTYLE_SHORTDATE2', 9); // "23 Jun" |
679
|
1 |
|
define('DAYSTYLE_SHORTDATE3', 10); // "Mon 23" |
680
|
1 |
|
define('DAYSTYLE_SHORTDATE4', 11); // "23" |
681
|
1 |
|
define('DAYSTYLE_CUSTOM', 12); // "M" |
682
|
|
|
|
683
|
|
|
// Styles for week header |
684
|
1 |
|
define('WEEKSTYLE_WNBR', 0); |
685
|
1 |
|
define('WEEKSTYLE_FIRSTDAY', 1); |
686
|
1 |
|
define('WEEKSTYLE_FIRSTDAY2', 2); |
687
|
1 |
|
define('WEEKSTYLE_FIRSTDAYWNBR', 3); |
688
|
1 |
|
define('WEEKSTYLE_FIRSTDAY2WNBR', 4); |
689
|
|
|
|
690
|
|
|
// Styles for month header |
691
|
1 |
|
define('MONTHSTYLE_SHORTNAME', 0); |
692
|
1 |
|
define('MONTHSTYLE_LONGNAME', 1); |
693
|
1 |
|
define('MONTHSTYLE_LONGNAMEYEAR2', 2); |
694
|
1 |
|
define('MONTHSTYLE_SHORTNAMEYEAR2', 3); |
695
|
1 |
|
define('MONTHSTYLE_LONGNAMEYEAR4', 4); |
696
|
1 |
|
define('MONTHSTYLE_SHORTNAMEYEAR4', 5); |
697
|
1 |
|
define('MONTHSTYLE_FIRSTLETTER', 6); |
698
|
|
|
|
699
|
|
|
// Types of constrain links |
700
|
1 |
|
define('CONSTRAIN_STARTSTART', 0); |
701
|
1 |
|
define('CONSTRAIN_STARTEND', 1); |
702
|
1 |
|
define('CONSTRAIN_ENDSTART', 2); |
703
|
1 |
|
define('CONSTRAIN_ENDEND', 3); |
704
|
|
|
|
705
|
|
|
// Arrow direction for constrain links |
706
|
1 |
|
define('ARROW_DOWN', 0); |
707
|
1 |
|
define('ARROW_UP', 1); |
708
|
1 |
|
define('ARROW_LEFT', 2); |
709
|
1 |
|
define('ARROW_RIGHT', 3); |
710
|
|
|
|
711
|
|
|
// Arrow type for constrain type |
712
|
1 |
|
define('ARROWT_SOLID', 0); |
713
|
1 |
|
define('ARROWT_OPEN', 1); |
714
|
|
|
|
715
|
|
|
// Arrow size for constrain lines |
716
|
1 |
|
define('ARROW_S1', 0); |
717
|
1 |
|
define('ARROW_S2', 1); |
718
|
1 |
|
define('ARROW_S3', 2); |
719
|
1 |
|
define('ARROW_S4', 3); |
720
|
1 |
|
define('ARROW_S5', 4); |
721
|
|
|
|
722
|
|
|
// Activity types for use with utility method CreateSimple() |
723
|
1 |
|
define('ACTYPE_NORMAL', 0); |
724
|
1 |
|
define('ACTYPE_GROUP', 1); |
725
|
1 |
|
define('ACTYPE_MILESTONE', 2); |
726
|
|
|
|
727
|
1 |
|
define('ACTINFO_3D', 1); |
728
|
1 |
|
define('ACTINFO_2D', 0); |
729
|
|
|
|
730
|
1 |
|
define('GICON_WARNINGRED', 0); |
731
|
1 |
|
define('GICON_TEXT', 1); |
732
|
1 |
|
define('GICON_ENDCONS', 2); |
733
|
1 |
|
define('GICON_MAIL', 3); |
734
|
1 |
|
define('GICON_STARTCONS', 4); |
735
|
1 |
|
define('GICON_CALC', 5); |
736
|
1 |
|
define('GICON_MAGNIFIER', 6); |
737
|
1 |
|
define('GICON_LOCK', 7); |
738
|
1 |
|
define('GICON_STOP', 8); |
739
|
1 |
|
define('GICON_WARNINGYELLOW', 9); |
740
|
1 |
|
define('GICON_FOLDEROPEN', 10); |
741
|
1 |
|
define('GICON_FOLDER', 11); |
742
|
1 |
|
define('GICON_TEXTIMPORTANT', 12); |
743
|
|
|
|
744
|
1 |
|
if (!class_exists('\Kint')) { |
745
|
|
|
/** |
746
|
|
|
* Class that mocks Kint |
747
|
|
|
* (will use this when dev dependencies are not installed). |
748
|
|
|
*/ |
749
|
|
|
class Kint |
|
|
|
|
750
|
|
|
{ |
751
|
|
|
public static $enabled_mode = true; |
752
|
|
|
|
753
|
|
|
public static function dump() |
754
|
|
|
{ |
755
|
|
|
} |
756
|
|
|
} |
757
|
|
|
} |
758
|
|
|
|
759
|
1 |
|
if (property_exists('\Kint', 'enabled_mode')) { |
760
|
1 |
|
\Kint::$enabled_mode = DEBUGMODE; |
761
|
|
|
} elseif (method_exists('\Kint', 'enabled')) { |
762
|
|
|
\Kint::enabled(DEBUGMODE); |
|
|
|
|
763
|
|
|
} |
764
|
|
|
|
765
|
1 |
|
if (!function_exists('is_countable')) { |
766
|
|
|
function is_countable($c) |
767
|
|
|
{ |
768
|
18 |
|
return is_array($c) || $c instanceof Countable; |
769
|
|
|
} |
770
|
|
|
} |
771
|
|
|
|
772
|
|
|
/** |
773
|
|
|
* Returns the item count of the variable, or zero if it's non countable. |
774
|
|
|
* |
775
|
|
|
* @param mixed $var The variable whose items we want to count |
776
|
|
|
*/ |
777
|
|
|
function safe_count($var) |
778
|
|
|
{ |
779
|
18 |
|
if (is_countable($var)) { |
780
|
18 |
|
return count($var); |
781
|
|
|
} |
782
|
|
|
|
783
|
14 |
|
return 0; |
784
|
|
|
} |
785
|
|
|
|
786
|
1 |
|
if (!class_exists('\PhpConsole\Handler')) { |
787
|
|
|
/** |
788
|
|
|
* Class that mocks PHP-Console debug feature. |
789
|
|
|
*/ |
790
|
|
|
class PC |
|
|
|
|
791
|
|
|
{ |
792
|
|
|
public static function debug() |
793
|
|
|
{ |
794
|
|
|
} |
795
|
|
|
} |
796
|
|
|
} elseif ( |
797
|
1 |
|
getenv('JPGRAPH_USE_PHPCONSOLE') && |
798
|
1 |
|
isset($_SERVER['HTTP_USER_AGENT']) && |
799
|
1 |
|
strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false |
800
|
|
|
) { |
801
|
|
|
$handler = \PhpConsole\Handler::getInstance(); |
802
|
|
|
\PhpConsole\Helper::register(); |
803
|
|
|
$handler->start(); |
804
|
|
|
\PC::debug('Started'); |
805
|
|
|
} |
806
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.