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