[Request] Who Viewed a Topic

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Scam Warning
User avatar
Théonaute
Registered User
Posts: 341
Joined: Sun Jan 22, 2006 10:31 am

Re: [Request] Who Viewed a Topic

Post by Théonaute » Sat Sep 06, 2008 9:19 am

It works.
Théonaute | ex-MOD Team member on phpbb-fr.com
No more phpBB's activities. No MODs updates, no new MODs... Thanks.

User avatar
DragonMaster1
Registered User
Posts: 994
Joined: Tue Aug 17, 2004 11:04 am
Name: Terry
Contact:

Re: [Request] Who Viewed a Topic

Post by DragonMaster1 » Sat Sep 06, 2008 1:38 pm

I found a newer version of what appears to be the same thing:

http://www.phpbb.com/community/viewtopi ... 0&t=546593

[Beta] JC Topic View Tracker 0.5.2
by BondGamer on Sat May 26, 2007 4:42 pm

MOD Title: JC Topic View Tracker
MOD Description: This MOD will allow moderators and administrators to track who views each topic. Each time a user opens a topic page in an activated forum, their name and IP is recorded. This can be useful for making sure unauthorized users don't have access to certain areas of your board.
MOD Version:Beta 0.5.2

im0en
Registered User
Posts: 7
Joined: Sat Oct 25, 2008 4:27 pm

Re: [Request] Who Viewed a Topic

Post by im0en » Sun Dec 28, 2008 1:16 am

I tried installing this mod and something went wrong. Now on the module management page I get "General Error
Module not accessible" so I can't even uninstall it. Can someone help me figure out how to remove this please?

net83it
Registered User
Posts: 500
Joined: Sun Jan 15, 2006 2:42 pm
Location: Sicily
Contact:

Re: [Request] Who Viewed a Topic

Post by net83it » Mon Dec 29, 2008 8:44 pm

which mod do you suggest to install between http://www.phpbb.com/community/viewtopi ... 0&t=546593 and http://forums.nosce-te-ipsum.net/viewtopic.php?f=10&t=8 ?

i'm looking for a mod that showes also the time the user visited the topic

thank you

Stass
Registered User
Posts: 3
Joined: Thu Jul 02, 2009 8:57 am
Location: where bears walk the streets

Re: [Request] Who Viewed a Topic

Post by Stass » Mon Jul 06, 2009 11:49 am

Hi all! How can I sort results by "Last view" colomn in viewtopicviewers.php?

Stass
Registered User
Posts: 3
Joined: Thu Jul 02, 2009 8:57 am
Location: where bears walk the streets

Re: [Request] Who Viewed a Topic

Post by Stass » Tue Jul 07, 2009 8:06 am

Well, there is some changes lets you sort result by username, last view or number of viewers.
Replace original viewtopicviewers.php

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

//*****************************
// Start session management
//*****************************
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewtopicviewers');

//*****************************
// Get and set some variables
//*****************************
$topic	= request_var('topic', 0);
$supp	= request_var('delete', 0);
$sort	= request_var('s', '');
$dir	= request_var('dir', '');

if(in_array($sort, array('u', 'v', 'n')))
{
switch ($sort)
{
	case 'u':
	$sql_order = 'u.username';
	break;
	
	case 'v':
	$sql_order = 'date';
	break;
	
	case 'n':
	$sql_order = 'nb';
	break;
}
}
else
{
$sql_order = 'u.username';
}

if(in_array($dir, array('a', 'd')))
{
switch ($dir)
{
	case 'a':
	$sql_sortdir = ' ASC';
	break;
	
	case 'd':
	$sql_sortdir = ' DESC';
	break;
}
}
else
{
$sql_sortdir = '';
}


if(!$config['tv_enable'])
{
	trigger_error('TV_DISABLED');
}

//*****************************
// Do you want to delete statistics for this topic ?
//*****************************
if($supp==1)
{
	//Admin ? go to confirm box
	if($auth->acl_get('a_'))
	{
		$s_hidden_fields = build_hidden_fields(array(
			'f'		=> $forum_id)
		);

		if (confirm_box(true))
		{
			//Delete
				$sql = 'DELETE FROM ' . TOPICS_VIEWERS_TABLE . "
						WHERE topic_id = $topic";
				$result = $db->sql_query($sql);
			
			//Display
			$meta_info = append_sid("{$phpbb_root_path}viewtopicviewers.$phpEx", 'topic=' . $topic);
			
			$message = $user->lang['TV_STATS_DELETED'] . '<br/><br/>';
			$message .= sprintf($user->lang['TV_RETURN_STATS'], '<a href="' . $meta_info . '">', '</a>');

			meta_refresh(3, $meta_info);
			trigger_error($message);
		}
		else
		{
			confirm_box(false, 'TV_DELETE_STATISTICS', $s_hidden_fields);
		}
	}
	else
		trigger_error('NO_AUTH_OPERATION');
}

//*****************************
// Check if the topic exist
//*****************************
	$sql = 'SELECT forum_id
		FROM ' . TOPICS_TABLE . "
		WHERE topic_id = $topic";
	$result = $db->sql_query($sql);
	$forum_id = (int) $db->sql_fetchfield('forum_id');
	$db->sql_freeresult($result);

	if (!$forum_id)
	{
		trigger_error('NO_TOPIC');
	}

//*****************************
// Get user list
//*****************************
	
	$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_type, u.user_colour, v.user_id, COUNT(v.user_id) AS nb, MAX(v.date) as date
		FROM ' . USERS_TABLE . ' u, ' . TOPICS_VIEWERS_TABLE . ' v
		WHERE u.user_id = v.user_id
			AND v.topic_id = ' . $topic . '
		GROUP BY v.user_id
		ORDER BY ' . $sql_order . $sql_sortdir;
	$result = $db->sql_query($sql);

	$prev_id = $prev_ip = $user_list = array();

	$total = 0;

	while ($row = $db->sql_fetchrow($result))
	{
		if ($row['user_id'] != ANONYMOUS && !isset($prev_id[$row['user_id']]))
		{
			//User color
			$user_colour = ($row['user_colour']) ? ' style="color:#' . $row['user_colour'] . '" class="username-coloured"' : '';
			//How username is display
			$username_full = ($row['user_type'] != USER_IGNORE) ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) . ', ' : '<span' . $user_colour . '>' . $row['username'] . '</span>, ';
			//Last view
			$dates = $user->format_date($row['date']);
			
			$prev_id[$row['user_id']] = 1;			
			$total++;
			
			//Is there a post from this user in this topic ?
				$sql_posts = 'SELECT COUNT(post_id) as nb_post
								FROM ' . POSTS_TABLE . '
								WHERE poster_id = ' . $row['user_id'] . '
									AND topic_id = ' . $topic;
				$result_posts = $db->sql_query($sql_posts);
				$post = (int) $db->sql_fetchfield('nb_post');
				$db->sql_freeresult($result_posts);
				
			if($post>0)
			{
				$postimage="topicyes.gif";
				$postalt=$user->lang['TV_POST'];
			}
			else
			{
				$postimage="topicno.gif";
				$postalt=$user->lang['TV_NOPOST'];
			}
			
			// Send vars to template
			$template->assign_block_vars('user_row', array(
					'USERNAME_FULL'	=> substr($username_full, 0, -2),
					'DATES'			=> $dates,
					'NB'			=> $row['nb'],
					'POSTER'		=> "<img src=\"" . $phpbb_root_path . "styles/" . $user->theme['theme_path'] . "/theme/images/$postimage\" alt=\"$postalt\" />",
			));	
		}
	}
	
	$template->assign_vars(array(
			'L_USERNAME'			=> "<a href=\"". append_sid("{$phpbb_root_path}viewtopicviewers.$phpEx", "topic=$topic&s=u&dir=" . (($sort == 'u' && $dir == 'd') ? 'a' : 'd')) ."\">". sprintf($user->lang['USERNAME'], $total) ."</a>",
			'L_TV_LAST_VIEW_DATES' 	=> "<a href=\"". append_sid("{$phpbb_root_path}viewtopicviewers.$phpEx", "topic=$topic&s=v&dir=" . (($sort == 'v' && $dir == 'd') ? 'a' : 'd')) ."\">". sprintf($user->lang['TV_LAST_VIEW_DATES'], $total) ."</a>",
			'L_TV_NB_VIEW_DATES'	=> "<a href=\"". append_sid("{$phpbb_root_path}viewtopicviewers.$phpEx", "topic=$topic&s=n&dir=" . (($sort == 'n' && $dir == 'd') ? 'a' : 'd')) ."\">". sprintf($user->lang['TV_NB_VIEW_DATES'], $total) ."</a>",
			'TOTAL_TOPIC_VIEWERS'	=> sprintf($user->lang['TV_TOTAL_VIEWERS'], $total)
	));
	
	$db->sql_freeresult($result);
	unset($prev_id, $prev_ip);
	
//*****************************
// Grab group details for legend display
//*****************************
	if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
	{
		$sql = 'SELECT group_id, group_name, group_colour, group_type
			FROM ' . GROUPS_TABLE . '
			WHERE group_legend = 1
			ORDER BY group_name ASC';
	}
	else
	{
		$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
			FROM ' . GROUPS_TABLE . ' g
			LEFT JOIN ' . USER_GROUP_TABLE . ' ug
				ON (
					g.group_id = ug.group_id
					AND ug.user_id = ' . $user->data['user_id'] . '
					AND ug.user_pending = 0
				)
			WHERE g.group_legend = 1
				AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
			ORDER BY g.group_name ASC';
	}
	$result = $db->sql_query($sql);

	$legend = '';
	while ($row = $db->sql_fetchrow($result))
	{
		if ($row['group_name'] == 'BOTS')
		{
			$legend .= (($legend != '') ? ', ' : '') . '<span style="color:#' . $row['group_colour'] . '">' . $user->lang['G_BOTS'] . '</span>';
		}
		else
		{
			$legend .= (($legend != '') ? ', ' : '') . '<a style="color:#' . $row['group_colour'] . '" href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</a>';
		}
	}
	$db->sql_freeresult($result);
	
	
//*****************************
// Statistics
//*****************************
	//What time is it ?
	$now = time();
	
	//Get total views and start time for this topic
	$sql_infos = 'SELECT COUNT(topic_id) as total
					FROM ' . TOPICS_VIEWERS_TABLE . '
					WHERE topic_id = ' . $topic . '
					GROUP BY topic_id';
	$result_infos = $db->sql_query($sql_infos);
		$total_viewers 	= (int) $db->sql_fetchfield('total');
	$db->sql_freeresult($result_infos);
	
	$sql_infos = 'SELECT MIN(date) as date
					FROM ' . TOPICS_VIEWERS_TABLE . '
					WHERE topic_id = ' . $topic . '
					GROUP BY topic_id';
	$result_infos = $db->sql_query($sql_infos);
		$start_time 	= (int) $db->sql_fetchfield('date');
	$db->sql_freeresult($result_infos);
			
	if($total_viewers>0)
	{
		//Lets go...
		$current = $start_time;
		
		while($current < $now)
		{
			$next = mktime(0,0,0,intval(date("n",$current))+1,1,intval(date("Y",$current)));
			
			$sql_nb = 'SELECT COUNT(date) as nb
							FROM ' . TOPICS_VIEWERS_TABLE . '
							WHERE topic_id = ' . $topic . '
								AND date >= ' . $current . ' AND date < ' . $next ;
			$result_nb = $db->sql_query($sql_nb);
				$nb	= (int) $db->sql_fetchfield('nb');
			$db->sql_freeresult($result_nb);
			
			
			// Send vars to template
			$template->assign_block_vars('stats', array(
					'MONTH'		=> $user->format_date($current, "F Y"),
					'PCT'		=> round($nb/$total_viewers*100),
					'PERCENT'	=> round($nb/$total_viewers*100,2) . '%',
					'RESULT'	=> $nb
			));	

			$current = $next;
		}
	}

	

