phpBB

Code Changes

File: includes/functions_user.php

  Unmodified   Added   Modified   Removed
Line 330Line 330

/**
* Remove User


/**
* Remove User

 
 *
* @param string $mode 'retain' or 'remove'
* @param int $user_id
* @param mixed $post_username
* @return bool

*/
function user_delete($mode, $user_id, $post_username = false)
{

*/
function user_delete($mode, $user_id, $post_username = false)
{

	global $cache, $config, $db, $user, $auth;

	global $cache, $config, $db, $user;

	global $phpbb_root_path, $phpEx;

$sql = 'SELECT *

	global $phpbb_root_path, $phpEx;

$sql = 'SELECT *

Line 437Line 442
				$sql = 'UPDATE ' . POSTS_TABLE . '
SET poster_id = ' . ANONYMOUS . ", post_username = '" . $db->sql_escape($post_username) . "'
WHERE poster_id = $user_id";

				$sql = 'UPDATE ' . POSTS_TABLE . '
SET poster_id = ' . ANONYMOUS . ", post_username = '" . $db->sql_escape($post_username) . "'
WHERE poster_id = $user_id";

				$db->sql_query($sql);

$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_edit_user = ' . ANONYMOUS . "
WHERE post_edit_user = $user_id";

 
				$db->sql_query($sql);

$sql = 'UPDATE ' . TOPICS_TABLE . '

				$db->sql_query($sql);

$sql = 'UPDATE ' . TOPICS_TABLE . '

Line 500Line 500
	}

$cache->destroy('sql', MODERATOR_CACHE_TABLE);

	}

$cache->destroy('sql', MODERATOR_CACHE_TABLE);

 

// Change user_id to anonymous for posts edited by this user
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_edit_user = ' . ANONYMOUS . '
WHERE post_edit_user = ' . $user_id;
$db->sql_query($sql);

// Change user_id to anonymous for pms edited by this user
$sql = 'UPDATE ' . PRIVMSGS_TABLE . '
SET message_edit_user = ' . ANONYMOUS . '
WHERE message_edit_user = ' . $user_id;
$db->sql_query($sql);


// Delete user log entries about this user
$sql = 'DELETE FROM ' . LOG_TABLE . '


// Delete user log entries about this user
$sql = 'DELETE FROM ' . LOG_TABLE . '

Line 528Line 540
		WHERE session_user_id = ' . $user_id;
$db->sql_query($sql);


		WHERE session_user_id = ' . $user_id;
$db->sql_query($sql);


	// Remove any undelivered mails...
$sql = 'SELECT msg_id, user_id
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE author_id = ' . $user_id . '
AND folder_id = ' . PRIVMSGS_NO_BOX;
$result = $db->sql_query($sql);

$undelivered_msg = $undelivered_user = array();
while ($row = $db->sql_fetchrow($result))

	// Clean the private messages tables from the user
if (!function_exists('phpbb_delete_user_pms'))








	{

	{

		$undelivered_msg[] = $row['msg_id'];
$undelivered_user[$row['user_id']][] = true;
}
$db->sql_freeresult($result);

if (sizeof($undelivered_msg))
{
$sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg);
$db->sql_query($sql);
}

$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
WHERE author_id = ' . $user_id . '
AND folder_id = ' . PRIVMSGS_NO_BOX;
$db->sql_query($sql);

// Delete all to-information
$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
WHERE user_id = ' . $user_id;
$db->sql_query($sql);

// Set the remaining author id to anonymous - this way users are still able to read messages from users being removed
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET author_id = ' . ANONYMOUS . '
WHERE author_id = ' . $user_id;
$db->sql_query($sql);

$sql = 'UPDATE ' . PRIVMSGS_TABLE . '
SET author_id = ' . ANONYMOUS . '
WHERE author_id = ' . $user_id;
$db->sql_query($sql);

foreach ($undelivered_user as $_user_id => $ary)
{
if ($_user_id == $user_id)
{
continue;
}

$sql = 'UPDATE ' . USERS_TABLE . '
SET user_new_privmsg = user_new_privmsg - ' . sizeof($ary) . ',
user_unread_privmsg = user_unread_privmsg - ' . sizeof($ary) . '
WHERE user_id = ' . $_user_id;
$db->sql_query($sql);

		include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);













































	}

	}

 
	phpbb_delete_user_pms($user_id);


$db->sql_transaction('commit');



$db->sql_transaction('commit');


Line 1297Line 1259
		{
$function = array_shift($validate);
array_unshift($validate, $data[$var]);

		{
$function = array_shift($validate);
array_unshift($validate, $data[$var]);

 
			$function_prefix = (function_exists('phpbb_validate_' . $function)) ? 'phpbb_validate_' : 'validate_';





			if ($result = call_user_func_array('validate_' . $function, $validate))

			if ($result = call_user_func_array($function_prefix . $function, $validate))

			{
// Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted.
$error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var);

			{
// Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted.
$error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var);

Line 1603Line 1566
*/
function validate_password($password)
{

*/
function validate_password($password)
{

	global $config, $db, $user;

	global $config;


if ($password === '' || $config['pass_complex'] === 'PASS_TYPE_ANY')
{


if ($password === '' || $config['pass_complex'] === 'PASS_TYPE_ANY')
{

Line 1946Line 1909
	}

return false;

	}

return false;

 
}

/**
* Validate hex colour value
*
* @param string $colour The hex colour value
* @param bool $optional Whether the colour value is optional. True if an empty
* string will be accepted as correct input, false if not.
* @return bool|string Error message if colour value is incorrect, false if it
* fits the hex colour code
*/
function phpbb_validate_hex_colour($colour, $optional = false)
{
if ($colour === '')
{
return (($optional) ? false : 'WRONG_DATA');
}

if (!preg_match('/^([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/', $colour))
{
return 'WRONG_DATA';
}

return false;
}

/**
* Verifies whether a style ID corresponds to an active style.
*
* @param int $style_id The style_id of a style which should be checked if activated or not.
* @return boolean
*/
function phpbb_style_is_active($style_id)
{
global $db;

$sql = 'SELECT style_active
FROM ' . STYLES_TABLE . '
WHERE style_id = '. (int) $style_id;
$result = $db->sql_query($sql);

$style_is_active = (bool) $db->sql_fetchfield('style_active');
$db->sql_freeresult($result);

return $style_is_active;

}

/**

}

/**

Line 3585Line 3593
	}

return $user_data['group_id'];

	}

return $user_data['group_id'];

 
}

/**
* Gets user ids of currently banned registered users.
*
* @param array $user_ids Array of users' ids to check for banning,
* leave empty to get complete list of banned ids
* @return array Array of banned users' ids if any, empty array otherwise
*/
function phpbb_get_banned_user_ids($user_ids = array())
{
global $db;

$sql_user_ids = (!empty($user_ids)) ? $db->sql_in_set('ban_userid', $user_ids) : 'ban_userid <> 0';

// Get banned User ID's
// Ignore stale bans which were not wiped yet
$banned_ids_list = array();
$sql = 'SELECT ban_userid
FROM ' . BANLIST_TABLE . "
WHERE $sql_user_ids
AND ban_exclude <> 1
AND (ban_end > " . time() . '
OR ban_end = 0)';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$user_id = (int) $row['ban_userid'];
$banned_ids_list[$user_id] = $user_id;
}
$db->sql_freeresult($result);

return $banned_ids_list;

}

?>

}

?>