properly exit script if no version was detected, for drupal and wordpress (courtesy WvR)

This commit is contained in:
florian
2013-10-15 20:01:44 +00:00
parent 8e4436f9de
commit 5ecd250bac
2 changed files with 11 additions and 8 deletions

View File

@@ -15,12 +15,11 @@ $context = stream_context_create(array(
$data = file_get_contents($url, FALSE, $context);
if($data)
$feed = simplexml_load_string($data);
if($feed && $feed instanceof SimpleXMLElement) {
// Check the property exists and assign
if( isset($feed->releases->release[0]->version) ) {
$dr_current = $feed->releases->release[0]->version;
// return $latest;
}
if($feed && $feed instanceof SimpleXMLElement && isset($feed->releases->release[0]->version)) {
$dr_current = $feed->releases->release[0]->version;
verbose("Current Drupal version: $dr_current", 1);
} else {
die("Unable to determine current Drupal version, exiting\n");
}
verbose("Current Drupal version: $dr_current", 1);

View File

@@ -5,8 +5,12 @@ require_once("toolkit.php");
// Retrieve current Wordpress version from http://api.wordpress.org/core/version-check/1.6/
//
$wp_api = unserialize(file_get_contents("http://api.wordpress.org/core/version-check/1.6/"));
$wp_current = $wp_api['offers'][0]['current'];
verbose("Current Wordpress version: $wp_current", 1);
if( isset($wp_api['offers'][0]['current']) ) {
$wp_current = $wp_api['offers'][0]['current'];
verbose("Current Wordpress version: $wp_current", 1);
} else {
die("Unable to determine current Wordpress version, exiting\n");
}
checkHost(null, $wp_current);
if( $hosts != null ) {