[ Index ] |
|
Code source de Serendipity 1.2 |
1 <?php # $Id: serendipity_config.inc.php 1871 2007-08-25 12:07:56Z garvinhicking $ 2 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) 3 # All rights reserved. See LICENSE file for licensing details 4 5 if (defined('S9Y_FRAMEWORK')) { 6 return; 7 } 8 9 @define('S9Y_FRAMEWORK', true); 10 11 if (!headers_sent()) { 12 session_start(); 13 14 // Prevent session fixation by only allowing sessions that have been sent by the server. 15 // Any session that does not contain our unique token will be regarded as foreign/fixated 16 // and be regenerated with a system-generated SID. 17 // Patch by David Vieira-Kurz of majorsecurity.de 18 if (!isset($_SESSION['SERVER_GENERATED_SID'])) { 19 session_regenerate_id(true); 20 session_start(); 21 header('X-Session-Reinit: true'); 22 $_SESSION['SERVER_GENERATED_SID'] = true; 23 } 24 } 25 26 if (!defined('S9Y_INCLUDE_PATH')) { 27 define('S9Y_INCLUDE_PATH', dirname(__FILE__) . '/'); 28 } 29 define('S9Y_CONFIG_TEMPLATE', S9Y_INCLUDE_PATH . 'include/tpl/config_local.inc.php'); 30 define('S9Y_CONFIG_USERTEMPLATE', S9Y_INCLUDE_PATH . 'include/tpl/config_personal.inc.php'); 31 32 define('IS_installed', file_exists('serendipity_config_local.inc.php') && (filesize('serendipity_config_local.inc.php') > 0)); 33 34 if (!defined('IN_serendipity')) { 35 define('IN_serendipity', true); 36 } 37 38 include (S9Y_INCLUDE_PATH . 'include/compat.inc.php'); 39 if (defined('USE_MEMSNAP')) { 40 memSnap('Framework init'); 41 } 42 43 // The version string 44 $serendipity['version'] = '1.2'; 45 46 // Setting this to 'false' will enable debugging output. All alpa/beta/cvs snapshot versions will emit debug information by default. To increase the debug level (to enable Smarty debugging), set this flag to 'debug'. 47 $serendipity['production'] = (preg_match('@\-(alpha|beta|cvs)@', $serendipity['version']) ? false : true); 48 49 // Set error reporting 50 error_reporting(E_ALL & ~E_NOTICE); 51 52 if ($serendipity['production'] !== true) { 53 if ($serendipity['production'] === 'debug') { 54 error_reporting(E_ALL); 55 } 56 @ini_set('display_errors', 'on'); 57 } 58 59 // Default rewrite method 60 $serendipity['rewrite'] = 'none'; 61 62 // Message container 63 $serendipity['messagestack'] = array(); 64 65 // Can the user change the date of publishing for an entry? 66 $serendipity['allowDateManipulation'] = true; 67 68 // How much time is allowed to pass since the publising of an entry, so that a comment to that entry 69 // will update it's LastModified stamp? If the time is passed, a comment to an old entry will no longer 70 // push an article as being updated. 71 $serendipity['max_last_modified'] = 60 * 60 * 24 * 7; 72 73 // Clients can send a If-Modified Header to the RSS Feed (Conditional Get) and receive all articles beyond 74 // that date. However it is still limited by the number below of maximum entries 75 $serendipity['max_fetch_limit'] = 50; 76 77 // How many bytes are allowed for fetching trackbacks, so that no binary files get accidently trackbacked? 78 $serendipity['trackback_filelimit'] = 150 * 1024; 79 80 if (!isset($serendipity['fetchLimit'])) { 81 $serendipity['fetchLimit'] = 15; 82 } 83 84 if (!isset($serendipity['RSSfetchLimit'])) { 85 $serendipity['RSSfetchLimit'] = 15; 86 } 87 88 if (!isset($serendipity['mediaProperties'])) { 89 $serendipity['mediaProperties'] = 'DPI;COPYRIGHT;TITLE;COMMENT1:MULTI;COMMENT2:MULTI'; 90 } 91 92 if (!isset($serendipity['use_PEAR'])) { 93 $serendipity['use_PEAR'] = true; 94 } 95 96 if (!isset($serendipity['useHTTP-Auth'])) { 97 $serendipity['useHTTP-Auth'] = true; 98 } 99 100 if (!isset($serendipity['CacheControl'])) { 101 $serendipity['CacheControl'] = true; 102 } 103 104 if (!isset($serendipity['expose_s9y'])) { 105 $serendipity['expose_s9y'] = true; 106 } 107 108 // Should IFRAMEs be used for previewing entries and sending trackbacks? 109 $serendipity['use_iframe'] = true; 110 111 /* Default language for autodetection */ 112 $serendipity['autolang'] = 'en'; 113 114 /* Name of folder for the default theme */ 115 $serendipity['defaultTemplate'] = 'carl_contest'; 116 117 /* Availiable languages */ 118 $serendipity['languages'] = array('en' => 'English', 119 'de' => 'German', 120 'da' => 'Danish', 121 'es' => 'Spanish', 122 'fr' => 'French', 123 'fi' => 'Finnish', 124 'cs' => 'Czech (Win-1250)', 125 'cz' => 'Czech (ISO-8859-2)', 126 'nl' => 'Dutch', 127 'is' => 'Icelandic', 128 'tr' => 'Turkish', 129 'se' => 'Swedish', 130 'pt' => 'Portuguese Brazilian', 131 'pt_PT' => 'Portuguese European', 132 'bg' => 'Bulgarian', 133 'hu' => 'Hungarian', 134 'no' => 'Norwegian', 135 'pl' => 'Polish', 136 'ro' => 'Romanian', 137 'it' => 'Italian', 138 'ru' => 'Russian', 139 'fa' => 'Persian', 140 'tw' => 'Traditional Chinese (Big5)', 141 'tn' => 'Traditional Chinese (UTF-8)', 142 'zh' => 'Simplified Chinese (GB2312)', 143 'cn' => 'Simplified Chinese (UTF-8)', 144 'ja' => 'Japanese', 145 'ko' => 'Korean', 146 'sa' => 'Arabic', 147 'ta' => 'Tamil'); 148 149 /* Available Calendars */ 150 $serendipity['calendars'] = array('gregorian' => 'Gregorian', 151 'persian-utf8' => 'Persian (utf8)'); 152 153 /* 154 * Load main language file 155 */ 156 include($serendipity['serendipityPath'] . 'include/lang.inc.php'); 157 158 $serendipity['charsets'] = array( 159 'UTF-8/' => 'UTF-8', 160 '' => CHARSET_NATIVE 161 ); 162 163 @define('PATH_SMARTY_COMPILE', 'templates_c'); // will be placed inside the template directory 164 @define('USERLEVEL_ADMIN', 255); 165 @define('USERLEVEL_CHIEF', 1); 166 @define('USERLEVEL_EDITOR', 0); 167 168 @define('VIEWMODE_THREADED', 'threaded'); 169 @define('VIEWMODE_LINEAR', 'linear'); 170 171 /* 172 * Kill the script if we are not installed, and not inside the installer 173 */ 174 if ( !defined('IN_installer') && IS_installed === false ) { 175 header('Location: ' . (strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])) . '/serendipity_admin.php'); 176 serendipity_die(sprintf(SERENDIPITY_NOT_INSTALLED, 'serendipity_admin.php')); 177 } 178 179 /* Do the PEAR dance. If $serendipity['use_PEAR'] is set to FALSE, Serendipity will first put its own PEAR include path. 180 By default, a local PEAR will be used. */ 181 if (function_exists('get_include_path')) { 182 $old_include = @get_include_path(); 183 } else { 184 $old_include = @ini_get('include_path'); 185 } 186 187 188 $new_include = ($serendipity['use_PEAR'] ? $old_include . PATH_SEPARATOR : '') 189 . S9Y_INCLUDE_PATH . 'bundled-libs/' . PATH_SEPARATOR 190 . S9Y_INCLUDE_PATH . 'bundled-libs/Smarty/libs/' . PATH_SEPARATOR 191 . $serendipity['serendipityPath'] . PATH_SEPARATOR 192 . (!$serendipity['use_PEAR'] ? $old_include . PATH_SEPARATOR : ''); 193 194 if (function_exists('set_include_path')) { 195 $use_include = @set_include_path($new_include); 196 } else { 197 $use_include = @ini_set('include_path', $new_include); 198 } 199 200 if ($use_include !== $false && $use_include == $new_include) { 201 @define('S9Y_PEAR', true); 202 @define('S9Y_PEAR_PATH', ''); 203 } else { 204 @define('S9Y_PEAR', false); 205 @define('S9Y_PEAR_PATH', S9Y_INCLUDE_PATH . 'bundled-libs/'); 206 } 207 /* PEAR path setup inclusion finished */ 208 209 if (defined('IN_installer') && IS_installed === false) { 210 $serendipity['lang'] = $serendipity['autolang']; 211 $css_mode = 'serendipity_admin.css'; 212 return 1; 213 } 214 215 /* 216 * Load DB configuration information 217 * Load Functions 218 * Make sure that the file included is in the current directory and not any possible 219 * include path 220 */ 221 if (file_exists($_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/serendipity_config_local.inc.php')) { 222 $local_config = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/serendipity_config_local.inc.php'; 223 } elseif (defined('S9Y_DATA_PATH')) { 224 // Shared installation! 225 $local_config = S9Y_DATA_PATH . '/serendipity_config_local.inc.php'; 226 } elseif (file_exists($serendipity['serendipityPath'] . '/serendipity_config_local.inc.php')) { 227 $local_config = $serendipity['serendipityPath'] . '/serendipity_config_local.inc.php'; 228 } else { 229 // Installation fallback 230 $local_config = S9Y_INCLUDE_PATH . '/serendipity_config_local.inc.php'; 231 } 232 233 if (!is_readable($local_config)) { 234 $serendipity['lang'] = 'en'; 235 include (S9Y_INCLUDE_PATH . 'include/lang.inc.php'); 236 serendipity_die(sprintf(INCLUDE_ERROR . '<br />' . FILE_CREATE_YOURSELF, $local_config)); 237 } 238 239 include($local_config); 240 241 define('IS_up2date', version_compare($serendipity['version'], $serendipity['versionInstalled'], '<=')); 242 243 /* 244 * Include main functions 245 */ 246 include (S9Y_INCLUDE_PATH . 'include/functions.inc.php'); 247 248 if (serendipity_FUNCTIONS_LOADED !== true) { 249 $serendipity['lang'] = 'en'; 250 include (S9Y_INCLUDE_PATH . 'include/lang.inc.php'); 251 serendipity_die(sprintf(INCLUDE_ERROR . '<br />' . FILE_CREATE_YOURSELF, 'include/functions.inc.php')); 252 } 253 254 /* 255 * Attempt to connect to the database 256 */ 257 if (!serendipity_db_connect()) { 258 $serendipity['lang'] = 'en'; 259 include (S9Y_INCLUDE_PATH . 'include/lang.inc.php'); 260 serendipity_die(DATABASE_ERROR); 261 } 262 263 /* 264 * Load Configuration options from the database 265 */ 266 267 if (defined('USE_MEMSNAP')) { 268 memSnap('Framework init'); 269 } 270 271 serendipity_load_configuration(); 272 $serendipity['lang'] = serendipity_getSessionLanguage(); 273 274 if ( (isset($serendipity['autodetect_baseURL']) && serendipity_db_bool($serendipity['autodetect_baseURL'])) || 275 (isset($serendipity['embed']) && serendipity_db_bool($serendipity['embed'])) ) { 276 $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'] : '') . $serendipity['serendipityHTTPPath']; 277 } 278 /* 279 * If a user is logged in, fetch his preferences. He possibly wants to have a different language 280 */ 281 282 if (IS_installed === true) { 283 // Import HTTP auth (mostly used for RSS feeds) 284 if ($serendipity['useHTTP-Auth'] && (isset($_REQUEST['http_auth']) || isset($_SERVER['PHP_AUTH_USER']))) { 285 if (!isset($_SERVER['PHP_AUTH_USER'])) { 286 header("WWW-Authenticate: Basic realm=\"Feed Login\""); 287 header("HTTP/1.0 401 Unauthorized"); 288 exit; 289 } else { 290 if (!isset($serendipity['POST']['user'])) { 291 $serendipity['POST']['user'] = $_SERVER['PHP_AUTH_USER']; 292 } 293 if (!isset($serendipity['POST']['pass'])) { 294 $serendipity['POST']['pass'] = $_SERVER['PHP_AUTH_PW']; 295 } 296 } 297 } elseif (isset($_REQUEST['http_auth_user']) && isset($_REQUEST['http_auth_pw'])) { 298 $serendipity['POST']['user'] = $_REQUEST['http_auth_user']; 299 $serendipity['POST']['pass'] = $_REQUEST['http_auth_pw']; 300 } 301 302 serendipity_login(false); 303 } 304 305 if (isset($_SESSION['serendipityAuthorid'])) { 306 serendipity_load_configuration($_SESSION['serendipityAuthorid']); 307 $serendipity['lang'] = serendipity_getPostAuthSessionLanguage(); 308 } 309 310 // Try to fix some path settings. It seems common users have this setting wrong 311 // when s9y is installed into the root directory, especially 0.7.1 upgrade users. 312 if (empty($serendipity['serendipityHTTPPath'])) { 313 $serendipity['serendipityHTTPPath'] = '/'; 314 } 315 316 /* Changing this is NOT recommended, rewrite rules does not take them into account - yet */ 317 serendipity_initPermalinks(); 318 319 // Apply constants/definitions from custom permalinks 320 serendipity_permalinkPatterns(); 321 322 /* 323 * Load main language file again, because now we have the preferred language 324 */ 325 include (S9Y_INCLUDE_PATH . 'include/lang.inc.php'); 326 327 /* 328 * Reset charset definition now that final language is known 329 */ 330 $serendipity['charsets'] = array( 331 'UTF-8/' => 'UTF-8', 332 '' => CHARSET_NATIVE 333 ); 334 335 /* 336 * Set current locale, if any has been defined 337 */ 338 if (defined('DATE_LOCALES')) { 339 $locales = explode(',', DATE_LOCALES); 340 foreach ($locales as $locale) { 341 $locale = trim($locale); 342 if (setlocale(LC_TIME, $locale) == $locale) { 343 break; 344 } 345 } 346 } 347 348 /* 349 * Fallback charset, if none is defined in the language files 350 */ 351 @define('LANG_CHARSET', 'ISO-8859-1'); 352 353 /* 354 * Create array of permission levels, with descriptions 355 */ 356 $serendipity['permissionLevels'] = array(USERLEVEL_EDITOR => USERLEVEL_EDITOR_DESC, 357 USERLEVEL_CHIEF => USERLEVEL_CHIEF_DESC, 358 USERLEVEL_ADMIN => USERLEVEL_ADMIN_DESC); 359 360 /* 361 * Check if the installed version is higher than the version of the config 362 */ 363 364 if (IS_up2date === false && !defined('IN_upgrader')) { 365 if (preg_match(PAT_CSS, $_SERVER['REQUEST_URI'], $matches)) { 366 $css_mode = 'serendipity_admin.css'; 367 return 1; 368 } 369 370 serendipity_die(sprintf(SERENDIPITY_NEEDS_UPGRADE, $serendipity['versionInstalled'], $serendipity['version'], $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php')); 371 } 372 373 // We don't care who tells us what to do 374 if (!isset($serendipity['GET']['action'])) { 375 $serendipity['GET']['action'] = (isset($serendipity['POST']['action']) ? $serendipity['POST']['action'] : ''); 376 } 377 378 if (!isset($serendipity['GET']['adminAction'])) { 379 $serendipity['GET']['adminAction'] = (isset($serendipity['POST']['adminAction']) ? $serendipity['POST']['adminAction'] : ''); 380 } 381 382 // Some stuff... 383 if (!isset($_SESSION['serendipityAuthedUser'])) { 384 $_SESSION['serendipityAuthedUser'] = false; 385 } 386 387 if (isset($_SESSION['serendipityUser'])) { 388 $serendipity['user'] = $_SESSION['serendipityUser']; 389 } 390 391 if (isset($_SESSION['serendipityEmail'])) { 392 $serendipity['email'] = $_SESSION['serendipityEmail']; 393 } 394 serendipity_plugin_api::hook_event('frontend_configure', $serendipity); 395 396 /* vim: set sts=4 ts=4 expandtab : */
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:00:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |