PDA

View Full Version : Make a forum statistically invisible v.1.0b


gopherhockey
03-09-2003, 05:29 PM
What it does

The idea behind this hack is to take a forum (or forums) and make them statistically invisible to the vb system. Users can still see the forum, read and reply, but activity does not increase post or thread counts for the users or the system itself.

Why?

I can only explain why by giving an example on my own system. In my example, the forum is an NNTP gateway (newsgroup) using the NNTP gateway hack. The forum itself can get anywhere from 0-2000+ posts/threads in a day. Users coming to my system do not wish to see these show up as new posts, new threads etc. I want to treat it as a resource (special) forum - but not let it act like the others by increasing post totals etc.


Lets take this a section at a time

The way vb works, as we all know, is that posts in a forum will trigger various affects. A few of which are:

1. Users post count increases (there is a way around this in the admin cp) No hack needed, just remember to set the forum correctly.

2. Total posts on the entire board go up (as displayed on the top of most unedited vb systems as:

Members: XX, Threads: YY, Posts: ZZ

There are also various scripts & hacks that will show this data on other pages as well, such as vbhome lite which shows it as:


YY new forum threads started
ZZ new forum posts


To not show threads for a specific forum in the total threads for a board, you can open your forum/index.php file and look for:

$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');

and replace it with:

$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread WHERE forumid!=XX');

(thanks to Tigga for this solution)

This solves YY, but not ZZ (this is why I'm posting here as I don't have a solution for this part)

4. When looking at the list of all forums, you can see the total number of posts and threads for each forum just before the "Last Post" column.

Post Threads
XXX YYY

I don't know how to turn this on or off either. For my purposes, I'd just as well leave this alone - users can at least see that there are new posts or threads in this resource forum somewhere - might as well be here. For the purposes of this hack, however, it might be nice to know how to turn this on or off.


5. When a user arrives and sees that there are new posts or threads, often times they click on "view new posts" to see a list of what has been posted lately.

Problem here is that they might see hundreds of new posts from this resource forum. I want to exclude this forum from view new posts, so here is how:

(thanks to logician for this answer)

in search.php, find:

$wheresql.=" AND thread.open<>10";

and replace it with:

$wheresql.=" AND thread.open<>10 AND thread.forumid!=X";

where X is your forum id.

There are 2 insances of this to find. (one for members, one for guests)

To exclude more than one forum, simply edit the line to look like this:

$wheresql.=" AND thread.open<>10 AND thread.forumid!=01 AND thread.forumid!=02";


Excluding the forum from the search function:

To keep this resource forum from showing up when a user does a search, you can edit the forum permissions for all user groups and select "no" for the "can search" setting. This requires custom settings for this forum for all groups that you do not wish to search this forum. This is not a hack but a built-in function of vb.


So where are we now?

What have we accomplished thus far is:

1. Our forum won't show new threads to the user
3. Our forum won't increase the users post count in this forum.
3. Our forum won't add to the thread count (display) to the user.
4. Our forum won't show up when a user clicks to view new posts since they last visited.
5. Our forum won't show up when a user does a search

What I haven't been able to do?

Anything related to the post count. Post counts still increase. A user will still see hundreds or thousands of new posts since they last visited. The problem is, with all the edits above they are confused when they see XX posts since they last visited, click on view new posts since last online and get the "sorry, there are no new posts since you last visited" message.

Can anyone provide this missing link?

If so, I *think* I could post this as a semi-hack for those that wish to have this functionality.

(note: I have posted this question elsewhere on this system with no luck, so I'm trying it this way and apologize for the multiple requests)

Thanks for your time...

Logician
03-10-2003, 11:57 AM
Originally posted by gopherhockey

Anything related to the post count. Post counts still increase. A user will still see hundreds or thousands of new posts since they last visited. The problem is, with all the edits above they are confused when they see XX posts since they last visited, click on view new posts since last online and get the "sorry, there are no new posts since you last visited" message.

Can anyone provide this missing link?

By default vb does not tell user there is XX posts since their last visit so I guess what you are asking is to hack Welcome Panel or a similiar hack that displays this info?

If this is welcome panel hack, the solution that ignores your forum in the query above will work for this hack too. So in index.php find,


$getnewthread=$DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE lastpost > '$bbuserinfo[lastvisit]'");

$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]'");

And replace it as:


$getnewthread=$DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE lastpost > '$bbuserinfo[lastvisit]' AND forumid!=X");

$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]' AND forumid!=X");


