New WXSIM user needs help, and can't seem to join this forum

Hi everybody!

A new WXSIM user is trying to employ PHP scripts, and wanted to join this forum, but can’t seem to make that work, so I told him I would relay his message. He can read the posts, but not write them. Here’s what he said. Thanks in advance!

Hello to all! I tried to configure ewn style script, but after several failed, it doesn’t work.

I modified config.php and loaded all files.

Can you help me?

forecast https://meteobresciano.com/forecast.php (and other .php in root folder)
config.php https://meteobresciano.com/wxsim/config.php (and other config files in wxsim folder ex. data.php)
lastret.txt https://meteobresciano.com/lastret.txt "

Fairly difficult if one can not register to this forum.

Problem occurs bacause there seems to be two problems
The wxsim/data.php returns these PHP error-messages


<b>Warning</b>:  Use of undefined constant lang - assumed 'lang' (this will throw an Error in a future version of PHP) in <b>/var/www/vhosts/meteobresciano.com/httpdocs/wxsim/config.php</b> on line <b>62</b>


<b>Warning</b>:  Use of undefined constant ewnwunit - assumed 'ewnwunit' (this will throw an Error in a future version of PHP) in <b>/var/www/vhosts/meteobresciano.com/httpdocs/wxsim/config.php</b> on line <b>285</b>

and no data at all.

To remove those two messages, change line 1 from wxsim/data.php from

<?php

to

<?php     ini_set('display_errors', '0');

And check these lines (35-39) in config.php as they define the location of the scripts and data

$path_to_langfiles = "./wxsim/lang/";
$path_to_lastret = "../lastret.txt";
$path_to_dataphp = "./wxsim/";
$path_to_js = "./js/";
$path_to_css = "./css/";

Succes, Wim

See http://discourse.weather-watch.com/p/532466

Hello Wim!

Thanks
for your reply!

Thanks also admin for for fixed signup problem.
Unfortunately I can’t display forecast.
Can you help me?

http://meteobresciano.com/forecast.php

Best regards

Nicola

Problem 1 previous answer is solved, no errors
Problem 2 from the same answer: and no data at all., is still there. The data.php script does not return any data.

Therefor the javascripts process an empty string and fail with these messages

Uncaught SyntaxError: Unexpected end of JSON input    . . .     at wxsim_frc_2017.js?2019.01:104

