Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

Cumulus realtime.txt file reader

Discussion and support for 3rd-party (non-Sandaysoft) tools for Cumulus
User avatar
phtvs
Posts: 96
Joined: Sat 04 Dec 2010 10:11 am
Weather Station: ws4000
Operating System: win7
Location: Lemmer

Cumulus realtime.txt file reader

Post by phtvs »

Because I want to use the information from realtime.txt in my website script, I made this tiny script to read the realtime.txt file and put the info from that file in variables.

Usage of the script:

include the view-realtime.php in your script. Now you can use the strings to print the info on your website

for testing the script, point your browser to:
http://linktoyoursite/view-realtime.php?action=view


For more instructions, read the comments in the script.

Have fun with it!

Theo


EDIT: Filecheck added to the script.
EDIT: Made a change to the filecheck. (Thanks to Steve for the tip!)

EDIT: Made another usefull script for using with the view-realtime.php script.

EDIT: Update of the script. now without errors

This script shows a table with all the strings that are used by the view-realtime-helper.php script

Unpack the .rar with winrar and put the realtime-helper.php script in the same directory as the view-realtime.php file.

Point your browser to:

http://www.linktoyoursite/realtime-helper.php

EDIT: To show what nice things you can do with the view-realtime.php script I have made a webpage.

DEMO: http://www.weerstation-lemmer.nl/cumulu ... onsole.php

This is a weatherconsole with "live"updates. Page refreshes every 15 seconds. (Could be more or less if you want)


Have fun with it!
You do not have the required permissions to view the files attached to this post.
Last edited by phtvs on Tue 11 Jan 2011 6:32 pm, edited 13 times in total.
User avatar
robynfali
Posts: 1076
Joined: Sat 31 Jul 2010 10:34 pm
Weather Station: Vantage Vue
Operating System: Windows XP
Location: Anglesey, North Wales, UK
Contact:

Re: Cumulus realtime.txt file reader

Post by robynfali »

have uploaded it to my website


to my root weather folder, my realtime.txt file is here


http://www.h-i-r.org.uk/weather/realtime.txt

I have changed the location in your script, to this below, but get a blank page?

Code: Select all

$file_clientraw = file_get_contents("weather/realtime.txt"); // change this line if realtime.txt is at another location
$data_clientraw = explode(" ", $file_clientraw);


http://h-i-r.org.uk/weather/view-realtime.php
User avatar
phtvs
Posts: 96
Joined: Sat 04 Dec 2010 10:11 am
Weather Station: ws4000
Operating System: win7
Location: Lemmer

Re: Cumulus realtime.txt file reader

Post by phtvs »

I think you need to add this: ../ before: weather/realtime.txt

So that line must be:

../weather/realtime.txt

If that wont work you can also use this line:

http://www.h-i-r.org.uk/weather/realtime.txt


EDIT:
To test the script use your browser to go to the script like this:

http://h-i-r.org.uk/weather/view-realti ... ction=view
Last edited by phtvs on Mon 10 Jan 2011 12:50 pm, edited 1 time in total.
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Cumulus realtime.txt file reader

Post by steve »

The PHP file is already in the 'weather' directory, so presumably this would work:

$file_clientraw = file_get_contents("realtime.txt");
Steve
User avatar
phtvs
Posts: 96
Joined: Sat 04 Dec 2010 10:11 am
Weather Station: ws4000
Operating System: win7
Location: Lemmer

Re: Cumulus realtime.txt file reader

Post by phtvs »

steve wrote:The PHP file is already in the 'weather' directory, so presumably this would work:

$file_clientraw = file_get_contents("realtime.txt");

Of course...

Thanks for helping, Steve!
User avatar
robynfali
Posts: 1076
Joined: Sat 31 Jul 2010 10:34 pm
Weather Station: Vantage Vue
Operating System: Windows XP
Location: Anglesey, North Wales, UK
Contact:

Re: Cumulus realtime.txt file reader

Post by robynfali »

