changeset 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 f93693980ead
children e92b8e5b8fd7
files myrss/FEEDS myrss/index.php weather/getweather.sh weather/index.css weather/index.php
diffstat 5 files changed, 50 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/myrss/FEEDS	Sat Jun 04 22:20:26 2011 -0700
     1.2 +++ b/myrss/FEEDS	Thu Jun 23 00:41:19 2011 -0700
     1.3 @@ -6,6 +6,7 @@
     1.4  http://feeds.sfgate.com/sfgate/rss/feeds/blogs/sfgate/warriors/index_rss2
     1.5  http://sports.yahoo.com/top/rss.xml
     1.6  http://sports.yahoo.com/blogs/rss.xml
     1.7 +http://www.grantland.com/feed
     1.8  http://rss.slashdot.org/Slashdot/slashdot
     1.9  http://www.reddit.com/.rss
    1.10  http://services.digg.com/2.0/story.getTopNews?type=rss
     2.1 --- a/myrss/index.php	Sat Jun 04 22:20:26 2011 -0700
     2.2 +++ b/myrss/index.php	Thu Jun 23 00:41:19 2011 -0700
     2.3 @@ -1,4 +1,6 @@
     2.4  <?php
     2.5 +umask(0037);
     2.6 +
     2.7  $start_time = microtime(true);
     2.8  
     2.9  $cache_fn = "__cache__.html";
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/weather/getweather.sh	Thu Jun 23 00:41:19 2011 -0700
     3.3 @@ -0,0 +1,5 @@
     3.4 +#!/bin/sh
     3.5 +
     3.6 +URL=ftp://tgftp.nws.noaa.gov/data/forecasts/zone/ca/caz043.txt
     3.7 +
     3.8 +wget -O - ${URL}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/weather/index.css	Thu Jun 23 00:41:19 2011 -0700
     4.3 @@ -0,0 +1,1 @@
     4.4 +@import "../index.css";
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/weather/index.php	Thu Jun 23 00:41:19 2011 -0700
     5.3 @@ -0,0 +1,41 @@
     5.4 +<HTML>
     5.5 +<HEAD>
     5.6 +<TITLE>Weather</TITLE>
     5.7 +<LINK REL="stylesheet" TYPE="text/css" HREF="index.css">
     5.8 +</HEAD>
     5.9 +
    5.10 +<BODY>
    5.11 +
    5.12 +<?php
    5.13 +umask(0037);
    5.14 +
    5.15 +$start_time = microtime(true);
    5.16 +
    5.17 +$cache_fn = "__cache__.txt";
    5.18 +$cache_life = "86400";
    5.19 +
    5.20 +$cache_mtime = "0";
    5.21 +if (file_exists($cache_fn) && filesize($cache_fn) > 0)
    5.22 +	$cache_mtime = filemtime($cache_fn);
    5.23 +
    5.24 +$newbody = '';
    5.25 +
    5.26 +if ((time() - $cache_mtime >= $cache_life)) {
    5.27 +	$newbody = shell_exec('./getweather.sh');
    5.28 +	file_put_contents($cache_fn, $newbody);
    5.29 +} else {
    5.30 +	$newbody = file_get_contents($cache_fn);
    5.31 +}
    5.32 +
    5.33 +$end_time = microtime(true);
    5.34 +$elapsed_time = $end_time - $start_time;
    5.35 +
    5.36 +echo "<PRE>";
    5.37 +echo $newbody;
    5.38 +echo "</PRE>";
    5.39 +
    5.40 +echo "<DIV class=\"debug\">Time elapsed: " . sprintf("%.3f", $elapsed_time)  . " seconds.</DIV>";
    5.41 +?>
    5.42 +
    5.43 +</BODY>
    5.44 +</HTML>