Author Topic: Detailed Reports problem php 8.0 and 8.1  (Read 3883 times)

0 Members and 1 Guest are viewing this topic.

Offline meteosa

  • Member
  • *
  • Posts: 18
Detailed Reports problem php 8.0 and 8.1
« on: January 08, 2023, 05:12:29 AM »
I set the php version of my site from php 7.4 to php 8.1 but i can't see rainy years anymore in "Rainfall Summary", it stops at year 2019 instead of going up to 2010 rain only, all others work (wind, temperature etc)
can anyone help me?
https://www.meteosantangelo.it/meteo/wxrainsummary.php
I noticed that other pages are also missing data, for example:
https://www.meteosantangelo.it/meteo/wxwindrunseason.php
Thank you

Offline broadstairs

  • Forecaster
  • *****
  • Posts: 853
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #1 on: January 08, 2023, 05:39:51 AM »
Have you checked to see if there are any errors recorded on your server?

Stuart
Ecowitt GW1003 with ultrasonic wind gauge, lightning sensor and PM2.5 sensor with Personal Weather Tablet as a console.

Offline meteosa

  • Member
  • *
  • Posts: 18
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #2 on: January 08, 2023, 05:48:45 AM »
Have you checked to see if there are any errors recorded on your server?

Stuart
Yes, there are many errors, it fills my file with many mb.
example:
PHP Fatal error:  Uncaught TypeError: abs(): Argument #1 ($num) must be of type int|float, string given in .../wxrainsummary.php:526
Stack trace:
#0 .../wxrainsummary.php(526): abs()
#1 .../wxrainsummary.php(370): trends_gen_difference()
#2 .../wxrainsummary.php(177): get_rain_detail()
#3 {main}
  thrown in .../wxrainsummary.php on line 526

Offline broadstairs

  • Forecaster
  • *****
  • Posts: 853
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #3 on: January 08, 2023, 05:53:17 AM »
Well that explains it. The something in V8 has changed and this line no longer works because the value is not of the correct type. I suspect there may be a later version of the script available to fix this. I do not use these scripts so am not aware of where they come from.

Stuart
Ecowitt GW1003 with ultrasonic wind gauge, lightning sensor and PM2.5 sensor with Personal Weather Tablet as a console.

Offline meteosa

  • Member
  • *
  • Posts: 18
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #4 on: January 08, 2023, 09:20:03 AM »
Well that explains it. The something in V8 has changed and this line no longer works because the value is not of the correct type. I suspect there may be a later version of the script available to fix this. I do not use these scripts so am not aware of where they come from.

Stuart
Yes exactly, I don't know where to start as I don't know much about php, the dcript package can be downloaded from: https://weather.wildwoodnaturist.com/downloads.php and it's the "Detail/Summary/Season Files ...." if anyone can make it work for php 8 that would be great.
Thank you

Offline broadstairs

  • Forecaster
  • *****
  • Posts: 853
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #5 on: January 08, 2023, 09:27:42 AM »
I suggest you contact the site to ask if they have a fix for PHP 8 as that site shows they were written for PHP 5!

Stuart
Ecowitt GW1003 with ultrasonic wind gauge, lightning sensor and PM2.5 sensor with Personal Weather Tablet as a console.

Offline meteosa

  • Member
  • *
  • Posts: 18
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #6 on: January 08, 2023, 09:36:41 AM »
I suggest you contact the site to ask if they have a fix for PHP 8 as that site shows they were written for PHP 5!

