File: _main.php

package info (click to toggle)
b2evolution 0.9.2-3
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 12,976 kB
  • ctags: 5,460
  • sloc: php: 58,989; sh: 298; makefile: 36
file content (175 lines) | stat: -rw-r--r-- 5,387 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?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/}
 *
 * @package evocore
 */
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)
	return;
}
$main_init = true;


/**
 * Load configuration:
 */
require_once( dirname(__FILE__).'/../conf/_config.php' );
if( !$config_is_done )
{	// base config is not done.
	$error_message = 'Base configuration is not done.';
	require dirname(__FILE__).'/_conf_error.page.php';	// error & exit
}


/**
 * Start timers:
 */
require_once( dirname(__FILE__).'/_functions.php' );
timer_start();
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' );


/**
 * Connecting to the db:
 */
require_once( dirname(__FILE__).'/_class_db.php' );
$DB = new DB( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST, $db_aliases );

// 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 -->';
}
else
{	// we have a referrer:
	if( strpos($HTTP_REFERER,$baseurl) === 0 )
	{	// We are referring from our own site:
		if( $debug >= 2 ) echo '<!-- ash:self_ref -->';
	}
	else
	{	// We're not referring from ourselves!
	 if( ! $DB->get_row( "SELECT aspm_ID, aspm_string
	  		 	FROM  $tableantispam
	       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 -->';
		}
		else
	  {	// 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' );




if( !function_exists( 'gzencode' ) )
{ // when there is no function to gzip, we won't do it
	$use_gzipcompression = false;
}

if( $use_obhandler )
{ // register output buffer handler
	ob_start( 'obhandler' );
}



$Settings = & new Settings();

$servertimenow = time();
$localtimenow = $servertimenow + ($Settings->get('time_difference') * 3600);


// Locale stuff:
debug_log('default_locale from conf: '.$default_locale);

locale_overwritefromDB();
debug_log('default_locale from DB: '.$default_locale);

$default_locale = locale_from_httpaccept(); // set default locale by autodetect
debug_log('default_locale from HTTP_ACCEPT: '.$default_locale);

// Activate default locale:
locale_activate( $default_locale );


// Object caches init:
$GroupCache = & new DataObjectCache( 'Group', true, $tablegroups, 'grp_', 'grp_ID' );
$BlogCache = & new BlogCache();
$ItemCache = & new ItemCache();


// Plug-ins init:
$Renderer = & new Renderer();
$Toolbars = & new Toolbars();


// Login procedure:
if( !isset($login_required) ) $login_required = false;
if( $error = veriflog( $login_required ) )
{	// Login failed:
	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');
	locale_activate( $default_locale );
	debug_log('default_locale from user profile: '.$default_locale);
}


// Load hacks file if it exists
@include_once( dirname(__FILE__) . '/../conf/hacks.php' );
?>