2010-09-03 18:26:59 +00:00
|
|
|
#!/usr/bin/env php
|
2008-03-30 18:50:06 +00:00
|
|
|
<?php
|
|
|
|
|
2010-02-27 14:44:38 +00:00
|
|
|
include("includes/defaults.inc.php");
|
2008-03-30 18:50:06 +00:00
|
|
|
include("config.php");
|
|
|
|
include("includes/functions.php");
|
|
|
|
|
2011-03-12 08:50:47 +00:00
|
|
|
$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);
|
|
|
|
|
2010-07-17 12:58: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
|
|
|
|
2011-03-12 08:50:47 +00:00
|
|
|
if ($dataHandle)
|
2008-03-30 18:50:06 +00:00
|
|
|
{
|
|
|
|
while (!feof($dataHandle))
|
|
|
|
{
|
|
|
|
$data.= fread($dataHandle, 4096);
|
|
|
|
}
|
2011-03-12 08:50:47 +00:00
|
|
|
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);
|
|
|
|
|
2011-03-12 08:50:47 +00:00
|
|
|
if ($argv[1] == "--cron")
|
2011-03-10 15:51:56 +00:00
|
|
|
{
|
2011-03-18 00:43:36 +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");
|
|
|
|
|
2011-03-12 08:50:47 +00:00
|
|
|
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");
|
2011-03-12 08:50:47 +00:00
|
|
|
} 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|