b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (0.9.x) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Source for file _main.php

Documentation is available at _main.php

  1. <?php
  2. /**
  3.  * This file initializes everything BUT the blog!
  4.  *
  5.  * It is useful when you want to do very customized templates!
  6.  * It is also called by more complete initializers.
  7.  * 
  8.  * b2evolution - {@link http://b2evolution.net/}
  9.  * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  10.  * @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
  11.  *
  12.  * @package evocore
  13.  */
  14. ifisset$main_init ) )
  15. {    // Prevent double loading since require_once won't work in all situations
  16.     // on windows when some subfolders have caps :(
  17.     // (Check it out on static page generation)
  18.     return;
  19. }
  20. $main_init true;
  21.  
  22.  
  23. /**
  24.  * Load configuration:
  25.  */
  26. require_oncedirname(__FILE__).'/../conf/_config.php' );
  27. if!$config_is_done )
  28. {    // base config is not done.
  29.     $error_message 'Base configuration is not done.';
  30.     require dirname(__FILE__).'/_conf_error.page.php';    // error & exit
  31. }
  32.  
  33.  
  34. /**
  35.  * Start timers:
  36.  */
  37. require_oncedirname(__FILE__).'/_functions.php' );
  38. require_once dirname(__FILE__).'/_timer.class.php';
  39. $Timer new Timer('main');
  40.  
  41.  
  42. /**
  43.  * Set various arrays and vars for use in b2
  44.  */
  45. require_oncedirname(__FILE__).'/_vars.php' );
  46.  
  47.  
  48. /**
  49.  * Connecting to the db:
  50.  */
  51. require_oncedirname(__FILE__).'/_class_db.php' );
  52. $DB new DBDB_USERDB_PASSWORDDB_NAMEDB_HOST$db_aliases );
  53.  
  54. // Specify which charset we are using on the client:
  55. //$DB->query( 'SET NAMES latin1');
  56. /*
  57. echo '<br />Server: '.$DB->get_var( 'SELECT @@character_set_server' );
  58. echo '<br />Database: '.$DB->get_var( 'SELECT @@character_set_database' );
  59. echo '<br />Connection: '.$DB->get_var( 'SELECT @@character_set_connection' );
  60. echo '<br />Client: '.$DB->get_var( 'SELECT @@character_set_client' );
  61. echo '<br />Results: '.$DB->get_var( 'SELECT @@character_set_results' );
  62. */
  63.  
  64. /**
  65.  * Check for referer spam:
  66.  *
  67.  * (Inspired by Isaac's hack. Note: this is done differently in phoenix)
  68.  */
  69. ifempty($HTTP_REFERER) )
  70. {    // There is no referer:
  71.     if$debug >= echo '<!-- ash:no_ref -->';
  72. }
  73. else
  74. {    // we have a referrer:
  75.     ifstrpos($HTTP_REFERER,$baseurl=== )
  76.     {    // We are referring from our own site:
  77.         if$debug >= echo '<!-- ash:self_ref -->';
  78.     }
  79.     else
  80.     {    // We're not referring from ourselves!
  81.      if$DB->get_row"SELECT aspm_ID, aspm_string
  82.                    FROM  $tableantispam
  83.            WHERE ".$DB->quote($HTTP_REFERER)." LIKE CONCAT('%',aspm_string,'%')
  84.            LIMIT 0, 1"OBJECT0'Advanced check for referer spam' ) )
  85.         {    // Referer is not matched by antispam blacklist:
  86.             if$debug >= echo '<!-- ash:ref_not_spam -->';
  87.         }
  88.         else
  89.       {    // THIS LOOKS LIKE REFERER SPAM!!
  90.             require dirname(__FILE__).'/_referer_spam.page.php';    // error & exit
  91.       }
  92.     }
  93. }
  94.  
  95.  
  96. require_oncedirname(__FILE__).'/_class_settings.php' );
  97. require_oncedirname(__FILE__).'/_functions_template.php' );    // function to be called from templates
  98. require_oncedirname(__FILE__).'/_functions_xmlrpc.php' );
  99. require_oncedirname(__FILE__).'/_functions_xmlrpcs.php' );
  100. require_oncedirname(__FILE__).'/_class_blog.php' );
  101. require_oncedirname(__FILE__).'/_class_itemlist.php' );
  102. require_oncedirname(__FILE__).'/_class_itemcache.php' );
  103. require_oncedirname(__FILE__).'/_class_commentlist.php' );
  104. require_oncedirname(__FILE__).'/_class_archivelist.php' );
  105. require_oncedirname(__FILE__).'/_class_dataobjectcache.php' );
  106. require_oncedirname(__FILE__).'/_class_calendar.php' );
  107. require_oncedirname(__FILE__).'/_functions_hitlogs.php' )// referer logging
  108. require_oncedirname(__FILE__).'/_functions_forms.php' );
  109. require_oncedirname(__FILE__).'/_class_renderer.php' );
  110. require_oncedirname(__FILE__).'/_class_toolbars.php' );
  111.  
  112.  
  113.  
  114.  
  115. if!function_exists'gzencode' ) )
  116. // when there is no function to gzip, we won't do it
  117.     $use_gzipcompression false;
  118. }
  119.  
  120. if$use_obhandler )
  121. // register output buffer handler
  122.     ob_start'obhandler' );
  123. }
  124.  
  125.  
  126.  
  127. $Settings new Settings();
  128.  
  129. $servertimenow time();
  130. $localtimenow $servertimenow ($Settings->get('time_difference'3600);
  131.  
  132.  
  133. // Locale stuff:
  134. debug_log('default_locale from conf: '.$default_locale);
  135.  
  136. debug_log('default_locale from DB: '.$default_locale);
  137.  
  138. $default_locale locale_from_httpaccept()// set default locale by autodetect
  139. debug_log('default_locale from HTTP_ACCEPT: '.$default_locale);
  140.  
  141. // Activate default locale:
  142. locale_activate$default_locale );
  143.  
  144.  
  145. // Object caches init:
  146. $GroupCache new DataObjectCache'Group'true$tablegroups'grp_''grp_ID' );
  147. $BlogCache new BlogCache();
  148. $ItemCache new ItemCache();
  149.  
  150.  
  151. // Plug-ins init:
  152. $Renderer new Renderer();
  153. $Toolbars new Toolbars();
  154.  
  155.  
  156. // Login procedure:
  157. if!isset($login_required) ) $login_required false;
  158. if$error veriflog$login_required ) )
  159. {    // Login failed:
  160.     require(dirname(__FILE__"/$core_dirout/$htsrv_subdir/login.php");
  161. }
  162.  
  163. ifis_logged_in(&& $current_User->get('locale'!= $default_locale )
  164. // change locale to users preference
  165.     $default_locale $current_User->get('locale');
  166.     locale_activate$default_locale );
  167.     debug_log('default_locale from user profile: '.$default_locale);
  168. }
  169.  
  170.  
  171. // Load hacks file if it exists
  172. @include_oncedirname(__FILE__'/../conf/hacks.php' );
  173. ?>

Documentation generated on Tue, 20 May 2008 01:55:25 +0200 by phpDocumentor 1.4.2