Example #1
0
if (!$_POST) {
    echo "Please create a user now:\r\n\t\t<form action='install.php' method='post'>\r\n\t\tAdmin Username: <input type='text' name='admin_username'>\r\n\t\t<br />\r\n\t\tAdmin Password: <input type='password' name='admin_password'>\r\n\t\t<br />\r\n\t\tAdmin Password (again): <input type='password' name='admin_password2'>\r\n\t\t<br />\r\n\t\t<input type='submit' value='Start Install!'>\r\n\t\t</form>\r\n\t\t";
} elseif ($_POST) {
    if ($_POST['admin_password'] != $_POST['admin_password2']) {
        die("Error: Passwords don't match.");
    }
    include './txtSQL.class.php';
    $db_username = "******";
    $db_password = "******";
    $database = "carbon";
    //**************PLACE THE DATABASE IS STORED***********//
    $sql = new txtSQL('./data/');
    //***********CONNECT TO DATABASE****************//
    $sql->connect($db_username, $db_password) or die('Unable to Connect To' . $database);
    //**********CREATE THE DATABASE**************//
    $sql->createdb(array('db' => $database)) or die('Error creating txtSQL DB, txtSQL said: ' . $sql->get_last_error());
    //**********SELECT DATABASE TO USE**************//
    if (!$sql->selectdb($database)) {
        print $database . 'Could not be selected, check to make sure it exists';
    }
    //****************CREATE TABLES IN DATABASE*****************//
    $nav = array('id' => array('type' => 'int', 'auto_increment' => 1), 'name' => array('type' => 'string'), 'page' => array('type' => 'string'), 'short_url' => array('type' => 'string'), 'order_id' => array('type' => 'int'));
    $sql->createtable(array('db' => $database, 'table' => 'nav', 'columns' => $nav));
    /*******************************************/
    $nav = array('name' => "News", 'page' => "index.php", 'short_url' => "news");
    if (!$sql->insert(array('db' => $database, 'table' => 'nav', 'values' => $nav))) {
        die('An error occurred, txtSQL said: ' . $sql->get_last_error());
    }
    /********************************************/
    $con = array('id' => array('type' => 'int', 'auto_increment' => 1), 'title' => array('type' => 'string'), 'name' => array('type' => 'string'), 'welcome' => array('type' => 'string'), 'template' => array('type' => 'string'), 'front_page' => array('type' => 'string'), 'date_format' => array('type' => 'string'), 'news_comments' => array('type' => 'int'), 'news_comments_loggedin' => array('type' => 'int'), 'user_reg' => array('type' => 'int'), 'user_active' => array('type' => 'int'), 'min_pass_length' => array('type' => 'int'), 'min_user_length' => array('type' => 'int'), 'login_time' => array('type' => 'int'), 'install_date' => array('type' => 'date'));
    $sql->createtable(array('db' => $database, 'table' => 'config', 'columns' => $con));