phpBBHacks.com - Disable Author View Counting
Discuss the martial arts at KarateForums.com
StatsForums Home   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in
FAQFAQ   SearchSearch   MemberlistMemberlist   TutorialsTutorials   ContactContact Us
Add Us:     MySpace     Facebook     StumbleUpon
Username:    Password:
Remember Me?    
Disable Author View Counting
BlinkList
del.icio.us
Furl
linkaGoGo
reddit
Simpy
Mister Wong
Yahoo! My Web

Post new topic   Reply to topic    phpBBHacks.com Support Forums Forum Index -> phpBB 2: Customizing Your phpBB
 See a User Guidelines violation? Please contact us.
Author Message

Thoul
VIP

Joined: 30 Jul 2002
Posts: 17676
Location: USA

PostPosted: November 27th 2004, 6:07 pm    Post subject: Disable Author View Counting Reply with quote

Usually, topics are viewed most often by the person that started the topic. If you feel that this artificially inflates the number of views counted for topics, or just plain dislike the behavior, you can prevent it with these changes.

These changes only disable counting of multiple views by the original poster of the topic. To stop counting the views of all posters in a topic, skip to the second post. Please note that this code does not account for guest posters - they are nearly impossible to track for this purpose.
Code:
##
##----------[ OPEN ]-------------------------------------

##

viewtopic.php

##
##----------[ FIND ]-------------------------------------
##

$sql = "UPDATE " . TOPICS_TABLE . "
   SET topic_views = topic_views + 1
   WHERE topic_id = $topic_id";
if ( !$db->sql_query($sql) )
{
   message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
}

##
##----------[ REPLACE WITH ]-----------------------------
##

/*-------------------------------------------------------------------
//  Disable Author View Counting - Begin ORIGINAL phpBB Code
//

$sql = "UPDATE " . TOPICS_TABLE . "
   SET topic_views = topic_views + 1
   WHERE topic_id = $topic_id";
if ( !$db->sql_query($sql) )
{
   message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
}

//
//  Disable Author View Counting - End ORIGINAL phpBB Code
//-------------------------------------------------------------------*/

//-------------------------------------------------------------------
//  Disable Author View Counting - Begin Code Addition
//
if ( $userdata['user_id'] == ANONYMOUS || $userdata['user_id'] != $postrow[0]['user_id'] )
{
   $sql = "UPDATE " . TOPICS_TABLE . "
      SET topic_views = topic_views + 1
      WHERE topic_id = $topic_id";
   if ( !$db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, 'Could not update topic views.', '', __LINE__, __FILE__, $sql);
   }
}
//
//  Disable Author View Counting - End Code Addition
//-------------------------------------------------------------------


Last edited by Thoul on May 6th 2005, 9:25 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website

Thoul
VIP

Joined: 30 Jul 2002
Posts: 17676
Location: USA

PostPosted: November 27th 2004, 6:16 pm    Post subject: Disable Poster View Counting Reply with quote

The above code only disables View counting for the first poster in a topic. To disable view counting for all posters in a topic, use this method instead. Again, this does not take guest posters into account. Also, this code can only be used if running phpBB on PHP 4 or later.

Code:
##
##----------[ OPEN ]-------------------------------------
##

viewtopic.php

##
##----------[ FIND ]-------------------------------------
##

$sql = "UPDATE " . TOPICS_TABLE . "
   SET topic_views = topic_views + 1
   WHERE topic_id = $topic_id";
if ( !$db->sql_query($sql) )
{
   message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
}

##
##----------[ REPLACE WITH ]-----------------------------
##

/*-------------------------------------------------------------------
//  Disable Poster View Counting - Begin ORIGINAL phpBB Code
//

$sql = "UPDATE " . TOPICS_TABLE . "
   SET topic_views = topic_views + 1
   WHERE topic_id = $topic_id";
if ( !$db->sql_query($sql) )
{
   message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
}

//
//  Disable Poster View Counting - End ORIGINAL phpBB Code
//-------------------------------------------------------------------*/

//-------------------------------------------------------------------
//  Disable Poster View Counting - Begin Code Addition
//

$sql = 'SELECT poster_id FROM ' . POSTS_TABLE . '
      WHERE topic_id = ' . $topic_id . '
         AND poster_id <> ' . ANONYMOUS;
if ( $posters_result = $db->sql_query($sql) )
{
   $authors = array();
   while( $posters = $db->sql_fetchrow($posters_result) )
   {
      $authors[] = intval($posters['poster_id']);
   }

   if ( $userdata['user_id'] == ANONYMOUS || !in_array($userdata['user_id'], $authors) )
   {
      $sql = "UPDATE " . TOPICS_TABLE . "
         SET topic_views = topic_views + 1
         WHERE topic_id = $topic_id";
      if ( !$db->sql_query($sql) )
      {
         message_die(GENERAL_ERROR, 'Could not update topic views.', '', __LINE__, __FILE__, $sql);
      }
   }
}
else
{
   $sql = "UPDATE " . TOPICS_TABLE . "
      SET topic_views = topic_views + 1
      WHERE topic_id = $topic_id";
   if ( !$db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
   }
}
//
//  Disable Poster View Counting - End Code Addition
//-------------------------------------------------------------------

_________________
Phantasy Star: The Fringes of Algo

Install, remove, or upgrade SQL with Advanced DB Update Generator! Now with phpBB 3 Support!

My phpBB Books, Hacks, and Other Works «·» 70+ Listings @ phpBBHacks.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    phpBBHacks.com Support Forums Forum Index -> phpBB 2: Customizing Your phpBB All times are GMT - 6 Hours
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Links: Big Message Boards - Free JavaScript - phpBB2 - phpbb styles - Suporte phpBB - phpBB.it - phpBB Česky - phpBB Turkiye - phpBBArabia.com - phpBB-fr.com - Romanian phpBB online community - phpBB-TW.net - phpBBservice.nl

Network: iFroggy Network Blog - iFroggy Hosting - SportsForums.net - KarateForums.com - YanksBlog.com - DeveloperCube - Managing Online Forums - ManagingCommunities.com - CommunityAdmins.com - PhotoshopForums.com - MicrosoftBlog.com - DrGregHouse.com - Bad Boy Blog - BadBoyForums.com - SodaRatings.com - Patrick O'Keefe

< Advertising - Contact Us - Staff - User Guidelines >

Copyright © 2001-2008. iFroggy Network, phpBBHacks.com. All Rights Reserved. Privacy Policy. We Support phpBBHacks.com (of course!).
Powered by phpBB © phpBB Group. phpBB SEO. Hosted by 100MegsWebHosting. We are in no way affiliated with the phpBB Group. phpBB is copyright to the phpBB Group.