PDA

View Full Version : Views Don't Count If Done By Guest Or Thread Starter Unless Replying


007
03-08-2003, 10:00 PM
Views Don't Count If Done By Guest Or Thread Starter Unless Replying by 006

What this hack does:

This hack basically keeps your thread views down to only the legit views, and does not add a vew for each refresh unless you are viewing somebody elses thread and are not the last poster in the thread. When a guest views a thread this also does not add a view unless the guest is allowed to reply and does so. In that case one view will be added. This hack makes it easier to tell if somebody has viewed your threads, because after posting, even if you go look at your thread to make sure it "looks right," the view count will still be 0. Your own views will not count.

Benefits of this hack:

The main reason I made this hack was because of the Lesane (https://vborg.vbsupport.ru/member.php?s=&action=getinfo&userid=345) "Store Hack (https://vborg.vbsupport.ru/showthread.php?s=&threadid=36991)." If you use the store hack, then you know that points can be awarded to people after so many views of their thread. Well, this hack creates the following variables when calculating the views for each thread: Views by the thread starter don't count unless they are replying. This way people cannot view their own thread over and over to get points. If the thread starter replies, one view will be added. This was there isn't a possibility of more replies than views.
Views by guests don't count unless guest posting is enabled, then the views will only count when guests reply. This way thread starters cannot simply log in as guests to get their thread view numbers up. Guests can still view the threads of course (unless you have this disabled with the "Restrict Guest Viewing Threads in a Forum (https://vborg.vbsupport.ru/showthread.php?s=&threadid=40145)" hack by PPN (https://vborg.vbsupport.ru/member.php?s=&action=getinfo&userid=96)), but their views will not be added to the total thread views.
Views Don't Count If Done By Guest Or Thread Starter Unless Replying

by 006

INSTALLATION:

It shouldn't take any more than 5 minutes to install. (3 steps, 2 file edits)

It has been tested and works fine in 2.2.9

Any questions? Feel free to ask in this thread. ;)

If you use this hack, please click "INSTALL (https://vborg.vbsupport.ru/misc.php?s=&action=install&threadid=49867)." Thanks

Boofo
03-09-2003, 11:30 PM
Will check it out. Sounds good. ;)

007
03-09-2003, 11:51 PM
I found a bug in this. It works for a while and then stops. For no reason that I could see....

I posted a thread here if anyone knows what I should do. :ermm:

https://vborg.vbsupport.ru/showthread.php?s=&threadid=49874

Dean C
03-10-2003, 04:11 PM
Interesting concept :)

- miSt

007
05-02-2003, 02:03 PM
Well this is now working fine now. I found the problem.

Boofo
05-02-2003, 02:44 PM
Today at 10:03 AM 006 said this in Post #5 (https://vborg.vbsupport.ru/showthread.php?postid=390441#post390441)
Well this is now working fine now. I found the problem.

Did you update the first post with the fix? If so, what is the update for those who already had it installed? ;)

007
05-02-2003, 02:53 PM
Well, if someone DID have it installed, I just removed all the elseif lines where it referred to $lastposter['userid'] in the THIRD step, since that caused problems.

I don't think anyone installed it though since it didn't work.

And yes, I have updated the first post. :)

Boofo
05-02-2003, 03:11 PM
Well, I had it installed but had to uninstall it when you reported the problem with it. I have re-installed it and it seems to be working fine so far. Good job! ;)

Edit: I was just looking at the file and the $lastposter['userid'] is still in there. Is this how it is supposed to be?

//Start Views Don't Count based on Variables by 006
if ($noshutdownfunc) {
if ($thread['postuserid']==$bbuserinfo['userid']) {
$DB_site->query("UPDATE thread SET views=views WHERE threadid='$threadid'");}
else if ($lastposter['userid'] != $bbuserinfo['userid']) {
$DB_site->query("UPDATE thread SET views=views WHERE threadid='$threadid'");}
else if (!$bbuserinfo['userid']) {
$DB_site->query("UPDATE thread SET views=views WHERE threadid='$threadid'");}
else if ($thread['postuserid'] <> $bbuserinfo['userid']) {
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");}
//End Views Don't Count based on Variables by 006

007
05-02-2003, 03:45 PM
Found the problem. I renamed it. Try clearing your history and then opening it, or opening it by "SHIFT+Clicking."

The line to remove in the first part of step 3 looks like this:

else if ($lastposter['userid'] != $bbuserinfo['userid']) {
$DB_site->query("UPDATE thread SET views=views WHERE threadid='$threadid'");}

There is a similar line in the second part of step 3.

I also changed the last line. Just try opening the install file again and see if it is different.

There are NO changes to newreply.php

Hope that works. :)

Boofo
05-02-2003, 04:14 PM
Ok, got it now. I will make the changes and let you know how it goes. Thank you, sir. ;)

Boofo
05-05-2003, 12:50 AM
006, in your first step in the showthread.php, the last 2 lines are wrong (they give a db error):

Instead of:

