PDA

View Full Version : Thread... Post... and Reply Count...


g-force2k2
08-19-2002, 10:00 PM
It's really a quick hack but i thought i'd release it because maybe some members would find interest in it... requested by Barret... it requires only a file edit and template edit... yes a smaller hack ;) i usually try to stay away from them because i like challenges...

open admin/functions.php

find:

$post[joindate]=vbdate($registereddateformat,$post[joindate]);

above it add:

global $DB_site;
$threads = $DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE postuserid='$post[userid]'");
$post[threads] = $threads['threads'];
$post[replies] = $post[posts] - $post[threads];

the open the postbit template and place $post[threads] and/or $post[replies] wherever you like... hopefully it'll be useful to some member...

Enjoy ;)

g-force2k2

ZiRu$
08-20-2002, 02:14 AM
good idea......i will not use it though.........incourages spamming.......hidin post count is cool

LOD-squa
08-20-2002, 02:58 AM
It's a good idea but I really like for people to see postcount.

altmac
08-20-2002, 03:43 AM
Could we set this in the header as well?

g-force2k2
08-20-2002, 03:50 AM
you mean on the index.php?

g-force2k2

altmac
08-20-2002, 03:55 AM
Yeah, nevermind, I figured it out.

ULTIMATESSJ
08-20-2002, 10:45 AM
pretty good stuffs, nice work

N9ne
08-20-2002, 01:25 PM
So this shows how many replies and how many topics each user has done?

g-force2k2
08-20-2002, 01:34 PM
yep thats right Tha Rock you can put what ever you want in the postbit template... if you want all three to show then use them all...

$post[posts]
$post[threads]
$post[replies]

else just put whichever ones that you want to show...

g-force2k2

Attrox
08-20-2002, 03:31 PM
Hmm...nice hack and all, but I don't think I'll be using this.

Xenon
08-20-2002, 08:10 PM
it'll add one extra query per post as i see.
you should optimize it, so it'll cache values it has already ;)

g-force2k2
08-21-2002, 02:15 AM
Xenon could you explain to me what you mean... i kinda have an idea... but i want to learn... after all thats why im hacking ;)

g-force2k2

kmfdm_kid2000
08-21-2002, 10:03 AM
Hey, this is good, my members have been asking for this. Works great, easy install. I only use the Thread count variable, not the replies as well. It's interesting to see people's stats though...

FFMania
08-21-2002, 10:12 AM
Nice Hack...but I already have too much things in my postbit so...not for me XD

Xenon
08-21-2002, 03:26 PM
@g-force:
you should replace this:$threads = $DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE postuserid='$post[userid]'");
$post[threads] = $threads['threads'];
$post[replies] = $post[posts] - $post[threads];

with something like this:
if(!isset($threads[$post[userid]])) {
$threads[$post[userid]] = $DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE postuserid='$post[userid]'");
}
$post[threads] = $threads[$post[userid]['threads'];
$post[replies] = $post[posts] - $post[threads];

this should reduce the querys if the same user has two or more posts in one thread on the displaying page ;)

Ice Man_00
09-01-2002, 11:16 AM
Great hack, but i`m keep getting a parse error in line 188 in that file :(

(Using vbb 2.2.7 - Works here ??)

Thx

Chris M
09-01-2002, 11:47 AM
I thought I had a solution, but then I found :

Fatal error: Call to a member function on a non-object in /home/virtual/site26/fst/var/www/html/forums/admin/functions.php on line 198

Satan

Ice Man_00
09-01-2002, 01:02 PM
Thx for helping out anyway :)

g-force2k2
09-01-2002, 04:06 PM
you can just use my original coding on post#15... Xenon made the first coding and im not sure whats up with it... but i'll test it later and find out whats up... regards...

g-force2k2

Chris M
09-01-2002, 04:13 PM
Thanks g-force:)

Satan

Chris M
09-01-2002, 04:15 PM
Fatal error: Call to a member function on a non-object in /home/virtual/site26/fst/var/www/html/forums/admin/functions.php on line 196

Satan

g-force2k2
09-01-2002, 04:20 PM
did you use my first coding not Xenon's code? regards...

g-force2k2

Chris M
09-01-2002, 04:25 PM
I used yours this time...

Satan

g-force2k2
09-01-2002, 04:28 PM
okay then above my code add this see if that works ;) regards...

global $DB_site;

g-force2k2

Chris M
09-01-2002, 04:36 PM
Yes...

Thanks it works now:D

Satan

Ice Man_00
09-01-2002, 10:46 PM
global $DB_site;
if(!isset($threads[$post[userid]])) {
$threads[$post[userid]] = $DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE postuserid='$post[userid]'");
}
$post[threads] = $threads[$post[userid]['threads'];
$post[replies] = $post[posts] - $post[threads];

As you can see i have tried it with and without global.

Still getting a parse error.
Not a big deal, just wanted you to know :)

Cheers

g-force2k2
09-02-2002, 01:32 AM
Ice Man 00 change the coding to what i first have on post#15 not the coding that Xenon created... and then add the global $DB_site; regards...

g-force2k2

squawell
09-02-2002, 02:12 PM
cant work for me......:(

no error....just nothing happen

so strange........:(:(

g-force2k2
09-02-2002, 03:21 PM
squawell

change the code and replace it with this instead:

global $DB_site;
$threads = $DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE postuserid='$post[userid]'");
$post[threads] = $threads['threads'];
$post[replies] = $post[posts] - $post[threads];

i will fix the first post i guess it just seems that Xenon's coding doesn't work exactly... regards...

g-force2k2

Learner29
09-12-2002, 05:05 AM
I LOVE THIS HACK !!!!!!!

THANK YOU g-force2k2

(i know am shouting.... ) :$

Exo
11-20-2002, 10:57 PM
Why use this Hack so much queries? The normal post counter does that not!

Bison
09-06-2003, 08:30 PM
08-21-02 at 12:26 PM Xenon said this in Post #15 (https://vborg.vbsupport.ru/showthread.php?postid=288310#post288310)
@g-force:
you should replace this:$threads = $DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE postuserid='$post[userid]'");
$post[threads] = $threads['threads'];
$post[replies] = $post[posts] - $post[threads];

with something like this:
if(!isset($threads[$post[userid]])) {
$threads[$post[userid]] = $DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE postuserid='$post[userid]'");
}
$post[threads] = $threads[$post[userid]]['threads'];
$post[replies] = $post[posts] - $post[threads];

this should reduce the querys if the same user has two or more posts in one thread on the displaying page ;)

Could you revise your code to limit the amount of queries this hack produces?

Thanks in advance Xenon!

Xenon
09-06-2003, 08:44 PM
well the code should work i'd say