Vergleich inc/datahandlers/user.php - 1.8.2 - 1.8.37

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 61Zeile 61
	 * @var array
*/
public $return_values = array();

	 * @var array
*/
public $return_values = array();

 

/**
* @var array
*/
var $delete_uids = array();

/**
* @var int
*/
var $deleted_users = 0;


/**
* Verifies if a username is valid or invalid.
*


/**
* Verifies if a username is valid or invalid.
*

	 * @param boolean True when valid, false when invalid.

	 * @return boolean True when valid, false when invalid.

	 */
function verify_username()
{

	 */
function verify_username()
{

Zeile 85Zeile 95
		if($username == '')
{
$this->set_error('missing_username');

		if($username == '')
{
$this->set_error('missing_username');

			return false;
}


			return false;
}


		// Check if the username belongs to the list of banned usernames.
if(is_banned_username($username, true))

		// Check if the username belongs to the list of banned usernames.
if(is_banned_username($username, true))

		{

		{

			$this->set_error('banned_username');

			$this->set_error('banned_username');

			return false;

			return false;

		}

// Check for certain characters in username (<, >, &, commas and slashes)
if(strpos($username, "<") !== false || strpos($username, ">") !== false || strpos($username, "&") !== false || my_strpos($username, "\\") !== false || strpos($username, ";") !== false || strpos($username, ",") !== false || !validate_utf8_string($username, false, false))
{
$this->set_error("bad_characters_username");

		}

// Check for certain characters in username (<, >, &, commas and slashes)
if(strpos($username, "<") !== false || strpos($username, ">") !== false || strpos($username, "&") !== false || my_strpos($username, "\\") !== false || strpos($username, ";") !== false || strpos($username, ",") !== false || !validate_utf8_string($username, false, false))
{
$this->set_error("bad_characters_username");

			return false;
}

			return false;
}


// Check if the username is of the correct length.
if(($mybb->settings['maxnamelength'] != 0 && my_strlen($username) > $mybb->settings['maxnamelength']) || ($mybb->settings['minnamelength'] != 0 && my_strlen($username) < $mybb->settings['minnamelength']))
{
$this->set_error('invalid_username_length', array($mybb->settings['minnamelength'], $mybb->settings['maxnamelength']));


// Check if the username is of the correct length.
if(($mybb->settings['maxnamelength'] != 0 && my_strlen($username) > $mybb->settings['maxnamelength']) || ($mybb->settings['minnamelength'] != 0 && my_strlen($username) < $mybb->settings['minnamelength']))
{
$this->set_error('invalid_username_length', array($mybb->settings['minnamelength'], $mybb->settings['maxnamelength']));

			return false;
}

return true;
}

			return false;
}

return true;
}


/**
* Verifies if a usertitle is valid or invalid.
*


/**
* Verifies if a usertitle is valid or invalid.
*

	 * @param boolean True when valid, false when invalid.

	 * @return boolean True when valid, false when invalid.

	 */
function verify_usertitle()
{

	 */
function verify_usertitle()
{

Zeile 156Zeile 166
		}

return false;

		}

return false;

	}


	}


	/**
* Verifies if a new password is valid or not.
*

	/**
* Verifies if a new password is valid or not.
*

Zeile 166Zeile 176
	function verify_password()
{
global $mybb;

	function verify_password()
{
global $mybb;





		$user = &$this->data;

// Always check for the length of the password.
if(my_strlen($user['password']) < $mybb->settings['minpasswordlength'] || my_strlen($user['password']) > $mybb->settings['maxpasswordlength'])

		$user = &$this->data;

// Always check for the length of the password.
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;
}


		// Has the user tried to use their email address or username as a password?
if($user['email'] == $user['password'] || $user['username'] == $user['password'])
{
$this->set_error('bad_password_security');
return false;
}







		// Has the user tried to use their email address or username as a password?
if(!empty($user['email']) && !empty($user['username']))
{
if($user['email'] === $user['password'] || $user['username'] === $user['password']
|| strpos($user['password'], $user['email']) !== false || strpos($user['password'], $user['username']) !== false
|| strpos($user['email'], $user['password']) !== false || strpos($user['username'], $user['password']) !== false)
{
$this->set_error('bad_password_security');
return false;
}
}


		// See if the board has "require complex passwords" enabled.
if($mybb->settings['requirecomplexpasswords'] == 1)

		// See if the board has "require complex passwords" enabled.
if($mybb->settings['requirecomplexpasswords'] == 1)

		{

		{

			// Complex passwords required, do some extra checks.
// First, see if there is one or more complex character(s) in the password.
if(!preg_match("/^.*(?=.{".$mybb->settings['minpasswordlength'].",})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/", $user['password']))

			// Complex passwords required, do some extra checks.
// First, see if there is one or more complex character(s) in the password.
if(!preg_match("/^.*(?=.{".$mybb->settings['minpasswordlength'].",})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/", $user['password']))

Zeile 193Zeile 208
				$this->set_error('no_complex_characters', array($mybb->settings['minpasswordlength']));
return false;
}

				$this->set_error('no_complex_characters', array($mybb->settings['minpasswordlength']));
return false;
}

		}

		}


// If we have a "password2" check if they both match


// If we have a "password2" check if they both match

		if(isset($user['password2']) && $user['password'] != $user['password2'])

		if(isset($user['password2']) && $user['password'] !== $user['password2'])

		{
$this->set_error("passwords_dont_match");
return false;
}

		{
$this->set_error("passwords_dont_match");
return false;
}


// MD5 the password
$user['md5password'] = md5($user['password']);

// Generate our salt
$user['salt'] = generate_salt();

// Combine the password and salt
$user['saltedpw'] = salt_password($user['md5password'], $user['salt']);

 

// Generate the user login key
$user['loginkey'] = generate_loginkey();


// Generate the user login key
$user['loginkey'] = generate_loginkey();

 

// Combine the password and salt
$password_fields = create_password($user['password'], false, $user);
$user = array_merge($user, $password_fields);


return true;
}


return true;
}

Zeile 224Zeile 234
	*/
