annotate weather/index.php @ 29:e92b8e5b8fd7

myrss/step1.xsl: fix bug with Digg feeds
author paulo@thepaulopc
date Sun, 04 Sep 2011 13:13:03 -0700
parents
children
rev   line source
paulo@28 1 <HTML>
paulo@28 2 <HEAD>
paulo@28 3 <TITLE>Weather</TITLE>
paulo@28 4 <LINK REL="stylesheet" TYPE="text/css" HREF="index.css">
paulo@28 5 </HEAD>
paulo@28 6
paulo@28 7 <BODY>
paulo@28 8
paulo@28 9 <?php
paulo@28 10 umask(0037);
paulo@28 11
paulo@28 12 $start_time = microtime(true);
paulo@28 13
paulo@28 14 $cache_fn = "__cache__.txt";
paulo@28 15 $cache_life = "86400";
paulo@28 16
paulo@28 17 $cache_mtime = "0";
paulo@28 18 if (file_exists($cache_fn) && filesize($cache_fn) > 0)
paulo@28 19 $cache_mtime = filemtime($cache_fn);
paulo@28 20
paulo@28 21 $newbody = '';
paulo@28 22
paulo@28 23 if ((time() - $cache_mtime >= $cache_life)) {
paulo@28 24 $newbody = shell_exec('./getweather.sh');
paulo@28 25 file_put_contents($cache_fn, $newbody);
paulo@28 26 } else {
paulo@28 27 $newbody = file_get_contents($cache_fn);
paulo@28 28 }
paulo@28 29
paulo@28 30 $end_time = microtime(true);
paulo@28 31 $elapsed_time = $end_time - $start_time;
paulo@28 32
paulo@28 33 echo "<PRE>";
paulo@28 34 echo $newbody;
paulo@28 35 echo "</PRE>";
paulo@28 36
paulo@28 37 echo "<DIV class=\"debug\">Time elapsed: " . sprintf("%.3f", $elapsed_time) . " seconds.</DIV>";
paulo@28 38 ?>
paulo@28 39
paulo@28 40 </BODY>
paulo@28 41 </HTML>