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
/
map.inc.php
1581 lines (1261 loc) · 44.4 KB
/
map.inc.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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
// GoogleMap with Markers
function bo_show_lightning_map($show_gmap=null, $show_static_maps=null)
{
global $_BO;
require_once 'functions_html.inc.php';
require_once 'functions_dynmap.inc.php';
$disabled = ((defined('BO_MAP_DISABLE') && BO_MAP_DISABLE && !bo_user_get_level())) || $show_gmap === 0;
$no_google = isset($_GET['bo_showmap']) || $disabled;
$period = (float)$_GET['bo_period'];
$static_map_id = $show_static_maps ? $show_static_maps : $_GET['bo_showmap'];
$show_static_maps = $show_static_maps === null || $show_static_maps;
$show_menu = $show_static_maps;
$last_update = BoData::get('uptime_strikes_modified');
if ($show_static_maps)
{
$map_groups = array();
$menu = array();
foreach($_BO['mapimg'] as $id => $d)
{
if (!$d['name'] || !$d['menu'])
continue;
if ($d['group'])
{
$map_groups[$d['group']][$id] = $d['name'];
$name = $d['group'];
$menu_id = 'group_'.$d['group'];
$menu_active = (string)$static_map_id === (string)$id;
if (!isset($menu[$menu_id]))
$menu[$menu_id] = array($menu_active, $name, $id);
else
$menu[$menu_id][0] = $menu[$menu_id][0] || $menu_active;
}
else
{
$name = $d['name'];
$menu_active = (string)$static_map_id === (string)$id;
$menu[$id] = array($menu_active, $name, $id);
}
}
if (!empty($menu) && $show_menu)
{
echo '<ul id="bo_menu">';
if (!$disabled)
echo '<li><a href="'.bo_insert_url(array('bo_*')).'" class="bo_navi'.(!$no_google ? '_active' : '').'">'._BL('Dynamic map').'</a></li>';
foreach($menu as $menu_id => $d)
{
$name = _BS($d[1], false, BO_CONFIG_IS_UTF8);
echo '<li><a href="'.bo_insert_url(array('bo_showmap', 'bo_*'), $d[2]);
echo count($_BO['mapimg'][$d[2]]['trange']) > 1 ? '&bo_period='.$period : '';
echo '" ';
echo ' class="bo_navi'.($d[0] ? '_active' : '').'">'.$name.'</a></li>';
if ($d[0])
bo_title($name);
}
echo '</ul>';
}
if ($no_google)
{
$cfg = $_BO['mapimg'][$static_map_id];
//look for different time ranges for the live-view
if (!is_array($cfg['trange']))
$ranges[$cfg['trange']] = $cfg['trange'];
else
$ranges = $cfg['trange'];
//find period ID
if ($period > 0)
{
$period_id = (int)array_search($period, $ranges);
$cache_file .= '_p'.$ranges[$period_id];
}
else
$period_id = 0; //set the default range!
//update intervals
if (!is_array($cfg['upd_intv']))
$update_interval = $cfg['upd_intv'] * 60;
elseif (!$cfg['upd_intv'][$period_id])
$update_interval = $cfg['upd_intv'][0] * 60;
else
$update_interval = $cfg['upd_intv'][$period_id] * 60;
if (!$update_interval)
$update_interval = 300;
$archive_maps_enabled = (defined('BO_ENABLE_ARCHIVE_MAPS') && BO_ENABLE_ARCHIVE_MAPS) || bo_user_get_level();
$url = bo_bofile_url().'?map='.$static_map_id.($period_id ? '&period='.$period : '').bo_lang_arg('map');
$img_dim = bo_archive_get_dim_html($static_map_id);
echo '<form method="GET">';
echo bo_insert_html_hidden(array('bo_showmap'));
echo '<fieldset class="bo_map_options_static">';
echo '<legend>'._BL("map_options_static").'</legend>';
echo ' <input type="submit" value="'._BL('update map').'" onclick="bo_map_reload_static(1); return false;" id="bo_map_reload">';
if ($cfg['group'] && isset($map_groups[$cfg['group']]) && count($map_groups[$cfg['group']]) > 1)
{
echo '<span class="bo_form_checkbox_text">';
echo _BL('Map').': ';
echo '<select name="bo_showmap" onchange="submit();">';
foreach($map_groups[$cfg['group']] as $map_id => $map_name)
{
$name = _BS($map_name, false, BO_CONFIG_IS_UTF8);
echo '<option value="'.$map_id.'" '.($map_id == $static_map_id ? 'selected' : '').'>';
echo $name;
echo '</option>';
if ($map_id == $static_map_id)
bo_title($name);
}
echo '</select> • ';
}
else
{
echo '<input type="hidden" name="bo_showmap" value="'.$static_map_id.'">';
}
echo '<span class="bo_form_checkbox_text">';
echo '<input type="checkbox" onclick="bo_toggle_autoupdate_static(this.checked);" id="bo_check_autoupdate_static"> ';
echo '<label for="bo_check_autoupdate_static">'._BL('auto update').'</label> ';
echo '</span>';
if (count($ranges) > 1)
{
echo '<span id="bo_livemap_select_periods">';
echo ' '._BL('Period').': ';
asort($ranges);
foreach($ranges as $i => $r)
{
echo '<a href="'.bo_insert_url("bo_period", $r).'" class="';
echo $i == $period_id ? 'bo_selected' : '';
echo '">';
if ($r < 2)
echo ($r * 60).'min';
else
echo $r.'h';
echo '</a> ';
}
echo '</span>';
}
echo '</fieldset>';
echo '</form>';
echo '<div id="bo_arch_maplinks_container_all">';
if ($cfg['header'])
echo '<div class="bo_map_header">'._BC($cfg['header'], true, BO_CONFIG_IS_UTF8).'</div>';
echo '<div style="display:inline-block;" id="bo_arch_maplinks_container">';
if ($archive_maps_enabled && $cfg['archive'])
{
echo '<div class="bo_arch_map_links">';
echo ' <a href="'.BO_ARCHIVE_URL.bo_add_sess_parms().'&bo_map='.$static_map_id.'" >'._BL('Archives').'</a> ';
if (intval(BO_ANIMATIONS_INTERVAL))
echo ' <a href="'.BO_ARCHIVE_URL.bo_add_sess_parms().'&bo_map='.$static_map_id.'&bo_animation=now" >'._BL('Animation').'</a> ';
echo '</div>';
}
$alt = _BL('Lightning map').' '._BL($_BO['mapimg'][$static_map_id]['name'], false, BO_CONFIG_IS_UTF8).' '._BDT($last_update);
echo '<div style="position:relative;display:inline-block;" id="bo_arch_map_container">';
echo '<img src="'.$url.'" '.$img_dim.' id="bo_arch_map_img" style="background-image:url(\''.bo_bofile_url().'?image=wait\');" alt="'.htmlspecialchars($alt).'">';
if ($cfg['footer'])
echo '<div class="bo_map_footer">'._BC($cfg['footer'], true, BO_CONFIG_IS_UTF8).'</div>';
echo '</div>';
echo '</div>';
echo '</div>';
?>
<script type="text/javascript">
var bo_autoupdate_running = false;
function bo_toggle_autoupdate_static(on)
{
if (on && bo_autoupdate_running)
return;
bo_autoupdate_running = on;
if (on)
bo_map_reload_static(0);
}
function bo_map_reload_static(manual)
{
if (bo_autoupdate_running || manual)
{
var now = new Date();
document.getElementById('bo_arch_map_img').src='<?php echo $url ?>&bo_t=' + Math.floor(now.getTime() / <?php echo 1+(1000 * $update_interval); ?>);
}
if (!manual)
bo_map_reload_static_wait();
}
function bo_map_reload_static_wait()
{
if (bo_autoupdate_running)
{
window.setTimeout("bo_map_reload_static(0);", <?php echo 1000 * ceil($update_interval / 2) ?>);
}
}
if (<?php echo BO_MAPS_AUTOUPDATE_DEFAULTON ? 'true' : 'false'; ?>)
{
bo_autoupdate_running=true;
bo_map_reload_static_wait();
document.getElementById('bo_check_autoupdate_static').checked=true;
}
</script>
<?php
return;
}
}
if ($disabled)
return;
//Max,min striketime
$row = BoDb::query("SELECT MIN(time) mintime, MAX(time) maxtime FROM ".BO_DB_PREF."strikes")->fetch_assoc();
$start_time = strtotime($row['mintime'].' UTC');
$end_time = strtotime($row['maxtime'].' UTC');
//Get Stations
$sid = bo_station_id();
$js_stations = '';
$res = BoDb::query("SELECT id, city, lat, lon, status
FROM ".BO_DB_PREF."stations a
WHERE id != '$sid'
ORDER BY status='A' ASC");
while($row = $res->fetch_assoc())
{
$row['status'] = bo_get_old_status($row['status']);
if ($row['status'] != '-' && $row['lat'] && $row['lon'])
{
$pos = bo_round_station_pos($row['lat'], $row['lon']);
$js_stations .= $js_stations ? ",\n" : '';
$js_stations .= '{';
$js_stations .= 'stid:'.$row['id'].', lat:'.$pos[0].', lon:'.$pos[1].', city:"'._BC($row['city']).'"';
$js_stations .= ', status:"'.$row['status'].'"';
$js_stations .= ', text:"';
switch($row['status'])
{
case 'A': $js_stations .= ' ('._BL('Active').')'; break;
case 'O': $js_stations .= ' ('._BL('Inactive').')'; break;
case 'V': $js_stations .= ' ('._BL('No GPS').')'; break;
}
$js_stations .= '"';
$js_stations .= '}';
}
$st_cities[$row['id']] = $row['city'].($row['status'] != 'A' ? ' (Offline)' : '');
}
//Static maps for admin (for testing)
if ((bo_user_get_level() & BO_PERM_ADMIN))
{
foreach($_BO['mapimg'] as $id => $data)
{
$_BO['mapovl'][] = array(
'img' => bo_bofile_url().'?map='.$id,
'coord' => $data['coord'],
'default_show' => false,
'sel_name' => $data['name'],
'only_loggedin' => true,
'to_mercator' => $data['proj'] == 'plate' ? true : false,
'opacity' => 50,
'is_map' => true
);
}
}
//Get extra map overlays
$Overlays = array();
foreach ($_BO['mapovl'] as $id => $data)
{
if ( (!(bo_user_get_level() & BO_PERM_NOLIMIT) && $data['only_loggedin'])
|| empty($data)
|| $data['hidden']
)
continue;
$Overlays[$id] = $data;
}
ksort($Overlays);
$radius = $_BO['radius'] * 1000;
$lat = (double)$_GET['bo_lat'];
$lon = (double)$_GET['bo_lon'];
$zoom = intval($_GET['bo_zoom']);
if ($lat || $lon || $zoom)
$cookie_load_defaults = false;
else
$cookie_load_defaults = true;
list($min_zoom, $max_zoom) = bo_get_zoom_limits();
$zoom = $zoom ? $zoom : BO_DEFAULT_ZOOM;
$lat = $lat ? $lat : BO_LAT;
$lon = $lon ? $lon : BO_LON;
if ($zoom < $min_zoom || $zoom > $max_zoom)
$zoom = $min_zoom;
echo '<fieldset class="bo_map_options">';
echo '<legend>'._BL("map_options").'</legend>';
ksort($_BO['mapcfg']);
$min_upd_interval = null;
$i = 0;
foreach ($_BO['mapcfg'] as $mapid => $cfg)
{
if (!is_array($cfg) || empty($cfg) || ($cfg['only_loggedin'] && !bo_user_get_level()) || !$cfg['sel_name'] || !$cfg['upd_intv'])
continue;
$mapcfg[$i] = $cfg;
$mapcfg[$i]['id'] = $mapid;
$mapcfg[$i]['upd_intv'] = max($cfg['upd_intv'], BO_UP_INTVL_STRIKES);
if ($min_upd_interval == null || $min_upd_interval > $mapcfg[$i]['upd_intv'])
$min_upd_interval = $mapcfg[$i]['upd_intv'];
$name = strtr($cfg['sel_name'], array('min' => _BL('unit_minutes'), 'h' => _BL('unit_hours'), 'days' => _BL('unit_days')));
echo '<span class="bo_form_checkbox_text">';
echo '<input type="checkbox" onclick="bo_map_toggle_overlay(this.checked, '.$i.');" ';
echo $cfg['default_show'] ? ' checked="checked" ' : '';
echo ' id="bo_map_opt'.$i.'"> ';
echo '<label for="bo_map_opt'.$i.'">'.$name.'</label> ';
echo '</span>';
$i++;
}
$mapcfg[-1] = $_BO['mapcfg'][-1];
$mapcfg[-1]['id'] = -1;
echo ' <input type="submit" value="'._BL('more').' ⇓" onclick="return bo_map_show_more();" id="bo_map_more">';
echo ' <input type="submit" value="'._BL('update map').'" onclick="bo_map_update(); return false;" id="bo_map_reload">';
if (intval(BO_MAP_AUTOUPDATE))
{
echo '<span class="bo_form_checkbox_text">';
echo '<input type="checkbox" onclick="bo_map_toggle_autoupdate(this.checked);" id="bo_check_autoupdate" '.(BO_MAP_AUTOUPDATE_DEFAULT_ON === true ? ' checked' : '').'> ';
echo '<label for="bo_check_autoupdate">'._BL('auto update').'</label> ';
echo '</span>';
}
echo '<div id="bo_map_more_container" style="display: none">';
/*** Manual time range ***/
if (BO_MAP_MANUAL_TIME_ENABLE === true || (bo_user_get_level() & BO_PERM_NOLIMIT))
{
$max_range = intval(BO_MAP_MANUAL_TIME_MAX_HOURS);
if ($max_range > 24)
$max_range = 24;
$yesterday = strtotime('now -1 day');
$year1 = (int)date('Y', $yesterday);
$month1 = (int)date('m', $yesterday);
$day1 = (int)date('d', $yesterday);
$hour1 = 0;
$minute1 = 0;
$time2 = strtotime("$year1-$month1-$day1 $hour1:$minute1:00 UTC") + $max_range * 3600;
$year2 = (int)date('Y', $time2);
$month2 = (int)date('m', $time2);
$day2 = (int)date('d', $time2);
$hour2 = (int)date('H', $time2);
$minute2 = (int)date('i', $time2);
echo '<div class="bo_input_container" id="bo_map_timerange">';
echo '<span class="bo_form_descr">'._BL('Time range').':</span> ';
echo '<select id="bo_map_select_year1" disabled>';
for($i=date('Y', $start_time); $i<=date('Y');$i++)
echo '<option value="'.$i.'" '.($i == $year1 ? 'selected' : '').'>'.$i.'</option>';
echo '</select> ';
echo '<select id="bo_map_select_month1" disabled>';
for($i=1;$i<=12;$i++)
echo '<option value="'.$i.'" '.($i == $month1 ? 'selected' : '').'>'._BL(date('M', strtotime("2000-$i-01"))).'</option>';
echo '</select> ';
echo '<select id="bo_map_select_day1" disabled>';
for($i=1;$i<=31;$i++)
echo '<option value="'.$i.'" '.($i == $day1 ? 'selected' : '').'>'.$i.'</option>';
echo '</select> ';
echo '<select id="bo_map_select_hour1" disabled>';
for($i=0;$i<=23;$i++)
echo '<option value="'.$i.'" '.($i == $hour1 ? 'selected' : '').'>'.sprintf('%02d', $i).'</option>';
echo '</select> : ';
echo '<select id="bo_map_select_minute1" disabled>';
for($i=0;$i<=59;$i+=5)
echo '<option value="'.$i.'" '.($i == $minute1 ? 'selected' : '').'>'.sprintf('%02d', $i).'</option>';
echo '</select>';
echo ' - ';
echo '<select id="bo_map_select_year2" disabled>';
for($i=date('Y', $start_time); $i<=date('Y');$i++)
echo '<option value="'.$i.'" '.($i == $year2 ? 'selected' : '').'>'.$i.'</option>';
echo '</select> ';
echo '<select id="bo_map_select_month2" disabled>';
for($i=1;$i<=12;$i++)
echo '<option value="'.$i.'" '.($i == $month2 ? 'selected' : '').'>'._BL(date('M', strtotime("2000-$i-01"))).'</option>';
echo '</select> ';
echo '<select id="bo_map_select_day2" disabled>';
for($i=1;$i<=31;$i++)
echo '<option value="'.$i.'" '.($i == $day2 ? 'selected' : '').'>'.$i.'</option>';
echo '</select> ';
echo '<select id="bo_map_select_hour2" disabled>';
for($i=0;$i<=23;$i++)
echo '<option value="'.$i.'" '.($i == $hour2 ? 'selected' : '').'>'.sprintf('%02d', $i).'</option>';
echo '</select> : ';
echo '<select id="bo_map_select_minute2" disabled>';
for($i=0;$i<=59;$i+=5)
echo '<option value="'.$i.'" '.($i == $minute2 ? 'selected' : '').'>'.sprintf('%02d', $i).'</option>';
echo '</select>';
echo ' ';
echo ' <span class="bo_form_checkbox_text">';
echo '<input type="checkbox" id="bo_map_timerange_check" onclick="bo_toggle_timerange(this.checked);"> ';
echo '<label for="bo_map_timerange_check">'._BL('Activated').'</label>';
echo '</span>';
echo '</div>';
}
$show_adv_counter = (bo_user_get_level() & BO_PERM_NOLIMIT);
$show_station_select = (bo_user_get_level() & BO_PERM_NOLIMIT) && BO_MAP_STATION_SELECT === true;
echo '<div class="bo_input_container" id="bo_map_advanced_options">';
echo '<span class="bo_form_descr">'._BL('Advanced').':</span> ';
echo '<span class="bo_form_checkbox_text">';
echo '<input type="checkbox" onclick="bo_map_toggle_stations(this.checked ? 2 : 1);" name="bo_map_station" id="bo_map_station1">';
echo '<label for="bo_map_station1">'._BL('Stations').'</label> ';
echo '</span>';
if (intval(BO_TRACKS_SCANTIME))
{
echo '<span class="bo_form_checkbox_text">';
echo '<input type="checkbox" onclick="bo_map_toggle_tracks(this.checked);" id="bo_map_opt_tracks"> ';
echo '<label for="bo_map_opt_tracks">'._BL("show tracks").'</label> ';
echo '</span>';
}
if (!$show_station_select && bo_station_id() > 0)
{
echo '<span class="bo_form_checkbox_text">';
echo '<input type="checkbox" onclick="bo_map_toggle_stationid_display(this.checked);" id="bo_map_opt_own"> ';
echo '<label for="bo_map_opt_own">'._BL("only own strikes").'</label> ';
echo '</span>';
}
if (!$show_adv_counter)
{
echo '<span class="bo_form_checkbox_text">';
echo '<input type="checkbox" onclick="bo_map_toggle_count(this.checked);" id="bo_map_opt_count"> ';
echo '<label for="bo_map_opt_count">'._BL("show strike counter").'</label> ';
echo '</span>';
}
echo '</div>';
if ($show_adv_counter)
{
echo '<div class="bo_input_container" id="bo_map_statistic_options">';
echo '<span class="bo_form_descr">'._BL('Statistics').':</span> ';
echo '<span class="bo_form_checkbox_text">';
echo '<input type="radio" name="bo_map_counter" value="0" onclick="bo_map_toggle_count(this.value);" id="bo_map_opt_count0"> ';
echo '<label for="bo_map_opt_count0">'._BL("Off").'</label> ';
echo '</span>';
echo '<span class="bo_form_checkbox_text">';
echo '<input type="radio" name="bo_map_counter" value="1" onclick="bo_map_toggle_count(this.value);" id="bo_map_opt_count"> ';
echo '<label for="bo_map_opt_count">'._BL("show strike counter").'</label> ';
echo '</span>';
if (BO_STATION_STAT_DISABLE !== true)
{
echo '<span class="bo_form_checkbox_text">';
echo '<input type="radio" name="bo_map_counter" value="2" onclick="bo_map_toggle_count(this.value);" id="bo_map_opt_count2"> ';
echo '<label for="bo_map_opt_count2">'._BL("show strike counter").' ('._BL('stations').')</label> ';
echo '</span>';
}
echo '</div>';
}
if ($show_station_select)
{
$opts = bo_get_station_list($style_class);
echo '<div class="bo_input_container" id="bo_map_statistic_options">';
echo '<span class="bo_form_descr">'._BL('Station').':</span> ';
echo '<span class="bo_form_checkbox_text">';
echo '<select name="bo_station_id" id="bo_only_station_id" onchange="bo_map_toggle_stationid(this.value);">';
echo '<option></option>';
foreach($opts as $id => $name)
{
echo '<option value="'.$id.'" class="'.$style_class[$id].'">';
echo $name;
echo '</option>';
}
echo '</select>';
echo '</span>';
echo '<span class="bo_form_checkbox_text">';
echo '<input type="checkbox" onclick="bo_map_toggle_stationid_display(this.checked);" id="bo_map_opt_strikes_station"> ';
echo '<label for="bo_map_opt_strikes_station">'._BL("Only strikes of selected station").'</label> ';
echo '</span>';
echo '</div>';
}
/* Moved
echo '<div class="bo_input_container" id="bo_map_stations_options">';
echo '<span class="bo_form_descr">'._BL('Show Stations').':</span> ';
echo '<span class="bo_form_checkbox_text">';
echo '<input type="radio" onclick="bo_map_toggle_stations(this.value);" value="2" name="bo_map_station" id="bo_map_station1">';
echo '<label for="bo_map_station1">'._BL('Stations').'</label> ';
echo '</span>';
echo '</div>';
*/
if (count($Overlays))
{
echo '<div class="bo_input_container" id="bo_map_overlay_options">';
echo '<span class="bo_form_descr">'._BL('Extra overlays').':</span> ';
$ovl_maps_showed = false;
foreach($Overlays as $id => $cfg)
{
if (!$ovl_maps_showed && $cfg['is_map'])
{
echo '<a href="#" onclick="javascript:document.getElementById(\'bo_extra_ovl_maps\').style.display=\'inline\';this.style.display=\'none\';">'._BL('Own maps').'</a>';
echo '<span style="display:none" id="bo_extra_ovl_maps">';
$ovl_maps_showed = true;
}
echo '<span class="bo_form_checkbox_text">';
echo '<input type="checkbox" onclick="bo_map_toggle_extraoverlay(this.checked, this.value);" value="'.$id.'" name="bo_map_overlay" id="bo_map_overlay'.$id.'" ';
echo $cfg['default_show'] ? ' checked="checked" ' : '';
echo '>';
echo '<label for="bo_map_overlay'.$id.'">';
if ($cfg['sel_name'])
echo _BL($cfg['sel_name'], false, BO_CONFIG_IS_UTF8);
else
echo '<em>'._BL('Id').' '.$id.'</em>';
if ($cfg['kml'])
echo ' <em>('._BL('KML').')</em>';
echo '</label> ';
echo '</span>';
}
if ($ovl_maps_showed)
echo '</span>';
echo '</div>';
}
echo '</div>';
echo '</fieldset>';
echo '<input id="bo_gmap_search" class="bo_gmap_controls" type="text" placeholder="'._BL('Search...').'">';
echo '<div id="bo_gmap" class="bo_map" style="width:500px; height:400px;"></div>';
?>
<script type="text/javascript">
var bo_OverlayMaps = new Array();
var bo_OverlayCount;
var bo_OverlayTracks;
var bo_ExtraOverlay = [];
var bo_ExtraOverlayMaps = [];
var bo_show_only_stationid = false;
var bo_select_stationid = 0;
var bo_show_count = 0;
var bo_show_tracks = 0;
var bo_mybo_markers = [];
var bo_mybo_circles = [];
var bo_station_markers = [];
var bo_station2_marker;
var bo_stations_display = 1;
var bo_mybo_stations = [ <?php echo $js_mybo_stations ?> ];
var bo_stations = [ <?php echo $js_stations ?> ];
var bo_infowindow;
var bo_autoupdate = false;
var bo_autoupdate_running = false;
var bo_manual_timerange = false;
var bo_user_last_activity = 0;
var bo_reload_mapinfo_next = false;
var bo_start_time_local = new Date();
var bo_start_time_server = <?php echo time() * 1000 ?>;
function bo_gmap_init2()
{
var i;
bo_infowindow = new google.maps.InfoWindow({content: ''});
<?php
foreach($mapcfg as $mapid => $cfg)
{
echo '
bo_OverlayMaps['.$mapid.'] = {
getTileUrl: function (coord, zoom) { return bo_get_tile(zoom, coord, '.$cfg['id'].', '.intval($cfg['upd_intv']).', '.BO_TILE_SIZE.'); },
tileSize: new google.maps.Size('.BO_TILE_SIZE.','.BO_TILE_SIZE.'),
isPng:true,
bo_show:'.($cfg['default_show'] ? 'true' : 'false').',
bo_interval:'.intval($cfg['upd_intv']).',
bo_mapid:'.$cfg['id'].'
};
';
}
foreach($Overlays as $ovlid => $cfg)
{
if (isset($cfg['img']))
{
if (strpos($cfg['img'], '?') === false)
$cfg['img'] .= '?';
echo '
bo_ExtraOverlay['.$ovlid.'] = {
bo_image: "'.$cfg['img'].'",
bo_bounds: new google.maps.LatLngBounds(
new google.maps.LatLng('.(double)$cfg['coord'][2].','.(double)$cfg['coord'][3].'),
new google.maps.LatLng('.(double)$cfg['coord'][0].','.(double)$cfg['coord'][1].')),
bo_show: '.($cfg['default_show'] ? 'true' : 'false').',
bo_opacity: '.((double)$cfg['opacity']).',
bo_tomercator: '.($cfg['to_mercator'] ? 'true' : 'false').',
bo_layer: '.((int)$cfg['layer']).'
};
';
}
else if (isset($cfg['kml']))
{
echo '
bo_ExtraOverlay['.$ovlid.'] = {
bo_kml: "'.$cfg['kml'].'",
bo_show: '.($cfg['default_show'] ? 'true' : 'false').'
};
';
}
}
?>
bo_OverlayCount = {
getTileUrl: function (coord, zoom) { return bo_get_tile_counts(zoom, coord, <?php echo BO_TILE_SIZE_COUNT ?>); },
tileSize: new google.maps.Size(<?php echo BO_TILE_SIZE_COUNT.','.BO_TILE_SIZE_COUNT ?>),
isPng:true,
bo_show:false
};
bo_OverlayTracks = {
getTileUrl: function (coord, zoom) { return bo_get_tile_tracks(zoom, coord, <?php echo BO_TILE_SIZE ?>); },
tileSize: new google.maps.Size(<?php echo BO_TILE_SIZE.','.BO_TILE_SIZE ?>),
isPng:true,
opacity:<?php echo (double)BO_TRACKS_MAP_OPACITY; ?>,
minZoom:<?php echo (int)BO_TRACKS_MAP_ZOOM_MIN; ?>,
maxZoom:<?php echo (int)BO_TRACKS_MAP_ZOOM_MAX; ?>,
bo_show:false
};
var c = bo_getcookie('bo_select_stationid');
if (c)
{
bo_select_stationid = c == -1 ? 0 : c;
if (document.getElementById('bo_map_opt_own') != null)
document.getElementById('bo_map_opt_own').checked = c == -1 ? false : true;
if (document.getElementById('bo_only_station_id') != null)
document.getElementById('bo_only_station_id').value = c > 0 ? c : 0;
//if (c > 0) bo_map_show_more();
}
<?php if (!$show_station_select) { ?>
bo_select_stationid = <?php echo bo_station_id(); ?>;
<?php } ?>
var c = bo_getcookie('bo_show_count');
if (c)
{
bo_show_count = c == -1 ? 0 : 1;
document.getElementById('bo_map_opt_count').checked = c == -1 ? false : true;
if (c > 0) bo_map_show_more();
}
<?php
if (intval(BO_TRACKS_SCANTIME))
{
?>
var c = bo_getcookie('bo_show_tracks');
if (c)
{
bo_show_tracks = c == -1 ? 0 : 1;
document.getElementById('bo_map_opt_tracks').checked = c == -1 ? false : true;
if (c > 0) bo_map_show_more();
}
<?php
}
?>
for (i=0;i<bo_OverlayMaps.length;i++)
{
var c = bo_getcookie('bo_show_ovl'+i);
if (c && bo_OverlayMaps[i] != null)
{
bo_OverlayMaps[i].bo_show = c == -1 ? false : true;
document.getElementById('bo_map_opt' + i).checked = c == -1 ? false : true;
}
}
for (i=0;i<bo_ExtraOverlay.length;i++)
{
var c = bo_getcookie('bo_show_extraovl'+i);
if (c && bo_ExtraOverlay[i] != null)
{
bo_ExtraOverlay[i].bo_show = c == -1 ? false : true;
document.getElementById('bo_map_overlay' + i).checked = c == -1 ? false : true;
if (c != -1) bo_map_show_more();
}
}
<?php if (BO_MAP_SHOW_CLOUDS === true) echo 'bo_draw_clouds(bo_map);' ?>
<?php if (BO_MAP_SHOW_COORD === true) echo 'bo_draw_coord(bo_map);' ?>
bo_draw_home(bo_map);
bo_infobox = document.createElement('DIV');
bo_infobox.index = 3;
bo_map.controls[google.maps.ControlPosition.RIGHT_TOP].push(bo_infobox);
bo_map_reload_overlays();
bo_station2_marker = new google.maps.Marker();
bo_map_toggle_stations(0);
<?php if (bo_user_get_level()) { ?>
google.maps.event.addListener(bo_map, 'rightclick', function(event) {
if (bo_map.getZoom() > 3)
{
window.open("<?php echo BO_ARCHIVE_URL.bo_add_sess_parms() ?>&bo_show=strikes&bo_lat="+event.latLng.lat()+"&bo_lon="+event.latLng.lng()+"&bo_zoom="+bo_map.getZoom(), '_blank');
}
});
bo_map.setOptions({draggableCursor:'crosshair'});
<?php } ?>
bo_map.setOptions({minZoom: <?php echo $min_zoom ?>, maxZoom: <?php echo $max_zoom ?>});
google.maps.event.addListener(bo_map, 'dragend', function() {
bo_setcookie('bo_map_lat', bo_map.getCenter().lat());
bo_setcookie('bo_map_lon', bo_map.getCenter().lng());
bo_setcookie('bo_map_zoom', bo_map.getZoom());
bo_map_user_activity();
});
google.maps.event.addListener(bo_map, 'center_changed', function() {
bo_setcookie('bo_map_lat', bo_map.getCenter().lat());
bo_setcookie('bo_map_lon', bo_map.getCenter().lng());
bo_setcookie('bo_map_zoom', bo_map.getZoom());
bo_map_user_activity();
});
google.maps.event.addListener(bo_map, 'zoom_changed', function() {
if (this.getZoom() < <?php echo $min_zoom ?>)
this.setZoom(<?php echo $min_zoom ?>);
if (this.getZoom() > <?php echo $max_zoom ?>)
this.setZoom(<?php echo $max_zoom ?>);
else
bo_setcookie('bo_map_zoom', this.getZoom());
bo_map_toggle_stations(0);
bo_map_user_activity();
bo_show_circle(this.getZoom());
});
google.maps.event.addListener(bo_map, 'maptypeid_changed', function() {
bo_map_set();
});
var map_lat = bo_getcookie('bo_map_lat');
var map_lon = bo_getcookie('bo_map_lon');
var map_zoom = bo_getcookie('bo_map_zoom');
var map_type = bo_getcookie('bo_map_type');
if (map_zoom < <?php echo $min_zoom ?> || map_zoom > <?php echo $max_zoom ?>)
{
map_zoom = <?php echo BO_DEFAULT_ZOOM ?>;
map_lat = <?php echo BO_LAT ?>;
map_lon = <?php echo BO_LON ?>;
}
if (map_lat != 0 && map_lon != 0 && <?php echo $cookie_load_defaults ? 'true' : 'false' ?>)
bo_map.setOptions({ center: new google.maps.LatLng(map_lat,map_lon) });
if (map_zoom > 0 && <?php echo $cookie_load_defaults ? 'true' : 'false' ?>)
bo_map.setOptions({ zoom: parseInt(map_zoom) });
if (map_type.match(/[a-z]+/i))
bo_map.setOptions({ mapTypeId: map_type });
bo_map_set();
if (document.getElementById("bo_check_autoupdate"))
{
if (document.getElementById("bo_check_autoupdate").checked)
bo_map_toggle_autoupdate(true);
}
window.setTimeout("bo_map_timer();", 1000 * 60);
}
function bo_map_timer()
{
var now = new Date();
var time = now.getTime() / 1000;
if (bo_autoupdate && time-bo_user_last_activity > <?php echo intval(BO_MAP_AUTOUPDATE)*60 ?>)
{
bo_map_toggle_autoupdate(false);
if (document.getElementById("bo_check_autoupdate"))
document.getElementById("bo_check_autoupdate").checked = false;
<?php if (BO_MAP_AUTOUPDATE_STALL_MSG === true) {
echo 'alert("'.strtr(_BL(map_autoupdate_stalled_msg), array('"' => '\"')).'");';
} ?>
<?php if (BO_MAP_AUTOUPDATE_STALL_RELOAD === true) { ?>
bo_map_reload_page();
<?php } ?>
}
bo_reload_mapinfo_next = true;
window.setTimeout("bo_map_timer();", 1000 * 60);
}
function bo_map_user_activity()
{
var now = new Date();
var time = now.getTime() / 1000;
<?php if (intval(BO_MAP_PAGE_RELOAD_INACTIVITY) > 0) { ?>
if (bo_user_last_activity > 0 && time-bo_user_last_activity > <?php echo intval(BO_MAP_PAGE_RELOAD_INACTIVITY)*60 ?>)
{
bo_map_reload_page();
}
<?php } ?>
bo_user_last_activity = now.getTime() / 1000;
if (bo_reload_mapinfo_next)
{
bo_reload_mapinfo_next = false;
bo_reload_mapinfo();
}
}
function bo_map_reload_page()
{
window.location.reload();
}
function bo_map_show_more()
{
document.getElementById('bo_map_more_container').style.display='block';
document.getElementById('bo_map_more').style.display='none';
bo_map_user_activity();
return false;
}
function bo_map_toggle_autoupdate(auto)
{
bo_autoupdate = auto;
bo_map_start_autoupdate();
bo_map_user_activity();
}
function bo_map_start_autoupdate()
{
if (bo_autoupdate_running)
return;
if (bo_autoupdate)
{
bo_autoupdate_running = true;
window.setTimeout("bo_map_do_autoupdate();", <?php echo 1000 * 60 * intval($min_upd_interval) ?>);
}
}
function bo_map_do_autoupdate()
{
bo_map_reload_overlays();
bo_autoupdate_running = false;
bo_map_start_autoupdate();
}
function bo_map_toggle_stations(display)
{
bo_map_user_activity();
var auto = display == 0;
if (display)
bo_stations_display = display;
else
display = bo_stations_display;
for (i in bo_mybo_markers)
bo_mybo_markers[i].setMap(null);
for (i in bo_mybo_circles)
bo_mybo_circles[i].setMap(null);
for (i in bo_station_markers)
bo_station_markers[i].setMap(null);
bo_station2_marker.setMap(null);
if (auto && bo_map.getZoom() > <?php echo (bo_user_get_level() & BO_PERM_SETTINGS) ? 20 : 9; ?>)
{
document.getElementById('bo_map_station1').disabled = true;