Issue with WXSIM-EWN Script ** Solved**

Hi, I am trying to set up the EWN style display script for WXSim. My server is running PHP 7.x but when I run the _test.php page I get the following:

Warning: Use of undefined constant lang - assumed 'lang' (this will throw an Error in a future version of PHP) in /var/www/html/weather/wxsim-ewn/wxsim/config.php on line 62

Notice: Undefined index: lang in /var/www/html/weather/wxsim-ewn/wxsim/config.php on line 62

Notice: Undefined variable: lang in /var/www/html/weather/wxsim-ewn/wxsim/config.php on line 63

Notice: Undefined variable: lang in /var/www/html/weather/wxsim-ewn/wxsim/config.php on line 64

Warning: Use of undefined constant ewnwunit - assumed 'ewnwunit' (this will throw an Error in a future version of PHP) in /var/www/html/weather/wxsim-ewn/wxsim/config.php on line 285

Notice: Undefined index: ewnwunit in /var/www/html/weather/wxsim-ewn/wxsim/config.php on line 285

Notice: Undefined variable: uploadupdate in /var/www/html/weather/wxsim-ewn/wxsim/frc.php on line 24

Warning: Use of undefined constant lang - assumed 'lang' (this will throw an Error in a future version of PHP) in /var/www/html/weather/wxsim-ewn/wxsim/frc.php on line 43

Fatal error: Uncaught Error: Call to undefined function mb_detect_encoding() in /var/www/html/weather/wxsim-ewn/wxsim/frc.php:251 Stack trace: #0 /var/www/html/weather/wxsim-ewn/wxsim/frc.php(47): html2utf8() #1 /var/www/html/weather/wxsim-ewn/wxsim/config.php(290): include('/var/www/html/w...') #2 /var/www/html/weather/wxsim-ewn/forecast.php(6): include('/var/www/html/w...') #3 /var/www/html/weather/wxsim-ewn/_test.php(5): include('/var/www/html/w...') #4 {main} thrown in /var/www/html/weather/wxsim-ewn/wxsim/frc.php on line 251

Any ideas? I basically uploaded the contents of the zip then set up config.php with the correct paths. TIA

Ideas can exists if you give more information:

  1. Where did you get the download from so that we know for sure we are talking about the same version
  2. Always post the URL to your website/ script with the problems, nobody on this forum is clairvoyant
  3. What exactly means " basically uploaded the contents of the zip". Did you upload all of the contents or only part.
  4. Where did you put the two files needed: plaintext.txt and lastret.txt?

Solutions:
Current version has line 62/63 changed to

#if($_GET['lang']&&!isset($lang)){$lang=$_GET['lang'];}  # 2022-05-01
if(array_key_exists('lang',$_GET) && !isset($lang)){$lang=$_GET['lang'];}  # 2022-05-01

Also the warnings for ewnunit and uploadupdate are removed since 2022-05-01

The fatal error in topic Forecast EwnWxsim - #6 by pwsdashboard

These are very beautiful scripts.
But also it are old scripts and not maintained by the author.

If you want to use them, please supply more information.

Wim

Hi Wim, and thanks for the reply. I’me getting a bit nearer but still not showing any data. The site is at https://www.360shetland.co.uk/weather/wxsim-ewn/forecast.php - I am also using the Saratoga script on my main weather website here: https://www.360shetland.co.uk/weather/forecast.php

Lastret.txt and plaintext.txt are both copied every report cycle to /var/www/html/weather , and as you can see the Saratoga script is reading plaintext.txt without issue.

I downloaded the WXSim 3in1 script from the nordic weather website, and uploaded the wxsim-ewn folder to my server under the weather directory. The contents of my config.php are:

$wxsimlocation     = "Lerwick, Shetland Islands";                 # Your location
$latitude = 60.45;
$longitude = -1.1;
$tzabb        = "Europe/London";
$datestyle    = "d.m.Y";
$timeFormat = "d.m.Y H:i";          # Timeformat
$updatehrs = array(3,6,9,12,15,18,21);  # Hours when wxsim runs
$updateminute = 14; 	              # 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 = "./lang/";
$path_to_lastret = "/var/www/html/weather/lastret.txt";
$path_to_dataphp = "./wxsim";
$path_to_js = "./js/";
$path_to_css = "./css/";

I’ve played around with the paths but still it’s not reading any data. I am running PHP Version 7.4.3-4ubuntu2.26.

There appears to be several versions of the scripts so I’m not 100% sure which I should use. I have downloaded some from this forum, although when I tried I still got errors and no data. Documentation is sketchy to say the least! Appreciate your help.

Cheers,

Rory

That is a very very old version.
Dozens of changes are needed for PHP 7/8

Your current “waiting circle” is caused by the same “unsolved” problems as the data script fails while downloading the data.

https://www.360shetland.co.uk/weather/wxsim-ewn/wxsim/data.php


As there are missing upodates in your version:

Attached a todays zip tested with PHP 8.2

wxsim-ewn2025-01-07.zip (462.1 KB)

Results should look like the attached screenshot.


If it fails at your site, please mail me a (temporary) FTP userID + password
Could be an unknown PHP problem.
Succes,
Wim

I tested the scripts with your lastret.txt

WXSIM - Retrieved Data for Lerwick  60.15  1.14  25  07 Jan  2025 12:00p (local standard time)
 
                                                                                                     
07 Jan ---------------------------------------------------------------------------------------       
                                          Tuesday                                                    
                                                                                                     
  TIME      WEATHER        AIR   DEW   WCF   HT.I  VLY  W.DIR VST  W.SP SKY  P.RT SN.C THK       LVL1  TMAX  TMIN                         S.IR VIS  UVI  WDIR G1HR                          DATE/TIME
 
12:00p DNS.OVCS PROB. DRZ   2.7   1.4  -4.5   2.7   2.9    4   20   14  100  0.0  0.0  1301      -0.1   2.9   2.5                           18   45  0.0  N     19                          2025-01-07_12:00_UTC
No shower or thunderstorm activity expected...............................................           
12:30p CLOUDY   PROB. DRZ   2.7   1.0  -4.5   2.7   3.1    4   33   14   92  0.0  0.0  1297      -0.8   2.9   2.4                           29   44  0.0  N     19                          2025-01-07_12:30_UTC
 1:00p CLOUDY   PR. RN/SN   2.6   0.7  -4.6   2.6   3.0    4   39   14   92  0.0  0.0  1296      -1.2   2.8   2.4                           31   44  0.0  N     19                          2025-01-07_13:00_UTC
 1:30p CLOUDY   LT. RN/SN   2.4   0.4  -4.8   2.4   2.8    4   34   13   95  0.6  0.0  1294      -1.4   2.6   2.2                           23  9.5  0.0  N     19                          2025-01-07_13:30_UTC
 2:00p DNS.OVCS LT. RN/SN   2.2   0.2  -5.1   2.2   2.6    4   30   13   98  0.6  0.0  1293      -1.6   2.3   1.9                           14  9.4  0.0  N     18                          2025-01-07_14:00_UTC
 2:30p DNS.OVCS PR. SNW/R   2.0   0.0  -5.3   2.0   2.4    4   25   13  100  0.0  0.0  1292      -1.9   2.1   1.7                            7   44  0.0  N     18                          2025-01-07_14:30_UTC
 3:00p DNS.OVCS PR. SNW/R   1.8  -0.2  -5.4   1.8   2.3    4   17   13  100  0.0  0.0  1291      -2.0   1.9   1.6                            1   43  0.0  N     18                          2025-01-07_15:00_UTC

You are missing some fields in your lastret.txt which causes “warnings”

PTOT SWXO

Attached image shows the “advised” minimal number of fields in lastret.txt
The image is from an earlier wxsim version.


Also your dataset is smaller as others use, only 3 days.
So there will be only 3 tabs to click on in the forecast.

Thanks again Wim, I’m getting there now!

It works fine as long as it’s only lastret.txt in the path. As soon as I copy plaintext.txt into the directory it just starts spinning again. Is it maybe because the plaintext.txt file spans longer that the lastret.txt?

This is my settings (I have changed it to 7 days from 3 days). I don’t have the agricultural data (as you can see they are greyed out). I do have the full professional mode with enhanced customisation.

I have no idea what you refer to with "As soon as I copy plaintext.txt into the directory "

Into what directory?

Plaintext.txt is processed and is stored in the same location as lastret.txt and latest.csv. The files should be in the same folder for these scripts.

So the settings are correct as is.

Wim

Sorry, I maybe didn’t explain it well. Lastret.txt and plaintext.txt are uploaded to my web server via WeeWX / rsync. The path to both of these is /var/www/html/weather. When I was testing the paths I copied lastret.txt into the wxsim-ewn directory and the script displayed what I showed above. As soon as I copied plaintext.txt into wxsim-ewn the script just show the waiting circle. As soon as I delete plaintext.txt then it displays the content from lastret.txt. Does that make sense?

I asked access, to find the problem.

Your PHP setup has no “mb_detect_encoding”
Also allready mentioned

Forecast EwnWxsim - #6 by pwsdashboard

If you do not add that to PHP , simply set line 375 in wxsim/plaintext.php to comment. From
if(!mb_detect_encoding($fixedtxt, 'UTF-8', true)){$fixedtxt=utf8_encode($fixedtxt);}

to

# if(!mb_detect_encoding($fixedtxt, 'UTF-8', true)){$fixedtxt=utf8_encode($fixedtxt);}

Wim

1 Like

Thanks again Wim, that’s it working now. I enabled the mb_detect_encoding and it sprung in to life. Apologies, I forgot about that after I uploaded the new scripts you sent.

https://www.360shetland.co.uk/weather/wxsim-ewn/forecast.php

1 Like

WIM
How do you get your agricultural data shown? mine is greyed out

Wim screen shot is of a 2013 version and the agricultural setting may depend on the version he got at the time
Mine is greyed out as I would expect as the info I sent Tom at purchase time did not include its use, so if you need the agricultural data you should email Tom

1 Like