Zeile 1 | Zeile 1 |
---|
<?php /** * MyBB 1.4
|
<?php /** * MyBB 1.4
|
* Copyright � 2008 MyBB Group, All Rights Reserved
| * Copyright © 2008 MyBB Group, All Rights Reserved
|
* * Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* * Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* $Id: user.php 4052 2008-07-29 15:45:49Z Tikitiki $
| * $Id: user.php 4620 2009-12-20 07:29:15Z dennis $
|
*/
// Disallow direct access to this file for security reasons
| */
// Disallow direct access to this file for security reasons
|
Zeile 70 | Zeile 70 |
---|
// Fix bad characters $username = trim($username);
|
// Fix bad characters $username = trim($username);
|
$username = str_replace(array(unicode_chr(160), unicode_chr(173), unicode_chr(0xCA), dec_to_utf8(8238), dec_to_utf8(8237)), array(" ", "-", "", "", ""), $username);
| $username = str_replace(array(unicode_chr(160), unicode_chr(173), unicode_chr(0xCA), dec_to_utf8(8238), dec_to_utf8(8237), dec_to_utf8(8203)), array(" ", "-", "", "", "", ""), $username);
|
// Remove multiple spaces from the username $username = preg_replace("#\s{2,}#", " ", $username);
| // Remove multiple spaces from the username $username = preg_replace("#\s{2,}#", " ", $username);
|
Zeile 170 | Zeile 170 |
---|
$user = &$this->data;
// Always check for the length of the password.
|
$user = &$this->data;
// Always check for the length of the password.
|
if(my_strlen($user['password']) < $mybb->settings['minpasswordlength'])
| if(my_strlen($user['password']) < $mybb->settings['minpasswordlength'] || my_strlen($user['password']) > $mybb->settings['maxpasswordlength'])
|
{ $this->set_error('invalid_password_length', array($mybb->settings['minpasswordlength'], $mybb->settings['maxpasswordlength'])); return false;
| { $this->set_error('invalid_password_length', array($mybb->settings['minpasswordlength'], $mybb->settings['maxpasswordlength'])); return false;
|
Zeile 220 | Zeile 220 |
---|
$user = &$this->data; return true; }
|
$user = &$this->data; return true; }
|
|
|
/** * Verifies if an email address is valid or not. *
| /** * Verifies if an email address is valid or not. *
|
Zeile 253 | Zeile 254 |
---|
} // Check signed up emails
|
} // Check signed up emails
|
if($mybb->settings['allowmultipleemails'] == 0)
| // Ignore the ACP because the Merge System sometimes produces users with duplicate email addresses (Not A Bug) if($mybb->settings['allowmultipleemails'] == 0 && !defined("IN_ADMINCP"))
|
{ if(email_already_in_use($user['email'], $user['uid'])) {
| { if(email_already_in_use($user['email'], $user['uid'])) {
|
Zeile 264 | Zeile 266 |
---|
// If we have an "email2", verify it matches the existing email if(isset($user['email2']) && $user['email'] != $user['email2'])
|
// If we have an "email2", verify it matches the existing email if(isset($user['email2']) && $user['email'] != $user['email2'])
|
{
| {
|
$this->set_error("emails_dont_match"); return false; }
|
$this->set_error("emails_dont_match"); return false; }
|
| return true;
|
}
/**
| }
/**
|
Zeile 276 | Zeile 280 |
---|
* @return boolean True when valid, false when invalid. */ function verify_website()
|
* @return boolean True when valid, false when invalid. */ function verify_website()
|
{ $website = &$this->data['website'];
| { $website = &$this->data['website'];
|
if(empty($website) || my_strtolower($website) == 'http://' || my_strtolower($website) == 'https://') { $website = ''; return true;
|
if(empty($website) || my_strtolower($website) == 'http://' || my_strtolower($website) == 'https://') { $website = ''; return true;
|
}
| }
|
// Does the website start with http(s)://? if(my_strtolower(substr($website, 0, 4)) != "http") { // Website does not start with http://, let's see if the user forgot. $website = "http://".$website;
|
// Does the website start with http(s)://? if(my_strtolower(substr($website, 0, 4)) != "http") { // Website does not start with http://, let's see if the user forgot. $website = "http://".$website;
|
}
return true; }
| }
return true; }
|
/** * Verifies if an ICQ number is valid or not.
| /** * Verifies if an ICQ number is valid or not.
|
Zeile 307 | Zeile 311 |
---|
if($icq != '' && !is_numeric($icq)) { $this->set_error("invalid_icq_number");
|
if($icq != '' && !is_numeric($icq)) { $this->set_error("invalid_icq_number");
|
return false;
| return false;
|
} $icq = intval($icq); return true;
| } $icq = intval($icq); return true;
|
Zeile 336 | Zeile 340 |
---|
* @return boolean True when valid, false when invalid. */ function verify_birthday()
|
* @return boolean True when valid, false when invalid. */ function verify_birthday()
|
{
| {
|
global $mybb;
$user = &$this->data;
| global $mybb;
$user = &$this->data;
|
Zeile 353 | Zeile 357 |
---|
$birthday['year'] = intval($birthday['year']);
// Error if a day and month exists, and the birthday day and range is not in range
|
$birthday['year'] = intval($birthday['year']);
// Error if a day and month exists, and the birthday day and range is not in range
|
if($birthday['day'] && $birthday['month'])
| if($birthday['day'] != 0 || $birthday['month'] != 0)
|
{ if($birthday['day'] < 1 || $birthday['day'] > 31 || $birthday['month'] < 1 || $birthday['month'] > 12 || ($birthday['month'] == 2 && $birthday['day'] > 29))
|
{ if($birthday['day'] < 1 || $birthday['day'] > 31 || $birthday['month'] < 1 || $birthday['month'] > 12 || ($birthday['month'] == 2 && $birthday['day'] > 29))
|
{ $this->set_error("invalid_birthday"); return false; }
// Check if the day actually exists. $months = get_bdays($birthday['year']); if($birthday['day'] > $months[$birthday['month']-1])
| |
{ $this->set_error("invalid_birthday"); return false; }
|
{ $this->set_error("invalid_birthday"); return false; }
|
| }
// Check if the day actually exists. $months = get_bdays($birthday['year']); if($birthday['day'] > $months[$birthday['month']-1]) { $this->set_error("invalid_birthday"); return false;
|
}
// Error if a year exists and the year is out of range if($birthday['year'] != 0 && ($birthday['year'] < (date("Y")-100)) || $birthday['year'] > date("Y")) { $this->set_error("invalid_birthday");
|
}
// Error if a year exists and the year is out of range if($birthday['year'] != 0 && ($birthday['year'] < (date("Y")-100)) || $birthday['year'] > date("Y")) { $this->set_error("invalid_birthday");
|
return false; }
| return false; }
// Error if COPPA is on, and the user hasn't verified their age / under 13 if($mybb->settings['coppa'] == "enabled" && ($birthday['year'] == 0 || !$birthday['year'])) { $this->set_error("invalid_birthday_coppa"); return false; } elseif(($mybb->settings['coppa'] == "deny" || $mybb->settings['coppa'] == "enabled") && $birthday['year'] > (date("Y")-13)) { $this->set_error("invalid_birthday_coppa2"); return false; }
|
// Make the user's birthday field if($birthday['year'] != 0)
| // Make the user's birthday field if($birthday['year'] != 0)
|
Zeile 393 | Zeile 409 |
---|
// No field is specified, so return an empty string for an unknown birthday $user['bday'] = ''; }
|
// No field is specified, so return an empty string for an unknown birthday $user['bday'] = ''; }
|
| return true; } /** * Verifies if the post count field is filled in correctly. * * @return boolean True when valid, false when invalid. */ function verify_postnum() { $user = &$this->data; if($user['postnum'] < 0) { $this->set_error("invalid_postnum"); return false; }
|
return true; }
| return true; }
|
Zeile 433 | Zeile 467 |
---|
$field = "fid{$profilefield['fid']}";
// If the profile field is required, but not filled in, present error.
|
$field = "fid{$profilefield['fid']}";
// If the profile field is required, but not filled in, present error.
|
if(trim($profile_fields[$field]) == "" && $profilefield['required'] == 1 && !defined('IN_ADMINCP'))
| if($type != "multiselect" && $type != "checkbox") { if(trim($profile_fields[$field]) == "" && $profilefield['required'] == 1 && !defined('IN_ADMINCP')) { $this->set_error('missing_required_profile_field', array($profilefield['name'])); } } elseif(($type == "multiselect" || $type == "checkbox") && $profile_fields[$field] == "" && $profilefield['required'] == 1 && !defined('IN_ADMINCP'))
|
{ $this->set_error('missing_required_profile_field', array($profilefield['name'])); }
| { $this->set_error('missing_required_profile_field', array($profilefield['name'])); }
|
Zeile 465 | Zeile 506 |
---|
{ $this->set_error('bad_profile_field_values', array($profilefield['name'])); }
|
{ $this->set_error('bad_profile_field_values', array($profilefield['name'])); }
|
| $options = $db->escape_string($profile_fields[$field]); } elseif($type == "textarea") { if($profilefield['maxlength'] > 0 && my_strlen($profile_fields[$field]) > $profilefield['maxlength']) { $this->set_error('max_limit_reached', array($profilefield['name'], $profilefield['maxlength'])); }
|
$options = $db->escape_string($profile_fields[$field]); } else
| $options = $db->escape_string($profile_fields[$field]); } else
|
Zeile 472 | Zeile 522 |
---|
$options = $db->escape_string($profile_fields[$field]); } $user['user_fields'][$field] = $options;
|
$options = $db->escape_string($profile_fields[$field]); } $user['user_fields'][$field] = $options;
|
}
return true;
| }
return true;
|
}
/**
| }
/**
|
Zeile 490 | Zeile 540 |
---|
// Does the referrer exist or not? if($mybb->settings['usereferrals'] == 1 && $user['referrer'] != '')
|
// Does the referrer exist or not? if($mybb->settings['usereferrals'] == 1 && $user['referrer'] != '')
|
{
| {
|
$query = $db->simple_select('users', 'uid', "username='".$db->escape_string($user['referrer'])."'", array('limit' => 1)); $referrer = $db->fetch_array($query); if(!$referrer['uid'])
| $query = $db->simple_select('users', 'uid', "username='".$db->escape_string($user['referrer'])."'", array('limit' => 1)); $referrer = $db->fetch_array($query); if(!$referrer['uid'])
|
Zeile 528 | Zeile 578 |
---|
$this->verify_yesno_option($options, 'showavatars', 1); $this->verify_yesno_option($options, 'showquickreply', 1); $this->verify_yesno_option($options, 'showredirect', 1);
|
$this->verify_yesno_option($options, 'showavatars', 1); $this->verify_yesno_option($options, 'showquickreply', 1); $this->verify_yesno_option($options, 'showredirect', 1);
|
$this->verify_yesno_option($options, 'classicpostbit', 0);
| if($mybb->settings['postlayout'] == 'classic') { $this->verify_yesno_option($options, 'classicpostbit', 1); } else { $this->verify_yesno_option($options, 'classicpostbit', 0); }
|
if(array_key_exists('subscriptionmethod', $options)) { // Value out of range
| if(array_key_exists('subscriptionmethod', $options)) { // Value out of range
|
Zeile 585 | Zeile 643 |
---|
}
// Verify the "threads per page" option.
|
}
// Verify the "threads per page" option.
|
if($this->method == "insert" || (array_key_exists('tpp', $options) && $mybb->settings['usetppoptions']))
| if($this->method == "insert" || (array_key_exists('tpp', $options) && $mybb->settings['usertppoptions']))
|
{ $explodedtpp = explode(",", $mybb->settings['usertppoptions']); if(is_array($explodedtpp))
| { $explodedtpp = explode(",", $mybb->settings['usertppoptions']); if(is_array($explodedtpp))
|
Zeile 690 | Zeile 748 |
---|
* @return boolean True when valid, false when invalid. */ function verify_away()
|
* @return boolean True when valid, false when invalid. */ function verify_away()
|
{
| {
|
global $mybb;
$user = &$this->data;
| global $mybb;
$user = &$this->data;
|
Zeile 709 | Zeile 767 |
---|
if(!$returnday || !$returnmonth || !$returnyear) { $this->set_error("missing_returndate");
|
if(!$returnday || !$returnmonth || !$returnyear) { $this->set_error("missing_returndate");
|
| return false;
|
}
|
}
|
| // Validate the return date lengths $user['away']['returndate'] = substr($returnday, 0, 2).'-'.substr($returnmonth, 0, 2).'-'.substr($returnyear, 0, 4);
|
}
|
}
|
| return true;
|
}
/**
| }
/**
|
Zeile 719 | Zeile 782 |
---|
* @return boolean True when valid, false when invalid. */ function verify_language()
|
* @return boolean True when valid, false when invalid. */ function verify_language()
|
{
| {
|
global $lang;
$language = &$this->data['language'];
| global $lang;
$language = &$this->data['language'];
|
Zeile 792 | Zeile 855 |
---|
if($this->method == "insert" || array_key_exists('usergroup', $user)) { $this->verify_usergroup();
|
if($this->method == "insert" || array_key_exists('usergroup', $user)) { $this->verify_usergroup();
|
}
| }
|
if($this->method == "insert" || array_key_exists('email', $user))
|
if($this->method == "insert" || array_key_exists('email', $user))
|
{
| {
|
$this->verify_email();
|
$this->verify_email();
|
}
| }
|
if($this->method == "insert" || array_key_exists('website', $user))
|
if($this->method == "insert" || array_key_exists('website', $user))
|
{
| {
|
$this->verify_website(); } if($this->method == "insert" || array_key_exists('icq', $user))
| $this->verify_website(); } if($this->method == "insert" || array_key_exists('icq', $user))
|
Zeile 806 | Zeile 869 |
---|
$this->verify_icq(); } if($this->method == "insert" || array_key_exists('msn', $user))
|
$this->verify_icq(); } if($this->method == "insert" || array_key_exists('msn', $user))
|
{
| {
|
$this->verify_msn();
|
$this->verify_msn();
|
| } if($this->method == "insert" || array_key_exists('postnum', $user)) { $this->verify_postnum();
|
} if($this->method == "insert" || is_array($user['birthday'])) { $this->verify_birthday();
|
} if($this->method == "insert" || is_array($user['birthday'])) { $this->verify_birthday();
|
}
| }
|
if($this->method == "insert" || array_key_exists('profile_fields', $user)) { $this->verify_profile_fields();
| if($this->method == "insert" || array_key_exists('profile_fields', $user)) { $this->verify_profile_fields();
|
Zeile 828 | Zeile 895 |
---|
if($this->method == "insert" || array_key_exists('regdate', $user)) { $this->verify_regdate();
|
if($this->method == "insert" || array_key_exists('regdate', $user)) { $this->verify_regdate();
|
}
| }
|
if($this->method == "insert" || array_key_exists('lastvisit', $user)) { $this->verify_lastvisit(); } if($this->method == "insert" || array_key_exists('lastactive', $user))
|
if($this->method == "insert" || array_key_exists('lastvisit', $user)) { $this->verify_lastvisit(); } if($this->method == "insert" || array_key_exists('lastactive', $user))
|
{
| {
|
$this->verify_lastactive(); } if($this->method == "insert" || array_key_exists('away', $user))
| $this->verify_lastactive(); } if($this->method == "insert" || array_key_exists('away', $user))
|
Zeile 849 | Zeile 916 |
---|
{ $this->verify_checkfields(); }
|
{ $this->verify_checkfields(); }
|
$plugins->run_hooks_by_ref("datahandler_user_validate", $this);
| if(method_exists($plugins, "run_hooks_by_ref")) { $plugins->run_hooks_by_ref("datahandler_user_validate", $this); }
|
// We are done validating, return. $this->set_validated(true); if(count($this->get_errors()) > 0)
| // We are done validating, return. $this->set_validated(true); if(count($this->get_errors()) > 0)
|
Zeile 958 | Zeile 1028 |
---|
{ $this->user_insert_data['dst'] = 0; }
|
{ $this->user_insert_data['dst'] = 0; }
|
$plugins->run_hooks_by_ref("datahandler_user_insert", $this);
| if(method_exists($plugins, "run_hooks_by_ref")) { $plugins->run_hooks_by_ref("datahandler_user_insert", $this); }
|
$this->uid = $db->insert_query("users", $this->user_insert_data);
$user['user_fields']['ufid'] = $this->uid;
| $this->uid = $db->insert_query("users", $this->user_insert_data);
$user['user_fields']['ufid'] = $this->uid;
|
Zeile 972 | Zeile 1045 |
---|
{ continue; }
|
{ continue; }
|
$user['user_fields']["ufid{$profile_field['fid']}"] = '';
| $user['user_fields']["fid{$profile_field['fid']}"] = '';
|
}
|
}
|
$db->insert_query("userfields", $user['user_fields']);
| $db->insert_query("userfields", $user['user_fields'], false);
|
// Update forum stats update_stats(array('numusers' => '+1'));
| // Update forum stats update_stats(array('numusers' => '+1'));
|
Zeile 1001 | Zeile 1074 |
---|
if(!$this->get_validated()) { die("The user needs to be validated before inserting it into the DB.");
|
if(!$this->get_validated()) { die("The user needs to be validated before inserting it into the DB.");
|
}
| }
|
if(count($this->get_errors()) > 0) { die("The user is not valid.");
| if(count($this->get_errors()) > 0) { die("The user is not valid.");
|
Zeile 1042 | Zeile 1115 |
---|
if(isset($user['additionalgroups'])) { $this->user_update_data['additionalgroups'] = $db->escape_string($user['additionalgroups']);
|
if(isset($user['additionalgroups'])) { $this->user_update_data['additionalgroups'] = $db->escape_string($user['additionalgroups']);
|
}
| }
|
if(isset($user['displaygroup'])) { $this->user_update_data['displaygroup'] = intval($user['displaygroup']);
| if(isset($user['displaygroup'])) { $this->user_update_data['displaygroup'] = intval($user['displaygroup']);
|
Zeile 1086 | Zeile 1159 |
---|
if(isset($user['msn'])) { $this->user_update_data['msn'] = $db->escape_string(htmlspecialchars($user['msn']));
|
if(isset($user['msn'])) { $this->user_update_data['msn'] = $db->escape_string(htmlspecialchars($user['msn']));
|
}
| }
|
if(isset($user['bday'])) { $this->user_update_data['birthday'] = $user['bday']; } if(isset($user['birthdayprivacy'])) {
|
if(isset($user['bday'])) { $this->user_update_data['birthday'] = $user['bday']; } if(isset($user['birthdayprivacy'])) {
|
$this->user_update_data['birthdayprivacy'] = $user['birthdayprivacy'];
| $this->user_update_data['birthdayprivacy'] = $db->escape_string($user['birthdayprivacy']);
|
} if(isset($user['style'])) {
| } if(isset($user['style'])) {
|
Zeile 1145 | Zeile 1218 |
---|
$old_user = get_user($user['uid']);
// If old user has new pmnotice and new user has = yes, keep old value
|
$old_user = get_user($user['uid']);
// If old user has new pmnotice and new user has = yes, keep old value
|
if($old_user['pmnotice'] == "new" && $this->user_update_data['pmnotice'] == 1)
| if($old_user['pmnotice'] == "2" && $this->user_update_data['pmnotice'] == 1)
|
{ unset($this->user_update_data['pmnotice']); }
|
{ unset($this->user_update_data['pmnotice']); }
|
$plugins->run_hooks_by_ref("datahandler_user_update", $this);
| if(method_exists($plugins, "run_hooks_by_ref")) { $plugins->run_hooks_by_ref("datahandler_user_update", $this); }
|
if(count($this->user_update_data) < 1) { return false;
| if(count($this->user_update_data) < 1) { return false;
|
Zeile 1161 | Zeile 1237 |
---|
$db->update_query("users", $this->user_update_data, "uid='{$user['uid']}'"); $cache->update_moderators();
|
$db->update_query("users", $this->user_update_data, "uid='{$user['uid']}'"); $cache->update_moderators();
|
| if(isset($user['bday'])) { $cache->update_birthdays(); }
|
// Maybe some userfields need to be updated? if(is_array($user['user_fields']))
| // Maybe some userfields need to be updated? if(is_array($user['user_fields']))
|
Zeile 1184 | Zeile 1264 |
---|
} $db->insert_query("userfields", $user_fields); }
|
} $db->insert_query("userfields", $user_fields); }
|
$db->update_query("userfields", $user['user_fields'], "ufid='{$user['uid']}'");
| $db->update_query("userfields", $user['user_fields'], "ufid='{$user['uid']}'", false);
|
}
// Let's make sure the user's name gets changed everywhere in the db if it changed.
| }
// Let's make sure the user's name gets changed everywhere in the db if it changed.
|