Ignore:
Timestamp:
Nov 14, 2011, 11:17:15 PM (12 years ago)
Author:
dj3c1t
Message:

passage a Fluxbb 1.4.7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rsr.v5.1.dev/web/punbb/include/common.php

    r1 r3  
    11<?php
    22
    3 /***********************************************************************
    4 
    5   Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
    6 
    7   This file is part of PunBB.
    8 
    9   PunBB is free software; you can redistribute it and/or modify it
    10   under the terms of the GNU General Public License as published
    11   by the Free Software Foundation; either version 2 of the License,
    12   or (at your option) any later version.
    13 
    14   PunBB is distributed in the hope that it will be useful, but
    15   WITHOUT ANY WARRANTY; without even the implied warranty of
    16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17   GNU General Public License for more details.
    18 
    19   You should have received a copy of the GNU General Public License
    20   along with this program; if not, write to the Free Software
    21   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
    22   MA  02111-1307  USA
    23 
    24 ************************************************************************/
    25 
    26 // Activez le mode DEBUG en enlevant // du début de la ligne ci-dessous
    27 //define('PUN_DEBUG', 1);
    28 
    29 // Ceci permettra d'afficher en bas de page toutes les requêtes exécutées
    30 // N'ACTIVEZ PAS cela sur un environnement de production !
    31 //define('PUN_SHOW_QUERIES', 1);
     3/**
     4 * Copyright (C) 2008-2011 FluxBB
     5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
     6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
     7 */
    328
    339if (!defined('PUN_ROOT'))
    34         exit('La constante PUN_ROOT doit être définie est doit pointer le repertoire racine d\'une installation fonctionnelle de PunBB.');
     10        exit('The constant PUN_ROOT must be defined and point to a valid FluxBB installation root directory.');
    3511
     12// Define the version and database revision that this code was written for
     13define('FORUM_VERSION', '1.4.7');
     14
     15define('FORUM_DB_REVISION', 15);
     16define('FORUM_SI_REVISION', 2);
     17define('FORUM_PARSER_REVISION', 2);
     18
     19// Block prefetch requests
     20if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
     21{
     22        header('HTTP/1.1 403 Prefetching Forbidden');
     23
     24        // Send no-cache headers
     25        header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); // When yours truly first set eyes on this world! :)
     26        header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
     27        header('Cache-Control: post-check=0, pre-check=0', false);
     28        header('Pragma: no-cache'); // For HTTP/1.0 compatibility
     29
     30        exit;
     31}
     32
     33// Attempt to load the configuration file config.php
     34if (file_exists(PUN_ROOT.'config.php'))
     35        require PUN_ROOT.'config.php';
     36
     37// If we have the 1.3-legacy constant defined, define the proper 1.4 constant so we don't get an incorrect "need to install" message
     38if (defined('FORUM'))
     39        define('PUN', FORUM);
    3640
    3741// Load the functions script
    3842require PUN_ROOT.'include/functions.php';
    3943
     44// Load UTF-8 functions
     45require PUN_ROOT.'include/utf8/utf8.php';
     46
     47// Strip out "bad" UTF-8 characters
     48forum_remove_bad_characters();
     49
    4050// Reverse the effect of register_globals
    41 if (@ini_get('register_globals'))
    42         unregister_globals();
    43 
    44 include PUN_ROOT.'config.php';
     51forum_unregister_globals();
    4552
    4653// If PUN isn't defined, config.php is missing or corrupt
    4754if (!defined('PUN'))
    48         exit('Le fichier "config.php" n\'existe pas ou est endommagé. Veuillez lancer <a href="install.php">install.php</a> pour installer PunBB.');
    49 
     55{
     56        header('Location: install.php');
     57        exit;
     58}
    5059
    5160// Record the start time (will be used to calculate the generation time for the page)
    52 list($usec, $sec) = explode(' ', microtime());
    53 $pun_start = ((float)$usec + (float)$sec);
     61$pun_start = get_microtime();
    5462
    55 // Enable full error, warning and notice reporting
     63// Make sure PHP reports all errors except E_NOTICE. FluxBB supports E_ALL, but a lot of scripts it may interact with, do not
    5664error_reporting(E_ALL ^ E_NOTICE);
    5765
     66// Force POSIX locale (to prevent functions such as strtolower() from messing up UTF-8 strings)
     67setlocale(LC_CTYPE, 'C');
     68
    5869// Turn off magic_quotes_runtime
    59 set_magic_quotes_runtime(0);
     70if (get_magic_quotes_runtime())
     71        set_magic_quotes_runtime(0);
    6072
    61 // Strip slashes from GET/POST/COOKIE (if magic_quotes_gpc is enabled)
     73// Strip slashes from GET/POST/COOKIE/REQUEST/FILES (if magic_quotes_gpc is enabled)
    6274if (get_magic_quotes_gpc())
    6375{
     
    7082        $_POST = stripslashes_array($_POST);
    7183        $_COOKIE = stripslashes_array($_COOKIE);
     84        $_REQUEST = stripslashes_array($_REQUEST);
     85        $_FILES = stripslashes_array($_FILES);
    7286}
    7387
    74 // Seed the random number generator
    75 mt_srand((double)microtime()*1000000);
     88// If a cookie name is not specified in config.php, we use the default (pun_cookie)
     89if (empty($cookie_name))
     90        $cookie_name = 'pun_cookie';
    7691
    77 // If a cookie name is not specified in config.php, we use the default (punbb_cookie)
    78 if (empty($cookie_name))
    79         $cookie_name = 'punbb_cookie';
     92// If the cache directory is not specified, we use the default setting
     93if (!defined('FORUM_CACHE_DIR'))
     94        define('FORUM_CACHE_DIR', PUN_ROOT.'cache/');
    8095
    8196// Define a few commonly used constants
    82 define('PUN_UNVERIFIED', 32000);
     97define('PUN_UNVERIFIED', 0);
    8398define('PUN_ADMIN', 1);
    8499define('PUN_MOD', 2);
    85100define('PUN_GUEST', 3);
    86101define('PUN_MEMBER', 4);
    87 
    88102
    89103// Load DB abstraction layer and connect
     
    94108
    95109// Load cached config
    96 @include PUN_ROOT.'cache/cache_config.php';
     110if (file_exists(FORUM_CACHE_DIR.'cache_config.php'))
     111        include FORUM_CACHE_DIR.'cache_config.php';
     112
    97113if (!defined('PUN_CONFIG_LOADED'))
    98114{
    99         require PUN_ROOT.'include/cache.php';
     115        if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
     116                require PUN_ROOT.'include/cache.php';
     117
    100118        generate_config_cache();
    101         require PUN_ROOT.'cache/cache_config.php';
     119        require FORUM_CACHE_DIR.'cache_config.php';
    102120}
    103121
     122// Verify that we are running the proper database schema revision
     123if (!isset($pun_config['o_database_revision']) || $pun_config['o_database_revision'] < FORUM_DB_REVISION ||
     124        !isset($pun_config['o_searchindex_revision']) || $pun_config['o_searchindex_revision'] < FORUM_SI_REVISION ||
     125        !isset($pun_config['o_parser_revision']) || $pun_config['o_parser_revision'] < FORUM_PARSER_REVISION ||
     126        version_compare($pun_config['o_cur_version'], FORUM_VERSION, '<'))
     127{
     128        header('Location: db_update.php');
     129        exit;
     130}
    104131
    105132// Enable output buffering
    106133if (!defined('PUN_DISABLE_BUFFERING'))
    107134{
    108         // For some very odd reason, "Norton Internet Security" unsets this
    109         $_SERVER['HTTP_ACCEPT_ENCODING'] = isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? $_SERVER['HTTP_ACCEPT_ENCODING'] : '';
    110 
    111135        // Should we use gzip output compression?
    112         if ($pun_config['o_gzip'] && extension_loaded('zlib') && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false || strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== false))
     136        if ($pun_config['o_gzip'] && extension_loaded('zlib'))
    113137                ob_start('ob_gzhandler');
    114138        else
     
    116140}
    117141
     142// Define standard date/time formats
     143$forum_time_formats = array($pun_config['o_time_format'], 'H:i:s', 'H:i', 'g:i:s a', 'g:i a');
     144$forum_date_formats = array($pun_config['o_date_format'], 'Y-m-d', 'Y-d-m', 'd-m-Y', 'm-d-Y', 'M j Y', 'jS M Y');
    118145
    119146// Check/update/set cookie and fetch user info
     
    122149
    123150// Attempt to load the common language file
    124 @include PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
    125 if (!isset($lang_common))
    126         exit('Il n\'y a pas de pack de langue \''.pun_htmlspecialchars($pun_user['language']).'\' d\'installé. Veuillez ré-installer une langue de ce nom.');
     151if (file_exists(PUN_ROOT.'lang/'.$pun_user['language'].'/common.php'))
     152        include PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
     153else
     154        error('There is no valid language pack \''.pun_htmlspecialchars($pun_user['language']).'\' installed. Please reinstall a language of that name');
    127155
    128156// Check if we are to display a maintenance message
     
    130158        maintenance_message();
    131159
     160// Load cached bans
     161if (file_exists(FORUM_CACHE_DIR.'cache_bans.php'))
     162        include FORUM_CACHE_DIR.'cache_bans.php';
    132163
    133 // Load cached bans
    134 @include PUN_ROOT.'cache/cache_bans.php';
    135164if (!defined('PUN_BANS_LOADED'))
    136165{
    137         require_once PUN_ROOT.'include/cache.php';
     166        if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
     167                require PUN_ROOT.'include/cache.php';
     168
    138169        generate_bans_cache();
    139         require PUN_ROOT.'cache/cache_bans.php';
     170        require FORUM_CACHE_DIR.'cache_bans.php';
    140171}
    141172
     
    146177update_users_online();
    147178
    148 ?>
     179// Check to see if we logged in without a cookie being set
     180if ($pun_user['is_guest'] && isset($_GET['login']))
     181        message($lang_common['No cookie']);
     182
     183// The maximum size of a post, in bytes, since the field is now MEDIUMTEXT this allows ~16MB but lets cap at 1MB...
     184if (!defined('PUN_MAX_POSTSIZE'))
     185        define('PUN_MAX_POSTSIZE', 1048576);
     186
     187if (!defined('PUN_SEARCH_MIN_WORD'))
     188        define('PUN_SEARCH_MIN_WORD', 3);
     189if (!defined('PUN_SEARCH_MAX_WORD'))
     190        define('PUN_SEARCH_MAX_WORD', 20);
     191
     192if (!defined('FORUM_MAX_COOKIE_SIZE'))
     193        define('FORUM_MAX_COOKIE_SIZE', 4048);
Note: See TracChangeset for help on using the changeset viewer.