<?php
/*=====================================================================*\
|| ###################################################################
|| # Bugdar
|| # Copyright (c)2004-2009 Blue Static
|| #
|| # This program is free software; you can redistribute it and/or modify
|| # it under the terms of the GNU General Public License as published by
|| # the Free Software Foundation; version 2 of the License.
|| #
|| # This program is distributed in the hope that it will be useful, but
|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|| # more details.
|| #
|| # You should have received a copy of the GNU General Public License along
|| # with this program; if not, write to the Free Software Foundation, Inc.,
|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|| ###################################################################
\*=====================================================================*/

require_once('./global.php');

// ###################################################################

if (!isset($input->in['next']))
{
	$db->showerrors = false;

	$version = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "setting WHERE varname = 'trackerversion'");
	$version = $version['value'];

	if ($version == '[#]version[#]')
	{
		header('Location: upgrade16.php');
		exit;
	}

	if (!$version)
	{
		die('You have done something to your database and this script cannot determine Bugdar\'s version... or you have no upgrade to perform...');
	}

	if ($bugsys->versions["$version"] == -1)
	{
		page_start();

		echo "<h1>Bugdar Upgrade System</h1>\n\n";

		echo "<p>Your Bugdar installation is up-to-date!</p>\n\n";

		page_end(false);
	}
	else
	{
		header("Location: upgrade.php?next=$version");
	}

	$db->showerrors = true;
}

// ###################################################################

else
{
	if ($bugsys->versions[ $input->in['next'] ] == -1)
	{
		die('Bugdar is up-to-date already');
	}

	header("Location: upgrade" . $bugsys->versions[ $input->in['next'] ] . ".php");
}

?>