<?php
include "config.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
<head>
<meta http-equiv="Content-type" content="application/xhtml+xml; charset=utf-8" />
<title>K:CMS 1.1 - Update to 1.2.0 / Aktualizace na 1.2.0</title>
</head>
<body style="text-align: center; font: 80% Arial, Verdana;">
<h1>K:CMS 1.1 - Update to 1.2.0 / Aktualizace na 1.2.0</h1>
<?php
if ($submit!="") {

echo "<p><strong>Updating... / Aktualizace...</strong></p>\n<div style=\"background: #f0f0f0; padding: 10px; margin: 20px auto; width: 425px; text-align: right;\">\n";

$old_version=mysql_query("SELECT value FROM kcms_variables WHERE variable='version'");
$old_version=mysql_fetch_array($old_version);

if ($old_version["value"]!="1.1") {

echo "<div>check previous version / ověření předchozí verze: ... <span style=\"color: #ff0000; font-weight: bold;\">KO</span></div>\n";

} else {

echo "<div>check previous version / ověření předchozí verze: ... <span style=\"color: #55b05a; font-weight: bold;\">OK</span></div>\n";

$sql1=mysql_query("CREATE TABLE kcms_files (
  id int(11) NOT NULL auto_increment,
  file varchar(128) NOT NULL,
  added int(11) NOT NULL,
  PRIMARY KEY (id)
 ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci");

if ($sql1) { echo "<div>part 1. / část 1.: ... <span style=\"color: #55b05a; font-weight: bold;\">OK</span></div>\n"; } else { echo "<div>part 1. / část 1.: ... <span style=\"color: #ff0000; font-weight: bold;\">KO</span></div>\n"; }


$sql2=mysql_query("INSERT INTO kcms_variables values ('theme', 'kcms_default')", $dbserver);

if ($sql2) { echo "<div>part 2. / část 2.: ... <span style=\"color: #55b05a; font-weight: bold;\">OK</span></div>\n"; } else { echo "<div>part 2. / část 2.: ... <span style=\"color: #ff0000; font-weight: bold;\">KO</span></div>\n"; }

$sql3=mysql_query("UPDATE kcms_variables SET value='1.2.0' WHERE variable='version'", $dbserver);

if ($sql3) { echo "<div>part 3. / část 3.: ... <span style=\"color: #55b05a; font-weight: bold;\">OK</span></div>\n"; } else { echo "<div>part 3. / část 3.: ... <span style=\"color: #ff0000; font-weight: bold;\">KO</span></div>\n"; }

echo "</div>\n";

if ($sql1 AND $sql2 AND $sql3) {

echo "<p><strong><span style=\"color: #55b05a;\">Update was successfuly completed! / Aktualizace byla úspěšně dokončena!</span></strong></p>\n";

} else {

echo "<p><strong><span style=\"color: #ff0000;\">An error occured while updating. / Při aktualizaci došlo k chybě.</span></strong></p>\n";

}

}

} else {

echo "<form action=\"./update.php\" method=\"post\">
<p><input type=\"submit\" name=\"submit\" value=\"Update / Aktualizovat\" /></p>
</form>\n";
}
?>
</body>
</html>