Mercurial > hg > index.fcgi > www > www-1
diff weather/index.php @ 28:28221b9bb370
add weather/; update myrss/FEEDS; add umask(0037) to weather/index.php and myrss/index.php
author | paulo@thepaulopc |
---|---|
date | Thu, 23 Jun 2011 00:41:19 -0700 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/weather/index.php Thu Jun 23 00:41:19 2011 -0700 1.3 @@ -0,0 +1,41 @@ 1.4 +<HTML> 1.5 +<HEAD> 1.6 +<TITLE>Weather</TITLE> 1.7 +<LINK REL="stylesheet" TYPE="text/css" HREF="index.css"> 1.8 +</HEAD> 1.9 + 1.10 +<BODY> 1.11 + 1.12 +<?php 1.13 +umask(0037); 1.14 + 1.15 +$start_time = microtime(true); 1.16 + 1.17 +$cache_fn = "__cache__.txt"; 1.18 +$cache_life = "86400"; 1.19 + 1.20 +$cache_mtime = "0"; 1.21 +if (file_exists($cache_fn) && filesize($cache_fn) > 0) 1.22 + $cache_mtime = filemtime($cache_fn); 1.23 + 1.24 +$newbody = ''; 1.25 + 1.26 +if ((time() - $cache_mtime >= $cache_life)) { 1.27 + $newbody = shell_exec('./getweather.sh'); 1.28 + file_put_contents($cache_fn, $newbody); 1.29 +} else { 1.30 + $newbody = file_get_contents($cache_fn); 1.31 +} 1.32 + 1.33 +$end_time = microtime(true); 1.34 +$elapsed_time = $end_time - $start_time; 1.35 + 1.36 +echo "<PRE>"; 1.37 +echo $newbody; 1.38 +echo "</PRE>"; 1.39 + 1.40 +echo "<DIV class=\"debug\">Time elapsed: " . sprintf("%.3f", $elapsed_time) . " seconds.</DIV>"; 1.41 +?> 1.42 + 1.43 +</BODY> 1.44 +</HTML>