equal
deleted
inserted
replaced
41 { |
41 { |
42 require( "punbb/include/common.php" ); |
42 require( "punbb/include/common.php" ); |
43 } |
43 } |
44 '); |
44 '); |
45 |
45 |
|
46 $plugins->attachHook('user_registered', 'pun_handle_reg_event($user_id, $username);'); |
|
47 |
46 define('PUNANO_VERSION', '0.1.3-beta'); |
48 define('PUNANO_VERSION', '0.1.3-beta'); |
47 define('PUNBB_VERSION', '1.3-beta'); |
49 define('PUNBB_VERSION', '1.3-beta'); |
48 define('PUN_ROOT', ENANO_ROOT . '/punbb/'); |
50 define('PUN_ROOT', ENANO_ROOT . '/punbb/'); |
49 define('PUN', ''); |
51 define('PUN', ''); |
50 define('PUN_DISABLE_BUFFERING', ''); |
52 define('PUN_DISABLE_BUFFERING', ''); |
86 die_friendly('Punano initialization error', '<p>The Punano plugin doesn\'t have its database schema installed yet, and your user account doesn\'t have permission to install it. Please ask the administrator of this site to set up Punano.</p>'); |
88 die_friendly('Punano initialization error', '<p>The Punano plugin doesn\'t have its database schema installed yet, and your user account doesn\'t have permission to install it. Please ask the administrator of this site to set up Punano.</p>'); |
87 } |
89 } |
88 else if ( $session->auth_level < USER_LEVEL_ADMIN ) |
90 else if ( $session->auth_level < USER_LEVEL_ADMIN ) |
89 { |
91 { |
90 $url = makeUrlNS('Special', 'Login/' . $paths->page, 'level=' . USER_LEVEL_ADMIN, true); |
92 $url = makeUrlNS('Special', 'Login/' . $paths->page, 'level=' . USER_LEVEL_ADMIN, true); |
91 pun_redirect($url, 'Permission denied', 'You need to have an active high-privilege session to set up Punano.', 4); |
93 redirect($url, 'Permission denied', 'You need to have an active high-privilege session to set up Punano.', 4); |
92 } |
94 } |
93 |
95 |
94 $template->header(); |
96 $template->header(); |
95 |
97 |
96 // Permissions are good |
98 // Permissions are good |
184 return false; |
186 return false; |
185 } |
187 } |
186 } |
188 } |
187 |
189 |
188 // Insert users |
190 // Insert users |
189 $q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE user_id > 1;'); |
191 $q = $db->sql_query('SELECT user_id, user_level FROM '.table_prefix.'users WHERE user_id > 1;'); |
190 if ( !$q ) |
192 if ( !$q ) |
191 { |
193 { |
192 echo $db->get_error(); |
194 echo $db->get_error(); |
193 return false; |
195 return false; |
194 } |
196 } |
195 $uid_list = array(); |
197 $uid_list = array(); |
196 while ( $row = $db->fetchrow_num() ) |
198 while ( $row = $db->fetchrow_num() ) |
197 { |
199 { |
198 $uid_list[] = $row[0]; |
200 $g_id = 4; |
199 } |
201 switch ( $row[1] ) |
200 $query = 'INSERT INTO '.table_prefix.'pun_users(id) VALUES(' . implode('),(', $uid_list) . ');'; |
202 { |
|
203 case USER_LEVEL_ADMIN: $g_id = 1; break; |
|
204 case USER_LEVEL_MOD: $g_id = 3; break; |
|
205 } |
|
206 $uid_list[] = "{$row[0]}, {$g_id}"; |
|
207 } |
|
208 $query = 'INSERT INTO '.table_prefix.'pun_users(id, group_id) VALUES(' . implode('),(', $uid_list) . ');'; |
201 |
209 |
202 if ( !$db->sql_query($query) ) |
210 if ( !$db->sql_query($query) ) |
203 { |
211 { |
204 echo $db->get_error(); |
212 echo $db->get_error(); |
205 return false; |
213 return false; |
281 // Don't worry. This is sanitized. |
289 // Don't worry. This is sanitized. |
282 require PUN_ROOT . 'admin/' . $file . '.php'; |
290 require PUN_ROOT . 'admin/' . $file . '.php'; |
283 |
291 |
284 } |
292 } |
285 |
293 |
|
294 function pun_handle_reg_event($user_id, $username) |
|
295 { |
|
296 global $db, $session, $paths, $template, $plugins; // Common objects |
|
297 if ( getConfig('punbb_installed') != 'yes' ) |
|
298 { |
|
299 return false; |
|
300 } |
|
301 |
|
302 // register the new user in PunBB |
|
303 // at this point $username has been SQL-injection-proofed already by the session manager |
|
304 $q = $db->sql_query('INSERT INTO ' . table_prefix . "pun_users ( id, username ) VALUES ( $user_id, '$username' );"); |
|
305 if ( !$q ) |
|
306 $db->_die(); |
|
307 } |
|
308 |
286 ?> |
309 ?> |