punbb/include/essentials.php
changeset 6 5e1f1e916419
child 9 a932ce8c4827
equal deleted inserted replaced
5:e3d7322305bf 6:5e1f1e916419
       
     1 <?php
       
     2 /***********************************************************************
       
     3 
       
     4   Copyright (C) 2002-2008  PunBB.org
       
     5 
       
     6   This file is part of PunBB.
       
     7 
       
     8   PunBB is free software; you can redistribute it and/or modify it
       
     9   under the terms of the GNU General Public License as published
       
    10   by the Free Software Foundation; either version 2 of the License,
       
    11   or (at your option) any later version.
       
    12 
       
    13   PunBB is distributed in the hope that it will be useful, but
       
    14   WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    16   GNU General Public License for more details.
       
    17 
       
    18   You should have received a copy of the GNU General Public License
       
    19   along with this program; if not, write to the Free Software
       
    20   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
       
    21   MA  02111-1307  USA
       
    22 
       
    23 ************************************************************************/
       
    24 
       
    25 
       
    26 // Enable DEBUG mode by removing // from the following line
       
    27 define('PUN_DEBUG', 1);
       
    28 
       
    29 // This displays all executed queries in the page footer.
       
    30 // DO NOT enable this in a production environment!
       
    31 //define('PUN_SHOW_QUERIES', 1);
       
    32 
       
    33 // Enable this if an extension is causing problems and you can't access the admin interface
       
    34 //define('PUN_DISABLE_HOOKS', 1);
       
    35 
       
    36 if (!defined('PUN_ROOT'))
       
    37 	exit('The constant PUN_ROOT must be defined and point to a valid PunBB installation root directory.');
       
    38 
       
    39 
       
    40 // Load the functions script
       
    41 require PUN_ROOT.'include/functions.php';
       
    42 
       
    43 // Reverse the effect of register_globals
       
    44 pun_unregister_globals();
       
    45 
       
    46 
       
    47 // Attempt to load the configuration file config.php
       
    48 if (file_exists(PUN_ROOT.'config.php'))
       
    49 	include PUN_ROOT.'config.php';
       
    50 
       
    51 if (!defined('PUN'))
       
    52 	error('The file \'config.php\' doesn\'t exist or is corrupt. Please run <a href="install.php">install.php</a> to install PunBB first.');
       
    53 
       
    54 
       
    55 // Record the start time (will be used to calculate the generation time for the page)
       
    56 list($usec, $sec) = explode(' ', microtime());
       
    57 $pun_start = ((float)$usec + (float)$sec);
       
    58 
       
    59 // Make sure PHP reports all errors except E_NOTICE. PunBB supports E_ALL, but a lot of scripts it may interact with, do not.
       
    60 error_reporting(E_ALL);
       
    61 
       
    62 // Force POSIX locale (to prevent functions such as strtolower() from messing up UTF-8 strings)
       
    63 setlocale(LC_CTYPE, 'C');
       
    64 
       
    65 // If the cache directory is not specified, we use the default setting
       
    66 if (!defined('PUN_CACHE_DIR'))
       
    67 	define('PUN_CACHE_DIR', PUN_ROOT.'cache/');
       
    68 
       
    69 
       
    70 // Load DB abstraction layer and connect
       
    71 require PUN_ROOT.'include/dblayer/common_db.php';
       
    72 
       
    73 // Start a transaction
       
    74 $pun_db->start_transaction();
       
    75 
       
    76 
       
    77 // Load cached config
       
    78 if (file_exists(PUN_CACHE_DIR.'cache_config.php'))
       
    79 	include PUN_CACHE_DIR.'cache_config.php';
       
    80 
       
    81 if (!defined('PUN_CONFIG_LOADED'))
       
    82 {
       
    83 	require_once PUN_ROOT.'include/cache.php';
       
    84 	generate_config_cache();
       
    85 	require PUN_CACHE_DIR.'cache_config.php';
       
    86 }
       
    87 
       
    88 
       
    89 // Load hooks
       
    90 if (file_exists(PUN_CACHE_DIR.'cache_hooks.php'))
       
    91 	include PUN_CACHE_DIR.'cache_hooks.php';
       
    92 
       
    93 if (!defined('PUN_HOOKS_LOADED'))
       
    94 {
       
    95 	require_once PUN_ROOT.'include/cache.php';
       
    96 	generate_hooks_cache();
       
    97 	require PUN_CACHE_DIR.'cache_hooks.php';
       
    98 }
       
    99 
       
   100 
       
   101 define('PUN_ESSENTIALS_LOADED', 1);