if (in_array("USERS_ONLINE", $arParams["SHOW"])) { $UserHideOnLine = 0; $Guest = 0; $arFields = array(); if ($arParams["FID"] && !$arParams["TID"]) { $arFields["FORUM_ID"] = $arParams["FID"]; } elseif ($arParams["TID"]) { $arFields["TOPIC_ID"] = $arParams["TID"]; } else { $arFields["SITE_ID"] = SITE_ID; } $arFields += array("ACTIVE" => "Y", "<=PERIOD" => $arParams["PERIOD"], "COUNT_GUEST" => true); $cache_id = "forum_user_online_" . serialize(array($arFields, $arParams["URL_TEMPLATES_PROFILE_VIEW"])); $cache_path = $cache_path_main . "user_online/"; $arUser = array("USERS" => array(), "USERS_HIDDEN" => array(), "GUEST" => 0, "REGISTER" => 0, "ALL" => 0); $db_res = CForumStat::GetListEx(array("USER_ID" => "DESC"), $arFields, array("sNameTemplate" => $arParams["NAME_TEMPLATE"])); if ($db_res && ($res = $db_res->GetNext())) { do { if ($res["USER_ID"] > 0) { $res["SHOW_NAME"] = $parser->wrap_long_words($res["SHOW_NAME"]); $res["profile_view"] = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_PROFILE_VIEW"], array("UID" => $res["USER_ID"])); if ($res["HIDE_FROM_ONLINE"] != "Y") { $arUser["USERS"][] = $res; } else { $arUser["USERS_HIDDEN"][] = $res; } } else { $Guest = intVal($res["COUNT_USER"]); } } while ($res = $db_res->GetNext()); $arUser["GUEST"] = $Guest;
function ShowActiveUser($arFields = array()) { $period = intVal($arFields["PERIOD"]); if ($period <= 0) { $period = 600; } $date = Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL", SITE_ID)), time() - $period + CTimeZone::GetOffset()); $arField = array(">=LAST_VISIT" => $date, "COUNT_GUEST" => true); if (intVal($arFields["FORUM_ID"]) > 0) { $arField["FORUM_ID"] = $arFields["FORUM_ID"]; } if (intVal($arFields["TOPIC_ID"]) > 0) { $arField["TOPIC_ID"] = $arFields["TOPIC_ID"]; } $db_res = CForumStat::GetListEx(array("USER_ID" => "DESC"), $arField); $OnLineUser = array(); $arOnLineUser = array(); $OnLineUserStr = ""; $UserHideOnLine = 0; $UserOnLine = 0; $result = array(); $result["NONE"] = "N"; if ($db_res && ($res = $db_res->GetNext())) { $OnLineUser["USER"] = array(); do { if ($res["USER_ID"] > 0 && $res["HIDE_FROM_ONLINE"] != "Y") { $OnLineUser["USER"][] = "<a href=\"view_profile.php?UID=" . $res["USER_ID"] . "\" title='" . GetMessage("FORUM_USER_PROFILE") . "'>" . $res["SHOW_NAME"] . "</a>"; $arOnLineUser[] = array_merge($res, array("UID" => $res["USER_ID"], "title" => GetMessage("FORUM_USER_PROFILE"), "text" => $res["SHOW_NAME"])); } elseif ($res["USER_ID"] > 0 && $res["HIDE_FROM_ONLINE"] == "Y") { $UserHideOnLine++; } else { $OnLineUser["GUEST"] = intVal($res["COUNT_USER"]); } } while ($res = $db_res->GetNext()); $CountAllUsers = count($OnLineUser["USER"]) + $UserHideOnLine + $OnLineUser["GUEST"]; $result["GUEST"] = $OnLineUser["GUEST"]; $result["HIDE"] = $UserHideOnLine; $result["REGISTER"] = IntVal(count($OnLineUser["USER"]) + $UserHideOnLine); $result["ALL"] = $CountAllUsers; if ($CountAllUsers > 0) { if (intVal($arFields["TOPIC_ID"]) <= 0) { $result["PERIOD"] = round($period / 60); $result["HEAD"] = str_replace("##", "<b>" . round($period / 60) . "</b>", GetMessage("FORUM_AT_LAST_PERIOD")) . " " . GetMessage("FORUM_COUNT_ALL_USER") . ": <b>" . $CountAllUsers . "</b><br/>"; } $OnLineUserStr = GetMessage("FORUM_COUNT_GUEST") . ": <b>" . intVal($OnLineUser["GUEST"]) . "</b>, " . GetMessage("FORUM_COUNT_USER") . ": <b>" . IntVal(count($OnLineUser["USER"]) + $UserHideOnLine) . "</b>,\n\t\t\t\t" . GetMessage("FORUM_FROM_THIS") . " " . GetMessage("FORUM_COUNT_USER_HIDEFROMONLINE") . ": <b>" . $UserHideOnLine . "</b>"; if (count($OnLineUser["USER"]) > 0) { $OnLineUserStr .= "<br/>" . implode(", ", $OnLineUser["USER"]) . "<br/>"; $result["USER"] = $arOnLineUser; } } else { $OnLineUserStr = GetMessage("FORUM_NONE"); $result["NONE"] = "Y"; } } else { $OnLineUserStr = GetMessage("FORUM_NONE"); $result["NONE"] = "Y"; } $result["BODY"] = $OnLineUserStr; return $result; }