Skip to content

Commit

Permalink
changed detection of a new update
Browse files Browse the repository at this point in the history
  • Loading branch information
cstegm committed Sep 8, 2018
1 parent 529d12e commit c26187a
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions check_nextcloud_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

$options = getopt($shortopts, $longopts);

$nextcloud_releases = "https://download.nextcloud.com/server/releases/";

if(array_key_exists("help",$options)){
echo "HELP:\n";
echo " -H hostname \n";
Expand All @@ -37,7 +35,7 @@ function error($e){
exit(3);
}

function get_newest_version($nextcloud_releases="https://download.nextcloud.com/server/releases/"){
function get_newest_version($nextcloud_releases="https://nextcloud.com/changelog/"){
$return=false;
try {
$homepage = file_get_contents($nextcloud_releases);
Expand All @@ -48,24 +46,11 @@ function get_newest_version($nextcloud_releases="https://download.nextcloud.com/
error($e);
}

$arr=explode("\n",$homepage);
$new[]=array_pop($arr);
$new[]=array_pop($arr);
$new[]=array_pop($arr);
$new[]=array_pop($arr);
$new[]=array_pop($arr);
$new[]=array_pop($arr);
$new[]=array_pop($arr);
$new[]=array_pop($arr);
// print_r($new);

foreach($new as $val){
if(preg_match('/nextcloud-([0-9]+\.[0-9]\.[0-9])\.zip\.md5/',$val,$res)){
if(preg_match('/.*?>nextcloud-(\d+\.\d+\.\d+)\.zip<.*/',$homepage,$res)){
if(is_array($res)){
return $res[1];
}
}
}

return false;
}
Expand Down

0 comments on commit c26187a

Please sign in to comment.