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

  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 106Zeile 116
		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']));

		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 160Zeile 170

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


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

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

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

	*/
function verify_password()
{

	*/
function verify_password()
{

Zeile 210Zeile 220

// Combine the password and salt
$user['saltedpw'] = salt_password($user['md5password'], $user['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();


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 491Zeile 500
		$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.
$pfcache = $cache->read('profilefields');


// Fetch all profile fields first.
$pfcache = $cache->read('profilefields');

Zeile 519Zeile 526
				}

$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 840Zeile 848
			if(!$returnday || !$returnmonth || !$returnyear)
{
$this->set_error("missing_returndate");

			if(!$returnday || !$returnmonth || !$returnyear)
{
$this->set_error("missing_returndate");

				return false;

				return false;

			}

			}





			// Validate the return date lengths
$user['away']['returndate'] = substr($returnday, 0, 2).'-'.substr($returnmonth, 0, 2).'-'.substr($returnyear, 0, 4);

			// Validate the return date lengths
$user['away']['returndate'] = substr($returnday, 0, 2).'-'.substr($returnmonth, 0, 2).'-'.substr($returnyear, 0, 4);

		}

		}

		return true;
}

		return true;
}





	/**

	/**

	 * 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 872
		if($language != '' && !$lang->language_exists($language))
{
$this->set_error("invalid_language");

		if($language != '' && !$lang->language_exists($language))
{
$this->set_error("invalid_language");

			return false;
}
return true;












































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

/**
* Verifies if this is coming from a spam bot or not
*
* @return boolean True when valid, false when invalid.
*/
function verify_checkfields()
{
$user = &$this->data;

// An invalid language has been specified?
if($user['regcheck1'] !== "" || $user['regcheck2'] !== "true")
{
$this->set_error("invalid_checkfield");
return false;
}
return true;

	}

/**

	}

/**

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


	 * Verifies if the user timezone is valid. 
* If the timezone is invalid, the board default is used.

	 *

	 *

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

	 * @return boolean True when timezone was valid, false otherwise

	 */

	 */

	function verify_checkfields()

	function verify_timezone()

	{
$user = &$this->data;

	{
$user = &$this->data;


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



$timezones = get_supported_timezones();

if(!array_key_exists($user['timezone'], $timezones))

		{

		{

			$this->set_error("invalid_checkfield");

			$user['timezone'] = $mybb->settings['timezoneoffset'];

			return false;
}

			return false;
}

 


		return true;
}


		return true;
}


Zeile 938Zeile 992
			$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" || (isset($user['birthday']) && is_array($user['birthday'])))
{
$this->verify_birthday();

			$this->verify_icq();
}
if($this->method == "insert" || (isset($user['birthday']) && is_array($user['birthday'])))
{
$this->verify_birthday();

		}

		}

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

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

		{

		{

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

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

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

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

		if($this->method == "insert" || array_key_exists('lastvisit', $user))
{
$this->verify_lastvisit();
}
if($this->method == "insert" || array_key_exists('lastactive', $user))

		{

		{

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

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

		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('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))
{
$this->verify_birthday_privacy();

		{
$this->verify_checkfields();
}
if(array_key_exists('birthdayprivacy', $user))
{
$this->verify_birthday_privacy();

		}





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


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



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


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

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

		}

		}

		else
{
return true;

		else
{
return true;

Zeile 1010Zeile 1072

/**
* Inserts a user into the database.


/**
* Inserts a user into the database.

 
	*
* @return array

	*/
function insert_user()
{

	*/
function insert_user()
{

Zeile 1033Zeile 1097
			if(!isset($user[$value]))
{
$user[$value] = '';

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

			}
}

			}
}


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


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

Zeile 1138Zeile 1202
				}
$user['user_fields']["fid{$profile_field['fid']}"] = '';
}

				}
$user['user_fields']["fid{$profile_field['fid']}"] = '';
}

		}


		}


		$db->insert_query("userfields", $user['user_fields'], false);

if($this->user_insert_data['referrer'] != 0)

		$db->insert_query("userfields", $user['user_fields'], false);

if($this->user_insert_data['referrer'] != 0)

Zeile 1175Zeile 1239

/**
* Updates a user in the database.


/**
* Updates a user in the database.

 
	*
* @return bool

	*/
function update_user()
{

	*/
function update_user()
{

Zeile 1423Zeile 1489
	/**
* 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 1462Zeile 1528
		if((int)$prunecontent == 1)
{
$this->delete_posts();

		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('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('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 1484Zeile 1557
				"totalratings" => $rating['totalratings'] - $rating['rating']
);
$db->update_query("threads", $update_thread, "tid='{$rating['tid']}'");

				"totalratings" => $rating['totalratings'] - $rating['rating']
);
$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
$db->update_query('forums', array('lastposteruid' => 0), "lastposteruid IN({$this->delete_uids})");
$db->update_query('threads', array('lastposteruid' => 0), "lastposteruid IN({$this->delete_uids})");


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


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







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

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

		// Update forum stats
update_stats(array('numusers' => '-'.$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_banned();
$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);

 

return $this->return_values;
}


return $this->return_values;
}





	/**
* Provides a method to delete users' content
*

	/**
* Provides a method to delete users' content
*

	 * @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_content($delete_uids=false)

	 */
function delete_content($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'])

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

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

Zeile 1575Zeile 1647
			$avatar = substr($avatar, 2, -20);
@unlink(MYBB_ROOT.$avatar);
}

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



 
	}

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

		global $db, $plugins, $mybb;


if($delete_uids != false)
{


if($delete_uids != false)
{

Zeile 1601Zeile 1672
			}

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

			}

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

		}


		}


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





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

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

		{

		{

			$moderation->delete_thread($tid);

			$moderation->delete_thread($tid);

		}

		}


// Posts


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

		$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).")");

 
		}
}

/**
* Provides a method to clear an users profile
*

		}
}

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