-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·138 lines (122 loc) · 8.96 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<?php
function get_color_by_kp($kp_index) {
return ($kp_index == 4 ? 'orange' : ($kp_index > 4 ? 'red' : '#0ad503'));
}
function get_moon_svg_by_size($m_size, $id_tag) {
$a = ($m_size == 100 ? 100 : (abs($m_size) == 50 ? 50 : 0));
$b = (($m_size == 100) || ($m_size == 50) ? 0 : abs($m_size));
$c = ($m_size < 0 ? abs($m_size)/3.9 : (($m_size == 100) || ($m_size == -50) ? 0 : ($m_size == 50 ? 100 : 100 - ($m_size/3.9))));
$d = (($m_size < 0) || ($m_size == 100) ? 100 : 0);
return '
<svg class="svg_moon">
<title>'.abs($m_size).'%</title>
<linearGradient id="grad'.$id_tag.'" x1="'.$c.'%" x2="'.$d.'%">
<stop offset="'.$a.'%" style="stop-color:rgba(204, 204, 204, 1);stop-opacity:1" />
<stop offset="'.$b.'%" style="stop-color:rgba(204, 204, 204, 0);stop-opacity:0" />
</linearGradient>
<circle cx="50%" cy="50%" r="45%" stroke="#ccc" stroke-width="0.18rem" fill="none" />
<circle cx="50%" cy="50%" r="45%" fill="url(#grad'.$id_tag.')" />
</svg>';
}
$lat_by_kp = [ 'Barrow (US), Reykjavik (IS), Inari (FI)',
'Fairbanks (US), Rovaniemi (FI)',
'Anchorage (US), Tórshavn (FO), Oulu (FI)',
'Calgary (CA), Ålesund (NO), Jyväskylä (FI)',
'Vancouver (CA), Stockholm (SV), Hobart (AU)',
'Toronto (CA), Edinburgh (GB), Devonport (AU)',
'New York (US), Hamburg (DE), Christchurch (NZ)',
'Nashville (US), Brussels (BE), Melbourne (AU)',
'San Francisco (US), Paris (FR), Sydney (AU)',
'Monterrey (MX), Oviedo (ES), Ushuaia (AR)' ];
$af = json_decode(file_get_contents("./pub/aurora_forecast.json"), true);
?>
<head>
<meta charset = "UTF-8" >
<meta name="description" content="astrek aurora forecast, a fast, light, and responsive northern lights forecast web app" >
<meta name="Keywords" content="aurora, aurora forecast, lapland, northern lights, revontulet, guide, finland" >
<meta name="Author" content="[email protected]" >
<meta property="og:title" content="Aurora Forecast: Now Kp <?php echo $af['next_hours'][0][1]; ?>!" >
<meta property="og:description" content="On a clear night maybe visible from places like: <?php echo $lat_by_kp[$af['next_hours'][0][1]]; ?>" >
<meta property="og:image" content="https://astrek.net/pub/aurora_forecast_europe.webp" >
<meta property="og:url" content="https://astrek.net" >
<meta property="og:site_name" content="astrek" >
<link rel="icon" href="favicon.ico" >
<link rel="stylesheet" href="./astrek.css">
<title id="title">aurora forecast | astrek</title>
</head>
<body>
<header>
<h1>astrek</h1>
<h2 id="h2">aurora forecast</h2>
<img id="forecast_img" src="./pub/aurora_forecast_europe.webp" alt="aurora forecast for the next hour">
<div id="marquee">
<ul>
<li>
<span id="now">now!</span><br>
K<sub>p</sub> <span style="color: <?php echo get_color_by_kp($af['next_hours'][0][1]); ?>"> <?php echo $af['next_hours'][0][1]; ?></span>
<?php echo get_moon_svg_by_size($af['next_hours'][0][2], "hours"); ?>
</li>
<?php
for ($i = 1; $i < 17; $i++) {
echo '
<li>
<span id="'.$af['next_hours'][$i][0].'h">'.gmdate("D, g:i", $af['next_hours'][$i][0]).' UTC</span><br>
K<sub>p</sub> <span style="color:'.get_color_by_kp($af['next_hours'][$i][1]).'">'.$af['next_hours'][$i][1].'</span>
'.get_moon_svg_by_size($af['next_hours'][$i][2],"h".$af['next_hours'][$i][0]).'
</li>';
}
?>
</ul>
</div>
</header>
<section id="next_days">
<h3 id="h3_0">next days</h3>
<table id="calendar">
<tr>
<th id="next_days_th0">date</th>
<th id="next_days_th1">kp index</th>
<th id="next_days_th2" class="right_align">moon</th>
</tr>
<?php
for ($i = 0; $i < 15; $i++){
echo '
<tr>
<td id="'.$af['next_days'][$i][0].'d">'.gmdate("M, d", $af['next_days'][$i][0]).'</td>
<td>K<sub>p</sub> <span style="color:'.get_color_by_kp($af['next_days'][$i][1]).'">'.$af['next_days'][$i][1].'</span></td>
<td class="right_align">'.get_moon_svg_by_size($af['next_days'][$i][2],"d".$af['next_days'][$i][0]).'</td>
</tr>';
}
?>
</table>
</section>
<section id="keys">
<h3 id="h3_1">keys</h3>
<ul id="def">
<li id="key_0">The <a href='https://en.wikipedia.org/wiki/Solar_wind'>solar wind</a> excites the atoms on the <a href='https://en.wikipedia.org/wiki/Ionosphere'>ionosphere</a> releasing diferent ligth colors depending on the <a href='https://en.wikipedia.org/wiki/Emission_spectrum'>emission spectrum</a>. Oxygen releases <span style='color:#0ad503'>green</span> and <span style='color:red'>red</span>. Nitrogen glows <a href='https://en.wikipedia.org/wiki/Nitrogen'>blue</a> and <span style='color:purple'>purple</span>. Hydrogen also releases <a href='https://en.wikipedia.org/wiki/Hydrogen'>blue</a>.</li>
<li id="key_1">The <dfn><a href='https://en.wikipedia.org/wiki/K-index'>K<sub>p</sub> index</a></dfn> is an excellent indicator of disturbances in the <a href='https://en.wikipedia.org/wiki/Earth%27s_magnetic_field'>Earth's magnetic field</a>. The K<sub>p</sub> index data of this site is provided by <a href='https://www.noaa.gov'>NOAA</a>.</li>
<li id="key_2">An <dfn><a href='https://en.wikipedia.org/wiki/Aurora'>aurora</a></dfn> is the glowing evidence of the particles from a <a href='https://en.wikipedia.org/wiki/Geomagnetic_storm'>geomagnetic storm</a> colliding with the <a href='https://en.wikipedia.org/wiki/Atmosphere_of_Earth'>atmosphere</a>. During a clear night could be possible to witness those phenomena from latitudes like:</li>
</ul>
<table id="lat">
<?php
for ($i=0;$i<10;$i++) {
echo ' <tr><td>K<sub>p</sub> <span style="color:'.get_color_by_kp($i).'">'.$i.'</span>: </td><td>'.$lat_by_kp[$i].'</td></tr>';
}
?>
</table>
</section>
<footer>
<a href="mailto:[email protected]">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M48 64C21.5 64 0 85.5 0 112c0 15.1 7.1 29.3 19.2 38.4L236.8 313.6c11.4 8.5 27 8.5 38.4 0L492.8 150.4c12.1-9.1 19.2-23.3 19.2-38.4c0-26.5-21.5-48-48-48H48zM0 176V384c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V176L294.4 339.2c-22.8 17.1-54 17.1-76.8 0L0 176z"/></svg>
</a>
<a href="https://github.com/astreknet/aurora_forecast">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg>
</a>
<a href="https://www.websitecarbon.com/website/astrek-net/">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M57.7 193l9.4 16.4c8.3 14.5 21.9 25.2 38 29.8L163 255.7c17.2 4.9 29 20.6 29 38.5v39.9c0 11 6.2 21 16 25.9s16 14.9 16 25.9v39c0 15.6 14.9 26.9 29.9 22.6c16.1-4.6 28.6-17.5 32.7-33.8l2.8-11.2c4.2-16.9 15.2-31.4 30.3-40l8.1-4.6c15-8.5 24.2-24.5 24.2-41.7v-8.3c0-12.7-5.1-24.9-14.1-33.9l-3.9-3.9c-9-9-21.2-14.1-33.9-14.1H257c-11.1 0-22.1-2.9-31.8-8.4l-34.5-19.7c-4.3-2.5-7.6-6.5-9.2-11.2c-3.2-9.6 1.1-20 10.2-24.5l5.9-3c6.6-3.3 14.3-3.9 21.3-1.5l23.2 7.7c8.2 2.7 17.2-.4 21.9-7.5c4.7-7 4.2-16.3-1.2-22.8l-13.6-16.3c-10-12-9.9-29.5 .3-41.3l15.7-18.3c8.8-10.3 10.2-25 3.5-36.7l-2.4-4.2c-3.5-.2-6.9-.3-10.4-.3C163.1 48 84.4 108.9 57.7 193zM464 256c0-36.8-9.6-71.4-26.4-101.5L412 164.8c-15.7 6.3-23.8 23.8-18.5 39.8l16.9 50.7c3.5 10.4 12 18.3 22.6 20.9l29.1 7.3c1.2-9 1.8-18.2 1.8-27.5zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256z"/></svg>
</a>
</footer>
<script type="module" src="./astrek.js"></script>
</body>
</html>