Vergleich inc/functions_user.php - 1.8.9 - 1.8.37

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 62Zeile 62

$user = get_user_by_username($username, $options);



$user = get_user_by_username($username, $options);


	if(!$user['uid'])

	if(!$user)

	{
return false;
}

	{
return false;
}

Zeile 88Zeile 88
	if(!$user['password'])
{
$user = get_user($uid);

	if(!$user['password'])
{
$user = get_user($uid);

	}
if(!$user['salt'])
{
// Generate a salt for this user and assume the password stored in db is a plain md5 password
$user['salt'] = generate_salt();
$user['password'] = create_password_hash($user['password'], $user['salt'], $user);
$sql_array = array(
"salt" => $user['salt'],
"password" => $user['password']
);
$db->update_query("users", $sql_array, "uid='".$user['uid']."'");

 
	}

if(!$user['loginkey'])

	}

if(!$user['loginkey'])

Zeile 183Zeile 172
 * Salts a password based on a supplied salt.
*
* @param string $password The input password.

 * Salts a password based on a supplied salt.
*
* @param string $password The input password.

 * @param string $salt The salt used by the MyBB algorithm.

 * @param string $salt (Optional) The salt used by the MyBB algorithm.

 * @param string $user (Optional) An array containing password-related data.

 * @param string $user (Optional) An array containing password-related data.

 * @return string The password hash.
*/
function create_password_hash($password, $salt, $user = false)
{
global $plugins;

$hash = null;

$parameters = compact('password', 'salt', 'user', 'hash');

if(!defined('IN_INSTALL') && !defined('IN_UPGRADE'))
{
$plugins->run_hooks('create_password_hash', $parameters);
}




















 * @return array Password-related fields.
*/
function create_password($password, $salt = false, $user = false)
{
global $plugins;

$fields = null;

$parameters = compact('password', 'salt', 'user', 'fields');

if(!defined('IN_INSTALL') && !defined('IN_UPGRADE'))
{
$plugins->run_hooks('create_password', $parameters);
}

if(!is_null($parameters['fields']))
{
$fields = $parameters['fields'];
}
else
{
if(!$salt)
{
$salt = generate_salt();
}

$hash = md5(md5($salt).md5($password));

$fields = array(
'salt' => $salt,
'password' => $hash,
);
}





	if(!is_null($parameters['hash']))
{
return $parameters['hash'];
}
else
{
return md5(md5($salt).md5($password));
}

	return $fields;








}

/**

}

/**

Zeile 224Zeile 225
	$result = null;

$parameters = compact('user', 'password', 'result');

	$result = null;

$parameters = compact('user', 'password', 'result');





	if(!defined('IN_INSTALL') && !defined('IN_UPGRADE'))

	if(!defined('IN_INSTALL') && !defined('IN_UPGRADE'))

	{

	{

		$plugins->run_hooks('verify_user_password', $parameters);
}


		$plugins->run_hooks('verify_user_password', $parameters);
}


	if(!is_null($parameters['result']))
{
return $parameters['result'];
}
else
{
$hashed_password = create_password_hash($password, $user['salt'], $user);

return my_hash_equals($user['password'], $hashed_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', '>='))

	if(!is_null($parameters['result']))






















	{

	{

		return hash_equals($known_string, $user_string);

		return $parameters['result'];

	}
else
{

	}
else
{

		$known_string_length = my_strlen($known_string);
$user_string_length = my_strlen($user_string);

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






		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;

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













	}
}


	}
}


Zeile 298Zeile 265

/**
* 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.
* @return string The new salt.
*/

 * @param int $uid The uid of the user to update.
* @return string The new salt.
*/

Zeile 307Zeile 274
	global $db;

$salt = generate_salt();

	global $db;

$salt = generate_salt();

	$sql_array = array(

	$sql_array = array(

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

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





	return $salt;
}

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

	return $salt;
}

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

 *

 *

 * @param int $uid The uid of the user to update.
* @return string The new login key.
*/

 * @param int $uid The uid of the user to update.
* @return string The new login key.
*/

Zeile 356Zeile 323
	if(!$uid)
{
return false;

	if(!$uid)
{
return false;

	}

	}


$query = $db->simple_select("threadsubscriptions", "*", "tid='".(int)$tid."' AND uid='".(int)$uid."'");
$subscription = $db->fetch_array($query);


$query = $db->simple_select("threadsubscriptions", "*", "tid='".(int)$tid."' AND uid='".(int)$uid."'");
$subscription = $db->fetch_array($query);

	if(!$subscription['tid'])

	if(!$subscription)

	{
$insert_array = array(
'uid' => (int)$uid,
'tid' => (int)$tid,
'notification' => (int)$notification,
'dateline' => TIME_NOW

	{
$insert_array = array(
'uid' => (int)$uid,
'tid' => (int)$tid,
'notification' => (int)$notification,
'dateline' => TIME_NOW

		);

		);

		$db->insert_query("threadsubscriptions", $insert_array);

		$db->insert_query("threadsubscriptions", $insert_array);

	}

	}

	else
{
// Subscription exists - simply update notification

	else
{
// Subscription exists - simply update notification

Zeile 377Zeile 344
			"notification" => (int)$notification
);
$db->update_query("threadsubscriptions", $update_array, "uid='{$uid}' AND tid='{$tid}'");

			"notification" => (int)$notification
);
$db->update_query("threadsubscriptions", $update_array, "uid='{$uid}' AND tid='{$tid}'");

	}
