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
/
archive.inc.php
1900 lines (1500 loc) · 54.8 KB
/
archive.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
function bo_show_archive_map()
{
global $_BO;
require_once 'functions_html.inc.php';
$ani_div = intval(BO_ANIMATIONS_INTERVAL);
$ani_pic_range = intval(BO_ANIMATIONS_STRIKE_TIME);
$ani_default_range = intval(BO_ANIMATIONS_DEFAULT_RANGE);
$ani_max_range = intval(BO_ANIMATIONS_MAX_RANGE);
$ani_delay = BO_ANIMATIONS_WAITTIME;
$ani_delay_end = BO_ANIMATIONS_WAITTIME_END;
$map = isset($_GET['bo_map']) ? $_GET['bo_map'] : -1;
$year = intval($_GET['bo_year']);
$month = intval($_GET['bo_month']);
$day = intval($_GET['bo_day']);
$day_add = intval($_GET['bo_day_add']);
$ani = isset($_GET['bo_animation']) && $_GET['bo_animation'] !== '0' ? 1 : 0;
$ani_preset = $_GET['bo_animation'] && $_GET['bo_animation'] != 1 ? trim($_GET['bo_animation']) : '';
$hour_from = (int)($_GET['bo_hour_from']);
$minute_from = fmod($_GET['bo_hour_from'], 1) * 60;
$hour_range = (float)($_GET['bo_hour_range']);
$map_changed = isset($_GET['bo_oldmap']) && $map != $_GET['bo_oldmap'];
$ani_changed = isset($_GET['bo_oldani']) && $ani != $_GET['bo_oldani'];
//Map
$select_map = bo_archive_select_map($map);
//image dimensions
$img_dim = bo_archive_get_dim_html($map);
//Config
$cfg = $_BO['mapimg'][$map];
$ani_cfg = $_BO['mapimg'][$map]['animation'];
$mapname = _BL($cfg['name'], false, BO_CONFIG_IS_UTF8);
//Animation-config
if (isset($ani_cfg['force']) && $ani_cfg['force'])
{
$ani_forced = true;
$ani = true;
}
if (isset($ani_cfg['range']))
$ani_pic_range = $ani_cfg['range'];
if (isset($ani_cfg['default_range']))
$ani_default_range = $ani_cfg['default_range'];
if (isset($ani_cfg['max_range']))
$ani_max_range = $ani_cfg['max_range'];
if (isset($ani_cfg['delay']))
$ani_delay = $ani_cfg['delay'];
if (isset($ani_cfg['delay_end']))
$ani_delay_end = $ani_cfg['delay_end'];
if (isset($ani_cfg['interval']))
$ani_div = $ani_cfg['interval'];
//Defaults...
if (isset($cfg['maxrange']) && intval($cfg['maxrange'])) //max. time range in one pic
$max_range = $cfg['maxrange'];
else
$max_range = BO_SMAP_MAX_RANGE;
if (isset($cfg['hoursinterval']) && $cfg['hoursinterval'] > 0) //interval of hours
$hours_interval = $cfg['hoursinterval'];
elseif ($ani)
$hours_interval = BO_ANIMATIONS_RANGE_STEP;
else
$hours_interval = BO_SMAP_RANGE_STEP;
//Date
if (!$year || $year < 0)
$year = date('Y');
if (!$month || $month < 0)
$month = date('m');
if (!$day)
$day = date('d') - 1;
if ($_GET['bo_prev'])
$day_add = -1;
else if ($_GET['bo_next'])
$day_add = +1;
//Hours & Range
if ($ani)
{
//now is default for maps with changing backgrounds
//if (!$ani_preset && isset($cfg['file_time']))
// $ani_preset = 'now';
if ($ani_changed || $ani_preset)
{
if ($ani_preset == 'now')
{
$end = floor(time()/$hours_interval/3600) * $hours_interval*3600 - $ani_pic_range * 60;
$start = $end - $ani_default_range*3600;
if (!is_float($hours_interval))
{
$hour_range = $ani_default_range + intval((time()/3600 - floor(time()/3600))*3600) / 3600;
$minute_from = 0;
}
else
{
$minute_from = (int)date('i', $start);
$hour_range = $ani_default_range + $hours_interval;
}
$hour_from = (int)date('H', $start);
$year = (int)date('Y', $start);
$month = (int)date('m', $start);
$day = (int)date('d', $start);
}
elseif ($ani_preset == 'day')
{
$hour_from = 0;
$hour_range = 24;
}
else
{
$hour_from = 12;
$hour_range = $ani_default_range;
}
}
if ($hour_range < $ani_pic_range / 60)
$hour_range = round($ani_pic_range / 60);
if ($hour_range > $ani_max_range)
$hour_range = $ani_max_range;
$max_range = $ani_max_range;
}
elseif (!$ani)
{
if ($ani_changed)
{
$hour_from = 0;
}
if ($map_changed || $ani_changed)
{
$hour_range = $max_range < 24 || $cfg['trange'] < 24 ? min($cfg['trange'], $hour_range) : 24;
}
}
if ($_GET['bo_prev_hour'])
$hour_from -= $hours_interval;
else if ($_GET['bo_next_hour'])
$hour_from += $hours_interval;
$hour_from = floor($hour_from / $hours_interval) * $hours_interval;
//Set to correct time
$time = mktime($hour_from,$minute_from,0,$month,$day+$day_add,$year);
if ($time > time())
$time = time() - $hour_range * 3600;
$year = date('Y', $time);
$month = date('m', $time);
$day = date('d', $time);
$hour_from = date('H', $time) + $minute_from/60;
//show time period select?
$show_range_sel = $ani || (!$ani && !isset($cfg['file_time_search']) && !isset($cfg['overlays']));
//use standard time period
if (!$show_range_sel && $cfg['trange'] != 24)
$hour_range = $hours_interval;
//min/max strike-time
$row = BoDb::query("SELECT MIN(time) mintime, MAX(time) maxtime FROM ".BO_DB_PREF."strikes")->fetch_assoc();
$strikes_available = $row['mintime'] > 0 || $row['maxtime'] > 0;
$start_time = strtotime($row['mintime'].' UTC');
$end_time = strtotime($row['maxtime'].' UTC');
if (isset($_GET['bo_oldmap']) || isset($_GET['bo_oldani'])
|| isset($_GET['bo_next']) || isset($_GET['bo_prev'])
|| isset($_GET['bo_next_hour']) || isset($_GET['bo_prev_hour'])
|| isset($_GET['bo_day_add'])
|| (isset($_GET['bo_animation']) && !$ani)
|| (!$show_range_sel && isset($_GET['bo_hour_range']))
)
{
$url = '';
$url .= '&bo_year='.$year;
$url .= '&bo_month='.$month;
$url .= '&bo_day='.$day;
$url .= '&bo_hour_from='.$hour_from;
if ($show_range_sel)
$url .= '&bo_hour_range='.$hour_range;
if ($ani)
$url .= '&bo_animation=1';
bo_try_redirect(array('bo_year', 'bo_month', 'bo_day', 'bo_day_add', 'bo_oldmap', 'bo_oldani', 'bo_animation', 'bo_next', 'bo_prev', 'bo_next_hour', 'bo_prev_hour', 'bo_hour_range', 'bo_hour_from'), $url);
}
//Output
echo '<div id="bo_arch_maps">';
if ($strikes_available)
{
echo '<p class="bo_general_description" id="bo_archive_density_info">';
echo strtr(_BL('archive_map_info'), array('{DATE_START}' => _BD($start_time),'{DATE_END}' => _BD($end_time)));
echo '</p>';
echo '<a name="bo_arch_strikes_maps_form"></a>';
echo '<form action="?#bo_arch_strikes_maps_form" method="GET" class="bo_arch_strikes_form" id="bo_arch_strikes_maps_form">';
echo bo_insert_html_hidden(array('bo_map', 'bo_year', 'bo_month', 'bo_day', 'bo_animation', 'bo_day_add', 'bo_hour_from', 'bo_next', 'bo_prev', 'bo_next_hour', 'bo_prev_hour', 'bo_get', 'bo_oldmap', 'bo_oldani'));
echo '<input type="hidden" name="bo_oldmap" value="'.$map.'">';
echo '<input type="hidden" name="bo_oldani" value="'.($ani ? 1 : 0).'">';
echo '<fieldset>';
echo '<legend>'._BL('legend_arch_strikes').'</legend>';
echo $select_map;
echo '<span class="bo_form_descr">'._BL('Date').':</span> ';
echo '<select name="bo_year" id="bo_arch_strikes_select_year">';
for($i=date('Y', $start_time); $i<=date('Y');$i++)
echo '<option value="'.$i.'" '.($i == $year ? 'selected' : '').'>'.$i.'</option>';
echo '</select> ';
echo '<select name="bo_month" id="bo_arch_strikes_select_month">';
for($i=1;$i<=12;$i++)
echo '<option value="'.$i.'" '.($i == $month ? 'selected' : '').'>'._BL(date('M', strtotime("2000-$i-01"))).'</option>';
echo '</select> ';
echo '<select name="bo_day" id="bo_arch_strikes_select_day" onchange="submit()">';
for($i=1;$i<=31;$i++)
echo '<option value="'.$i.'" '.($i == $day ? 'selected' : '').'>'.$i.'</option>';
echo '</select>';
echo ' <input type="submit" name="bo_prev" value=" < " id="bo_archive_maps_prevday" class="bo_form_submit">';
echo ' <input type="submit" name="bo_next" value=" > " id="bo_archive_maps_nextday" class="bo_form_submit">';
echo '<input type="submit" value="'._BL('update map').'" id="bo_archive_maps_submit" class="bo_form_submit">';
echo '<div class="bo_input_container">';
echo '<span class="bo_form_descr">'._BL('Time range').':</span> ';
echo '<select name="bo_hour_from" id="bo_arch_strikes_select_hour_from"';
echo !$show_range_sel ? ' onchange="submit()"' : '';
echo '>';
for($i=0;$i<=23;$i+=$hours_interval)
{
echo '<option value="'.$i.'" '.(floor($i) == floor($hour_from) && fmod($i, 1)*60 == $minute_from ? 'selected' : '').'>';
if (is_float($hours_interval))
echo bo_hours($i)." "._BL('oclock');
else
echo $i.' '._BL('oclock');
echo '</option>';
}
echo '</select>';
if (!is_float($hours_interval) || $hours_interval > 1)
{
echo ' <input type="submit" name="bo_prev_hour" value=" < " id="bo_archive_maps_prevhour" class="bo_form_submit">';
echo ' <input type="submit" name="bo_next_hour" value=" > " id="bo_archive_maps_nexthour" class="bo_form_submit">';
}
if ($show_range_sel)
{
echo ' <select name="bo_hour_range" id="bo_arch_strikes_select_hour_to" '.($ani ? '' : ' onchange="submit()"').'>';
for($i=$hours_interval;$i<=$max_range;$i+=$hours_interval)
{
echo '<option value="'.$i.'" ';
if (is_float($hours_interval))
{
echo $i == intval($hour_range / $hours_interval) * $hours_interval ? 'selected' : '';
echo '>+ '.bo_hours($i)." h";
}
else
{
echo (int)$i == (int)$hour_range ? 'selected' : '';
echo '>+'.$i.' '._BL('hours');
}
echo '</option>';
}
echo '</select> ';
}
else
{
echo '<input type="hidden" name="bo_hour_range" value="'.$hours_interval.'">';
}
if ($ani_div)
{
echo ' ';
echo '<span class="bo_form_descr">'._BL('Animation').':</span> ';
echo '<input type="radio" name="bo_animation" value="0" id="bo_archive_maps_animation_off" class="bo_form_radio" '.(!$ani ? ' checked' : '').' onclick="bo_enable_timerange(false, true);" '.($ani_forced ? ' disabled' : '').'>';
echo '<label for="bo_archive_maps_animation_off">'._BL('Off').'</label>';
echo '<input type="radio" name="bo_animation" value="'.($ani_preset ? htmlentities($ani_preset) : 1).'" id="bo_archive_maps_animation_on" class="bo_form_radio" '.($ani ? ' checked' : '').' onclick="bo_enable_timerange(true, true);">';
echo '<label for="bo_archive_maps_animation_on">'._BL('On').'</label>';
}
echo '</div>';
echo '<div class="bo_input_container">';
echo '<div class="bo_arch_map_form_links">';
echo '<span class="bo_form_descr">';
echo _BL('Yesterday').': ';
echo '</span>';
if (!$ani_cfg['force'])
echo ' <a href="'.bo_insert_url('bo_*').'&bo_map='.$map.'&bo_day_add=0#bo_arch_strikes_maps_form" >'._BL('Picture').'</a> ';
if ($ani_div)
echo ' <a href="'.bo_insert_url('bo_*').'&bo_map='.$map.'&bo_day_add=0&bo_hour_from=0&bo_hour_range=24&bo_animation=day#bo_arch_strikes_maps_form" >'._BL('Animation').'</a> ';
echo ' ';
echo '<span class="bo_form_descr">';
echo _BL('Today').': ';
echo '</span>';
if (!$ani_cfg['force'])
echo ' <a href="'.bo_insert_url('bo_*').'&bo_map='.$map.'&bo_day_add=1#bo_arch_strikes_maps_form" >'._BL('Picture').'</a> ';
if ($ani_div)
echo ' <a href="'.bo_insert_url('bo_*').'&bo_map='.$map.'&bo_day_add=1&bo_hour_from=0&bo_hour_range=24&bo_animation=day#bo_arch_strikes_maps_form" >'._BL('Animation').'</a> ';
echo ' ';
echo '<span class="bo_form_descr">';
echo _BL('Now').': ';
echo '</span>';
if (!$ani_cfg['force'])
echo ' <a href="'.bo_insert_url(array('bo_page', 'bo_*')).'&bo_showmap='.$map.'" >'._BL('Picture').'</a> ';
if ($ani_div)
echo ' <a href="'.bo_insert_url('bo_*').'&bo_map='.$map.'&bo_animation=now" >'._BL('Animation').'</a> ';
echo '</div>';
echo '</div>';
echo '</fieldset>';
echo '</form>';
}
if ($cfg['date_min'] && ($min = strtotime($cfg['date_min'])))
{
$start_time = $min;
$end_time = max($start_time, $end_time);
}
echo '<div id="bo_arch_map_container_all">';
if ($cfg['archive'])
{
if ($_BO['mapimg'][$map]['header'])
echo '<div class="bo_map_header">'._BC($_BO['mapimg'][$map]['header'], true, BO_CONFIG_IS_UTF8).'</div>';
echo '<div style="display:inline-block;" id="bo_arch_maplinks_container">';
if ($ani)
{
echo '<div class="bo_arch_map_links">';
echo ' <a href="javascript:bo_animation_prev();" id="bo_animation_doprev">< '._BL('ani_prev').'</a>';
echo ' <a href="javascript:bo_animation_pause();" id="bo_animation_dopause">'._BL('ani_pause').'</a>';
echo ' <a href="javascript:bo_animation_next();" id="bo_animation_donext">'._BL('ani_next').' ></a>';
echo '</div>';
}
echo '<div style="position:relative;display:inline-block; min-width: 300px; " id="bo_arch_map_container">';
if (!$strikes_available || $time < floor($start_time/3600/24)*3600*24 || $time > $end_time + 3600 * 24)
{
if ($strikes_available)
$text = _BL('arch_select_dates_between');
else
$text = _BL('no_lightning_data');
$img_file = bo_bofile_url().'?map='.$map.'&blank&blank_background'.bo_lang_arg('map');
echo '<div style="position:relative;'.bo_archive_get_dim_css($map).'" id="bo_arch_map_nodata">';
echo '<img style="position:absolute;background-image:url(\''.bo_bofile_url().'?image=wait\');" '.$img_dim.' id="bo_arch_map_noimg" src="'.$img_file.'">';
echo '<div style="position:absolute;top:0px;left:0px" id="bo_arch_map_nodata_white"></div>';
echo '<div style="position:absolute;top:0px;left:0px" id="bo_arch_map_nodata_text">';
echo '<p>';
echo strtr($text, array('{START}' => _BD($start_time), '{END}' => _BD($end_time) ));
echo '</p>';
echo '</div>';
echo '</div>';
}
else if ($ani)
{
//use transparency?
if ($ani_cfg['transparent'] === false)
{
$img_file = null;
$bo_file_url = bo_bofile_url().'?map='.$map.bo_lang_arg('map').'&date=';
}
else
{
$img_file = bo_bofile_url().'?map='.$map.'&blank'.bo_lang_arg('map');
$bo_file_url = bo_bofile_url().'?map='.$map.'&transparent'.bo_lang_arg('map').'&date=';
}
$images = array();
for ($i=$hour_from*60; $i< ($hour_from+$hour_range) * 60; $i+= $ani_div)
{
$time = strtotime("$year-$month-$day 00:00:00 +$i minutes");
$images[] .= gmdate('YmdHi', $time).'-'.$ani_pic_range;
if ($time > $end_time - $ani_pic_range * 60)
break;
}
$alt = _BL('Lightning map').' '.$mapname.' '._BD($time).' ('._BL('Animation').')';
bo_insert_animation_js($images, $bo_file_url, $img_file, $ani_delay, $ani_delay_end, $img_dim, $alt);
}
else
{
if ($hour_range == 24 && $hour_from == 0)
{
$date_arg = sprintf('%04d%02d%02d', $year, $month, $day);
}
else
{
//image url needs UTC-time!
$uyear = gmdate('Y', $time);
$umonth = gmdate('m', $time);
$uday = gmdate('d', $time);
$uhour_from = gmdate('H', $time);
$umin_from = gmdate('i', $time);
$date_arg = sprintf('%04d%02d%02d', $uyear, $umonth, $uday);
if ($hour_range)
$date_arg .= sprintf('%02d', $uhour_from).sprintf('%02d', $umin_from).'-'.($hour_range*60);
}
$alt = _BL('Lightning map').' '.$mapname.' '._BD($time);
$img_file = bo_bofile_url().'?map='.$map.'&date='.$date_arg.bo_lang_arg('map');
echo '<img style="position:relative;background-image:url(\''.bo_bofile_url().'?image=wait\');" '.$img_dim.' id="bo_arch_map_img" src="'.$img_file.'" alt="'.htmlspecialchars($alt).'">';
}
if ($_BO['mapimg'][$map]['footer'])
echo '<div class="bo_map_footer">'._BC($_BO['mapimg'][$map]['footer'], true, BO_CONFIG_IS_UTF8).'</div>';
echo '</div>';
echo '</div>';
}
echo '</div>';
?>
<script type="text/javascript">
function bo_enable_timerange(enable, s)
{
//document.getElementById('bo_arch_strikes_select_hour_from').disabled=!enable;
//document.getElementById('bo_arch_strikes_select_hour_to').disabled=!enable;
if (s) document.getElementById('bo_arch_strikes_maps_form').submit();
}
bo_enable_timerange(<?php echo $ani ? 'true' : 'false'; ?>);
</script>
<?php
echo '</div>';
}
function bo_show_archive_search()
{
global $_BO;
require_once 'functions_dynmap.inc.php';
$radius = $_BO['radius'] * 1000;
$max_count = intval(BO_ARCHIVE_SEARCH_STRIKECOUNT);
$select_count = $max_count;
$perm = (bo_user_get_level() & BO_PERM_NOLIMIT);
echo '<div id="bo_archive">';
echo '<p class="bo_general_description" id="bo_archive_search_info">';
echo strtr(_BL('archive_search_info'), array('{COUNT}' => $perm ? '' : $max_count));
echo '</p>';
echo '<h4>'._BL('Map').'</h4>';
echo '<input id="bo_gmap_search" class="bo_gmap_controls" type="text" placeholder="'._BL('Search...').'">';
echo '<div id="bo_gmap" class="bo_map_archive"></div>';
if ($_GET['bo_lat'])
{
$lat = (double)$_GET['bo_lat'];
$lon = (double)$_GET['bo_lon'];
$map_lat = (double)$_GET['bo_map_lat'];
$map_lon = (double)$_GET['bo_map_lon'];
$zoom = (int)$_GET['bo_map_zoom'];
$delta_dist = (int)$_GET['bo_dist'];
$getit = isset($_GET['bo_get']);
if ( $perm && (int)$_GET['bo_count'])
{
$select_count = (int)$_GET['bo_count'];
$time_from = trim($_GET['bo_time_from']);
$time_to = trim($_GET['bo_time_to']);
$utime_from = 0;
$utime_to = 0;
if (preg_match('/([0-9]{2,4})(-([0-9]{2}))?(-([0-9]{2}))? *([0-9]{2})?(:([0-9]{2}))?(:([0-9]{2}))?/', $time_from, $r))
$utime_from = mktime($r[6], $r[8], $r[10], $r[3], $r[5], $r[1]);
else
$time_from = '';
if (preg_match('/([0-9]{2,4})(-([0-9]{2}))?(-([0-9]{2}))? *([0-9]{2})?(:([0-9]{2}))?(:([0-9]{2}))?/', $time_to, $r))
$utime_to = mktime($r[6], $r[8], $r[10], $r[3], $r[5], $r[1]);
else
$time_to = '';
}
//lat,lon is limited to a region
elseif (!$perm && bo_latlon2dist($lat, $lon, BO_LAT, BO_LON) > $radius && $radius)
{
//marker is too far away from home
$getit = false;
echo '<p>'._BL('search_outside_radius').'</p>';
}
//circle radius is limited
elseif (!$perm && $delta_dist > BO_ARCHIVE_SEARCH_RADIUS_MAX * 1000)
{
$delta_dist = BO_ARCHIVE_SEARCH_RADIUS_MAX * 1000;
}
}
elseif ($perm && $_GET['bo_strike_id'])
{
$getit = true;
$get_by_id = intval($_GET['bo_strike_id']);
$zoom = 4;
$lat = $lon = false;
$map_lat = BO_LAT;
$map_lon = BO_LON;
}
else
{
$map_lat = $lat = BO_LAT;
$map_lon = $lon = BO_LON;
$zoom = BO_DEFAULT_ZOOM_ARCHIVE;
$delta_dist = BO_ARCHIVE_SEARCH_RADIUS_DEFAULT * 1000;
}
if ($radius && $delta_dist > $radius)
$delta_dist = $radius;
/*** Get data from Database ***/
if ($getit)
{
$time_min = 0;
$time_max = 0;
$count = 0;
$text = '';
$more_found = false;
$sql_where = '';
if ($get_by_id)
{
$sql_where .= " AND s.id='$get_by_id' ";
}
else
{
//max and min latitude for strikes
list($str_lat_min, $str_lon_min) = bo_distbearing2latlong($delta_dist * sqrt(2), 225, $lat, $lon);
list($str_lat_max, $str_lon_max) = bo_distbearing2latlong($delta_dist * sqrt(2), 45, $lat, $lon);
$sql_where .= " AND ".bo_strikes_sqlkey($index_sql, $utime_from, $utime_to, $str_lat_min, $str_lat_max, $str_lon_min, $str_lon_max);
$sql_where .= ($radius ? "AND distance < $radius" : "");
$sql_where .= " AND ". bo_sql_latlon2dist($lat, $lon, 's.lat', 's.lon').' <= '.$delta_dist.' ';
}
$sql = "SELECT s.id id, s.distance distance, s.lat lat, s.lon lon, s.time time, s.time_ns time_ns, s.stations stations,
s.current current, s.deviation deviation, s.type type, s.part part, s.raw_id raw_id
FROM ".BO_DB_PREF."strikes s $index_sql
WHERE 1
$sql_where
ORDER BY s.time DESC
LIMIT ".intval($select_count + 1);
$res = BoDb::query($sql);
while($row = $res->fetch_assoc())
{
if ($count >= $select_count)
{
$more_found = true;
break;
}
$time = strtotime($row['time'].' UTC');
$description = '<div class=\'bo_archiv_map_infowindow\'>';
$description .= '<ul class=\'bo_archiv_map_infowindow_list\'>';
$description .= '<li><span class=\'bo_descr\'>'._BL('Time').':</span><span class=\'bo_value\'> '._BDT($time, false).'.'.$row['time_ns']._BZ($time).'</span></li>';
$description .= '<li><span class=\'bo_descr\'>'._BL('Deviation').':</span><span class=\'bo_value\'> '._BK($row['deviation'] / 1000, 1).'</span></li>';
//$description .= '<li><span class=\'bo_descr\'>'._BL('Current').':</span><span class=\'bo_value\'> '._BN($row['current'], 1).'kA ('._BL('experimental').')</span></li>';
if (bo_station_id() > 0)
$description .= '<li><span class=\'bo_descr\'>'._BL('Participated').':</span><span class=\'bo_value\'> '.($row['part'] > 0 ? _BL('yes') : _BL('no')).'</span></li>';
$description .= '<li><span class=\'bo_descr\'>'._BL('Participants').':</span><span class=\'bo_value\'> '.intval($row['stations']).'</span></li>';
if ($perm)
$description .= '<li><span class=\'bo_value\'><a href=\''.bo_insert_url(array('bo_show', 'bo_*'), 'strikes').'&bo_strike_id='.$row['id'].'\' target=\'_blank\'>'._BL('more').'<a></span></li>';
$description .= '</ul>';
if ($row['raw_id'] && BO_UP_INTVL_RAW > 0)
{
$alt = _BL('Signals');
$description .= '<a href=\''.bo_bofile_url().'?bo_graph='.$row['raw_id'].bo_lang_arg('graph').'&bo_size=3\' target=\'_blank\'>';
$description .= '<img src=\''.bo_bofile_url().'?bo_graph='.$row['raw_id'].bo_lang_arg('graph').'\' style=\'width:'.BO_GRAPH_RAW_W.'px;height:'.BO_GRAPH_RAW_H.'px\' class=\'bo_archiv_map_signal\' alt=\''.htmlspecialchars($alt).'\'>';
$description .= '</a>';
}
$description .= '</div>';
$text .= "\n".'lightnings['.$row['id'].']={'.
'center: new google.maps.LatLng('.$row['lat'].','.$row['lon'].'), '.
'participated: '.$row['part'].', '.
'utime: '.$time.', '.
'description: "'.$description.'" '.
'};';
if (!$time_max)
$time_max = $time;
$count++;
}
$time_min = $time;
$time_int = ($time_max - $time_min) / 9;
echo '<h4>'._BL('Result').'</h4>';
echo '<ul>';
if ($utime_from || $utime_to)
{
echo '<li><span class="bo_descr">'._BL('Time range').': </span> ';
if ($utime_from)
echo _BL('time_from').' '._BDT($utime_from).' ';
if ($utime_to)
echo _BL('time_to').' '._BDT($utime_to).' ';
echo '</li>';
}
if ($radius && $dist > $radius)
{
echo '<li>'._BL('You have to place the pointer inside the red circle!').'</li>';
}
elseif ($count)
{
echo '<li>';
echo '<span class="bo_descr">'._BL('Count').':</span> ';
echo '<span class="bo_value">';
echo $more_found ? _BL('More than') : _BL('Exact');
echo ' '.$count.' ';
echo $count == 1 ? _BL('Strike') : _BL('Strikes');
echo ' '._BL('found');
echo '</span>';
echo '</li>';
echo '<li><span class="bo_descr">'._BL('Oldest').':</span><span class="bo_value"> '._BDT($time_min).'</value></li>';
echo '<li><span class="bo_descr">'._BL('Newest').':</span><span class="bo_value"> '._BDT($time_max).'</value></li>';
}
else
{
echo '<li>'._BL('No strikes found!').'</li>';
}
echo '</ul>';
}
if (!$get_by_id)
{
echo '<h4>'._BL('Search Options').'</h4>';
echo '<form action="?" method="GET" class="bo_archive_form">';
echo bo_insert_html_hidden(array('bo_lat', 'bo_lon', 'bo_map_zoom', 'bo_map_lat', 'bo_map_lon'));
echo '<fieldset class="bo_archive_fieldset">';
echo '<legend>'._BL('archive_legend').'</legend>';
echo '<span class="bo_form_descr">'._BL('Coordinates').':</span>';
echo '<input type="text" name="bo_lat" value="'._BC($lat).'" id="bo_archive_lat" class="bo_form_text bo_archive_latlon">';
echo '<input type="text" name="bo_lon" value="'._BC($lon).'" id="bo_archive_lon" class="bo_form_text bo_archive_latlon">';
echo '<span class="bo_form_descr">'._BL('Distance').' '.'('._BL('unit_meters').'):</span>';
echo '<input type="text" name="bo_dist" value="'._BC($delta_dist).'" id="bo_archive_dist" class="bo_form_text bo_archive_dist">';
if (bo_user_get_level() & BO_PERM_NOLIMIT)
{
echo '<span class="bo_form_descr">'._BL('Count').':';
echo '<input type="text" name="bo_count" value="'._BC($select_count).'" id="bo_archive_count" class="bo_form_text bo_archive_count">';
echo '</span>';
echo '<span class="bo_form_descr">'._BL('Min time').':';
echo '<input type="text" name="bo_time_from" value="'._BC($time_from).'" id="bo_archive_time_from" class="bo_form_text bo_archive_time_from">';
echo '</span>';
echo '<span class="bo_form_descr">'._BL('Max time').':';
echo '<input type="text" name="bo_time_to" value="'._BC($time_to).'" id="bo_archive_time_to" class="bo_form_text bo_archive_time_to">';
echo '</span>';
}
echo '<input type="hidden" name="bo_map_zoom" id="bo_map_zoom">';
echo '<input type="hidden" name="bo_map_lat" id="bo_map_lat">';
echo '<input type="hidden" name="bo_map_lon" id="bo_map_lon">';
echo '<input type="hidden" name="bo_get">';
echo '<input type="submit" value="'._BL('button_search').'" id="bo_archive_submit" class="bo_form_submit">';
echo '</fieldset>';
if (bo_user_get_level() & BO_PERM_NOLIMIT)
{
echo '<p class="bo_enter_time_hint">'._BL('enter_time_hint').'</p>';
}
echo '</form>';
}
echo '</div>';
?>
<script type="text/javascript">
var centerMarker;
function bo_gmap_init2()
{
var markerOptions;
var infowindow;
var bounds = new google.maps.LatLngBounds();
bo_map.setOptions({scrollwheel: true});
<?php if ($lat !== false && $lon !== false) { ?>
var myLatlng = new google.maps.LatLng(<?php echo "$lat,$lon" ?>);
centerMarker = new google.maps.Marker({
position: myLatlng,
draggable: true,
map: bo_map,
icon: '//maps.google.com/mapfiles/ms/micons/blue-dot.png'
});
google.maps.event.addListener(centerMarker, 'dragend', function() {
document.getElementById('bo_archive_lat').value=this.getPosition().lat();
document.getElementById('bo_archive_lon').value=this.getPosition().lng();
});
google.maps.event.addListener(bo_map, 'click', function(event) {
centerMarker.setPosition(event.latLng);
document.getElementById('bo_archive_lat').value=event.latLng.lat();
document.getElementById('bo_archive_lon').value=event.latLng.lng();
});
google.maps.event.addListener(bo_map, 'dragend', function() {bo_gmap_map2form();});
google.maps.event.addListener(bo_map, 'zoom_changed', function() {bo_gmap_map2form();});
<?php } ?>
<?php if ($getit && $lat !== false && $lon !== false) { ?>
var boDistCircle = {
clickable: false,
strokeColor: "#5555ff",
strokeOpacity: 0.5,
strokeWeight: 1,
fillColor: "#5555ff",
fillOpacity: 0.1,
map: bo_map,
center: new google.maps.LatLng(<?php echo "$lat,$lon" ?>),
radius: <?php echo $delta_dist ?>
};
new google.maps.Circle(boDistCircle);
<?php } ?>
var lightnings = [ ];
<?php echo $text ?>
var images = new Array();
var img_count = 10;
var d;
var time_min=<?php echo intval($time_min) ?>;
var time_int=<?php echo intval($time_int) ?>;
for (var j=0;j<2;j++)
{
for (var i=0;i<img_count;i++)
{
d = i * 25;
d = d.toString(16);
d = d.length == 1 ? '0'+d : d;
images[i+j*img_count] = new google.maps.MarkerImage("<?php echo bo_bofile_url() ?>?bo_icon=ff"+d+"00"+(j ? '1' : ''),
new google.maps.Size(11,11),
new google.maps.Point(0,0),
new google.maps.Point(5, 5));
}
}
var color;
var lmarker = Array();
var infowindow = new google.maps.InfoWindow({
content: '...'
});
var lcount=0;
for (var lightning in lightnings)
{
if (time_int)
color = Math.floor((lightnings[lightning].utime-time_min)/time_int);
else
color = 0;
if (lightnings[lightning].participated > 0)
color = color + img_count;
markerOptions = {
map: bo_map,
position: lightnings[lightning].center,
flat: true,
icon: images[color],
content: lightnings[lightning].description
};
var marker = new google.maps.Marker(markerOptions);
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(this.content);
infowindow.open(bo_map, this);
});
bounds.extend(lightnings[lightning].center);
lcount++;
}
if (lcount == 1 || (lcount > 0 && lcount <= <?php echo intval($select_count); ?>))
{
bounds.extend(new google.maps.LatLng(<?php echo "$map_lat,$map_lon" ?>));
bo_map.fitBounds(bounds);
}
<?php if ($lat !== false && $lon !== false) { ?>
bo_gmap_map2form();
<?php } ?>
}
function bo_gmap_map2form()
{
document.getElementById('bo_map_lat').value=bo_map.getCenter().lat();
document.getElementById('bo_map_lon').value=bo_map.getCenter().lng();
document.getElementById('bo_map_zoom').value=bo_map.getZoom();
}
</script>
<?php
bo_insert_map(2, $map_lat, $map_lon, $zoom);
}
//Last raw data and strikes table
function bo_show_archive_table($show_strike_list = false, $lat = null, $lon = null, $fuzzy = null)
{
require_once 'functions_html.inc.php';
$perm = bo_user_get_level() & BO_PERM_ARCHIVE;
$per_page = BO_ARCHIVE_TABLE_PER_PAGE;
$max_pages = $perm ? 1E9 : 10;
$page = intval($_GET['bo_action']);
$lat = $_GET['bo_lat'];
$lon = $_GET['bo_lon'];
$zoom = intval($_GET['bo_zoom']);
$only_strikes = $_GET['bo_only_strikes'] == 1;
$only_participated = $_GET['bo_only_participated'] == 1;
$strike_id = intval($_GET['bo_strike_id']);
$strikes_before = intval($_GET['bo_strikes_before']);
$date = $_GET['bo_datetime_start'];
$region = $_GET['bo_region'];
$map = isset($_GET['bo_map']) ? $_GET['bo_map'] : 0;
$show_details = $_GET['bo_show_details'];
$show_other_graphs = isset($_GET['bo_other_graphs']) && $perm;
$own_station = bo_station_id() > 0 && bo_station_id() == $station_id;
if ($perm)
{
$station_id = bo_get_current_stationid();
}
else
$station_id = bo_station_id();
$channels = BoData::get('raw_channels');
$raw_bpv = BoData::get('raw_bitspervalue');
$raw_values = BoData::get('raw_values');
$station_info = bo_station_info($station_id);
if ($page < 0)
$page = 0;
else if ($page > $max_pages)
$page = $max_pages;
$sql_where = '';
$datetime_start = 0;
$hours_back = 0;
if (!$perm)
{
$show_strike_list = false;
$strike_id = 0;
$strike_id_to = 0;
}
else if ($date)
{
$datetime_start = strtotime($date);
}
echo '<form action="?#bo_arch_table_form" method="GET" class="bo_arch_table_form" id="bo_arch_tableform">';
if ($lat !== null && $lon !== null)
{
if (!$fuzzy)
{
if ($zoom)
$fuzzy = 1/pow(2,$zoom)*5;
else
$fuzzy = 0.005;
}
$latS = $lat - $fuzzy;
$latN = $lat + $fuzzy;
$lonW = $lon - $fuzzy;
$lonE = $lon + $fuzzy;
$sql_where .= "AND ".bo_latlon2sql($latS, $latN, $lonW, $lonE); //" AND NOT (s.lat < '$latS' OR s.lat > '$latN' OR s.lon < '$lonW' OR s.lon > '$lonE') ";
$show_strike_list = true;
$hours_back = 24 * 7;
}
else if ($strike_id && $strikes_before)
{
//Special effects ;-)
$hyps = intval($_GET['bo_hyps']);
if (BO_ARCHIVE_STRIKE_INFO_ANIM <= 0)
exit('Disabled');
$images = array();