Vergleich inc/functions_user.php - 1.8.7 - 1.8.21

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 56Zeile 56
	global $mybb;

$options = array(

	global $mybb;

$options = array(

		'fields' => array('username', 'password', 'salt', 'loginkey', 'coppauser', 'usergroup'),

		'fields' => '*',

		'username_method' => $mybb->settings['username_method'],
);


		'username_method' => $mybb->settings['username_method'],
);


Zeile 87Zeile 87
	}
if(!$user['password'])
{

	}
if(!$user['password'])
{

		$query = $db->simple_select("users", "uid,username,password,salt,loginkey,usergroup", "uid='".(int)$uid."'");
$user = $db->fetch_array($query);

		$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

	}
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'] = salt_password($user['password'], $user['salt']);
$sql_array = array(
"salt" => $user['salt'],
"password" => $user['password']
);
$db->update_query("users", $sql_array, "uid='".$user['uid']."'");

		$password_fields = create_password($user['password'], false, $user);
$db->update_query("users", $password_fields, "uid='".$user['uid']."'");






	}

if(!$user['loginkey'])

	}

if(!$user['loginkey'])

Zeile 110Zeile 104
		);
$db->update_query("users", $sql_array, "uid = ".$user['uid']);
}

		);
$db->update_query("users", $sql_array, "uid = ".$user['uid']);
}

	if(salt_password(md5($password), $user['salt']) === $user['password'])

	if(verify_user_password($user, $password))

	{
return $user;

	{
return $user;

	}

	}

	else
{
return false;

	else
{
return false;

Zeile 127Zeile 121
 * @param string $password The md5()'ed password.
* @param string $salt (Optional) The salt of the user.
* @return array The new password.

 * @param string $password The md5()'ed password.
* @param string $salt (Optional) The salt of the user.
* @return array The new password.

 
 * @deprecated deprecated since version 1.8.6 Please use other alternatives.

 */
function update_password($uid, $password, $salt="")
{

 */
function update_password($uid, $password, $salt="")
{

Zeile 162Zeile 157
	$db->update_query("users", $newpassword, "uid='$uid'");

$plugins->run_hooks("password_changed");

	$db->update_query("users", $newpassword, "uid='$uid'");

$plugins->run_hooks("password_changed");





	return $newpassword;

	return $newpassword;

}

/**
* Salts a password based on a supplied salt.

}

/**
* Salts a password based on a supplied salt.

 *
* @param string $password The md5()'ed password.
* @param string $salt The salt.
* @return string The password hash.

 *
* @param string $password The md5()'ed password.
* @param string $salt The salt.
* @return string The password hash.

 */


 * @deprecated deprecated since version 1.8.9 Please use other alternatives.
*/

function salt_password($password, $salt)

function salt_password($password, $salt)

{

{

	return md5(md5($salt).$password);

	return md5(md5($salt).$password);

 
}

/**
* Salts a password based on a supplied salt.
*
* @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 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,
);
}

return $fields;
}

/**
* Compares user's password data against provided input.
*
* @param array $user An array containing password-related data.
* @param string $password The plain-text input password.
* @return bool Result of the comparison.
*/
function verify_user_password($user, $password)
{
global $plugins;

$result = null;

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

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

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

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

}

/**

}

/**

Zeile 292Zeile 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)
{
$uid = $mybb->user['uid'];
}

{
global $mybb, $db;

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


if(!$uid)
{


if(!$uid)
{

Zeile 306Zeile 377
	}
$db->delete_query("threadsubscriptions", "tid='".$tid."' AND uid='{$uid}'");


	}
$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.
*
* @param int $fid The fid of the forum to add to the 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.
*
* @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.
* @return boolean True when success, false when otherwise.

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

 */
function add_subscribed_forum($fid, $uid=0)
{

 */
function add_subscribed_forum($fid, $uid=0)
{

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

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

	}


	}


	if(!$uid)
{
return false;
}

$fid = (int)$fid;

	if(!$uid)
{
return false;
}

$fid = (int)$fid;

	$uid = (int)$uid;

	$uid = (int)$uid;


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

Zeile 361Zeile 432
	global $mybb, $db;

if(!$uid)

	global $mybb, $db;

if(!$uid)

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

if(!$uid)
{

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

if(!$uid)
{

		return false;
}
$db->delete_query("forumsubscriptions", "fid='".$fid."' AND uid='{$uid}'");

		return false;
}
$db->delete_query("forumsubscriptions", "fid='".$fid."' AND uid='{$uid}'");





	return true;
}

	return true;
}





/**
* Constructs the usercp navigation menu.
*

/**
* Constructs the usercp navigation menu.
*

Zeile 383Zeile 454
	global $mybb, $templates, $theme, $plugins, $lang, $usercpnav, $usercpmenu;

$lang->load("usercpnav");

	global $mybb, $templates, $theme, $plugins, $lang, $usercpnav, $usercpmenu;

$lang->load("usercpnav");





	// Add the default items as plugins with separated priorities of 10

	// Add the default items as plugins with separated priorities of 10

	if($mybb->settings['enablepms'] != 0)

	if($mybb->settings['enablepms'] != 0 && $mybb->usergroup['canusepms'] == 1)

	{
$plugins->add_hook("usercp_menu", "usercp_menu_messenger", 10);
}


	{
$plugins->add_hook("usercp_menu", "usercp_menu_messenger", 10);
}


	$plugins->add_hook("usercp_menu", "usercp_menu_profile", 20);
$plugins->add_hook("usercp_menu", "usercp_menu_misc", 30);




	if($mybb->usergroup['canusercp'] == 1)
{
$plugins->add_hook("usercp_menu", "usercp_menu_profile", 20);
$plugins->add_hook("usercp_menu", "usercp_menu_misc", 30);
}


// Run the plugin hooks
$plugins->run_hooks("usercp_menu");
global $usercpmenu;


// Run the plugin hooks
$plugins->run_hooks("usercp_menu");
global $usercpmenu;

 

if($mybb->usergroup['canusercp'] == 1)
{
eval("\$ucp_nav_home = \"".$templates->get("usercp_nav_home")."\";");
}


eval("\$usercpnav = \"".$templates->get("usercp_nav")."\";");



eval("\$usercpnav = \"".$templates->get("usercp_nav")."\";");


Zeile 408Zeile 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 470Zeile 550
 */
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 497Zeile 577
		$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 506Zeile 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 535Zeile 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 575Zeile 657
		}

return $usertitle['title'];

		}

return $usertitle['title'];

	}
}

	}
}


/**
* Updates a users private message count in the users table with the number of pms they have.


/**
* Updates a users private message count in the users table with the number of pms they have.

Zeile 593Zeile 675
	if((int)$uid == 0)
{
$uid = $mybb->user['uid'];

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

	}

	}


$uid = (int)$uid;
$pmcount = array();


$uid = (int)$uid;
$pmcount = array();

Zeile 619Zeile 701
	}

if(!empty($pmcount))

	}

if(!empty($pmcount))

	{

	{

		$db->update_query("users", $pmcount, "uid='".$uid."'");
}
return $pmcount;

		$db->update_query("users", $pmcount, "uid='".$uid."'");
}
return $pmcount;

Zeile 643Zeile 725

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 2:
return $lang->folder_sent_items;