Skip to content

Commit

Permalink
Update getLiveVersion method
Browse files Browse the repository at this point in the history
This method was only using file_get_contents to retrieve the most current version number, but if someone's web server has allow_url_fopen disabled this won't work, so I added cURL as a backup
  • Loading branch information
chetcuti committed Apr 11, 2017
1 parent 95f179a commit 087ca5a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion classes/DomainMOD/System.php
Expand Up @@ -48,6 +48,8 @@ public function checkVersion($connection, $current_version)
$_SESSION['s_system_upgrade_available'] = '1';
$message = $this->getUpgradeMessage();
} else {
$sql = "UPDATE settings SET upgrade_available = '0'";
mysqli_query($connection, $sql);
$_SESSION['s_system_upgrade_available'] = '0';
$message = "No Upgrade Available";
}
Expand All @@ -56,7 +58,19 @@ public function checkVersion($connection, $current_version)

public function getLiveVersion()
{
return file_get_contents('https://raw.githubusercontent.com/domainmod/domainmod/master/version.txt');
$version_file = 'https://raw.githubusercontent.com/domainmod/domainmod/master/version.txt';
$version_fgc = file_get_contents($version_file);
if ($version_fgc) {
$live_version = $version_fgc;
} else {
$handle = curl_init();
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_URL, $version_file);
$result = curl_exec($handle);
curl_close($handle);
$live_version = $result;
}
return $live_version;
}

public function getUpgradeMessage()
Expand Down

0 comments on commit 087ca5a

Please sign in to comment.