Thread View Count Script

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Scam Warning
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
DustyParnell
Registered User
Posts: 64
Joined: Tue Aug 08, 2006 11:27 pm

Thread View Count Script

Post by DustyParnell »

Where can I find the code that handles the Thread View Count?

Thanks
DustyParnell
Registered User
Posts: 64
Joined: Tue Aug 08, 2006 11:27 pm

Re: Thread View Count Script

Post by DustyParnell »

Maybe I should ask this a little differently.

On what page can I find the code that handles the Thread View count?

Right now when one person views the thread, instead of it adding 1 it will add 2 or 3 to the ongoing count. Something is obviously wrong so I need to check out the code to see what's going on.

Help locating this varmint will be appreciated. Thanks

Dusty
User avatar
onehundredandtwo
Registered User
Posts: 1228
Joined: Fri Nov 14, 2008 8:07 am

Re: Thread View Count Script

Post by onehundredandtwo »

The thread count script isn't supposed to be perfect, only a guide on how popular the thread is. If the person refreshed the page or went into the thread twice then it would add two, not one.

It would depend on your browser's behaviour, some browsers send multiple requests for pages, which might be causing your problem. ;)
Need help preventing spam? Read Preventing spam in phpBB 3.0.6 and above
DustyParnell
Registered User
Posts: 64
Joined: Tue Aug 08, 2006 11:27 pm

Re: Thread View Count Script

Post by DustyParnell »

I'm proficient in php so I could probably work the count code so that it's a little closer to perfect than it is right now... if I knew where the count code was located.
User avatar
onehundredandtwo
Registered User
Posts: 1228
Joined: Fri Nov 14, 2008 8:07 am

Re: Thread View Count Script

Post by onehundredandtwo »

In viewforum.php ~line 106:

Code: Select all

	if ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK)
	{
		$sql = 'UPDATE ' . FORUMS_TABLE . '
			SET forum_posts = forum_posts + 1
			WHERE forum_id = ' . $forum_id;
		$db->sql_query($sql);
	}
Need help preventing spam? Read Preventing spam in phpBB 3.0.6 and above
ToonArmy
Former Team Member
Posts: 4608
Joined: Sat Mar 06, 2004 5:29 pm
Location: Worcestershire, UK
Name: Chris Smith
Contact:

Re: Thread View Count Script

Post by ToonArmy »

onehundredandtwo wrote:In viewforum.php ~line 106:

Code: Select all

	if ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK)
	{
		$sql = 'UPDATE ' . FORUMS_TABLE . '
			SET forum_posts = forum_posts + 1
			WHERE forum_id = ' . $forum_id;
		$db->sql_query($sql);
	}
Thats for the 'link' forum type, counting the clicks.
DustyParnell wrote:Where can I find the code that handles the Thread View Count?
viewtopic.php wrote:

Code: Select all

// Update topic view and if necessary attachment view counters ... but only for humans and if this is the first 'page view'
if (isset($user->data['session_page']) && !$user->data['is_bot'] && (strpos($user->data['session_page'], '&t=' . $topic_id) === false || isset($user->data['session_created'])))
{
    $sql = 'UPDATE ' . TOPICS_TABLE . '
        SET topic_views = topic_views + 1, topic_last_view_time = ' . time() . "
        WHERE topic_id = $topic_id";
    $db->sql_query($sql);

    // Update the attachment download counts
    if (sizeof($update_count))
    {
        $sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
            SET download_count = download_count + 1
            WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count));
        $db->sql_query($sql);
    }
}
Moving this to support too.
Chris SmithGitHub
Locked

Return to “[3.0.x] Support Forum”