<?php
# Script to upgrade cancerbero's database
include_once("include/dbconnect.php");
include_once("include/read_config_class.php");
$config = new ReadConfig;
$database_ver = DATABASE_VER;
$database_db_ver = $config->database_version;
$db_version_diff = $database_ver - $database_db_ver;
$update_go = "";
$sure_go = "";
if (isset ($_GET["sure"]))
$sure_go = $_GET["sure"];
if (isset ($_GET["update"]))
$update_go = $_GET["update"];
if ($database_db_ver < 0) {
include_once("menu.html");
die ("<h1>ERROR, PROBLEMS WITH THE UPGRADE FROM THE VERSION ". abs($database_db_ver) ." OF THE DATABASE</h1>");
}
if ($sure_go == 'yes') {
switch($db_version_diff)
{
case "3":
include ("include/update_1_2.php");
case "2":
include ("include/update_2_3.php");
case "1":
include ("include/update_3_4.php");
case "0":
break;
default:
die ("ERROR, UNKNOWN VERSION OF THE DATABASE");
}
include_once("include/functions.php");
include_once("menu.html");
echo "
<div class='row'>
<div align='center'><h2> Update finish. Press load bottom to begin working cancerbero.</h2></div>
<form action='index.php' method='get' onsubmit='return checkform(this);'>
<p><div align='center'><input class='lowred' type='submit' name='load' value='load'></div>
";
} elseif ($update_go == 'continue') {
include_once("menu.html");
echo "
<th>
<h2>Do you want to begin the database update? <p>This can be take some minutes...so be patient.</h2></div>
<form action='upgrade.php' method='get' onsubmit='return checkform(this);'>
<input type='hidden' name='sure' value='yes'>
<p><div align='center'><input class='lowred' type='submit' name='update' value='yes'></div>
</th>
</tr>
</table>
";
} else {
if ($db_version_diff > 0) {
echo "
<p>
<div align='center'>
<table class='cancerbero' width = 788 border = 1>
<tr>
<th>
<h1>WARNING, your database version (v.$database_db_ver) is deprecated<p>
Upgrade is needed to v.$database_ver.<br></h1>
</th>
</tr>
<tr>
<th style='vertical-align: bottom; background-color: rgb(255, 255, 255)'>
<p>
<h2>Probably, no data should be lost, but anyway we recommend you to do a security copy
<p>of your data before to take any decision.<p> <p>
More information in the <a href=http://cancerbero.sourceforge.net/wikka.php?wakka=Documentation>online documentation</a>.
</h2>
</th>
</tr>
<tr>
<th>
<h2>Do you want to continue?</h2></div>
<form action='upgrade.php' method='get' onsubmit='return checkform(this);'>
<p><div align='center'><input class='lowred' type='submit' name='update' value='continue'></div>
</th>
</tr>
</table>
";
} elseif ($db_version_diff == 0) {
include ("index.php");
}
}
?>