//*****************************
// Refreshing the page every 5 minutes...
//*****************************
	meta_refresh(300, append_sid("{$phpbb_root_path}viewtopicviewers.$phpEx", "topic=$topic"));

	
// Send data to template
	$template->assign_vars(array(
		'LEGEND'	=> $legend
	));
	
	
//*****************************
// Can the user delete statistics ?
//*****************************
	if($auth->acl_get('a_'))
	{
		$template->assign_vars(array(
		'U_SUPP'	=> "<a href=\"". append_sid("{$phpbb_root_path}viewtopicviewers.$phpEx", "topic=$topic&delete=1") ."\">". $user->lang['TV_DELETE_STATISTICS'] ."</a>"
	));
	}

//*****************************
// Output the page
//*****************************
	page_header($user->lang['VIEW_TOPIC_VIEWERS']);

	$template->set_filenames(array(
		'body' => 'viewtopicviewers_body.html')
	);
	
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));

page_footer();

?>

jaxouk
Registered User
Posts: 21
Joined: Fri Jun 18, 2010 9:30 pm
Contact:

Re: [Request] Who Viewed a Topic

Post by jaxouk » Thu Nov 25, 2010 2:01 pm

does anyone know where i can download this as the download link is broken,.. or even if there is any similar alternatives.

Thanks in advance

marian0810
Former Team Member
Posts: 3011
Joined: Mon May 21, 2007 9:17 pm
Location: The Netherlands
Name: Marian
Contact:

Re: [Request] Who Viewed a Topic

Post by marian0810 » Thu Nov 25, 2010 7:27 pm

You and me, time and space. You watch us run!

GlouGlou
Registered User
Posts: 168
Joined: Thu Mar 04, 2010 12:09 am

Re: [Request] Who Viewed a Topic

Post by GlouGlou » Thu Sep 08, 2011 10:50 am

The link is broken :(

marian0810
Former Team Member
Posts: 3011
Joined: Mon May 21, 2007 9:17 pm
Location: The Netherlands
Name: Marian
Contact:

Re: [Request] Who Viewed a Topic

Post by marian0810 » Thu Sep 08, 2011 11:11 am

I added the file but please keep in mind this mod is no longer supported.
Attachments
Qui_a_vu_ce_sujet_v1.0.0.zip
(42.42 KiB) Downloaded 52 times
You and me, time and space. You watch us run!

User avatar
Terr0r
Registered User
Posts: 553
Joined: Thu May 05, 2011 3:39 pm
Location: The Netherlands
Contact:

Re: [Request] Who Viewed a Topic

Post by Terr0r » Thu Sep 08, 2011 11:52 am

I don't know if i'm right I think the topic starter search for this MOD

Image
if you can't fix it with ducktape you ain't using enough
if you want to search a MOD maybe you can find it here
For my MODS and BBCodes or other things that I have made take a look here

GlouGlou
Registered User
Posts: 168
Joined: Thu Mar 04, 2010 12:09 am

Re: [Request] Who Viewed a Topic

Post by GlouGlou » Thu Sep 08, 2011 12:04 pm

thx marian ;)

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [Request] Who Viewed a Topic

Post by 4_seven » Thu Sep 08, 2011 2:55 pm

Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
Oyabun1
Former Team Member
Posts: 23162
Joined: Sun May 17, 2009 1:05 pm
Location: Australia
Name: Bill

Re: [Request] Who Viewed a Topic

Post by Oyabun1 » Fri Sep 09, 2011 4:42 am

Or maybe this one, [RC] AOS Who Visited a Topic.
                      Support Request Template
3.0.x: Knowledge Base Styles Support MOD Requests
3.1.x: Knowledge BaseStyles SupportExtension Requests

GlouGlou
Registered User
Posts: 168
Joined: Thu Mar 04, 2010 12:09 am

Re: [Request] Who Viewed a Topic

Post by GlouGlou » Fri Sep 09, 2011 9:49 am

Yes, I have tested AOS Who Visited a Topic ans seems to be good.

Locked

Return to “[3.0.x] MOD Requests”