tried both, no luck, strange this is, when you look at the page source for the .php page, it has no coding?
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Cumulus realtime.txt file reader

Post by steve »

Looks fine from here: http://h-i-r.org.uk/weather/view-realti ... ction=view
Mozilla Firefox_2011-01-10_12-57-44.png
You do not have the required permissions to view the files attached to this post.
Steve
User avatar
phtvs
Posts: 96
Joined: Sat 04 Dec 2010 10:11 am
Weather Station: ws4000
Operating System: win7
Location: Lemmer

Re: Cumulus realtime.txt file reader

Post by phtvs »

robynfali wrote:tried both, no luck, strange this is, when you look at the page source for the .php page, it has no coding?

Seems to me that it works perfect...

Follow this link:

http://h-i-r.org.uk/weather/view-realti ... ction=view
gemini06720
Posts: 1700
Joined: Mon 10 Aug 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: Cumulus realtime.txt file reader

Post by gemini06720 »

robynfali wrote:tried both, no luck, strange this is, when you look at the page source for the .php page, it has no coding?
Rob, if you try to look at a PHP script through your browser, you should/would see nothing of the code of the script ... because the script itself is not sent to your browser but processed by your Web server and only the results are sent to your browser... ;)
User avatar
robynfali
Posts: 1076
Joined: Sat 31 Jul 2010 10:34 pm
Weather Station: Vantage Vue
Operating System: Windows XP
Location: Anglesey, North Wales, UK
Contact:

Re: Cumulus realtime.txt file reader

Post by robynfali »

didnt realise you needed the
?action=view
bit after, sorry
gemini06720
Posts: 1700
Joined: Mon 10 Aug 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: Cumulus realtime.txt file reader

Post by gemini06720 »

Theo, I have quickly looked at the code of your 'view-realtime.php' script... Once I tried it, I will probably come up with some suggestions, one of them being a check for the presence of the 'realtime.txt' before trying to read the file... ;)
User avatar
phtvs
Posts: 96
Joined: Sat 04 Dec 2010 10:11 am
Weather Station: ws4000
Operating System: win7
Location: Lemmer

Re: Cumulus realtime.txt file reader

Post by phtvs »

gemini06720 wrote:Theo, I have quickly looked at the code of your 'view-realtime.php' script... Once I tried it, I will probably come up with some suggestions, one of them being a check for the presence of the 'realtime.txt' before trying to read the file... ;)

Good idea. I was working on that part but got stuck..
Im just a beginner at php scripting ;-)

Sugestions are always welcome!!

So feel free to make the script better!
User avatar
phtvs
Posts: 96
Joined: Sat 04 Dec 2010 10:11 am
Weather Station: ws4000
Operating System: win7
Location: Lemmer

Re: Cumulus realtime.txt file reader

Post by phtvs »

Finaly got the filecheck function working...

The script checks if realtime.txt is there, if not then it displays a warning and exits from the script.

Done it the easy way, so if someone can do it better, please do!!
You do not have the required permissions to view the files attached to this post.
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Cumulus realtime.txt file reader

Post by steve »

Just a minor comment, if I may:

Code: Select all

$filename = "realtime.txt";
if (file_exists($filename)) {
//
// edit these lines when needed
//
$file_clientraw = file_get_contents("realtime.txt"); // change this line if realtime.txt is at another location
You have the realtime.txt file in twice; better to just have it once at the beginning, for the user to configure, and then use the same variable again later:

Code: Select all

$filename = "realtime.txt";  // change this line if realtime.txt is at another location

if (file_exists($filename)) {
$file_clientraw = file_get_contents($filename);
Steve
User avatar
phtvs
Posts: 96
Joined: Sat 04 Dec 2010 10:11 am
Weather Station: ws4000
Operating System: win7
Location: Lemmer

Re: Cumulus realtime.txt file reader

Post by phtvs »

So true, Steve...

Thanks for the tip. I change that and post a new rar file with the correct php file in my first post.

EDIT: updated my first post with new rar file.
Post Reply