Thanks, Tim.
Well, I'm trying to stay within the confines of the original submit_weather.php file rather than reinvent the wheel there. If you look at the original submit_weather.php file in Lightsoft (I'm fairly certain the file in LWC is the same as in WC) it reads:
<?php
// Script by Lightsoft -
http://www.lightsoft.co.uk // Use with LWC Custom CGI feature
//
// Provides receipt of weather data to the server and stores in a simple file. Has to be a server side
// script but theoretically need not be PHP. Other options are Perl CGI, Python, etc - depending upon
// what your web server supports.
//
// We assume security of the username/password is not critical (sent as plain text). We limit what
// data we accept and try to ensure all sequences from the GET are properly stripped before use
// on a web page.
//
// We use a GET rather than POST since data is very limited and doesn't overly affect server operation.
//
$success = 0;
$line_end = "<br>\r\n";
if(htmlspecialchars($_GET['action']) === 'update') // what do we want to do?
{
if(htmlspecialchars($_GET['ID']) === 'joeblog') // the user name allowed to update the data (***CHANGE THIS!***)
{
if(htmlspecialchars($_GET['PASSWORD']) === 'xxxxxx') // the password of that user (***CHANGE THIS!***)
{
$output = "";
$output .= "Date (UTC): " . htmlspecialchars($_GET['dateutc']) . $line_end; // 2008-02-10+11%3A20%3A39
$output .= "Wind dir (deg): " . (float)($_GET['winddir']) . $line_end; // 230
$output .= "Wind Speed (mph): " . (float)($_GET['windspeedmph']) . $line_end; //12
$output .= "Wind Speed (mphAv10mins): " . (float)($_GET['windspeedmphav_10m']) . $line_end; //12
$output .= "Wind Gust (mph): " . (float)($_GET['windgustmph']) . $line_end; // 12
$output .= "Wind Gust (dir): " . (float)($_GET['windgustdir']) . $line_end; // 12
$output .= "Wind Gust (mph10mins): " . (float)($_GET['windgustmph_10m']) . $line_end; // 12
$output .= "Wind Gust (dir10mins): " . (float)($_GET['windgustdir_10m']) . $line_end; // 12
$output .= "Humidity: " . (float)($_GET['humidity']) . $line_end; // 90
$output .= "Dew Point (F): " . (float)($_GET['dewptf']) . $line_end; // 68.2
$output .= "Temp (F): " . (float)($_GET['tempf']) . $line_end; // 12
$output .= "Rain (in): " . (float)($_GET['raininch']) . $line_end; // 0
$output .= "Rain24h (in): " . (float)($_GET['rain24hinch']) . $line_end; // 0
$output .= "Barom (in): " . (float)($_GET['baroinch']) . $line_end; // 29.1
$output .= "Conditions: " . htmlspecialchars($_GET['weather']) . $line_end; // Sunny
//echo $output; // for testing
if(($handle = fopen("weather_data.txt","wb")) !== FALSE)
{
$write_status = fwrite($handle, $output); // we ignore write status (FALSE on fail or bytes written)
$close_status = fclose($handle); // we ignore close status (FALSE failure, TRUE on success)
$success = 1;
}
}
}
}
if($success==0)
{
echo 'Fail';
}
else
{
echo 'OK';
}
?>
As you can see it outputs a txt file which is ultimately read as an HTML page. If you look at the second line down from the comments, you'll see: $line_end = "<br>\r\n";
This inserts a <br> into the text code so when the page is read via an HTML, each output line is on a separate line. But since I'm not interested in reading the file as an HTML, this isn't desirable.
I'm going to be rewriting this php file so it essentially creates this file almost exactly:
<slickboard>
<object offset_x='240' offset_y='75'>
<text x='-5' y='-28' size='12'>N</text>
<text x='-5' y='0' size='17' color='88ff00'>6</text>
<circle x='0' y='0' radius='30' fill_alpha='0' line_thickness='5' shadow='default' />
<radial_ticks x='0' y='0' radius='33' start='0' end='90' count='8' color='444444' length='6' thickness='2' />
<object>
<line x1='0' y1='-40' x2='0' y2='-30' color='ff3300' thickness='4' shadow='default' />
<rotate x='0' y='0' start='230' span='175' step='5' shake_span='0' />
</object>
</object>
</slickboard>
That's what I want the submit_weather.php file to build (there will have to be some variable input here, but in essence this is what I'm looking for).
So, how to get the current php file to do this? How to get it to build that xml file. Is there something similar in PHP to the <br> that will force a new line for each "output" line in the submit_weather.php file? See?