本文整理汇总了PHP中updateMemberData函数的典型用法代码示例。如果您正苦于以下问题:PHP updateMemberData函数的具体用法?PHP updateMemberData怎么用?PHP updateMemberData使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了updateMemberData函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onUse
function onUse()
{
global $db_prefix, $context, $item_info;
updateMemberData($context['user']['id'], array('totalTimeLoggedIn' => 'totalTimeLoggedIn + ' . (int) $item_info[1]));
$time_hours = (int) $item_info[1] / 3600;
return 'Successfully added ' . $item_info[1] . ' seconds (' . $time_hours . ' hours) to total logged in time.';
}
示例2: onUse
function onUse()
{
global $db_prefix, $context, $item_info;
// If an amount was not defined by the admin, assume defaults
if (!isset($item_info[1]) || $item_info[1] == '') {
$item_info[1] = -190;
}
if (!isset($item_info[2]) || $item_info[2] == '') {
$item_info[2] = 190;
}
$amount = mt_rand($item_info[1], $item_info[2]);
// Did we lose money?
if ($amount < 0) {
$result = db_query("\n\t\t\t\tSELECT money\n\t\t\t\tFROM {$db_prefix}members\n\t\t\t\tWHERE ID_MEMBER = {$context[user][id]}", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
$amountLoss = abs($amount);
// If the user has enough money to pay for it out of his/her pocket
if ($row['money'] > $amountLoss) {
updateMemberData($context['user']['id'], array('money' => 'money - ' . $amountLoss));
return 'You lost ' . formatMoney($amountLoss) . '!';
} else {
updateMemberData($context['user']['id'], array('memberBank' => 'moneyBank - ' . $amountLoss));
return 'You lost ' . formatMoney($amountLoss) . '!<br /><br />You didn\'t have enough money in your pocket, so the money was taken from your bank! :(';
}
} else {
updateMemberData($context['user']['id'], array('money' => 'money + ' . $amount));
return 'You got ' . formatMoney($amount) . '!';
}
}
示例3: onUse
function onUse()
{
global $context, $smcFunc;
if (!isset($_POST['newtitle']) || $_POST['newtitle'] == '') {
die('ERROR: Please enter a new user title!');
}
$_POST['newtitle'] = $smcFunc['htmlspecialchars']($_POST['newtitle'], ENT_QUOTES);
updateMemberData($context['user']['id'], array('usertitle' => $_POST['newtitle']));
return 'Successfully changed your user title to ' . $_POST['newtitle'];
}
示例4: twit_integrate_login
function twit_integrate_login($user, $hashPasswd, $cookieTime)
{
global $user_settings;
if (isset($_GET['synctw'])) {
$twitter_profile = '' . $_SESSION['twit_name'] . '';
updateMemberData($user_settings['id_member'], array('twitname' => $_SESSION['twit_name'], 'twitid' => $_SESSION['twit_id'], 'twitrn' => $_SESSION['twit_sn']));
update_themes_twitter($user_settings['id_member'], 'twit_pro', $twitter_profile);
unset($_SESSION['twit_name']);
unset($_SESSION['twit_id']);
unset($_SESSION['twit_sn']);
} else {
return;
}
}
示例5: onUse
function onUse()
{
global $context, $item_info, $smcFunc;
// Use a length of 5 as default
if (!isset($item_info[1]) || $item_info[1] == 0) {
$item_info[1] = 5;
}
if (strlen($_POST['newDisplayName']) < $item_info[1]) {
die('ERROR: The name you chose was not long enough! Please go back and choose a name which is at least ' . $item_info[1] . ' characters long.');
}
$_POST['newDisplayName'] = $smcFunc['htmlspecialchars']($_POST['newDisplayName'], ENT_QUOTES);
updateMemberData($context['user']['id'], array('real_name' => $_POST['newDisplayName']));
return 'Successfully changed your display name to ' . $_POST['newDisplayName'];
}
示例6: gplus_integrate_login
function gplus_integrate_login($user, $hashPasswd, $cookieTime)
{
global $user_settings;
if (isset($_GET['syncgp'])) {
$gdata = $_SESSION['gplusdata'];
$_SESSION['gplus']['id'] = $gdata['id'];
$_SESSION['gplus']['name'] = $gdata['name'];
updateMemberData($user_settings['id_member'], array('gpid' => $_SESSION['gplus']['id'], 'gpname' => $_SESSION['gplus']['name']));
unset($_SESSION['gplus']['id']);
unset($_SESSION['gplus']['name']);
unset($_SESSION['gplusdata']);
} else {
return;
}
}
示例7: onUse
function onUse()
{
global $context, $func;
if (!isset($_POST['newusername']) || $_POST['newusername'] == '') {
die('ERROR: Please enter a new username!');
}
$_POST['newusername'] = $func['htmlspecialchars']($_POST['newusername'], ENT_QUOTES);
// Check if username is in use
$result = db_query("\n\t\tSELECT \n\t\t\tmemberName\n\t\tFROM {$db_prefix}members\n\t\tWHER memberName = '" . $_POST['newusername'] . "' LIMIT 1", __FILE__, __LINE__);
$memCount = mysql_num_rows($result);
if ($memCount > 0) {
die('ERROR: Username is already in use!');
}
updateMemberData($context['user']['id'], array('memberName' => '"' . $_POST['newusername'] . '"'));
return 'Successfully changed your username to ' . $_POST['newusername'];
}
示例8: createUserHandle
public function createUserHandle($email, $username, $password, $verified, $custom_register_fields, $profile, &$errors)
{
global $sourcedir, $context, $modSettings, $maintenance, $mmessage, $scripturl;
checkSession();
$_POST['emailActivate'] = true;
if (empty($password)) {
get_error('password cannot be empty');
}
if (!($maintenance == 0)) {
get_error('Forum is in maintenance model or Tapatalk is disabled by forum administrator.');
}
if ($modSettings['registration_method'] == 0) {
$register_mode = 'nothing';
} else {
if ($modSettings['registration_method'] == 1) {
$register_mode = $verified ? 'nothing' : 'activation';
} else {
$register_mode = isset($modSettings['auto_approval_tp_user']) && $modSettings['auto_approval_tp_user'] && $verified ? 'nothing' : 'approval';
}
}
$email = htmltrim__recursive(str_replace(array("\n", "\r"), '', $email));
$username = htmltrim__recursive(str_replace(array("\n", "\r"), '', $username));
$password = htmltrim__recursive(str_replace(array("\n", "\r"), '', $password));
$group = 0;
if ($register_mode == 'nothing' && isset($modSettings['tp_iar_usergroup_assignment'])) {
$group = $modSettings['tp_iar_usergroup_assignment'];
}
$regOptions = array('interface' => $register_mode == 'approval' ? 'guest' : 'admin', 'username' => $username, 'email' => $email, 'password' => $password, 'password_check' => $password, 'check_reserved_name' => true, 'check_password_strength' => true, 'check_email_ban' => false, 'send_welcome_email' => isset($_POST['emailPassword']) || empty($password), 'require' => $register_mode, 'memberGroup' => (int) $group);
define('mobi_register', 1);
require_once $sourcedir . '/Subs-Members.php';
$memberID = registerMember($regOptions);
if (!empty($memberID)) {
$context['new_member'] = array('id' => $memberID, 'name' => $username, 'href' => $scripturl . '?action=profile;u=' . $memberID, 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $memberID . '">' . $username . '</a>');
$context['registration_done'] = sprintf($txt['admin_register_done'], $context['new_member']['link']);
//update profile
if (isset($profile) && !empty($profile) && is_array($profile)) {
$profile_vars = array('avatar' => $profile['avatar_url']);
updateMemberData($memberID, $profile_vars);
}
return get_user_by_name_or_email($username, false);
}
return null;
}
示例9: countUserMentions
/**
* Count the mentions of the current user
* callback for createList in action_list of Mentions_Controller
*
* @package Mentions
* @param bool $all : if true counts all the mentions, otherwise only the unread
* @param string[]|string $type : the type of the mention can be a string or an array of strings.
* @param string|null $id_member : the id of the member the counts are for, defaults to user_info['id']
*/
function countUserMentions($all = false, $type = '', $id_member = null)
{
global $user_info;
static $counts;
$db = database();
$id_member = $id_member === null ? $user_info['id'] : (int) $id_member;
if (isset($counts[$id_member])) {
return $counts[$id_member];
}
$request = $db->query('', '
SELECT COUNT(*)
FROM {db_prefix}log_mentions as mtn
WHERE mtn.id_member = {int:current_user}
AND mtn.status IN ({array_int:status})' . (empty($type) ? '' : (is_array($type) ? '
AND mtn.mention_type IN ({array_string:current_type})' : '
AND mtn.mention_type = {string:current_type}')), array('current_user' => $id_member, 'current_type' => $type, 'status' => $all ? array(0, 1) : array(0)));
list($counts[$id_member]) = $db->fetch_row($request);
$db->free_result($request);
// Counts as maintenance! :P
if ($all === false && empty($type)) {
updateMemberData($id_member, array('mentions' => $counts[$id_member]));
}
return $counts[$id_member];
}
示例10: AdminBoardRecount
//.........这里部分代码省略.........
$request = $smcFunc['db_query']('', '
SELECT /*!40001 SQL_NO_CACHE */ t.id_board, COUNT(*) AS real_unapproved_topics
FROM {db_prefix}topics AS t
WHERE t.approved = {int:is_approved}
AND t.id_topic > {int:id_topic_min}
AND t.id_topic <= {int:id_topic_max}
GROUP BY t.id_board', array('is_approved' => 0, 'id_topic_min' => $_REQUEST['start'], 'id_topic_max' => $_REQUEST['start'] + $increment));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$smcFunc['db_query']('', '
UPDATE {db_prefix}boards
SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics}
WHERE id_board = {int:id_board}', array('id_board' => $row['id_board'], 'real_unapproved_topics' => $row['real_unapproved_topics']));
}
$smcFunc['db_free_result']($request);
$_REQUEST['start'] += $increment;
if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3) {
$context['continue_get_data'] = '?action=admin;area=maintain;sa=routine;activity=recount;step=4;start=' . $_REQUEST['start'] . ';' . $context['session_var'] . '=' . $context['session_id'];
$context['continue_percent'] = round((500 + 100 * $_REQUEST['start'] / $max_topics) / $total_steps);
return;
}
}
$_REQUEST['start'] = 0;
}
// Get all members with wrong number of personal messages.
if ($_REQUEST['step'] <= 5) {
$request = $smcFunc['db_query']('', '
SELECT /*!40001 SQL_NO_CACHE */ mem.id_member, COUNT(pmr.id_pm) AS real_num,
MAX(mem.instant_messages) AS instant_messages
FROM {db_prefix}members AS mem
LEFT JOIN {db_prefix}pm_recipients AS pmr ON (mem.id_member = pmr.id_member AND pmr.deleted = {int:is_not_deleted})
GROUP BY mem.id_member
HAVING COUNT(pmr.id_pm) != MAX(mem.instant_messages)', array('is_not_deleted' => 0));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
updateMemberData($row['id_member'], array('instant_messages' => $row['real_num']));
}
$smcFunc['db_free_result']($request);
$request = $smcFunc['db_query']('', '
SELECT /*!40001 SQL_NO_CACHE */ mem.id_member, COUNT(pmr.id_pm) AS real_num,
MAX(mem.unread_messages) AS unread_messages
FROM {db_prefix}members AS mem
LEFT JOIN {db_prefix}pm_recipients AS pmr ON (mem.id_member = pmr.id_member AND pmr.deleted = {int:is_not_deleted} AND pmr.is_read = {int:is_not_read})
GROUP BY mem.id_member
HAVING COUNT(pmr.id_pm) != MAX(mem.unread_messages)', array('is_not_deleted' => 0, 'is_not_read' => 0));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
updateMemberData($row['id_member'], array('unread_messages' => $row['real_num']));
}
$smcFunc['db_free_result']($request);
if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3) {
$context['continue_get_data'] = '?action=admin;area=maintain;sa=routine;activity=recount;step=6;start=0;' . $context['session_var'] . '=' . $context['session_id'];
$context['continue_percent'] = round(700 / $total_steps);
return;
}
}
// Any messages pointing to the wrong board?
if ($_REQUEST['step'] <= 6) {
while ($_REQUEST['start'] < $modSettings['maxMsgID']) {
$request = $smcFunc['db_query']('', '
SELECT /*!40001 SQL_NO_CACHE */ t.id_board, m.id_msg
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic AND t.id_board != m.id_board)
WHERE m.id_msg > {int:id_msg_min}
AND m.id_msg <= {int:id_msg_max}', array('id_msg_min' => $_REQUEST['start'], 'id_msg_max' => $_REQUEST['start'] + $increment));
$boards = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$boards[$row['id_board']][] = $row['id_msg'];
}
示例11: QuickModeration
//.........这里部分代码省略.........
WHERE id_board IN ({array_int:move_boards})', array('move_boards' => array_keys($moveTos)));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$cp = empty($row['count_posts']);
// Go through all the topics that are being moved to this board.
foreach ($moveTos[$row['id_board']] as $topic) {
// If both boards have the same value for post counting then no adjustment needs to be made.
if ($countPosts[$topic] != $cp) {
// If the board being moved to does count the posts then the other one doesn't so add to their post count.
$topicRecounts[$topic] = $cp ? '+' : '-';
}
}
}
$smcFunc['db_free_result']($request);
if (!empty($topicRecounts)) {
$members = array();
// Get all the members who have posted in the moved topics.
$request = $smcFunc['db_query']('', '
SELECT id_member, id_topic
FROM {db_prefix}messages
WHERE id_topic IN ({array_int:moved_topic_ids})', array('moved_topic_ids' => array_keys($topicRecounts)));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
if (!isset($members[$row['id_member']])) {
$members[$row['id_member']] = 0;
}
if ($topicRecounts[$row['id_topic']] === '+') {
$members[$row['id_member']] += 1;
} else {
$members[$row['id_member']] -= 1;
}
}
$smcFunc['db_free_result']($request);
// And now update them member's post counts
foreach ($members as $id_member => $post_adj) {
updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
}
}
}
}
// Now delete the topics...
if (!empty($removeCache)) {
// They can only delete their own topics. (we wouldn't be here if they couldn't do that..)
$result = $smcFunc['db_query']('', '
SELECT id_topic, id_board
FROM {db_prefix}topics
WHERE id_topic IN ({array_int:removed_topic_ids})' . (!empty($board) && !allowedTo('remove_any') ? '
AND id_member_started = {int:current_member}' : '') . '
LIMIT ' . count($removeCache), array('current_member' => $user_info['id'], 'removed_topic_ids' => $removeCache));
$removeCache = array();
$removeCacheBoards = array();
while ($row = $smcFunc['db_fetch_assoc']($result)) {
$removeCache[] = $row['id_topic'];
$removeCacheBoards[$row['id_topic']] = $row['id_board'];
}
$smcFunc['db_free_result']($result);
// Maybe *none* were their own topics.
if (!empty($removeCache)) {
// Gotta send the notifications *first*!
foreach ($removeCache as $topic) {
// Only log the topic ID if it's not in the recycle board.
logAction('remove', array(empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $removeCacheBoards[$topic] ? 'topic' : 'old_topic_id' => $topic, 'board' => $removeCacheBoards[$topic]));
sendNotifications($topic, 'remove');
}
require_once $sourcedir . '/RemoveTopic.php';
removeTopics($removeCache);
}
}
示例12: EditMembergroup
//.........这里部分代码省略.........
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$smcFunc['db_query']('', '
UPDATE {db_prefix}boards
SET {raw:column} = {string:member_group_access}
WHERE id_board = {int:current_board}', array('current_board' => $row['id_board'], 'member_group_access' => implode(',', array_diff(explode(',', $row['member_groups']), array($_REQUEST['group']))), 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups'));
}
$smcFunc['db_free_result']($request);
// Add the membergroup to all boards that hadn't been set yet.
if (!empty($changed_boards[$board_action])) {
$smcFunc['db_query']('', '
UPDATE {db_prefix}boards
SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END
WHERE id_board IN ({array_int:board_list})
AND FIND_IN_SET({int:current_group}, {raw:column}) = 0', array('board_list' => $changed_boards[$board_action], 'blank_string' => '', 'current_group' => (int) $_REQUEST['group'], 'group_id_string' => (string) (int) $_REQUEST['group'], 'comma_group' => ',' . $_REQUEST['group'], 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups'));
}
}
}
// Remove everyone from this group!
if ($_POST['min_posts'] != -1) {
$smcFunc['db_query']('', '
UPDATE {db_prefix}members
SET id_group = {int:regular_member}
WHERE id_group = {int:current_group}', array('regular_member' => 0, 'current_group' => (int) $_REQUEST['group']));
$request = $smcFunc['db_query']('', '
SELECT id_member, additional_groups
FROM {db_prefix}members
WHERE FIND_IN_SET({string:current_group}, additional_groups) != 0', array('current_group' => (int) $_REQUEST['group']));
$updates = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$updates[$row['additional_groups']][] = $row['id_member'];
}
$smcFunc['db_free_result']($request);
foreach ($updates as $additional_groups => $memberArray) {
updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group'])))));
}
} elseif ($_REQUEST['group'] != 3) {
// Making it a hidden group? If so remove everyone with it as primary group (Actually, just make them additional).
if ($_POST['group_hidden'] == 2) {
$request = $smcFunc['db_query']('', '
SELECT id_member, additional_groups
FROM {db_prefix}members
WHERE id_group = {int:current_group}
AND FIND_IN_SET({int:current_group}, additional_groups) = 0', array('current_group' => (int) $_REQUEST['group']));
$updates = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$updates[$row['additional_groups']][] = $row['id_member'];
}
$smcFunc['db_free_result']($request);
foreach ($updates as $additional_groups => $memberArray) {
updateMemberData($memberArray, array('additional_groups' => implode(',', array_merge(explode(',', $additional_groups), array((int) $_REQUEST['group'])))));
}
$smcFunc['db_query']('', '
UPDATE {db_prefix}members
SET id_group = {int:regular_member}
WHERE id_group = {int:current_group}', array('regular_member' => 0, 'current_group' => $_REQUEST['group']));
}
// Either way, let's check our "show group membership" setting is correct.
$request = $smcFunc['db_query']('', '
SELECT COUNT(*)
FROM {db_prefix}membergroups
WHERE group_type > {int:non_joinable}', array('non_joinable' => 1));
list($have_joinable) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
// Do we need to update the setting?
if (empty($modSettings['show_group_membership']) && $have_joinable || !empty($modSettings['show_group_membership']) && !$have_joinable) {
updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0));
示例13: writeLog
function writeLog($force = false)
{
global $user_info, $user_settings, $context, $modSettings, $settings, $topic, $board, $smcFunc, $sourcedir;
// If we are showing who is viewing a topic, let's see if we are, and force an update if so - to make it accurate.
if (!empty($settings['display_who_viewing']) && ($topic || $board)) {
// Take the opposite approach!
$force = true;
// Don't update for every page - this isn't wholly accurate but who cares.
if ($topic) {
if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) {
$force = false;
}
$_SESSION['last_topic_id'] = $topic;
}
}
// Are they a spider we should be tracking? Mode = 1 gets tracked on its spider check...
if (!empty($user_info['possibly_robot']) && !empty($modSettings['spider_mode']) && $modSettings['spider_mode'] > 1) {
require_once $sourcedir . '/ManageSearchEngines.php';
logSpider();
}
// Don't mark them as online more than every so often.
if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= time() - 8 && !$force) {
return;
}
if (!empty($modSettings['who_enabled'])) {
$serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
// In the case of a dlattach action, session_var may not be set.
if (!isset($context['session_var'])) {
$context['session_var'] = $_SESSION['session_var'];
}
unset($serialized['sesc'], $serialized[$context['session_var']]);
$serialized = serialize($serialized);
} else {
$serialized = '';
}
// Guests use 0, members use their session ID.
$session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id();
// Grab the last all-of-SMF-specific log_online deletion time.
$do_delete = cache_get_data('log_online-update', 30) < time() - 30;
// If the last click wasn't a long time ago, and there was a last click...
if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= time() - $modSettings['lastActive'] * 20) {
if ($do_delete) {
$smcFunc['db_query']('delete_log_online_interval', '
DELETE FROM {db_prefix}log_online
WHERE log_time < {int:log_time}
AND session != {string:session}', array('log_time' => time() - $modSettings['lastActive'] * 60, 'session' => $session_id));
// Cache when we did it last.
cache_put_data('log_online-update', time(), 30);
}
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_online
SET log_time = {int:log_time}, ip = IFNULL(INET_ATON({string:ip}), 0), url = {string:url}
WHERE session = {string:session}', array('log_time' => time(), 'ip' => $user_info['ip'], 'url' => $serialized, 'session' => $session_id));
// Guess it got deleted.
if ($smcFunc['db_affected_rows']() == 0) {
$_SESSION['log_time'] = 0;
}
} else {
$_SESSION['log_time'] = 0;
}
// Otherwise, we have to delete and insert.
if (empty($_SESSION['log_time'])) {
if ($do_delete || !empty($user_info['id'])) {
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}log_online
WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), array('current_member' => $user_info['id'], 'log_time' => time() - $modSettings['lastActive'] * 60));
}
$smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', '{db_prefix}log_online', array('session' => 'string', 'id_member' => 'int', 'id_spider' => 'int', 'log_time' => 'int', 'ip' => 'raw', 'url' => 'string'), array($session_id, $user_info['id'], empty($_SESSION['id_robot']) ? 0 : $_SESSION['id_robot'], time(), 'IFNULL(INET_ATON(\'' . $user_info['ip'] . '\'), 0)', $serialized), array('session'));
}
// Mark your session as being logged.
$_SESSION['log_time'] = time();
// Well, they are online now.
if (empty($_SESSION['timeOnlineUpdated'])) {
$_SESSION['timeOnlineUpdated'] = time();
}
// Set their login time, if not already done within the last minute.
if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60) {
// Don't count longer than 15 minutes.
if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) {
$_SESSION['timeOnlineUpdated'] = time();
}
$user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in']));
if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
}
$user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
$_SESSION['timeOnlineUpdated'] = time();
}
}
示例14: updateBanMembers
function updateBanMembers()
{
global $smcFunc;
$updates = array();
$allMembers = array();
$newMembers = array();
// Start by getting all active bans - it's quicker doing this in parts...
$request = $smcFunc['db_query']('', '
SELECT bi.id_member, bi.email_address
FROM {db_prefix}ban_items AS bi
INNER JOIN {db_prefix}ban_groups AS bg ON (bg.id_ban_group = bi.id_ban_group)
WHERE (bi.id_member > {int:no_member} OR bi.email_address != {string:blank_string})
AND bg.cannot_access = {int:cannot_access_on}
AND (bg.expire_time IS NULL OR bg.expire_time > {int:current_time})', array('no_member' => 0, 'cannot_access_on' => 1, 'current_time' => time(), 'blank_string' => ''));
$memberIDs = array();
$memberEmails = array();
$memberEmailWild = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
if ($row['id_member']) {
$memberIDs[$row['id_member']] = $row['id_member'];
}
if ($row['email_address']) {
// Does it have a wildcard - if so we can't do a IN on it.
if (strpos($row['email_address'], '%') !== false) {
$memberEmailWild[$row['email_address']] = $row['email_address'];
} else {
$memberEmails[$row['email_address']] = $row['email_address'];
}
}
}
$smcFunc['db_free_result']($request);
// Build up the query.
$queryPart = array();
$queryValues = array();
if (!empty($memberIDs)) {
$queryPart[] = 'mem.id_member IN ({array_string:member_ids})';
$queryValues['member_ids'] = $memberIDs;
}
if (!empty($memberEmails)) {
$queryPart[] = 'mem.email_address IN ({array_string:member_emails})';
$queryValues['member_emails'] = $memberEmails;
}
$count = 0;
foreach ($memberEmailWild as $email) {
$queryPart[] = 'mem.email_address LIKE {string:wild_' . $count . '}';
$queryValues['wild_' . $count++] = $email;
}
// Find all banned members.
if (!empty($queryPart)) {
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.is_activated
FROM {db_prefix}members AS mem
WHERE ' . implode(' OR ', $queryPart), $queryValues);
while ($row = $smcFunc['db_fetch_assoc']($request)) {
if (!in_array($row['id_member'], $allMembers)) {
$allMembers[] = $row['id_member'];
// Do they need an update?
if ($row['is_activated'] < 10) {
$updates[$row['is_activated'] + 10][] = $row['id_member'];
$newMembers[] = $row['id_member'];
}
}
}
$smcFunc['db_free_result']($request);
}
// We welcome our new members in the realm of the banned.
if (!empty($newMembers)) {
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}log_online
WHERE id_member IN ({array_int:new_banned_members})', array('new_banned_members' => $newMembers));
}
// Find members that are wrongfully marked as banned.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.is_activated - 10 AS new_value
FROM {db_prefix}members AS mem
LEFT JOIN {db_prefix}ban_items AS bi ON (bi.id_member = mem.id_member OR mem.email_address LIKE bi.email_address)
LEFT JOIN {db_prefix}ban_groups AS bg ON (bg.id_ban_group = bi.id_ban_group AND bg.cannot_access = {int:cannot_access_activated} AND (bg.expire_time IS NULL OR bg.expire_time > {int:current_time}))
WHERE (bi.id_ban IS NULL OR bg.id_ban_group IS NULL)
AND mem.is_activated >= {int:ban_flag}', array('cannot_access_activated' => 1, 'current_time' => time(), 'ban_flag' => 10));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
// Don't do this twice!
if (!in_array($row['id_member'], $allMembers)) {
$updates[$row['new_value']][] = $row['id_member'];
$allMembers[] = $row['id_member'];
}
}
$smcFunc['db_free_result']($request);
if (!empty($updates)) {
foreach ($updates as $newStatus => $members) {
updateMemberData($members, array('is_activated' => $newStatus));
}
}
// Update the latest member and our total members as banning may change them.
updateStats('member');
}
示例15: action_deleteaccount2
/**
* Actually delete an account.
*/
public function action_deleteaccount2()
{
global $user_info, $context, $cur_profile, $user_profile, $modSettings;
// Try get more time...
@set_time_limit(600);
// @todo Add a way to delete pms as well?
if (!$context['user']['is_owner']) {
isAllowedTo('profile_remove_any');
} elseif (!allowedTo('profile_remove_any')) {
isAllowedTo('profile_remove_own');
}
checkSession();
$memID = currentMemberID();
// Check we got here as we should have!
if ($cur_profile != $user_profile[$memID]) {
fatal_lang_error('no_access', false);
}
$old_profile =& $cur_profile;
// This file is needed for our utility functions.
require_once SUBSDIR . '/Members.subs.php';
// Too often, people remove/delete their own only administrative account.
if (in_array(1, explode(',', $old_profile['additional_groups'])) || $old_profile['id_group'] == 1) {
// Are you allowed to administrate the forum, as they are?
isAllowedTo('admin_forum');
$another = isAnotherAdmin($memID);
if (empty($another)) {
fatal_lang_error('at_least_one_admin', 'critical');
}
}
// Do you have permission to delete others profiles, or is that your profile you wanna delete?
if ($memID != $user_info['id']) {
isAllowedTo('profile_remove_any');
// Now, have you been naughty and need your posts deleting?
// @todo Should this check board permissions?
if ($_POST['remove_type'] != 'none' && allowedTo('moderate_forum')) {
// Include subs/Topic.subs.php - essential for this type of work!
require_once SUBSDIR . '/Topic.subs.php';
require_once SUBSDIR . '/Messages.subs.php';
// First off we delete any topics the member has started - if they wanted topics being done.
if ($_POST['remove_type'] == 'topics') {
// Fetch all topics started by this user.
$topicIDs = topicsStartedBy($memID);
// Actually remove the topics.
// @todo This needs to check permissions, but we'll let it slide for now because of moderate_forum already being had.
removeTopics($topicIDs);
}
// Now delete the remaining messages.
removeNonTopicMessages($memID);
}
// Only delete this poor member's account if they are actually being booted out of camp.
if (isset($_POST['deleteAccount'])) {
deleteMembers($memID);
}
} elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) {
// Setup their account for deletion ;)
updateMemberData($memID, array('is_activated' => 4));
// Another account needs approval...
updateSettings(array('unapprovedMembers' => true), true);
} else {
deleteMembers($memID);
require_once CONTROLLERDIR . '/Auth.controller.php';
$controller = new Auth_Controller();
$controller->action_logout(true);
redirectexit();
}
}