Vergleich inc/datahandlers/user.php - 1.4.1 - 1.4.8

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1Zeile 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 4111 2008-08-13 06:14:12Z Tikitiki $

 * $Id: user.php 4384 2009-06-19 11:49:42Z Tomm $

 */

// Disallow direct access to this file for security reasons

 */

// Disallow direct access to this file for security reasons

Zeile 220Zeile 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 253Zeile 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 353Zeile 355
		$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'] < 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

		}

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

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

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

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

		}

		}


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


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

Zeile 384Zeile 383
			$user['bday'] = $birthday['day']."-".$birthday['month']."-".$birthday['year'];
}
elseif($birthday['day'] && $birthday['month'])

			$user['bday'] = $birthday['day']."-".$birthday['month']."-".$birthday['year'];
}
elseif($birthday['day'] && $birthday['month'])

		{

		{

			// If only a day and month are specified, put together a d-m string
$user['bday'] = $birthday['day']."-".$birthday['month']."-";
}

			// If only a day and month are specified, put together a d-m string
$user['bday'] = $birthday['day']."-".$birthday['month']."-";
}

Zeile 407Zeile 406

$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.
$userfields = array();
$comma = '';

		// Loop through profile fields checking if they exist or not and are filled in.
$userfields = array();
$comma = '';

Zeile 431Zeile 430
			$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']}";





			// If the profile field is required, but not filled in, present error.
if(trim($profile_fields[$field]) == "" && $profilefield['required'] == 1 && !defined('IN_ADMINCP'))
{

			// If the profile field is required, but not filled in, present error.
if(trim($profile_fields[$field]) == "" && $profilefield['required'] == 1 && !defined('IN_ADMINCP'))
{

Zeile 455Zeile 454
						$options .= "\n";
}
$options .= $db->escape_string($value);

						$options .= "\n";
}
$options .= $db->escape_string($value);

				}
}

				}
}

			elseif($type == "select" || $type == "radio")
{
$expoptions = explode("\n", $thing[1]);

			elseif($type == "select" || $type == "radio")
{
$expoptions = explode("\n", $thing[1]);

Zeile 465Zeile 464
				{
$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]);
}

				$options = $db->escape_string($profile_fields[$field]);
}

			else
{
$options = $db->escape_string($profile_fields[$field]);
}
$user['user_fields'][$field] = $options;

			else
{
$options = $db->escape_string($profile_fields[$field]);
}
$user['user_fields'][$field] = $options;

		}

return true;

		}

return true;

	}

/**

	}

/**

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

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

	{

	{

		global $db, $mybb;

$user = &$this->data;

		global $db, $mybb;

$user = &$this->data;

Zeile 528Zeile 527
		$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 585Zeile 592
		}

// 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 686Zeile 693

/**
* Verifies if an away mode status is valid or not.


/**
* Verifies if an away mode status is valid or not.

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

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

	 */
function verify_away()
{

	 */
function verify_away()
{

Zeile 702Zeile 709
			$user['away']['returndate'] = 0;
$user['away']['reason'] = '';
return true;

			$user['away']['returndate'] = 0;
$user['away']['reason'] = '';
return true;

		}

		}

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

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

Zeile 715Zeile 722

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


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

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

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

	 */
function verify_language()
{
global $lang;

	 */
function verify_language()
{
global $lang;





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

// An invalid language has been specified?
if($language != '' && !$lang->language_exists($language))
{
$this->set_error("invalid_language");

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

// An invalid language has been specified?
if($language != '' && !$lang->language_exists($language))
{
$this->set_error("invalid_language");

			return false;
}
return true;
}

			return false;
}
return true;
}

	
/**
* Verifies if this is coming from a spam bot or not

	
/**
* Verifies if this is coming from a spam bot or not

Zeile 759Zeile 766
	function validate_user()
{
global $mybb, $plugins;

	function validate_user()
{
global $mybb, $plugins;





		$user = &$this->data;

// First, grab the old user details if this user exists

		$user = &$this->data;

// First, grab the old user details if this user exists

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

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

		}

		}

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

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

		{

		{

			$this->verify_usergroup();

			$this->verify_usergroup();

		}

		}

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

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

		{

		{

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

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

Zeile 802Zeile 809
			$this->verify_website();
}
if($this->method == "insert" || array_key_exists('icq', $user))

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

		{

		{

			$this->verify_icq();
}
if($this->method == "insert" || array_key_exists('msn', $user))
{
$this->verify_msn();

			$this->verify_icq();
}
if($this->method == "insert" || array_key_exists('msn', $user))
{
$this->verify_msn();

		}

		}

		if($this->method == "insert" || is_array($user['birthday']))
{
$this->verify_birthday();
}
if($this->method == "insert" || array_key_exists('profile_fields', $user))

		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('referrer', $user))
{
$this->verify_referrer();

			$this->verify_profile_fields();
}
if($this->method == "insert" || array_key_exists('referrer', $user))
{
$this->verify_referrer();

		}

		}

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

		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('lastvisit', $user))
{
$this->verify_lastvisit();

			$this->verify_regdate();
}
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))

		if($this->method == "insert" || array_key_exists('lastactive', $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('regcheck1', $user) && array_key_exists('regcheck2', $user))

		if($this->method == "insert" && array_key_exists('regcheck1', $user) && array_key_exists('regcheck2', $user))

		{

		{

			$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 958Zeile 968
		{
$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 975Zeile 988
			$user['user_fields']["fid{$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 1005Zeile 1018
		if(count($this->get_errors()) > 0)
{
die("The user is not valid.");

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

		}


		}


		$user = &$this->data;
$user['uid'] = intval($user['uid']);
$this->uid = $user['uid'];

		$user = &$this->data;
$user['uid'] = intval($user['uid']);
$this->uid = $user['uid'];

Zeile 1025Zeile 1038
		if(isset($user['email']))
{
$this->user_update_data['email'] = $user['email'];

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

		}

		}

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

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

		{

		{

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

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

		}

		}

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

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

Zeile 1093Zeile 1106
		}
if(isset($user['birthdayprivacy']))
{

		}
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 1149Zeile 1162
		{
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)
{

		
if(count($this->user_update_data) < 1)
{

Zeile 1188Zeile 1204
				}
$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.