source: branches/rsr.v5.1/web/punbb/include/common.php @ 7

Last change on this file since 7 was 1, checked in by dj3c1t, 13 years ago

import initial

File size: 4.5 KB
RevLine 
[1]1<?php
2
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);
32
33if (!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.');
35
36
37// Load the functions script
38require PUN_ROOT.'include/functions.php';
39
40// Reverse the effect of register_globals
41if (@ini_get('register_globals'))
42        unregister_globals();
43
44include PUN_ROOT.'config.php';
45
46// If PUN isn't defined, config.php is missing or corrupt
47if (!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
50
51// Record the start time (will be used to calculate the generation time for the page)
52list($usec, $sec) = explode(' ', microtime());
53$pun_start = ((float)$usec + (float)$sec);
54
55// Enable full error, warning and notice reporting
56error_reporting(E_ALL ^ E_NOTICE);
57
58// Turn off magic_quotes_runtime
59set_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
75mt_srand((double)microtime()*1000000);
76
77// If a cookie name is not specified in config.php, we use the default (punbb_cookie)
78if (empty($cookie_name))
79        $cookie_name = 'punbb_cookie';
80
81// Define a few commonly used constants
82define('PUN_UNVERIFIED', 32000);
83define('PUN_ADMIN', 1);
84define('PUN_MOD', 2);
85define('PUN_GUEST', 3);
86define('PUN_MEMBER', 4);
87
88
89// Load DB abstraction layer and connect
90require PUN_ROOT.'include/dblayer/common_db.php';
91
92// Start a transaction
93$db->start_transaction();
94
95// Load cached config
96@include PUN_ROOT.'cache/cache_config.php';
97if (!defined('PUN_CONFIG_LOADED'))
98{
99        require PUN_ROOT.'include/cache.php';
100        generate_config_cache();
101        require PUN_ROOT.'cache/cache_config.php';
102}
103
104
105// Enable output buffering
106if (!defined('PUN_DISABLE_BUFFERING'))
107{
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
111        // 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))
113                ob_start('ob_gzhandler');
114        else
115                ob_start();
116}
117
118
119// Check/update/set cookie and fetch user info
120$pun_user = array();
121check_cookie($pun_user);
122
123// Attempt to load the common language file
124@include PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
125if (!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.');
127
128// Check if we are to display a maintenance message
129if ($pun_config['o_maintenance'] && $pun_user['g_id'] > PUN_ADMIN && !defined('PUN_TURN_OFF_MAINT'))
130        maintenance_message();
131
132
133// Load cached bans
134@include PUN_ROOT.'cache/cache_bans.php';
135if (!defined('PUN_BANS_LOADED'))
136{
137        require_once PUN_ROOT.'include/cache.php';
138        generate_bans_cache();
139        require PUN_ROOT.'cache/cache_bans.php';
140}
141
142// Check if current user is banned
143check_bans();
144
145// Update online list
146update_users_online();
147
148?>
Note: See TracBrowser for help on using the repository browser.