Author Topic: PHP 8 and Alt Dash 6 problem running cloudbase.php [RESOLVED]  (Read 652 times)

0 Members and 1 Guest are viewing this topic.

Offline cirrus

  • Kevin Hough
  • Member
  • *
  • Posts: 48
  • Davis Vantage Pro2 Plus
    • Gorge-East Weather
PHP 8 and Alt Dash 6 problem running cloudbase.php [RESOLVED]
« on: January 15, 2022, 06:52:48 PM »
Hello All!

I'm using the Alt Dash 6 template and the only thing not working with PHP8 is the cloudbase.php script.

Using https://thedallesweather.com/cloud-base.php?uom=M&html=1&test=1 to view errors, here's what I'm seeing:

Warning: Undefined variable $metcon3 in /home/thedalle/public_html/cloud-base.php on line 757

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /home/thedalle/public_html/cloud-base.php on line 1199

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /home/thedalle/public_html/cloud-base.php on line 1199

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /home/thedalle/public_html/cloud-base.php on line 1199

Deprecated: Implicit conversion from float 1.1555555555555554 to int loses precision in /home/thedalle/public_html/cloud-base.php on line 1081




Enclosed is a copy of the cloudbase.php I'm using in txt form... any help would be greatly appreciated.

Regards, Kevin
« Last Edit: January 16, 2022, 08:17:45 PM by cirrus »
Regards, --Kevin


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP 8 and Alt Dash 6 problem running cloudbase.php
« Reply #1 on: January 16, 2022, 11:56:50 AM »
Ahh... PHP8 seems to be much more picky than PHP7 on things.

Change
Code: [Select]
   case 1: $curcond = $curcond3; $metcond = $metcon3; $cldhgt = 2138;    $night = false;
to
Code: [Select]
   case 1: $curcond = $curcond3; $metcond = $metcond3; $cldhgt = 2138;    $night = false;

Then change
Code: [Select]
function cloud_match($searchfor,$haystack) {
   if (empty($searchfor)) return false;
to
Code: [Select]
function cloud_match($searchfor,$haystack) {
   if (empty($searchfor) or empty($haystack)) return false;

And try changing
Code: [Select]
    return $langWindDir[floor((($winddir + 11) / 22.5) % 16 )]; to
Code: [Select]
    return $langWindDir[(integer)floor((($winddir + 11) / 22.5) % 16 )];
and see if that fixes the issues.
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 cirrus

  • Kevin Hough
  • Member
  • *
  • Posts: 48
  • Davis Vantage Pro2 Plus
    • Gorge-East Weather
Re: PHP 8 and Alt Dash 6 problem running cloudbase.php
« Reply #2 on: January 16, 2022, 05:02:06 PM »
Thank You for looking into this. The changes you made fixed everything except for: Deprecated: Implicit conversion from float 0.7111111111111111 to int loses precision in /home/thedalle/public_html/cloud-base.php on line 1081

Thanks again Ken, for the help...

Best Regards, Kevin

Update: I changed both of the settings: $showWindDir  = true; and $windAlwaysMPH  = true; to "false", and that seems to have at least made cloudbase.php work despite the line 1081 error.


 

« Last Edit: January 16, 2022, 07:52:55 PM by cirrus »
Regards, --Kevin


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP 8 and Alt Dash 6 problem running cloudbase.php
« Reply #3 on: January 16, 2022, 07:53:08 PM »
How about trying
Code: [Select]
return $langWindDir[(integer)fmod((($winddir + 11) / 22.5),16 )];
And if that still shows it, try
Code: [Select]
$rDir = (integer)fmod((($winddir + 11) / 22.5),16 ); return $langWindDir[$rDir];
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 cirrus

  • Kevin Hough
  • Member
  • *
  • Posts: 48
  • Davis Vantage Pro2 Plus
    • Gorge-East Weather
Re: PHP 8 and Alt Dash 6 problem running cloudbase.php
« Reply #4 on: January 16, 2022, 08:17:06 PM »
How about trying
Code: [Select]
return $langWindDir[(integer)fmod((($winddir + 11) / 22.5),16 )];
And if that still shows it, try
Code: [Select]
$rDir = (integer)fmod((($winddir + 11) / 22.5),16 ); return $langWindDir[$rDir];

Okay... I tried the first line change and it worked perfect! Just for curiosities sake, I tried the second line change and it also worked great. Thanks Ken, for the great support...
Best Regards, Kevin
Regards, --Kevin


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP 8 and Alt Dash 6 problem running cloudbase.php [RESOLVED]
« Reply #5 on: January 16, 2022, 10:18:26 PM »
Glad they worked :)

I've updated cloud-base.php to V2.3 with these fixes in the legacy scripts (also downloadable separately from here)

Thanks for finding and changing the match() function to cloud_match() .. PHP8 added a new built-in match() function, so that was a big fatal error in PHP8.

Best regards,
Ken
« Last Edit: January 16, 2022, 10:20:18 PM by saratogaWX »
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 cirrus

  • Kevin Hough
  • Member
  • *
  • Posts: 48
  • Davis Vantage Pro2 Plus
    • Gorge-East Weather
Re: PHP 8 and Alt Dash 6 problem running cloudbase.php [RESOLVED]
« Reply #6 on: January 16, 2022, 10:49:58 PM »
Glad they worked :)

I've updated cloud-base.php to V2.3 with these fixes in the legacy scripts (also downloadable separately from here)

Thanks for finding and changing the match() function to cloud_match() .. PHP8 added a new built-in match() function, so that was a big fatal error in PHP8.

Best regards,
Ken

Oops...sorry my bad :oops:...forgot to mention those cloud_match() changes... glad you noticed [tup]
« Last Edit: January 17, 2022, 12:14:51 AM by cirrus »
Regards, --Kevin


 

anything