Forums / Cotonti / Core Labs / Archive / Who was online add in Common.php

rayblo
#1 2009-04-05 19:33
Why is this not added in common.php below;

/* ======== Who's online (part 1) and shield protection ======== */
if (!$cfg['disablewhosonline'] || $cfg['shieldenabled'])
{
	if ($usr['id']>0)
	{
		$sql = sed_sql_query("SELECT * FROM $db_online WHERE online_userid=".$usr['id']);

		if ($row = sed_sql_fetcharray($sql))
		{
			$online_count = 1;
			if ($cfg['shieldenabled'])
			{
				$shield_limit = $row['online_shield'];
				$shield_action = $row['online_action'];
				$shield_hammer = sed_shield_hammer($row['online_hammer'],$shield_action,$row['online_lastseen']);
			}
			sed_sql_query("UPDATE $db_online SET online_lastseen='".$sys['now']."', online_location='".sed_sql_prep($location)."', online_subloc='".sed_sql_prep($sys['sublocation'])."', online_hammer=".(int)$shield_hammer." WHERE online_userid=".$usr['id']);
		}
		else
		{
			sed_sql_query("INSERT INTO $db_online (online_ip, online_name, online_lastseen, online_location, online_subloc, online_userid, online_shield, online_hammer) VALUES ('".$usr['ip']."', '".sed_sql_prep($usr['name'])."', ".(int)$sys['now'].", '".sed_sql_prep($location)."',  '".sed_sql_prep($sys['sublocation'])."', ".(int)$usr['id'].", 0, 0)");
		}
	}
	else
	{
		$sql = sed_sql_query("SELECT * FROM $db_online WHERE online_ip='".$usr['ip']."'");
		$online_count = sed_sql_numrows($sql);

		if ($online_count>0)
		{
			if ($cfg['shieldenabled'])
			{
				if ($row = sed_sql_fetcharray($sql))
				{
					$shield_limit = $row['online_shield'];
					$shield_action = $row['online_action'];
					$shield_hammer = sed_shield_hammer($row['online_hammer'],$shield_action,$row['online_lastseen']);
				}
			}
			sed_sql_query("UPDATE $db_online SET online_lastseen='".$sys['now']."', online_location='".$location."', online_subloc='".sed_sql_prep($sys['sublocation'])."', online_hammer=".(int)$shield_hammer." WHERE online_ip='".$usr['ip']."'");
		}
		else
		{
			sed_sql_query("INSERT INTO $db_online (online_ip, online_name, online_lastseen, online_location, online_subloc, online_userid, online_shield, online_hammer) VALUES ('".$usr['ip']."', 'v', ".(int)$sys['now'].", '".$location."', '".sed_sql_prep($sys['sublocation'])."', -1, 0, 0)");
		}
	}

	$sql = sed_sql_query("DELETE FROM $db_online WHERE online_lastseen<$online_timedout");
	$sql = sed_sql_query("SELECT COUNT(*) FROM $db_online WHERE online_name='v'");
	$sys['whosonline_vis_count'] = sed_sql_result($sql, 0, 'COUNT(*)');
	$sql = sed_sql_query("SELECT DISTINCT o.online_name, o.online_userid FROM $db_online o WHERE o.online_name != 'v' ORDER BY online_name ASC");
	$sys['whosonline_reg_count'] = sed_sql_numrows($sql);
	$sys['whosonline_all_count'] = $sys['whosonline_reg_count'] + $sys['whosonline_vis_count'];

	$ii=0;
	while ($row = sed_sql_fetcharray($sql))
	{
		$out['whosonline_reg_list'] .= ($ii>0) ? ', ' : '';
		$out['whosonline_reg_list'] .= sed_build_user($row['online_userid'], sed_cc($row['online_name']));
		$sed_usersonline[] = $row['online_userid'];
		$ii++;
	}
}

This is what i used in Seditio to show people that have visited the website the last 24 hours.

/* ======== Who was online ======== */
$timeback = $sys['now_offset'] - 86400;

$sql = sed_sql_query("SELECT * FROM $db_users WHERE user_lastlog>$timeback ORDER BY user_maingrp DESC");

$ii=0;

while ($row = sed_sql_fetcharray($sql))
                {
        $out['whowassonline_reg_list'] .= ($ii>0) ? ', ' : '';
        $out['whowassonline_reg_list'] .= ($row['user_id']>1) ? '<strong>' : '' ;
        $out['whowassonline_reg_list'] .= sed_build_user($row['user_id'], sed_cc(stripslashes($row['user_name'])));
        $out['whowassonline_reg_list'] .= ($row['user_id']>1) ? '</strong>' : '' ;
        $ii++;
        }


To use this add this into your file where needed;

{PHP.out.whosonline_reg_list}

The team players willing to add this ?[/]
[b]www.dutchcotonti.com[/b]<br />
De plaats voor nederlandse ondersteuning voor Cotonti.<br />
The place for support for Cotonti in Dutch
This post was edited by rayblo (2009-04-07 14:29, 15 years ago)
Trustmaster
#2 2009-06-27 05:04
Why not make it a plugin? It's not for every site and it adds a bit of extra load, so it would be best as a plugin.
May the Source be with you!
rayblo
#3 2009-06-27 05:59
Will think about it!
[b]www.dutchcotonti.com[/b]<br />
De plaats voor nederlandse ondersteuning voor Cotonti.<br />
The place for support for Cotonti in Dutch