look for ideas find out cumuluswebtags.php is be updated
Posted: Wed 17 Jun 2015 12:27 am
Hi All,
I have been thinking about this
I been look at <#DataStopped>
I like to come up with a way to see if cumuluswebtags.php is not be ftp and return a value like <#DataStopped>
I like to here ideas
Thus is what I tired then turned off u upload it shows http://n9mfk.info/newidea/mydata/realtimetest.php it shows false no mater what what did i miss
I have been thinking about this
I been look at <#DataStopped>
I like to come up with a way to see if cumuluswebtags.php is not be ftp and return a value like <#DataStopped>
I like to here ideas
Thus is what I tired then turned off u upload it shows http://n9mfk.info/newidea/mydata/realtimetest.php it shows false no mater what what did i miss
Code: Select all
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
//----------------------------------------------------------------------
// Generate JSON data for the Weather SteelSeries Gauges
// Author: Mark Crossley
//
// Ver 0.1 - 05/01/14 - Initial release, 0.X = a work in progress, breakages and changes on the fly likely!
//----------------------------------------------------------------------
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------
$timeout = 28; // Seconds to wait for file update before giving up (PHP default runtime limit is 30 seconds)
$RealtimeFilename = $_SERVER['DOCUMENT_ROOT'].'/cumuluswebtagsRealtime.php'; // realtime PHP variable file
// set up the response headers
header('Cache-Control: private');
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: text/json');
$endTime = time() + $timeout;
if (file_exists($RealtimeFilename) && time() < $endTime) {
$lastmodif = isset($_GET['timestamp']) ? $_GET['timestamp'] : 0 ;
$currentmodif = filemtime($RealtimeFilename);
while ($currentmodif <= $lastmodif) {
usleep(1000000);
clearstatcache();
$currentmodif = filemtime($RealtimeFilename);
}
if (time() >= $endTime) {
$DataStopped = 'true';
} else {
// wait 0.2 seconds for file to be closed, just in case we caught it during an update
usleep(200000);
$DataStopped = 'false';
}
}
$response = decodeCumulus($RealtimeFilename);
function decodeCumulus($RealFile) {
global $response,$DataStopped;
error_reporting(E_ALL);
try {
// incorporate the Cumulus variables
include($RealFile);
return array(
'AlltimeHighPressure' => $pressH,
'AlltimeLowPressure' => $pressL,
'AppTemp' => $apptemp,
'AvgTempToday' => $avgtemp,
'Avgbearing' => $avgbearing,
'Bearing' => $bearing,
'BearingRangeFrom10' => $BearingRangeFrom10,
'BearingRangeTo10' => $BearingRangeTo10,
'Build' => $build,
'CurrentSolarMax' => $CurrentSolarMax,
'DataStopped' => $DataStopped,
'DominantWindDirection' => $domwinddir,
'Forecast' => $forecastenc,
'HeatIndex' => $heatindex,
'HighAppTempToday' => $apptempTH,
'HighAppTempTodayTime' => $TapptempTH,
'HighBeaufortToday' => $Tbeaufort,
'HighDewpointToday' => $dewpointTH,
'HighDewpointTodayTime' => $TdewpointTH,
'HighGustBearingToday' => $bearingTM,
'HighGustToday' => $wgustTM,
'HighGustTodayTime' => $TwgustTM,
'HighHeatIndexToday' => $heatindexTH,
'HighHeatIndexTodayTime' => $TheatindexTH,
'HighHourlyRainToday' => $hourlyrainTH,
'HighHourlyRainTodayTime' => $ThourlyrainTH,
'HighHumToday' => $humTH,
'HighHumTodayTime' => $ThumTH,
'HighPressToday' => $pressTH,
'HighPressTodayTime' => $TpressTH,
'HighRainRateToday' => $rrateTM,
'HighRainRateTodayTime' => $TrrateTM,
'HighSolarRadToday' => $solarTH,
'HighSolarRadTodayTime' => $TsolarTH,
'HighTempToday' => $tempTH,
'HighTempTodayTime' => $TtempTH,
'HighUVindexToday' => $UVTH,
'HighUVindexTodayTime' => $TUVTH,
'HighWindToday' => $windTM,
'Humidex' => $humidex,
'IndoorHum' => $inhum,
'IndoorTemp' => $intemp,
'LastDataRead' => $LastDataReadT,
'LastRainTipISO' => $LastRainTipISO,
'LowAppTempToday' => $apptempTL,
'LowAppTempTodayTime' => $TapptempTL,
'LowDewpointToday' => $dewpointTL,
'LowDewpointTodayTime' => $TdewpointTL,
'LowHumToday' => $humTL,
'LowHumTodayTime' => $ThumTL,
'LowPressToday' => $pressTL,
'LowPressTodayTime' => $TpressTL,
'LowTempToday' => $tempTL,
'LowTempTodayTime' => $TtempTL,
'LowWindChillToday' => $wchillTL,
'LowWindChillTodayTime' => $TwchillTL,
'Moonrise' => $moonrise,
'Moonset' => $moonset,
'OutdoorDewpoint' => $dew,
'OutdoorHum' => $hum,
'OutdoorTemp' => $temp,
'PressTrend' => $presstrendval,
'PressUnit' => $pressunit,
'Pressure' => $press,
'RainLastHour' => $rhour,
'RainMonth' => $rmonth,
'RainRate' => $rrate,
'RainToday' => $rfall,
'RainUnit' => $rainunit,
'RainYear' => $ryear,
'RainYesterday' => $rfallY,
'Recentmaxgust' => $RecentWindGust,
'SolarRad' => $SolarRad,
'StormRain' => $StormRain,
'StormRainStart' => $StormRainStart,
'Sunrise' => $sunrise,
'Sunset' => $sunset,
'SunshineHours' => $SunshineHours,
'TempTrend' => $temptrend,
'TempUnit' => "\xc2\xb0".$tempunitnodeg,
'UVindex' => $UV,
'Version' => $version,
'WindAverage' => $wspeed,
'WindChill' => $wchill,
'WindLatest' => $wlatest,
'WindRoseData' => array_map('intval', explode(',', $WindRoseData)),
'WindRunToday' => $windrun,
'WindUnit' => $windunit,
);
} catch (Exception $e) {
return $e->getMessage() . ' line:' . $e->getLine();
}
}
// JSON encode the response
echo json_encode($response, JSON_UNESCAPED_UNICODE);
// all done!
?>