Author Topic: WxSimCSV Script PHP Deprecated  (Read 596 times)

0 Members and 1 Guest are viewing this topic.

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 209
WxSimCSV Script PHP Deprecated
« on: March 17, 2023, 07:42:46 PM »
Is anyone still using the WxSimCSV script and know how to fix the deprecated errors?

http://www.weathercat.net/wxsimcsv.php

Code: [Select]
PHP Deprecated:  Function date_sunrise() is deprecated in C:\inetpub\weathercat\wxsimcsv\index.php on line 158
PHP Deprecated:  Function date_sunset() is deprecated in C:\inetpub\weathercat\wxsimcsv\index.php on line 159
PHP Deprecated:  Function date_sunrise() is deprecated in C:\inetpub\weathercat\wxsimcsv\index.php on line 160
PHP Deprecated:  Function date_sunset() is deprecated in C:\inetpub\weathercat\wxsimcsv\index.php on line 161
PHP Deprecated:  Implicit conversion from float 17.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 302
PHP Deprecated:  Implicit conversion from float 17.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 18.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 19.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 20.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 21.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 22.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 23.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 24.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 1.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 2.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 3.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 4.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 5.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 6.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 7.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 8.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 9.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 10.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 11.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 12.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 13.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 14.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 15.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 16.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 17.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 18.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 19.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 20.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 21.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 22.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 23.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 24.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 1.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 2.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 3.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 4.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 5.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 6.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 7.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 8.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 9.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 10.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 11.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 12.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 13.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 14.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 15.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 16.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 17.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 18.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 19.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 20.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 21.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 22.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 23.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 24.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 1.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 2.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 3.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 4.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 5.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 6.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 7.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 8.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 9.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 10.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 11.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 12.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 13.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 14.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 15.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 16.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 17.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 18.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 19.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 20.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 21.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 22.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 23.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 24.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 1.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 2.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 3.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 4.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 5.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 6.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 7.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317
PHP Deprecated:  Implicit conversion from float 8.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 317

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WxSimCSV Script PHP Deprecated
« Reply #1 on: March 18, 2023, 12:54:28 PM »
Post the script, and I'll take a look.

Generally, instead of using date_sunrise/date_sunset, you have to switch to date_sun_info() instead. And use the returned array with 'sunrise' and 'sunset' to address the values.  Like
Code: [Select]
   $now  = time();
   $sun = date_sun_info($now, $SITE['latitude' ], $SITE["longitude"]);
   $da  = $sun["civil_twilight_begin"];
   $sr  = $sun["sunrise"];
   $st  = $sun["transit"];
   $ss  = $sun["sunset"];
   $du  = $sun["civil_twilight_end"];

Fixing the implicit conversion usually means adding (float) in front of the variable/expression to cast it to float explicitly.
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 Forever

  • Senior Contributor
  • ****
  • Posts: 209
Re: WxSimCSV Script PHP Deprecated
« Reply #2 on: March 18, 2023, 01:55:47 PM »
Thanks for look at this for me. I tried to attach the file but it may be too big?

Here is a link to the file.
http://www.weathercat.net/wssimcsv.zip

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WxSimCSV Script PHP Deprecated
« Reply #3 on: March 18, 2023, 02:54:48 PM »
So, I did download the .zip.  Added just one line and get no errata on PHP 8.2:

Change wxsimcsv/index.php
Code: [Select]
// Explode into array $data

for ($i = 0; $i < 2; $i++) {$data[$i] = explode($sep, $csv[$i]);}
to
Code: [Select]
// Explode into array $data

$data = array();
for ($i = 0; $i < 2; $i++) {$data[$i] = explode($sep, $csv[$i]);}
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 Forever

  • Senior Contributor
  • ****
  • Posts: 209
Re: WxSimCSV Script PHP Deprecated
« Reply #4 on: March 18, 2023, 03:43:40 PM »
I'm still getting the deprecated errors. I know I can turn this off in my PHP.ini but was try to get this fixed before it stops working in a future version of PHP. Would it be hard to fix them?

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WxSimCSV Script PHP Deprecated
« Reply #5 on: March 18, 2023, 04:21:04 PM »
Ok.. change wxsimcsv/index.php from
Code: [Select]
$srise = date_sunrise(time(), SUNFUNCS_RET_STRING, $lat, $long, 90, $gmtoffset);
$sset = date_sunset(time(), SUNFUNCS_RET_STRING, $lat, $long, 90, $gmtoffset);
$sunrise = round(date_sunrise(time(), SUNFUNCS_RET_DOUBLE, $lat, $long, 90, $gmtoffset));
$sunset =  round(date_sunset(time(), SUNFUNCS_RET_DOUBLE, $lat, $long, 90, $gmtoffset));
to
Code: [Select]
$sun = date_sun_info(time(), $lat, $long);
$srise = date('H:i',$sun["sunrise"]);
$sset = date('H:i',$sun["sunset"]);
$sunrise = (integer)date('H',$sun["sunrise"]);
$sunset = (integer)date('H',$sun["sunset"]);

and in wxsimcsv/usersettings.php change
Code: [Select]
$dst = date("I"); //Set Daylight Savings Time
to
Code: [Select]
$dst = (integer)date("I"); //Set Daylight Savings Time
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 Forever

  • Senior Contributor
  • ****
  • Posts: 209
Re: WxSimCSV Script PHP Deprecated
« Reply #6 on: March 18, 2023, 04:45:45 PM »
The fixes part of it, just have the one error now.

PHP Deprecated:  Implicit conversion from float 13.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 304

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WxSimCSV Script PHP Deprecated
« Reply #7 on: March 18, 2023, 05:11:22 PM »
Sorry.. with the above 2 fixes, I can't replicate the error.  What is the code for line 304 in wxsimcsv/index.php ?
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 Forever

  • Senior Contributor
  • ****
  • Posts: 209
Re: WxSimCSV Script PHP Deprecated
« Reply #8 on: March 18, 2023, 05:19:44 PM »
I'm getting the following two errors.

PHP Deprecated:  Implicit conversion from float 15.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 304
PHP Deprecated:  Implicit conversion from float 15.5 to int loses precision in C:\inetpub\weathercat\wxsimcsv\index.php on line 319

Here is the code.

$forecastdate = $fday." ".$fdt." ".$fmonth." ".$fy." ".$lng[24]." ".date('g:00 A T' , mktime($data[3][3]+$dst, 0, 0, $data[3][1], $data[3][2], $data[3][0]));

$forecast = date('YmdH' , mktime($data[$i][3]+$dst, 0, 0, $data[$i][1], $data[$i][2], $data[$i][0]));

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WxSimCSV Script PHP Deprecated
« Reply #9 on: March 18, 2023, 05:26:06 PM »
Then try changing them to

$forecastdate = $fday." ".$fdt." ".$fmonth." ".$fy." ".$lng[24]." ".date('g:00 A T' , mktime((integer)($data[3][3]+$dst), 0, 0, $data[3][1], $data[3][2], $data[3][0]));

$forecast = date('YmdH' , mktime((integer)($data[$i][3]+$dst), 0, 0, $data[$i][1], $data[$i][2], $data[$i][0]));

You did apply the change to usersettings.php of
Code: [Select]
$dst = (integer)date("I"); //Set Daylight Savings Time
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 Forever

  • Senior Contributor
  • ****
  • Posts: 209
Re: WxSimCSV Script PHP Deprecated
« Reply #10 on: March 18, 2023, 06:02:52 PM »
Thanks Ken. Everything is working now.  :-)