Source for file _main.php
Documentation is available at _main.php
* This file initializes everything BUT the blog!
* It is useful when you want to do very customized templates!
* It is also called by more complete initializers.
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
* @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
if( isset
( $main_init ) )
{ // Prevent double loading since require_once won't work in all situations
// on windows when some subfolders have caps :(
// (Check it out on static page generation)
require_once( dirname(__FILE__
).
'/../conf/_config.php' );
{ // base config is not done.
$error_message =
'Base configuration is not done.';
require
dirname(__FILE__
).
'/_conf_error.page.php'; // error & exit
require_once( dirname(__FILE__
).
'/_functions.php' );
require_once dirname(__FILE__
).
'/_timer.class.php';
$Timer =
& new Timer('main');
* Set various arrays and vars for use in b2
require_once( dirname(__FILE__
).
'/_vars.php' );
require_once( dirname(__FILE__
).
'/_class_db.php' );
// Specify which charset we are using on the client:
//$DB->query( 'SET NAMES latin1');
echo '<br />Server: '.$DB->get_var( 'SELECT @@character_set_server' );
echo '<br />Database: '.$DB->get_var( 'SELECT @@character_set_database' );
echo '<br />Connection: '.$DB->get_var( 'SELECT @@character_set_connection' );
echo '<br />Client: '.$DB->get_var( 'SELECT @@character_set_client' );
echo '<br />Results: '.$DB->get_var( 'SELECT @@character_set_results' );
* Check for referer spam:
* (Inspired by Isaac's hack. Note: this is done differently in phoenix)
if( empty($HTTP_REFERER) )
{ // There is no referer:
if( $debug >=
2 ) echo
'<!-- ash:no_ref -->';
if( strpos($HTTP_REFERER,$baseurl) ===
0 )
{ // We are referring from our own site:
if( $debug >=
2 ) echo
'<!-- ash:self_ref -->';
{ // We're not referring from ourselves!
if( ! $DB->get_row( "SELECT aspm_ID, aspm_string
WHERE ".
$DB->quote($HTTP_REFERER).
" LIKE CONCAT('%',aspm_string,'%')
LIMIT 0, 1", OBJECT, 0, 'Advanced check for referer spam' ) )
{ // Referer is not matched by antispam blacklist:
if( $debug >=
2 ) echo
'<!-- ash:ref_not_spam -->';
{ // THIS LOOKS LIKE REFERER SPAM!!
require
dirname(__FILE__
).
'/_referer_spam.page.php'; // error & exit
require_once( dirname(__FILE__
).
'/_class_settings.php' );
require_once( dirname(__FILE__
).
'/_functions_template.php' ); // function to be called from templates
require_once( dirname(__FILE__
).
'/_functions_xmlrpc.php' );
require_once( dirname(__FILE__
).
'/_functions_xmlrpcs.php' );
require_once( dirname(__FILE__
).
'/_class_blog.php' );
require_once( dirname(__FILE__
).
'/_class_itemlist.php' );
require_once( dirname(__FILE__
).
'/_class_itemcache.php' );
require_once( dirname(__FILE__
).
'/_class_commentlist.php' );
require_once( dirname(__FILE__
).
'/_class_archivelist.php' );
require_once( dirname(__FILE__
).
'/_class_dataobjectcache.php' );
require_once( dirname(__FILE__
).
'/_class_calendar.php' );
require_once( dirname(__FILE__
).
'/_functions_hitlogs.php' ); // referer logging
require_once( dirname(__FILE__
).
'/_functions_forms.php' );
require_once( dirname(__FILE__
).
'/_class_renderer.php' );
require_once( dirname(__FILE__
).
'/_class_toolbars.php' );
{ // when there is no function to gzip, we won't do it
$use_gzipcompression =
false;
{ // register output buffer handler
$localtimenow =
$servertimenow +
($Settings->get('time_difference') *
3600);
debug_log('default_locale from conf: '.
$default_locale);
debug_log('default_locale from DB: '.
$default_locale);
debug_log('default_locale from HTTP_ACCEPT: '.
$default_locale);
// Activate default locale:
$GroupCache =
& new DataObjectCache( 'Group', true, $tablegroups, 'grp_', 'grp_ID' );
if( !isset
($login_required) ) $login_required =
false;
if( $error =
veriflog( $login_required ) )
require
(dirname(__FILE__
) .
"/
$core_dirout/
$htsrv_subdir/login.php
");
if( is_logged_in() &&
$current_User->get('locale') !=
$default_locale )
{ // change locale to users preference
$default_locale =
$current_User->get('locale');
debug_log('default_locale from user profile: '.
$default_locale);
// Load hacks file if it exists
@include_once( dirname(__FILE__
) .
'/../conf/hacks.php' );