bug3
[aidenligne_francais_universite.git] / fluxbb / include / common.php
CommitLineData
c495c100
P
1<?php
2/***********************************************************************
3
4 Copyright (C) 2002-2005 Rickard Andersson (rickard@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// Activez le mode DEBUG en enlevant // du début de la ligne ci-dessous
26//define('PUN_DEBUG', 1);
27
28// Ceci permettra d'afficher en bas de page toutes les requêtes exécutées
29// N'ACTIVEZ PAS cela sur un environnement de production !
30//define('PUN_SHOW_QUERIES', 1);
31
32if (!defined('PUN_ROOT'))
33 exit('La constante PUN_ROOT doit être définie est doit pointer le repertoire racine d\'une installation fonctionnelle de FluxBB.');
34
35
36// Load the functions script
37require PUN_ROOT.'include/functions.php';
38
39// Reverse the effect of register_globals
40unregister_globals();
41
42
43@include PUN_ROOT.'config.php';
44
45// If PUN isn't defined, config.php is missing or corrupt
46if (!defined('PUN'))
47 exit('Le fichier "config.php" n\'existe pas ou est endommagé. Veuillez lancer <a href="install.php">install.php</a> pour installer FluxBB.');
48
49
50// Record the start time (will be used to calculate the generation time for the page)
51list($usec, $sec) = explode(' ', microtime());
52$pun_start = ((float)$usec + (float)$sec);
53
54// Make sure PHP reports all errors except E_NOTICE. FluxBB supports E_ALL, but a lot of scripts it may interact with, do not.
55error_reporting(E_ALL ^ E_NOTICE);
56
57// Turn off magic_quotes_runtime
58if (get_magic_quotes_runtime())
59 set_magic_quotes_runtime(0);
60
61// Strip slashes from GET/POST/COOKIE (if magic_quotes_gpc is enabled)
62if (get_magic_quotes_gpc())
63{
64 function stripslashes_array($array)
65 {
66 return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
67 }
68
69 $_GET = stripslashes_array($_GET);
70 $_POST = stripslashes_array($_POST);
71 $_COOKIE = stripslashes_array($_COOKIE);
72}
73
74// Seed the random number generator (PHP <4.2.0 only)
75if (version_compare(PHP_VERSION, '4.2.0', '<'))
76 mt_srand((double)microtime()*1000000);
77
78// If a cookie name is not specified in config.php, we use the default (forum_cookie)
79if (empty($cookie_name))
80 $cookie_name = 'forum_cookie';
81
82// Define a few commonly used constants
83define('PUN_UNVERIFIED', 32000);
84define('PUN_ADMIN', 1);
85define('PUN_MOD', 2);
86define('PUN_GUEST', 3);
87define('PUN_MEMBER', 4);
88
89
90// Load DB abstraction layer and connect
91require PUN_ROOT.'include/dblayer/common_db.php';
92
93// Start a transaction
94$db->start_transaction();
95
96// Load cached config
97@include PUN_ROOT.'cache/cache_config.php';
98if (!defined('PUN_CONFIG_LOADED'))
99{
100 require PUN_ROOT.'include/cache.php';
101 generate_config_cache();
102 require PUN_ROOT.'cache/cache_config.php';
103}
104
105
106// Enable output buffering
107if (!defined('PUN_DISABLE_BUFFERING'))
108{
109 // For some very odd reason, "Norton Internet Security" unsets this
110 $_SERVER['HTTP_ACCEPT_ENCODING'] = isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? $_SERVER['HTTP_ACCEPT_ENCODING'] : '';
111
112 // Should we use gzip output compression?
113 if ($pun_config['o_gzip'] && extension_loaded('zlib') && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false || strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== false))
114 ob_start('ob_gzhandler');
115 else
116 ob_start();
117}
118
119
120// Check/update/set cookie and fetch user info
121$pun_user = array();
122check_cookie($pun_user);
123
124// Attempt to load the common language file
125@include PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
126if (!isset($lang_common))
127 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.');
128
129// Check if we are to display a maintenance message
130if ($pun_config['o_maintenance'] && $pun_user['g_id'] > PUN_ADMIN && !defined('PUN_TURN_OFF_MAINT'))
131 maintenance_message();
132
133
134// Load cached bans
135@include PUN_ROOT.'cache/cache_bans.php';
136if (!defined('PUN_BANS_LOADED'))
137{
138 require_once PUN_ROOT.'include/cache.php';
139 generate_bans_cache();
140 require PUN_ROOT.'cache/cache_bans.php';
141}
142
143// Check if current user is banned
144check_bans();
145
146
147// Update online list
148update_users_online();
149