Stuart
I already tried but got no response, unfortunately.  :-(

Offline broadstairs

  • Forecaster
  • *****
  • Posts: 853
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #7 on: January 08, 2023, 09:40:47 AM »
Lets hope someone who uses them comes along to help....

Stuart
Ecowitt GW1003 with ultrasonic wind gauge, lightning sensor and PM2.5 sensor with Personal Weather Tablet as a console.

Offline hcorrin

  • Contributor
  • ***
  • Posts: 126
    • Ballaugh Weather
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #8 on: January 08, 2023, 03:08:12 PM »

Offline meteosa

  • Member
  • *
  • Posts: 18
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #9 on: January 09, 2023, 03:10:28 PM »
ok, this i can solve like this but in some file, example: https://www.meteosantangelo.it/meteo/wxrainsummary.php
data is missing, several "years" are missing how can I fix this?
I think there is some string in php 8 that doesn't work, if I put php 7.4 you see the complete data in all pages

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #10 on: January 09, 2023, 05:46:58 PM »
I've tried to fix just one of the wildwood scripts for PHP 8 .. to get rid of all the PHP warning errors there were multiple changes to be made as PHP 5 was much more forgiving about variables usage than the much more strict PHP 8.

Examples: 
  $varname[$idx]  when $idx is not in the array was treated as a null in PHP 5 with no error, casts a Warning in PHP 8
  ${varname} syntax is deprecated in PHP 8.2 .. must use {$varname} (except in preg_* function replacement strings, where ${varname} is required)

Here's the changes I had to make for just the wxtempdetails.php to get it to run without error messages:

Code: [Select]
--- C:\Users\Ken\Documents\saratoga-weather-Website-1and1\wxtemplates\wildwood\WD-wxreports\wxtempdetail.php 2016-06-15 22:56:06.000000000 -0800
+++ C:\xampp\htdocs\USA-wildwood\wxtempdetail.php 2023-01-09 14:34:33.696000000 -0800
@@ -47,6 +47,7 @@
 # 2011-12-27 3.6 Added support for Multilingual and Cumulus, Weatherlink, VWS
 # 2012-08-26 3.8 Added check for manually provided NOAA data in csv file format
 # 2013-08-22 4.0 Updated to allow use without Saratoga templates
+# 2023-01-09 4.1 Updated for PHP 8+ (K. True - Saratoga-weather.org)
 ############################################################################
 $Saratoga_template = !file_exists('nonsaratogatemplate.txt');
 if ($Saratoga_template == true){
@@ -460,26 +461,34 @@
  echo '<td class="noday" colspan="'.$colspan.'">&nbsp;</td>';
  } else {
                 
-        // Get mean temperature data
-                $mean =  $raw[$mnt][0][$day][$rawlb['mean']] ;
+        // Get mean temperature data
+ if(!isset($raw[$mnt][0][$day][$rawlb['mean']])) {
+ $mean = null;
+ } else {
+          $mean =  $raw[$mnt][0][$day][$rawlb['mean']] ;
+ }
                 if (is_null($mean)){
                     // if max and min values are available, calculate the mean
-                    if ((!is_null($raw[$mnt][0][$day][$rawlb['high']])) AND (!is_null($raw[$mnt][0][$day][$rawlb['low']]))){
+                    if ((isset($raw[$mnt][0][$day][$rawlb['high']])) AND (isset($raw[$mnt][0][$day][$rawlb['low']]))){
                         $raw[$mnt][0][$day][$rawlb['mean']] = round((($raw[$mnt][0][$day][$rawlb['high']] + $raw[$mnt][0][$day][$rawlb['low']])/2),1);
                         $mean =  $raw[$mnt][0][$day][$rawlb['mean']] ;
                     }
-                }     
+                }
+ if(!isset($tempmonth[$mnt][4])) {$tempmonth[$mnt][4] = 0.0;}
+ if(!isset($tempmonth[$mnt][5])) {$tempmonth[$mnt][5] = 0;  }     
                 if (is_numeric($mean)) {       
                 $tempmonth[$mnt][4] = $tempmonth[$mnt][4] + $mean;
                 $tempmonth[$mnt][5] = $tempmonth[$mnt][5] + 1;
                  }               
                                             
 
- if ( $raw[$mnt][0][$day][$rawlb['high']] == "" ) {
+ if ( !isset($raw[$mnt][0][$day][$rawlb['high']]) ) {
  $put = "---";
  } else {
  $put = $raw[$mnt][0][$day][$rawlb['high']];
-                    $put = roundoff($put, $round);
+          $put = roundoff($put, $round);
+ if(!isset($tempmonth[$mnt][0])) {$tempmonth[$mnt][0] = 0.0;}
+ if(!isset($tempmonth[$mnt][1])) {$tempmonth[$mnt][1] = 0; }
  $tempmonth[$mnt][0] = $tempmonth[$mnt][0] + $put;
  $tempmonth[$mnt][1] = $tempmonth[$mnt][1] + 1;
                     if ($put > $monthmax[$mnt]) {
@@ -494,10 +503,12 @@
                }
 
 
-             if ( $raw[$mnt][0][$day][$rawlb['low']] == ""  ) {
+             if ( !isset($raw[$mnt][0][$day][$rawlb['low']]) ) {
                 $put = "---";
  } else {
                 $put = $raw[$mnt][0][$day][$rawlb['low']];
+ if(!isset($tempmonth[$mnt][2])) {$tempmonth[$mnt][2] = 0.0;}
+ if(!isset($tempmonth[$mnt][3])) {$tempmonth[$mnt][3] = 0; }
                 $tempmonth[$mnt][2] = $tempmonth[$mnt][2] + $put;
                 $tempmonth[$mnt][3] = $tempmonth[$mnt][3] + 1;
                  if ($put < $monthmin[$mnt]) {
@@ -551,7 +562,7 @@
     echo '</td>';
     for ( $i = 0 ; $i < 12 ; $i++ )
         {
-        if ($tempmonth[$i][1] > 0)
+        if (isset($tempmonth[$i][1]) and $tempmonth[$i][1] > 0)
             {                 
                     echo '<td class=" ' . ValueColor($monthmax[$i]).'" colspan="'.$colspan.'">' . sprintf($places,$monthmax[$i]) .' </td>';     
             }
@@ -567,7 +578,7 @@
  echo '</td>';
     for ( $i = 0 ; $i < 12 ; $i++ )
      {
- if ($tempmonth[$i][1] > 0)
+ if (isset($tempmonth[$i][1]) and $tempmonth[$i][1] > 0)
  {         
             echo '<td class=" ' . ValueColor(($tempmonth[$i][0] / $tempmonth[$i][1] )).'" colspan="'.$colspan.'">' .  sprintf($places,($tempmonth[$i][0] / $tempmonth[$i][1] )) . '</td>';
             }
@@ -594,7 +605,7 @@
     echo '</td>';
     for ( $i = 0 ; $i < 12 ; $i++ )
     {       
- if ($tempmonth[$i][3] > 0)
+ if (isset($tempmonth[$i][3]) and $tempmonth[$i][3] > 0)
  {             
             echo '<td class=" ' . ValueColor(($tempmonth[$i][2] / $tempmonth[$i][3] )).'" colspan="'.$colspan.'">' .  sprintf($places,($tempmonth[$i][2] / $tempmonth[$i][3] )) . '</td>';                               
  }
@@ -611,7 +622,7 @@
     for ( $i = 0 ; $i < 12 ; $i++ )
         {
 
-        if ($tempmonth[$i][3] > 0)
+        if (isset($tempmonth[$i][3]) and $tempmonth[$i][3] > 0)
             {
             echo '<td class=" ' . ValueColor($monthmin[$i]).'" colspan="'.$colspan.'">' .  sprintf($places,$monthmin[$i]) . '</td>';                                     
             }

You get the general idea.. somebody else can slog through the various scripts making those type of code changes.. I'm tired..
 
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline scudwatcher

  • Billy T. Forecaster Webmaster csraweather.net
  • Senior Contributor
  • ****
  • Posts: 157
  • Amateur Radio KC4SRA csraweather.net
    • CSRA Weather
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #11 on: March 04, 2023, 07:54:23 AM »
I have downloaded and installed jmurray's new updated php 8.2 detailed summary season files and uploaded them to my webserver after I revised these scripts for my specific usage.  Upon running these scripts, I observe where I have no soil temperature records and et records from the last 3 years!  The soil temp and et do not update daily.  I DO observe my temp and rainfall data since 2017!  I manually created a csv file wxreports012023 and uploaded to my webserver, but still, no data.  Would someone consider directing me to a resolution?  Thank You.

Offline Murry Conarroe

  • Contributor
  • ***
  • Posts: 143
    • Wildwood Weather
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #12 on: March 04, 2023, 09:12:15 AM »
I overlooked updating the soil temperature scripts since I don't have a soil temp sensor. I will update them later today.
Murry

Online zeppline

  • Senior Member
  • **
  • Posts: 66
    • Las Vegas Weather Guy
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #13 on: March 04, 2023, 11:31:47 AM »
I have a problem with all the information is one ahead it starter the last day of Feb was printed as march 1 now all data is one day ahead? WD averages/extremes and Noaa style reports are OK. How can I fix it.

Offline Murry Conarroe

  • Contributor
  • ***
  • Posts: 143
    • Wildwood Weather
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #14 on: March 04, 2023, 01:46:06 PM »
I have a problem with all the information is one ahead it starter the last day of Feb was printed as march 1 now all data is one day ahead? WD averages/extremes and Noaa style reports are OK. How can I fix it.

The data on your dailynoaareport at http://www.lasvegaswx.com/dailynoaareport.htm matches the data displayed by the detail reports for the first three days of March. The data displayed in the detail reports for today comes from data in your testtags file.
If you don't want today's data displayed in the reports, change the $show_today setting in the wxreport-settings.php to false.
Code: [Select]
$show_today = true; # WD - only ---Set to true if you want info to be displayed for today. Info for today will come from custom tags in your testtags file.
Murry

Offline Murry Conarroe

  • Contributor
  • ***
  • Posts: 143
    • Wildwood Weather
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #15 on: March 04, 2023, 02:02:07 PM »
I have downloaded and installed jmurray's new updated php 8.2 detailed summary season files and uploaded them to my webserver after I revised these scripts for my specific usage.  Upon running these scripts, I observe where I have no soil temperature records and et records from the last 3 years!  The soil temp and et do not update daily.  I DO observe my temp and rainfall data since 2017!  I manually created a csv file wxreports012023 and uploaded to my webserver, but still, no data.  Would someone consider directing me to a resolution?  Thank You.

You need to update your path setting in the wxreport-settings.php for your climatedataout files. Change
Code: [Select]
$path_climatedata = "./reports/";           # WD only -- Location of climatedataout*.html filesto
 
Code: [Select]
$path_climatedata = "./";           # WD only -- Location of climatedataout*.html files


Murry

Offline scudwatcher

  • Billy T. Forecaster Webmaster csraweather.net
  • Senior Contributor
  • ****
  • Posts: 157
  • Amateur Radio KC4SRA csraweather.net
    • CSRA Weather
Re: Detailed Reports problem php 8.0 and 8.1 - RESOLVED-
« Reply #16 on: March 04, 2023, 02:59:11 PM »
Thank You Ken and Murray for all you do!  Resolved by changing path from:

$path_climatedata = "./reports/";

To:

$path_climatedata = "./";

All climate soil and et data are being viewed.  Now, my next step, is to contact my web host to upgade to PHP8.2.

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 209
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #17 on: March 04, 2023, 09:17:20 PM »
Dose the Wind Run Summary still need to be updated? It will not run for me.

http://www.weathercat.net/wxwindrunsummary.php?r=wxwindsummary.php

Offline Murry Conarroe

  • Contributor
  • ***
  • Posts: 143
    • Wildwood Weather
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #18 on: March 04, 2023, 10:49:38 PM »
Dose the Wind Run Summary still need to be updated? It will not run for me.

http://www.weathercat.net/wxwindrunsummary.php?r=wxwindsummary.php

Your wind run files looked the same as mine (which work okay). I did notice a line missing from your wxreport-settings.php file.
I have attached an edited version of it for your use. Change the file extension from txt to php and see if it corrects your problem.
Murry

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 209
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #19 on: March 04, 2023, 11:23:56 PM »
I tried the new file but still no luck.

Offline Murry Conarroe

  • Contributor
  • ***
  • Posts: 143
    • Wildwood Weather
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #20 on: March 05, 2023, 09:23:18 AM »
I tried the new file but still no luck.

Try the attached wxwindrunsummary.php file. Remember to rename from txt to php.
Murry

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 209
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #21 on: March 05, 2023, 11:03:39 AM »
Thanks, I did not notice the file was specifying the error reporting and not pulling the value from the include file.

I had to make the change below in wxreportinclude.php to get any of the pages to load with out a page full of warnings. Is there a reason I need to do this and others don't?

Old  value
error_reporting(E_ALL & ~E_NOTICE);

New value
error_reporting(E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR);
« Last Edit: March 05, 2023, 04:03:10 PM by Forever »

Offline hcorrin

  • Contributor
  • ***
  • Posts: 126
    • Ballaugh Weather
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #22 on: March 06, 2023, 05:41:24 PM »
the 3 snow depth reports in wxreports appears to not be seeing the data https://www.hc-iom.co.uk/WD-AJAX3/wxsnowdepthdetail.php
every thing else is showing ok is the clientdata files missing something its looking for

Offline Murry Conarroe

  • Contributor
  • ***
  • Posts: 143
    • Wildwood Weather
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #23 on: March 06, 2023, 05:55:48 PM »
the 3 snow depth reports in wxreports appears to not be seeing the data https://www.hc-iom.co.uk/WD-AJAX3/wxsnowdepthdetail.php
every thing else is showing ok is the clientdata files missing something its looking for
Is snow depth listed in your climatedataout files? Do you have a link to one of them?
Murry

Offline Murry Conarroe

  • Contributor
  • ***
  • Posts: 143
    • Wildwood Weather
Re: Detailed Reports problem php 8.0 and 8.1
« Reply #24 on: March 06, 2023, 08:45:13 PM »
the 3 snow depth reports in wxreports appears to not be seeing the data https://www.hc-iom.co.uk/WD-AJAX3/wxsnowdepthdetail.php
every thing else is showing ok is the clientdata files missing something its looking for

Your climatedataout file at https://www.hc-iom.co.uk/weather/climatedataout.html doesn't have any snowdepth listed so the snowdepth scripts have nothing to display. If you are recording snow depth, your climatedataout file should look like https://weather.wildwoodnaturist.com/climatedataout.html.

This assumes you are recording snow depth in WD. If so, you will need to use the climatedatasolaruvdepth.html template included in the wxreports zip. Put it in the webfiles folder of WD and rename to climatedata.html. Then recreate your climatedataout files for the months as needed.
Murry