Vergleich inc/functions_user.php - 1.2.0 - 1.2.10

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 44Zeile 44
 * Checks a password with a supplied username.
*
* @param string The username of the user.

 * Checks a password with a supplied username.
*
* @param string The username of the user.

 * @param string The md5()'ed password.

 * @param string The plain-text password.

 * @return boolean|array False when no match, array with user info when match.
*/
function validate_password_from_username($username, $password)
{
global $db;

 * @return boolean|array False when no match, array with user info when match.
*/
function validate_password_from_username($username, $password)
{
global $db;

	$query = $db->query("SELECT uid,username,password,salt,loginkey FROM ".TABLE_PREFIX."users WHERE username='".$db->escape_string($username)."' LIMIT 1");

	$query = $db->query("SELECT uid,username,password,salt,loginkey,remember FROM ".TABLE_PREFIX."users WHERE username='".$db->escape_string($username)."' LIMIT 1");

	$user = $db->fetch_array($query);
if(!$user['uid'])

	$user = $db->fetch_array($query);
if(!$user['uid'])

	{

	{

		return false;

		return false;

	}

	}

	else
{
return validate_password_from_uid($user['uid'], $password, $user);
}
}

	else
{
return validate_password_from_uid($user['uid'], $password, $user);
}
}





/**
* Checks a password with a supplied uid.
*
* @param int The user id.

/**
* Checks a password with a supplied uid.
*
* @param int The user id.

 * @param string The md5()'ed password.

 * @param string The plain-text password.

 * @param string An optional user data array.
* @return boolean|array False when not valid, user data array when valid.
*/

 * @param string An optional user data array.
* @return boolean|array False when not valid, user data array when valid.
*/

Zeile 78Zeile 78
		$user = $mybb->user;
}
if(!$user['password'])

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

	{

	{

		$query = $db->query("SELECT uid,username,password,salt,loginkey FROM ".TABLE_PREFIX."users WHERE uid='".intval($uid)."' LIMIT 1");
$user = $db->fetch_array($query);
}

		$query = $db->query("SELECT uid,username,password,salt,loginkey FROM ".TABLE_PREFIX."users WHERE uid='".intval($uid)."' LIMIT 1");
$user = $db->fetch_array($query);
}

Zeile 109Zeile 109
	else
{
return false;

	else
{
return false;

	}

	}

}

/**
* Updates a user's password.
*
* @param int The user's id.

}

/**
* Updates a user's password.
*
* @param int The user's id.

 * @param string The md5()'ed password.

 * @param string The md5()'ed password.

 * @param string (Optional) The salt of the user.
* @return array The new password.
*/

 * @param string (Optional) The salt of the user.
* @return array The new password.
*/

Zeile 148Zeile 148
	// Create new password based on salt
//
$saltedpw = salt_password($password, $salt);

	// Create new password based on salt
//
$saltedpw = salt_password($password, $salt);





	//
// Generate new login key
//

	//
// Generate new login key
//

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

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

 */

 */

function salt_password($password, $salt)
{
return md5(md5($salt).$password);

function salt_password($password, $salt)
{
return md5(md5($salt).$password);

Zeile 186Zeile 186
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 203Zeile 203
 *
* @param int The uid of the user to update.
* @return string The new salt.

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

 */

 */

function update_salt($uid)
{
global $db;
$salt = generate_salt();
$sql_array = array(
"salt" => $salt

function update_salt($uid)
{
global $db;
$salt = generate_salt();
$sql_array = array(
"salt" => $salt

	);
$db->update_query(TABLE_PREFIX."users", $sql_array, "uid = ".$uid, 1);

	);
$db->update_query(TABLE_PREFIX."users", $sql_array, "uid = ".$uid, 1);

	return $salt;
}


	return $salt;
}


Zeile 235Zeile 235

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


/**
* Adds a thread to a user's favorite thread 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 The tid of the thread to add to the list.
* @param int (Optional) The uid of the user who's list to update.
* @return boolean True when success, false when otherwise.
*/
function add_favorite_thread($tid, $uid="")

 *
* @param int The tid of the thread to add to the list.
* @param int (Optional) The uid of the user who's list to update.
* @return boolean True when success, false when otherwise.
*/
function add_favorite_thread($tid, $uid="")

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

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

		return;
}
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."favorites WHERE tid='".intval($tid)."' AND type='f' AND uid='".intval($uid)."' LIMIT 1");

		return;
}
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."favorites WHERE tid='".intval($tid)."' AND type='f' AND uid='".intval($uid)."' LIMIT 1");

Zeile 263Zeile 263

/**
* Removes a thread from a user's favorite thread list.


/**
* Removes a thread from a user's favorite thread 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 The tid of the thread to remove from the list.
* @param int (Optional)The uid of the user who's list to update.
* @return boolean True when success, false when otherwise.
*/
function remove_favorite_thread($tid, $uid="")

 *
* @param int The tid of the thread to remove from the list.
* @param int (Optional)The uid of the user who's list to update.
* @return boolean True when success, false when otherwise.
*/
function remove_favorite_thread($tid, $uid="")

{
global $mybb, $db;
if(!$uid)
{

{
global $mybb, $db;
if(!$uid)
{

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

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

		return;

		return;

	}
$db->query("DELETE FROM ".TABLE_PREFIX."favorites WHERE tid='".intval($tid)."' AND type='f' AND uid='".intval($uid)."'");
return true;

	}
$db->query("DELETE FROM ".TABLE_PREFIX."favorites WHERE tid='".intval($tid)."' AND type='f' AND uid='".intval($uid)."'");
return true;

Zeile 293Zeile 293
 * @return boolean True when success, false when otherwise.
*/
function add_subscribed_thread($tid, $uid="")

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

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

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

		return;
}
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."favorites WHERE tid='".intval($tid)."' AND type='s' AND uid='".intval($uid)."' LIMIT 1");

		return;
}
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."favorites WHERE tid='".intval($tid)."' AND type='s' AND uid='".intval($uid)."' LIMIT 1");

Zeile 308Zeile 308
	if(!$favorite['tid'])
{
$db->query("INSERT INTO ".TABLE_PREFIX."favorites (uid,tid,type) VALUES ('".intval($uid)."','".intval($tid)."','s')");

	if(!$favorite['tid'])
{
$db->query("INSERT INTO ".TABLE_PREFIX."favorites (uid,tid,type) VALUES ('".intval($uid)."','".intval($tid)."','s')");

	}

	}

	return true;
}


	return true;
}


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

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

{
global $mybb, $db;
if(!$uid)
{

{
global $mybb, $db;
if(!$uid)
{

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

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

	}

	}

	if(!$uid)
{
return;
}
$db->query("DELETE FROM ".TABLE_PREFIX."favorites WHERE tid='".$tid."' AND type='s' AND uid='".$uid."'");

	if(!$uid)
{
return;
}
$db->query("DELETE FROM ".TABLE_PREFIX."favorites WHERE tid='".$tid."' AND type='s' AND uid='".$uid."'");

	return true;

	return true;

}

/**

}

/**

Zeile 356Zeile 356
	}
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."forumsubscriptions WHERE fid='".$fid."' AND uid='".$uid."' LIMIT 1");
$fsubscription = $db->fetch_array($query);

	}
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."forumsubscriptions WHERE fid='".$fid."' AND uid='".$uid."' LIMIT 1");
$fsubscription = $db->fetch_array($query);

	if(!$fsubscription['fid'])
{
$db->query("INSERT INTO ".TABLE_PREFIX."forumsubscriptions (fid,uid) VALUES ('".$fid."','".$uid."')");
}
return true;
}

	if(!$fsubscription['fid'])
{
$db->query("INSERT INTO ".TABLE_PREFIX."forumsubscriptions (fid,uid) VALUES ('".$fid."','".$uid."')");
}
return true;
}


/**
* Removes a forum from a user's forum subscription list.


/**
* Removes a forum from a user's forum subscription list.

Zeile 508Zeile 508
{
global $db, $mybb;
static $pm_lastvisit_cache;

{
global $db, $mybb;
static $pm_lastvisit_cache;





	
$uid = intval($uid);


	// If no user id, assume that we mean the current logged in user.

	// If no user id, assume that we mean the current logged in user.

	if(intval($uid) == 0)

	if($uid == 0)

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


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


	// If using logged in user, use the last visit

	// If using current user, use the last visit

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

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

Zeile 525Zeile 527
	{
if(!$pm_lastvisit_cache[$uid])
{

	{
if(!$pm_lastvisit_cache[$uid])
{

			$query = $db->query("SELECT lastvisit FROM ".TABLE_PREFIX."users WHERE uid='".intval($uid)."'");

			$query = $db->query("SELECT lastvisit FROM ".TABLE_PREFIX."users WHERE uid='".$uid."'");

			$user = $db->fetch_array($query);
$pm_lastvisit_cache[$uid] = $user['lastvisit'];
}

			$user = $db->fetch_array($query);
$pm_lastvisit_cache[$uid] = $user['lastvisit'];
}

Zeile 533Zeile 535
	}
// Update total number of messages.
if($count_to_update & 1)

	}
// Update total number of messages.
if($count_to_update & 1)

	{

	{

		$query = $db->query("SELECT COUNT(pmid) AS pms_total FROM ".TABLE_PREFIX."privatemessages WHERE uid='".$uid."'");
$total = $db->fetch_array($query);
$pmcount['totalpms'] = $total['pms_total'];

		$query = $db->query("SELECT COUNT(pmid) AS pms_total FROM ".TABLE_PREFIX."privatemessages WHERE uid='".$uid."'");
$total = $db->fetch_array($query);
$pmcount['totalpms'] = $total['pms_total'];

Zeile 541Zeile 543
	// Update number of new messages.
if($count_to_update & 2)
{

	// Update number of new messages.
if($count_to_update & 2)
{

		$query = $db->query("SELECT COUNT(pmid) AS pms_new FROM ".TABLE_PREFIX."privatemessages WHERE uid='".$uid."' AND dateline>'".$mybb->user['lastvisit']."' AND folder=1");

		$query = $db->query("SELECT COUNT(pmid) AS pms_new FROM ".TABLE_PREFIX."privatemessages WHERE uid='".$uid."' AND dateline>'".$lastvisit."' AND folder=1");

		$new = $db->fetch_array($query);
$pmcount['newpms'] = $new['pms_new'];
}

		$new = $db->fetch_array($query);
$pmcount['newpms'] = $new['pms_new'];
}

Zeile 554Zeile 556
	}
if(is_array($pmcount))
{

	}
if(is_array($pmcount))
{

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

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

	}
return $pmcount;

	}
return $pmcount;

}

/**
* Return a list of banned usernames.
*
* @return array The array of banned usernames.
*/
function get_banned_usernames()
{
$bannedusernames = explode(",", $mybb->settings['bannedusernames']);
return $bannedusernames;

 
}

/**

}

/**