diff -r 8baccbad4a55 -r a932ce8c4827 plugins/PunBB.php --- a/plugins/PunBB.php Sun Apr 06 00:35:38 2008 -0400 +++ b/plugins/PunBB.php Sun Jun 15 01:42:31 2008 -0400 @@ -43,6 +43,8 @@ } '); +$plugins->attachHook('user_registered', 'pun_handle_reg_event($user_id, $username);'); + define('PUNANO_VERSION', '0.1.3-beta'); define('PUNBB_VERSION', '1.3-beta'); define('PUN_ROOT', ENANO_ROOT . '/punbb/'); @@ -88,7 +90,7 @@ else if ( $session->auth_level < USER_LEVEL_ADMIN ) { $url = makeUrlNS('Special', 'Login/' . $paths->page, 'level=' . USER_LEVEL_ADMIN, true); - pun_redirect($url, 'Permission denied', 'You need to have an active high-privilege session to set up Punano.', 4); + redirect($url, 'Permission denied', 'You need to have an active high-privilege session to set up Punano.', 4); } $template->header(); @@ -186,7 +188,7 @@ } // Insert users - $q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE user_id > 1;'); + $q = $db->sql_query('SELECT user_id, user_level FROM '.table_prefix.'users WHERE user_id > 1;'); if ( !$q ) { echo $db->get_error(); @@ -195,9 +197,15 @@ $uid_list = array(); while ( $row = $db->fetchrow_num() ) { - $uid_list[] = $row[0]; + $g_id = 4; + switch ( $row[1] ) + { + case USER_LEVEL_ADMIN: $g_id = 1; break; + case USER_LEVEL_MOD: $g_id = 3; break; + } + $uid_list[] = "{$row[0]}, {$g_id}"; } - $query = 'INSERT INTO '.table_prefix.'pun_users(id) VALUES(' . implode('),(', $uid_list) . ');'; + $query = 'INSERT INTO '.table_prefix.'pun_users(id, group_id) VALUES(' . implode('),(', $uid_list) . ');'; if ( !$db->sql_query($query) ) { @@ -283,4 +291,19 @@ } +function pun_handle_reg_event($user_id, $username) +{ + global $db, $session, $paths, $template, $plugins; // Common objects + if ( getConfig('punbb_installed') != 'yes' ) + { + return false; + } + + // register the new user in PunBB + // at this point $username has been SQL-injection-proofed already by the session manager + $q = $db->sql_query('INSERT INTO ' . table_prefix . "pun_users ( id, username ) VALUES ( $user_id, '$username' );"); + if ( !$q ) + $db->_die(); +} + ?>