Skip to content

Instantly share code, notes, and snippets.

@philip
Created June 21, 2016 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philip/9385ac1d47f10dea60e70a3fd27c54de to your computer and use it in GitHub Desktop.
Save philip/9385ac1d47f10dea60e70a3fd27c54de to your computer and use it in GitHub Desktop.
Test installer manifest dates, report dates and releases since last mod date
<?php
$url = "http://cdn.mysql.com/windows/installer/manifest.zip";
$headers = get_headers($url, true);
if ($headers && false !== strpos($headers[0], '200') && !empty($headers['Last-Modified'])) {
$lastmod = new \DateTime($headers['Last-Modified']);
$today = new \DateTime;
$daysold = $lastmod->diff($today)->days;
$s = ($daysold === 1) ? 's' : '';
echo "Manifest was last updated {$daysold}{$s} days ago on " . $lastmod->format("Y-m-d") . PHP_EOL;
echo "Today is: " . $today->format("Y-m-d") . PHP_EOL;
echo "Releases since manifest was last updated" . PHP_EOL;
get_last_releases_since_date($lastmod);
}
function get_last_releases_since_date($date, $max = 30) {
$url = "http://dev.mysql.com/downloads/rss.php";
$rss = simplexml_load_file($url);
$i = 1;
foreach($rss->channel->item as $item) {
if ($i++ < $max) {
$release_date = new \DateTime($item->pubDate);
$interval = $release_date->diff($date);
if ($interval->invert === 1) {
echo $item->description . PHP_EOL;
} else {
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment