-
Notifications
You must be signed in to change notification settings - Fork 0
/
serendipity_config.inc.php
567 lines (474 loc) · 23.1 KB
/
serendipity_config.inc.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
if (defined('S9Y_FRAMEWORK')) {
return;
}
@define('S9Y_FRAMEWORK', true);
if (!headers_sent() && php_sapi_name() !== 'cli') {
// Only set the session name, if no session has yet been issued.
if (session_id() == '') {
$cookieParams = session_get_cookie_params();
$cookieParams['secure'] = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? true : false);
$cookieParams['httponly'] = $cookieParams['secure'] === true ? false : true;
$cookieParams['path'] = dirname($_SERVER['PHP_SELF']);
$cookieParams['samesite'] = 'Lax';
// Remember: 'lifetime' param in session_set_cookie_params() is, what 'expires' is in setcookie()
#session_set_cookie_params($cookieParams['lifetime'], $cookieParams['path'], $cookieParams['domain'], $cookieParams['secure'], $cookieParams['httponly']);
session_set_cookie_params($cookieParams); // use as $options array to support 6th param sameSite ! Requires PHP 7.3.0 ++ !!
session_name('s9y_' . md5(dirname(__FILE__)));
session_start();
}
// Prevent session fixation by only allowing sessions that have been sent by the server.
// Any session that does not contain our unique token will be regarded as foreign/fixated
// and be regenerated with a system-generated SID.
// Patch by David Vieira-Kurz of majorsecurity.de
if (!isset($_SESSION['SERVER_GENERATED_SID'])) {
session_regenerate_id(true);
@session_start();
header('X-Session-Reinit: true');
$_SESSION['SERVER_GENERATED_SID'] = $_SERVER['REMOTE_ADDR'] . $_SERVER['QUERY_STRING'];
}
}
if (!defined('S9Y_INCLUDE_PATH')) {
define('S9Y_INCLUDE_PATH', dirname(__FILE__) . '/');
}
define('S9Y_CONFIG_TEMPLATE', S9Y_INCLUDE_PATH . 'include/tpl/config_local.inc.php');
define('S9Y_CONFIG_USERTEMPLATE', S9Y_INCLUDE_PATH . 'include/tpl/config_personal.inc.php');
define('IS_installed', file_exists('serendipity_config_local.inc.php') && (filesize('serendipity_config_local.inc.php') > 0));
if (!defined('IN_serendipity')) {
define('IN_serendipity', true);
}
include(S9Y_INCLUDE_PATH . 'include/compat.inc.php');
if (defined('USE_MEMSNAP')) {
echo memSnap('Framework init');
}
// The version string
$serendipity['version'] = '4.5.0';
$serendipity['edition'] = 'Styx';
// Setting this to 'false' will enable debugging output.
// All alpha/beta/cvs snapshot versions will emit debug information by default.
// To manually increase the debug level (and to enable Smarty debugging), set this flag
// to 'debug' in your serendipity_config_local.inc.php file.
if (!isset($serendipity['production'])) {
$serendipity['production'] = ! preg_match('@\-(alpha|beta|cvs|rc).*@', $serendipity['version']);
}
// Set error reporting - watch out non-production settings down below
error_reporting(E_ALL & ~(E_NOTICE|@E_STRICT|E_DEPRECATED)); // is 22519 with 5.4+
if ($serendipity['production'] !== true) {
@ini_set('display_errors', 'on');
}
// The serendipity error handler string
$serendipity['errorhandler'] = 'errorToExceptionHandler';
// Default rewrite method
$serendipity['rewrite'] = 'none';
// Message container
$serendipity['messagestack'] = array();
// Can the user change the date of publishing for an entry?
$serendipity['allowDateManipulation'] = true;
// How much time is allowed to pass since the publishing of an entry, so that a comment to that entry
// will update it's LastModified stamp? If the time is passed, a comment to an old entry will no longer
// push an article as being updated. This is for RSS-Feed caching update guidance. Default 1 week.
$serendipity['max_last_modified'] = 60 * 60 * 24 * 7;
// Clients can send a If-Modified Header to the RSS Feed (Conditional Get) and receive all articles beyond
// that date. However it is still limited by the number below of maximum entries
$serendipity['max_fetch_limit'] = 50;
// Users may try to break database limits by very loooong page requests. We assume this is enough!
$serendipity['max_page_limit'] = 2500;
// How many bytes are allowed for fetching trackbacks, so that no binary files get accidentally trackbacked?
$serendipity['trackback_filelimit'] = 150 * 1024;
// Allow "Access-Control-Allow-Origin: *" to be used in sensible locations (RSS feed)
$serendipity['cors'] = false;
// Init default and ensure that these limits do not contain strings
$serendipity['fetchLimit'] = (int) ($serendipity['fetchLimit'] ?? 15);
$serendipity['CBAfetchLimit'] = (int) ($serendipity['CBAfetchLimit'] ?? 10);
$serendipity['RSSfetchLimit'] = (int) ($serendipity['RSSfetchLimit'] ?? 15);
if (!isset($serendipity['mediaProperties'])) {
$serendipity['mediaProperties'] = 'DPI;COPYRIGHT;TITLE;COMMENT1:MULTI;COMMENT2:MULTI;ALT';
}
if (!isset($serendipity['use_PEAR'])) {
$serendipity['use_PEAR'] = true;
}
if (!isset($serendipity['useHTTP-Auth'])) {
$serendipity['useHTTP-Auth'] = true;
}
if (!isset($serendipity['CacheControl'])) {
$serendipity['CacheControl'] = true;
}
if (!isset($serendipity['expose_s9y'])) {
$serendipity['expose_s9y'] = true;
}
// muteExpectedErrors undefined index "global" pre-check sets
// functions_config.inc.php:273
if (!isset($serendipity['smarty_preview'])) {
$serendipity['smarty_preview'] = false;
}
// functions_smarty.inc.php:1144
if (!isset($serendipity['head_title'])) {
$serendipity['head_title'] = '';
}
// functions_smarty.inc.php:1145
if (!isset($serendipity['head_subtitle'])) {
$serendipity['head_subtitle'] = '';
}
// functions_smarty.inc.php:1155
if (!isset($serendipity['smarty_raw_mode'])) {
$serendipity['smarty_raw_mode'] = false;
}
// functions_config.inc.php:1511
if (!isset($serendipity['no_create'])) {
$serendipity['no_create'] = false;
}
// If set to true (in serendipity_config_local.inc.php) this prevents using imap_8bit
// functions to send a mail, and use base64 encoding instead
if (!isset($serendipity['forceBase64'])) {
$serendipity['forceBase64'] = false;
}
// Should IFRAMEs be used for previewing entries and sending trackbacks?
$serendipity['use_iframe'] = true;
// Default language for autodetection
$serendipity['autolang'] = 'en';
// Name of folder for the default theme, which is called the Standard Theme
$serendipity['defaultTemplate'] = 'pure';
// Default backend theme
if (!isset($serendipity['template_backend'])) {
$serendipity['template_backend'] = 'styx';
}
// Available languages
if (!isset($serendipity['languages'])) {
$serendipity['languages'] = array('en' => 'English',
'de' => 'German',
'da' => 'Danish',
'es' => 'Spanish',
'fr' => 'French',
'fi' => 'Finnish',
'cs' => 'Czech (Win-1250)',
'cz' => 'Czech (ISO-8859-2)',
'sk' => 'Slovak',
'nl' => 'Dutch',
'is' => 'Icelandic',
'tr' => 'Turkish',
'se' => 'Swedish',
'pt' => 'Portuguese Brazilian',
'pt_PT' => 'Portuguese European',
'bg' => 'Bulgarian',
'hu' => 'Hungarian',
'no' => 'Norwegian',
'pl' => 'Polish',
'ro' => 'Romanian',
'it' => 'Italian',
'ru' => 'Russian',
'fa' => 'Persian',
'tw' => 'Traditional Chinese (Big5)',
'tn' => 'Traditional Chinese (UTF-8)',
'zh' => 'Simplified Chinese (GB2312)',
'cn' => 'Simplified Chinese (UTF-8)',
'ja' => 'Japanese',
'ko' => 'Korean',
'sa' => 'Arabic',
'ta' => 'Tamil');
}
// Available Calendars
$serendipity['calendars'] = array('gregorian' => 'Gregorian',
'persian-utf8' => 'Persian (utf8)');
// Load main language file
include($serendipity['serendipityPath'] . 'include/lang.inc.php');
$serendipity['charsets'] = array(
'UTF-8/' => 'UTF-8',
'' => (defined('CHARSET_NATIVE') ? CHARSET_NATIVE : 'CHARSET_NATIVE')
);
@define('PATH_SMARTY_COMPILE', 'templates_c');
@define('USERLEVEL_ADMIN', 255);
@define('USERLEVEL_CHIEF', 1);
@define('USERLEVEL_EDITOR', 0);
@define('VIEWMODE_THREADED', 'threaded'); // static
@define('VIEWMODE_LINEAR', 'linear'); // static
if (!version_compare(PHP_VERSION, '7.4.0', '>=')) {
$serendipity['lang'] = 'en';
include(S9Y_INCLUDE_PATH . 'include/lang.inc.php');
serendipity_die(sprintf(SERENDIPITY_PHPVERSION_FAIL, PHP_VERSION, '7.4.0'));
}
// Kill the script if we are not installed, and not inside the installer
if ( !defined('IN_installer') && IS_installed === false ) {
header('Status: 302 Found');
header('X-RequireInstall: 1');
header('Location: ' . ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . str_ireplace(array('\\', "%0A", "%0A"), array('/', '', ''), dirname($_SERVER['PHP_SELF'])) . '/serendipity_admin.php');
serendipity_die(sprintf(SERENDIPITY_NOT_INSTALLED, 'serendipity_admin.php'));
}
// Do the PEAR dance. If $serendipity['use_PEAR'] is set to FALSE, Serendipity will first put its own PEAR include path.
// By default, a local PEAR will be used.
if (function_exists('get_include_path')) {
$old_include = @get_include_path();
} else {
$old_include = @ini_get('include_path');
}
require_once("bundled-libs/autoload.php");
$new_include = ($serendipity['use_PEAR'] ? $old_include . PATH_SEPARATOR : '')
. S9Y_INCLUDE_PATH . 'bundled-libs/' . PATH_SEPARATOR
. S9Y_INCLUDE_PATH . 'bundled-libs/Smarty/libs/' . PATH_SEPARATOR
. $serendipity['serendipityPath'] . PATH_SEPARATOR
. (!$serendipity['use_PEAR'] ? $old_include . PATH_SEPARATOR : '');
if (function_exists('set_include_path')) {
$use_include = @set_include_path($new_include);
} else {
$use_include = @ini_set('include_path', $new_include);
}
// at here $new_include == full path to bundled-libs, to Smarty and to Serendipity as a Win/Unix style include_path string AND $use_include == .
if ($use_include !== false && $use_include == $new_include) {
@define('S9Y_PEAR', true);
@define('S9Y_PEAR_PATH', '');
} else {
@define('S9Y_PEAR', false);
@define('S9Y_PEAR_PATH', S9Y_INCLUDE_PATH . 'bundled-libs/');
}
// PEAR path setup inclusion finished
if (defined('IN_installer') && IS_installed === false) {
$serendipity['lang'] = $serendipity['autolang'];
$css_mode = 'serendipity_admin.css';
return 1;
}
/*
* Load DB configuration information
* Load Functions
* Make sure that the file included is in the current directory and not any possible
* include path
*/
if (!defined('S9Y_DATA_PATH') && file_exists(dirname(__FILE__) . '/serendipity_config_local.inc.php')) {
$local_config = dirname(__FILE__) . '/serendipity_config_local.inc.php';
} elseif (@file_exists($_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/serendipity_config_local.inc.php')) {
$local_config = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/serendipity_config_local.inc.php';
} elseif (defined('S9Y_DATA_PATH')) {
// Shared installation!
$local_config = S9Y_DATA_PATH . 'serendipity_config_local.inc.php';
} elseif (@file_exists($serendipity['serendipityPath'] . 'serendipity_config_local.inc.php')) {
$local_config = $serendipity['serendipityPath'] . 'serendipity_config_local.inc.php';
} else {
// Installation fallback
$local_config = S9Y_INCLUDE_PATH . 'serendipity_config_local.inc.php';
}
if (!is_readable($local_config)) {
$serendipity['lang'] = 'en';
include(S9Y_INCLUDE_PATH . 'include/lang.inc.php');
serendipity_die(sprintf(INCLUDE_ERROR . '<br />' . FILE_CREATE_YOURSELF, $local_config));
}
include($local_config);
if ($serendipity['production'] === 'debug') {
error_reporting(E_ALL ^ E_NOTICE); // is 32759 with 5.4+
}
if ($serendipity['production'] === false) {
error_reporting(E_ALL & ~(E_NOTICE|@E_STRICT)); // is 30711 with 5.4+
}
$errLevel = error_reporting();
/* [DEBUG] Helper to display current error levels, meant for developers.
echo $errLevel."<br>\n";
for ($i = 0; $i < 15; $i++ ) {
print debug_ErrorLevelType($errLevel & pow(2, $i)) . "<br>\n";
}
*/
// [internal callback function]: errorToExceptionHandler()
if (is_callable($serendipity['errorhandler'], false, $callable_name)) {
// set serendipity global error to exception handler
try {
set_error_handler($serendipity['errorhandler'], $errLevel); // depends on upper set error_reporting(), to see which errors are passed to the handler, switched by $serendipity['production'].
} catch (\Throwable $t) {
register_shutdown_function('fatalErrorShutdownHandler'); // make fatal errors not die in a white screen of death
}
}
define('IS_up2date', version_compare($serendipity['version'], $serendipity['versionInstalled'], '<='));
// Include main functions
include(S9Y_INCLUDE_PATH . 'include/functions.inc.php');
// while having been removed in PHP 7.0.0
if (!isset( $HTTP_RAW_POST_DATA ) && function_exists('get_raw_data')) {
$HTTP_RAW_POST_DATA = get_raw_data();
}
if (serendipity_FUNCTIONS_LOADED !== true) {
$serendipity['lang'] = 'en';
include(S9Y_INCLUDE_PATH . 'include/lang.inc.php');
serendipity_die(sprintf(INCLUDE_ERROR . '<br />' . FILE_CREATE_YOURSELF, 'include/functions.inc.php'));
}
// Attempt to connect to the database
if (!serendipity_db_connect()) {
$serendipity['lang'] = 'en';
include(S9Y_INCLUDE_PATH . 'include/lang.inc.php');
if (isset($serendipity['logger']) && is_object($serendipity['logger'])) {
$serendipity['logger']->critical(mb_convert_encoding(DATABASE_ERROR, 'UTF-8', LANG_CHARSET));
}
serendipity_die(DATABASE_ERROR);
}
// Load Configuration options from the database
if (defined('USE_MEMSNAP')) {
echo memSnap('Framework init');
}
serendipity_load_configuration();
$serendipity['lang'] = serendipity_getSessionLanguage();
serendipity_initLog();
if ( (isset($serendipity['autodetect_baseURL']) && serendipity_db_bool($serendipity['autodetect_baseURL'])) ||
(isset($serendipity['embed']) && serendipity_db_bool($serendipity['embed'])) ) {
$serendipity['baseURL'] = 'http' . (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . (!strstr($_SERVER['HTTP_HOST'], ':') && !empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != '80' && $_SERVER['SERVER_PORT'] != '443' ? ':' . $_SERVER['SERVER_PORT'] : '') . $serendipity['serendipityHTTPPath'];
}
// If a user is logged in, fetch his preferences. He probably wants to have a different language
if (IS_installed === true && php_sapi_name() !== 'cli') {
// Import HTTP auth (mostly used for RSS feeds)
if ($serendipity['useHTTP-Auth'] && (isset($_REQUEST['http_auth']) || isset($_SERVER['PHP_AUTH_USER']))) {
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header("WWW-Authenticate: Basic realm=\"Feed Login\"");
header("HTTP/1.0 401 Unauthorized");
header("Status: 401 Unauthorized");
exit;
} else {
if (!isset($serendipity['POST']['user'])) {
$serendipity['POST']['user'] = $_SERVER['PHP_AUTH_USER'];
}
if (!isset($serendipity['POST']['pass'])) {
$serendipity['POST']['pass'] = $_SERVER['PHP_AUTH_PW'];
}
}
} elseif (isset($_REQUEST['http_auth_user']) && isset($_REQUEST['http_auth_pw'])) {
$serendipity['POST']['user'] = $_REQUEST['http_auth_user'];
$serendipity['POST']['pass'] = $_REQUEST['http_auth_pw'];
}
serendipity_login(false);
}
if (isset($_SESSION['serendipityAuthorid'])) {
serendipity_load_configuration($_SESSION['serendipityAuthorid']);
$serendipity['lang'] = serendipity_getPostAuthSessionLanguage();
}
// Try to fix some path settings. It seems common users have this setting wrong
// when s9y is installed into the root directory, especially 0.7.1 upgrade users.
if (empty($serendipity['serendipityHTTPPath'])) {
$serendipity['serendipityHTTPPath'] = '/';
}
// Changing this is NOT recommended, rewrite rules does not take them into account - yet
serendipity_initPermalinks();
// Apply constants/definitions from custom permalinks
serendipity_permalinkPatterns();
// Load main language file again, because now we have the preferred language
include(S9Y_INCLUDE_PATH . 'include/lang.inc.php');
// Reset charset definition now that final language is known
$serendipity['charsets'] = array(
'UTF-8/' => 'UTF-8',
'' => CHARSET_NATIVE
);
// Set current locale, if any has been defined
if (defined('DATE_LOCALES')) {
$locales = explode(',', DATE_LOCALES);
foreach ($locales AS $locale) {
$locale = trim($locale);
if (setlocale(LC_TIME, $locale) == $locale) {
break;
}
}
}
if (function_exists('date_default_timezone_set')) {
if (isset($serendipity['useServerOffset']) && $serendipity['useServerOffset'] == false) {
date_default_timezone_set('UTC');
}
}
// Fallback charset, if none is defined in the language files
if (!defined('LANG_CHARSET')) {
@define('LANG_CHARSET', 'ISO-8859-1');
}
// define a global constant for localized dateTime usage
@define('PHP_VERSION_ICU', (PHP_VERSION_ID >= 80200 && extension_loaded('intl')));
// Create array of permission levels, with descriptions
$serendipity['permissionLevels'] = array(USERLEVEL_EDITOR => USERLEVEL_EDITOR_DESC,
USERLEVEL_CHIEF => USERLEVEL_CHIEF_DESC,
USERLEVEL_ADMIN => USERLEVEL_ADMIN_DESC);
// Redirect to the upgrader
if (IS_up2date === false && !defined('IN_upgrader')) {
if (preg_match(PAT_CSS, $_SERVER['REQUEST_URI'], $matches)) {
$css_mode = 'serendipity_admin.css';
return 1;
}
if (preg_match('@/(serendipity_styx\.js$)@', $_SERVER['REQUEST_URI'], $matches)) {
return 1;
}
if (serendipity_checkPermission('adminUsers')) {
// manually redirect to the BACKEND to finish the autoupdate UPGRADE. It happens ONCE only per version, so multiple (DEV) forced upgrades match IS_up2date and end up in the FRONTEND.
if (isset($serendipity['maintenance']) && serendipity_db_bool($serendipity['maintenance'])) {
serendipity_die(sprintf(SERENDIPITY_NEEDS_UPGRADE, $serendipity['versionInstalled'], $serendipity['version'], $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php'), null);
} else {
header('Location: ' . $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php');
exit;
}
}
}
// We don't care who tells us what to do
if (!isset($serendipity['GET']['action'])) {
// trying to get rid of possible rare "Uncaught TypeError: Cannot access offset of type string on string" errors
if (is_array($serendipity['POST'])) {
$serendipity['GET']['action'] = $serendipity['POST']['action'] ?? '';
} else {
if (!is_array($serendipity['GET'])) {
$serendipity['GET'] = [];
}
$serendipity['GET']['action'] = '';
}
}
if (!isset($serendipity['GET']['adminAction'])) {
$serendipity['GET']['adminAction'] = $serendipity['POST']['adminAction'] ?? '';
}
// NO, NOT on MYSQL alike databases for use of fulltext extended search operators !!!
// Make sure this variable is always properly sanitized, though it should have gone through routing taking care before. Previously in compat.inc.php, but there LANG_CHARSET was not defined.
if (isset($serendipity['GET']['searchTerm']) && $serendipity['dbType'] !== 'mysqli') {
$serendipity['GET']['searchTerm'] = serendipity_specialchars(strip_tags((string)$serendipity['GET']['searchTerm']), null, LANG_CHARSET, false);
}
// Some default inits...
if (!isset($_SESSION['serendipityAuthedUser'])) {
$_SESSION['serendipityAuthedUser'] = false;
}
if (isset($_SESSION['serendipityUser'])) {
$serendipity['user'] = $_SESSION['serendipityUser'];
}
if (isset($_SESSION['serendipityEmail'])) {
$serendipity['email'] = $_SESSION['serendipityEmail'];
}
if (defined('IN_serendipity_admin') && !isset($serendipity['use_autosave'])) {
$serendipity['use_autosave'] = true;
}
if (!isset($serendipity['useInternalCache'])) {
$serendipity['useInternalCache'] = false;
}
if (!isset($serendipity['smarty'])) {
$serendipity['smarty'] = null;
}
if (!isset($serendipity['logger'])) {
$serendipity['logger'] = null;
}
// Does the clients browser accept webp?
if (!isset($serendipity['http_accept_webp']) && isset($_SERVER['HTTP_ACCEPT'])) {
$serendipity['http_accept_webp'] = (strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') >= 0) ? true : false;
}
if (!isset($serendipity['useWebPFormat'])) {
$serendipity['useWebPFormat'] = serendipity_get_config_var('hasWebPSupport', false);
}
// Does the clients browser accept avif?
if (!isset($serendipity['http_accept_avif']) && isset($_SERVER['HTTP_ACCEPT'])) {
$serendipity['http_accept_avif'] = (strpos($_SERVER['HTTP_ACCEPT'], 'image/avif') >= 0) ? true : false;
}
if (!isset($serendipity['useAvifFormat'])) {
$serendipity['useAvifFormat'] = serendipity_get_config_var('hasAvifSupport', false);
}
if ($_SESSION['serendipityAuthedUser'] && isset($serendipity['enableAVIF']) && $serendipity['enableAVIF']) {
// check and set image Libraries AV1 image file Support w/o notice
if ($serendipity['useAvifFormat'] === false && serendipity_checkAvifSupport()) {
serendipity_set_config_var('hasAvifSupport', 'true', 0);
$serendipity['useAvifFormat'] = true;
}
}
if ($_SESSION['serendipityAuthedUser'] && $serendipity['useAvifFormat'] === true && (!isset($serendipity['enableAVIF']) || !$serendipity['enableAVIF'])) {
// reset AV1 image Variation file usage w/o notice
serendipity_set_config_var('hasAvifSupport', 'false', 0);
$serendipity['useAvifFormat'] = false;
}
// You can set parameters which ImageMagick should use to generate the thumbnails
// by default, thumbs will get a little more brightness and saturation (modulate)
// an unsharp-mask (unsharp)
// and quality-compression of 75% (default would be to use quality of original image)
if (!isset($serendipity['imagemagick_thumb_parameters'])) {
$serendipity['imagemagick_thumb_parameters'] = '';
// Set a variable like below in your serendipity_config_local.inc.php // Be strict! -settings go before -operators, see http://magick.imagemagick.org/script/command-line-processing.php#setting
#$serendipity['imagemagick_thumb_parameters'] = '-quality 75 -modulate 105,140 -unsharp 0.5x0.5+1.0';
}
serendipity_plugin_api::hook_event('frontend_configure', $serendipity);
/* vim: set sts=4 ts=4 expandtab : */