break;
             case 'exit':
             case 'x':
                 exit;
                 break;
             default:
                 fwrite(STDOUT, "Really? That's what you're going with? Not even going to try for the options huh?\n");
         }
     }
     break;
 case 0:
     fwrite(STDOUT, "Are you sure you want to Erase ALL data!? This action CANNOT be undone! [Y]es, [N]o ");
     $confirm = trim(strtolower(fgets(STDIN)), "\n");
     if ($confirm == "y" || $confirm == "yes") {
         //TODO get a list of tables and drop them!
         $db = new DataBaseSchema();
         $tables = $db->listTables();
         fwrite(STDOUT, "Once again you are about to empty the entire database erasing all data with it. This action is primarily for development servers or in case of database corruption. To continue please type 'yes'! ");
         $final_confirm = trim(fgets(STDIN), "\n");
         if ($final_confirm == "yes") {
             foreach ($tables as $table) {
                 $db->dropTable($table[0]);
             }
             fwrite(STDOUT, "Please verify that the database is now empty using the tools that came with your server software.\n");
             exit;
         } else {
             fwrite(STDOUT, "You typed '" . $final_confirm . "' this is not 'yes'. We will now exit without touching the database\n");
             exit;
         }
     } else {
         exit;
function set_tables()
{
    //#Table definition for 'settings' table
    $def['settings'][0] = "`key` VARCHAR(30) NOT NULL PRIMARY KEY";
    $def['settings'][1] = "`value` VARCHAR(220)";
    //#Table definition for 'types' table (information table ONLY!!)
    $def['types'][0] = "`ttid` INT(4) NOT NULL PRIMARY KEY AUTO_INCREMENT";
    $def['types'][1] = "`name` VARCHAR(160) NOT NULL";
    $def['types'][2] = "`description` TEXT";
    //#Table definition for 'genres' table
    $def['genres'][0] = "`gid` INT(4) NOT NULL PRIMARY KEY AUTO_INCREMENT";
    $def['genres'][1] = "`name` VARCHAR(160)";
    //#Table definitionfor 'genre associations (gassoc)' table
    $def['gassoc'][0] = "`row` INT(4) NOT NULL PRIMARY KEY AUTO_INCREMENT";
    $def['gassoc'][1] = "`gid` INT(4) NOT NULL";
    $def['gassoc'][2] = "`cid` INT(4) NOT NULL";
    //#Table definition for 'logs' table
    $def['logs'][0] = "`mid` INT(11) PRIMARY KEY AUTO_INCREMENT";
    $def['logs'][1] = "`time` DATETIME";
    $def['logs'][2] = "`code` INT(11)";
    $def['logs'][3] = "`action` VARCHAR(20)";
    $def['logs'][4] = "`message` TEXT";
    //#Table definition for 'users' table
    $def['users'][0] = "`uid` INT(255) PRIMARY KEY AUTO_INCREMENT";
    $def['users'][1] = "`registered` DATETIME";
    $def['users'][2] = "`name` VARCHAR(160)";
    $def['users'][3] = "`first` TEXT";
    $def['users'][4] = "`last` TEXT";
    $def['users'][5] = "`birthdate` DATE";
    $def['users'][6] = "`email` TEXT";
    $def['users'][7] = "`level` INT(1)";
    $def['users'][8] = "`level_time` INT(4)";
    $def['users'][9] = "`level_date` DATETIME";
    $def['users'][10] = "`date_format` VARCHAR(50)";
    $def['users'][11] = "`rows_per_page` INT(2)";
    $def['users'][12] = "`items_per_page` INT(3)";
    $def['users'][13] = "`password` TEXT";
    $def['users'][14] = "`passes` TEXT";
    $def['users'][15] = "`library` TEXT";
    //#Table definition for 'comments' table
    $def['comments'][0] = "`ccid` INT(255) PRIMARY KEY AUTO_INCREMENT";
    $def['comments'][1] = "`subject` VARCHAR(160) NOT NULL";
    $def['comments'][2] = "`created` DATETIME";
    $def['comments'][3] = "`modified` DATETIME";
    $def['comments'][4] = "`cid` INT(255)";
    $def['comments'][5] = "`aid` INT(255)";
    $def['comments'][6] = "`eid` INT(255)";
    $def['comments'][7] = "`hidden` INT(1)";
    $def['comments'][8] = "`enotes` TEXT";
    $def['comments'][9] = "`comment` TEXT";
    //#Table definition for 'tags' table
    $def['tags'][0] = "`tid` INT(4) NOT NULL PRIMARY KEY AUTO_INCREMENT";
    $def['tags'][1] = "`name` VARCHAR(160) NOT NULL";
    //#Table definition for 'tag associations (tassoc)' table
    $def['tassoc'][0] = "`row` INT(20) NOT NULL PRIMARY KEY AUTO_INCREMENT";
    $def['tassoc'][1] = "`tid` INT(4) NOT NULL";
    $def['tassoc'][2] = "`cid` INT(255) NOT NULL";
    //#Table definition for 'issues' table
    $def['content'][0] = "`cid` INT(255) PRIMARY KEY AUTO_INCREMENT";
    $def['content'][2] = "`pid` INT(255)";
    $def['content'][3] = "`ttid` INT(4) NOT NULL";
    $def['content'][4] = "`created` DATETIME";
    $def['content'][5] = "`modified` DATETIME";
    $def['content'][6] = "`price` INT(5)";
    $def['content'][7] = "`title` VARCHAR(160)";
    $def['content'][8] = "`tags` TEXT";
    $def['content'][9] = "`script` TEXT";
    $def['content'][10] = "`pdf` TEXT";
    $def['content'][11] = "`notes` TEXT";
    //#Make sure the database's list of tables is empty, if it is not then there may have been a failed install attempt.
    $db = new DataBaseSchema(null, dirname(__FILE__) . "/dataconnect/connect.ini");
    if (!empty($db->showTables())) {
        trigger_error("Cannot continue install; database not empty! Perhaps you have another intallation or another project on the server. Please empty this database or select a different one before continuing", E_USER_ERROR);
        return false;
    }
    //#Write tables according to above definitions.
    $okay = 0;
    $tottables = 0;
    foreach ($def as $tablename => $cols) {
        if ($table = $db->addTable($tablename, $cols)) {
            $okay++;
        }
        $tottables++;
    }
    if ($okay == $tottables) {
        return true;
    } else {
        trigger_error("Only " . $okay . " of " . $tottables . " were created! Please empty the database and try again!", E_USER_WARNING);
        return false;
    }
}