Zeile 56 | Zeile 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 87 | Zeile 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 110 | Zeile 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 127 | Zeile 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="") { global $db, $plugins;
|
*/ function update_password($uid, $password, $salt="") { global $db, $plugins;
|
|
|
$newpassword = array();
// If no salt was specified, check in database first, if still doesn't exist, create one
| $newpassword = array();
// If no salt was specified, check in database first, if still doesn't exist, create one
|
Zeile 155 | Zeile 150 |
---|
// Generate new login key $loginkey = generate_loginkey();
|
// Generate new login key $loginkey = generate_loginkey();
|
|
|
// Update password and login key in database $newpassword['password'] = $saltedpw; $newpassword['loginkey'] = $loginkey;
| // Update password and login key in database $newpassword['password'] = $saltedpw; $newpassword['loginkey'] = $loginkey;
|
Zeile 164 | Zeile 159 |
---|
$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 string The password hash. */ 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']); } }
/** * 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; } }
/**
|
* Generates a random salt * * @return string The salt.
| * Generates a random salt * * @return string The salt.
|
Zeile 186 | Zeile 291 |
---|
function generate_salt() { return random_str(8);
|
function generate_salt() { return random_str(8);
|
}
| }
|
/** * Generates a 50 character random login key. * * @return string The login key.
|
/** * Generates a 50 character random login key. * * @return string The login key.
|
*/
| */
|
function generate_loginkey() { return random_str(50);
| function generate_loginkey() { return random_str(50);
|
Zeile 205 | Zeile 310 |
---|
* @return string The new salt. */ function update_salt($uid)
|
* @return string The new salt. */ function update_salt($uid)
|
{ global $db;
| { global $db;
|
$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;
|
}
| }
|
/** * Generates a new login key for a user. *
| /** * Generates a new login key for a user. *
|
Zeile 234 | Zeile 339 |
---|
$db->update_query("users", $sql_array, "uid='{$uid}'");
return $loginkey;
|
$db->update_query("users", $sql_array, "uid='{$uid}'");
return $loginkey;
|
|
|
}
/**
| }
/**
|
Zeile 243 | Zeile 348 |
---|
* * @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)
|
* @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 add_subscribed_thread($tid, $notification=1, $uid=0) { global $mybb, $db;
|
* @return boolean True when success, false when otherwise. */ function add_subscribed_thread($tid, $notification=1, $uid=0) { global $mybb, $db;
|
if(!$uid) {
| if(!$uid) {
|
$uid = $mybb->user['uid']; }
if(!$uid)
|
$uid = $mybb->user['uid']; }
if(!$uid)
|
{
| {
|
return false; }
| return false; }
|
Zeile 268 | Zeile 373 |
---|
'uid' => (int)$uid, 'tid' => (int)$tid, 'notification' => (int)$notification,
|
'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 281 | Zeile 384 |
---|
"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.
|
}
/** * 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.
| * 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 $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. * @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 remove_subscribed_thread($tid, $uid=0) { global $mybb, $db;
|
function remove_subscribed_thread($tid, $uid=0) { global $mybb, $db;
|
if(!$uid)
| if(!$uid)
|
{ $uid = $mybb->user['uid'];
|
{ $uid = $mybb->user['uid'];
|
}
| }
|
if(!$uid) { return false;
| if(!$uid) { return false;
|
Zeile 320 | Zeile 423 |
---|
* @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 357 | Zeile 460 |
---|
* @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;
|
if(!$uid)
| if(!$uid)
|
{ $uid = $mybb->user['uid']; }
| { $uid = $mybb->user['uid']; }
|
Zeile 385 | Zeile 488 |
---|
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")."\";");
|