} if (isset($_POST['edit_users']) && is_array($_POST['edit_users'])) { list($gid) = array_keys($_POST['edit_users']); $redirect_uri = "admin_user_groups_edit_users.php?webtag={$webtag}&gid={$gid}"; $redirect_uri .= "&ret=admin_user.php%3Fwebtag%3D{$webtag}%26uid={$uid}%26ret%3D"; $redirect_uri .= rawurlencode($ret); header_redirect($redirect_uri); } // Array to hold error messages $error_msg_array = array(); // Get the user details. if (!($user = admin_user_get($uid))) { html_draw_error(gettext("Unknown user account"), 'admin_users.php', 'get', array('back' => gettext("Back"))); } // Get the user's post count. $user['POST_COUNT'] = user_get_post_count($uid); // Get the user's permissions. $user_perms = perm_get_forum_user_permissions($uid); // Page title $page_title = gettext("Admin") . " - " . gettext("Manage User") . " - " . format_user_name($user['LOGON'], $user['NICKNAME']); // Do updates if (isset($_POST['action_submit'])) { if (isset($_POST['action']) && strlen(trim($_POST['action'])) > 0) { $post_action = trim($_POST['action']); if ($post_action == 'edit_details') { header_redirect("edit_prefs.php?webtag={$webtag}&profileuid={$uid}"); exit; } else { if ($post_action == 'edit_signature') { header_redirect("edit_signature.php?webtag={$webtag}&siguid={$uid}"); exit;
echo " <td align=\"left\" class=\"posthead\">\n"; echo " <table class=\"posthead\" width=\"100%\">\n"; echo " <tr>\n"; echo " <td align=\"left\" class=\"subhead\" width=\"20\"> </td>\n"; echo " <td align=\"left\" class=\"subhead\" width=\"200\">", gettext("User"), "</td>\n"; echo " <td align=\"center\" class=\"subhead\" width=\"120\">", gettext("Total posts"), "</td>\n"; echo " <td align=\"center\" class=\"subhead\" width=\"120\">", gettext("Posts"), "</td>\n"; echo " <td align=\"center\" class=\"subhead\" width=\"120\">", gettext("Percent"), "</td>\n"; echo " <td align=\"center\" class=\"subhead\" width=\"120\">", gettext("Average"), "</td>\n"; echo " </tr>\n"; if (sizeof($user_stats_array['user_stats']) > 0) { foreach ($user_stats_array['user_stats'] as $user_stats) { echo " <tr>\n"; echo " <td align=\"left\"> </td>\n"; echo " <td align=\"left\">", word_filter_add_ob_tags(format_user_name($user_stats['LOGON'], $user_stats['NICKNAME']), true), "</td>\n"; echo " <td align=\"center\">", user_get_post_count($user_stats['UID']), "</td>\n"; echo " <td align=\"center\">{$user_stats['POST_COUNT']}</td>\n"; echo " <td align=\"center\">", number_format(round(100 / $user_stats_array['post_count'] * $user_stats['POST_COUNT'], 2), 2, '.', ','), "%</td>\n"; echo " <td align=\"center\">", number_format(round($user_stats['POST_COUNT'] / $num_days, 2), 2, '.', ','), "</td>\n"; echo " </tr>\n"; } echo " <tr>\n"; echo " <td align=\"left\" colspan=\"6\"> </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td colspan=\"6\" align=\"center\">", gettext("Total posts for this period"), ": {$user_stats_array['post_count']}</td>\n"; echo " </tr>\n"; } else { echo " <tr>\n"; echo " <td align=\"left\" colspan=\"6\"> </td>\n"; echo " </tr>\n";
function user_get_post_count($uid) { if (!is_numeric($uid)) { return false; } if (!($table_prefix = get_table_prefix())) { return false; } if (!($db = db::get())) { return false; } $sql = "SELECT POST_COUNT FROM `{$table_prefix}USER_TRACK` "; $sql .= "WHERE UID = '{$uid}' AND POST_COUNT IS NOT NULL"; if (!($result = $db->query($sql))) { return false; } if ($result->num_rows > 0) { list($post_count) = $result->fetch_row(); return $post_count; } $sql = "INSERT IGNORE INTO `{$table_prefix}USER_TRACK` (UID, POST_COUNT) "; $sql .= "SELECT '{$uid}', COUNT(POST.PID) AS POST_COUNT FROM `{$table_prefix}POST` POST "; $sql .= "WHERE FROM_UID = '{$uid}' ON DUPLICATE KEY UPDATE POST_COUNT = VALUES(POST_COUNT)"; if (!($result = $db->query($sql))) { return false; } return user_get_post_count($uid); }