<?php
echo "<h2>Updater of CheckServer</h2>";
echo "<p>Connecting to database</p>";
require_once 'connect.php';
$version = dbw_query_fetch_array($db_conn,"SELECT value FROM SYS WHERE option = 'version'")[0];
echo "<p>Your version: ".$version;
echo "<p>Updating to lastest</p>";
switch ($version){
	case '0.9':
		echo "<p>0.9->0.9.1<p>";
		dbw_query($db_conn,"DELETE FROM SYS WHERE option='maxChecksSave'");
		dbw_query($db_conn,"INSERT INTO SYS VALUES('maxTimeSave',14)");
		//Can not delete USERS.SessionID because sqlite3 not supports it, but doesn't do any harm.

	case '0.9.1':
		echo "0.9.1-Lastest";
		echo "<p>Updated to lastest. Close this and go to index</p>";
		//Remove files on a good update
		unlink('updater.php');
		unlink('installer.php');
}