/** * API function - set up shop */ function install() { global $db; if (!class_exists('phpbb_db_tools')) { include IP_ROOT_PATH . '/includes/db/db_tools.' . PHP_EXT; } $db_tool = new phpbb_db_tools($db); $tables = array(CAPTCHA_QUESTIONS_TABLE, CAPTCHA_ANSWERS_TABLE, CAPTCHA_QA_CONFIRM_TABLE); $schemas = array(CAPTCHA_QUESTIONS_TABLE => array('COLUMNS' => array('question_id' => array('UINT', Null, 'auto_increment'), 'strict' => array('BOOL', 0), 'lang_id' => array('UINT', 0), 'lang_iso' => array('VCHAR:30', ''), 'question_text' => array('TEXT_UNI', '')), 'PRIMARY_KEY' => 'question_id', 'KEYS' => array('lang_iso' => array('INDEX', 'lang_iso'))), CAPTCHA_ANSWERS_TABLE => array('COLUMNS' => array('question_id' => array('UINT', 0), 'answer_text' => array('STEXT_UNI', '')), 'KEYS' => array('question_id' => array('INDEX', 'question_id'))), CAPTCHA_QA_CONFIRM_TABLE => array('COLUMNS' => array('session_id' => array('CHAR:32', ''), 'confirm_id' => array('CHAR:32', ''), 'lang_iso' => array('VCHAR:30', ''), 'question_id' => array('UINT', 0), 'attempts' => array('UINT', 0), 'confirm_type' => array('USINT', 0)), 'KEYS' => array('session_id' => array('INDEX', 'session_id'), 'lookup' => array('INDEX', array('confirm_id', 'session_id', 'lang_iso'))), 'PRIMARY_KEY' => 'confirm_id')); foreach ($schemas as $table => $schema) { if (!$db_tool->sql_table_exists($table)) { $db_tool->sql_create_table($table, $schema); } } }
/** * Create temporary conversion table to store info about colliding usernames. */ function phpbb_create_userconv_table() { global $db, $phpbb_root_path, $phpEx; if (!class_exists('phpbb_db_tools')) { include($phpbb_root_path . 'includes/db/db_tools.' . $phpEx); } // create a temporary table in which we store the clean usernames $db->sql_return_on_error(true); $db->sql_query('DROP TABLE ' . USERCONV_TABLE); $db->sql_return_on_error(false); $db_tools = new phpbb_db_tools($db); $db_tools->sql_create_table(USERCONV_TABLE, array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), 'username_clean' => array('VCHAR_CI', ''), ), )); }