Last active
February 26, 2019 16:35
-
-
Save brahimmachkouri/82d4f154bde2066a7892d24f2a82ba18 to your computer and use it in GitHub Desktop.
Get the latest version of fusioninventory agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// BM 20190226 | |
function get_links($link) | |
{ | |
$result = ""; | |
$ret = array(); | |
/*** a new dom object ***/ | |
$dom = new domDocument; | |
/*** get the HTML (suppress errors) ***/ | |
@$dom->loadHTML(file_get_contents($link)); | |
/*** remove silly white space ***/ | |
$dom->preserveWhiteSpace = false; | |
/*** get the links from the HTML ***/ | |
$links = $dom->getElementsByTagName('a'); | |
/*** loop over the links ***/ | |
foreach ($links as $tag) | |
{ | |
if (strpos($tag->getAttribute('href'),"/fusioninventory/fusioninventory-agent/releases/tag/") !== false) { | |
$result = trim($tag->childNodes->item(0)->nodeValue); | |
break; | |
} | |
} | |
return $result; | |
} | |
$release = get_links("https://github.com/fusioninventory/fusioninventory-agent/tags"); | |
echo $release; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment