Vergleich inc/functions_user.php - 1.8.6 - 1.8.37

  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'],
);

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


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

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


	if(!$user['uid'])

	if(!$user)

	{
return false;
}

	{
return false;
}

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);
}
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']."'");

		$user = get_user($uid);













	}

if(!$user['loginkey'])

	}

if(!$user['loginkey'])

Zeile 110Zeile 98
		);
$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;
}

Zeile 127Zeile 115
 * @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 140Zeile 129
		$query = $db->simple_select("users", "salt", "uid='$uid'");
$user = $db->fetch_array($query);
if($user['salt'])

		$query = $db->simple_select("users", "salt", "uid='$uid'");
$user = $db->fetch_array($query);
if($user['salt'])

		{

		{

			$salt = $user['salt'];
}
else

			$salt = $user['salt'];
}
else

Zeile 164Zeile 153
	$plugins->run_hooks("password_changed");

return $newpassword;

	$plugins->run_hooks("password_changed");

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)
{
return md5(md5($salt).$password);

 */
function salt_password($password, $salt)
{
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']);
}
}


/**
* Generates a random salt


/**
* Generates a random salt

Zeile 194Zeile 259
 * @return string The login key.
*/
function generate_loginkey()

 * @return string The login key.
*/
function generate_loginkey()

{

{

	return random_str(50);
}


	return random_str(50);
}


Zeile 203Zeile 268
 *
* @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.

 */

 */

function update_salt($uid)
{
global $db;

function update_salt($uid)
{
global $db;

Zeile 211Zeile 276
	$salt = generate_salt();
$sql_array = array(
"salt" => $salt

	$salt = generate_salt();
$sql_array = array(
"salt" => $salt

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

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


return $salt;
}


return $salt;
}

Zeile 239Zeile 304

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


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

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

 *
* @param int $tid The tid of the thread to add to the list.
* @param int $notification (Optional) The type of notification to receive for replies (0=none, 1=email, 2=pm)

 *
* @param int $tid The tid of the thread to add to the list.
* @param int $notification (Optional) The type of notification to receive for replies (0=none, 1=email, 2=pm)

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

if(!$uid)
{

{
global $mybb, $db;

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

if(!$uid)
{

		return false;
}

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

		return false;
}

$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,

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

			'dateline' => TIME_NOW,
'subscriptionkey' => md5(TIME_NOW.$uid.$tid)


			'dateline' => TIME_NOW



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

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

Zeile 313Zeile 376

/**
* 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 338Zeile 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 387Zeile 450
	$lang->load("usercpnav");

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

	$lang->load("usercpnav");

// 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 410Zeile 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 420Zeile 492
		$tracking = $templates->get("usercp_nav_messenger_tracking");
}
eval("\$ucp_nav_tracking = \"". $tracking ."\";");

		$tracking = $templates->get("usercp_nav_messenger_tracking");
}
eval("\$ucp_nav_tracking = \"". $tracking ."\";");





	// Hide compose link if no permission
$ucp_nav_compose = '';
if($mybb->usergroup['cansendpms'] == 1)

	// Hide compose link if no permission
$ucp_nav_compose = '';
if($mybb->usergroup['cansendpms'] == 1)

Zeile 437Zeile 509
		if($folderinfo[0] == 4)
{
$class = "usercp_nav_trash_pmfolder";

		if($folderinfo[0] == 4)
{
$class = "usercp_nav_trash_pmfolder";

		}

		}

		else if($folderlinks)
{
$class = "usercp_nav_sub_pmfolder";

		else if($folderlinks)
{
$class = "usercp_nav_sub_pmfolder";

Zeile 454Zeile 526
	}

if(!isset($collapsedimg['usercppms']))

	}

if(!isset($collapsedimg['usercppms']))

	{

	{

		$collapsedimg['usercppms'] = '';

		$collapsedimg['usercppms'] = '';

	}


	}


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

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

	}


	}


	eval("\$usercpmenu .= \"".$usercp_nav_messenger."\";");
}


	eval("\$usercpmenu .= \"".$usercp_nav_messenger."\";");
}


Zeile 472Zeile 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 499Zeile 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 508Zeile 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 537Zeile 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 645Zeile 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 671Zeile 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;