Vergleich inc/functions_user.php - 1.8.11 - 1.8.20

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 180Zeile 180
 * @param string $password The input password.
* @param string $salt (Optional) The salt used by the MyBB algorithm.
* @param string $user (Optional) An array containing password-related data.

 * @param string $password The input password.
* @param string $salt (Optional) The salt used by the MyBB algorithm.
* @param string $user (Optional) An array containing password-related data.

 * @return string The password hash.

 * @return array Password-related fields.

 */
function create_password($password, $salt = false, $user = false)
{

 */
function create_password($password, $salt = false, $user = false)
{

Zeile 246Zeile 246
		$password_fields = create_password($password, $user['salt'], $user);

return my_hash_equals($user['password'], $password_fields['password']);

		$password_fields = create_password($password, $user['salt'], $user);

return my_hash_equals($user['password'], $password_fields['password']);

	}
}

/**
* Performs a timing attack safe string comparison.
*
* @param string $known_string The first string to be compared.
* @param string $user_string The second, user-supplied string to be compared.
* @return bool Result of the comparison.
*/
function my_hash_equals($known_string, $user_string)
{
if(version_compare(PHP_VERSION, '5.6.0', '>='))
{
return hash_equals($known_string, $user_string);
}
else
{
$known_string_length = my_strlen($known_string);
$user_string_length = my_strlen($user_string);

if($user_string_length != $known_string_length)
{
return false;
}

$result = 0;

for($i = 0; $i < $known_string_length; $i++)
{
$result |= ord($known_string[$i]) ^ ord($user_string[$i]);
}

return $result === 0;

 
	}
}


	}
}


Zeile 291Zeile 257
function generate_salt()
{
return random_str(8);

function generate_salt()
{
return random_str(8);

}

}


/**
* Generates a 50 character random login key.


/**
* Generates a 50 character random login key.

Zeile 305Zeile 271

/**
* Updates a user's salt in the database (does not update a password).


/**
* Updates a user's salt in the database (does not update a password).

 *
* @param int $uid The uid of the user to update.

 *
* @param int $uid The uid of the user to update.

 * @return string The new salt.
*/
function update_salt($uid)

 * @return string The new salt.
*/
function update_salt($uid)

Zeile 320Zeile 286
	$db->update_query("users", $sql_array, "uid='{$uid}'");

return $salt;

	$db->update_query("users", $sql_array, "uid='{$uid}'");

return $salt;

}

}


/**
* Generates a new login key for a user.


/**
* Generates a new login key for a user.

Zeile 339Zeile 305
	$db->update_query("users", $sql_array, "uid='{$uid}'");

return $loginkey;

	$db->update_query("users", $sql_array, "uid='{$uid}'");

return $loginkey;


}

/**


}

/**

 * Adds a thread to a user's thread subscription list.
* If no uid is supplied, the currently logged in user's id will be used.
*

 * Adds a thread to a user's thread subscription list.
* If no uid is supplied, the currently logged in user's id will be used.
*

Zeile 352Zeile 318
 * @return boolean True when success, false when otherwise.
*/
function add_subscribed_thread($tid, $notification=1, $uid=0)

 * @return boolean True when success, false when otherwise.
*/
function add_subscribed_thread($tid, $notification=1, $uid=0)

