here instead.'); // Make sure we are running at least MIN_PHP_VERSION if (!function_exists('version_compare') || version_compare(PHP_VERSION, MIN_PHP_VERSION, '<')) exit('You are running PHP version '.PHP_VERSION.'. PunBB requires at least PHP '.MIN_PHP_VERSION.' to run properly. You must upgrade your PHP installation before you can continue.'); // Disable error reporting for uninitialized variables error_reporting(E_ALL); // Turn off PHP time limit @set_time_limit(0); // We need some stuff from functions.php require FORUM_ROOT.'include/functions.php'; // Load UTF-8 functions require FORUM_ROOT.'include/utf8/utf8.php'; require FORUM_ROOT.'include/utf8/ucwords.php'; require FORUM_ROOT.'include/utf8/trim.php'; // Strip out "bad" UTF-8 characters forum_remove_bad_characters(); // // Generate output to be used for config.php // function generate_config_file() { global $db_type, $db_host, $db_name, $db_username, $db_password, $db_prefix, $base_url, $cookie_name; return ' 1) $dual_mysql = true; } if (function_exists('sqlite_open')) $db_extensions[] = array('sqlite', 'SQLite'); if (function_exists('pg_connect')) $db_extensions[] = array('pgsql', 'PostgreSQL'); if (empty($db_extensions)) error($lang_install['No database support']); // Make an educated guess regarding base_url $base_url_guess = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://').preg_replace('/:80$/', '', $_SERVER['HTTP_HOST']).substr(str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])), 0, -6); if (substr($base_url_guess, -1) == '/') $base_url_guess = substr($base_url_guess, 0, -1); // Check for available language packs $languages = get_language_packs(); ?> PunBB Installation

