Files
Testing/include/analytics/whoison2.php
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

91 lines
2.2 KiB
PHP

<?php header('Content-type: application/json; charset=utf-8');
//copyright 2013 Philip Poremba
//no one other than Philip Poremba may use this code
ini_set('session.bug_compat_warn', 0);
ini_set('session.bug_compat_42', 0);
if ( !defined('PATHTOINCLUDES') ) define('PATHTOINCLUDES', $_SERVER["DOCUMENT_ROOT"] . '/include/analytics/');
include(PATHTOINCLUDES."base.php");
date_default_timezone_set('UTC');
$em="";
$sql="SELECT nickname, userphoto, userid, (UNIX_TIMESTAMP()-UNIX_TIMESTAMP(ison)) as alive, blocklist, user_age, user_region, user_so, user_cs, user_hair FROM heartbeat WHERE (UNIX_TIMESTAMP()-UNIX_TIMESTAMP(ison)) < 122960 AND pagename = 'Community Page' OR pagename='community'";
$result=$database->database_query($sql) or $em=$em.$database->database_error();
$thecount=$database->database_num_rows($result);
$online="";
$ustats="";
$bclass="img_border_green";
$theonline="";
while ($row = $database->database_fetch_assoc($result))
{
if($row["alive"] < 30){$bclass="img_border_green";}
elseif($row["alive"] <= 45){$bclass="img_border_yellow";}
elseif($row["alive"] > 45){$bclass="img_border_red";}
$blocklist = explode(",", $row["blocklist"]);
if(isset($_GET["uid"]))
{
if(!isset($_SESSION["cp_userid"]))
{
$_SESSION["cp_userid"]= $_GET["uid"];
}
}
$user_key = array_search($_SESSION["cp_userid"], $blocklist);
if($user_key===false){
$theonline=$theonline.'<a href="javascript:hl_profile2(\''.$row["userphoto"].'\',\''.$row["nickname"].'\',\''.$row["user_age"].'\',\''.$row["user_region"].'\',\''.$row["user_so"].'\',\''.$row["user_cs"].'\',\''.$row["user_hair"].'\',\''.$row["userid"].'\')"><img src="'.$row["userphoto"].'" width="22" height="23" alt="'.$row["nickname"].'" class="'.$bclass.' cp_pthumb" onmouseover="hl_profile(\''.$row["userphoto"].'\',\''.$row["nickname"].'\',\''.$row["user_age"].'\',\''.$row["user_region"].'\',\''.$row["user_so"].'\',\''.$row["user_cs"].'\',\''.$row["user_hair"].'\',\''.$row["userid"].'\')" onmouseout="hl_profile_out()" /></a>';
}
}
echo $theonline;
$theonline= utf8_encode($theonline);
$arr = array ('thecount'=> $thecount, 'onlines' => $theonline, 'woustats' => $ustats, 'theid' => $user_key);
echo json_encode($arr);
exit();
?>