Enjoy..

gopherhockey
03-10-2003, 01:57 PM
Close, but adding that to a posts query always gives me a SQL error...

One of the displays I run is actually a hack (welcome message on non-vb page) - however, the index.php for vb has the following:

// get total posts
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=number_format($countposts['posts']);

This one isn't as critical because people don't really seem to watch it closely, but for the purposes of this hack I'd like to have the stats not show here either.

I've tried doing something similar to your threads solution with your code (for a hack) or something like this (for index.php):

$totalposts=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE forumid!=X");


But then I get a SQL error:

Invalid SQL: SELECT count(*) AS posts FROM post WHERE forumid!=50
mysql error: Unknown column 'forumid' in 'where clause'


Actually I wonder if I'm taking the wrong road with this whole thing and should be hitting this from the other side of things.. what I mean is, instead of allowing vb to continue to count posts from this forum and masking them in displays - wouldn't there be a way to just not count them at the time some counter is increased?

I'd be happy either way I guess.. I just always get a SQL error when adding the term forumid!=XX to the post count line(s) regardless of it being a hack or being index.php...

Logician
03-10-2003, 04:36 PM
My solution will work with new thread count because that table saves forum id for all threads. So adding forumid!=X will work for thread count in welcome panel hack.

However as for post count this solution does not work, because post count is retrieved from posts table and that table does not have any referrence to the forumid of the posts.

A work around might be using this trick:
Hack your gateway hack so that it posts with a special username (a fake username that does not belong to any member but a bot). Then you can exclude it in your query to get accurate results: Eg.


$getnewthread=$DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE lastpost > '$bbuserinfo[lastvisit]' AND forumid!=X");

$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]' AND username!=X");

gopherhockey
03-10-2003, 06:14 PM
Hey, we're getting closer... at least to solving my gateway, but not the original problem.

I get the following error, however, when using the code you suggested. (all posts from the NNTP gateway are posted under userid "Guest"):



Invalid SQL: SELECT count(*) AS posts FROM post WHERE dateline > '1047312216' AND username!=Guest
mysql error: Unknown column 'Guest' in 'where clause'

Original line:

$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]'");

Updated code that gives error:

$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]' AND username!=Guest");

Is Guest perhaps not a real username, at least in the way other usernames are treated? I'll try another (real) userid, I think it is pretty clear how to do that in the gateway code.

Logician
03-10-2003, 06:35 PM
$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]' AND username!='Guest'");

Logician
03-10-2003, 06:53 PM
please notice the ' signs covering username in my last code..

gopherhockey
03-10-2003, 07:37 PM
Yea, I posted too quickly and didn't see your answer.

I don't get a SQL query error, however - ignoring "Guest" doesn't seem to work - it still shows new posts from that gateway.

If I use an ID that is an actual user on the system, however, it works... so now I just need to find out from the author of that hack how to change the userid it uses when posting...

Thx.

gopherhockey
03-10-2003, 07:59 PM
I did it... you use the userid instead of username...

To ignore posts totals from the guest user, simply edit your index.php and change:

$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');

to:

$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post WHERE userid!=0');


If you run a script such as webwelcome where it picks out the number of posts since the user last logged in, just find the line:

$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]'");

and change to:

$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]' AND userid!=0");


HOWEVER - this doesn't solve my initial issue, making a forum transparent. Apparently since the forumid is not logged to the posts table, this might be impossible unless we add a column to the table such as "ignoreforum" and set it to 1 or 0 when posting items for that forum. Then we could look for ignoreforum!=1 and it would probably work.

Problem is, I don't know enough to do that.. but I'll keep looking. I know in my original case the NNTP gateway hack did add an "isnntpgateway" column which I could have used. If I can figure out how it is setting this, I can probably complete this "hack" (so to speak)

Dan_UPC
10-03-2003, 01:07 PM
HOWEVER - this doesn't solve my initial issue, making a forum transparent. Apparently since the forumid is not logged to the posts table, this might be impossible unless we add a column to the table such as "ignoreforum" and set it to 1 or 0 when posting items for that forum. Then we could look for ignoreforum!=1 and it would probably work.

To ignore posts (from a particular forum) on index.php this should work ...

$totalposts=$DB_site->query_first("SELECT count(*) AS posts FROM post, thread WHERE post.threadid=thread.threadid AND thread.forumid!=X");

I think it will probably do a full table scan of the thread table but it does work.