<?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.2.0 - Installation / Instalace</title>
</head>
<body style="text-align: center; font: 80% Arial, Verdana;">
<h1>K:CMS 1.2.0 - Installation / Instalace</h1>
<?php
if ($submit!="") {

echo "<p><strong>Creating tables... / Vytvářím tabulky...</strong></p>\n<div style=\"background: #f0f0f0; margin: 20px auto; width: 425px; text-align: right;\">\n";

$sql1=mysql_query("CREATE TABLE kcms_articles (
  id int(11) NOT NULL auto_increment,
  quick varchar(160) NOT NULL,
  title varchar(128) NOT NULL,
  type int(1) NOT NULL,
  hp int(1) NOT NULL,
  complete int(1) NOT NULL,
  confirmed int(1) NOT NULL,
  discussion int(1) NOT NULL,
  section int(3) NOT NULL,
  perex text,
  text text,
  added int(11) NOT NULL,
  published int(11) NOT NULL,
  author int(11) NOT NULL,
  publisher int(11) NOT NULL,
  edited int(11) NOT NULL,
  pereximg varchar(128) NOT NULL,
  views int(11) NOT NULL,
  PRIMARY KEY (id),
  FULLTEXT KEY title (title),
  FULLTEXT KEY text (text),
  FULLTEXT KEY perex (perex)
 ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci");

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

$sql2=mysql_query("CREATE TABLE kcms_comments (
  id int(11) NOT NULL auto_increment,
  article int(11) NOT NULL,
  added int(11) default NULL,
  author varchar(128) NOT NULL,
  text text NOT NULL,
  confirmed int(1) NOT NULL,
  user int(1) NOT NULL,
  PRIMARY KEY (id)
 ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci");

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

$sql13=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 ($sql13) { echo "<div>kcms_files ... <span style=\"color: #55b05a; font-weight: bold;\">OK</span></div>\n"; } else { echo "<div>kcms_files ... <span style=\"color: #ff0000; font-weight: bold;\">KO</span></div>\n"; }

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

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

$sql4=mysql_query("CREATE TABLE kcms_images_sections (
  id int(11) NOT NULL auto_increment,
  quick varchar(160) NOT NULL,
  name varchar(128) NOT NULL,
  public int(1) NOT NULL,
  PRIMARY KEY (id)
 ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci");

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

$sql5=mysql_query("CREATE TABLE kcms_sections (
  id int(11) NOT NULL auto_increment,
  quick varchar(160) NOT NULL,
  name varchar(128) NOT NULL,
  highlight int(1) NOT NULL,
  PRIMARY KEY (id)
 ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci");

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

$sql6=mysql_query("CREATE TABLE kcms_users (
  id int(11) NOT NULL auto_increment,
  login varchar(128) NOT NULL,
  password varchar(128) NOT NULL,
  rights int(1) NOT NULL,
  age varchar(3) default NULL,
  jabber varchar(128) NOT NULL,
  skype varchar(128) NOT NULL,
  about text NOT NULL,
  mail varchar(128) NOT NULL,
  realname varchar(128) NOT NULL,
  regdate int(11) NOT NULL,
  lastvisit int(11) NOT NULL,
  PRIMARY KEY (id)
 ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci");

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

$sql7=mysql_query("CREATE TABLE kcms_variables (
  variable varchar(64) default NULL,
  value text
 ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci");

if ($sql7) { echo "<div>kcms_variables ... <span style=\"color: #55b05a; font-weight: bold;\">OK</span></div>\n<br />\n"; } else { echo "<div>kcms_variables ... <span style=\"color: #ff0000; font-weight: bold;\">KO</span></div>\n<br />\n"; }

$sql8=mysql_query("INSERT INTO kcms_users values ('', 'admin', '".SHA1("admin")."', '3', '', '', '', '', '', '', '".time()."', '')", $dbserver);

if ($sql8) { echo "<div>user / uživatel admin ... <span style=\"color: #55b05a; font-weight: bold;\">OK</span></div>\n"; } else { echo "<div>kcms_images ... <span style=\"color: #ff0000; font-weight: bold;\">KO</span></div>\n"; }

$sql10=mysql_query("INSERT INTO kcms_variables values ('lang', 'en')", $dbserver);
$sql10=mysql_query("INSERT INTO kcms_variables values ('sitename', 'Website')", $dbserver);
$sql10=mysql_query("INSERT INTO kcms_variables values ('login_for_comments', '0')", $dbserver);
$sql10=mysql_query("INSERT INTO kcms_variables values ('show_text', '0')", $dbserver);
$sql10=mysql_query("INSERT INTO kcms_variables values ('sort_sections_by_name', '0')", $dbserver);
$sql10=mysql_query("INSERT INTO kcms_variables values ('articles_number', '10')", $dbserver);
$sql10=mysql_query("INSERT INTO kcms_variables values ('left_column', '')", $dbserver);
$sql10=mysql_query("INSERT INTO kcms_variables values ('right_column', '')", $dbserver);
$sql10=mysql_query("INSERT INTO kcms_variables values ('meta_copyright', 'Copyright')", $dbserver);
$sql10=mysql_query("INSERT INTO kcms_variables values ('meta_keywords', '')", $dbserver);
$sql10=mysql_query("INSERT INTO kcms_variables values ('meta_desc', '')", $dbserver);
$sql10=mysql_query("INSERT INTO kcms_variables values ('version', '1.2.0')", $dbserver);
$sql10=mysql_query("INSERT INTO kcms_variables values ('theme', 'kcms_default')", $dbserver);

if ($sql10) { echo "<div>configuration of K:CMS / nastavení K:CMS ... <span style=\"color: #55b05a; font-weight: bold;\">OK</span></div>\n"; } else { echo "<div>configuration of K:CMS / nastavení K:CMS ... <span style=\"color: #ff0000; font-weight: bold;\">KO</span></div>\n"; }

$sql11=mysql_query("INSERT INTO kcms_sections values ('', 'test', 'Test', '0')", $dbserver);

if ($sql11) { echo "<div>test section created / testovací sekce vytvořena ... <span style=\"color: #55b05a; font-weight: bold;\">OK</span></div>\n"; } else { echo "<div>test section created / testovací sekce vytvořena ... <span style=\"color: #ff0000; font-weight: bold;\">KO</span></div>\n"; }

$sql12=mysql_query("INSERT INTO kcms_articles values ('', 'test', 'Test', '1', '1', '1', '1', '1', '1', '', '<p>Test article / testovací článek.</p>', '".time()."', '".time()."', '1', '1', '', '', '')", $dbserver);

if ($sql12) { echo "<div>test article created / testovací článek vytvořen ... <span style=\"color: #55b05a; font-weight: bold;\">OK</span></div>\n"; } else { echo "<div>test article created / testovací článek vytvořen ... <span style=\"color: #ff0000; font-weight: bold;\">KO</span></div>\n"; }

echo "</div>\n";

if ($sql1 AND $sql2 AND $sql3 AND $sql4 AND $sql5 AND $sql6 AND $sql7 AND $sql8 AND $sql10 AND $sql11 AND $sql12 AND $sql13) {

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

} else {

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

}

} else {

echo "<form action=\"./install.php\" method=\"post\">
<p><input type=\"submit\" name=\"submit\" value=\"Install / Instalovat\" /></p>
</form>\n";

}
?>
</body>
</html>