$cacheperiod); if($cache_too_old) { $url = "https://mozilla.org/firefox/notes/"; if(function_exists('curl_init')) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, 0); $str = curl_exec($ch); if(curl_error($ch)) { echo curl_error($ch); die(); } curl_close($ch); } else { // If the cURL library isn't installed, just use file_get_contents() $str = file_get_contents($url); } preg_match('/(
([0-9]|\.)+<\/div>)/', $str, $rcs); // extract the element containing the version number preg_match('/([0-9]|\.)+/', $rcs[0], $rs); // extract the version number from that $rel = $rs[0]; $link = "https://www.mozilla.org/en-US/firefox/".$rel."/releasenotes"; // construct a permalink to the patch notes for the current latest release in particular preg_match('/(

.+<\/p>)/', $str, $odcs); // extract the element containing the release date $origdate = str_replace('

', "", str_replace('

', "", $odcs[0])); // extract the date string $udate = strtotime($origdate) + 43200; // convert said date string to the unix timestamp for noon GMT on that date $rssdate = "D, d M Y H:i:s"; $date = date($rssdate, $udate); // convert unix timestamp to the date format RSS uses $updatetime = date($rssdate, filemtime($fname)); // generating some data to fill out optional elements of the RSS feed. $ttl = $cacheperiod / 60; // This is the sole reason why a few variables exist. $output = "Firefox Release Noteshttps://www.mozilla.org/firefox/releases/Release notes for new versions of Firefox, updated every $ttl minutesen-us$date$updatetimehttps://www.rssboard.org/rss-specificationniceopod's Firefox release notes RSS feed bridge$ttlhttps://upload.wikimedia.org/wikipedia/commons/8/84/Mozilla_Firefox_3.5_logo.pngFirefox Release Noteshttps://www.mozilla.org/firefox/releases/Firefox $rel$dateRelease $rel of Firefox, from $origdate$link$link"; // Outputs an RSS feed with one entry. I wanted to do the latest ten, but the releases weren't in // chronological order on the release list page and I couldn't be bothered trying to reorder them, // plus I would have had to scrape all those pages for the release date too and fuck that lol file_put_contents($fname, $output); } else { $output = file_get_contents($fname); } header('Content-Type: text/xml'); // Not sure if this is necessary but it feels like good practice and it gets Chromium to display it all pretty echo $output;