diff myrss/index.php @ 13:b1038ce571d3

add myrss/index.php; add <div.debug> to index.css
author paulo@twcdns.fastsearch.net
date Wed, 15 Sep 2010 01:30:07 -0700
parents
children 469b1e6dd364
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/myrss/index.php	Wed Sep 15 01:30:07 2010 -0700
     1.3 @@ -0,0 +1,25 @@
     1.4 +<?php
     1.5 +$start_time = microtime(true);
     1.6 +
     1.7 +$cache_fn = "__cache__.html";
     1.8 +$cache_life = "1200";
     1.9 +
    1.10 +$cache_mtime = "0";
    1.11 +if (file_exists($cache_fn))
    1.12 +	$cache_mtime = filemtime($cache_fn);
    1.13 +
    1.14 +$newbody = '';
    1.15 +
    1.16 +if ((time() - $cache_mtime >= $cache_life)) {
    1.17 +	$newbody = shell_exec('./myrss_update.sh');
    1.18 +	file_put_contents($cache_fn, $newbody);
    1.19 +} else {
    1.20 +	$newbody = file_get_contents($cache_fn);
    1.21 +}
    1.22 +
    1.23 +$end_time = microtime(true);
    1.24 +$elapsed_time = $end_time - $start_time;
    1.25 +
    1.26 +$newbody = preg_replace("/<\/BODY>/", "<DIV class=\"debug\">Time elapsed: " . sprintf("%.3f", $elapsed_time)  . " seconds.</DIV>\n</BODY>", $newbody);
    1.27 +echo $newbody;
    1.28 +?>