1) { ?>


'.$lang_install['Required'].'') ?>














1) { ?>


25) error($lang_install['Username too long']); if (utf8_strlen($password1) < 4) error($lang_install['Pass too short']); if ($password1 != $password2) error($lang_install['Pass not match']); if (strtolower($username) == 'guest') error($lang_install['Username guest']); if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username) || preg_match('/((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))/', $username)) error($lang_install['Username IP']); if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false) error($lang_install['Username reserved chars']); if (preg_match('/(?:\[\/?(?:b|u|i|h|colou?r|quote|code|img|url|email|list)\]|\[(?:code|quote|list)=)/i', $username)) error($lang_install['Username BBCode']); // Validate email if (!defined('FORUM_EMAIL_FUNCTIONS_LOADED')) require FORUM_ROOT.'include/email.php'; if (!is_valid_email($email)) error($lang_install['Invalid email']); // Make sure board title and description aren't left blank if ($board_title == '') $board_title = 'My PunBB forum'; if ($board_descrip == '') $board_descrip = 'Unfortunately no one can be told what PunBB is - you have to see it for yourself.'; if (utf8_strlen($base_url) == 0) error($lang_install['Missing base url']); if (!file_exists(FORUM_ROOT.'lang/'.$default_lang.'/common.php')) error($lang_install['Invalid language']); // Load the appropriate DB layer class switch ($db_type) { case 'mysql': require FORUM_ROOT.'include/dblayer/mysql.php'; break; case 'mysqli': require FORUM_ROOT.'include/dblayer/mysqli.php'; break; case 'pgsql': require FORUM_ROOT.'include/dblayer/pgsql.php'; break; case 'sqlite': require FORUM_ROOT.'include/dblayer/sqlite.php'; break; default: error(sprintf($lang_install['No such database type'], forum_htmlencode($db_type))); } // Create the database object (and connect/select db) $forum_db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, false); // If MySQL, make sure it's at least 4.1.2 if ($db_type == 'mysql' || $db_type == 'mysqli') { $mysql_info = $forum_db->get_version(); if (version_compare($mysql_info['version'], MIN_MYSQL_VERSION, '<')) error(sprintf($lang_install['Invalid MySQL version'], $mysql_version, MIN_MYSQL_VERSION)); } // 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 ($db_type == 'sqlite' && strtolower($db_prefix) == 'sqlite_') error($lang_install['SQLite prefix collision']); // Make sure PunBB isn't already installed $query = array( 'SELECT' => '1', 'FROM' => 'users', 'WHERE' => 'id = 1' ); $result = $forum_db->query_build($query); if ($forum_db->num_rows($result)) 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); $schema = array( 'FIELDS' => array( 'id' => array( 'datatype' => 'SERIAL', 'allow_null' => false ), 'forum_name' => array( 'datatype' => 'VARCHAR(80)', 'allow_null' => false, 'default' => '\'New forum\'' ), 'forum_desc' => array( 'datatype' => 'TEXT', 'allow_null' => true ), 'redirect_url' => array( 'datatype' => 'VARCHAR(100)', 'allow_null' => true ), 'moderators' => array( 'datatype' => 'TEXT', 'allow_null' => true ), 'num_topics' => array( 'datatype' => 'MEDIUMINT(8) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'num_posts' => array( 'datatype' => 'MEDIUMINT(8) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'last_post' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => true ), 'last_post_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => true ), 'last_poster' => array( 'datatype' => 'VARCHAR(200)', 'allow_null' => true ), 'sort_by' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'disp_position' => array( 'datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0' ), 'cat_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ) ), 'PRIMARY KEY' => array('id') ); $forum_db->create_table('forums', $schema); $schema = array( 'FIELDS' => array( 'g_id' => array( 'datatype' => 'SERIAL', 'allow_null' => false ), 'g_title' => array( 'datatype' => 'VARCHAR(50)', 'allow_null' => false, 'default' => '\'\'' ), 'g_user_title' => array( 'datatype' => 'VARCHAR(50)', 'allow_null' => true ), 'g_moderator' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'g_mod_edit_users' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'g_mod_rename_users' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'g_mod_change_passwords' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'g_mod_ban_users' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'g_read_board' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'g_view_users' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'g_post_replies' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'g_post_topics' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'g_edit_posts' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'g_delete_posts' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'g_delete_topics' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'g_set_title' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'g_search' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'g_search_users' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'g_send_email' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'g_post_flood' => array( 'datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '30' ), 'g_search_flood' => array( 'datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '30' ), 'g_email_flood' => array( 'datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '60' ) ), 'PRIMARY KEY' => array('g_id') ); $forum_db->create_table('groups', $schema); $schema = array( 'FIELDS' => array( 'user_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '1' ), 'ident' => array( 'datatype' => 'VARCHAR(200)', 'allow_null' => false, 'default' => '\'\'' ), 'logged' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'idle' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'csrf_token' => array( 'datatype' => 'VARCHAR(40)', 'allow_null' => false, 'default' => '\'\'' ), 'prev_url' => array( 'datatype' => 'VARCHAR(255)', 'allow_null' => true ), 'last_post' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => true ), 'last_search' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => true ), ), 'UNIQUE KEYS' => array( 'user_id_ident_idx' => array('user_id', 'ident') ), 'INDEXES' => array( 'ident_idx' => array('ident'), 'logged_idx' => array('logged') ), 'ENGINE' => 'HEAP' ); if ($db_type == 'mysql' || $db_type == 'mysqli') { $schema['UNIQUE KEYS']['user_id_ident_idx'] = array('user_id', 'ident(25)'); $schema['INDEXES']['ident_idx'] = array('ident(25)'); } $forum_db->create_table('online', $schema); $schema = array( 'FIELDS' => array( 'id' => array( 'datatype' => 'SERIAL', 'allow_null' => false ), 'poster' => array( 'datatype' => 'VARCHAR(200)', 'allow_null' => false, 'default' => '\'\'' ), 'poster_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '1' ), 'poster_ip' => array( 'datatype' => 'VARCHAR(39)', 'allow_null' => true ), 'poster_email' => array( 'datatype' => 'VARCHAR(80)', 'allow_null' => true ), 'message' => array( 'datatype' => 'TEXT', 'allow_null' => true ), 'hide_smilies' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'posted' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'edited' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => true ), 'edited_by' => array( 'datatype' => 'VARCHAR(200)', 'allow_null' => true ), 'topic_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ) ), 'PRIMARY KEY' => array('id'), 'INDEXES' => array( 'topic_id_idx' => array('topic_id'), 'multi_idx' => array('poster_id', 'topic_id') ) ); $forum_db->create_table('posts', $schema); $schema = array( 'FIELDS' => array( 'id' => array( 'datatype' => 'SERIAL', 'allow_null' => false ), 'rank' => array( 'datatype' => 'VARCHAR(50)', 'allow_null' => false, 'default' => '\'\'' ), 'min_posts' => array( 'datatype' => 'MEDIUMINT(8) UNSIGNED', 'allow_null' => false, 'default' => '0' ) ), 'PRIMARY KEY' => array('id') ); $forum_db->create_table('ranks', $schema); $schema = array( 'FIELDS' => array( 'id' => array( 'datatype' => 'SERIAL', 'allow_null' => false ), 'post_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'topic_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'forum_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'reported_by' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'created' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'message' => array( 'datatype' => 'TEXT', 'allow_null' => true ), 'zapped' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => true ), 'zapped_by' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => true ) ), 'PRIMARY KEY' => array('id'), 'INDEXES' => array( 'zapped_idx' => array('zapped') ) ); $forum_db->create_table('reports', $schema); $schema = array( 'FIELDS' => array( 'id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'ident' => array( 'datatype' => 'VARCHAR(200)', 'allow_null' => false, 'default' => '\'\'' ), 'search_data' => array( 'datatype' => 'TEXT', 'allow_null' => true ) ), 'PRIMARY KEY' => array('id'), 'INDEXES' => array( 'ident_idx' => array('ident') ) ); if ($db_type == 'mysql' || $db_type == 'mysqli') $schema['INDEXES']['ident_idx'] = array('ident(8)'); $forum_db->create_table('search_cache', $schema); $schema = array( 'FIELDS' => array( 'post_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'word_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'subject_match' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ) ), 'INDEXES' => array( 'word_id_idx' => array('word_id'), 'post_id_idx' => array('post_id') ) ); $forum_db->create_table('search_matches', $schema); $schema = array( 'FIELDS' => array( 'id' => array( 'datatype' => 'SERIAL', 'allow_null' => false ), 'word' => array( 'datatype' => 'VARCHAR(20)', 'allow_null' => false, 'default' => '\'\'', 'collation' => 'bin' ) ), 'PRIMARY KEY' => array('word'), 'INDEXES' => array( 'id_idx' => array('id') ) ); if ($db_type == 'sqlite') { $schema['PRIMARY KEY'] = array('id'); $schema['UNIQUE KEYS'] = array('word_idx' => array('word')); } $forum_db->create_table('search_words', $schema); $schema = array( 'FIELDS' => array( 'user_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'topic_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ) ), 'PRIMARY KEY' => array('user_id', 'topic_id') ); $forum_db->create_table('subscriptions', $schema); $schema = array( 'FIELDS' => array( 'id' => array( 'datatype' => 'SERIAL', 'allow_null' => false ), 'poster' => array( 'datatype' => 'VARCHAR(200)', 'allow_null' => false, 'default' => '\'\'' ), 'subject' => array( 'datatype' => 'VARCHAR(255)', 'allow_null' => false, 'default' => '\'\'' ), 'posted' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'first_post_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'last_post' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'last_post_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'last_poster' => array( 'datatype' => 'VARCHAR(200)', 'allow_null' => true ), 'num_views' => array( 'datatype' => 'MEDIUMINT(8) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'num_replies' => array( 'datatype' => 'MEDIUMINT(8) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'closed' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'sticky' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'moved_to' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => true ), 'forum_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ) ), 'PRIMARY KEY' => array('id'), 'INDEXES' => array( 'forum_id_idx' => array('forum_id'), 'moved_to_idx' => array('moved_to'), 'last_post_idx' => array('last_post'), 'first_post_id_idx' => array('first_post_id') ) ); $forum_db->create_table('topics', $schema); $schema = array( 'FIELDS' => array( 'id' => array( 'datatype' => 'SERIAL', 'allow_null' => false ), 'group_id' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '3' ), 'username' => array( 'datatype' => 'VARCHAR(200)', 'allow_null' => false, 'default' => '\'\'' ), 'password' => array( 'datatype' => 'VARCHAR(40)', 'allow_null' => false, 'default' => '\'\'' ), 'salt' => array( 'datatype' => 'VARCHAR(12)', 'allow_null' => true ), 'email' => array( 'datatype' => 'VARCHAR(80)', 'allow_null' => false, 'default' => '\'\'' ), 'title' => array( 'datatype' => 'VARCHAR(50)', 'allow_null' => true ), 'realname' => array( 'datatype' => 'VARCHAR(40)', 'allow_null' => true ), 'url' => array( 'datatype' => 'VARCHAR(100)', 'allow_null' => true ), 'jabber' => array( 'datatype' => 'VARCHAR(80)', 'allow_null' => true ), 'icq' => array( 'datatype' => 'VARCHAR(12)', 'allow_null' => true ), 'msn' => array( 'datatype' => 'VARCHAR(80)', 'allow_null' => true ), 'aim' => array( 'datatype' => 'VARCHAR(30)', 'allow_null' => true ), 'yahoo' => array( 'datatype' => 'VARCHAR(30)', 'allow_null' => true ), 'location' => array( 'datatype' => 'VARCHAR(30)', 'allow_null' => true ), 'signature' => array( 'datatype' => 'TEXT', 'allow_null' => true ), 'disp_topics' => array( 'datatype' => 'TINYINT(3) UNSIGNED', 'allow_null' => true ), 'disp_posts' => array( 'datatype' => 'TINYINT(3) UNSIGNED', 'allow_null' => true ), 'email_setting' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'notify_with_post' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'auto_notify' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'show_smilies' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'show_img' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'show_img_sig' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'show_avatars' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'show_sig' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1' ), 'access_keys' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'timezone' => array( 'datatype' => 'FLOAT', 'allow_null' => false, 'default' => '0' ), 'dst' => array( 'datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0' ), 'time_format' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'date_format' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'language' => array( 'datatype' => 'VARCHAR(25)', 'allow_null' => false, 'default' => '\'English\'' ), 'style' => array( 'datatype' => 'VARCHAR(25)', 'allow_null' => false, 'default' => '\'Oxygen\'' ), 'num_posts' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'last_post' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => true ), 'last_search' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => true ), 'last_email_sent' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => true ), 'registered' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'registration_ip' => array( 'datatype' => 'VARCHAR(39)', 'allow_null' => false, 'default' => '\'0.0.0.0\'' ), 'last_visit' => array( 'datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0' ), 'admin_note' => array( 'datatype' => 'VARCHAR(30)', 'allow_null' => true ), 'activate_string' => array( 'datatype' => 'VARCHAR(80)', 'allow_null' => true ), 'activate_key' => array( 'datatype' => 'VARCHAR(8)', 'allow_null' => true ), ), 'PRIMARY KEY' => array('id'), 'INDEXES' => array( 'registered_idx' => array('registered'), 'username_idx' => array('username') ) ); if ($db_type == 'mysql' || $db_type == 'mysqli') $schema['INDEXES']['username_idx'] = array('username(8)'); $forum_db->create_table('users', $schema); $now = time(); // Insert the four preset groups $query = array( 'INSERT' => 'g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood', 'INTO' => 'groups', 'VALUES' => '\'Administrators\', \'Administrator\', 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0' ); if ($db_type != 'pgsql') { $query['INSERT'] .= ', g_id'; $query['VALUES'] .= ', 1'; } $forum_db->query_build($query) or error(__FILE__, __LINE__); $query = array( 'INSERT' => 'g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood', 'INTO' => 'groups', 'VALUES' => '\'Guest\', NULL, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 60, 30, 0' ); if ($db_type != 'pgsql') { $query['INSERT'] .= ', g_id'; $query['VALUES'] .= ', 2'; } $forum_db->query_build($query) or error(__FILE__, __LINE__); $query = array( 'INSERT' => 'g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood', 'INTO' => 'groups', 'VALUES' => '\'Members\', NULL, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 60, 30, 60' ); if ($db_type != 'pgsql') { $query['INSERT'] .= ', g_id'; $query['VALUES'] .= ', 3'; } $forum_db->query_build($query) or error(__FILE__, __LINE__); $query = array( 'INSERT' => 'g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood', 'INTO' => 'groups', 'VALUES' => '\'Moderators\', \'Moderator\', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0' ); if ($db_type != 'pgsql') { $query['INSERT'] .= ', g_id'; $query['VALUES'] .= ', 4'; } $forum_db->query_build($query) or error(__FILE__, __LINE__); // Insert guest and first admin user $query = array( 'INSERT' => 'group_id, username, password, email', 'INTO' => 'users', 'VALUES' => '2, \'Guest\', \'Guest\', \'Guest\'' ); if ($db_type != 'pgsql') { $query['INSERT'] .= ', id'; $query['VALUES'] .= ', 1'; } $forum_db->query_build($query) or error(__FILE__, __LINE__); $salt = random_key(12); $query = array( 'INSERT' => 'group_id, username, password, email, language, num_posts, last_post, registered, registration_ip, last_visit, salt', 'INTO' => 'users', 'VALUES' => '1, \''.$forum_db->escape($username).'\', \''.forum_hash($password1, $salt).'\', \''.$forum_db->escape($email).'\', \''.$forum_db->escape($default_lang).'\', 1, '.$now.', '.$now.', \'127.0.0.1\', '.$now.', \''.$forum_db->escape($salt).'\'' ); $forum_db->query_build($query) or error(__FILE__, __LINE__); $new_uid = $forum_db->insert_id(); // Enable/disable avatars depending on file_uploads setting in PHP configuration $avatars = in_array(strtolower(@ini_get('file_uploads')), array('on', 'true', '1')) ? 1 : 0; // Enable/disable automatic check for updates depending on PHP environment (require cURL, fsockopen or allow_url_fopen) $check_for_updates = (function_exists('curl_init') || function_exists('fsockopen') || in_array(strtolower(@ini_get('allow_url_fopen')), array('on', 'true', '1'))) ? 1 : 0; // Insert config data $config = array( 'o_cur_version' => "'".FORUM_VERSION."'", 'o_database_revision' => "'".FORUM_DB_REVISION."'", 'o_board_title' => "'".$forum_db->escape($board_title)."'", 'o_board_desc' => "'".$forum_db->escape($board_descrip)."'", 'o_default_timezone' => "'0'", 'o_time_format' => "'H:i:s'", 'o_date_format' => "'Y-m-d'", 'o_check_for_updates' => "'$check_for_updates'", 'o_check_for_versions' => "'$check_for_updates'", 'o_timeout_visit' => "'1800'", 'o_timeout_online' => "'300'", 'o_redirect_delay' => "'1'", 'o_show_version' => "'0'", 'o_show_user_info' => "'1'", 'o_show_post_count' => "'1'", 'o_signatures' => "'1'", 'o_smilies' => "'1'", 'o_smilies_sig' => "'1'", 'o_make_links' => "'1'", 'o_default_lang' => "'".$forum_db->escape($default_lang)."'", 'o_default_style' => "'Oxygen'", 'o_default_user_group' => "'3'", 'o_topic_review' => "'15'", 'o_disp_topics_default' => "'30'", 'o_disp_posts_default' => "'25'", 'o_indent_num_spaces' => "'4'", 'o_quote_depth' => "'3'", 'o_quickpost' => "'1'", 'o_users_online' => "'1'", 'o_censoring' => "'0'", 'o_ranks' => "'1'", 'o_show_dot' => "'0'", 'o_topic_views' => "'1'", 'o_quickjump' => "'1'", 'o_gzip' => "'0'", 'o_additional_navlinks' => "''", 'o_report_method' => "'0'", 'o_regs_report' => "'0'", 'o_default_email_setting' => "'1'", 'o_mailing_list' => "'".$forum_db->escape($email)."'", 'o_avatars' => "'$avatars'", 'o_avatars_dir' => "'img/avatars'", 'o_avatars_width' => "'60'", 'o_avatars_height' => "'60'", 'o_avatars_size' => "'10240'", 'o_search_all_forums' => "'1'", 'o_sef' => "'Default'", 'o_admin_email' => "'".$forum_db->escape($email)."'", 'o_webmaster_email' => "'".$forum_db->escape($email)."'", 'o_subscriptions' => "'1'", 'o_smtp_host' => "NULL", 'o_smtp_user' => "NULL", 'o_smtp_pass' => "NULL", 'o_smtp_ssl' => "'0'", 'o_regs_allow' => "'1'", 'o_regs_verify' => "'0'", 'o_announcement' => "'0'", 'o_announcement_heading' => "'".$lang_install['Default announce heading']."'", 'o_announcement_message' => "'".$lang_install['Default announce message']."'", 'o_rules' => "'0'", 'o_rules_message' => "'".$lang_install['Default rules']."'", 'o_maintenance' => "'0'", 'o_maintenance_message' => "'".$lang_install['Default maint message']."'", 'o_default_dst' => "'0'", 'p_message_bbcode' => "'1'", 'p_message_img_tag' => "'1'", 'p_message_all_caps' => "'1'", 'p_subject_all_caps' => "'1'", 'p_sig_all_caps' => "'1'", 'p_sig_bbcode' => "'1'", 'p_sig_img_tag' => "'0'", 'p_sig_length' => "'400'", 'p_sig_lines' => "'4'", 'p_allow_banned_email' => "'1'", 'p_allow_dupe_email' => "'0'", 'p_force_guest_email' => "'1'" ); foreach ($config as $conf_name => $conf_value) { $query = array( 'INSERT' => 'conf_name, conf_value', 'INTO' => 'config', 'VALUES' => '\''.$conf_name.'\', '.$conf_value.'' ); $forum_db->query_build($query) or error(__FILE__, __LINE__); } // Insert some other default data $query = array( 'INSERT' => 'cat_name, disp_position', 'INTO' => 'categories', 'VALUES' => '\''.$lang_install['Default category name'].'\', 1' ); $forum_db->query_build($query) or error(__FILE__, __LINE__); $query = array( 'INSERT' => 'forum_name, forum_desc, num_topics, num_posts, last_post, last_post_id, last_poster, disp_position, cat_id', 'INTO' => 'forums', 'VALUES' => '\''.$lang_install['Default forum name'].'\', \''.$lang_install['Default forum descrip'].'\', 1, 1, '.$now.', 1, \''.$forum_db->escape($username).'\', 1, '.$forum_db->insert_id().'' ); $forum_db->query_build($query) or error(__FILE__, __LINE__); $query = array( 'INSERT' => 'poster, subject, posted, first_post_id, last_post, last_post_id, last_poster, forum_id', 'INTO' => 'topics', 'VALUES' => '\''.$forum_db->escape($username).'\', \''.$lang_install['Default topic subject'].'\', '.$now.', 1, '.$now.', 1, \''.$forum_db->escape($username).'\', '.$forum_db->insert_id().'' ); $forum_db->query_build($query) or error(__FILE__, __LINE__); $query = array( 'INSERT' => 'poster, poster_id, poster_ip, message, posted, topic_id', 'INTO' => 'posts', 'VALUES' => '\''.$forum_db->escape($username).'\', '.$new_uid.', \'127.0.0.1\', \''.$lang_install['Default post contents'].'\', '.$now.', '.$forum_db->insert_id().'' ); if ($db_type != 'pgsql') { $query['INSERT'] .= ', id'; $query['VALUES'] .= ', 1'; } $forum_db->query_build($query) or error(__FILE__, __LINE__); // Add new post to search table require FORUM_ROOT.'include/search_idx.php'; update_search_index('post', $forum_db->insert_id(), $lang_install['Default post contents'], $lang_install['Default topic subject']); // Insert the default ranks $query = array( 'INSERT' => 'rank, min_posts', 'INTO' => 'ranks', 'VALUES' => '\''.$lang_install['Default rank 1'].'\', 0' ); $forum_db->query_build($query) or error(__FILE__, __LINE__); $query = array( 'INSERT' => 'rank, min_posts', 'INTO' => 'ranks', 'VALUES' => '\''.$lang_install['Default rank 2'].'\', 10' ); $forum_db->query_build($query) or error(__FILE__, __LINE__); $forum_db->end_transaction(); $alerts = array(); // Check if the cache directory is writable if (!is_writable('./cache/')) $alerts[] = '
  • '.$lang_install['No cache write'].'
  • '; // Check if default avatar directory is writable if (!is_writable('./img/avatars/')) $alerts[] = '
  • '.$lang_install['No avatar write'].'
  • '; // Check if we disabled uploading avatars because file_uploads was disabled if ($avatars == '0') $alerts[] = '
  • '.$lang_install['File upload alert'].'
  • '; // Add some random bytes at the end of the cookie name to prevent collisions $cookie_name = 'forum_cookie_'.random_key(6, false, true); /// Generate the config.php file data $config = generate_config_file(); // Attempt to write config.php and serve it up for download if writing fails $written = false; if (is_writable(FORUM_ROOT)) { $fh = @fopen(FORUM_ROOT.'config.php', 'wb'); if ($fh) { fwrite($fh, $config); fclose($fh); $written = true; } } if ($install_pun_repository && is_readable(FORUM_ROOT.'extensions/pun_repository/manifest.xml')) { require FORUM_ROOT.'include/xml.php'; $ext_data = xml_to_array(file_get_contents(FORUM_ROOT.'extensions/pun_repository/manifest.xml')); if (!empty($ext_data)) { $query = array( 'INSERT' => 'id, title, version, description, author, uninstall, uninstall_note, dependencies', 'INTO' => 'extensions', 'VALUES' => '\'pun_repository\', \''.$forum_db->escape($ext_data['extension']['title']).'\', \''.$forum_db->escape($ext_data['extension']['version']).'\', \''.$forum_db->escape($ext_data['extension']['description']).'\', \''.$forum_db->escape($ext_data['extension']['author']).'\', NULL, NULL, \'||\'', ); $forum_db->query_build($query) or error(__FILE__, __LINE__); if (isset($ext_data['extension']['hooks']['hook'])) { foreach ($ext_data['extension']['hooks']['hook'] as $ext_hook) { $cur_hooks = explode(',', $ext_hook['attributes']['id']); foreach ($cur_hooks as $cur_hook) { $query = array( 'INSERT' => 'id, extension_id, code, installed, priority', 'INTO' => 'extension_hooks', 'VALUES' => '\''.$forum_db->escape(forum_trim($cur_hook)).'\', \'pun_repository\', \''.$forum_db->escape(forum_trim($ext_hook['content'])).'\', '.time().', '.(isset($ext_hook['attributes']['priority']) ? $ext_hook['attributes']['priority'] : 5) ); $forum_db->query_build($query) or error(__FILE__, __LINE__); } } } } } ?> PunBB Installation

    '.$lang_install['Go to index'].'') ?>

    '.$lang_install['Go to index'].'') ?>