{
global $mybb, $db;

if(!$uid)

{
global $mybb, $db;

if(!$uid)

	{
$uid = $mybb->user['uid'];

	{
$uid = $mybb->user['uid'];

	}

if(!$uid)

	}

if(!$uid)

	{
return false;
}

	{
return false;
}

Zeile 397Zeile 363
 * @return boolean True when success, false when otherwise.
*/
function remove_subscribed_thread($tid, $uid=0)

 * @return boolean True when success, false when otherwise.
*/
function remove_subscribed_thread($tid, $uid=0)

{
global $mybb, $db;

if(!$uid)
{

{
global $mybb, $db;

if(!$uid)
{

		$uid = $mybb->user['uid'];
}


		$uid = $mybb->user['uid'];
}


Zeile 416Zeile 382

/**
* Adds a forum to a user's forum subscription list.


/**
* Adds a forum to a user's forum subscription list.

 * If no uid is supplied, the currently logged in user's id will be used.

 * If no uid is supplied, the currently logged in user's id will be used.

 *
* @param int $fid The fid of the forum to add to the list.
* @param int $uid (Optional) The uid of the user who's list to update.

 *
* @param int $fid The fid of the forum to add to the list.
* @param int $uid (Optional) The uid of the user who's list to update.

Zeile 438Zeile 404

$fid = (int)$fid;
$uid = (int)$uid;


$fid = (int)$fid;
$uid = (int)$uid;





	$query = $db->simple_select("forumsubscriptions", "*", "fid='".$fid."' AND uid='{$uid}'", array('limit' => 1));
$fsubscription = $db->fetch_array($query);
if(!$fsubscription['fid'])

	$query = $db->simple_select("forumsubscriptions", "*", "fid='".$fid."' AND uid='{$uid}'", array('limit' => 1));
$fsubscription = $db->fetch_array($query);
if(!$fsubscription['fid'])

Zeile 460Zeile 426
 * @param int $fid The fid of the forum to remove from the list.
* @param int $uid (Optional) The uid of the user who's list to update.
* @return boolean True when success, false when otherwise.

 * @param int $fid The fid of the forum to remove from the list.
* @param int $uid (Optional) The uid of the user who's list to update.
* @return boolean True when success, false when otherwise.

 */

 */

function remove_subscribed_forum($fid, $uid=0)
{
global $mybb, $db;

function remove_subscribed_forum($fid, $uid=0)
{
global $mybb, $db;

Zeile 521Zeile 487
 */
function usercp_menu_messenger()
{

 */
function usercp_menu_messenger()
{

	global $db, $mybb, $templates, $theme, $usercpmenu, $lang, $collapsed, $collapsedimg;

	global $db, $mybb, $templates, $theme, $usercpmenu, $lang, $collapse, $collapsed, $collapsedimg;





 
	$expaltext = (in_array("usercppms", $collapse)) ? "[+]" : "[-]";

	$usercp_nav_messenger = $templates->get("usercp_nav_messenger");
// Hide tracking link if no permission
$tracking = '';

	$usercp_nav_messenger = $templates->get("usercp_nav_messenger");
// Hide tracking link if no permission
$tracking = '';

Zeile 579Zeile 546

/**
* Constructs the usercp profile menu.


/**
* Constructs the usercp profile menu.

 *

 *

 */
function usercp_menu_profile()
{

 */
function usercp_menu_profile()
{

	global $db, $mybb, $templates, $theme, $usercpmenu, $lang, $collapsed, $collapsedimg;

	global $db, $mybb, $templates, $theme, $usercpmenu, $lang, $collapse, $collapsed, $collapsedimg;


$changenameop = '';
if($mybb->usergroup['canchangename'] != 0)


$changenameop = '';
if($mybb->usergroup['canchangename'] != 0)

	{

	{

		eval("\$changenameop = \"".$templates->get("usercp_nav_changename")."\";");
}


		eval("\$changenameop = \"".$templates->get("usercp_nav_changename")."\";");
}


Zeile 608Zeile 575
	if(!isset($collapsed['usercpprofile_e']))
{
$collapsed['usercpprofile_e'] = '';

	if(!isset($collapsed['usercpprofile_e']))
{
$collapsed['usercpprofile_e'] = '';

	}



	}

$expaltext = (in_array("usercpprofile", $collapse)) ? "[+]" : "[-]";

	eval("\$usercpmenu .= \"".$templates->get("usercp_nav_profile")."\";");
}


	eval("\$usercpmenu .= \"".$templates->get("usercp_nav_profile")."\";");
}


Zeile 619Zeile 587
 */
function usercp_menu_misc()
{

 */
function usercp_menu_misc()
{

	global $db, $mybb, $templates, $theme, $usercpmenu, $lang, $collapsed, $collapsedimg;

	global $db, $mybb, $templates, $theme, $usercpmenu, $lang, $collapse, $collapsed, $collapsedimg;


$draftstart = $draftend = '';
$draftcount = $lang->ucp_nav_drafts;


$draftstart = $draftend = '';
$draftcount = $lang->ucp_nav_drafts;

Zeile 640Zeile 608
	if(!isset($collapsedimg['usercpmisc']))
{
$collapsedimg['usercpmisc'] = '';

	if(!isset($collapsedimg['usercpmisc']))
{
$collapsedimg['usercpmisc'] = '';

	}

	}


if(!isset($collapsed['usercpmisc_e']))
{


if(!isset($collapsed['usercpmisc_e']))
{

Zeile 648Zeile 616
	}

$profile_link = get_profile_link($mybb->user['uid']);

	}

$profile_link = get_profile_link($mybb->user['uid']);

 
	$expaltext = (in_array("usercpmisc", $collapse)) ? "[+]" : "[-]";

	eval("\$usercpmenu .= \"".$templates->get("usercp_nav_misc")."\";");
}


	eval("\$usercpmenu .= \"".$templates->get("usercp_nav_misc")."\";");
}


Zeile 662Zeile 631
	global $db, $mybb;

if($mybb->user['uid'] == $uid)

	global $db, $mybb;

if($mybb->user['uid'] == $uid)

	{

	{

		$user = $mybb->user;
}
else
{
$query = $db->simple_select("users", "usertitle,postnum", "uid='$uid'", array('limit' => 1));
$user = $db->fetch_array($query);

		$user = $mybb->user;
}
else
{
$query = $db->simple_select("users", "usertitle,postnum", "uid='$uid'", array('limit' => 1));
$user = $db->fetch_array($query);

	}

	}


if($user['usertitle'])
{


if($user['usertitle'])
{

Zeile 699Zeile 668
 * @return array The updated counters
*/
function update_pm_count($uid=0, $count_to_update=7)

 * @return array The updated counters
*/
function update_pm_count($uid=0, $count_to_update=7)

{

{

	global $db, $mybb;

	global $db, $mybb;





	// If no user id, assume that we mean the current logged in user.
if((int)$uid == 0)
{
$uid = $mybb->user['uid'];

	// If no user id, assume that we mean the current logged in user.
if((int)$uid == 0)
{
$uid = $mybb->user['uid'];

	}


	}


	$uid = (int)$uid;
$pmcount = array();
if($uid == 0)
{
return $pmcount;

	$uid = (int)$uid;
$pmcount = array();
if($uid == 0)
{
return $pmcount;

	}


	}


	// Update total number of messages.
if($count_to_update & 1)
{
$query = $db->simple_select("privatemessages", "COUNT(pmid) AS pms_total", "uid='".$uid."'");
$total = $db->fetch_array($query);
$pmcount['totalpms'] = $total['pms_total'];

	// Update total number of messages.
if($count_to_update & 1)
{
$query = $db->simple_select("privatemessages", "COUNT(pmid) AS pms_total", "uid='".$uid."'");
$total = $db->fetch_array($query);
$pmcount['totalpms'] = $total['pms_total'];

	}

	}


// Update number of unread messages.
if($count_to_update & 2 && $db->field_exists("unreadpms", "users") == true)


// Update number of unread messages.
if($count_to_update & 2 && $db->field_exists("unreadpms", "users") == true)

Zeile 750Zeile 719
	global $lang;

if($name != '')

	global $lang;

if($name != '')

	{

	{

		return $name;
}

switch($fid)
{

		return $name;
}

switch($fid)
{

 
		case 0:
return $lang->folder_inbox;
break;

		case 1:

		case 1:

			return $lang->folder_inbox;

			return $lang->folder_unread;

			break;
case 2:
return $lang->folder_sent_items;

			break;
case 2:
return $lang->folder_sent_items;