This repository has been archived by the owner on Apr 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
blitzortung.php
326 lines (269 loc) · 7.75 KB
/
blitzortung.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<?php
/*
MyBlitzortung - a tool for participants of blitzortung.org
to display lightning data on their web sites.
Copyright 2011-2012 by Tobias Volgnandt & Blitzortung.org Participants
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if (!defined("BO_VER"))
{
//show all errors/warnings by default
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', 1);
define("BO_DIR", dirname(__FILE__).'/');
define("BO_VER", '1.4-dev7');
define("BO_PERM_ADMIN", 1);
define("BO_PERM_SETTINGS", 2);
define("BO_PERM_NOLIMIT", 4);
define("BO_PERM_ALERT", 8);
define("BO_PERM_ALERT_ALL", 16);
define("BO_PERM_ALERT_SMS", 32);
define("BO_PERM_ALERT_URL", 64);
define("BO_PERM_ARCHIVE", 128);
define("BO_PERM_ALERT_TWITTER", 256);
define("BO_PERM_COUNT", 9);
//Some default PHP-Options
ini_set('magic_quotes_runtime', 0);
//Config var.
global $_BO, $_BL;
$_BO = array();
$_BL = array();
if (!file_exists(BO_DIR.'config.php'))
die('Missing config.php! Please run installation first!');
//Load Config
require_once 'includes/const.inc.php';
require_once 'includes/templates_gmap.inc.php';
require_once 'includes/templates.inc.php';
require_once 'config.php';
require_once 'includes/default_settings.inc.php'; //after config.php!
require_once 'includes/default_templates.inc.php'; //after config.php!
//includes #1
require_once 'includes/functions.inc.php';
require_once 'includes/functions_image.inc.php';
require_once 'includes/functions_station.inc.php';
require_once 'includes/functions_lang.inc.php';
require_once 'includes/functions_geo.inc.php';
require_once 'includes/functions_sql.inc.php';
require_once 'includes/functions_signal.inc.php';
require_once 'includes/functions_strokes.inc.php';
require_once 'includes/functions_user.inc.php';
require_once 'includes/data.inc.php';
require_once 'includes/user.inc.php';
//Classes
require_once 'includes/classes/Db.class.php';
require_once 'includes/classes/DateTime.class.php';
//Debug Mode?
if (BO_DEBUG === true)
{
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', 1);
}
elseif (BO_DEBUG === "file")
{
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', 0);
define('BO_PHP_ERROR_LOG', BO_DIR.BO_CACHE_DIR.'/error.log');
}
elseif (BO_DEBUG === "silent")
{
ini_set('display_errors', 0);
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
}
else
{
ini_set('display_errors', 0);
}
set_error_handler("bo_error_handler");
//timezone
date_default_timezone_set(BO_TIMEZONE);
//User init (session, cookie, etc...)
bo_user_init();
//Station init
bo_station_init();
//creating tiles should be very fast, other include files not needed
if (isset($_GET['tile']))
{
//if (defined('BO_MAP_DISABLE') && BO_MAP_DISABLE && !(bo_user_get_level() & BO_PERM_NOLIMIT))
// exit('Google Maps disabled');
require_once 'includes/tiles.inc.php';
if (isset($_GET['tracks']))
bo_tile_tracks();
else
bo_tile();
exit;
}
//phpinfo for admin
else if ((BO_PERM_ADMIN & bo_user_get_level()) && $_GET['bo_action'] == 'phpinfo')
{
phpinfo();
exit;
}
// includes #2
require_once 'includes/pages.inc.php';
//Save info wether headers where sent
$_BO['headers_sent'] = headers_sent();
//Update with new data from blitzortung.org
$bo_do_update = false;
$bo_force_update = false;
$bo_only = '';
if (isset($_GET['update']))
{
if (defined('BO_UPDATE_SECRET') && BO_UPDATE_SECRET && $_GET['secret'] !== BO_UPDATE_SECRET)
exit('Wrong secret: "<b>'.htmlentities($_GET['secret']).'</b>" Look in your config.php for "<b>BO_UPDATE_SECRET</b>"');
$bo_do_update = true;
$bo_force_update = isset($_GET['force']);
$bo_only = strtolower($_GET['only']);
header("Content-Type: text/plain");
}
else if (isset($argv))
{
foreach ($argv as $a)
{
if ($a == 'update')
$bo_do_update = true;
elseif ($a == 'force')
$bo_force_update = true;
elseif ($bo_do_update == true && $a)
$bo_only = $a;
}
}
//load locale after tiles
$bo_redir_lang = bo_load_locale();
//decisions what to do begins...
if ($bo_do_update)
{
require_once 'includes/import.inc.php';
bo_update_all($bo_force_update, $bo_only);
exit;
}
else if (isset($_POST['bo_do_login']))
{
//Login
$bo_login_name = BoDb::esc(bo_gpc_prepare($_POST['bo_user']));
$bo_login_pass = BoDb::esc(bo_gpc_prepare($_POST['bo_pass']));
$bo_login_cookie = $_POST['bo_login_cookie'] ? true : false;
if (!bo_user_do_login($bo_login_name, $bo_login_pass, $bo_login_cookie))
$_BO['login_fail'] = true;
}
else if (isset($_GET['bo_logout']))
{
//Logout
bo_user_do_logout();
}
else if (isset($_GET['bo_login']) && (!defined('BO_LOGIN_URL') || !BO_LOGIN_URL))
{
//login-screen: workaround when no special login-url is specified
bo_show_login();
exit;
}
else if (!headers_sent())
{
if (isset($_GET['bo_icon']))
{
require_once 'includes/image.inc.php';
bo_icon($_GET['bo_icon']);
exit;
}
else if (isset($_GET['bo_graph']))
{
require_once 'includes/graphs.inc.php';
bo_graph_raw();
exit;
}
else if (isset($_GET['image']))
{
require_once 'includes/image.inc.php';
bo_get_image($_GET['image']);
exit;
}
else if (isset($_GET['graph_statistics']))
{
require_once 'includes/graphs.inc.php';
bo_graph_statistics();
exit;
}
else if (isset($_GET['density']))
{
require_once 'includes/density.inc.php';
bo_get_density_image();
exit;
}
elseif (isset($_GET['map']))
{
require_once 'includes/image.inc.php';
bo_get_map_image();
exit;
}
elseif (isset($_GET['animation']))
{
require_once 'includes/image.inc.php';
bo_get_map_image_ani();
exit;
}
}
//Order maps
if (defined('BO_MAPS_ORDER') && strlen(BO_MAPS_ORDER))
{
$bo_order = explode(',',BO_MAPS_ORDER);
$bo_tmp = array();
ksort($_BO['mapimg']);
foreach($bo_order as $id)
{
$bo_tmp[$id] = $_BO['mapimg'][$id];
}
foreach($_BO['mapimg'] as $id => $data)
{
if (!isset($bo_tmp[$id]))
$bo_tmp[$id] = $_BO['mapimg'][$id];
}
$_BO['mapimg'] = $bo_tmp;
}
if (isset($_GET['kml']))
{
bo_output_kml();
exit;
}
else if (isset($_GET['stations_json']))
{
header("Content-Type:application/json; charset=UTF-8");
echo bo_stations_json();
exit;
}
if (BO_SEND_CACHE_HEADER_HTML > 0 && !headers_sent())
{
if (intval($_COOKIE['bo_select_stationid']) || bo_user_get_level() || bo_sess_parms_set())
{
$bo_max_age = 5;
header("Cache-Control: private, max-age=".$bo_max_age);
}
else
{
$bo_max_age = BO_SEND_CACHE_HEADER_HTML;
header("Cache-Control: public, max-age=".$bo_max_age);
}
$bo_data_time = intval(time()/60)*60 - $bo_max_age;
header("Pragma: ");
header("Last-Modified: ".gmdate("D, d M Y H:i:s", $bo_data_time)." GMT");
header("Expires: ".gmdate("D, d M Y H:i:s", time() + $bo_max_age - 1) ." GMT");
}
//Redirect to correct language (only on pages)
if ($bo_redir_lang && strlen($_SERVER['REQUEST_URI']) > 1)
{
$url = bo_insert_url(BO_LANG_ARGUMENT, $bo_redir_lang, true);
header("X-Accel-Expires: 0");
header("Location: http://".$_SERVER['HTTP_HOST'].$url);
exit;
}
require_once 'includes/pages.inc.php';
require_once 'includes/functions_html.inc.php';
}
?>