Zeile 44 | Zeile 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)
| * @return boolean|array False when no match, array with user info when match. */ function validate_password_from_username($username, $password)
|
Zeile 66 | Zeile 66 |
---|
* 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 101 | Zeile 101 |
---|
"loginkey" => $user['loginkey'] ); $db->update_query(TABLE_PREFIX."users", $sql_array, "uid = ".$user['uid'], 1);
|
"loginkey" => $user['loginkey'] ); $db->update_query(TABLE_PREFIX."users", $sql_array, "uid = ".$user['uid'], 1);
|
}
| }
|
if(salt_password(md5($password), $user['salt']) == $user['password'])
|
if(salt_password(md5($password), $user['salt']) == $user['password'])
|
{
| {
|
return $user;
|
return $user;
|
}
| }
|
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 148 | Zeile 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 172 | Zeile 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 186 | Zeile 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 203 | Zeile 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 235 | Zeile 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 263 | Zeile 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 293 | Zeile 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 308 | Zeile 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 321 | Zeile 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 356 | Zeile 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. * If no uid is supplied, the currently logged in user's id will be used.
| /** * Removes a forum from a user's forum subscription list. * If no uid is supplied, the currently logged in user's id will be used.
|
Zeile 370 | Zeile 370 |
---|
* @param int The fid of the forum 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.
|
* @param int The fid of the forum 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_subscribed_forum($fid, $uid="") { global $mybb, $db;
| function remove_subscribed_forum($fid, $uid="") { global $mybb, $db;
|
Zeile 384 | Zeile 384 |
---|
} $db->query("DELETE FROM ".TABLE_PREFIX."forumsubscriptions WHERE fid='".$fid."' AND uid='".$uid."'"); return true;
|
} $db->query("DELETE FROM ".TABLE_PREFIX."forumsubscriptions WHERE fid='".$fid."' AND uid='".$uid."'"); return true;
|
}
/**
| }
/**
|
* Constructs the usercp navigation menu. * */ function usercp_menu() { global $mybb, $templates, $theme, $plugins, $lang, $usercpnav, $usercpmenu;
|
* Constructs the usercp navigation menu. * */ function usercp_menu() { global $mybb, $templates, $theme, $plugins, $lang, $usercpnav, $usercpmenu;
|
$lang->load("usercpnav");
| $lang->load("usercpnav");
|
// Add the default items as plugins with separated priorities of 10 if($mybb->settings['enablepms'] != "no")
| // Add the default items as plugins with separated priorities of 10 if($mybb->settings['enablepms'] != "no")
|
Zeile 425 | Zeile 425 |
---|
$foldersexploded = explode("$%%$", $mybb->user['pmfolders']); foreach($foldersexploded as $key => $folders)
|
$foldersexploded = explode("$%%$", $mybb->user['pmfolders']); foreach($foldersexploded as $key => $folders)
|
{
| {
|
$folderinfo = explode("**", $folders, 2); $folderinfo[1] = get_pm_folder_name($folderinfo[0], $folderinfo[1]); $folderlinks .= "<li class=\"pmfolders\"><a href=\"private.php?fid=$folderinfo[0]\">$folderinfo[1]</a></li>\n"; } eval("\$usercpmenu .= \"".$templates->get("usercp_nav_messenger")."\";");
|
$folderinfo = explode("**", $folders, 2); $folderinfo[1] = get_pm_folder_name($folderinfo[0], $folderinfo[1]); $folderlinks .= "<li class=\"pmfolders\"><a href=\"private.php?fid=$folderinfo[0]\">$folderinfo[1]</a></li>\n"; } eval("\$usercpmenu .= \"".$templates->get("usercp_nav_messenger")."\";");
|
}
| }
|
/** * Constructs the usercp profile menu. * */ function usercp_menu_profile()
|
/** * Constructs the usercp profile menu. * */ function usercp_menu_profile()
|
{ global $db, $mybb, $templates, $theme, $usercpmenu, $lang;
| { global $db, $mybb, $templates, $theme, $usercpmenu, $lang;
|
if($mybb->usergroup['canchangename'] != "no") { eval("\$changenameop = \"".$templates->get("usercp_nav_changename")."\";"); } eval("\$usercpmenu .= \"".$templates->get("usercp_nav_profile")."\";");
|
if($mybb->usergroup['canchangename'] != "no") { eval("\$changenameop = \"".$templates->get("usercp_nav_changename")."\";"); } eval("\$usercpmenu .= \"".$templates->get("usercp_nav_profile")."\";");
|
}
/**
| }
/**
|
* Constructs the usercp misc menu. * */
| * Constructs the usercp misc menu. * */
|
Zeile 488 | Zeile 488 |
---|
if($user['usertitle']) { return $user['usertitle'];
|
if($user['usertitle']) { return $user['usertitle'];
|
}
| }
|
else { $query = $db->query("SELECT title FROM ".TABLE_PREFIX."usertitles WHERE posts<='".$user['postnum']."' ORDER BY posts DESC"); $usertitle = $db->fetch_array($query); return $usertitle['title'];
|
else { $query = $db->query("SELECT title FROM ".TABLE_PREFIX."usertitles WHERE posts<='".$user['postnum']."' ORDER BY posts DESC"); $usertitle = $db->fetch_array($query); 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 508 | Zeile 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 525 | Zeile 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 540 | Zeile 542 |
---|
} // 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>'".$lastvisit."' AND folder=1"); $new = $db->fetch_array($query); $pmcount['newpms'] = $new['pms_new'];
| $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'];
|
Zeile 554 | Zeile 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;
| |
}
/**
| }
/**
|