Skip to content

Instantly share code, notes, and snippets.

@brahimmachkouri
Last active February 26, 2019 16:35
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 brahimmachkouri/82d4f154bde2066a7892d24f2a82ba18 to your computer and use it in GitHub Desktop.
Save brahimmachkouri/82d4f154bde2066a7892d24f2a82ba18 to your computer and use it in GitHub Desktop.
Get the latest version of fusioninventory agent
<?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