if (!$ver) { # Which DB to select if (!isset($_POST['installdb']) && !isset($_POST['install'])) { exitMessage("<form method=post>Select database type to use:<br><br>\r\n<label><input type=radio name=installdb value=sqlite checked=checked onclick=\"document.getElementById('mysqlsettings').style.display='none'\">SQLite</label><br><br>\r\n<label><input type=radio name=installdb value=mysql onclick=\"document.getElementById('mysqlsettings').style.display=''\">MySQL</label><br>\r\n<div id='mysqlsettings' style='display:none; margin-left:30px;'><br><table><tr><td>Host:</td><td><input name=mysql_host value=localhost></td></tr>\r\n<tr><td>Database:</td><td><input name=mysql_db value=mytinytodo></td></tr>\r\n<tr><td>User:</td><td><input name=mysql_user value=user></td></tr>\r\n<tr><td>Password:</td><td><input type=password name=mysql_password></td></tr>\r\n<tr><td>Table prefix:</td><td><input name=prefix value=\"mtt_\"></td></tr>\r\n</table></div><br><input type=submit value=' Next '></form>"); } elseif (isset($_POST['installdb'])) { # Save configuration $dbtype = $_POST['installdb'] == 'mysql' ? 'mysql' : 'sqlite'; Config::set('db', $dbtype); if ($dbtype == 'mysql') { Config::set('mysql.host', _post('mysql_host')); Config::set('mysql.db', _post('mysql_db')); Config::set('mysql.user', _post('mysql_user')); Config::set('mysql.password', _post('mysql_password')); Config::set('prefix', trim(_post('prefix'))); } if (!testConnect($error)) { exitMessage("Database connection error: {$error}"); } if (!is_writable('./db/config.php')) { exitMessage("Config file ('db/config.php') is not writable."); } Config::set('signature', md5(uniqid(rand(), true))); Config::save(); exitMessage("This will create myTinyTodo database <form method=post><input type=hidden name=install value=1><input type=submit value=' Install '></form>"); } # install database if ($dbtype == 'mysql') { try { $db->ex("CREATE TABLE {$db->prefix}lists (\r\n `id` INT UNSIGNED NOT NULL auto_increment,\r\n `uuid` CHAR(36) NOT NULL default '',\r\n `ow` INT NOT NULL default 0,\r\n `name` VARCHAR(50) NOT NULL default '',\r\n `d_created` INT UNSIGNED NOT NULL default 0,\r\n `d_edited` INT UNSIGNED NOT NULL default 0,\r\n `sorting` TINYINT UNSIGNED NOT NULL default 0,\r\n `published` TINYINT UNSIGNED NOT NULL default 0,\r\n `taskview` INT UNSIGNED NOT NULL default 0,\r\n PRIMARY KEY(`id`),\r\n UNIQUE KEY(`uuid`)\r\n) CHARSET=utf8 "); $db->ex("CREATE TABLE {$db->prefix}todolist (\r\n `id` INT UNSIGNED NOT NULL auto_increment,\r\n `uuid` CHAR(36) NOT NULL default '',\r\n `list_id` INT UNSIGNED NOT NULL default 0,\r\n `d_created` INT UNSIGNED NOT NULL default 0, /* time() timestamp */\r\n `d_completed` INT UNSIGNED NOT NULL default 0, /* time() timestamp */\r\n `d_edited` INT UNSIGNED NOT NULL default 0, /* time() timestamp */\r\n `compl` TINYINT UNSIGNED NOT NULL default 0,\r\n `title` VARCHAR(250) NOT NULL,\r\n `note` TEXT,\r\n `prio` TINYINT NOT NULL default 0,\t\t\t/* priority -,0,+ */\r\n `ow` INT NOT NULL default 0,\t\t\t\t/* order weight */\r\n `tags` VARCHAR(600) NOT NULL default '',\t/* for fast access to task tags */\r\n `tags_ids` VARCHAR(250) NOT NULL default '', /* no more than 22 tags (x11 chars) */\r\n `duedate` DATE default NULL,\r\n PRIMARY KEY(`id`),\r\n KEY(`list_id`),\r\n UNIQUE KEY(`uuid`)\r\n) CHARSET=utf8 "); $db->ex("CREATE TABLE {$db->prefix}tags (\r\n `id` INT UNSIGNED NOT NULL auto_increment,\r\n `name` VARCHAR(50) NOT NULL,\r\n PRIMARY KEY(`id`),\r\n UNIQUE KEY `name` (`name`)\r\n) CHARSET=utf8 ");
?> <div class="row"> <div class="large-12 medium-12 small-12 columns"> <div class="panel"> <?php /*//////////////////////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////// Tests for log //////////////////////////////////////*/ /*//////////////////////////////////////////////////////////////////////////////////////////*/ $test = TRUE; // If data in $_POST login & passwd if (!empty($_POST) && !empty($_POST['login']) && !empty($_POST['passwd'])) { $login = htmlentities($_POST['login'], ENT_QUOTES); $passwd = htmlentities($_POST['passwd'], ENT_QUOTES); // Test if user is in DB, log him testConnect($login, md5($passwd)); // If is log or not, appropriate message if ($_SESSION['isLog']) { $message = 'Vous êtes à présent connecté, vous allez être redirigé vers l\'accueil.'; } else { $message = 'Erreur d\'identifiants'; $test = FALSE; } } /*//////////////////////////////////////////////////////////////////////////////////////////*/ /*//////////////////////////////////////////////////////////////////////////////////////////*/ /*//////////////////////////////// Display good information ////////////////////////////////*/ /*//////////////////////////////////////////////////////////////////////////////////////////*/ // If user is log if (isset($_SESSION['isLog']) && $_SESSION['isLog']) { // If $message has been set