/
noaa.php
217 lines (205 loc) · 8.84 KB
/
noaa.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
<?php
require_once __DIR__ . '/include/access_rights.php';
require_once __DIR__ . '/config/config.php';
require_once __DIR__ . '/sql/connect_pdo.php';
require_once __DIR__ . '/sql/import.php';
require_once __DIR__ . '/include/functions.php';
?>
<!DOCTYPE html>
<html lang="fr-FR" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">
<head>
<title><?php echo $short_station_name; ?> | Récap. NOAA</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Balises META SEO pour le referencement Google, Facebook Twitter etc. -->
<meta name="description" content="<?php echo $hashtag_meteo; ?> Récap. NOAA de la station <?php echo $station_name; ?>"/>
<link rel="canonical" href="<?php if ($SSL){echo'https://';}else echo'http://'; echo $_SERVER['HTTP_HOST'].parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);?>" />
<meta property="og:locale" content="fr_FR" />
<meta property="og:type" content="website" />
<meta property="og:title" content="<?php echo $short_station_name; ?> | Récap. NOAA" />
<meta property="og:description" content="<?php echo $hashtag_meteo; ?> Récap. NOAA de la station <?php echo $station_name; ?>" />
<meta property="og:url" content="<?php if ($SSL){echo'https://';}else echo'http://'; echo $_SERVER['HTTP_HOST'].parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);?>" />
<meta property="og:site_name" content="<?php echo $short_station_name; ?>" />
<meta property="fb:app_id" content="<?php echo $fb_app_id; ?>" />
<meta property="og:image" content="<?php echo $url_site; ?>/img/capture_site.jpeg" />
<meta property="og:image:type" content="image/jpeg" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:description" content="<?php echo $hashtag_meteo; ?> Récap. NOAA de la station <?php echo $station_name; ?>" />
<meta name="twitter:title" content="<?php echo $short_station_name; ?> | Récap. NOAA" />
<meta name="twitter:site" content="<?php echo $tw_account_name; ?>" />
<meta name="twitter:image" content="<?php echo $url_site; ?>/img/capture_site.jpg" />
<meta name="twitter:creator" content="<?php echo $tw_account_name; ?>" />
<!-- Fin des balises META SEO -->
<?php include __DIR__ . '/config/favicon.php';?>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- JQUERY JS -->
<script src="content/jquery/jquery-slim-3.4.1.min.js"></script>
<!-- Bootstrap 4.4.1 -->
<link href="content/bootstrap/css/bootswatch-united-4.4.1.min.css" rel="stylesheet">
<link href="content/custom/custom.css?v=1.2" rel="stylesheet">
<script defer src="content/bootstrap/js/popper-1.16.0.min.js"></script>
<script defer src="content/bootstrap/js/bootstrap-4.4.1.min.js"></script>
<!-- Font Awesome CSS -->
<link href="content/fontawesome-5.13.0/css/all.min.css" rel="stylesheet">
<script type="text/javascript">
function openNoaaFileMonth(file_month){
var yearNoaaForm = file_month.substring(0,4);
var monthNoaaForm = file_month.substring(5,7);
var url = "noaa.php?yr="+yearNoaaForm+"&mo="+monthNoaaForm+"#anchorReport";
window.location.href = url;
}
function openNoaaFileYear(file_year){
var url = "noaa.php?yr=";
url = url + file_year + "#anchorReport";
window.location.href = url;
}
// Get the URL variables. Source: https://stackoverflow.com/a/26744533/1177153
function getURLvar(k) {
var p={};
location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(s,k,v){p[k]=v});
return k?p[k]:p;
}
</script>
</head>
<body>
<div class="container">
<header>
<?php include __DIR__ . '/header.php';?>
</header>
<br>
<nav>
<?php include __DIR__ . '/nav.php';?>
</nav>
<br>
<!-- DEBUT DU CORPS DE PAGE -->
<!-- Bannière infos -->
<?php if ($banniere_info_active) : ?>
<div class="alert alert-<?php echo $banniere_info_type; ?>">
<h4 class="alert-heading"><?php echo $banniere_info_titre; ?></h4>
<hr>
<p class="mb-0"><?php echo $banniere_info_message; ?></p>
</div>
<?php endif; ?>
<div class="row">
<div class="col-md-12">
<h3 class="text-center">Rapports climatologiques de la station au format NOAA</h3>
<!-- START module en ligne/Hors ligne -->
<h3 <?php if ($diff>$offline_time){echo'class="textOfflineStation text-center"';}echo'class="textOnlineStation text-center"';?>>
Derniers relevés de la station le <?php echo $date; ?> à <?php echo $heure; ?>
</h3>
<?php if ($diff>$offline_time) : ?>
<h4 class="textOfflineStation text-center">
Station actuellement hors ligne depuis
<?php echo $jours; ?> jour(s) <?php echo $heures; ?> h et <?php echo $minutes; ?> min
</h4>
<?php endif; ?>
<!-- FIN module en ligne/Hors ligne -->
</div>
</div>
<script>
jQuery(document).ready(function() {
var monthUrl = getURLvar("mo");
var yearUrl = getURLvar("yr");
function month2digits(month){
return (month < 10 ? '0' : '') + month;
}
var date = new Date(); // date object
var yearNow = date.getUTCFullYear();
var month2digits = month2digits(date.getMonth()+1); // get month in two digits
if ( ( yearUrl !== undefined ) && ( monthUrl !== undefined ) ) {
url = 'NOAA/raw/month/NOAA-'+yearUrl+'-'+monthUrl+'.txt';
} else if ( yearUrl !== undefined ) {
url = 'NOAA/raw/year/NOAA-'+yearUrl+'.txt';
} else {
url = 'NOAA/raw/month/NOAA-'+yearNow+'-'+month2digits+'.txt';
}
// Load the file into the pre
populatePre( url );
// Change the direct href link
jQuery(".noaa_direct_link").attr( "href", url );
});
// Change the div to the right NOAA file
// I normally use PHP for this, but JavaScript seems to work well for the skin
// Source: https://stackoverflow.com/a/18933218/1177153
function populatePre(url) {
var xhr = new XMLHttpRequest();
xhr.onload = function () {
raw_content = this.responseText;
updated_content = raw_content.replace('<sup>','').replace('</sup>','').replace('°','');
document.getElementById('noaa_contents').textContent = updated_content;
};
xhr.open('GET', url);
xhr.send();
}
</script>
<div class="row">
<div class="col-md-12">
<p class="text-justify">
Vous pouvez via les listes déroulantes ci-dessous, accéder aux rapports climatologiques mensuels et annuels bruts de la station au format "NOAA". Ce sont des fichiers texte très simple qui sont mis à jours tous les quarts d'heures pour le rapport mensuel en cours
</p>
</div>
</div>
<div class="row">
<div class="col-md-4 mx-auto text-center">
<h5 class="text-center">Rapports mensuels :</h5>
<select class="form-control" name="Month" onchange="openNoaaFileMonth(value)">
<?php
$path = "NOAA/raw/month";
$blacklist = array('.','..');
// get everything except hidden files
$files = preg_grep('/^([^.])/', scandir($path));
// boucle
foreach ($files as $file) {
if (!in_array($file, $blacklist)) {
$properName = substr("$file", 5, 7);
echo '<option value="',$properName,'">',$properName,'</option>';
}
}
?>
<option selected value="#">- Selectionnez le mois -</option>'
</select>
<hr>
<h5 class="text-center">Rapports annuels :</h5>
<select class="form-control" name="Year" onchange="openNoaaFileYear(value)">
<?php
$path = "NOAA/raw/year";
$blacklist = array('.','..');
// get everything except hidden files
$files = preg_grep('/^([^.])/', scandir($path));
// boucle
foreach ($files as $file) {
if (!in_array($file, $blacklist)) {
$properName = substr("$file", 5, 4);
echo '<option value="',$properName,'">',$properName,'</option>';
}
}
?>
<option selected value="#">- Selectionnez l'année -</option>'
</select>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-12" id="anchorReport">
<h5 class="text-center">Affichage du rapport :</h5>
<p class="text-center">Ouvrir ce rapport dans une nouvelle fenêtre <a href="#" class="noaa_direct_link" target="_blank">en cliquant ici</a></p>
<div class="bg-light p-3">
<pre id="noaa_contents"></pre>
</div>
</div>
</div>
<hr>
<footer class="footer bg-light rounded">
<?php include __DIR__ . '/footer.php';?>
</footer>
</div>
</body>
</html>