Mercurial > hg > index.fcgi > www > www-1
annotate myrss/index.php @ 129:bd8a61f9162f
myrss2: add San Mateo Daily Journal to FEEDS
author | paulo |
---|---|
date | Tue, 11 Jan 2022 02:36:16 -0800 |
parents | f93693980ead |
children |
rev | line source |
---|---|
paulo@13 | 1 <?php |
paulo@28 | 2 umask(0037); |
paulo@28 | 3 |
paulo@13 | 4 $start_time = microtime(true); |
paulo@13 | 5 |
paulo@13 | 6 $cache_fn = "__cache__.html"; |
paulo@13 | 7 $cache_life = "1200"; |
paulo@13 | 8 |
paulo@13 | 9 $cache_mtime = "0"; |
paulo@20 | 10 if (file_exists($cache_fn) && filesize($cache_fn) > 0) |
paulo@13 | 11 $cache_mtime = filemtime($cache_fn); |
paulo@13 | 12 |
paulo@13 | 13 $newbody = ''; |
paulo@13 | 14 |
paulo@13 | 15 if ((time() - $cache_mtime >= $cache_life)) { |
paulo@27 | 16 $newbody = shell_exec('./myrss_update.sh 2>&1'); |
paulo@13 | 17 file_put_contents($cache_fn, $newbody); |
paulo@13 | 18 } else { |
paulo@13 | 19 $newbody = file_get_contents($cache_fn); |
paulo@13 | 20 } |
paulo@13 | 21 |
paulo@13 | 22 $end_time = microtime(true); |
paulo@13 | 23 $elapsed_time = $end_time - $start_time; |
paulo@13 | 24 |
paulo@13 | 25 $newbody = preg_replace("/<\/BODY>/", "<DIV class=\"debug\">Time elapsed: " . sprintf("%.3f", $elapsed_time) . " seconds.</DIV>\n</BODY>", $newbody); |
paulo@13 | 26 echo $newbody; |
paulo@13 | 27 ?> |