<?php
ini_set("display_errors", 0);
error_reporting(0);

  $jazyk = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  $jazyk = str_replace("-", "_", $jazyk);
  $jazyk = preg_replace("~,(.*)$~", "", $jazyk);
  
if ($jazyk == "cs_CZ" or $jazyk == "sk_SK" or $jazyk == "cs" or $jazyk == "sk") {   
  $head_lang = "cs-cz";
  
    $set_lang1 = "cs";
    $set_lang2 = "cs_CZ";   
    
  $set_nazev_www = "Webovky, powered by JT-CMS";
  $set_popis_www = "Stránky, které běží na redakčním systému JT-CMS.";
  
  $lang['1'] = "Instalace";
  $lang['2'] = "Upgrade z verze 1.8.0";
  $lang['3'] = "Instalace";
  $lang['4'] = "Vyberte jednu z možností";
  $lang['5'] = 'Instalace redakčního systému JT-CMS.<br />Vylepšení a různé doplňky najdete na: <a href="http://jt-cms.com/">jt-cms.com</a>.<br /><br />JT-CMS <strong>musí</strong> být v adresáří "admin" který se musí nacházet v adresáří, kde jsou umístěny Vaše stránky. Při případných problémech s instalací nebo funkčností JT-CMS nás kontaktuje na našem fóru, na webu <a href="http://jt-cms.com">jt-cms.com</a>.';
  $lang['6'] = "Administrátoři";
  $lang['7'] = "Konfigurační soubor se povedlo vytvořit";
  $lang['8'] = 'Všechny tabulky v MySQL byly vytvořeny<br /><br />Doporučujeme si uschovat Vaše heslo, JT-CMS zatím neobsahuje možnost vygenerování nového hesla při případné ztrátě.<br /><br /><font color="red">!! Nyní smažte soubor install.php a pokračujte na přihlášení do administrace <a href="index.php">ZDE</a> !!</font>';
  $lang['9'] = "Konfugirační soubor (config.php) již existuje!";
  $lang['10'] = "Potřebná tabulka";
  $lang['11'] = "již existuje!";
  $lang['12'] = "Chyba při instalaci!";
  $lang['13'] = "Nepodařilo se připojit k MySQL! Zkontrolujte přihlašovací údaje!";
  $lang['14'] = "Nepodařilo se vybrat databázi! Zkontrolujte název databáze!";
  $lang['15'] = "Jméno administrátora nebylo vyplněno!";
  $lang['16'] = "Heslo administrátora nebylo vyplněno!";
  $lang['17'] = "Ověření hesla administrátora nebylo vyplněno!";
  $lang['18'] = "Hesla u administrátora se neshodují!";
  $lang['19'] = "Chyba při instalaci nastala z neznámého důvodu.";
  $lang['20'] = "Po opravení všech výše uvedených chyb zmáčkněte znovu tlačítko Instaluj.";
  $lang['21'] = "Nastavení databáze:";
  $lang['22'] = "Hostname:";
  $lang['23'] = "Databáze:";
  $lang['24'] = "Jméno:";
  $lang['25'] = "Heslo:";
  $lang['26'] = "Znaková sada:";
  $lang['27'] = "Účet administrátora <small>(údaje lze později změnit)</small>";
  $lang['28'] = "Jméno:";
  $lang['29'] = "Heslo:";
  $lang['30'] = "Opakuj heslo:";
  $lang['31'] = "Instaluj!";
  
  $lang['32'] = 'Soubor config.php neexistuje!<br />Pokud nemáte JT-CMS nainstalovaný, <a href="install.php?action=install">nainstalujte ho</a>';
  $lang['33'] = '<p>!! <font color="red">Pozor</font> !!<br />Tento upgrade slouží <strong>POUZE</strong> pro upgrade z verze 1.8.0 na verzi 2.0.0!!</p><br /><br />';
  $lang['34'] = "Správci";
  $lang['35'] = "Redaktoři";
  $lang['36'] = "Návod na upgrade:";
  $lang['37'] = 'Smažte veškerý obsah složky "admin" až na soubor config.php na Vašem server. (Toto jste nejspíš již provedli)';
  $lang['38'] = 'Klikněte na tlačítko "Upgradovat!" :)';
  $lang['39'] = 'Všechny změny provedené ve verzi 2.0.0 najdete na našem webu <a href="http://jt-cms.com/">jt-cms.com</a>.<br />Pro případnou pomoc s upgradem napište na náš web.';
  $lang['40'] = "Upgradovat!";
  $lang['41'] = 'Upgrade proběhl úspěšně!<br /><br /><font color="red">!! Nyní smažte soubor install.php a pokračujte na přihlášení do administrace <a href="index.php">ZDE</a> !!</font>';
  $lang['42'] = 'E-mail';
  $lang['43'] = 'E-mail administrátora nebyl vyplněn!'; 
   
} else {
  $head_lang = "en-gb";
  
    $set_lang1 = "en";
    $set_lang2 = "en_GB";   

  $set_nazev_www = "Websites, powered by JT-CMS";
  $set_popis_www = "Websites, that runs on JT-CMS.";
  
  $lang['1'] = "Instalation";
  $lang['2'] = "Upgrade from version 1.8.0";
  $lang['3'] = "Instalation";
  $lang['4'] = "Select one option";
  $lang['5'] = 'Instalation JT-CMS.<br />Some plugins, designs and other you can find at: <a href="http://jt-cms.com/">jt-cms.com</a>.<br /><br />JT-CMS <strong>must</strong> be in directory "admin" and directory "admin" must be in direcotry where are you websites. If you have any problems with installation or functionality of JT-CMS, please contact us on our <a href="http://forum.jt-cms.com">forum</a> or on our web <a href="http://jt-cms.com">jt-cms.com</a>.<br />English translation isn\'t maybe 100% right.';
  $lang['6'] = "Administrators";
  $lang['7'] = "Config.php was created";
  $lang['8'] = 'All MySQL table were created<br /><br />We strongly recommended save your password.<br /><br /><font color="red">!! Now please delete install.php and go <a href="index.php">HERE</a> !!</font>';
  $lang['9'] = "Config.php already exists!";
  $lang['10'] = "MySQL table";
  $lang['11'] = "already exists!";
  $lang['12'] = "Instalation error!";
  $lang['13'] = "Unable to connect to MySQL! Please check connect data!";
  $lang['14'] = "Unable to select database! Please check name od database!";
  $lang['15'] = "Name of administrator is empty!";
  $lang['16'] = "Password of administrator is empty!";
  $lang['17'] = "Password of administrator is empty!";
  $lang['18'] = "Passwords doesn't match is empty!";
  $lang['19'] = "Unknow instalation error.";
  $lang['20'] = "After correcting all errors above, again click on \"Install!\" button.";
  $lang['21'] = "Database setting:";
  $lang['22'] = "Hostname:";
  $lang['23'] = "Database:";
  $lang['24'] = "Name:";
  $lang['25'] = "Password:";
  $lang['26'] = "Character set:";
  $lang['27'] = "Administator account <small>(data can be changed later)</small>";
  $lang['28'] = "Name:";
  $lang['29'] = "Password:";
  $lang['30'] = "Passowrd:";
  $lang['31'] = "Install!";
  
  $lang['32'] = 'File config.php doesn\'t exists!<br />If you didn\'t have JT-CMS installed, <a href="install.php?action=install">install him</a>';
  $lang['33'] = '<p>!! <font color="red">Warning</font> !!<br />This upgrade is <strong>ONLY</strong> for upgrade from version 1.8.0 on version 2.0.0!!</p><br /><br />';
  $lang['34'] = "Light administrators";
  $lang['35'] = "Redactors";
  $lang['36'] = "How to upgrade:";
  $lang['37'] = 'Delete all of directory "admin" on your server, ONLY config.php file MUST stay! (This step is probably complete)';
  $lang['38'] = 'Click on button "Upgrade!" :)';
  $lang['39'] = 'All changes at version 2.0.0 you can find at our web <a href="http://jt-cms.com/">jt-cms.com</a>.<br />If you have some problems with instalation contact us!';
  $lang['40'] = "Upgrade!";
  $lang['41'] = 'Upgrade is complete!<br /><br /><font color="red">!! Now please delete install.php and go <a href="index.php">HERE</a> !!</font>';
  $lang['42'] = 'E-mail';
  $lang['43'] = 'E-mail of administrator is empty!'; 
};

