root/include/config.php

Revision 324, 5.0 kB (checked in by Nafania, 1 year ago)

Много мелких изменений. Если используется xbtt, то надо обязательно скачать новую версию на форуме.
Добавлен файл cron.php - если есть возможность, то пускайте cron таски через него. Особенно если используете массовую рассылку почты.

Line 
1 <?php</span>
2 <span class="code-lang">$starttime = explode(' ', microtime());
3 $starttime = $starttime[1] + $starttime[0];</span>
4 <span class="code-lang">
5 if ( version_compare(PHP_VERSION, '5.3', '>=') ) {
6     error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
7 }
8 else {
9     error_reporting(E_ALL & ~E_NOTICE);
10 }
11
12 function deregister_globals()
13 {
14     $not_unset = array(
15         'GLOBALS'    => true,
16         '_GET'        => true,
17         '_POST'        => true,
18         '_COOKIE'    => true,
19         '_REQUEST'    => true,
20         '_SERVER'    => true,
21         '_SESSION'    => true,
22         '_ENV'        => true,
23         '_FILES'    => true,
24         'phpEx'        => true,
25         'tracker_root_path' => true
26     );
27
28     if (!isset($_SESSION) || !is_array($_SESSION))
29     {
30         $_SESSION = array();
31     }
32
33     $input = array_merge(
34         array_keys($_GET),
35         array_keys($_POST),
36         array_keys($_COOKIE),
37         array_keys($_SERVER),
38         array_keys($_SESSION),
39         array_keys($_ENV),
40         array_keys($_FILES)
41     );
42
43     foreach ($input as $varname)
44     {
45         if (isset($not_unset[$varname]))
46         {
47             exit;
48         }
49
50         unset($GLOBALS[$varname]);
51     }
52
53     unset($input);
54 }
55
56 if (version_compare(PHP_VERSION, '6.0.0-dev', '>='))
57 {
58     define('STRIP', false);
59 }
60 else
61 {
62     set_magic_quotes_runtime(0);
63
64     if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
65     {
66         deregister_globals();
67     }
68
69     define('STRIP', (get_magic_quotes_gpc()) ? true : false);
70 }
71
72 if (!file_exists($root_path . 'include/secrets.php'))
73 {
74     die("<p>The secrets.php file could not be found.</p><p><a href=\"/install/index.php\">Click here to install TB Dev SZ Edition</a></p>");
75 }
76
77 require($root_path . 'include/secrets.php');
78
79 if (!defined('TB_INSTALLED'))
80 {
81     // Redirect the user to the installer
82     // We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
83     // available as used by the redirect function
84     $server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME');
85     $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
86     $secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
87
88     $script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
89     if (!$script_name)
90     {
91         $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
92     }
93
94     // Replace any number of consecutive backslashes and/or slashes with a single slash
95     // (could happen on some proxy setups and/or Windows servers)
96     $script_path = trim(dirname($script_name)) . '/install/index.php';
97     $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);
98
99     $url = (($secure) ? 'https://' : 'http://') . $server_name;
100
101     if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
102     {
103         $url .= ':' . $server_port;
104     }
105
106     $url .= $script_path;
107     header('Location: ' . $url);
108     exit;
109 }
110
111 if ( file_exists($root_path . 'install') )
112 {
113         die('Delete the install directory');
114 }
115
116 require_once($root_path . 'include/constants.php');
117 require_once($root_path . 'include/db/' . $db_type . '.php');
118 require_once($root_path . 'include/class.cache.php');
119 //we don't include some scripts when we are in announce
120 if ( !defined('IN_ANNOUNCE') ) {</span>
121 <span class="code-keyword">    require_once($root_path . 'include/functions.php');
122     require_once($root_path . 'include/functions_utf.php');
123     set_error_handler('msg_handler');
124     require_once($root_path . 'include/sessions.php');
125     require_once($root_path . 'include/auth.php');
126     if ( defined('IN_PHPBB') || defined('IN_PHPBB2_BRIDGE') ) {
127         $dss_seeded = false;
128         require_once($root_path . 'phpBB2/includes/functions.php');
129     }
130 }
131
132 $phpbb_class = array (UC_SYSOP => 6,</span>
133 <span class="code-lang">                      UC_ADMINISTRATOR => 6,
134                       UC_MODERATOR => 7,
135                       UC_UPLOADER => 55,
136                       UC_VIP => 386,
137                       UC_POWER_USER => 56,
138                       UC_USER => 385,
139                       UC_PEASANT => 387);
140
141 $db = new $sql_db();
142 $cache = new cache();
143
144 $db->sql_connect($db_host, $db_user, $db_pass, $db_name, $db_port, $db_persistency);</span>
145 <span class="code-lang">unset($db_pass);
146
147 $config = $cache->obtain_config();</span>
148 <span class="code-lang">
149 if ( !defined('IN_ANNOUNCE') ) {
150     require_once($root_path . 'include/class.seo.php');
151     $seo = new seo();
152 }
153
154 $userdata = array();</span>
155 <span class="code-lang">
156 if (defined('DEBUG_EXTRA'))
157 {
158     $base_memory_usage = 0;
159     if (function_exists('memory_get_usage'))
160     {
161         $base_memory_usage = memory_get_usage();
162     }
163 }
164
165 //start determine user ip
166 if( isset($_SERVER['HTTP_X_FORWARDED_FOR']) && ( $_SERVER['HTTP_X_FORWARDED_FOR'] != 'unknown') ) {</span>
167 <span class="code-keyword">    $user_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
168 }
169 elseif( isset($_SERVER['HTTP_CLIENT_IP']) ) {
170     $user_ip = $_SERVER['HTTP_CLIENT_IP'];
171 }
172 else {
173     $user_ip = $_SERVER['REMOTE_ADDR'];
174 }
175 $user_ip = implode('.', array_slice(explode('.', $user_ip), 0, 4));</span>
176 <span class="code-lang">list($user_ip) = explode(' ', $user_ip);
177 list($user_ip) = explode(',', $user_ip);
178 //end determine user ip
179
180 if( ( !isset($config['siteonline']) || !$config['siteonline'] ) && !defined('IN_ADMIN') && !defined('IN_LOGIN') && !defined('IN_ANNOUNCE') )</span>
181 <span class="code-keyword">{
182     $text = ( isset($config['offline_text']) && !empty($config['offline_text']) ? $config['offline_text'] : 'Tracker currently offline, please come back later' );
183     trigger_error($text, E_USER_ERROR);
184 }
185 ?>
Note: See TracBrowser for help on using the browser.