Skip to content

Commit 3136bcb

Browse files
committed
Another tiny fix to be compatible with PHP 8, tested also on PHP 8.1.1
1 parent 69d4f51 commit 3136bcb

File tree

5 files changed

+58
-44
lines changed

5 files changed

+58
-44
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Application demo: [roudnice.eu](http://www.roudnice.eu)
1717

1818
Read tmep-info-en.html or tmep-info-cz.html for more information.
1919

20-
* **Version 8.4 released at 2021-10-05** Small fix to be compatible with PHP 8 and some other code improvements along the way
20+
* **Version 8.4.1 released at 2022-02-02** Another tiny fix to be compatible with PHP 8, tested also on PHP 8.1.1
21+
* Version 8.4 released at 2021-10-05 Small fix to be compatible with PHP 8 and some other code improvements along the way
2122
* Version 8.3 released at 2018-11-22 (Added spanish translation - thank you [Emilio Cortés Martínez]([email protected]), fixed measured humidity detection on Yearly statistics tab, minimum version of PHP is 5.4.0+)
2223
* Version 8.2.1 released at 2017-05-09 (Minor changes - custom page heading in config, humidity detected separately from temperature, proposed by [mikrom](http://www.mikrom.cz))
2324
* Version 8.2 released at 2017-02-23 (New Highcharts library, better graphs on Actually tab)

app/scripts/grafy/kombinovane/24-hodin.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// abychom meli graf "uhlazenejsi" (vypada to lepe)
2323
$teplota = (float)$teplota + $t['teplota'];
2424
$vlhkost = (float)$vlhkost + $t['vlhkost'];
25-
$rosnyBod = (float)$rosnyBod + rosnybod($t['teplota'], $t['vlhkost']);
25+
$rosnyBod = (float)$rosnyBod + (float)rosnybod($t['teplota'], $t['vlhkost']);
2626
$count++;
2727

2828
if($predchoziTeplota != "")
@@ -44,9 +44,8 @@
4444
}
4545

4646
// uz mame dostatek mereni?
47-
if(($a == 10 OR $delejUpdate == 1) AND $zobrazuj == 1)
47+
if(($a == 10 or $delejUpdate == 1) and $zobrazuj == 1)
4848
{
49-
5049
// pridame teplotu do pole
5150
$ydata[] = round(jednotkaTeploty($teplota / $count, $u, 0), 1);
5251
$ydata2[] = round($vlhkost / $count, 1);
@@ -62,14 +61,11 @@
6261
// vynulujeme pocitadla
6362
$count = 0;
6463
$a = 0;
65-
6664
}
6765

68-
// iterujeme
6966
$a++;
7067

7168
$predchoziTeplota = $t['kdy'];
72-
7369
}
7470

7571
// abychom ziskali spravnou posloupnoust udaju, tak obe pole obratime
@@ -84,7 +80,7 @@
8480

8581
foreach($labels as $index => $label)
8682
{
87-
if((substr($label, 0, 10) != substr($latestLabel, 0, 10)) AND $latestLabel != "")
83+
if((substr($label, 0, 10) != substr($latestLabel, 0, 10)) and $latestLabel != "")
8884
{
8985
$plotLines[] = $mereni;
9086
}
@@ -98,7 +94,7 @@
9894
{
9995
$toOutput = [];
10096

101-
foreach($plotLines AS $position)
97+
foreach($plotLines as $position)
10298
{
10399
$toOutput[] = "{ color: 'lightgrey', dashStyle: 'solid', value: {$position}, width: 1 }";
104100
}

app/scripts/grafy/kombinovane/3-dny.php

+40-35
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// INIT
44
require dirname(__FILE__) . "/../../init.php";
55

6-
$od = Array();
7-
$do = Array();
6+
$od = [];
7+
$do = [];
88
// posledni dny do pole
9-
$dny2 = Array();
10-
$od = date("Y-m-d H:00:00", mktime(date("H"), date("i"), date("s"), date("m"), date("d")-3, date("Y")));
9+
$dny2 = [];
10+
$od = date("Y-m-d H:00:00", mktime(date("H"), date("i"), date("s"), date("m"), date("d") - 3, date("Y")));
1111
$do = date("Y-m-d H:m:s");
1212

1313
// Posledni zaznamy vcera
@@ -22,21 +22,20 @@
2222

2323
while($t = MySQLi_fetch_assoc($q))
2424
{
25-
2625
// budeme za tu dobu, aktualne 10 minut, pocitat prumernou teplotu,
2726
// abychom meli graf "uhlazenejsi" (vypada to lepe)
28-
$teplota = (float)$teplota+$t['teplota'];
29-
$vlhkost = (float)$vlhkost+$t['vlhkost'];
30-
$rosnyBod = (float)$rosnyBod+rosnybod($t['teplota'], $t['vlhkost']);
27+
$teplota = (float)$teplota + $t['teplota'];
28+
$vlhkost = (float)$vlhkost + $t['vlhkost'];
29+
$rosnyBod = (float)$rosnyBod + (float)rosnybod($t['teplota'], $t['vlhkost']);
3130
$count++;
3231

3332
// uz mame dostatek mereni?
3433
if($a == 12)
3534
{
3635
// pridame teplotu do pole
37-
$ydata[] = round(jednotkaTeploty($teplota/$count, $u, 0), 1);
38-
$ydata2[] = round($vlhkost/$count, 1);
39-
$ydata3[] = round($rosnyBod/$count, 1);
36+
$ydata[] = round(jednotkaTeploty($teplota / $count, $u, 0), 1);
37+
$ydata2[] = round($vlhkost / $count, 1);
38+
$ydata3[] = round($rosnyBod / $count, 1);
4039

4140
// pridame popisek do pole
4241
$labels[] = $t['kdy'];
@@ -50,9 +49,7 @@
5049
$a = 0;
5150
}
5251

53-
// iterujeme
5452
$a++;
55-
5653
}
5754

5855
// abychom ziskali spravnou posloupnoust udaju, tak obe pole obratime
@@ -67,7 +64,7 @@
6764

6865
foreach($labels as $index => $label)
6966
{
70-
if((substr($label, 0, 10) != substr($latestLabel, 0, 10)) AND $latestLabel != "")
67+
if((substr($label, 0, 10) != substr($latestLabel, 0, 10)) and $latestLabel != "")
7168
{
7269
$plotLines[] = $mereni;
7370
}
@@ -81,7 +78,7 @@
8178
{
8279
$toOutput = [];
8380

84-
foreach($plotLines AS $position)
81+
foreach($plotLines as $position)
8582
{
8683
$toOutput[] = "{ color: 'lightgrey', dashStyle: 'solid', value: {$position}, width: 1 }";
8784
}
@@ -92,58 +89,64 @@
9289
<script type="text/javascript">
9390
$(function () {
9491
var chart;
95-
$(document).ready(function() {
92+
$(document).ready(function () {
9693
chart = new Highcharts.Chart({
97-
chart: { renderTo: 'graf-3-dny', zoomType: 'x', backgroundColor: '#ffffff', borderRadius: 0 },
98-
credits: { enabled: 0 },
99-
title: { text: '<?php echo $lang['3dny']; ?>' },
94+
chart: {renderTo: 'graf-3-dny', zoomType: 'x', backgroundColor: '#ffffff', borderRadius: 0},
95+
credits: {enabled: 0},
96+
title: {text: '<?php echo $lang['3dny']; ?>'},
10097
xAxis: {
10198
categories: ['<?php echo implode("','", $labels); ?>'],
102-
labels: { rotation: -45, align: 'right', step: 12 },
99+
labels: {rotation: -45, align: 'right', step: 12},
103100
plotLines: [<?php echo $plotLinesOutput; ?>]
104101
},
105102
yAxis: [{
106103
labels: {
107-
formatter: function() { return this.value +' <?php echo "$jednotka"; ?>'; },
108-
style: { color: '#c4423f' }
104+
formatter: function () {
105+
return this.value + ' <?php echo "$jednotka"; ?>';
106+
},
107+
style: {color: '#c4423f'}
109108
},
110109
title: {
111110
text: null,
112-
style: { color: '#c4423f' }
111+
style: {color: '#c4423f'}
113112
},
114113
opposite: false
115114
}, {
116115
gridLineWidth: 0,
117116
title: {
118117
text: null,
119-
style: { color: '#4572a7' }
118+
style: {color: '#4572a7'}
120119
},
121120
labels: {
122-
formatter: function() { return this.value +' %'; },
123-
style: { color: '#4572a7' }
121+
formatter: function () {
122+
return this.value + ' %';
123+
},
124+
style: {color: '#4572a7'}
124125
},
125126
opposite: true,
126127
max: 100
127128
}, {
128129
gridLineWidth: 0,
129130
title: {
130131
text: null,
131-
style: { color: '#6ba54e' }
132+
style: {color: '#6ba54e'}
132133
},
133134
labels: {
134-
formatter: function() { return this.value +' <?php echo "$jednotka"; ?>'; },
135-
style: { color: '#6ba54e' }
135+
formatter: function () {
136+
return this.value + ' <?php echo "$jednotka"; ?>';
137+
},
138+
style: {color: '#6ba54e'}
136139
},
137140
opposite: true
138141
}],
139142
tooltip: {
140-
formatter: function() {
143+
formatter: function () {
141144
var unit = {
142145
'<?php echo $lang['teplota'] ?>': '<?php echo "$jednotka"; ?>',
143146
'<?php echo $lang['vlhkost'] ?>': '%',
144147
'<?php echo $lang['rosnybod'] ?>': '<?php echo "$jednotka"; ?>'
145148
}[this.series.name];
146-
return '<b>'+ this.x +'</b><br /><b>'+ this.y +' '+ unit + '</b>';
149+
return '<b>' + this.x + '</b><br /><b>' + this.y + ' ' + unit + '</b>';
147150
},
148151
crosshairs: true,
149152
},
@@ -162,27 +165,29 @@
162165
color: '#c4423f',
163166
yAxis: 0,
164167
data: [<?php echo implode(", ", $ydata); ?>],
165-
marker: { enabled: false }
168+
marker: {enabled: false}
166169
}, {
167170
name: '<?php echo $lang['vlhkost'] ?>',
168171
type: 'spline',
169172
color: '#4572a7',
170173
yAxis: 1,
171174
data: [<?php echo implode(", ", $ydata2); ?>],
172-
marker: { enabled: false }
175+
marker: {enabled: false}
173176

174177
}, {
175178
name: '<?php echo $lang['rosnybod'] ?>',
176179
type: 'spline',
177180
color: '#6ba54e',
178181
yAxis: 2,
179182
data: [<?php echo implode(", ", $ydata3); ?>],
180-
marker: { enabled: false },
183+
marker: {enabled: false},
181184
visible: false
182185
}]
183186
});
184187

185-
$(".tabs > li").click(function () { chart.reflow(); });
188+
$(".tabs > li").click(function () {
189+
chart.reflow();
190+
});
186191

187192
});
188193

tmep-info-cz.html

+6
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ <h2><a name="aktualizace">Aktualizace na verzi 8</a></h2>
178178

179179
<h2><a name="seznamzmen">Seznam změn</a></h2>
180180

181+
<h4>version 8.4.1 (2022-02-02)</h4>
182+
183+
<ul>
184+
<li>Další drobná oprava kvůli kompatibilitě s PHP 8, otestováno i na živé instalaci s PHP 8.1.1.</li>
185+
</ul>
186+
181187
<h4>version 8.4 (2021-10-05)</h4>
182188

183189
<ul>

tmep-info-en.html

+6
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ <h2><a name="update">Update to v8</a></h2>
168168

169169
<h2><a name="chagelog">Changelog</a></h2>
170170

171+
<h4>version 8.4.1 (2022-02-02)</h4>
172+
173+
<ul>
174+
<li>Another tiny fix to be compatible with PHP 8, tested also on PHP 8.1.1</li>
175+
</ul>
176+
171177
<h4>version 8.4 (2021-10-05)</h4>
172178

173179
<ul>

0 commit comments

Comments
 (0)