Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

Announcement

FluxBB 1.5.6 and 1.4.12 released

These releases fix a security issue - please update your forums! Download links: v1.5.6 | v1.4.12

#1 2013-12-24 19:50:21

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 228
Website

View users on current page

In viewtopic.php (or any page for that matter) is there a way to echo the current users on that page (and guests)?

Offline

#2 2013-12-25 08:39:41

Visman
Member
From: Siberia
Registered: 2010-07-10
Posts: 827
Website

Re: View users on current page

In my version FluxBB https://fluxbb.org/forums/viewtopic.php?id=4941 for viewtopic.php


My modification of FluxBB 1.5.6 - rev.64
I speak only Russian  tongue

Offline

#3 2013-12-25 17:40:56

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 228
Website

Re: View users on current page

Thanks for the link, your mod is very good indeed. However, since there are a lot of mods in the files (and I'm not that good at the best of times), could you point out any specific areas of files where the code for it is for  it for me?

Offline

#4 2013-12-26 00:34:52

Visman
Member
From: Siberia
Registered: 2010-07-10
Posts: 827
Website

Re: View users on current page

Precisely on a code I won't tell, I wrote it long ago.
It is necessary to look for according to comments:

// Кто в этой теме - Visman

My modification of FluxBB 1.5.6 - rev.64
I speak only Russian  tongue

Offline

#5 2013-12-29 16:56:10

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 228
Website

Re: View users on current page

Is there anything in the Database that needs changing? I have found this from your code, but it isn't showing anything.

// *****************************************************************************
// Кто в этой теме - Visman
if (defined('WITT_ENABLE'))
{
	$now = time();
	$remote_addr = get_remote_address();

	// подготовка массива посещений
	if (empty($pun_user['witt_data']))
	{
		$witt_ar = array();
		$witt_ar[$id] = $now;
		$pun_user['witt_data'] = serialize($witt_ar);
	}
	else
	{
		$witt_ar = unserialize($pun_user['witt_data']);
		$witt_ar[$id] = $now;
		arsort($witt_ar);
		$witt_du = array();
		$i = 0;
		foreach ($witt_ar as $key => $value)
		{
			if ($i > 8 || $value < $now - WITT_ENABLE) break;
			$witt_du[$key] = $value;
			$i++;
		}
		$pun_user['witt_data'] = serialize($witt_du);
	}

	// оставим о себе данные в online
	if ($pun_user['is_guest'])
	{
		// Update online list
		if (!$pun_user['logged'])
		{
			$pun_user['logged'] = time();

			// With MySQL/MySQLi/SQLite, REPLACE INTO avoids a user having two rows in the online table
			switch ($db_type)
			{
				case 'mysql':
				case 'mysqli':
				case 'mysql_innodb':
				case 'mysqli_innodb':
				case 'sqlite':
					$db->query('REPLACE INTO '.$db->prefix.'online (user_id, ident, logged, witt_data) VALUES(1, \''.$db->escape($pun_user['ident']).'\', '.$pun_user['logged'].', \''.$db->escape($pun_user['witt_data']).'\')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
					break;

				default:
					$db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged, witt_data) SELECT 1, \''.$db->escape($pun_user['ident']).'\', '.$pun_user['logged'].', \''.$db->escape($pun_user['witt_data']).'\' WHERE NOT EXISTS (SELECT 1 FROM '.$db->prefix.'online WHERE ident=\''.$db->escape($pun_user['ident']).'\')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
					break;
			}
		}
		else
			$db->query('UPDATE '.$db->prefix.'online SET logged='.$now.', witt_data=\''.$db->escape($pun_user['witt_data']).'\' WHERE ident=\''.$db->escape($pun_user['ident']).'\'') or error('Unable to update online list', __FILE__, __LINE__, $db->error());
	}
	else
	{
		// Define this if you want this visit to affect the online list and the users last visit data
		if (!defined('PUN_QUIET_VISIT'))
		{
			// Update the online list
			if (!$pun_user['logged'])
			{
				$pun_user['logged'] = $now;

				// With MySQL/MySQLi/SQLite, REPLACE INTO avoids a user having two rows in the online table
				switch ($db_type)
				{
					case 'mysql':
					case 'mysqli':
					case 'mysql_innodb':
					case 'mysqli_innodb':
					case 'sqlite':
						$db->query('REPLACE INTO '.$db->prefix.'online (user_id, ident, logged, witt_data) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$pun_user['logged'].', \''.$db->escape($pun_user['witt_data']).'\')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
						break;

					default:
						$db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged, witt_data) SELECT '.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$pun_user['logged'].', \''.$db->escape($pun_user['witt_data']).'\' WHERE NOT EXISTS (SELECT 1 FROM '.$db->prefix.'online WHERE user_id='.$pun_user['id'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
						break;
				}

				// Reset tracked topics
				set_tracked_topics(null);
			}
			else
			{
				// Special case: We've timed out, but no other user has browsed the forums since we timed out
				if ($pun_user['logged'] < ($now-$pun_config['o_timeout_visit']))
				{
					$db->query('UPDATE '.$db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id']) or error('Unable to update user visit data', __FILE__, __LINE__, $db->error());
					$pun_user['last_visit'] = $pun_user['logged'];
				}

				$idle_sql = ($pun_user['idle'] == '1') ? ', idle=0' : '';
				$db->query('UPDATE '.$db->prefix.'online SET logged='.$now.$idle_sql.', witt_data=\''.$db->escape($pun_user['witt_data']).'\' WHERE user_id='.$pun_user['id']) or error('Unable to update online list', __FILE__, __LINE__, $db->error());

				// Update tracked topics with the current expire time
				if (isset($_COOKIE[$cookie_name.'_track']))
					forum_setcookie($cookie_name.'_track', $_COOKIE[$cookie_name.'_track'], $now + $pun_config['o_timeout_visit']);
			}
		}
		else
		{
			if (!$pun_user['logged'])
				$pun_user['logged'] = $pun_user['last_visit'];
		}
	}

	// смотрим кто в online
	$witt_us = array(1 => array());
	update_users_online($id, $witt_us);
	
}
// Кто в этой теме - Visman
// *****************************************************************************



//FURTHER DOWN

// *****************************************************************************
// Кто в этой теме - Visman
if (defined('WITT_ENABLE'))
{
?>
<div id="brdstats" class="block">
	<div class="box">
		<div class="inbox">
			<dl class="conl">
<?php

	$num_guests = count($witt_us[1]);
	$num_bots = 0;
	$num_users = count($witt_us) - 1;
	$users = $bots = array();
	$witt_bt = $witt_us[1];
	unset($witt_us[1]);
	unset($witt_us[1]);

	foreach ($witt_us as $online_id => $online_name)
	{
		if ($pun_user['g_view_users'] == '1')
			$users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$online_id.'">'.pun_htmlspecialchars($online_name).'</a>';
		else
			$users[] = "\n\t\t\t\t".'<dd>'.pun_htmlspecialchars($online_name);
	}
	foreach ($witt_bt as $online_name)
	{
		if (strpos($online_name, '[Bot]') !== false)
		{
		   ++$num_bots;
		   $arr_o_name = explode('[Bot]', $online_name);
		   if (empty($bots[$arr_o_name[1]])) $bots[$arr_o_name[1]] = 1;
		   else ++$bots[$arr_o_name[1]];
		}
	}
	foreach ($bots as $online_name => $online_id)
	{
		   $users[] = "\n\t\t\t\t".'<dd>[Bot] '.pun_htmlspecialchars($online_name.($online_id > 1 ? ' ('.$online_id.')' : ''));
	}
	echo "\t\t\t\t".'<dd><span>'.sprintf($lang_topic['Users online'], '<strong>'.forum_number_format($num_users).'</strong>').', '.sprintf($lang_topic['Guests online'], '<strong>'.forum_number_format($num_guests).'</strong>').'</span></dd>'."\n\t\t\t".'</dl>'."\n";;

 	if ($num_users + $num_bots > 0)
		echo "\t\t\t".'<dl id="onlinelist" class="clearb">'.implode(',</dd> ', $users).'</dd>'."\n\t\t\t".'</dl>'."\n";
	else
		echo "\t\t\t".'<div class="clearer"></div>'."\n";

?>
		</div>
	</div>
</div>
<?php
}
// Кто в этой теме - Visman
// *****************************************************************************

Offline

#6 2013-12-30 06:12:55

Visman
Member
From: Siberia
Registered: 2010-07-10
Posts: 827
Website

Re: View users on current page

		$db->add_field('online', 'witt_data', 'VARCHAR(255)', false, '') or error('Unable to add witt_data field', __FILE__, __LINE__, $db->error());

You watch still changes in the functions.php and common.php files.
At the beginning of the viewtopic.php file there is a line

define('WITT_ENABLE', 300);

My modification of FluxBB 1.5.6 - rev.64
I speak only Russian  tongue

Offline

#7 2013-12-30 12:07:29

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 228
Website

Re: View users on current page

I have searched manually through all the files, found any other parts, and updated the db using the code you gave me, but it doesn't show anyone in the topic - it just says

Registered users online in this topic: 0, guests: 0

always.

Does this have something to do with the cache? - I checked in your version but I couldn't find any.

When I check in the online table, I find the witt_data has this in:

a:1:{i:13;i:1388404690;}

- is this right?

Offline

#8 2013-12-30 12:48:32

Visman
Member
From: Siberia
Registered: 2010-07-10
Posts: 827
Website

Re: View users on current page

The update_users_online function is guilty. It at me very strongly differs from the original sad


My modification of FluxBB 1.5.6 - rev.64
I speak only Russian  tongue

Offline

#9 2013-12-30 15:12:05

chris98
Member
From: England, United Kingdom
Registered: 2013-05-31
Posts: 228
Website

Offline

#10 2013-12-31 00:30:56

Visman
Member
From: Siberia
Registered: 2010-07-10
Posts: 827
Website

Re: View users on current page

Use my version FluxBB.


My modification of FluxBB 1.5.6 - rev.64
I speak only Russian  tongue

Offline

Board footer

Powered by FluxBB 1.5.6