error($lang_install['MySQL InnoDB Not Supported']); } } } // Validate prefix if (strlen($db_prefix) > 0 && (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $db_prefix) || strlen($db_prefix) > 40)) { 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);
$query = array('UPDATE' => 'categories', 'SET' => 'father_id=' . intval($get_id[0]), 'WHERE' => 'id=' . $res['id']); $db->query_build($query) or error(__FILE__, __LINE__); } $imp_result = "Links and categories have now been imported from phpLD"; } elseif ($_POST['directory_script'] == 'fpds') { //collect category data $query = array('SELECT' => 'id, title, description, ref', 'FROM' => 'categories'); $cat_query = $imp->query_build($query) or error(__FILE__, __LINE__); //collect link data $query = array('SELECT' => 'id, title, description, url, category, ip, accepted', 'FROM' => 'pages'); $link_query = $imp->query_build($query) or error(__FILE__, __LINE__); //DBlayers switched table, so $db must be re-introduced $db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, false); while ($row = $imp->fetch_assoc($cat_query)) { $query = array('INSERT' => 'title, description, active, father_id, old_id, old_id_backup', 'INTO' => 'categories', 'VALUES' => '"' . $row['title'] . '", "' . $row['description'] . '", 1, "' . $row['ref'] . '", "' . $row['id'] . '", "' . $row['id'] . '"'); $db->query_build($query) or error(__FILE__, __LINE__); } while ($lrow = $imp->fetch_assoc($link_query)) { $query = array('SELECT' => 'id', 'FROM' => 'categories', 'WHERE' => 'old_id=' . $lrow['ref']); $new_cat_id = $db->query_build($query) or error(__FILE__, __LINE__); $new_cat_id = $db->fetch_row($new_cat_id); $query = array('INSERT' => 'title, url, description, active, category_id, ip, type, payment_status, old_category_id_backup', 'INTO' => 'links', 'VALUES' => '"' . $lrow['title'] . '", "' . $lrow['url'] . '", "' . $lrow['description'] . '", ' . ($lrow['accepted'] == 'y' ? 1 : 0) . ', ' . $new_cat_id[0] . ', "' . $lrow['ip'] . '", "a", "ok", ' . $lrow['category']); $db->query_build($query) or error(__FILE__, __LINE__); } //re-sort father_ids $query = array('UPDATE' => 'categories', 'SET' => 'father_id=' . intval($_POST['category_id']), 'WHERE' => 'father_id=0 AND old_id<>0'); $db->query_build($query) or error(__FILE__, __LINE__); $query = array('SELECT' => 'id, father_id, old_id', 'FROM' => 'categories', 'WHERE' => 'father_id <> ' . intval($_POST['category_id']) . ' AND old_id<>0 ORDER BY father_id ASC'); $sql_resort = $db->query_build($query) or error(__FILE__, __LINE__); while ($res = $db->fetch_assoc($sql_resort)) { $query = array('SELECT' => 'id', 'FROM' => 'categories', 'WHERE' => 'old_id=' . $res['father_id']);