vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Preventing thread authors from increasing the view count of their own threads (https://vborg.vbsupport.ru/showthread.php?t=79728)

Shy 04-10-2005 06:40 PM

Preventing thread authors from increasing the view count of their own threads
 
I searched but couldn't find anything related here or on vbulletin.com forums.
I've decided to post here instead of possibly wasting time and be told this would require hacking and getting pointed here.

Preventing the thread view count from getting increased by the thread's starter is very useful, and I'd say fundamental to any forum. I was able to find simple mods for several other forum solutions, but not for vBulletin.
If anyone knows how to achieve this, I'd appreciate directions.
Thank you.

tnguy3n 04-10-2005 07:10 PM

I didn't test it out, but you can try to replace

Code:

        $DB_site->shutdown_query("
                UPDATE " . TABLE_PREFIX . "thread
                SET views = views + 1
                WHERE threadid = " . intval($threadinfo['threadid'])
        );

WITH:
Code:

        $DB_site->shutdown_query("
                UPDATE " . TABLE_PREFIX . "thread
                SET views = views + 1
                WHERE threadid = " . intval($threadinfo['threadid'])
                AND postuserid <> $bbuserinfo[userid]
        );


Paul M 04-10-2005 07:23 PM

It might help if you said which file this was in ;)

Shy 04-10-2005 07:26 PM

Thank you tnguy3n! This addition to showthread.php seems to work fine.

edit: nope, jump 2 posts ;)

Marco van Herwaarden 04-10-2005 07:33 PM

Maybe better to try to avoid the query to be run (would save a query again) by surrounding it with an if tgesting for authorid. Something like:
PHP Code:

if ($threadinfo['postuserid'] != $bbuserinfo['userid'])
{
run query



Shy 04-10-2005 07:35 PM

sorry, i was wrong. in fact, it's not working properly, view count is not increased by anyone.
(i enabled instant view updating in cp)

edited: post=view*

007 04-10-2005 07:59 PM

I released a hack for this for VB2. Feel free to look at that for reference.

Shy 04-11-2005 12:06 PM

Since I have little knowledge of PHP and how the forum's script works (plus I do need guest views to count), I hope someone could create this type of solution for vBulletin 3.
I'm surprised that it's not a widely requested feature. It's quite popular with other forums.

Marco van Herwaarden 04-11-2005 12:30 PM

Quote:

Originally Posted by Shy
Since I have little knowledge of PHP and how the forum's script works (plus I do need guest views to count), I hope someone could create this type of solution for vBulletin 3.
I'm surprised that it's not a widely requested feature. It's quite popular with other forums.

Well it really should work. Try the following edit to your showthread.php:

Find:
PHP Code:

if ($vboptions['threadviewslive'])
{
 
// doing it as they happen
 
$DB_site->shutdown_query("
  UPDATE " 
TABLE_PREFIX "thread
  SET views = views + 1
  WHERE threadid = " 
intval($threadinfo['threadid'])
 );
}
else
{
 
// or doing it once an hour
 
$DB_site->shutdown_query("
  INSERT INTO " 
TABLE_PREFIX "threadviews (threadid)
  VALUES (" 
intval($threadinfo['threadid']) . ')'
 
);


And replace by:
PHP Code:

// Ignore views by thread starter
if ($threadinfo[postuserid] != $bbuserinfo[userid])
{
 if (
$vboptions['threadviewslive'])
 {
  
// doing it as they happen
  
$DB_site->shutdown_query("
   UPDATE " 
TABLE_PREFIX "thread
   SET views = views + 1
   WHERE threadid = " 
intval($threadinfo['threadid'])
  );
 }
 else
 {
  
// or doing it once an hour
  
$DB_site->shutdown_query("
   INSERT INTO " 
TABLE_PREFIX "threadviews (threadid)
   VALUES (" 
intval($threadinfo['threadid']) . ')'
  
);
 }
}
// End: Ignore views by thread starter 


Shy 04-11-2005 01:37 PM

MarcoH64: Yes, this (really) works properly. Thanks!

However, queries jumped from 8 to 13.
Can someone modify it to be more query friendly? :)


All times are GMT. The time now is 12:16 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01814 seconds
  • Memory Usage 1,743KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete