WXSIM\short.php "EWN-style" for php8

Hello,
I noticed that even the short version (short.php) doesn’t work with php 8.1
thanks in advance to fix, if possibile


Hi,

It would help to understand your problem when you always post the link (URL) to the “not working” script.

I tested PHP 8.1.4 without problems: the full forecast.php and the small short.php work correct without any messages in the error log.
So I do not understand your remarks,
==> are you using the version I uploaded after your previous question about PHP 8.1?

Currently you are using the 2 versions on your main site
https://meteoesine.it/wxsim/short.php => looks OK, no errors when using test.php
https://meteoesine.it/wxsim/forecast.php => looks OK, but multiple errors when using test.php, those errors should not occur.

Could you please give us more information:

[ul]
[li]the url to the short version running with PHP 8.1.x[/li]
[li]the contents of line 20 in short.php [/li][/ul]

That line has in item ewnpath the link to the data script. When there is only the background visible, probably the data script was not found.

echo '<script>var lang="'.$lang.'",wiset="'.$windunit.'",ewnpath="./wxsim";</script>';  #### 2022-08-10

Please always post an answer when someone answers your questions. If an answer solves your problem or not, others will benefit in the future.
You never did that here: http://discourse.weather-watch.com/p/561364

Wim


Schermafbeelding 2022-08-10 om 11.23.01.png

Yes, my fault, you are totally right.
I’ve just installed the correct files and now everything seems working fine both short and complete version.

https://meteoesine.it/wxsim/_test.php

I’ve been setting up my host for php 8.1.8 for a few days now and it seems wxsim is working fine, or almost …
I don’t know if it is a coincidence but for some days, always at the same time (around 20:30) the script stops working displaying only the spinning circle and no data.
After some time, magically, everything returns to work correctly.
Meanwhile, if I try to set up php 7.4, without touching anything, the script works fine

https://www.meteoesine.it/wxsim/forecast.php

below the error report test even if it works properly

Warning: Undefined variable $path_to_lastret in /home/cldvlwax/public_html/wxsim/wxsim/plaintext.php on line 8

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/cldvlwax/public_html/wxsim/wxsim/plaintext.php on line 8

Warning: Undefined variable $lang in /home/cldvlwax/public_html/wxsim/wxsim/plaintext.php on line 10

Warning: Undefined variable $lang in /home/cldvlwax/public_html/wxsim/wxsim/plaintext.php on line 10

Warning: Undefined variable $lang in /home/cldvlwax/public_html/wxsim/wxsim/plaintext.php on line 20

Warning: Undefined variable $lang in /home/cldvlwax/public_html/wxsim/wxsim/plaintext.php on line 21

Warning: Undefined variable $Status in /home/cldvlwax/public_html/wxsim/wxsim/plaintext.php on line 21

Fatal error: Uncaught Error: Call to undefined function fixtemp() in /home/cldvlwax/public_html/wxsim/wxsim/plaintext.php:111 Stack trace: #0 /home/cldvlwax/public_html/wxsim/wxsim/test.php(5): include() #1 {main} thrown in /home/cldvlwax/public_html/wxsim/wxsim/plaintext.php on line 111


My config.php details

$wxsimlocation = 'phpversion: '.phpversion(); # Your location
$latitude = 45.93;
$longitude = 10.25;
$tzabb = “Europe/Rome”;
$datestyle = “d.m.Y”;
$timeFormat = “d.m.Y H:i”; # Timeformat
$updatehrs = array(0,3,6,9,12,15,18,21); # Hours when wxsim runs
$updateminute = 30; # minutes past full hour for upload time
$jqueryload = true; # Should we load JQuery? (Set to false if your site loads it by default)
$bootstrapload = true; # Should we load Bootstrap? (Set to false if your site loads it by default)
$mainwidth = “100%”; // Use 100% for responsivity

$path_to_langfiles = “./wxsim/lang/”;
$path_to_lastret = “/home/cldvlwax/public_html/wxsim/wxsim/lastret.txt”;
$path_to_dataphp = “./wxsim/”;
$path_to_js = “./js/”;
$path_to_css = “./css/”;

$wxsimversion = 2017.03; # internal version PHP8


Another question regarding short.php

I have set wxsim to display 9 days of forecast.
Forecast.php displays them all, but short.php displays only 8 (1 less). If I set 5 forecast days, short.php displays only 4 days

thanks in advance for any comments


I don’t want to sound boring but the problem that appears to me the blank screen EVERY DAY from around 20 to 22:30 (UTC + 2) is driving me crazy.
Even clearing the browser cache doesn’t fix it … it restarts by itself and works well during all the day, until around the next 8pm.

Hours when wxsim runs: (0,3,6,9,12,15,18,21)

https://www.meteoesine.it/wxsim/forecast.php
php vrs 8.1.9


Check and re-download the zip => http://discourse.weather-watch.com/p/561372
Are you sure you are running the scripts wxsim/wxsim/data.php and wxsim/wxsim/plaintext.php from that download?

When I run https://www.meteoesine.it/wxsim/wxsim/_test.php?test=data.php I get errors from plaintext.php and data.php with different line-numbers compared to the download-versions.

When I locally test with your files from 18:00 no errors

After the 22:00, again no errors

So I assume there are problems: check the the data.php script, probably it is an old version.

Succes,
Wim

hello,
I still noticed some inconsistencies:
On ‘table’, the feel like temperature marks 0°
and the date of the next update is not correct, see attached image
is it possible to fix them?
thanks again

https://www.meteoesine.it/wxsim/forecast.php
php vrs 8.1.11


Attached updated data.php

and the date of the next update is not correct, see attached image
In wxsim/fcr.php around lines 23-24 it reads now
// Next update by Labbs
$thishr = date('i');

change that i to a H It should be like this

// Next update by Labbs
$thishr = date('H');

Wim

Edit 2022-12-29: removed data.php.zip as there is a newer version a few messages down

Hi all,

Trying to get this script to work on PHP 8.1.12 OS Linux 4.18.0-425.3.1.el8.x86_64 x86_64

I set display errors to 1
ini_set(‘display_errors’, ‘1’);

I had to change the script at a few places to get the lastret.txt and plaintext.php to read.

Around Line 10
//$pathtodata=str_replace(“lastret.txt”,“”,$path_to_lastret); # echo LINE.‘HERE’; exit;
To
$path_to_lastret = “/home/help061/public_html/weatherdata/wxsim/”;

Around Line 92
//$pt = file($pathtodata.“plaintext.txt”); # echo LINE.print_r($pt,true); exit;
To
$pt = “/home/help061/public_html/weatherdata/wxsim/plaintext.txt”;

I get this error:
/home/help061/public_html/weatherdata/wxsim/
Warning: foreach() argument must be of type array|object, string given in /home/help061/public_html/weatherdata/wxsim-ewn/wxsim/plaintext.php on line 95

Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in /home/help061/public_html/weatherdata/wxsim-ewn/wxsim/plaintext.php:98 Stack trace: #0 /home/help061/public_html/weatherdata/wxsim-ewn/wxsim/plaintext.php(98): implode(‘’, ‘/home/help061/p…’) #1 /home/help061/public_html/weatherdata/wxsim-ewn/wxsim/test.php(5): include(‘/home/help061/p…’) #2 {main} thrown in /home/help061/public_html/weatherdata/wxsim-ewn/wxsim/plaintext.php on line 98

It looks like an implode error string versus array, but my brain is not computing atm. No idea how to fix it, anybody with some PHP skills might fix the lines.

Line 94 // fix missing space at start of line if need be
Line 95 foreach ($pt as $i => $line) {
Line 96 if(substr($line,0,1) != ’ ‘) {$pt[$i] = ’ ’ . $line;}
Line 97 }
Line 98 $plaintext = implode(’',$pt); // get the plaintext file.

Link to file
https://061.com.au/weatherdata/wxsim-ewn/wxsim/test.php

https://061.com.au/weatherdata/wxsim-ewn/wxsim/plaintext.php

Any help with this is appreciated.


plaintext.zip (5.26 KB)

i think your changing a file that should not be touched this link WXSIM "EWN-style" for php8 has the download of a 8.1 php working version
the config.php has the link for were the lastret.txt is as does the graph.php

Thanks,
That is how I started. I did not install anything else only those files in that zip file.
I only want to display the weather forecast…

H

Hello,
i installed the new wxsim-ewn for php 8, in the old version when there was a dot “.” the letter after was uppercase now is always lowercase, only the first letter of the sentence is uppercase, is it possible to change this?
Examples attached.

Thank you


old.jpg

new.jpg

I received a private message with a question for help with another? 23:00 problem when using PHP 8.x

@ALL Please do not sent PM’s or e-mails to ask questions about this script.
Use the forum: There are maybe more users with the same problem and there are more knowledgable PHP users

Problem description: Only spinning wheel, no detailed data occurs between 23:00 and 01:00
This spinning wheel is shown when the scripts is waiting for new data.
If it is not replaced with live-data . . / wxsim/data.php did not return any data or returned invalid data.
This can be caused by “invalid wxsim generated data”(10%) or "problems in the wxsim/data.php script itself (90%).

Problem solution:
Attached an updated wxsim/data.php to use from now on.

Finding errors which occur only between 23:00 and 01:00 is not easy as that is the normal time for me to sleep.
But with a test server plus the the time-zone and wxsim-data from users in New-Zealand & Anchorage I found another nasty PHP 8.x problem.
Which indeed only occurs between for data at 00:00 or 23:55

If you encounter this spinning wheel problem again:
=> use your browser and run the script . ./wxsim/data.php?test
It should return a PHP error message.
Copy the error message and post it here on the forum. Include also the URL to your wxsim forecast.

Succes,
Wim


data.php.zip (6.93 KB)

Thanks Wim,
today I try the new data.php. Did you happen to see my post prior to your answer, this one?

Do you happen to have a solution?
Thank you

You did not include the URL to your WXSIM forecast script.
I have no idea which part of the scripts you are talking about.
Neither where it is displayed. Maybe it is generated somewhere in the javascripts.

Be aware: I did not write those scripts.
I only try to make the scripts compatible with PHP-8 for you and other WXSIM users.

Wim

Thanks Wim for your work much appreciated, here is the link: Previsioni MeteoSantAngelo.it - WXSIM

Attached a script originally written by Ken True. It is an extremely old version and modified by different authors.
Let’s hope it works for Italian also.
Make a copy of the current version to use if new problems occur.

Wim


plaintext.php.zip (5.67 KB)

Hi Wim,
seems to work perfectly, I test it again some days.
Thank you

Hello,
I’m noticing that in the “errors” file this error appears in the file: frc.php how can I fix it?

PHP Warning: Undefined variable $uploadupdate in …/wxsim/frc.php on line 24

Thank you