--- a/punbb/register.php Wed Jul 11 21:28:39 2007 -0400
+++ b/punbb/register.php Thu Jul 12 01:04:01 2007 -0400
@@ -23,8 +23,11 @@
************************************************************************/
-define('PUN_ROOT', './');
-require PUN_ROOT.'include/common.php';
+//define('PUN_ROOT', './');
+//require PUN_ROOT.'include/common.php';
+
+global $pun_db, $pun_user, $pun_config, $lang_common;
+
// If we are logged in, we shouldn't be here
@@ -46,7 +49,7 @@
// User pressed the cancel button
if (isset($_GET['cancel']))
- redirect('index.php', $lang_register['Reg cancel redirect']);
+ pun_redirect('index.php', $lang_register['Reg cancel redirect']);
else if ($pun_config['o_rules'] == '1' && !isset($_GET['agree']) && !isset($_POST['form_sent']))
@@ -80,9 +83,9 @@
else if (isset($_POST['form_sent']))
{
// Check that someone from this IP didn't register a user within the last hour (DoS prevention)
- $result = $db->query('SELECT 1 FROM '.$db->prefix.'users WHERE registration_ip=\''.get_remote_address().'\' AND registered>'.(time() - 3600)) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
+ $result = $pun_db->query('SELECT 1 FROM '.$pun_db->prefix.'users WHERE registration_ip=\''.get_remote_address().'\' AND registered>'.(time() - 3600)) or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error());
- if ($db->num_rows($result))
+ if ($pun_db->num_rows($result))
message('A new user was registered with the same IP address as you within the last hour. To prevent registration flooding, at least an hour has to pass between registrations from the same IP. Sorry for the inconvenience.');
@@ -132,11 +135,11 @@
}
// Check that the username (or a too similar username) is not already registered
- $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE UPPER(username)=UPPER(\''.$db->escape($username).'\') OR UPPER(username)=UPPER(\''.$db->escape(preg_replace('/[^\w]/', '', $username)).'\')') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
+ $result = $pun_db->query('SELECT username FROM '.$pun_db->prefix.'users WHERE UPPER(username)=UPPER(\''.$pun_db->escape($username).'\') OR UPPER(username)=UPPER(\''.$pun_db->escape(preg_replace('/[^\w]/', '', $username)).'\')') or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error());
- if ($db->num_rows($result))
+ if ($pun_db->num_rows($result))
{
- $busy = $db->result($result);
+ $busy = $pun_db->result($result);
message($lang_register['Username dupe 1'].' '.pun_htmlspecialchars($busy).'. '.$lang_register['Username dupe 2']);
}
@@ -163,13 +166,13 @@
// Check if someone else already has registered with that e-mail address
$dupe_list = array();
- $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE email=\''.$email1.'\'') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
- if ($db->num_rows($result))
+ $result = $pun_db->query('SELECT username FROM '.$pun_db->prefix.'users WHERE email=\''.$email1.'\'') or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error());
+ if ($pun_db->num_rows($result))
{
if ($pun_config['p_allow_dupe_email'] == '0')
message($lang_prof_reg['Dupe e-mail']);
- while ($cur_dupe = $db->fetch_assoc($result))
+ while ($cur_dupe = $pun_db->fetch_assoc($result))
$dupe_list[] = $cur_dupe['username'];
}
@@ -196,8 +199,8 @@
$password_hash = pun_hash($password1);
// Add the user
- $db->query('INSERT INTO '.$db->prefix.'users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) VALUES(\''.$db->escape($username).'\', '.$intial_group_id.', \''.$password_hash.'\', \''.$email1.'\', '.$email_setting.', '.$save_pass.', '.$timezone.' , \''.$db->escape($language).'\', \''.$pun_config['o_default_style'].'\', '.$now.', \''.get_remote_address().'\', '.$now.')') or error('Unable to create user', __FILE__, __LINE__, $db->error());
- $new_uid = $db->insert_id();
+ $pun_db->query('INSERT INTO '.$pun_db->prefix.'users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) VALUES(\''.$pun_db->escape($username).'\', '.$intial_group_id.', \''.$password_hash.'\', \''.$email1.'\', '.$email_setting.', '.$save_pass.', '.$timezone.' , \''.$pun_db->escape($language).'\', \''.$pun_config['o_default_style'].'\', '.$now.', \''.get_remote_address().'\', '.$now.')') or error('Unable to create user', __FILE__, __LINE__, $pun_db->error());
+ $new_uid = $pun_db->insert_id();
// If we previously found out that the e-mail was banned
@@ -252,7 +255,7 @@
pun_setcookie($new_uid, $password_hash, ($save_pass != '0') ? $now + 31536000 : 0);
- redirect('index.php', $lang_register['Reg complete']);
+ pun_redirect('index.php', $lang_register['Reg complete']);
}