elseif {
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");}

it should be:

else {
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");}

shouldn't it?

Boofo
05-05-2003, 03:23 AM
For some reason, this hack is no longer working for me. The thread views are not updating even when I am not the thread starter or last poster.

007
05-05-2003, 04:24 AM
That's weird. That's what happened to me before I "fixed" it... which I thought I did. I haven't been having any problems with it. I'll check it tomorrow.

The code you mentioned above is set to -1 so it doesn't give you a view after posting your own topic.

You wouldn't want to change it to +1 because it is already adding one. I think that part is no longer necessary since I took out the disableing view count adding if you are the last poster option since that gave me trouble.

I will look into this tomorrow and let you know.

Boofo
05-05-2003, 06:26 AM
After you look at the file in post 1, let me know what you find out. I'd really like to get this working. Thanks. ;)

007
05-05-2003, 04:07 PM
Ok, try cdownloading the file again. If it does not say "Updated 05/05/03" after "by 006" then you will need to clear your history and try opening it again.

What I did was remove some unecessary code in the 2nd step. This should have an effect on whether or not it works, but it makes the code cleaner.

The reason for the -1 as you mentioned before, is so after someone makes a post, usualy in VB by the time they finish posting it, there are already 2 views on it. This simply makes it so first of all they don't get a view as the thread poster, and second of all, the first view will be subtracted. This leaves new posts with 0 views.

Boofo
05-05-2003, 05:13 PM
The code you updated was for the newreply, right? That's not where I was having the problem yesterday. ;)

007
05-05-2003, 05:43 PM
I know but are you sure you have the most recent file??? It works totally fine with the most recent.

The problem you are having sounds a lot like what I was having before I fixed it... The new file says Updated 05/05/03 near the top of it. Let me know. :ermm:

007
05-19-2003, 02:59 PM
Does this work for you now Boofo?

Pikok
07-14-2003, 03:18 PM
There's an error in your code in step 3..

In "root/showthread.php" you say to replace:if ($noshutdownfunc) {
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");With//Start Views Don't Count based on Variables by 006
if ($noshutdownfunc) {
if ($thread['postuserid']==$bbuserinfo['userid']) {
$DB_site->query("UPDATE thread SET views=views WHERE threadid='$threadid'");}
elseif (!$bbuserinfo['userid']) {
$DB_site->query("UPDATE thread SET views=views WHERE threadid='$threadid'");}
elseif {
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");}
//End Views Don't Count based on Variables by 006However, it should be replaced with://Start Views Don't Count based on Variables by 006
if ($noshutdownfunc) {
if ($thread['postuserid']==$bbuserinfo['userid']) {
$DB_site->query("UPDATE thread SET views=views WHERE threadid='$threadid'");}
elseif (!$bbuserinfo['userid']) {
$DB_site->query("UPDATE thread SET views=views WHERE threadid='$threadid'");}
else {
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");}
//End Views Don't Count based on Variables by 006
The last elseif statement should be an else statement. Can't have an if statement with no condition to be checked against. ;)

Azhrialilu
08-08-2003, 08:14 AM
Pikok.. I could kiss you LOL I was just on the verge of going back to my last backup after the third time of installing, then I finally spotted your post!!!

It works beautifully now :)

*Clicks install*

Bison
08-08-2003, 08:23 PM
07-14-03 at 12:18 PM Pikok said this in Post #19 (https://vborg.vbsupport.ru/showthread.php?postid=417698#post417698)
There's an error in your code in step 3..

In "root/showthread.php" you say to replace:if ($noshutdownfunc) {
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");With//Start Views Don't Count based on Variables by 006
if ($noshutdownfunc) {
if ($thread['postuserid']==$bbuserinfo['userid']) {
$DB_site->query("UPDATE thread SET views=views WHERE threadid='$threadid'");}
elseif (!$bbuserinfo['userid']) {
$DB_site->query("UPDATE thread SET views=views WHERE threadid='$threadid'");}
elseif {
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");}
//End Views Don't Count based on Variables by 006However, it should be replaced with://Start Views Don't Count based on Variables by 006
if ($noshutdownfunc) {
if ($thread['postuserid']==$bbuserinfo['userid']) {
$DB_site->query("UPDATE thread SET views=views WHERE threadid='$threadid'");}
elseif (!$bbuserinfo['userid']) {
$DB_site->query("UPDATE thread SET views=views WHERE threadid='$threadid'");}
else {
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");}
//End Views Don't Count based on Variables by 006
The last elseif statement should be an else statement. Can't have an if statement with no condition to be checked against. ;)

If you look a line down from that elseif statement, there's a reason why the elseif is used again ... the condition is continued from an else statement that opens another series of test conditions.

JeffyJoe
08-30-2003, 11:01 PM
Bison
what is your suggestion?

Bison
09-01-2003, 12:07 PM
Insert the code the way it is written in the hack ... it works!

X-Fan
09-09-2003, 03:13 AM
No, it didn't work for me with the second elseif. Changing it to an else got my showthread working again.

007
01-08-2004, 11:54 PM
Ok, it works just fine on a clean copy of VB. If you have hacked your board up then it may cause problems. Sorry to hear you guys had trouble. At least it's working now :)

akanevsky
04-19-2005, 05:59 PM
Nice hack, shall install :)

Bison
10-09-2006, 04:13 PM
Anyone done this hack for VB 3.5?