We apologize for this temporary unavailability.
' .
'Thank you for your understanding.
'),
20);
} else {
__error(__('Unable to connect to database')
, $e->getCode() == 0 ?
sprintf(__('This either means that the username and password information in ' .
'your config.php file is incorrect or we can\'t contact ' .
'the database server at "%s". This could mean your ' .
'host\'s database server is down.
' .
'- Are you sure you have the correct username and password?
' .
'- Are you sure that you have typed the correct hostname?
' .
'- Are you sure that the database server is running?
' .
'If you\'re unsure what these terms mean you should probably contact ' .
'your host. If you still need help you can always visit the ' .
'Dotclear Support Forums.
') .
(DC_DEBUG ?
__('The following error was encountered while trying to read the database:') . '' : '')
, (DC_DBHOST != '' ? DC_DBHOST : 'localhost')
)
: ''
, 20);
}
}
# If we have some __top_behaviors, we load them
if (isset($__top_behaviors) && is_array($__top_behaviors)) {
foreach ($__top_behaviors as $b) {
$core->addBehavior($b[0], $b[1]);
}
unset($b);
}
http::trimRequest();
try {
http::unsetGlobals();
} catch (Exception $e) {
header('Content-Type: text/plain');
echo $e->getMessage();
exit;
}
$core->url->registerDefault(['dcUrlHandlers', 'home']);
$core->url->registerError(['dcUrlHandlers', 'default404']);
$core->url->register('lang', '', '^([a-zA-Z]{2}(?:-[a-z]{2})?(?:/page/[0-9]+)?)$', ['dcUrlHandlers', 'lang']);
$core->url->register('post', 'post', '^post/(.+)$', ['dcUrlHandlers', 'post']);
$core->url->register('preview', 'preview', '^preview/(.+)$', ['dcUrlHandlers', 'preview']);
$core->url->register('category', 'category', '^category/(.+)$', ['dcUrlHandlers', 'category']);
$core->url->register('archive', 'archive', '^archive(/.+)?$', ['dcUrlHandlers', 'archive']);
$core->url->register('feed', 'feed', '^feed/(.+)$', ['dcUrlHandlers', 'feed']);
$core->url->register('trackback', 'trackback', '^trackback/(.+)$', ['dcUrlHandlers', 'trackback']);
$core->url->register('webmention', 'webmention', '^webmention(/.+)?$', ['dcUrlHandlers', 'webmention']);
$core->url->register('rsd', 'rsd', '^rsd$', ['dcUrlHandlers', 'rsd']);
$core->url->register('xmlrpc', 'xmlrpc', '^xmlrpc/(.+)$', ['dcUrlHandlers', 'xmlrpc']);
// Should use dcAdminURL class, but only in admin -> to be moved to public/prepend.php and admin/prepend.php ?
$core->setPostType('post', 'post.php?id=%d', $core->url->getURLFor('post', '%s'), 'Posts');
# Store upload_max_filesize in bytes
$u_max_size = files::str2bytes(ini_get('upload_max_filesize'));
$p_max_size = files::str2bytes(ini_get('post_max_size'));
if ($p_max_size < $u_max_size) {
$u_max_size = $p_max_size;
}
define('DC_MAX_UPLOAD_SIZE', $u_max_size);
unset($u_max_size);unset($p_max_size);
# Register supplemental mime types
files::registerMimeTypes([
// Audio
'aac' => 'audio/aac',
'ogg' => 'audio/ogg',
'weba' => 'audio/webm',
'm4a' => 'audio/mp4',
// Video
'mp4' => 'video/mp4',
'm4p' => 'video/mp4',
'webm' => 'video/webm'
]);
# Shutdown
register_shutdown_function('__shutdown');
function __shutdown()
{
global $__shutdown;
if (is_array($__shutdown)) {
foreach ($__shutdown as $f) {
if (is_callable($f)) {
call_user_func($f);
}
}
}
# Explicitly close session before DB connection
try {
if (session_id()) {
session_write_close();
}
} catch (Exception $e) {}
$GLOBALS['core']->con->close();
}
function __error($summary, $message, $code = 0)
{
# Error codes
# 10 : no config file
# 20 : database issue
# 30 : blog is not defined
# 40 : template files creation
# 50 : no default theme
# 60 : template processing error
# 70 : blog is offline
if (CLI_MODE) {
trigger_error($summary, E_USER_ERROR);
exit(1);
} else {
if (defined('DC_ERRORFILE') && is_file(DC_ERRORFILE)) {
include DC_ERRORFILE;
} else {
include dirname(__FILE__) . '/core_error.php';
}
exit;
}
}
function init_prepend_l10n()
{
# Loading locales for detected language
$dlang = http::getAcceptLanguages();
foreach ($dlang as $l) {
if ($l == 'en' || l10n::set(dirname(__FILE__) . '/../locales/' . $l . '/main') !== false) {
l10n::lang($l);
break;
}
}
}