return true;
}

	}
return true;
}


/**
* Remove a thread from a user's thread subscription list.
* If no uid is supplied, the currently logged in user's id will be used.
*
* @param int $tid The tid of the thread to remove from the list.


/**
* Remove a thread from a user's thread subscription list.
* If no uid is supplied, the currently logged in user's id will be used.
*
* @param int $tid The tid of the thread to remove from the list.

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

 * @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_thread($tid, $uid=0)

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

{
global $mybb, $db;

if(!$uid)
{
$uid = $mybb->user['uid'];
}

{
global $mybb, $db;

if(!$uid)
{
$uid = $mybb->user['uid'];
}


if(!$uid)
{
return false;
}
$db->delete_query("threadsubscriptions", "tid='".$tid."' AND uid='{$uid}'");


if(!$uid)
{
return false;
}
$db->delete_query("threadsubscriptions", "tid='".$tid."' AND uid='{$uid}'");


return true;
}



return true;
}


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

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

Zeile 416Zeile 383
 * @return boolean True when success, false when otherwise.
*/
function add_subscribed_forum($fid, $uid=0)

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

{

{

	global $mybb, $db;

if(!$uid)

	global $mybb, $db;

if(!$uid)

Zeile 434Zeile 401

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


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

	if(!$fsubscription['fid'])

	if(!$fsubscription)

	{
$insert_array = array(
'fid' => $fid,

	{
$insert_array = array(
'fid' => $fid,

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

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


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


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

	}

if(!$uid)

	}

if(!$uid)

Zeile 514Zeile 481
 */
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)) ? $lang->expcol_expand : $lang->expcol_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 576Zeile 544
 */
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)

Zeile 603Zeile 571
		$collapsed['usercpprofile_e'] = '';
}


		$collapsed['usercpprofile_e'] = '';
}


 
	$expaltext = (in_array("usercpprofile", $collapse)) ? $lang->expcol_expand : $lang->expcol_collapse;

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


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


Zeile 612Zeile 581
 */
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 = '';

	$draftstart = $draftend = $attachmentop = '';

	$draftcount = $lang->ucp_nav_drafts;

$query = $db->simple_select("posts", "COUNT(pid) AS draftcount", "visible = '-2' AND uid = '{$mybb->user['uid']}'");

	$draftcount = $lang->ucp_nav_drafts;

$query = $db->simple_select("posts", "COUNT(pid) AS draftcount", "visible = '-2' AND uid = '{$mybb->user['uid']}'");

Zeile 641Zeile 610
	}

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

	}

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

 
	$expaltext = (in_array("usercpmisc", $collapse)) ? $lang->expcol_expand : $lang->expcol_collapse;

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


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


Zeile 749Zeile 719

switch($fid)
{


switch($fid)
{

		case 1:

		case 0:

			return $lang->folder_inbox;

			return $lang->folder_inbox;

 
			break;
case 1:
return $lang->folder_unread;

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

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

			break;

			break;

		case 4:
return $lang->folder_trash;
break;

		case 4:
return $lang->folder_trash;
break;

Zeile 775Zeile 748
function generate_question($old_qid=0)
{
global $db;

function generate_question($old_qid=0)
{
global $db;





	if($db->type == 'pgsql' || $db->type == 'sqlite')
{
$order_by = 'RANDOM()';

	if($db->type == 'pgsql' || $db->type == 'sqlite')
{
$order_by = 'RANDOM()';

	}

	}

	else
{
$order_by = 'RAND()';
}

	else
{
$order_by = 'RAND()';
}

	



$excl_old = '';

	if($old_qid)
{
$excl_old = ' AND qid != '.(int)$old_qid;

	if($old_qid)
{
$excl_old = ' AND qid != '.(int)$old_qid;