| [0] | 1 | <?php | 
|---|
|  | 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- | 
|---|
|  | 3 | # | 
|---|
|  | 4 | # This file is part of Dotclear 2. | 
|---|
|  | 5 | # | 
|---|
| [1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear | 
|---|
| [0] | 7 | # Licensed under the GPL version 2.0 license. | 
|---|
|  | 8 | # See LICENSE file or | 
|---|
|  | 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | 
|---|
|  | 10 | # | 
|---|
|  | 11 | # -- END LICENSE BLOCK ----------------------------------------- | 
|---|
|  | 12 |  | 
|---|
| [2595] | 13 | /* Start tick  */ | 
|---|
|  | 14 | define('DC_START_TIME',microtime(true)); | 
|---|
|  | 15 |  | 
|---|
| [0] | 16 | /* ------------------------------------------------------------------------------------------- */ | 
|---|
| [7] | 17 | #  ClearBricks, DotClear classes auto-loader | 
|---|
| [0] | 18 | if (@is_dir('/usr/lib/clearbricks')) { | 
|---|
|  | 19 | define('CLEARBRICKS_PATH','/usr/lib/clearbricks'); | 
|---|
|  | 20 | } elseif (is_dir(dirname(__FILE__).'/libs/clearbricks')) { | 
|---|
|  | 21 | define('CLEARBRICKS_PATH',dirname(__FILE__).'/libs/clearbricks'); | 
|---|
|  | 22 | } elseif (isset($_SERVER['CLEARBRICKS_PATH']) && is_dir($_SERVER['CLEARBRICKS_PATH'])) { | 
|---|
|  | 23 | define('CLEARBRICKS_PATH',$_SERVER['CLEARBRICKS_PATH']); | 
|---|
|  | 24 | } | 
|---|
|  | 25 |  | 
|---|
|  | 26 | if (!defined('CLEARBRICKS_PATH') || !is_dir(CLEARBRICKS_PATH)) { | 
|---|
|  | 27 | exit('No clearbricks path defined'); | 
|---|
|  | 28 | } | 
|---|
|  | 29 |  | 
|---|
|  | 30 | require CLEARBRICKS_PATH.'/_common.php'; | 
|---|
| [3162] | 31 |  | 
|---|
| [2657] | 32 | $__autoload['dcCore']        = dirname(__FILE__).'/core/class.dc.core.php'; | 
|---|
|  | 33 | $__autoload['dcAuth']        = dirname(__FILE__).'/core/class.dc.auth.php'; | 
|---|
|  | 34 | $__autoload['dcBlog']        = dirname(__FILE__).'/core/class.dc.blog.php'; | 
|---|
|  | 35 | $__autoload['dcCategories']  = dirname(__FILE__).'/core/class.dc.categories.php'; | 
|---|
|  | 36 | $__autoload['dcError']       = dirname(__FILE__).'/core/class.dc.error.php'; | 
|---|
|  | 37 | $__autoload['dcMeta']        = dirname(__FILE__).'/core/class.dc.meta.php'; | 
|---|
|  | 38 | $__autoload['dcMedia']       = dirname(__FILE__).'/core/class.dc.media.php'; | 
|---|
|  | 39 | $__autoload['dcPostMedia']   = dirname(__FILE__).'/core/class.dc.postmedia.php'; | 
|---|
|  | 40 | $__autoload['dcModules']     = dirname(__FILE__).'/core/class.dc.modules.php'; | 
|---|
|  | 41 | $__autoload['dcPlugins']     = dirname(__FILE__).'/core/class.dc.plugins.php'; | 
|---|
|  | 42 | $__autoload['dcThemes']      = dirname(__FILE__).'/core/class.dc.themes.php'; | 
|---|
|  | 43 | $__autoload['dcRestServer']  = dirname(__FILE__).'/core/class.dc.rest.php'; | 
|---|
|  | 44 | $__autoload['dcNamespace']   = dirname(__FILE__).'/core/class.dc.namespace.php'; | 
|---|
|  | 45 | $__autoload['dcSettings']    = dirname(__FILE__).'/core/class.dc.settings.php'; | 
|---|
|  | 46 | $__autoload['dcTrackback']   = dirname(__FILE__).'/core/class.dc.trackback.php'; | 
|---|
|  | 47 | $__autoload['dcUpdate']      = dirname(__FILE__).'/core/class.dc.update.php'; | 
|---|
|  | 48 | $__autoload['dcUtils']       = dirname(__FILE__).'/core/class.dc.utils.php'; | 
|---|
|  | 49 | $__autoload['dcXmlRpc']      = dirname(__FILE__).'/core/class.dc.xmlrpc.php'; | 
|---|
|  | 50 | $__autoload['dcLog']         = dirname(__FILE__).'/core/class.dc.log.php'; | 
|---|
|  | 51 | $__autoload['dcWorkspace']   = dirname(__FILE__).'/core/class.dc.workspace.php'; | 
|---|
|  | 52 | $__autoload['dcPrefs']       = dirname(__FILE__).'/core/class.dc.prefs.php'; | 
|---|
|  | 53 | $__autoload['dcStore']       = dirname(__FILE__).'/core/class.dc.store.php'; | 
|---|
|  | 54 | $__autoload['dcStoreReader'] = dirname(__FILE__).'/core/class.dc.store.reader.php'; | 
|---|
|  | 55 | $__autoload['dcStoreParser'] = dirname(__FILE__).'/core/class.dc.store.parser.php'; | 
|---|
| [3162] | 56 | $__autoload['rsExtPost']     = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; | 
|---|
|  | 57 | $__autoload['rsExtComment']  = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; | 
|---|
|  | 58 | $__autoload['rsExtDates']    = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; | 
|---|
|  | 59 | $__autoload['rsExtUser']     = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; | 
|---|
| [0] | 60 |  | 
|---|
| [3162] | 61 | $__autoload['dcUpgrade']  = dirname(__FILE__).'/dbschema/upgrade.php'; | 
|---|
| [0] | 62 |  | 
|---|
| [3162] | 63 | $__autoload['dcMenu']               = dirname(__FILE__).'/admin/class.dc.menu.php'; | 
|---|
|  | 64 | $__autoload['dcFavorites']          = dirname(__FILE__).'/admin/class.dc.favorites.php'; | 
|---|
|  | 65 | $__autoload['dcPage']               = dirname(__FILE__).'/admin/lib.dc.page.php'; | 
|---|
|  | 66 | $__autoload['adminGenericList']     = dirname(__FILE__).'/admin/lib.pager.php'; | 
|---|
|  | 67 | $__autoload['adminPostList']        = dirname(__FILE__).'/admin/lib.pager.php'; | 
|---|
|  | 68 | $__autoload['adminPostMiniList']    = dirname(__FILE__).'/admin/lib.pager.php'; | 
|---|
|  | 69 | $__autoload['adminCommentList']     = dirname(__FILE__).'/admin/lib.pager.php'; | 
|---|
|  | 70 | $__autoload['adminUserList']        = dirname(__FILE__).'/admin/lib.pager.php'; | 
|---|
|  | 71 | $__autoload['dcPager']              = dirname(__FILE__).'/admin/lib.pager.php'; | 
|---|
|  | 72 | $__autoload['dcAdminCombos']        = dirname(__FILE__).'/admin/lib.admincombos.php'; | 
|---|
|  | 73 | $__autoload['adminModulesList']     = dirname(__FILE__).'/admin/lib.moduleslist.php'; | 
|---|
|  | 74 | $__autoload['adminThemesList']      = dirname(__FILE__).'/admin/lib.moduleslist.php'; | 
|---|
|  | 75 | $__autoload['dcThemeConfig']        = dirname(__FILE__).'/admin/lib.themeconfig.php'; | 
|---|
|  | 76 | $__autoload['dcAdminURL']            = dirname(__FILE__).'/admin/lib.dc.adminurl.php'; | 
|---|
|  | 77 | $__autoload['dcPostsActionsPage']    = dirname(__FILE__).'/admin/actions/class.dcactionposts.php'; | 
|---|
|  | 78 | $__autoload['dcCommentsActionsPage'] = dirname(__FILE__).'/admin/actions/class.dcactioncomments.php'; | 
|---|
|  | 79 | $__autoload['dcActionsPage']         = dirname(__FILE__).'/admin/actions/class.dcaction.php'; | 
|---|
| [0] | 80 |  | 
|---|
| [2657] | 81 | $__autoload['dcTemplate']            = dirname(__FILE__).'/public/class.dc.template.php'; | 
|---|
|  | 82 | $__autoload['context']               = dirname(__FILE__).'/public/lib.tpl.context.php'; | 
|---|
|  | 83 | $__autoload['dcUrlHandlers']         = dirname(__FILE__).'/public/lib.urlhandlers.php'; | 
|---|
| [0] | 84 |  | 
|---|
|  | 85 | # Clearbricks extensions | 
|---|
|  | 86 | html::$absolute_regs[] = '/(<param\s+name="movie"\s+value=")(.*?)(")/msu'; | 
|---|
|  | 87 | html::$absolute_regs[] = '/(<param\s+name="FlashVars"\s+value=".*?(?:mp3|flv)=)(.*?)(&|")/msu'; | 
|---|
|  | 88 | /* ------------------------------------------------------------------------------------------- */ | 
|---|
|  | 89 |  | 
|---|
|  | 90 |  | 
|---|
|  | 91 | mb_internal_encoding('UTF-8'); | 
|---|
|  | 92 |  | 
|---|
|  | 93 | # Setting timezone | 
|---|
|  | 94 | dt::setTZ('UTC'); | 
|---|
|  | 95 |  | 
|---|
|  | 96 | # CLI_MODE, boolean constant that tell if we are in CLI mode | 
|---|
|  | 97 | define('CLI_MODE',PHP_SAPI == 'cli'); | 
|---|
|  | 98 |  | 
|---|
|  | 99 | # Disallow every special wrapper | 
|---|
|  | 100 | if (function_exists('stream_wrapper_unregister')) | 
|---|
|  | 101 | { | 
|---|
|  | 102 | foreach (array('http','https','ftp','ftps','ssh2.shell','ssh2.exec', | 
|---|
|  | 103 | 'ssh2.tunnel','ssh2.sftp','ssh2.scp','ogg','expect') as $p) { | 
|---|
|  | 104 | @stream_wrapper_unregister($p); | 
|---|
|  | 105 | } | 
|---|
|  | 106 | } | 
|---|
|  | 107 |  | 
|---|
|  | 108 | if (isset($_SERVER['DC_RC_PATH'])) { | 
|---|
|  | 109 | define('DC_RC_PATH',$_SERVER['DC_RC_PATH']); | 
|---|
|  | 110 | } elseif (isset($_SERVER['REDIRECT_DC_RC_PATH'])) { | 
|---|
|  | 111 | define('DC_RC_PATH',$_SERVER['REDIRECT_DC_RC_PATH']); | 
|---|
|  | 112 | } else { | 
|---|
|  | 113 | define('DC_RC_PATH',dirname(__FILE__).'/config.php'); | 
|---|
|  | 114 | } | 
|---|
|  | 115 |  | 
|---|
|  | 116 | if (!is_file(DC_RC_PATH)) | 
|---|
|  | 117 | { | 
|---|
|  | 118 | if (strpos($_SERVER['SCRIPT_FILENAME'],'/admin') === false) { | 
|---|
|  | 119 | $path = 'admin/install/wizard.php'; | 
|---|
|  | 120 | } else { | 
|---|
|  | 121 | $path = strpos($_SERVER['PHP_SELF'],'/install') === false ? 'install/wizard.php' : 'wizard.php'; | 
|---|
|  | 122 | } | 
|---|
|  | 123 | http::redirect($path); | 
|---|
|  | 124 | } | 
|---|
|  | 125 |  | 
|---|
|  | 126 | require DC_RC_PATH; | 
|---|
|  | 127 |  | 
|---|
| [726] | 128 | //*== DC_DEBUG == | 
|---|
|  | 129 | if (!defined('DC_DEBUG')) { | 
|---|
|  | 130 | define('DC_DEBUG',true); | 
|---|
|  | 131 | } | 
|---|
|  | 132 | if (DC_DEBUG) { | 
|---|
|  | 133 | ini_set('display_errors',true); | 
|---|
|  | 134 | error_reporting(E_ALL | E_STRICT); | 
|---|
|  | 135 | } | 
|---|
|  | 136 | //*/ | 
|---|
|  | 137 |  | 
|---|
|  | 138 | if (!defined('DC_DEBUG')) { | 
|---|
|  | 139 | define('DC_DEBUG',false); | 
|---|
|  | 140 | } | 
|---|
|  | 141 |  | 
|---|
| [0] | 142 | # Constants | 
|---|
|  | 143 | define('DC_ROOT',path::real(dirname(__FILE__).'/..')); | 
|---|
| [3193] | 144 | define('DC_VERSION','2.9'); | 
|---|
| [0] | 145 | define('DC_DIGESTS',dirname(__FILE__).'/digests'); | 
|---|
|  | 146 | define('DC_L10N_ROOT',dirname(__FILE__).'/../locales'); | 
|---|
|  | 147 | define('DC_L10N_UPDATE_URL','http://services.dotclear.net/dc2.l10n/?version=%s'); | 
|---|
| [3010] | 148 | define('DC_DISTRIB_PLUGINS','aboutConfig,akismet,antispam,attachments,blogroll,blowupConfig,dclegacy,fairTrackbacks,importExport,maintenance,pages,pings,simpleMenu,tags,themeEditor,userPref,widgets,dcLegacyEditor,dcCKEditor,breadcrumb'); | 
|---|
| [2641] | 149 | define('DC_DISTRIB_THEMES','berlin,blueSilence,blowupConfig,customCSS,default,ductile'); | 
|---|
| [2607] | 150 | define('DC_DEFAULT_TPLSET','mustek'); | 
|---|
| [2800] | 151 | define('DC_DEFAULT_JQUERY','1.4.2'); | 
|---|
| [0] | 152 |  | 
|---|
|  | 153 | if (!defined('DC_VENDOR_NAME')) { | 
|---|
|  | 154 | define('DC_VENDOR_NAME','Dotclear'); | 
|---|
|  | 155 | } | 
|---|
|  | 156 |  | 
|---|
|  | 157 | if (!defined('DC_XMLRPC_URL')) { | 
|---|
|  | 158 | define('DC_XMLRPC_URL','%1$sxmlrpc/%2$s'); | 
|---|
|  | 159 | } | 
|---|
|  | 160 |  | 
|---|
| [3157] | 161 | if (!defined('DC_SESSION_TTL')) { | 
|---|
|  | 162 | define('DC_SESSION_TTL',null); | 
|---|
|  | 163 | } | 
|---|
|  | 164 |  | 
|---|
| [0] | 165 | if (!defined('DC_ADMIN_SSL')) { | 
|---|
|  | 166 | define('DC_ADMIN_SSL',false); | 
|---|
|  | 167 | } | 
|---|
|  | 168 |  | 
|---|
|  | 169 | if (defined('DC_FORCE_SCHEME_443') && DC_FORCE_SCHEME_443) { | 
|---|
|  | 170 | http::$https_scheme_on_443 = true; | 
|---|
|  | 171 | } | 
|---|
|  | 172 |  | 
|---|
|  | 173 | if (!defined('DC_DBPERSIST')) { | 
|---|
|  | 174 | define('DC_DBPERSIST',false); | 
|---|
|  | 175 | } | 
|---|
|  | 176 |  | 
|---|
|  | 177 | if (!defined('DC_UPDATE_URL')) { | 
|---|
|  | 178 | define('DC_UPDATE_URL','http://download.dotclear.org/versions.xml'); | 
|---|
|  | 179 | } | 
|---|
|  | 180 |  | 
|---|
|  | 181 | if (!defined('DC_UPDATE_VERSION')) { | 
|---|
|  | 182 | define('DC_UPDATE_VERSION','stable'); | 
|---|
|  | 183 | } | 
|---|
|  | 184 |  | 
|---|
| [3189] | 185 | if (!defined('DC_NOT_UPDATE')) { | 
|---|
|  | 186 | define('DC_NOT_UPDATE',false); | 
|---|
|  | 187 | } | 
|---|
|  | 188 |  | 
|---|
| [2319] | 189 | if (!defined('DC_ALLOW_MULTI_MODULES')) { | 
|---|
|  | 190 | define('DC_ALLOW_MULTI_MODULES',false); | 
|---|
|  | 191 | } | 
|---|
|  | 192 |  | 
|---|
| [0] | 193 | l10n::init(); | 
|---|
|  | 194 |  | 
|---|
|  | 195 | try { | 
|---|
|  | 196 | $core = new dcCore(DC_DBDRIVER,DC_DBHOST,DC_DBNAME,DC_DBUSER,DC_DBPASSWORD,DC_DBPREFIX,DC_DBPERSIST); | 
|---|
|  | 197 | } catch (Exception $e) { | 
|---|
|  | 198 | init_prepend_l10n(); | 
|---|
| [1069] | 199 | if (!defined('DC_CONTEXT_ADMIN')) { | 
|---|
|  | 200 | __error(__('Site temporarily unavailable'), | 
|---|
|  | 201 | __('<p>We apologize for this temporary unavailability.<br />'. | 
|---|
|  | 202 | 'Thank you for your understanding.</p>'), | 
|---|
|  | 203 | 20); | 
|---|
|  | 204 | } else { | 
|---|
|  | 205 | __error(__('Unable to connect to database') | 
|---|
|  | 206 | ,$e->getCode() == 0 ? | 
|---|
|  | 207 | sprintf(__('<p>This either means that the username and password information in '. | 
|---|
|  | 208 | 'your <strong>config.php</strong> file is incorrect or we can\'t contact '. | 
|---|
|  | 209 | 'the database server at "<em>%s</em>". This could mean your '. | 
|---|
|  | 210 | 'host\'s database server is down.</p> '. | 
|---|
|  | 211 | '<ul><li>Are you sure you have the correct username and password?</li>'. | 
|---|
|  | 212 | '<li>Are you sure that you have typed the correct hostname?</li>'. | 
|---|
|  | 213 | '<li>Are you sure that the database server is running?</li></ul>'. | 
|---|
|  | 214 | '<p>If you\'re unsure what these terms mean you should probably contact '. | 
|---|
|  | 215 | 'your host. If you still need help you can always visit the '. | 
|---|
|  | 216 | '<a href="http://forum.dotclear.net/">Dotclear Support Forums</a>.</p>'). | 
|---|
|  | 217 | (DC_DEBUG ? | 
|---|
|  | 218 | __('The following error was encountered while trying to read the database:').'</p><ul><li>'.$e->getMessage().'</li></ul>' :  '') | 
|---|
|  | 219 | ,(DC_DBHOST != '' ? DC_DBHOST : 'localhost') | 
|---|
|  | 220 | ) | 
|---|
|  | 221 | : '' | 
|---|
|  | 222 | ,20); | 
|---|
|  | 223 | } | 
|---|
| [0] | 224 | } | 
|---|
|  | 225 |  | 
|---|
|  | 226 | # If we have some __top_behaviors, we load them | 
|---|
|  | 227 | if (isset($__top_behaviors) && is_array($__top_behaviors)) | 
|---|
|  | 228 | { | 
|---|
|  | 229 | foreach ($__top_behaviors as $b) { | 
|---|
|  | 230 | $core->addBehavior($b[0],$b[1]); | 
|---|
|  | 231 | } | 
|---|
|  | 232 | unset($b); | 
|---|
|  | 233 | } | 
|---|
|  | 234 |  | 
|---|
|  | 235 | http::trimRequest(); | 
|---|
|  | 236 | try { | 
|---|
|  | 237 | http::unsetGlobals(); | 
|---|
|  | 238 | } catch (Exception $e) { | 
|---|
|  | 239 | header('Content-Type: text/plain'); | 
|---|
|  | 240 | echo $e->getMessage(); | 
|---|
|  | 241 | exit; | 
|---|
|  | 242 | } | 
|---|
|  | 243 |  | 
|---|
|  | 244 | $core->url->registerDefault(array('dcUrlHandlers','home')); | 
|---|
|  | 245 | $core->url->registerError(array('dcUrlHandlers','default404')); | 
|---|
|  | 246 | $core->url->register('lang','','^([a-zA-Z]{2}(?:-[a-z]{2})?(?:/page/[0-9]+)?)$',array('dcUrlHandlers','lang')); | 
|---|
|  | 247 | $core->url->register('post','post','^post/(.+)$',array('dcUrlHandlers','post')); | 
|---|
|  | 248 | $core->url->register('preview','preview','^preview/(.+)$',array('dcUrlHandlers','preview')); | 
|---|
|  | 249 | $core->url->register('category','category','^category/(.+)$',array('dcUrlHandlers','category')); | 
|---|
|  | 250 | $core->url->register('archive','archive','^archive(/.+)?$',array('dcUrlHandlers','archive')); | 
|---|
|  | 251 |  | 
|---|
|  | 252 | $core->url->register('feed','feed','^feed/(.+)$',array('dcUrlHandlers','feed')); | 
|---|
|  | 253 | $core->url->register('trackback','trackback','^trackback/(.+)$',array('dcUrlHandlers','trackback')); | 
|---|
|  | 254 | $core->url->register('rsd','rsd','^rsd$',array('dcUrlHandlers','rsd')); | 
|---|
|  | 255 | $core->url->register('xmlrpc','xmlrpc','^xmlrpc/(.+)$',array('dcUrlHandlers','xmlrpc')); | 
|---|
|  | 256 |  | 
|---|
| [2821] | 257 | // Should use dcAdminURL class, but only in admin -> to be moved to public/prepend.php and admin/prepend.php ? | 
|---|
| [1694] | 258 | $core->setPostType('post','post.php?id=%d',$core->url->getURLFor('post','%s'),'Posts'); | 
|---|
| [0] | 259 |  | 
|---|
|  | 260 | # Store upload_max_filesize in bytes | 
|---|
|  | 261 | $u_max_size = files::str2bytes(ini_get('upload_max_filesize')); | 
|---|
|  | 262 | $p_max_size = files::str2bytes(ini_get('post_max_size')); | 
|---|
|  | 263 | if ($p_max_size < $u_max_size) { | 
|---|
|  | 264 | $u_max_size = $p_max_size; | 
|---|
|  | 265 | } | 
|---|
|  | 266 | define('DC_MAX_UPLOAD_SIZE',$u_max_size); | 
|---|
|  | 267 | unset($u_max_size); unset($p_max_size); | 
|---|
|  | 268 |  | 
|---|
| [2767] | 269 | # Register supplemental mime types | 
|---|
|  | 270 | files::registerMimeTypes(array( | 
|---|
|  | 271 | // Audio | 
|---|
|  | 272 | 'aac'     => 'audio/aac', | 
|---|
|  | 273 | 'ogg'     => 'audio/ogg', | 
|---|
|  | 274 | 'weba'    => 'audio/webm', | 
|---|
|  | 275 | 'm4a'     => 'audio/mp4', | 
|---|
|  | 276 | // Video | 
|---|
|  | 277 | 'mp4'     => 'video/mp4', | 
|---|
|  | 278 | 'm4p'     => 'video/mp4', | 
|---|
|  | 279 | 'webm'    => 'video/webm' | 
|---|
|  | 280 | )); | 
|---|
|  | 281 |  | 
|---|
| [0] | 282 | # Shutdown | 
|---|
|  | 283 | register_shutdown_function('__shutdown'); | 
|---|
|  | 284 |  | 
|---|
|  | 285 | function __shutdown() | 
|---|
|  | 286 | { | 
|---|
|  | 287 | global $__shutdown; | 
|---|
|  | 288 | if (is_array($__shutdown)) { | 
|---|
|  | 289 | foreach ($__shutdown as $f) { | 
|---|
|  | 290 | if (is_callable($f)) { | 
|---|
|  | 291 | call_user_func($f); | 
|---|
|  | 292 | } | 
|---|
|  | 293 | } | 
|---|
|  | 294 | } | 
|---|
|  | 295 | # Explicitly close session before DB connection | 
|---|
|  | 296 | try { | 
|---|
|  | 297 | if (session_id()) { | 
|---|
|  | 298 | session_write_close(); | 
|---|
|  | 299 | } | 
|---|
|  | 300 | } catch (Exception $e) {} | 
|---|
|  | 301 | $GLOBALS['core']->con->close(); | 
|---|
|  | 302 | } | 
|---|
|  | 303 |  | 
|---|
|  | 304 | function __error($summary,$message,$code=0) | 
|---|
|  | 305 | { | 
|---|
|  | 306 | # Error codes | 
|---|
|  | 307 | # 10 : no config file | 
|---|
|  | 308 | # 20 : database issue | 
|---|
|  | 309 | # 30 : blog is not defined | 
|---|
|  | 310 | # 40 : template files creation | 
|---|
|  | 311 | # 50 : no default theme | 
|---|
|  | 312 | # 60 : template processing error | 
|---|
|  | 313 | # 70 : blog is offline | 
|---|
| [2466] | 314 |  | 
|---|
| [0] | 315 | if (CLI_MODE) | 
|---|
|  | 316 | { | 
|---|
|  | 317 | trigger_error($summary,E_USER_ERROR); | 
|---|
|  | 318 | exit(1); | 
|---|
|  | 319 | } | 
|---|
|  | 320 | else | 
|---|
|  | 321 | { | 
|---|
|  | 322 | if (defined('DC_ERRORFILE') && is_file(DC_ERRORFILE)) { | 
|---|
|  | 323 | include DC_ERRORFILE; | 
|---|
|  | 324 | } else { | 
|---|
|  | 325 | include dirname(__FILE__).'/core_error.php'; | 
|---|
|  | 326 | } | 
|---|
|  | 327 | exit; | 
|---|
|  | 328 | } | 
|---|
|  | 329 | } | 
|---|
|  | 330 |  | 
|---|
|  | 331 | function init_prepend_l10n() | 
|---|
|  | 332 | { | 
|---|
|  | 333 | # Loading locales for detected language | 
|---|
|  | 334 | $dlang = http::getAcceptLanguages(); | 
|---|
|  | 335 | foreach($dlang as $l) | 
|---|
|  | 336 | { | 
|---|
|  | 337 | if ($l == 'en' || l10n::set(dirname(__FILE__).'/../locales/'.$l.'/main') !== false) { | 
|---|
| [1949] | 338 | l10n::lang($l); | 
|---|
| [0] | 339 | break; | 
|---|
|  | 340 | } | 
|---|
|  | 341 | } | 
|---|
|  | 342 | } | 
|---|