annotate myrss/index.php @ 36:6c10a8188375

add longreads.com to myrss/FEEDS
author paulo
date Wed, 30 Jan 2013 01:00:13 -0700
parents
children 469b1e6dd364
rev   line source
paulo@13 1 <?php
paulo@13 2 $start_time = microtime(true);
paulo@13 3
paulo@13 4 $cache_fn = "__cache__.html";
paulo@13 5 $cache_life = "1200";
paulo@13 6
paulo@13 7 $cache_mtime = "0";
paulo@13 8 if (file_exists($cache_fn))
paulo@13 9 $cache_mtime = filemtime($cache_fn);
paulo@13 10
paulo@13 11 $newbody = '';
paulo@13 12
paulo@13 13 if ((time() - $cache_mtime >= $cache_life)) {
paulo@13 14 $newbody = shell_exec('./myrss_update.sh');
paulo@13 15 file_put_contents($cache_fn, $newbody);
paulo@13 16 } else {
paulo@13 17 $newbody = file_get_contents($cache_fn);
paulo@13 18 }
paulo@13 19
paulo@13 20 $end_time = microtime(true);
paulo@13 21 $elapsed_time = $end_time - $start_time;
paulo@13 22
paulo@13 23 $newbody = preg_replace("/<\/BODY>/", "<DIV class=\"debug\">Time elapsed: " . sprintf("%.3f", $elapsed_time) . " seconds.</DIV>\n</BODY>", $newbody);
paulo@13 24 echo $newbody;
paulo@13 25 ?>