|
|
|
saratogaWX
|
 |
« Reply #1 on: November 21, 2008, 06:15:21 PM » |
|
Mine is fairly specific to my setup, but you're welcome to the code .. some adaptation will be necessary for your setup, I'm sure  Enjoy! and best regards, Ken <div id="content"> <h1 id="pageName">Saratoga-Weather.org Weather Station Status </h1> <div class="story"> <?php include_once("version-info.php"); include_once("testtags.php"); include_once("WeatherLinktags.php"); // for the Weatherlink specific stuff putenv("TZ=PST8PDT"); function check_file($chkfile,$maxFileSecs) { $timeFormat = 'd-M-Y g:i:sa T'; $now = time(); if (file_exists($chkfile)) { $age = $now - filemtime($chkfile); $updateTime = date($timeFormat,filemtime($chkfile)); } else { $age = 'unknown'; $updateTime = 'file not found'; } $status = ''; print "<!-- $chkfile age = $age secs. -->\n"; if (file_exists($chkfile) and (filemtime($chkfile) + $maxFileSecs > $now) ) { // stale file $status = "<span style=\"color: green\"><b>Current</b></span>\t$age\t$updateTime ";
} else { $status = "<span style=\"color: red\"><b>NOT Current</b></span>\t$age\t > $maxFileSecs secs <br/><b>$updateTime</b>"; } return($status);
} function check_applic($applTime,$maxFileSecs) { $timeFormat = 'd-M-Y g:i:sa T'; $now = time(); $age = $now - $applTime; $updateTime = date($timeFormat,$applTime); $status = ''; print "<!-- $chkfile age = $age secs. -->\n"; if ($applTime + $maxFileSecs > $now ) { // stale file $status = "<span style=\"color: green\"><b>Current</b></span>\t$age\t$updateTime ";
} else { $status = "<span style=\"color: red\"><b>NOT Current</b></span>\t$age\t > $maxFileSecs secs <br/><b>$updateTime</b>"; } return($status);
}
?> <p>This page shows the current status of the weather software used in the operation of this website.<br/><br/> Station system up for <b><?php print $windowsuptime; ?></b><br/> Station system free memory <b><?php print $freememory; ?></b><br/> Weather Display last started <b><?php print $Startimedate; ?></b><br/></p>
<table width="100%" border="1" cellspacing="3" cellpadding="2"> <tr> <th width="40%" scope="col">Component</th> <th width="15%" scope="col" align="center">Status</th> <th width="5%" scope="col" align="center">Age<br />Secs</th> <th width="40%" scope="col">Latest update time as of<br/> <?php print date('d-M-Y g:i:sa T',time()); ?></th> </tr> <tr> <td><a href="http://www.weather-display.com/">Weather Display</a> (<?php echo $wdversion; ?>) realtime </td> <?php list($stat,$age,$data) = explode("\t",check_file('clientraw.txt',15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td><a href="http://www.weather-display.com/">Weather Display</a> (<?php echo $wdversion; ?>) FTP </td> <?php list($stat,$age,$data) = explode("\t",check_file('testtags.php',60*5+15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td><a href="http://www.davisnet.com/weather/products/weather_product.asp?pnum=06510SER">WeatherLink</a> (<?php echo $WLversion; ?>) FTP </td> <?php list($stat,$age,$data) = explode("\t",check_file('NOAAMO.TXT',60*5+15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td><a href="http://www.ambientweather.com/virtualstation.html">VWS</a> (<?php echo $VWS_version; ?>) WeatherFlash realtime </td> <?php list($stat,$age,$data) = explode("\t",check_file('./wflash/Data/wflash.txt',15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td><a href="http://www.ambientweather.com/virtualstation.html">VWS</a> (<?php echo $VWS_version; ?>) FTP </td> <?php list($stat,$age,$data) = explode("\t",check_file('./AJAX/VWS/usa-V2.htm',60*5+15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td colspan="4"><?php include_once("radar-status-kt.php"); ?></td> </tr> <tr> <td><a href="http://www.grlevelx.com/grlevel3/">GRLevel3</a> (<?php echo $GRLEVEL3_version; ?>) Radar FTP </td> <?php list($stat,$age,$data) = explode("\t",check_file('./GR3/kmux_cr248_0.jpg',60*10+15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td><a href="http://www.astrogenic.com/nexstorm.html">NexStorm</a> (<?php echo $NEXSTORM_version; ?>) Lightning Map </td> <?php list($stat,$age,$data) = explode("\t",check_file('nexstorm.jpg',10*60+15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td><a href="http://www.astrogenic.com/nexstorm.html">NexStorm</a> (<?php echo $NEXSTORM_version; ?>) TRACreport</td> <?php list($stat,$age,$data) = explode("\t",check_file('TRACReport.txt',10*60+15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td><a href="http://www.astrogenic.com/nexstorm.html">NexStorm</a> (<?php echo $NEXSTORM_version; ?>) Data </td> <?php list($stat,$age,$data) = explode("\t",check_file('nexstorm_arc.dat',10*60+15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td>WASP2 (<?php echo $WASP2_version; ?>) Lightning Map<br />upload </td> <?php list($stat,$age,$data) = explode("\t",check_file('./WASP2/wasp2.png',10*60+15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td><a href="http://www.imagesalsa.com/download.htm">ImageSalsa</a> (<?php echo $IMAGESALSA_version; ?>) Netcam FTP </td> <?php list($stat,$age,$data) = explode("\t",check_file('netcam-thumb.jpg',25)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td><a href="http://www.wxsim.com/">WXSIM</a> (<?php echo $WXSIM_version; ?>) Forecast </td> <?php $doPrint = false; include_once("plaintext-parser.php"); print "<!-- wdate='$wdate' -->\n"; $lastWXSIM = strtotime($wdate); ?> <?php list($stat,$age,$data) = explode("\t",check_applic($lastWXSIM,4*60*60 + 2*60)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td>Cron animation WASP2 </td> <?php list($stat,$age,$data) = explode("\t",check_file('./WASP2/status.txt',60*10+15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td>Cron graphs</td> <?php list($stat,$age,$data) = explode("\t",check_file('./WDS/rain.png',60*5+15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td>Cron SWN mesomap</td> <?php list($stat,$age,$data) = explode("\t",check_file('./SWN-cache.html',60*5+15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr> <tr> <td>Cron WD conditions logger</td> <?php list($stat,$age,$data) = explode("\t",check_file('./WD-conditions.html',60*5+15)); ?> <td align="center"><?php echo $stat; ?></td> <td align="right"><?php echo $age; ?></td> <td><?php echo $data; ?></td> </tr>
</table> <p> </p> </div> </div>
My version-info.php has <?php // allow viewing of generated source
if ( isset($_REQUEST['sce']) && strtolower($_REQUEST['sce']) == 'view' ) { //--self downloader -- $filenameReal = __FILE__; $filenameLcl = substr($PHP_SELF,1); $download_size = filesize($filenameReal); header('Pragma: public'); header('Cache-Control: private'); header('Cache-Control: no-cache, must-revalidate'); header("Content-type: text/plain"); header("Accept-Ranges: bytes"); header("Content-Length: $download_size"); header('Connection: close'); readfile($filenameReal); exit; }
// Version info for Saratoga-weather.org
$GRLEVEL3_version = '1.41'; $NEXSTORM_version = '1.6.0.2553'; $WASP2_version = '2.2.3167.20051'; $WXSIM_version = '12.2'; $WXSIMATE_version = '4.2'; $STARTWATCH_version = '1.0.2'; $VIRTUALVP_version = '1.1.4'; $IMAGESALSA_version = '2.0.13'; $MOVIESALSA_version = '1.0.14'; $ODDCAST_version = '3 (25-Aug-2006)'; $VWS_version = '13.01 p09';
?>
|
|
|
|
|
Logged
|
Ken True/Saratoga, CA saratoga-weather.orgDavis Vantage Pro Plus - FARS, Boltek-PCI/NexStorm, GRLevel3 Free weather PHP scripts/website templates 
|
|
|
|
Mark / Ohio
|
 |
« Reply #2 on: November 21, 2008, 06:33:58 PM » |
|
Thanks for posting your code Ken! I've wanted to do something like that myself mainly for ease of my own reference to check on things while away from home.
|
|
|
|
|
Logged
|
Mark2002 Davis VP I Wireless, WeatherLink (Serial), VWS, ImageSalsa, GRLevel3, VirtualVP, VPLive, StartWatch, Windows XP (SP3)

|
|
|
|
jwyman
Guest
|
 |
« Reply #3 on: November 21, 2008, 11:12:17 PM » |
|
If anyone is interested, I will make this available.... Just let me know.. I will probably post it on my scripts page.... Jim
|
|
|
|
|
Logged
|
|
|
|
|
jwwd
|
 |
« Reply #4 on: November 22, 2008, 01:32:52 AM » |
|
Hi What a great script - I have modified it to my site: http://www.silkeborg-vejret.dk/english/om.phpHow do I get the time in the right timezone? GMT is 1 hour behind our normaltime here in Denmark. And how do I get the time in 24-hour timeformat? Here is the code: <?php include_once("1version-info.php");
putenv("TZ=DK"); function check_file($chkfile,$maxFileSecs) { $timeFormat = 'd-M-Y g:i:sa T'; $now = time(); if (file_exists($chkfile)) { $age = $now - filemtime($chkfile); $updateTime = date($timeFormat,filemtime($chkfile)); } else { $age = 'unknown'; $updateTime = 'file not found'; } $status = ''; print "<!-- $chkfile age = $age secs. -->\n"; if (file_exists($chkfile) and (filemtime($chkfile) + $maxFileSecs > $now) ) { // stale file $status = "<span style=\"color: green\"><b>Opdateret</b></span>\t$age\t$updateTime ";
} else { $status = "<span style=\"color: red\"><b>IKKE opdateret</b></span>\t$age\t > $maxFileSecs secs <br/><b>$updateTime</b>"; } return($status);
} function check_applic($applTime,$maxFileSecs) { $timeFormat = 'd-M-Y g:i:sa T'; $now = time(); $age = $now - $applTime; $updateTime = date($timeFormat,$applTime); $status = ''; print "<!-- $chkfile age = $age secs. -->\n"; if ($applTime + $maxFileSecs > $now ) { // stale file $status = "<span style=\"color: green\"><b>Opdateret</b></span>\t$age\t$updateTime ";
} else { $status = "<span style=\"color: red\"><b>IKKE opdateret</b></span>\t$age\t > $maxFileSecs secs <br/><b>$updateTime</b>"; } return($status);
}
?> Best regards, Henrik
|
|
|
|
« Last Edit: November 22, 2008, 03:35:07 AM by jwwd »
|
Logged
|
  Davis Vantage Pro2 w/FARS & solarsensor. Boltek LD-250 Lightningdetector
|
|
|
|
saratogaWX
|
 |
« Reply #5 on: November 22, 2008, 01:41:58 AM » |
|
Hi Henrik! Use putenv("TZ=Europe/Copenhagen"); and $timeFormat = 'd-M-Y H:i:s T'; or roll-your-own using the http://us3.php.net/manual/en/function.date.php docs  Best regards, Ken
|
|
|
|
|
Logged
|
Ken True/Saratoga, CA saratoga-weather.orgDavis Vantage Pro Plus - FARS, Boltek-PCI/NexStorm, GRLevel3 Free weather PHP scripts/website templates 
|
|
|
|
jwwd
|
 |
« Reply #6 on: November 22, 2008, 02:01:34 AM » |
|
Hi Ken
Thank you very much - now its working the way I like it.
Take care and say hi to Holly from me.
Best regards,
Henrik
|
|
|
|
|
Logged
|
  Davis Vantage Pro2 w/FARS & solarsensor. Boltek LD-250 Lightningdetector
|
|
|
|
jwwd
|
 |
« Reply #7 on: November 22, 2008, 03:38:54 AM » |
|
Hi again I have it up and running: http://www.silkeborg-vejret.dk/english/om.phpJust one last thing: Would it be possible to recalculate the seconds into hours, minutes and seconds? Example: My plaintext is set to be uploaded every 3 hours + 2 minutes (10,920 seconds) - that would be nice to present in hours and minutes instead. Best regards, Henrik
|
|
|
|
|
Logged
|
  Davis Vantage Pro2 w/FARS & solarsensor. Boltek LD-250 Lightningdetector
|
|
|
|
ADM
|
 |
« Reply #8 on: November 22, 2008, 07:26:07 AM » |
|
Thanks to all for your responses, I appreciate them! Al... www.RockyCreekWeather.com
|
|
|
|
|
Logged
|
|
|
|
|
jwyman
Guest
|
 |
« Reply #9 on: November 22, 2008, 03:50:36 PM » |
|
For those interested in the script , you can get it from espwxctr.coml Go to INFO -> SCRIPTS section. You will see it at the bottom of the page.. Enjoy!
Jim
|
|
|
|
|
Logged
|
|
|
|
|
Mark / Ohio
|
 |
« Reply #10 on: November 22, 2008, 10:20:27 PM » |
|
Thanks for sharing your script with us Jim! I saved a copy of it for future reference as well. 
|
|
|
|
|
Logged
|
Mark2002 Davis VP I Wireless, WeatherLink (Serial), VWS, ImageSalsa, GRLevel3, VirtualVP, VPLive, StartWatch, Windows XP (SP3)

|
|
|
|
jwwd
|
 |
« Reply #11 on: November 23, 2008, 01:02:11 AM » |
|
Hi Jim Thank you very much for sharing your script. I have it up and running - but I just cant figure out why the script keeps presenting the upload frequency in minutes - see example here: http://www.silkeborg-vejret.dk/om.phpI have tried your script without any changeds - and I have tried modifying the dateformat - here is the code: <?PHP
// System Status Report Script // Author: Jim Wyman // Date: 11/11/2008 // Esperanza Weather Center // www.espwxctr.com //
if (isset($_REQUEST['sce']) && strtolower($_REQUEST['sce']) == 'view' ) { //--self downloader -- $filenameReal = $_SERVER["SCRIPT_FILENAME"]; $download_size = filesize($filenameReal); header('Pragma: public'); header('Cache-Control: private'); header('Cache-Control: no-cache, must-revalidate'); header("Content-type: text/plain"); header("Accept-Ranges: bytes"); header("Content-Length: $download_size"); header('Connection: close'); readfile($filenameReal); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> .style11 { color: #FFFFFF; font-family: Arial; border-width: 1px; background-color: #666699; } .style22 { font-family: Cambria; font-size: small; border-width: 1px; background-color: #5B9CC6; } .style44 { font-family: Cambria; font-size: small; border-width: 1px; background-color: #99CCFF; } .style55 { font-family: Cambria; font-weight: bold; } .style66 { font-family: Cambria; } </style> </head> <body style="background-color: #ffffff">
<?PHP date_default_timezone_set("Europe/Copenhagen");?> <!--Change to your time zone, see scripts website for help identifying your timezone--> <span class="style66">The current data and time is: </span><span class="style55"><?PHP echo date("d-m-y H:i:s T");?></span><br/><br/> <table border cellspacing=0 cellpadding=5> <tr bgcolor=#D0D0D0><th class="style11">Application<th class="style11">Uploaded Files<th class="style11">Upload Frequency<th class="style11">Last Upload<th class="style11">Time Since Upload</tr>
<!-- Here we process the entries in the array - one routine to handle 1 or many files. --> <?PHP
$application = array ("Weather Display","Weather Display","WXSIM","Webcam"); $filename = array ("vejrdata/clientraw.txt","vejrdata/testtags.php","vejrudsigt/1plaintext.txt","vejrdata/jpgwebcam.jpg"); $upload_time_secs = array (5,300,10800,300);
if(count($application) != count($filename)) echo "Array Dimension Error"; if(count($upload_time_secs) != count($filename)) echo "Array Dimension Error"; if(count($upload_time_secs ) != count($application)) echo "Array Dimension Error";
for($i=0;$i<=count($application)-1;$i++){
$pos = strrpos($filename[$i],"/"); if($pos > 0 ) $trunc_filename = substr($filename[$i],$pos+1); else $trunc_filename = $filename[$i]; echo '<tr><td align=center class="style22">' . $application[$i] . '<td align=center class="style22">' . $trunc_filename . ' <td align=center class="style22">' . strval($upload_time_secs[$i]/60) . ' Minutes</td>'; echo '<td class="style22">'. date("d-m-y H:i:s T", filectime($filename[$i])) . '</td>'; echo '<td align=center class="style44">'; $tdiffsecs = timediffsecs ($filename[$i]); $tdiff = timediff($filename[$i]); if ($tdiffsecs > $upload_time_secs[$i]){ echo $tdiff . ' <img src="billeder/answer_bad.gif" align="middle"></img>'; } else echo $tdiff . ' <img src="billeder/answer_good.gif" align="middle"></img>'; echo '</td></tr>'; } ?>
</table>
<?PHP //========================================================================== // Function timediff - Shawn Curran - CastleRockWeather.org // version: 1.0 - 08/11/08 - Initial Release // version: 1.1 - 09/03/08 - Public Released version // Description: This function calculates the number of seconds, minutes, // hours, or days since the file's timestamp has been written. This works // well for files uploaded to your website via FTP, since the timestamp // reflects when the file was last written to the server with FTP client. //========================================================================== function timediff ($filepath) { //Get time stamp of file $t = date("dmyHis", filectime($filepath)); //Split $t into month, day, and year values $d = substr($t, 2, 2); $m = substr($t, 0, 2); $y = substr($t, 4, 2); $h = substr($t, 6, 2); $min = substr($t, 8, 2); $s = substr($t, 10, 2); $timestamp = mktime($h, $min, $s, $d, $m, $y); $tdiff = mktime() - $timestamp; //Subtrack $timestamp from now, give us diff in seconds. //Determin how to display by size of timediff if ($tdiff < 60) { //Timediff is less then 1 minute, so must be seconds $tdiff=number_format($tdiff); return $tdiff." sec"; } elseif ($tdiff < 3600) { //timediff is less then 1 hour, so must be minutes $tdiff=$tdiff/60; $tdiff=number_format($tdiff, 1, '.', ''); return $tdiff." min"; } elseif ($tdiff < 86400) { //timediff is less then 1 day, so must be hours. $tdiff=($tdiff/60)/60; $tdiff=number_format($tdiff, 1, '.', ''); return $tdiff." hr"; } elseif ($tdiff < 604800){ //timediff is greater then 1 day, so must be days. $tdiff=(($tdiff/60)/60)/24; $tdiff=number_format($tdiff, 1, '.', ''); return $tdiff." days"; }else{ //timediff is greater then 1 day, so must be days. $tdiff=(($tdiff/60)/60)/24/7; $tdiff=number_format($tdiff, 1, '.', ''); return $tdiff." weeks"; }
} ?><?PHP //========================================================================== // Function timediffsecs - Jim Wyman - espwxctr.com // derived from the above function timediff() //========================================================================== function timediffsecs ($filepath) { //Get time stamp of file $t = date("mdyHis", filectime($filepath)); //Split $t into month, day, and year values $d = substr($t, 2, 2); $m = substr($t, 0, 2); $y = substr($t, 4, 2); $h = substr($t, 6, 2); $min = substr($t, 8, 2); $s = substr($t, 10, 2); $timestamp = mktime($h, $min, $s, $d, $m, $y); $tdiff = mktime() - $timestamp; //Subtrack $timestamp from now, give us diff in seconds. return $tdiff; } ?> </body>
</html> Could it be some kind of timezone problem? Best regards, Henrik
|
|
|
|
« Last Edit: December 24, 2008, 01:45:18 AM by jwwd »
|
Logged
|
  Davis Vantage Pro2 w/FARS & solarsensor. Boltek LD-250 Lightningdetector
|
|
|
|
jwyman
Guest
|
 |
« Reply #12 on: November 23, 2008, 07:06:57 AM » |
|
Henrik, I made a modification to the script last night to show seconds if the upload frequency is under 60 seconds. download it again and try it out.... Had one other person test it and it works great ofr them. Let me know if you have any problems...
Jim
|
|
|
|
|
Logged
|
|
|
|
|
jwwd
|
 |
« Reply #13 on: November 23, 2008, 10:05:59 AM » |
|
Hi Jim Thanks for your reply. I have it up and running now. I would like to have a href tag in the first array - would that be possible? Example: Weather Display - I would like to link to www.weather-display.com. One thing more: If one of the files dont excist - then the script returns and error - see example here: http://www.silkeborg-vejret.dk/1nyom.phpBest regards, Henrik
|
|
|
|
« Last Edit: November 23, 2008, 03:36:45 PM by jwwd »
|
Logged
|
  Davis Vantage Pro2 w/FARS & solarsensor. Boltek LD-250 Lightningdetector
|
|
|
|
BillW69
|
 |
« Reply #14 on: November 23, 2008, 12:07:32 PM » |
|
Ken, I am using IE8 beta. When I go to your site here.... http://saratoga-weather.org/status.php The drop down menus only show up as black boxes. There is no text in them, nor can I click on anything in them. If I use 'compatability mode, all works correctly. I just thought I'd let you know. Bill
|
|
|
|
|
Logged
|
|
|
|
|