Files
librenms-librenms/versioncheck.php
T

54 lines
2.0 KiB
PHP
Raw Normal View History

2010-09-03 18:26:59 +00:00
#!/usr/bin/env php
2008-03-30 18:50:06 +00:00
<?php
include("includes/defaults.inc.php");
2008-03-30 18:50:06 +00:00
include("config.php");
include("includes/functions.php");
$ports = mysql_result(mysql_query("SELECT count(*) FROM ports"),0);
2009-03-24 13:56:47 +00:00
$devices = mysql_result(mysql_query("SELECT count(*) FROM devices"),0);
2011-04-03 17:09:09 +00:00
$dataHandle = fopen("http://www.observium.org/latest.php?i=$ports&d=$devices&v=".$config['version'], 'r');
2008-03-30 18:50:06 +00:00
if ($dataHandle)
2008-03-30 18:50:06 +00:00
{
while (!feof($dataHandle))
{
$data.= fread($dataHandle, 4096);
}
if ($data)
2008-03-30 18:50:06 +00:00
{
list($major, $minor, $release) = explode(".", $data);
list($cur, $tag) = explode("-", $config['version']);
list($cur_major, $cur_minor, $cur_release) = explode(".", $cur);
if ($argv[1] == "--cron")
2011-03-10 15:51:56 +00:00
{
if (is_file('rrd')) { echo("ERROR: 'rrd' is not a directory!\n"); exit; }
if (is_dir('rrd') && !is_writable('rrd')) { echo("ERROR: I can not write in the 'rrd' directory!\n"); exit; }
if (!is_dir('rrd')) { mkdir('rrd'); }
$fd = fopen('rrd/version.txt','w');
2011-03-10 15:51:56 +00:00
fputs($fd, "$major.$minor.$release");
fclose($fd);
2008-03-30 18:50:06 +00:00
} else {
echo("Current Version $cur_major.$cur_minor.$cur_release \n");
if ($major > $cur_major) {
2008-03-30 18:50:06 +00:00
echo("New major release : $major.$minor.$release");
2009-03-24 13:56:47 +00:00
} elseif ($major == $cur_major && $minor > $cur_minor) {
2008-03-30 18:50:06 +00:00
echo("New minor release : $major.$minor.$release");
2009-03-24 13:56:47 +00:00
} elseif ($major == $cur_major && $minor == $cur_minor && $release > $cur_release) {
2008-03-30 18:50:06 +00:00
echo("New trivial release : $major.$minor.$release");
} elseif ($major < $cur_major || ($major == $cur_major && $minor < $cur_minor) || ($major == $cur_major && $minor == $cur_minor && $release < $cur_release)) {
2009-03-24 13:56:47 +00:00
echo("Your release is newer than the official version!\n");
2008-03-30 18:50:06 +00:00
} else {
echo("Your release is up to date\n");
}
2009-03-24 13:56:47 +00:00
echo("\n");
2008-03-30 18:50:06 +00:00
}
}
fclose($dataHandle);
}
?>