The lines 102 - 104 read

  var dpath = ewnpath+"/data.php?wunit="+wiset+"&lang="+lang;
  wget([dpath], function(points) {
    strData=JSON.parse(points);

What texts did you try / typed in your wxsim/config.php around line 36 for the correct location of the lastret.txt file? I assume you typed either ./lastret.txt or the full link.

$path_to_lastret = "./lastret.txt";

The main problem now is your lastret,txt, it is NOT created at the exact half and exact full hour as it should for this script. This script only uses lines which have :00 for the minutes .
All other lines, in this case all lines, are skipped.

3:02p M.CLOUDY CHNC. DRZ   7,7   7,2   7,7   7,7   5,1    0   33    1   70   97  0,0  1325       1,1   8,0   7,5                          0,0  2,4  1006 -1,7    6                        0 2019-12-09_14:02_UTC
3:32p M.CLOUDY DRIZZLE     7,7   7,0   7,6   7,6   4,9  225   36    1   73   96  0,0  1324       0,9   7,9   7,5                          0,0  3,1  1006 -1,7    7                        0 2019-12-09_14:32_UTC
4:02p P.-M.CLD DRIZZLE     7,6   6,8   7,6   7,6   7,5  225   45    1   64   95  0,0  1330       1,1   7,8   7,4                          0,0  3,8  1006 -1,3    5                        0 2019-12-09_15:02_UTC

You could adapt the settings in the wxsim programs on your PC to generate the files exactly at the hour.
Or adapt your current ./wxsim/data.php script as we need to modify it to process those non-standard times.
You can do it yourself. Find line about 22 which reads

$wxd = file_get_contents($path_to_lastret);

You should add 1 line below so that it reads

$wxd = file_get_contents($path_to_lastret);
$wxd =  str_replace (':02',':00',$wxd); 

As you do that, and if the file-location is correct, it should produce the output as on the screenshot.

Wim

P.S. The WXSIM output is meant to be looked at (plaintext.txt) and displayed as is or used in EXCEL and those programs for latest.csv or lastret.txt
Not to be processed by other scripts. So it can take some time to get it right. Make a backup of the scripts and make some notes to use when a new version of the script arrives.


Many thanks Wim! you have solved all problem!
I fixed some small things with your solutions in other thread.

I have only two last problem with translation. Description is in English. How do I translate the Italian language?

Translation file is at this path, but don’t work:
http://meteobresciano.com/wxsim/lang/plaintext-parser-lang-it.txt

Second problem, less important: I can’t include php scripts in my joomla or wordpress pages. i can’t use iframe or add follow script in header template:

<?php $wxsimtype="forecast"; include 'wxsim/config.php'; echo $ewnhead; ?>

can you help me?

Many thanks

Nicola

This is not my script, and there are multiple versions, so I am not sure.
But I think the language file should be in the same folder (wxsim) as all other scripts as this is the php instruction in plaintext.php to load the file

if ($lang <> 'en' and file_exists("plaintext-parser-lang-$lang.txt") ) {

In your case this should work http://meteobresciano.com/wxsim/plaintext-parser-lang-it.txt

Second problem, less important: I can't include php scripts in my joomla or wordpress pages. i can't use iframe or add follow script in header template: . . . shortened . . can you help me? Many thanks Nicola

Sorry, no experience at all with with joomla or wordpress.
You should ask in a separate discussion or on a separate forum,

Succes, Wim

Many thanks Wim!
Sorry but how do I set which language to use? Can i add $lang=IT in config.php file?

I tried use your script (for example plaintext-parser-lang-DE.txt) but doesn’t work…

forecast.php appears in Italian language because I have translated the few words myself.

Thanks in advance

Nicola

The plaintext.php is an adapted Saratoga script. All languages in Saratoga scripts are in lowercase.
So to use Italian you should use : forcast.php?lang=it
The language file should be in the wxsim/ folder and the name should be plaintext-parser-lang-it.txt

But the file is not present there, https://meteobresciano.com/wxsim/plaintext-parser-lang-it.txt => 404 error

I tried use your script (for example plaintext-parser-lang-DE.txt) but doesn't work..
?? this is not my script and not my language either ??
forecast.php appears in Italian language because I have translated the few words myself. Thanks in advance Nicola
There are two translation aspects. 1. The texts from wxsim, that is handled by the plaintext.php script using a correct language file. 2. The rest of the texts should also be translated correctly, 2.1 if there is a correct plaintext-parser-lang-it.txt file. 2.2 if the Italian translations in wxsim/config.php are still correct. They start at approx. line 217
if($lang=="it"){
  define('OVERVIEW','Panoramica');
  define('DESCRIPTION','Descrizione');
  define('WSXFRC','Previsioni WXSIM per');
  define('UPDATED','Aggiornato');
  define('NXTUPDATE','Prossimo aggiornamento');
  define('FULLGRAPH','Mostra intero periodo previsionale');
  define('SELECTWUNIT','Unit&agrave;');
  define('GRAPH','Grafici');
  define('TABLE','Table');
  define('FRCGRAPH','Forecastgraph');
  define('TODAY', 'Oggi');
  define('TOMORROW','Domani');
  define('TONIGHT', 'Stasera/Notte');
  define('HUMIDITY','Umidit&agrave;');
  define('SNOW','Nevicata');
  define('TSPROB','TS-prob.');
  define('MIDNIGHTSUN','Midnight Sun');
  define('POLARNIGHT','Polar Night');
  define('POP','PoP');
  define('FEELS','Percepita');
  define('GUST','Raffica');
  define('DEWP', 'Punto di Rugiada');
  define('BARO', 'Pressione');
  define('TEMP', 'Temperatura');
  define('WIND', 'Vento');
  define('PRECIP', 'Precipitazioni');
  $days = array('Domenica','Lunedì','Martedì','Mercoledì','Giovedì','Venerdì','Sabato');
  $months = array('Gen','Feb','Mar','Apr','Mag','Giu','Lug','Ago','Set','Ott','Nov','Dic');
}

No need normally to translate if you are using 1 of the included languages from the download.

You can set the default language to use around line 65 in wxsim/config.php, these are lines 62-65, they can differ with your version:

if($_GET[lang]&&!isset($lang)){$lang=$_GET[lang];}
if($lang == "se"){$lang="sv";$oldlang = "se";}
if($lang == "dk"){$lang="da";$oldlang = "dk";}
if (!isset($lang)) { $lang = "en";}

Change the last line to always use Italian if no other language is used by the visitor.

if (!isset($lang)) { $lang = "it";}

Wim

thanks for the comprehensive reply!
I had renamed italian translation file in uppercase just for a test.

I solved with change last line:

if (!isset($lang)) { $lang = "it";}

Thank you very much for your precious support !!

Nicola