function TableExists($tablename, $db) {
   
   $result = mysql_list_tables($db);
   $rcount = mysql_num_rows($result);


   for ($i=0;$i<$rcount;$i++) {
       if (mysql_tablename($result, $i) == $tablename) return true;
   };
   return false;
};
?>
<!DOCTYPE html>
 <html lang="<?php echo $head_lang; ?>" dir="ltr">
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title><?php echo $lang['1']; ?> | JT-CMS</title>
  
  <link href="stuff/img/favicon.ico" rel="shortcut icon" type="image/ico" />
  
  <meta name="author" content="all: Jan Tužil, mailto: Izolex@jantuzil.cz" />
  
<style type="text/css">
* {margin: 0; padding: 0; border: 0; outline: none;}
body {background-color: #d2d2d2; color: #333333; font-family: Arial; font-size: 17px;}
.obal {width: 900px; margin-left: auto; margin-right: auto; text-align: center;}

h1 {margin-top: 10px; margin-bottom: 10px; text-shadow: #a0a0a0 0 0 25px;}
h1 {text-decoration: none;}
h1.instalace_nadpis {display: inline; background-color: #b9b9b9; padding: 20px; border: solid 1px grey; margin-left: auto; margin-right: auto; box-shadow: #282828 0 0 10px; -moz-box-shadow: #282828 0 0 10px; -webkit-box-shadow: #282828 0 0 10px; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px;}
h1.instalace_nadpis:hover {background-color: #c9c9c9; box-shadow: #282828 0 0 18px; -moz-box-shadow: #282828 0 0 18px; -webkit-box-shadow: #282828 0 0 18px;}
a {color: #333333;}
a:hover {text-decoration: none;}

.no_decor {text-decoration: none;}

.pole {width: 300px; margin-left: auto; margin-right: auto;}
.pole input, select {border: solid 1px #909090; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; padding: 3px 5px 3px 5px; margin: 2px; font-family: Arial; color: black;}
.pole label {float: left; width: 110px; padding: 3px 5px 3px 5px; margin: 1px; text-align: right;}

input:focus, .pole select:focus {border-color: #404040; box-shadow: #333333 0 0 5px; -webkit-box-shadow: #333333 0 0 5px; -moz-box-shadow: #333333 0 0 5px;}

.submit {padding: 8px; border: solid 2px #b9b9b9; border-radius: 8px; -moz-border-radius: 8px; -webkit-border-radius: 8px;}
.submit:hover {background-color: #d0d0d0; cursor: pointer;}

.upgrade_but {background-color: #f5f5f5; text-decoration: none;}

.error-div {width: 550px; margin-left: auto; margin-right: auto; background-color: #c0c0c0; border: solid 1px #b0b0b0; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; padding: 7px; list-style-position: outside;}
.error-div h3 {text-align: center; color: red; margin-bottom: 8px;}
.hlavicka {width: 100%; height: 200px; background: url('stuff/img/hlavicka.png') no-repeat scroll transparent center top;}

.nf {width: 100%; clear: both; visibility: hidden;}
</style>
  </head>
  <body>
<div class="obal">

<?php
if (!isset($_GET['action'])) {$_GET['action'] = "default";};
switch ($_GET['action']) { 

case "install" : 
?>

  <h1><?php echo $lang['3']; ?> JT-CMS</h1>
  <p><?php echo $lang['5']; ?></p>
  <br /><br />
<?php
if (!empty($_POST)) {

  $sql_host = $_POST['sql_host'];
  $sql_databaze = $_POST['sql_databaze'];
  $sql_jmeno = $_POST['sql_jmeno'];
  $sql_heslo = $_POST['sql_heslo'];
  $sql_znaky = $_POST['sql_znaky'];
  
  $uz_jmeno = $_POST['uz_jmeno'];
  $uz_heslo = $_POST['uz_heslo'];
  $uz_heslo2 = $_POST['uz_heslo2'];
  $uz_mail = $_POST['uz_mail'];
  
  if (mysql_connect($sql_host, $sql_jmeno, $sql_heslo) && mysql_select_db($sql_databaze) && !empty($uz_jmeno) && !empty($uz_heslo) && !empty($uz_heslo2) && $uz_heslo == $uz_heslo2 && !empty($uz_mail) && !empty($sql_znaky)) {

$tabulky = array ("jtcms_nastaveni", "jtcms_uzivatele", "jtcms_clanky", "jtcms_stranky", "jtcms_kategorie", "jtcms_komentare_cl", "jtcms_komentare_st", "jtcms_banlist", "jtcms_zmenilose", "jtcms_skupiny", "jtcms_stitky", "jtcms_galerie", "jtcms_soubory", "jtcms_soubory_slozky");

$table_ex = FALSE;

for($i=0;$i<count($tabulky);$i++) {
  if (TableExists($tabulky[$i], $sql_databaze)) {$table_ex = TRUE;};
};

if (!$table_ex && !file_exists("config.php")) {
  
$skript = '<?php
if ($_SERVER["SERVER_ADDR"]=="localhost")
{
  define("SQL_HOST","localhost");
  define("SQL_DBNAME","database");
  define("SQL_USERNAME","user");
  define("SQL_PASSWORD","password");
}
else
{
  define("SQL_HOST","'.$sql_host.'");
  define("SQL_DBNAME","'.$sql_databaze.'");
  define("SQL_USERNAME","'.$sql_jmeno.'");
  define("SQL_PASSWORD","'.$sql_heslo.'");
};
mysql_connect(SQL_HOST, SQL_USERNAME, SQL_PASSWORD) or die("ERROR: " . mysql_error());
mysql_select_db(SQL_DBNAME) or die("ERROR: ". mysql_error());
mysql_query("SET NAMES \''.$sql_znaky.'\'");
?'.'>';
    $soubor = fopen("config.php", "w");
    fwrite($soubor, $skript);
    fclose($soubor);
    
switch ($sql_znaky) {
  case "utf8_czech_ci" : $skript_znaky = "UTF-8"; break;
  case "latin2_czech_ci" : $skript_znaky = "ISO-8859-2"; break;
  case "cp1250_czech_ci" : $skript_znaky = "windows-cp1250"; break;
  default : $skript_znaky = "UTF-8";
};

$uz_jmeno = mysql_real_escape_string($uz_jmeno);
$uz_heslo = sha1($uz_heslo);
$uz_heslo = mysql_real_escape_string($uz_heslo);
$uz_mail = mysql_real_escape_string($uz_mail);
$uz_ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);
$sql_znaky = mysql_real_escape_string($sql_znaky);
$skript_znaky = mysql_real_escape_string($skript_znaky);
   
mysql_query("CREATE TABLE jtcms_uzivatele (id INT AUTO_INCREMENT, jmeno TEXT, heslo TEXT, skupina INT, mail TEXT, posledni_ip TEXT, datum_reg DATETIME, posledni_pr DATETIME, set_jazyk TEXT, set_jazyk2 TEXT, set_vzhled TEXT, set_tinymce TEXT, info1 TEXT, info2 DATETIME, info3 TEXT, info4 TEXT, info5 TEXT, info12 TEXT, info13 TEXT, info14 TEXT, info15 TEXT, info16 TEXT, info17 TEXT, info18 TEXT, PRIMARY KEY (id))");
mysql_query("INSERT INTO jtcms_uzivatele (jmeno,heslo,skupina,mail,posledni_ip,datum_reg,posledni_pr) VALUES ('".$uz_jmeno."','".$uz_heslo."','1','".$uz_mail."','".$uz_ip."',NOW(),NOW())");
mysql_query("CREATE TABLE jtcms_skupiny(id INT AUTO_INCREMENT, nazev TEXT, clanky INT, stranky INT, kategorie INT, komentare INT, nastaveni INT, sablony INT, banlist INT, zacleneni INT, uzivatele INT, skupiny INT, stitky INT, galerie INT, soubory INT, PRIMARY KEY (id))");
mysql_query("INSERT INTO jtcms_skupiny (nazev, clanky, stranky, kategorie, komentare, nastaveni, sablony, banlist, zacleneni, uzivatele, skupiny, stitky, galerie, soubory) VALUES ('".$lang['6']."', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1')");
mysql_query("INSERT INTO jtcms_skupiny (nazev, clanky, stranky, kategorie, komentare, nastaveni, sablony, banlist, zacleneni, uzivatele, skupiny, stitky, galerie, soubory) VALUES ('".$lang['34']."', '1', '1', '1', '1', '3', '3', '1', '3', '3', '3', '1', '1', '1')");
mysql_query("INSERT INTO jtcms_skupiny (nazev, clanky, stranky, kategorie, komentare, nastaveni, sablony, banlist, zacleneni, uzivatele, skupiny, stitky, galerie, soubory) VALUES ('".$lang['35']."', '2', '2', '2', '2', '3', '3', '3', '3', '3', '3', '2', '2', '2')");

mysql_query("CREATE TABLE jtcms_nastaveni (id INT AUTO_INCREMENT, typ TEXT, hodnota TEXT, hodnota2 TEXT, PRIMARY KEY (id))");
mysql_query("CREATE TABLE jtcms_clanky (id INT AUTO_INCREMENT, perex TEXT, obsah TEXT, datum DATETIME, nazev TEXT, pocet INT, kategorie INT, pridal INT, kom_pov INT, status INT, stitky TEXT, obrazek TEXT, PRIMARY KEY (id))");
mysql_query("CREATE TABLE jtcms_stranky (id INT AUTO_INCREMENT, obsah TEXT, nazev TEXT, datum DATETIME, pocet INT, pridal INT, kom_pov INT, menu_zob INT, menu_por INT, PRIMARY KEY (id))");
mysql_query("CREATE TABLE jtcms_kategorie (id INT AUTO_INCREMENT, nazev TEXT, pridal INT, datum DATETIME, menu_zob INT, menu_por INT, PRIMARY KEY (id))");
mysql_query("CREATE TABLE jtcms_komentare_cl (id INT AUTO_INCREMENT, clanek INT, jmeno TEXT, mail TEXT, web TEXT, obsah TEXT, ip TEXT, datum DATETIME, PRIMARY KEY (id))");
mysql_query("CREATE TABLE jtcms_komentare_st (id INT AUTO_INCREMENT, stranka INT, jmeno TEXT, mail TEXT, web TEXT, obsah TEXT, ip TEXT, datum DATETIME, PRIMARY KEY (id))");
mysql_query("CREATE TABLE jtcms_banlist (id INT AUTO_INCREMENT, ip TEXT, datum DATETIME, druh INT, duvod TEXT, PRIMARY KEY (id))");
mysql_query("CREATE TABLE jtcms_zmenilose (id INT AUTO_INCREMENT, typ TEXT, old INT, datum DATETIME, PRIMARY KEY (id))");
mysql_query("CREATE TABLE jtcms_stitky (id INT AUTO_INCREMENT, nazev TEXT, pridal INT, datum DATETIME, PRIMARY KEY (id))");
mysql_query("CREATE TABLE jtcms_galerie (id INT AUTO_INCREMENT, nazev TEXT, datum DATETIME, pridal INT, PRIMARY KEY (id))");
mysql_query("CREATE TABLE jtcms_soubory_slozky (id INT AUTO_INCREMENT, nazev TEXT, datum DATETIME, pridal INT, PRIMARY KEY (id))");
mysql_query("CREATE TABLE jtcms_soubory (id INT AUTO_INCREMENT, nazev TEXT, typ TEXT, velikost TEXT, stazeni INT, pridal INT, slozka INT, datum DATETIME, PRIMARY KEY (id))");

mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('jtcms_verze','2.0.0')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('vzhled', 'jt-greywall')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('tinymce','1')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('pocet_kom_adm','10')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('pocet_clst_adm','10')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('pocet_clanku','6')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('strankovani','1')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('komentare','1')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('komentare_raz','1')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota, hodnota2) VALUES ('znakova_sada','".$sql_znaky."', '".$skript_znaky."')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota, hodnota2) VALUES ('jazyk','".$set_lang1."', '".$set_lang2."')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('nazev_www','".$set_nazev_www."')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('popis_www','".$set_popis_www."')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota, hodnota2) VALUES ('galerie_nahled','125','125')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('galerie_max_upload','5000000')");
mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('soubory_max_upload','10000000')");

    $umask_old = umask(0000);
      mkdir("./data/files", 0777);
    umask($umask_old);
    
    $config = TRUE;
};

if ($config) {echo '<img src="stuff/img/icons/accept.png" alt="" /> '.$lang['7'].'<br /><img src="stuff/img/icons/accept.png" alt="" /> '.$lang['8']; echo '</div></body></html>'; mysql_close(); exit();};
if (!$config) {
if (file_exists("config.php")) {echo '<img src="stuff/img/icons/delete.png" alt="" /> '.$lang['9'].'<br />';};
for($i=0;$i<count($tabulky);$i++) {
  if (TableExists($tabulky[$i], $sql_databaze)) {echo '<img src="stuff/img/icons/delete.png" alt="" /> '.$lang['10'].' '.$tabulky[$i].' '.$lang['11'].'<br />';};
};
};

  } else {
  
echo '<div class="error-div">';
echo '<h3>'.$lang['12'].'</h3>';  
if (!mysql_connect($sql_host, $sql_jmeno, $sql_heslo)) {echo '<li>'.$lang['13'].'</li>'; $db_er = TRUE; $error = TRUE;};
if (!$db_er && !mysql_select_db($sql_databaze)) {echo '<li>'.$lang['14'].'</li>'; $error = TRUE;};
if (empty($uz_jmeno)) {echo '<li>'.$lang['15'].'</li>'; $error = TRUE;};
if (empty($uz_heslo)) {echo '<li>'.$lang['16'].'</li>'; $heslo_er = TRUE; $error = TRUE;};
if (empty($uz_heslo2)) {echo '<li>'.$lang['17'].'</li>'; $heslo_er = TRUE; $error = TRUE;};
if (!$heslo_er && $uz_heslo != $uz_heslo2) {echo '<li>'.$lang['18'].'</li>'; $error = TRUE;};
if (empty($uz_mail)) {echo '<li>'.$lang['43'].'</li>';};
if (!$error) {echo $lang['19'];} else {echo '<br />'.$lang['20'];};
echo '</div>'; 
  
  };
echo '<br /><br />';

 mysql_close();  
};
?>  
  
  <form method="post" action="install.php?action=install">
  
  <h2><?php echo $lang['21']; ?></h2><br />
  <div class="pole">  
  <label for="sql_host"><?php echo $lang['22']; ?></label><input type="text" id="sql_host" name="sql_host"<?php if (!empty($_POST['sql_host'])) {echo ' value="'.htmlspecialchars($_POST['sql_host']).'"';}; ?> /><br />
  <label for="sql_databaze"><?php echo $lang['23']; ?></label><input type="text" id="sql_databaze" name="sql_databaze"<?php if (!empty($_POST['sql_databaze'])) {echo ' value="'.htmlspecialchars($_POST['sql_databaze']).'"';}; ?> /><br />
  <label for="sql_jmeno"><?php echo $lang['24']; ?></label><input type="text" id="sql_jmeno" name="sql_jmeno"<?php if (!empty($_POST['sql_jmeno'])) {echo ' value="'.htmlspecialchars($_POST['sql_jmeno']).'"';}; ?> /><br />
  <label for="sql_heslo"><?php echo $lang['25']; ?></label><input type="password" id="sql_heslo" name="sql_heslo"<?php if (!empty($_POST['sql_heslo'])) {echo ' value="'.htmlspecialchars($_POST['sql_heslo']).'"';}; ?> /><br />
  <label for="sql_znaky"><?php echo $lang['26']; ?></label>
  <select name="sql_znaky" id="sql_znaky">
  <option value="utf8_czech_ci"<?php if (!empty($_POST['sql_znaky'])) {if ($_POST['sql_znaky'] == "utf8_czech_ci") {echo ' selected';};}; ?> />UTF-8
  <option value="latin2_czech_ci"<?php if (!empty($_POST['sql_znaky'])) {if ($_POST['sql_znaky'] == "latin2_czech_ci") {echo ' selected';};}; ?> />ISO-8859-2
  <option value="cp1250_czech_ci"<?php if (!empty($_POST['sql_znaky'])) {if ($_POST['sql_znaky'] == "cp1250_czech_ci") {echo ' selected';};}; ?> />CP1250
  </select>
  </div>
  
  <br /><br />
  
  <h2><?php echo $lang['27']; ?></h2><br />
  <div class="pole">
  <label for="uz_jmeno"><?php echo $lang['28']; ?></label><input type="text" id="uz_jmeno" name="uz_jmeno"<?php if (!empty($_POST['uz_jmeno'])) {echo ' value="'.htmlspecialchars($_POST['uz_jmeno']).'"';}; ?> /><br />
  <label for="uz_heslo"><?php echo $lang['29']; ?></label><input type="password" id="uz_heslo" name="uz_heslo"<?php if (!empty($_POST['uz_heslo'])) {echo ' value="'.htmlspecialchars($_POST['uz_heslo']).'"';}; ?> /><br />
  <label for="uz_heslo2"><?php echo $lang['30']; ?></label><input type="password" id="uz_heslo2" name="uz_heslo2"<?php if (!empty($_POST['uz_heslo2'])) {echo ' value="'.htmlspecialchars($_POST['uz_heslo2']).'"';}; ?> /><br />
  <label for="uz_mail"><?php echo $lang['42']; ?></label><input type="text" id="uz_mail" name="uz_mail"<?php if (!empty($_POST['uz_mail'])) {echo ' value="'.htmlspecialchars($_POST['uz_mail']).'"';}; ?> /><br />
  </div>
  
  <br /><br />
  
  <input type="submit" name="submit" value="<?php echo $lang['31']; ?>" class="submit" />
  
  </form>
  
<?php
break; 

case "upgrade" : 
?>

<h1><?php echo $lang['2']; ?></h1>
<br />
<?php
  if (!file_exists("config.php")) {
    echo '<img src="stuff/img/icons/delete.png" alt="" /> '.$lang['32'];
    echo '</div></body></html>'; mysql_close(); exit();
  };
  
  include "config.php";
  
  echo $lang['33'];
  
if (isset($_GET['upgrade']) && $_GET['upgrade'] == "1") {

  mysql_query("DELETE FROM jtcms_nastaveni WHERE typ='pomocne_ikony' LIMIT 1");
  mysql_query("UPDATE jtcms_nastaveni SET hodnota='jt-greywall' WHERE typ='vzhled' LIMIT 1");
  mysql_query("UPDATE jtcms_nastaveni SET hodnota='2.0.0' WHERE typ='jtcms_verze' LIMIT 1"); 
  
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN mail TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN posledni_ip TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN datum_reg TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN posledni_pr TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN set_jazyk TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN set_jazyk2 TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN set_vzhled TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN set_tinymce TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN info1 TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN info2 DATETIME");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN info3 TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN info4 TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN info5 TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN info12 TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN info13 TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN info14 TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN info15 TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN info16 TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN info17 TEXT");
  mysql_query("ALTER TABLE jtcms_uzivatele ADD COLUMN info18 TEXT");
  mysql_query("ALTER TABLE jtcms_skupiny ADD COLUMN soubory INT");
  
  mysql_query("UPDATE jtcms_uzivatele SET info2='0000-00-00 00:00:00'");
  
  mysql_query("CREATE TABLE jtcms_soubory_slozky (id INT AUTO_INCREMENT, nazev TEXT, datum DATETIME, pridal INT, PRIMARY KEY (id))");
  
  mysql_query("INSERT INTO jtcms_nastaveni (typ, hodnota) VALUES ('soubory_max_upload','10000000')");
  
  mysql_query("CREATE TABLE jtcms_soubory (id INT AUTO_INCREMENT, nazev TEXT, typ TEXT, velikost TEXT, stazeni INT, pridal INT, slozka INT, datum DATETIME, PRIMARY KEY (id))");
    
    $umask_old = umask(0000);
      mkdir("./data/files", 0777);
    umask($umask_old);
  
  echo '<p><img src="stuff/img/icons/accept.png" alt="" /> '.$lang['41'].'</p>';

};
?>

<?php
  if (!isset($_GET['upgrade'])) { ?>
<p><?php echo $lang['36']; ?></p>
<br />
<li><?php echo $lang['37']; ?></li>
<li><?php echo $lang['38']; ?></li>
<br /><br />

<p><?php echo $lang['39']; ?></p>
<br /><br />

<a href="install.php?action=upgrade&amp;upgrade=1" class="submit upgrade_but"><?php echo $lang['40']; ?></a> 

<?php
};

break; 

default :
?>
<div class="hlavicka"></div>

<br /><br /><br />
<a href="install.php?action=install" class="no_decor"><h1 class="instalace_nadpis"><?php echo $lang['3']; ?></h1></a>
<div class="nf"></div>
<br /><br /><br /><br /><br /><br />
<h2><a href="install.php?action=upgrade" class="no_decor"><?php echo $lang['2']; ?></a></h2>
<?php
};
?>
  
  <br /><br />
   
</div>
  </body>
</html>