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

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 303Zeile 303
	{
$website = &$this->data['website'];


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


		if(empty($website) || my_strtolower($website) == 'http://' || my_strtolower($website) == 'https://')

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

		{

		{

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

			$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 358Zeile 350
		if(!is_array($birthday))
{
return true;

		if(!is_array($birthday))
{
return true;

		}

		}


// Sanitize any input we have
$birthday['day'] = (int)$birthday['day'];


// Sanitize any input we have
$birthday['day'] = (int)$birthday['day'];

Zeile 367Zeile 359

// Error if a day and month exists, and the birthday day and range is not in range
if($birthday['day'] != 0 || $birthday['month'] != 0)


// Error if a day and month exists, and the birthday day and range is not in range
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))
{
$this->set_error("invalid_birthday");

			if($birthday['day'] < 1 || $birthday['day'] > 31 || $birthday['month'] < 1 || $birthday['month'] > 12 || ($birthday['month'] == 2 && $birthday['day'] > 29))
{
$this->set_error("invalid_birthday");

Zeile 378Zeile 370
		// Check if the day actually exists.
$months = get_bdays($birthday['year']);
if($birthday['month'] != 0 && $birthday['day'] > $months[$birthday['month']-1])

		// Check if the day actually exists.
$months = get_bdays($birthday['year']);
if($birthday['month'] != 0 && $birthday['day'] > $months[$birthday['month']-1])

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

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

		}

// Error if a year exists and the year is out of range

		}

// Error if a year exists and the year is out of range

Zeile 388Zeile 380
		{
$this->set_error("invalid_birthday");
return false;

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

		}

		}

		else if($birthday['year'] == date("Y"))
{
// Error if birth date is in future

		else if($birthday['year'] == date("Y"))
{
// Error if birth date is in future

Zeile 401Zeile 393

// 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']))


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

			$this->set_error("invalid_birthday_coppa");

			return false;

			return false;

		}
elseif(($mybb->settings['coppa'] == "deny" && $birthday['year'] > (date("Y")-13)) && !is_moderator())

		}
elseif(($mybb->settings['coppa'] == "deny" && $birthday['year'] > (date("Y")-13)) && !is_moderator())

		{

		{

			$this->set_error("invalid_birthday_coppa2");
return false;

			$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 423Zeile 415
			$user['bday'] = $birthday['day']."-".$birthday['month']."-";
}
else

			$user['bday'] = $birthday['day']."-".$birthday['month']."-";
}
else

		{

		{

			// 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'] = '';
}

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

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

			return false;
}

return true;
}

			return false;
}

return true;
}


/**
* Verifies if the thread count field is filled in correctly.


/**
* Verifies if the thread count field is filled in correctly.

Zeile 483Zeile 475
			$this->set_error("invalid_threadnum");
return false;
}

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





		return true;
}

/**
* Verifies if a profile fields are filled in correctly.

		return true;
}

/**
* Verifies if a profile fields are filled in correctly.

	*

	*

	* @return boolean True when valid, false when invalid.
*/
function verify_profile_fields()
{
global $db, $cache;

	* @return boolean True when valid, false when invalid.
*/
function verify_profile_fields()
{
global $db, $cache;





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

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





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

// Fetch all profile fields first.

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

// Fetch all profile fields first.

Zeile 512Zeile 504
				if(isset($this->data['profile_fields_editable']) || isset($this->data['registration']) && ($profilefield['required'] == 1 || $profilefield['registration'] == 1))
{
$profilefield['editableby'] = -1;

				if(isset($this->data['profile_fields_editable']) || isset($this->data['registration']) && ($profilefield['required'] == 1 || $profilefield['registration'] == 1))
{
$profilefield['editableby'] = -1;

				}

				}


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


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

				{
continue;
}


				{
continue;
}


				// Does this field have a minimum post count?
if(!isset($this->data['profile_fields_editable']) && !empty($profilefield['postnum']) && $profilefield['postnum'] > $user['postnum'])

				// Does this field have a minimum post count?
if(!isset($this->data['profile_fields_editable']) && !empty($profilefield['postnum']) && $profilefield['postnum'] > $user['postnum'])

				{

				{

					continue;
}


					continue;
}


Zeile 534Zeile 526
				if(!isset($profile_fields[$field]))
{
$profile_fields[$field] = '';

				if(!isset($profile_fields[$field]))
{
$profile_fields[$field] = '';

				}

				}


// If the profile field is required, but not filled in, present error.
if($type != "multiselect" && $type != "checkbox")


// If the profile field is required, but not filled in, present error.
if($type != "multiselect" && $type != "checkbox")

Zeile 601Zeile 593

/**
* 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 614Zeile 606
		if($mybb->settings['usereferrals'] == 1 && $user['referrer'] != '')
{
$referrer = get_user_by_username($user['referrer']);

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





			if(empty($referrer['uid']))
{
$this->set_error('invalid_referrer', array($user['referrer']));

			if(empty($referrer['uid']))
{
$this->set_error('invalid_referrer', array($user['referrer']));

Zeile 622Zeile 614
			}

$user['referrer_uid'] = $referrer['uid'];

			}

$user['referrer_uid'] = $referrer['uid'];

		}
else
{

		}
else
{

			$user['referrer_uid'] = 0;
}


			$user['referrer_uid'] = 0;
}


Zeile 668Zeile 660
		else
{
$this->verify_yesno_option($options, 'classicpostbit', 0);

		else
{
$this->verify_yesno_option($options, 'classicpostbit', 0);

		}

		}


if(array_key_exists('subscriptionmethod', $options))
{


if(array_key_exists('subscriptionmethod', $options))
{

Zeile 921Zeile 913
	}

/**

	}

/**

	 * 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

	 * If the timezone is invalid, the board default is used.
*
* @return boolean True when timezone was valid, false otherwise

Zeile 1054Zeile 1046
		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 1374
		}
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 1386Zeile 1382
		if(isset($user['notepad']))
{
$this->user_update_data['notepad'] = $db->escape_string($user['notepad']);

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

		}

		}

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

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

Zeile 1419Zeile 1415
		}

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

Zeile 1468Zeile 1464
			);
$lastposter_update = array(
"lastposter" => $this->user_update_data['username']

			);
$lastposter_update = array(
"lastposter" => $this->user_update_data['username']

			);

			);


$db->update_query("posts", $username_update, "uid='{$user['uid']}'");
$db->update_query("threads", $username_update, "uid='{$user['uid']}'");
$db->update_query("threads", $lastposter_update, "lastposteruid='{$user['uid']}'");
$db->update_query("forums", $lastposter_update, "lastposteruid='{$user['uid']}'");


$db->update_query("posts", $username_update, "uid='{$user['uid']}'");
$db->update_query("threads", $username_update, "uid='{$user['uid']}'");
$db->update_query("threads", $lastposter_update, "lastposteruid='{$user['uid']}'");
$db->update_query("forums", $lastposter_update, "lastposteruid='{$user['uid']}'");





			$stats = $cache->read("stats");
if($stats['lastuid'] == $user['uid'])
{

			$stats = $cache->read("stats");
if($stats['lastuid'] == $user['uid'])
{

Zeile 1484Zeile 1480
		}

return true;

		}

return true;

	}

	}


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


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

Zeile 1517Zeile 1513
		$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 1602
		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 1611
					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 1652
		$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 1665
	 * @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 1686

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

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

	}
}

	}
}