Exemplo n.º 1
0
         }
         break;
 }
 // Make sure PunBB isn't already installed
 $result = $db->query('SELECT 1 FROM ' . $db_prefix . 'users WHERE id=1');
 if ($db->num_rows($result)) {
     error('A table called "' . $db_prefix . 'users" is already present in the database "' . $db_name . '". This could mean that PunBB is already installed or that another piece of software is installed and is occupying one or more of the table names PunBB requires. If you want to install multiple copies of PunBB in the same database, you must choose a different table prefix.');
 }
 // Create all tables
 switch ($db_type) {
     case 'mysql':
     case 'mysqli':
         $sql = 'CREATE TABLE ' . $db_prefix . "bans (\n\t\t\t\t\tid INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tusername VARCHAR(200),\n\t\t\t\t\tip VARCHAR(255),\n\t\t\t\t\temail VARCHAR(50),\n\t\t\t\t\tmessage VARCHAR(255),\n\t\t\t\t\texpire INT(10) UNSIGNED,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t) TYPE=MyISAM;";
         break;
     case 'pgsql':
         $db->start_transaction();
         $sql = 'CREATE TABLE ' . $db_prefix . "bans (\n\t\t\t\t\tid SERIAL,\n\t\t\t\t\tusername VARCHAR(200),\n\t\t\t\t\tip VARCHAR(255),\n\t\t\t\t\temail VARCHAR(50),\n\t\t\t\t\tmessage VARCHAR(255),\n\t\t\t\t\texpire INT,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t)";
         break;
     case 'sqlite':
         $db->start_transaction();
         $sql = 'CREATE TABLE ' . $db_prefix . "bans (\n\t\t\t\t\tid INTEGER NOT NULL,\n\t\t\t\t\tusername VARCHAR(200),\n\t\t\t\t\tip  VARCHAR(255),\n\t\t\t\t\temail VARCHAR(50),\n\t\t\t\t\tmessage VARCHAR(255),\n\t\t\t\t\texpire INTEGER,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t)";
         break;
 }
 $db->query($sql) or error('Unable to create table ' . $db_prefix . 'bans. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
 switch ($db_type) {
     case 'mysql':
     case 'mysqli':
         $sql = 'CREATE TABLE ' . $db_prefix . "categories (\n\t\t\t\t\tid INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tcat_name VARCHAR(80) NOT NULL DEFAULT 'New Category',\n\t\t\t\t\tdisp_position INT(10) NOT NULL DEFAULT 0,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t) TYPE=MyISAM;";
         break;
     case 'pgsql':
         $sql = 'CREATE TABLE ' . $db_prefix . "categories (\n\t\t\t\t\tid SERIAL,\n\t\t\t\t\tcat_name VARCHAR(80) NOT NULL DEFAULT 'New Category',\n\t\t\t\t\tdisp_position INT NOT NULL DEFAULT 0,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t)";
Exemplo n.º 2
0
     error(sprintf($lang_install['Invalid table prefix'], $db_prefix));
 }
 // Check SQLite prefix collision
 if (in_array($db_type, array('sqlite', 'sqlite3')) && strtolower($db_prefix) == 'sqlite_') {
     error($lang_install['SQLite prefix collision']);
 }
 // Make sure PunBB isn't already installed
 if ($forum_db->table_exists('users')) {
     $query = array('SELECT' => 'COUNT(id)', 'FROM' => 'users', 'WHERE' => 'id=1');
     $result = $forum_db->query_build($query);
     if ($forum_db->result($result) > 0) {
         error(sprintf($lang_install['PunBB already installed'], $db_prefix, $db_name));
     }
 }
 // Start a transaction
 $forum_db->start_transaction();
 // Create all tables
 $schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'username' => array('datatype' => 'VARCHAR(200)', 'allow_null' => true), 'ip' => array('datatype' => 'VARCHAR(255)', 'allow_null' => true), 'email' => array('datatype' => 'VARCHAR(80)', 'allow_null' => true), 'message' => array('datatype' => 'VARCHAR(255)', 'allow_null' => true), 'expire' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true), 'ban_creator' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0')), 'PRIMARY KEY' => array('id'));
 $forum_db->create_table('bans', $schema);
 $schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'cat_name' => array('datatype' => 'VARCHAR(80)', 'allow_null' => false, 'default' => '\'New Category\''), 'disp_position' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0')), 'PRIMARY KEY' => array('id'));
 $forum_db->create_table('categories', $schema);
 $schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'search_for' => array('datatype' => 'VARCHAR(60)', 'allow_null' => false, 'default' => '\'\''), 'replace_with' => array('datatype' => 'VARCHAR(60)', 'allow_null' => false, 'default' => '\'\'')), 'PRIMARY KEY' => array('id'));
 $forum_db->create_table('censoring', $schema);
 $schema = array('FIELDS' => array('conf_name' => array('datatype' => 'VARCHAR(255)', 'allow_null' => false, 'default' => '\'\''), 'conf_value' => array('datatype' => 'TEXT', 'allow_null' => true)), 'PRIMARY KEY' => array('conf_name'));
 $forum_db->create_table('config', $schema);
 $schema = array('FIELDS' => array('id' => array('datatype' => 'VARCHAR(150)', 'allow_null' => false, 'default' => '\'\''), 'title' => array('datatype' => 'VARCHAR(255)', 'allow_null' => false, 'default' => '\'\''), 'version' => array('datatype' => 'VARCHAR(25)', 'allow_null' => false, 'default' => '\'\''), 'description' => array('datatype' => 'TEXT', 'allow_null' => true), 'author' => array('datatype' => 'VARCHAR(50)', 'allow_null' => false, 'default' => '\'\''), 'uninstall' => array('datatype' => 'TEXT', 'allow_null' => true), 'uninstall_note' => array('datatype' => 'TEXT', 'allow_null' => true), 'disabled' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'dependencies' => array('datatype' => 'VARCHAR(255)', 'allow_null' => false, 'default' => '\'\'')), 'PRIMARY KEY' => array('id'));
 $forum_db->create_table('extensions', $schema);
 $schema = array('FIELDS' => array('id' => array('datatype' => 'VARCHAR(150)', 'allow_null' => false, 'default' => '\'\''), 'extension_id' => array('datatype' => 'VARCHAR(50)', 'allow_null' => false, 'default' => '\'\''), 'code' => array('datatype' => 'TEXT', 'allow_null' => true), 'installed' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'priority' => array('datatype' => 'TINYINT(1) UNSIGNED', 'allow_null' => false, 'default' => '5')), 'PRIMARY KEY' => array('id', 'extension_id'));
 $forum_db->create_table('extension_hooks', $schema);
 $schema = array('FIELDS' => array('group_id' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0'), 'forum_id' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0'), 'read_forum' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'post_replies' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'post_topics' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1')), 'PRIMARY KEY' => array('group_id', 'forum_id'));
 $forum_db->create_table('forum_perms', $schema);