Vergleich inc/datahandlers/user.php - 1.8.6 - 1.8.10

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 211Zeile 211
			$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();


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





		// Combine the password and salt

		// Combine the password and salt

		$user['saltedpw'] = salt_password($user['md5password'], $user['salt']);


		$user['saltedpw'] = create_password_hash($user['password'], $user['salt'], $user);


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

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


return true;
}



return true;
}


	/**
* Verifies usergroup selections and other group details.
*

	/**
* Verifies usergroup selections and other group details.
*

Zeile 258Zeile 255
		if(!validate_email_format($user['email']))
{
$this->set_error('invalid_email_format');

		if(!validate_email_format($user['email']))
{
$this->set_error('invalid_email_format');

			return false;

			return false;

		}

// Check banned emails

		}

// Check banned emails

Zeile 303Zeile 300
	{
$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")

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








		{

		{

			// Website does not start with http://, let's see if the user forgot.
$website = "http://".$website;

			$website = 'http://'.$website;


		}


		}


		if(!filter_var($website, FILTER_VALIDATE_URL))

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

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

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

Zeile 601Zeile 590

/**
* Verifies if an optionally entered referrer exists or not.


/**
* Verifies if an optionally entered referrer exists or not.

	*

	*

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

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

Zeile 720Zeile 709
			}
$explodedtpp = explode(",", $mybb->settings['usertppoptions']);
if(is_array($explodedtpp))

			}
$explodedtpp = explode(",", $mybb->settings['usertppoptions']);
if(is_array($explodedtpp))

			{

			{

				@asort($explodedtpp);
$biggest = $explodedtpp[count($explodedtpp)-1];
// Is the selected option greater than the allowed options?

				@asort($explodedtpp);
$biggest = $explodedtpp[count($explodedtpp)-1];
// Is the selected option greater than the allowed options?

Zeile 791Zeile 780
	 * @return boolean True when valid, false when invalid.
*/
function verify_lastvisit()

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

	{

	{

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

$lastvisit = (int)$lastvisit;

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

$lastvisit = (int)$lastvisit;

Zeile 863Zeile 852
	 * @return boolean True when valid, false when invalid.
*/
function verify_language()

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

	{
global $lang;


	{
global $lang;


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

// An invalid language has been specified?

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

// An invalid language has been specified?

Zeile 876Zeile 865
		}
return true;
}

		}
return true;
}





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

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

Zeile 886Zeile 875
	{
global $lang;


	{
global $lang;


		$user = &$this->data;


		$user = &$this->data;


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

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





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

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

Zeile 908Zeile 897
	 * @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")
{

Zeile 921Zeile 910
	}

/**

	}

/**

	 * Verifies if the user timezone is valid. 

	 * 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()
{

	 * 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();

		$user = &$this->data;

$timezones = get_supported_timezones();

Zeile 959Zeile 950
		}

if($this->method == "insert" || array_key_exists('username', $user))

		}

if($this->method == "insert" || array_key_exists('username', $user))

		{

		{

			// If the username is the same - no need to verify
if(!isset($old_user['username']) || $user['username'] != $old_user['username'])

			// If the username is the same - no need to verify
if(!isset($old_user['username']) || $user['username'] != $old_user['username'])

			{

			{

				$this->verify_username();
$this->verify_username_exists();

				$this->verify_username();
$this->verify_username_exists();

			}

			}

			else
{
unset($user['username']);

			else
{
unset($user['username']);

Zeile 974Zeile 965
		if($this->method == "insert" || array_key_exists('usertitle', $user))
{
$this->verify_usertitle();

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

		}

		}

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

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

Zeile 982Zeile 973
		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))
{
$this->verify_email();

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

Zeile 1000Zeile 991
			$this->verify_birthday();
}
if($this->method == "insert" || array_key_exists('postnum', $user))

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

		{

		{

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

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

Zeile 1018Zeile 1009
		if($this->method == "insert" || array_key_exists('options', $user))
{
$this->verify_options();

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

		}

		}

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

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

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

			$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_language();
}
if($this->method == "insert" || array_key_exists('timezone', $user))

Zeile 1054Zeile 1045
		if($this->method == "insert" || array_key_exists('style', $user))
{
$this->verify_style();

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

		}

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

Zeile 1378Zeile 1373
		}
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 1517Zeile 1512
		$plugins->run_hooks('datahandler_user_delete_start', $this);

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

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

$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

Zeile 1596Zeile 1601
		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 1605Zeile 1610
					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);

 

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('userfields', "ufid IN({$this->delete_uids})");
$db->delete_query('privatemessages', "uid IN({$this->delete_uids})");

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

// Remove any of the user(s) uploaded avatars

		$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'))

		require_once MYBB_ROOT.'inc/functions_upload.php';
foreach(explode(',', $this->delete_uids) as $uid)

		{

		{

			$avatar = substr($avatar, 2, -20);
@unlink(MYBB_ROOT.$avatar);

			remove_avatars($uid);


		}
}


		}
}


Zeile 1655Zeile 1664
	 * @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)

	 * @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)

	{
global $db, $plugins, $mybb;


	{
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);

Zeile 1676Zeile 1685

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


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





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

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

 

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


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


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

Zeile 1748Zeile 1762
		}

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

		}

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

 

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


$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($parser))
{
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
}

$parser_options = array(
'allow_html' => $mybb->settings['sightml'],
'filter_badwords' => 1,
'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']);
}
else
{
$parsed_sig = $this->data['signature'];
}

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

	}
}

	}
}