//========== SETTINGS ============================================ $RSS_URL = 'https://news.google.com/news/rss/?ned=us&gl=US&hl=en'; $CACHE_TIME_IN_HOURS = 5; $SITE_NAME = 'Daily news'; //================================================================ if(!file_exists('cache')){mkdir('cache', 0755);file_put_contents('cache'.'/'.'.htaccess', "\nDeny from all\n", LOCK_EX);} $url = $_SERVER["SCRIPT_NAME"]; $break = Explode('/', $url);$file = $break[count($break) - 1]; $cachefile = 'cache/cached-'.substr_replace($file ,"",-4).'.html'; $cachetime = 60*60*$CACHE_TIME_IN_HOURS; if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) { include($cachefile); exit;}ob_start(); echo ''.$SITE_NAME.'' . ''; echo RetRSS($RSS_URL);echo ''; $cached = fopen($cachefile, 'w');fwrite($cached, ob_get_contents());fclose($cached);ob_end_flush(); function RetRSS($url){global $rss; $rss = simplexml_load_file($url); foreach ($rss->channel->item as $item) { $ribbon .= '

'.$item->title.'

'; $ribbon .= $item->description; $ribbon .= '

';}return $ribbon;} ?>