function verify_usergroup()
{

	*/
function verify_usergroup()
{

		$user = &$this->data;

 
		return true;
}
/**

		return true;
}
/**

Zeile 256Zeile 265
		if(is_banned_email($user['email'], true))
{
$this->set_error('banned_email');

		if(is_banned_email($user['email'], true))
{
$this->set_error('banned_email');

			return false;
}


			return false;
}


		// Check signed up emails
// 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"))

		// Check signed up emails
// 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"))

Zeile 267Zeile 276
			if(isset($user['uid']))
{
$uid = $user['uid'];

			if(isset($user['uid']))
{
$uid = $user['uid'];

			}

			}

			if(email_already_in_use($user['email'], $uid))
{
$this->set_error('email_already_in_use');
return false;
}

			if(email_already_in_use($user['email'], $uid))
{
$this->set_error('email_already_in_use');
return false;
}

		}

		}


// 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");


// 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;
}


			return false;
}


		return true;
}


		return true;
}


Zeile 294Zeile 303
	{
$website = &$this->data['website'];


	{
$website = &$this->data['website'];


		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;
}

if(!filter_var($website, FILTER_VALIDATE_URL))

		if(!empty($website) && !my_validate_url($website))
{
$website = 'http://'.$website;
}

if(!empty($website) && !my_validate_url($website))









		{
$this->set_error('invalid_website');

		{
$this->set_error('invalid_website');

			return false;
}

return true;
}


			return false;
}

return true;
}


	/**
* Verifies if an ICQ number is valid or not.
*

	/**
* Verifies if an ICQ number is valid or not.
*

Zeile 331Zeile 332
			return false;
}
$icq = (int)$icq;

			return false;
}
$icq = (int)$icq;

		return true;
}

/**

		return true;
}

/**

	* Verifies if a birthday is valid or not.
*
* @return boolean True when valid, false when invalid.

	* Verifies if a birthday is valid or not.
*
* @return boolean True when valid, false when invalid.

Zeile 378Zeile 379
		if($birthday['year'] != 0 && ($birthday['year'] < (date("Y")-100)) || $birthday['year'] > date("Y"))
{
$this->set_error("invalid_birthday");

		if($birthday['year'] != 0 && ($birthday['year'] < (date("Y")-100)) || $birthday['year'] > date("Y"))
{
$this->set_error("invalid_birthday");

			return false;
}
else if($birthday['year'] == date("Y"))
{

			return false;
}
elseif($birthday['year'] == date("Y"))
{

			// Error if birth date is in future
if($birthday['month'] > date("m") || ($birthday['month'] == date("m") && $birthday['day'] > date("d")))
{

			// Error if birth date is in future
if($birthday['month'] > date("m") || ($birthday['month'] == date("m") && $birthday['day'] > date("d")))
{

Zeile 404Zeile 405

// Make the user's birthday field
if($birthday['year'] != 0)


// Make the user's birthday field
if($birthday['year'] != 0)

		{

		{

			// If the year is specified, put together a d-m-y string
$user['bday'] = $birthday['day']."-".$birthday['month']."-".$birthday['year'];
}

			// If the year is specified, put together a d-m-y string
$user['bday'] = $birthday['day']."-".$birthday['month']."-".$birthday['year'];
}

Zeile 438Zeile 439
		{
$this->set_error("invalid_birthday_privacy");
return false;

		{
$this->set_error("invalid_birthday_privacy");
return false;

 
		}
else if ($birthdayprivacy == 'age')
{
$birthdayyear = &$this->data['birthday']['year'];
if(empty($birthdayyear))
{
$this->set_error("conflicted_birthday_privacy");
return false;
}

		}
return true;
}

		}
return true;
}

Zeile 448Zeile 458
	* @return boolean True when valid, false when invalid.
*/
function verify_postnum()

	* @return boolean True when valid, false when invalid.
*/
function verify_postnum()

	{
$user = &$this->data;


	{
$user = &$this->data;


		if(isset($user['postnum']) && $user['postnum'] < 0)
{
$this->set_error("invalid_postnum");

		if(isset($user['postnum']) && $user['postnum'] < 0)
{
$this->set_error("invalid_postnum");

Zeile 491Zeile 501
		$profile_fields = &$this->data['profile_fields'];

// Loop through profile fields checking if they exist or not and are filled in.

		$profile_fields = &$this->data['profile_fields'];

// Loop through profile fields checking if they exist or not and are filled in.

		$userfields = array();
$comma = '';

 

// Fetch all profile fields first.


// Fetch all profile fields first.

		$pfcache = $cache->read('profilefields');


		$pfcache = $cache->read('profilefields');


		if(is_array($pfcache))
{
// Then loop through the profile fields.
foreach($pfcache as $profilefield)
{
if(isset($this->data['profile_fields_editable']) || isset($this->data['registration']) && ($profilefield['required'] == 1 || $profilefield['registration'] == 1))

		if(is_array($pfcache))
{
// Then loop through the profile fields.
foreach($pfcache as $profilefield)
{
if(isset($this->data['profile_fields_editable']) || isset($this->data['registration']) && ($profilefield['required'] == 1 || $profilefield['registration'] == 1))

				{

				{

					$profilefield['editableby'] = -1;
}


					$profilefield['editableby'] = -1;
}


				if(empty($profilefield['editableby']) || ($profilefield['editableby'] != -1 && !is_member($profilefield['editableby'], array('usergroup' => $user['usergroup'], 'additionalgroups' => $user['additionalgroups']))))


















				if(isset($user['usergroup']))
{
$usergroup = $user['usergroup'];
}
else
{
$usergroup = '';
}
if(isset($user['additionalgroups']))
{
$additionalgroups = $user['additionalgroups'];
}
else
{
$additionalgroups = '';
}

if(!is_member($profilefield['editableby'], array('usergroup' => $usergroup, 'additionalgroups' => $additionalgroups)))

				{
continue;
}

				{
continue;
}

Zeile 519Zeile 544
				}

$profilefield['type'] = htmlspecialchars_uni($profilefield['type']);

				}

$profilefield['type'] = htmlspecialchars_uni($profilefield['type']);

 
				$profilefield['name'] = htmlspecialchars_uni($profilefield['name']);

				$thing = explode("\n", $profilefield['type'], "2");
$type = trim($thing[0]);
$field = "fid{$profilefield['fid']}";

				$thing = explode("\n", $profilefield['type'], "2");
$type = trim($thing[0]);
$field = "fid{$profilefield['fid']}";

Zeile 577Zeile 603
						$this->set_error('max_limit_reached', array($profilefield['name'], $profilefield['maxlength']));
}


						$this->set_error('max_limit_reached', array($profilefield['name'], $profilefield['maxlength']));
}


					if(!empty($profilefield['regex']) && !preg_match("#".$profilefield['regex']."#i", $profile_fields[$field]))

					if(!empty($profilefield['regex']) && !empty($profile_fields[$field]) && !preg_match("#".$profilefield['regex']."#i", $profile_fields[$field]))

					{
$this->set_error('bad_profile_field_value', array($profilefield['name']));
}

					{
$this->set_error('bad_profile_field_value', array($profilefield['name']));
}

Zeile 585Zeile 611
					$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 603Zeile 629
		$user = &$this->data;

// Does the referrer exist or not?

		$user = &$this->data;

// Does the referrer exist or not?

		if($mybb->settings['usereferrals'] == 1 && $user['referrer'] != '')

		if($mybb->settings['usereferrals'] == 1 && !empty($user['referrer']))

		{
$referrer = get_user_by_username($user['referrer']);


		{
$referrer = get_user_by_username($user['referrer']);


			if(empty($referrer['uid']))

			if(!$referrer)

			{
$this->set_error('invalid_referrer', array($user['referrer']));
return false;

			{
$this->set_error('invalid_referrer', array($user['referrer']));
return false;

Zeile 633Zeile 659
		global $mybb;

$options = &$this->data['options'];

		global $mybb;

$options = &$this->data['options'];

 

if(!is_array($options))
{
$options = array();
}


// Verify yes/no options.
$this->verify_yesno_option($options, 'allownotices', 1);


// Verify yes/no options.
$this->verify_yesno_option($options, 'allownotices', 1);

Zeile 649Zeile 680
		$this->verify_yesno_option($options, 'showquickreply', 1);
$this->verify_yesno_option($options, 'showredirect', 1);
$this->verify_yesno_option($options, 'showcodebuttons', 1);

		$this->verify_yesno_option($options, 'showquickreply', 1);
$this->verify_yesno_option($options, 'showredirect', 1);
$this->verify_yesno_option($options, 'showcodebuttons', 1);

		$this->verify_yesno_option($options, 'sourceeditor', 1);



		$this->verify_yesno_option($options, 'sourceeditor', 0);
$this->verify_yesno_option($options, 'buddyrequestspm', 1);
$this->verify_yesno_option($options, 'buddyrequestsauto', 0);


if($mybb->settings['postlayout'] == 'classic')
{


if($mybb->settings['postlayout'] == 'classic')
{

Zeile 677Zeile 710
			if($options['dstcorrection'] < 0 || $options['dstcorrection'] > 2)
{
$options['dstcorrection'] = 0;

			if($options['dstcorrection'] < 0 || $options['dstcorrection'] > 2)
{
$options['dstcorrection'] = 0;

 
			}

if($options['dstcorrection'] == 1)
{
$options['dst'] = 1;
}
elseif($options['dstcorrection'] == 0)
{
$options['dst'] = 0;

			}
}


			}
}


		if($options['dstcorrection'] == 1)
{
$options['dst'] = 1;
}
else if($options['dstcorrection'] == 0)
{
$options['dst'] = 0;
}

if($this->method == "insert" || (isset($options['threadmode']) && $options['threadmode'] != "linear" && $options['threadmode'] != "threaded"))

		if($this->method == "insert" || (isset($options['threadmode']) && $options['threadmode'] != "linear" && $options['threadmode'] != "threaded" && $options['threadmode'] != ''))










		{

		{

			if($mybb->settings['threadusenetstyle'])
{
$options['threadmode'] = 'threaded';
}
else
{
$options['threadmode'] = 'linear';
}

			$options['threadmode'] = '';








		}

// Verify the "threads per page" option.

		}

// Verify the "threads per page" option.

Zeile 727Zeile 753
			if(!isset($options['ppp']))
{
$options['ppp'] = 0;

			if(!isset($options['ppp']))
{
$options['ppp'] = 0;

			}

			}

			$explodedppp = explode(",", $mybb->settings['userpppoptions']);
if(is_array($explodedppp))
{

			$explodedppp = explode(",", $mybb->settings['userpppoptions']);
if(is_array($explodedppp))
{

Zeile 745Zeile 771
		if($this->method == "insert" || array_key_exists('daysprune', $options))
{
if(!isset($options['daysprune']))

		if($this->method == "insert" || array_key_exists('daysprune', $options))
{
if(!isset($options['daysprune']))

			{
$options['daysprune'] = 0;

			{
$options['daysprune'] = 0;

			}
$options['daysprune'] = (int)$options['daysprune'];
if($options['daysprune'] < 0)

			}
$options['daysprune'] = (int)$options['daysprune'];
if($options['daysprune'] < 0)

Zeile 783Zeile 809
	function verify_lastvisit()
{
$lastvisit = &$this->data['lastvisit'];

	function verify_lastvisit()
{
$lastvisit = &$this->data['lastvisit'];





		$lastvisit = (int)$lastvisit;
// If the timestamp is below 0, set it to the current time.
if($lastvisit <= 0)

		$lastvisit = (int)$lastvisit;
// If the timestamp is below 0, set it to the current time.
if($lastvisit <= 0)

Zeile 832Zeile 858
			$user['away']['awayreason'] = '';
return true;
}

			$user['away']['awayreason'] = '';
return true;
}

		else if($user['away']['returndate'])

		elseif($user['away']['returndate'])

		{

		{

 
			// Validate the awayreason length, since the db holds 200 chars for this field
$reasonlength = my_strlen($user['away']['awayreason']);
if($reasonlength > 200)
{
$this->set_error("away_too_long", array($reasonlength - 200));
return false;
}


			list($returnday, $returnmonth, $returnyear) = explode('-', $user['away']['returndate']);
if(!$returnday || !$returnmonth || !$returnyear)

			list($returnday, $returnmonth, $returnyear) = explode('-', $user['away']['returndate']);
if(!$returnday || !$returnmonth || !$returnyear)

			{

			{

				$this->set_error("missing_returndate");
return false;
}

				$this->set_error("missing_returndate");
return false;
}

Zeile 848Zeile 882
	}

/**

	}

/**

	 * Verifies if a langage is valid for this user or not.

	 * Verifies if a language is valid for this user or not.

	 *
* @return boolean True when valid, false when invalid.
*/

	 *
* @return boolean True when valid, false when invalid.
*/

Zeile 864Zeile 898
			$this->set_error("invalid_language");
return false;
}

			$this->set_error("invalid_language");
return false;
}

 
		return true;
}

/**
* Verifies if a style is valid for this user or not.
*
* @return boolean True when valid, false when invalid.
*/
function verify_style()
{
global $lang;

$user = &$this->data;

if(!empty($user['style']))
{
$theme = get_theme($user['style']);

if(empty($theme) || !is_member($theme['allowedgroups'], $user) && $theme['allowedgroups'] != 'all')
{
$this->set_error('invalid_style');
return false;
}
}


		return true;
}


		return true;
}


Zeile 873Zeile 932
	 * @return boolean True when valid, false when invalid.
*/
function verify_checkfields()

	 * @return boolean True when valid, false when invalid.
*/
function verify_checkfields()

	{
$user = &$this->data;

	{
$user = &$this->data;


// An invalid language has been specified?
if($user['regcheck1'] !== "" || $user['regcheck2'] !== "true")


// An invalid language has been specified?
if($user['regcheck1'] !== "" || $user['regcheck2'] !== "true")

		{

		{

			$this->set_error("invalid_checkfield");
return false;
}

			$this->set_error("invalid_checkfield");
return false;
}

		return true;
}
























		return true;
}

/**
* Verifies if the user timezone is valid.
* If the timezone is invalid, the board default is used.
*
* @return boolean True when timezone was valid, false otherwise
*/
function verify_timezone()
{
global $mybb;

$user = &$this->data;

$timezones = get_supported_timezones();

if(!isset($user['timezone']) || !array_key_exists($user['timezone'], $timezones))
{
$user['timezone'] = $mybb->settings['timezoneoffset'];
return false;
}

return true;
}


/**
* Validate all user assets.


/**
* Validate all user assets.

Zeile 930Zeile 1012
		if($this->method == "insert" || array_key_exists('email', $user))
{
$this->verify_email();

		if($this->method == "insert" || array_key_exists('email', $user))
{
$this->verify_email();

		}

		}

		if($this->method == "insert" || array_key_exists('website', $user))
{
$this->verify_website();

		if($this->method == "insert" || array_key_exists('website', $user))
{
$this->verify_website();

Zeile 976Zeile 1058
			$this->verify_lastactive();
}
if($this->method == "insert" || array_key_exists('away', $user))

			$this->verify_lastactive();
}
if($this->method == "insert" || array_key_exists('away', $user))

		{

		{

			$this->verify_away();
}
if($this->method == "insert" || array_key_exists('language', $user))
{
$this->verify_language();

			$this->verify_away();
}
if($this->method == "insert" || array_key_exists('language', $user))
{
$this->verify_language();

		}





		}
if($this->method == "insert" || array_key_exists('timezone', $user))
{
$this->verify_timezone();
}

		if($this->method == "insert" && array_key_exists('regcheck1', $user) && array_key_exists('regcheck2', $user))
{
$this->verify_checkfields();
}
if(array_key_exists('birthdayprivacy', $user))

		if($this->method == "insert" && array_key_exists('regcheck1', $user) && array_key_exists('regcheck2', $user))
{
$this->verify_checkfields();
}
if(array_key_exists('birthdayprivacy', $user))

		{

		{

			$this->verify_birthday_privacy();
}

			$this->verify_birthday_privacy();
}











		if($this->method == "insert" || array_key_exists('style', $user))
{
$this->verify_style();
}
if($this->method == "insert" || array_key_exists('signature', $user))
{
$this->verify_signature();
}


		$plugins->run_hooks("datahandler_user_validate", $this);

// We are done validating, return.

		$plugins->run_hooks("datahandler_user_validate", $this);

// We are done validating, return.

Zeile 999Zeile 1093
		if(count($this->get_errors()) > 0)
{
return false;

		if(count($this->get_errors()) > 0)
{
return false;

		}

		}

		else
{
return true;
}
}

		else
{
return true;
}
}





	/**
* Inserts a user into the database.

	/**
* Inserts a user into the database.

 
	*
* @return array

	*/
function insert_user()
{
global $db, $cache, $plugins;


	*/
function insert_user()
{
global $db, $cache, $plugins;


		// Yes, validating is required.
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.");
}

$user = &$this->data;

$array = array('postnum', 'threadnum', 'avatar', 'avatartype', 'additionalgroups', 'displaygroup', 'icq', 'aim', 'yahoo', 'skype', 'google', 'bday', 'signature', 'style', 'dateformat', 'timeformat', 'notepad');
foreach($array as $value)

		// Yes, validating is required.
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.");
}

$user = &$this->data;

$array = array('postnum', 'threadnum', 'avatar', 'avatartype', 'additionalgroups', 'displaygroup', 'icq', 'skype', 'google', 'bday', 'signature', 'style', 'dateformat', 'timeformat', 'notepad', 'regip', 'lastip', 'coppa_user');
foreach($array as $value)

		{
if(!isset($user[$value]))

		{
if(!isset($user[$value]))

			{

			{

				$user[$value] = '';
}

				$user[$value] = '';
}

 
		}

$array = array('subscriptionmethod', 'dstcorrection');
foreach($array as $value)
{
if(!isset($user['options'][$value]))
{
$user['options'][$value] = '';
}
}

// If user is being created from ACP, there is no last visit or last active
if(defined('IN_ADMINCP'))
{
$user['lastvisit'] = $user['lastactive'] = 0;

		}

$this->user_insert_data = array(
"username" => $db->escape_string($user['username']),

		}

$this->user_insert_data = array(
"username" => $db->escape_string($user['username']),

			"password" => $user['saltedpw'],

			"password" => $user['password'],

			"salt" => $user['salt'],
"loginkey" => $user['loginkey'],
"email" => $db->escape_string($user['email']),

			"salt" => $user['salt'],
"loginkey" => $user['loginkey'],
"email" => $db->escape_string($user['email']),

Zeile 1053Zeile 1164
			"lastvisit" => (int)$user['lastvisit'],
"website" => $db->escape_string($user['website']),
"icq" => (int)$user['icq'],

			"lastvisit" => (int)$user['lastvisit'],
"website" => $db->escape_string($user['website']),
"icq" => (int)$user['icq'],

			"aim" => $db->escape_string($user['aim']),
"yahoo" => $db->escape_string($user['yahoo']),

 
			"skype" => $db->escape_string($user['skype']),
"google" => $db->escape_string($user['google']),
"birthday" => $user['bday'],
"signature" => $db->escape_string($user['signature']),

			"skype" => $db->escape_string($user['skype']),
"google" => $db->escape_string($user['google']),
"birthday" => $user['bday'],
"signature" => $db->escape_string($user['signature']),

			"allownotices" => $user['options']['allownotices'],
"hideemail" => $user['options']['hideemail'],

			"allownotices" => (int)$user['options']['allownotices'],
"hideemail" => (int)$user['options']['hideemail'],

			"subscriptionmethod" => (int)$user['options']['subscriptionmethod'],

			"subscriptionmethod" => (int)$user['options']['subscriptionmethod'],

			"receivepms" => $user['options']['receivepms'],
"receivefrombuddy" => $user['options']['receivefrombuddy'],
"pmnotice" => $user['options']['pmnotice'],
"pmnotify" => $user['options']['pmnotify'],
"showimages" => $user['options']['showimages'],
"showvideos" => $user['options']['showvideos'],
"showsigs" => $user['options']['showsigs'],
"showavatars" => $user['options']['showavatars'],
"showquickreply" => $user['options']['showquickreply'],
"showredirect" => $user['options']['showredirect'],

			"receivepms" => (int)$user['options']['receivepms'],
"receivefrombuddy" => (int)$user['options']['receivefrombuddy'],
"pmnotice" => (int)$user['options']['pmnotice'],
"pmnotify" => (int)$user['options']['pmnotify'],
"showimages" => (int)$user['options']['showimages'],
"showvideos" => (int)$user['options']['showvideos'],
"showsigs" => (int)$user['options']['showsigs'],
"showavatars" => (int)$user['options']['showavatars'],
"showquickreply" => (int)$user['options']['showquickreply'],
"showredirect" => (int)$user['options']['showredirect'],

			"tpp" => (int)$user['options']['tpp'],
"ppp" => (int)$user['options']['ppp'],

			"tpp" => (int)$user['options']['tpp'],
"ppp" => (int)$user['options']['ppp'],

			"invisible" => $user['options']['invisible'],

			"invisible" => (int)$user['options']['invisible'],

			"style" => (int)$user['style'],
"timezone" => $db->escape_string($user['timezone']),
"dstcorrection" => (int)$user['options']['dstcorrection'],

			"style" => (int)$user['style'],
"timezone" => $db->escape_string($user['timezone']),
"dstcorrection" => (int)$user['options']['dstcorrection'],

Zeile 1083Zeile 1192
			"dateformat" => $db->escape_string($user['dateformat']),
"timeformat" => $db->escape_string($user['timeformat']),
"regip" => $db->escape_binary($user['regip']),

			"dateformat" => $db->escape_string($user['dateformat']),
"timeformat" => $db->escape_string($user['timeformat']),
"regip" => $db->escape_binary($user['regip']),

 
			"lastip" => $db->escape_binary($user['lastip']),

			"language" => $db->escape_string($user['language']),

			"language" => $db->escape_string($user['language']),

			"showcodebuttons" => $user['options']['showcodebuttons'],
"sourceeditor" => $user['options']['sourceeditor'],
"away" => $user['away']['away'],
"awaydate" => $user['away']['date'],



			"showcodebuttons" => (int)$user['options']['showcodebuttons'],
"sourceeditor" => (int)$user['options']['sourceeditor'],
"buddyrequestspm" => (int)$user['options']['buddyrequestspm'],
"buddyrequestsauto" => (int)$user['options']['buddyrequestsauto'],
"away" => (int)$user['away']['away'],
"awaydate" => (int)$user['away']['date'],

			"returndate" => $user['away']['returndate'],
"awayreason" => $db->escape_string($user['away']['awayreason']),

			"returndate" => $user['away']['returndate'],
"awayreason" => $db->escape_string($user['away']['awayreason']),

			"notepad" => $db->escape_string($user['notepad']),

 
			"referrer" => (int)$user['referrer_uid'],
"referrals" => 0,
"buddylist" => '',
"ignorelist" => '',

			"referrer" => (int)$user['referrer_uid'],
"referrals" => 0,
"buddylist" => '',
"ignorelist" => '',

			"pmfolders" => '',

			"pmfolders" => "0**$%%$1**$%%$2**$%%$3**$%%$4**",

			"notepad" => '',
"warningpoints" => 0,
"moderateposts" => 0,

			"notepad" => '',
"warningpoints" => 0,
"moderateposts" => 0,

Zeile 1103Zeile 1214
			"suspendposting" => 0,
"suspensiontime" => 0,
"coppauser" => (int)$user['coppa_user'],

			"suspendposting" => 0,
"suspensiontime" => 0,
"coppauser" => (int)$user['coppa_user'],

			"classicpostbit" => $user['options']['classicpostbit'],

			"classicpostbit" => (int)$user['options']['classicpostbit'],

			"usernotes" => ''
);


			"usernotes" => ''
);


Zeile 1111Zeile 1222
		{
$this->user_insert_data['dst'] = 1;
}

		{
$this->user_insert_data['dst'] = 1;
}

		else if($user['options']['dstcorrection'] == 0)

		elseif($user['options']['dstcorrection'] == 0)

		{
$this->user_insert_data['dst'] = 0;
}

$plugins->run_hooks("datahandler_user_insert", $this);

		{
$this->user_insert_data['dst'] = 0;
}

$plugins->run_hooks("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 1163Zeile 1274
			"password" => $user['password'],
"usergroup" => $user['usergroup']
);

			"password" => $user['password'],
"usergroup" => $user['usergroup']
);





		$plugins->run_hooks("datahandler_user_insert_end", $this);

		$plugins->run_hooks("datahandler_user_insert_end", $this);





		return $this->return_values;
}

/**
* Updates a user in the database.

		return $this->return_values;
}

/**
* Updates a user in the database.

 
	*
* @return bool

	*/
function update_user()
{

	*/
function update_user()
{

Zeile 1195Zeile 1308
		{
$this->user_update_data['username'] = $db->escape_string($user['username']);
}

		{
$this->user_update_data['username'] = $db->escape_string($user['username']);
}

		if(isset($user['saltedpw']))





		if(isset($user['password']))
{
$this->user_update_data['password'] = $user['password'];
}
if(isset($user['salt']))

		{

		{

			$this->user_update_data['password'] = $user['saltedpw'];

 
			$this->user_update_data['salt'] = $user['salt'];

			$this->user_update_data['salt'] = $user['salt'];

 
		}
if(isset($user['loginkey']))
{

			$this->user_update_data['loginkey'] = $user['loginkey'];
}
if(isset($user['email']))

			$this->user_update_data['loginkey'] = $user['loginkey'];
}
if(isset($user['email']))

		{
$this->user_update_data['email'] = $user['email'];
}

		{
$this->user_update_data['email'] = $db->escape_string($user['email']);
}

		if(isset($user['postnum']))
{
$this->user_update_data['postnum'] = (int)$user['postnum'];

		if(isset($user['postnum']))
{
$this->user_update_data['postnum'] = (int)$user['postnum'];

Zeile 1212Zeile 1331
		if(isset($user['threadnum']))
{
$this->user_update_data['threadnum'] = (int)$user['threadnum'];

		if(isset($user['threadnum']))
{
$this->user_update_data['threadnum'] = (int)$user['threadnum'];

		}

		}

		if(isset($user['avatar']))
{
$this->user_update_data['avatar'] = $db->escape_string($user['avatar']);

		if(isset($user['avatar']))
{
$this->user_update_data['avatar'] = $db->escape_string($user['avatar']);

Zeile 1221Zeile 1340
		if(isset($user['usergroup']))
{
$this->user_update_data['usergroup'] = (int)$user['usergroup'];

		if(isset($user['usergroup']))
{
$this->user_update_data['usergroup'] = (int)$user['usergroup'];

		}

		}

		if(isset($user['additionalgroups']))
{
$this->user_update_data['additionalgroups'] = $db->escape_string($user['additionalgroups']);
}
if(isset($user['displaygroup']))

		if(isset($user['additionalgroups']))
{
$this->user_update_data['additionalgroups'] = $db->escape_string($user['additionalgroups']);
}
if(isset($user['displaygroup']))

		{

		{

			$this->user_update_data['displaygroup'] = (int)$user['displaygroup'];
}
if(isset($user['usertitle']))

			$this->user_update_data['displaygroup'] = (int)$user['displaygroup'];
}
if(isset($user['usertitle']))

Zeile 1235Zeile 1354
			$this->user_update_data['usertitle'] = $db->escape_string($user['usertitle']);
}
if(isset($user['regdate']))

			$this->user_update_data['usertitle'] = $db->escape_string($user['usertitle']);
}
if(isset($user['regdate']))

		{

		{

			$this->user_update_data['regdate'] = (int)$user['regdate'];
}
if(isset($user['lastactive']))
{
$this->user_update_data['lastactive'] = (int)$user['lastactive'];

			$this->user_update_data['regdate'] = (int)$user['regdate'];
}
if(isset($user['lastactive']))
{
$this->user_update_data['lastactive'] = (int)$user['lastactive'];

		}

		}

		if(isset($user['lastvisit']))

		if(isset($user['lastvisit']))

		{

		{

			$this->user_update_data['lastvisit'] = (int)$user['lastvisit'];
}
if(isset($user['signature']))
{
$this->user_update_data['signature'] = $db->escape_string($user['signature']);

			$this->user_update_data['lastvisit'] = (int)$user['lastvisit'];
}
if(isset($user['signature']))
{
$this->user_update_data['signature'] = $db->escape_string($user['signature']);

		}

		}

		if(isset($user['website']))

		if(isset($user['website']))

		{

		{

			$this->user_update_data['website'] = $db->escape_string($user['website']);
}
if(isset($user['icq']))
{
$this->user_update_data['icq'] = (int)$user['icq'];

			$this->user_update_data['website'] = $db->escape_string($user['website']);
}
if(isset($user['icq']))
{
$this->user_update_data['icq'] = (int)$user['icq'];

		}
if(isset($user['aim']))
{
$this->user_update_data['aim'] = $db->escape_string($user['aim']);
}
if(isset($user['yahoo']))
{
$this->user_update_data['yahoo'] = $db->escape_string($user['yahoo']);
}

		}









		if(isset($user['skype']))
{
$this->user_update_data['skype'] = $db->escape_string($user['skype']);

		if(isset($user['skype']))
{
$this->user_update_data['skype'] = $db->escape_string($user['skype']);

Zeile 1300Zeile 1411
		}
if(isset($user['regip']))
{

		}
if(isset($user['regip']))
{

			$this->user_update_data['regip'] = $db->escape_string($user['regip']);





			$this->user_update_data['regip'] = $db->escape_binary($user['regip']);
}
if(isset($user['lastip']))
{
$this->user_update_data['lastip'] = $db->escape_binary($user['lastip']);

		}
if(isset($user['language']))
{

		}
if(isset($user['language']))
{

Zeile 1308Zeile 1423
		}
if(isset($user['away']))
{

		}
if(isset($user['away']))
{

			$this->user_update_data['away'] = $user['away']['away'];

			$this->user_update_data['away'] = (int)$user['away']['away'];

			$this->user_update_data['awaydate'] = $db->escape_string($user['away']['date']);
$this->user_update_data['returndate'] = $db->escape_string($user['away']['returndate']);
$this->user_update_data['awayreason'] = $db->escape_string($user['away']['awayreason']);

			$this->user_update_data['awaydate'] = $db->escape_string($user['away']['date']);
$this->user_update_data['returndate'] = $db->escape_string($user['away']['returndate']);
$this->user_update_data['awayreason'] = $db->escape_string($user['away']['awayreason']);

Zeile 1334Zeile 1449
		}
// First, grab the old user details for later use.
$old_user = get_user($user['uid']);

		}
// First, grab the old user details for later use.
$old_user = get_user($user['uid']);





		// If old user has new pmnotice and new user has = yes, keep old value

		// If old user has new pmnotice and new user has = yes, keep old value

		if($old_user['pmnotice'] == "2" && $this->user_update_data['pmnotice'] == 1)
{

		if(isset($this->user_update_data['pmnotice']) && $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("datahandler_user_update", $this);

if(count($this->user_update_data) < 1 && empty($user['user_fields']))
{
return false;

		$plugins->run_hooks("datahandler_user_update", $this);

if(count($this->user_update_data) < 1 && empty($user['user_fields']))
{
return false;

		}

		}


if(count($this->user_update_data) > 0)


if(count($this->user_update_data) > 0)

		{

		{

			// Actual updating happens here.
$db->update_query("users", $this->user_update_data, "uid='{$user['uid']}'");

			// Actual updating happens here.
$db->update_query("users", $this->user_update_data, "uid='{$user['uid']}'");

		}

		}


$cache->update_moderators();
if(isset($user['bday']) || isset($user['username']))
{
$cache->update_birthdays();


$cache->update_moderators();
if(isset($user['bday']) || isset($user['username']))
{
$cache->update_birthdays();

		}

		}


if(isset($user['usergroup']) && (int)$user['usergroup'] == 5)
{


if(isset($user['usergroup']) && (int)$user['usergroup'] == 5)
{

Zeile 1370Zeile 1485
		{
$query = $db->simple_select("userfields", "*", "ufid='{$user['uid']}'");
$fields = $db->fetch_array($query);

		{
$query = $db->simple_select("userfields", "*", "ufid='{$user['uid']}'");
$fields = $db->fetch_array($query);

			if(!$fields['ufid'])

			if(empty($fields['ufid']))

			{
$user_fields = array(
'ufid' => $user['uid']

			{
$user_fields = array(
'ufid' => $user['uid']

Zeile 1419Zeile 1534
	/**
* Provides a method to completely delete a user.
*

	/**
* Provides a method to completely delete a user.
*

	 * @param array Array of user information
* @param integer Whether if delete threads/posts or not
* @return boolean True when successful, false if fails

	 * @param array $delete_uids Array of user information
* @param integer $prunecontent Whether if delete threads/posts or not
* @return array

	 */
function delete_user($delete_uids, $prunecontent=0)
{

	 */
function delete_user($delete_uids, $prunecontent=0)
{

Zeile 1431Zeile 1546
		if(count($this->get_errors()) > 0)
{
die('The user is not valid.');

		if(count($this->get_errors()) > 0)
{
die('The user is not valid.');

		}

		}


$this->delete_uids = array_map('intval', (array)$delete_uids);


$this->delete_uids = array_map('intval', (array)$delete_uids);





		foreach($this->delete_uids as $key => $uid)
{
if(!$uid || is_super_admin($uid) || $uid == $mybb->user['uid'])

		foreach($this->delete_uids as $key => $uid)
{
if(!$uid || is_super_admin($uid) || $uid == $mybb->user['uid'])

Zeile 1442Zeile 1557
				// Remove super admins
unset($this->delete_uids[$key]);
}

				// Remove super admins
unset($this->delete_uids[$key]);
}

		}


		}


		$plugins->run_hooks('datahandler_user_delete_start', $this);


		$plugins->run_hooks('datahandler_user_delete_start', $this);


		$this->delete_uids = '\''.implode('\',\'', $this->delete_uids).'\'';












		$this->delete_uids = implode(',', $this->delete_uids);

if(empty($this->delete_uids))
{
$this->deleted_users = 0;
$this->return_values = array(
"deleted_users" => $this->deleted_users
);

return $this->return_values;
}


		$this->delete_content();

// Delete the user

		$this->delete_content();

// Delete the user

		$query = $db->delete_query('users', 'uid IN('.$this->delete_uids.')');
$this->deleted_users = (int)$db->affected_rows($query);

		$query = $db->delete_query('users', "uid IN({$this->delete_uids})");
$this->deleted_users = $db->affected_rows($query);


// Are we removing the posts/threads of a user?
if((int)$prunecontent == 1)
{
$this->delete_posts();


// Are we removing the posts/threads of a user?
if((int)$prunecontent == 1)
{
$this->delete_posts();

		}


			$db->delete_query('announcements', "uid IN({$this->delete_uids})");
}

		else
{
// We're just updating the UID

		else
{
// We're just updating the UID

			$db->update_query('posts', array('uid' => 0), 'uid IN('.$this->delete_uids.')');
$db->update_query('threads', array('uid' => 0), 'uid IN('.$this->delete_uids.')');




			$db->update_query('pollvotes', array('uid' => 0), "uid IN({$this->delete_uids})");
$db->update_query('posts', array('uid' => 0), "uid IN({$this->delete_uids})");
$db->update_query('threads', array('uid' => 0), "uid IN({$this->delete_uids})");
$db->update_query('attachments', array('uid' => 0), "uid IN({$this->delete_uids})");
$db->update_query('announcements', array('uid' => 0), "uid IN({$this->delete_uids})");

		}

		}

 

$db->update_query('privatemessages', array('fromid' => 0), "fromid IN({$this->delete_uids})");
$db->update_query('users', array('referrer' => 0), "referrer IN({$this->delete_uids})");


// Update thread ratings
$query = $db->query("


// Update thread ratings
$query = $db->query("

Zeile 1482Zeile 1614
			$db->update_query("threads", $update_thread, "tid='{$rating['tid']}'");
}


			$db->update_query("threads", $update_thread, "tid='{$rating['tid']}'");
}


		$db->delete_query('threadratings', 'uid IN('.$this->delete_uids.')');

		$db->delete_query('threadratings', "uid IN({$this->delete_uids})");


// Update forums & threads if user is the lastposter


// Update forums & threads if user is the lastposter

		$db->update_query('forums', array('lastposteruid' => 0), 'lastposteruid IN('.$this->delete_uids.')');
$db->update_query('threads', array('lastposteruid' => 0), 'lastposteruid IN('.$this->delete_uids.')');

		$db->update_query('forums', array('lastposteruid' => 0), "lastposteruid IN({$this->delete_uids})");
$db->update_query('threads', array('lastposteruid' => 0), "lastposteruid IN({$this->delete_uids})");





		$cache->update_banned();
$cache->update_moderators();

// Update forum stats
update_stats(array('numusers' => '-'.(int)$this->deleted_users));

		// Update forum stats
update_stats(array('numusers' => '-'.$this->deleted_users));





$this->return_values = array(
"deleted_users" => $this->deleted_users
);


$this->return_values = array(
"deleted_users" => $this->deleted_users
);

		
// Update reports cache






$plugins->run_hooks("datahandler_user_delete_end", $this);

// Update cache
$cache->update_moderators();
$cache->update_forumsdisplay();

		$cache->update_reportedcontent();

		$cache->update_reportedcontent();



 
		$cache->update_awaitingactivation();

		$cache->update_awaitingactivation();


$plugins->run_hooks("datahandler_user_delete_end", $this);


		$cache->update_birthdays();



		return $this->return_values;

		return $this->return_values;

	}

/**
* Provides a method to delete an users content
*
* @param array Array of user ids, false if they're already set (eg when using the delete_user function)
*/
function delete_content($delete_uids=false)
{
global $db, $plugins;


	}

/**
* Provides a method to delete users' content
*
* @param array|bool $delete_uids Array of user ids, false if they're already set (eg when using the delete_user function)
*/
function delete_content($delete_uids=false)
{
global $db, $plugins, $mybb;


		if($delete_uids != false)
{
$this->delete_uids = array_map('intval', (array)$delete_uids);

		if($delete_uids != false)
{
$this->delete_uids = array_map('intval', (array)$delete_uids);

		



			foreach($this->delete_uids as $key => $uid)
{
if(!$uid || is_super_admin($uid) || $uid == $mybb->user['uid'])

			foreach($this->delete_uids as $key => $uid)
{
if(!$uid || is_super_admin($uid) || $uid == $mybb->user['uid'])

Zeile 1529Zeile 1660
					unset($this->delete_uids[$key]);
}
}

					unset($this->delete_uids[$key]);
}
}

		
$this->delete_uids = '\''.implode('\',\'', $this->delete_uids).'\'';
}


$this->delete_uids = implode(',', $this->delete_uids);
}


$plugins->run_hooks('datahandler_user_delete_content', $this);


$plugins->run_hooks('datahandler_user_delete_content', $this);


$db->delete_query('userfields', 'ufid IN('.$this->delete_uids.')');
$db->delete_query('privatemessages', 'uid IN('.$this->delete_uids.')');
$db->delete_query('events', 'uid IN('.$this->delete_uids.')');
$db->delete_query('moderators', 'id IN('.$this->delete_uids.') AND isgroup=\'0\'');
$db->delete_query('forumsubscriptions', 'uid IN('.$this->delete_uids.')');
$db->delete_query('threadsubscriptions', 'uid IN('.$this->delete_uids.')');
$db->delete_query('sessions', 'uid IN('.$this->delete_uids.')');
$db->delete_query('banned', 'uid IN('.$this->delete_uids.')');
$db->delete_query('joinrequests', 'uid IN('.$this->delete_uids.')');
$db->delete_query('awaitingactivation', 'uid IN('.$this->delete_uids.')');
$db->delete_query('warnings', 'uid IN('.$this->delete_uids.')');
$db->delete_query('reputation', 'uid IN('.$this->delete_uids.') OR adduid IN('.$this->delete_uids.')');
$db->delete_query('posts', 'uid IN('.$this->delete_uids.') AND visible=\'-2\'');
$db->delete_query('threads', 'uid IN('.$this->delete_uids.') AND visible=\'-2\'');
$db->delete_query('moderators', 'id IN('.$this->delete_uids.') AND isgroup=\'0\'');













if(empty($this->delete_uids))
{
return;
}

$db->delete_query('userfields', "ufid IN({$this->delete_uids})");
$db->delete_query('privatemessages', "uid IN({$this->delete_uids})");
$db->delete_query('events', "uid IN({$this->delete_uids})");
$db->delete_query('moderators', "id IN({$this->delete_uids}) AND isgroup = 0");
$db->delete_query('forumsubscriptions', "uid IN({$this->delete_uids})");
$db->delete_query('threadsubscriptions', "uid IN({$this->delete_uids})");
$db->delete_query('forumsread', "uid IN({$this->delete_uids})");
$db->delete_query('threadsread', "uid IN({$this->delete_uids})");
$db->delete_query('adminviews', "uid IN({$this->delete_uids})");
$db->delete_query('adminoptions', "uid IN({$this->delete_uids})");
$db->delete_query('adminsessions', "uid IN({$this->delete_uids})");
$db->delete_query('sessions', "uid IN({$this->delete_uids})");
$db->delete_query('banned', "uid IN({$this->delete_uids})");
$db->delete_query('joinrequests', "uid IN({$this->delete_uids})");
$db->delete_query('groupleaders', "uid IN({$this->delete_uids})");
$db->delete_query('awaitingactivation', "uid IN({$this->delete_uids})");
$db->delete_query('warnings', "uid IN({$this->delete_uids})");
$db->delete_query('reputation', "uid IN({$this->delete_uids}) OR adduid IN({$this->delete_uids})");
$db->delete_query('buddyrequests', "uid IN({$this->delete_uids}) OR touid IN({$this->delete_uids})");
$db->delete_query('posts', "uid IN({$this->delete_uids}) AND visible = -2");
$db->delete_query('threads', "uid IN({$this->delete_uids}) AND visible = -2");


// Delete reports made to the profile or reputation of the deleted users (i.e. made by them)


// Delete reports made to the profile or reputation of the deleted users (i.e. made by them)

		$db->delete_query('reportedcontent', 'type=\'reputation\' AND id3 IN('.$this->delete_uids.') OR type=\'reputation\' AND id2 IN('.$this->delete_uids.')');
$db->delete_query('reportedcontent', 'type=\'profile\' AND id IN('.$this->delete_uids.')');

		$db->delete_query('reportedcontent', "type='reputation' AND id3 IN({$this->delete_uids}) OR type='reputation' AND id2 IN({$this->delete_uids})");
$db->delete_query('reportedcontent', "type='profile' AND id IN({$this->delete_uids})");


// Update the reports made by the deleted users by setting the uid to 0


// Update the reports made by the deleted users by setting the uid to 0

		$db->update_query('reportedcontent', array('uid' => 0), 'uid IN('.$this->delete_uids.')');

// Remove any of the user(s) uploaded avatars
$query = $db->simple_select('users', 'avatar', 'uid IN ('.$this->delete_uids.') AND avatartype=\'upload\'');
while($avatar = $db->fetch_field($query, 'avatar'))
{
$avatar = substr($avatar, 2, -20);
@unlink(MYBB_ROOT.$avatar);
}

		$db->update_query('reportedcontent', array('uid' => 0), "uid IN({$this->delete_uids})");













 
		// Remove any of the user(s) uploaded avatars
require_once MYBB_ROOT.'inc/functions_upload.php';
foreach(explode(',', $this->delete_uids) as $uid)
{
remove_avatars($uid);
}

	}

	}





	/**
* Provides a method to delete an users posts and threads
*

	/**
* Provides a method to delete an users posts and threads
*

	 * @param array Array of user ids, false if they're already set (eg when using the delete_user function)

	 * @param array|bool $delete_uids Array of user ids, false if they're already set (eg when using the delete_user function)

	 */
function delete_posts($delete_uids=false)

	 */
function delete_posts($delete_uids=false)

	{
global $db, $plugins;

if($delete_uids != false)
{
$this->delete_uids = array_map('intval', (array)$delete_uids);

foreach($this->delete_uids as $key => $uid)
{
if(!$uid || is_super_admin($uid) || $uid == $mybb->user['uid'])
{
// Remove super admins
unset($this->delete_uids[$key]);
}
}

$this->delete_uids = '\''.implode('\',\'', $this->delete_uids).'\'';

	{
global $db, $plugins, $mybb;

if($delete_uids != false)
{
$this->delete_uids = array_map('intval', (array)$delete_uids);

foreach($this->delete_uids as $key => $uid)
{
if(!$uid || is_super_admin($uid) || $uid == $mybb->user['uid'])
{
// Remove super admins
unset($this->delete_uids[$key]);
}
}

$this->delete_uids = implode(',', $this->delete_uids);

		}

require_once MYBB_ROOT.'inc/class_moderation.php';
$moderation = new Moderation();

$plugins->run_hooks('datahandler_user_delete_posts', $this);

		}

require_once MYBB_ROOT.'inc/class_moderation.php';
$moderation = new Moderation();

$plugins->run_hooks('datahandler_user_delete_posts', $this);

 

if(empty($this->delete_uids))
{
return;
}


// Threads


// Threads

		$query = $db->simple_select('threads', 'tid', 'uid IN('.$this->delete_uids.')');

		$query = $db->simple_select('threads', 'tid', "uid IN({$this->delete_uids})");

		while($tid = $db->fetch_field($query, 'tid'))
{
$moderation->delete_thread($tid);
}

// Posts

		while($tid = $db->fetch_field($query, 'tid'))
{
$moderation->delete_thread($tid);
}

// Posts

		$pids = array();
$query = $db->simple_select('posts', 'pid', 'uid IN('.$this->delete_uids.')');
while($pid = $db->fetch_field($query, 'pid'))
{
$moderation->delete_post($pid);
$pids[] = (int)$pid;
}

// Delete Reports made to users's posts/threads
if(!empty($pids))
{
$db->delete_query('reportedcontent', 'type=\'posts\' AND id IN('.implode(',', $pids).')');
}
}


		$query = $db->simple_select('posts', 'pid', "uid IN({$this->delete_uids})");
while($pid = $db->fetch_field($query, 'pid'))
{
$moderation->delete_post($pid);
}
}










	/**

	/**

	 * Provides a method to clear an users profile (note that this doesn't delete the custom profilefields)

	 * Provides a method to clear an users profile

	 *

	 *

	 * @param array Array of user ids, false if they're already set (eg when using the delete_user function)
* @param int The new usergroup if the users should be moved (additional usergroups are always removed)

	 * @param array|bool $delete_uids Array of user ids, false if they're already set (eg when using the delete_user function)
* @param int $gid The new usergroup if the users should be moved (additional usergroups are always removed)

	 */
function clear_profile($delete_uids=false, $gid=0)
{

	 */
function clear_profile($delete_uids=false, $gid=0)
{

		global $db, $plugins;

		global $db, $plugins, $mybb;


// delete_uids isn't a nice name, but it's used as the functions above use the same
if($delete_uids != false)


// delete_uids isn't a nice name, but it's used as the functions above use the same
if($delete_uids != false)

Zeile 1645Zeile 1782
				}
}


				}
}


			$this->delete_uids = '\''.implode('\',\'', $this->delete_uids).'\'';

			$this->delete_uids = implode(',', $this->delete_uids);

		}

$update = array(
"website" => "",
"birthday" => "",
"icq" => "",

		}

$update = array(
"website" => "",
"birthday" => "",
"icq" => "",

			"aim" => "",
"yahoo" => "",

 
			"skype" => "",
"google" => "",
"usertitle" => "",

			"skype" => "",
"google" => "",
"usertitle" => "",

Zeile 1664Zeile 1799
			"additionalgroups" => "",
"displaygroup" => 0,
"signature" => "",

			"additionalgroups" => "",
"displaygroup" => 0,
"signature" => "",

			"avatar" => ""



			"avatar" => "",
'avatardimensions' => '',
'avatartype' => ''

		);

if($gid > 0)
{
$update["usergroup"] = (int)$gid;

		);

if($gid > 0)
{
$update["usergroup"] = (int)$gid;


}


		}



		$plugins->run_hooks('datahandler_user_clear_profile', $this);


		$plugins->run_hooks('datahandler_user_clear_profile', $this);


		$db->update_query("users", $update, 'uid IN('.$this->delete_uids.')');



























































































		if(empty($this->delete_uids))
{
return;
}

$db->update_query("users", $update, "uid IN({$this->delete_uids})");
$db->delete_query('userfields', "ufid IN({$this->delete_uids})");

// Remove any of the user(s) uploaded avatars
require_once MYBB_ROOT.'inc/functions_upload.php';
foreach(explode(',', $this->delete_uids) as $uid)
{
remove_avatars($uid);
}
}

public function verify_signature()
{
global $mybb, $parser;

if(!isset($this->data['signature']))
{
return true;
}

if(!isset($parser))
{
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
}

$parser_options = array(
'allow_html' => $mybb->settings['sightml'],
'allow_mycode' => $mybb->settings['sigmycode'],
'allow_smilies' => $mybb->settings['sigsmilies'],
'allow_imgcode' => $mybb->settings['sigimgcode'],
"filter_badwords" => 1
);

$parsed_sig = $parser->parse_message($this->data['signature'], $parser_options);

if((($mybb->settings['sigimgcode'] == 0 && $mybb->settings['sigsmilies'] != 1) &&
substr_count($parsed_sig, "<img") > 0) ||
(($mybb->settings['sigimgcode'] == 1 || $mybb->settings['sigsmilies'] == 1) &&
substr_count($parsed_sig, "<img") > $mybb->settings['maxsigimages'])
)
{
$imgsallowed = 0;

if($mybb->settings['sigimgcode'] == 1)
{
$imgsallowed = $mybb->settings['maxsigimages'];
}

$this->set_error('too_many_sig_images2', array($imgsallowed));
}

if($mybb->settings['sigcountmycode'] == 0)
{
$parsed_sig = $parser->text_parse_message($this->data['signature'], array('signature_parse' => '1'));
}
else
{
$parsed_sig = $this->data['signature'];
}

if($mybb->settings['siglength'] > 0)
{
$parsed_sig = preg_replace("#\s#", "", $parsed_sig);
$sig_length = my_strlen($parsed_sig);

if($sig_length > $mybb->settings['siglength'])
{
$this->set_error('sig_too_long', array($mybb->settings['siglength']));

if($sig_length - $mybb->settings['siglength'] > 1)
{
$this->set_error('sig_remove_chars_plural', array($sig_length-$mybb->settings['siglength']));
}
else
{
$this->set_error('sig_remove_chars_singular');
}
}
}

if(count($this->get_errors()) > 0)
{
return false;
}
return true;

	}
}

	}
}