PDA

View Full Version : [RELEASE v2] Top Posters


tubedogg
Wed 9th May '01, 11:06am
To all my loyal "fans" and others:
I am sorry to withdraw this hack. However there are so many problems with it it's just not worth putting you guys through it. Therefore I am ceasing work on it and will no longer be able to support it.

To remove the hack, run the following query from phpMyAdmin or Telnet:
DELETE FROM template WHERE title='toppostall' OR title='toppost24' OR title='topposttoday'

then "un-make" the changes you made to index.php and admin/functions.php. These are:

Remove from index.php
if ($loadtoppost==1) {
$today = mktime(0,0,0); $yesterday = $today-86400;

$toptemp = gettemplate('toppost24',0,0);
$top24 = explode("|||",$toptemp);
if ($top24[0] != $yesterday and $top24[1] != $today) {
gettop24();
$top24 = gettemplate('toppost24',0,0);
$top24 = explode("|||",$top24);
}
$ttopthreadname = $top24[2]; $ttopthreadnum = $top24[3]; $ttoppostname = $top24[4]; $ttoppostnum = $top24[5];
$tttu = $top24[6]; $ttpu = $top24[7];

gettoptoday();
$toptoday = gettemplate('topposttoday',0,0);
$toptoday = explode("|||",$toptoday);
$tttopthreadname = $toptoday[0]; $tttopthreadnum = $toptoday[1]; $ttttu = $toptoday[2];
$tttoppostname = $toptoday[3]; $tttoppostnum = $toptoday[4]; $tttpu = $toptoday[5];

$topatemp = gettemplate('toppostall',0,0);
$topall = explode("|||",$topatemp);
if ($topall[0] != $today) {
gettopall();
$topall = gettemplate('toppostall',0,0);
$topall = explode("|||",$topall);
}
$topthreadname = $topall[1]; $topthreadnum = $topall[2]; $toppostname = $topall[3]; $toppostnum = $topall[4];
$topthreaddate = date($dateformat,$topall[5]); $toppostdate = date($dateformat,$topall[6]);
$ttu = $topall[7]; $tpu = $topall[8];
eval("\$topposterinfo = \"".gettemplate('topposters')."\";");
}
$templatesused.=",topposters";
$loadtoppost=1;

From admin/functions.php, change
global $templatecache,$DB_site,$templatesetid,$loadmaxuse rs,$loadbirthdays,$loadtoppost;
to
global $templatecache,$DB_site,$templatesetid,$loadmaxuse rs,$loadbirthdays;
Then remove
".iif ($loadtoppost,"OR (title = 'toppostall')","")."
".iif ($loadtoppost,"OR (title = 'toppost24')","")."
".iif ($loadtoppost,"OR (title = 'topposttoday')","")."
// ###################### Start gettoptoday #######################
function gettoptoday() {
global $DB_site;
$today = mktime(0,0,0); $tommorrow = $today+86400;
$ttopt = $DB_site->query_first("SELECT userid,COUNT(*) AS threads,username FROM thread,user WHERE dateline>=$today AND dateline<=$tommorrow AND postuserid>0 AND postuserid=userid GROUP BY postusername ORDER BY threads DESC");
$ttopp = $DB_site->query_first("SELECT user.username AS uuname,COUNT(*) AS posts,user.userid AS uuid FROM post,user WHERE dateline>=$today AND dateline<=$tommorrow AND post.userid>0 AND user.userid=post.userid GROUP BY post.username ORDER BY posts DESC");
$sep = "|||";
if ($ttopt[username] == "") {
$ttopt[username] = "No one yet";
$ttopt[userid] = 0;
$ttopt[threads] = 0;
}
if ($ttopp[uuname] == "") {
$ttopp[uuname] = "No one yet";
$ttopp[uuid] = 0;
$ttopp[posts] = 0;
}
$template = "$ttopt[username]$sep$ttopt[threads]$sep$ttopt[userid]$sep$ttopp[uuname]$sep$ttopp[posts]$sep$ttopp[uuid]";
$DB_site->query("UPDATE template SET template='".addslashes($template)."' WHERE title='topposttoday'");
}

// ###################### Start gettop24 #######################
function gettop24() {
global $DB_site;
$today = mktime(0,0,0); $yesterday = $today-86400;
$ttopt = $DB_site->query_first("SELECT username,COUNT(*) AS threads,userid FROM thread,user WHERE dateline<=$today AND dateline>=$yesterday AND postuserid>0 AND postuserid=userid GROUP BY postusername ORDER BY threads DESC");
$ttopp = $DB_site->query_first("SELECT user.username AS uuname,COUNT(*) AS posts,user.userid AS uuid FROM post,user WHERE dateline<=$today AND dateline>=$yesterday AND post.userid>0 AND user.userid=post.userid GROUP BY post.username ORDER BY posts DESC");
$sep = "|||";
$template = "$yesterday$sep$today$sep$ttopt[username]$sep$ttopt[threads]$sep$ttopp[uuname]$sep$ttopp[posts]$sep$ttopt[userid]$sep$ttopp[uuid]";
$DB_site->query("UPDATE template SET template='".addslashes($template)."' WHERE title='toppost24'");
}

// ###################### Start gettopall #######################
function gettopall() {
global $DB_site, $topall;
$today = mktime(0,0,0); $yesterday = $today-86400;
$topt = $DB_site->query_first("SELECT username,COUNT(*) AS threads,userid FROM thread,user WHERE dateline<=$today AND dateline>=$yesterday AND postuserid>0 AND postuserid=userid GROUP BY postusername ORDER BY threads DESC");
$topp = $DB_site->query_first("SELECT user.username AS uuname,COUNT(*) AS posts,user.userid AS uuid FROM post,user WHERE dateline<=$today AND dateline>=$yesterday AND post.userid>0 AND user.userid=post.userid GROUP BY post.username ORDER BY posts DESC");
$topalle = explode("|||",$topall);
if ($topalle[4] < $topp[posts]) {
$toppb = $topp[posts]; $toppa = $topp[uuname];
$toppd = $yesterday; $toppc = $topp[uuid];
} else {
$toppb = $topalle[4]; $toppa = $topalle[3];
$toppd = $topalle[6]; $toppc = $topalle[8];
}
if ($topalle[2] < $topt[threads]) {
$toptb = $topt[threads]; $topta = $topt[username];
$toptd = $yesterday; $toptc = $topt[userid];
} else {
$toptb = $topalle[2]; $topta = $topalle[1];
$toptd = $topalle[5]; $toptc = $topalle[7];
}
$sep = "|||";
$template = "$today$sep$topta$sep$toptb$sep$toppa$sep$toppb$sep $toptd$sep$toppd$sep$toptc$sep$toppc";
$DB_site->query("UPDATE template SET template='".addslashes($template)."' WHERE title='toppostall'");
}

Finally, remove the custom template topposters.

This should remove the hack completely from your vBulletin installation.

BradC
Wed 9th May '01, 2:30pm
That is great...! thanks :)

can't wait to get out of my C++ class and try this out :)

is there a way.. to have a Member of the Month or Week hack...? I seen it in UBB.. just curious

ztsky
Wed 9th May '01, 5:17pm
Parse error: parse error in ./admin/functions.php on line 49

Fatal error: Call to undefined function: getuserinfo() in ./admin/sessions.php on line 300

Warning: Unable to call doshutdown() - function does not exist in ./admin/sessions.php on line 300

AS_Eagle_1
Wed 9th May '01, 5:25pm
Hello Kevin,
I'm a fan of your Hacks :)
but this one makes some troubles.
i run the topinstall.php in my browser and come directly to the page where the instructons are. the script doesn't modify my DB.
when i upload the modified index.php and functions.php i'll get a parse error.
Parse error: parse error in url/board/admin/functions.php on line 49

Fatal error: Call to undefined function: getuserinfo() in url/board/admin/sessions.php on line 300

can you help me?


*sorry for my bad english i hope u can understand me*

Sarge
Wed 9th May '01, 5:58pm
will this work on beta 3?
Thanks
Chris

tubedogg
Thu 10th May '01, 6:07am
I have hopefully fixed all of the problems listed and then some with v0.5, released in the first post in this thread. I apologize again to this who previously tried to install this.

If you did previously install this, please start again with fresh copies of index.php and admin/functions.php. Same directions: upload topinstall.php to your admin directory and follow the instructions in it.

jojo85
Thu 10th May '01, 6:28am
Ohhh very nice :)
will add it on my site tonight,thx very much guy

Blue2000
Thu 10th May '01, 2:17pm
very nice hack mate


works well too. :D

jojo85
Thu 10th May '01, 2:43pm
it is possible to add this hack to a non-vbpage ?
if yes,how?

furious
Thu 10th May '01, 8:26pm
i follow all the steps but nothing change on my forum
what can i do?

tubedogg
Thu 10th May '01, 8:39pm
Nothing changes...do you mean it doesn't appear on your front page? If that's the case, make sure you edited the forumhome template (make sure, if you have multiple template sets, you edited the template set you are using on your site!). Can you be a little more specific?

furious
Thu 10th May '01, 8:42pm
i follow all the steps, i make all the modifications including the forumhome template but there is nothing new, no top poster :(
it doesnt appear
and i havent multiple template set

chrispadfield
Thu 10th May '01, 8:43pm
another cool hack :) cheers.

furious
Thu 10th May '01, 8:50pm
wow i need some sleep (its 2.46am here)
i'm sorry its working fine
i forgot $loadtoppost=1; in index.php, i put twice $loadmaxusers=1; instead

very nice hack :)

tubedogg
Thu 10th May '01, 8:59pm
Chris: Thanks ;)

Furious: I'm glad you found it...I couldn't figure out for the life of me why it wouldn't show! :)

furious
Thu 10th May '01, 9:01pm
is it possible to include the top poster and the top thread starter not only on one day but since the beginning?

almighty one
Thu 10th May '01, 9:06pm
ok ok i need some help here i installed hack and now i get an error i am dumb to this so please dont flame me



Fatal error: Call to undefined function: gettop24() in /home/websites/my****/vbb/folder1/index.php on line 207
do i need to rename soemthing to match the 24 or get rid of it or what is the deal i do have the timezones hack installed

almighty one
Thu 10th May '01, 9:09pm
and should this look like this

if ($loadtoppost==1) {
$top24 = gettemplate('toppost24',0,0);
$top24 = explode("|||",$top24);
if ($top24[0] != $yesterday and $top24[1] != $toda
is the loadtoppost = = supposed to be 2 =?

tubedogg
Thu 10th May '01, 9:15pm
OK did you modify your functions.php (in your admin directory) and reupload that to the server?

Yes the double equal sign is correct.

supernut
Thu 10th May '01, 10:10pm
would be nice to add a cron job to post the stats at the end of the day in a forum for every to look back on anytime they want ?

nice to also PM the top members with a well done ?

almighty one
Thu 10th May '01, 10:11pm
has anyone else installed tis hack and it show the top posters area and show everything except the posters name and the number of posts and if so how did you fix it if you did fix it

-DLoH-hammer
Fri 11th May '01, 9:43am
get this error message

Database error in vBulletin: Invalid SQL: SELECT user.username AS uuname,COUNT(*) AS
posts,userid.userid AS uuid FROM post,user WHERE dateline<=989532000 AND dateline>=989445600 AND
post.userid>0 AND user.userid=post.userid GROUP BY post.username ORDER BY posts DESC
mysql error: Unknown table 'userid' in field list
mysql error number: 1109
Date: Friday 11th of May 2001 03:39:10 PM
Script: /forum/index.php

-DLoH-hammer
Fri 11th May '01, 10:04am
i crosschecked my installation and found all changes are ok

but i have run the bits installation more times :( is this possible the error ? how to undo the changes? without install backups or new database ?????????

insdel
Fri 11th May '01, 10:31am
I got some problems too - I'have installed the hack without any hassle and everything seemed to work fine. But now my index.php doesn't show up any moreand only this message appears:

There seems to have been a slight problem with the database. Please try again by pressing the refresh button in your browser.
An E-Mail has been dispatched to our Technical Staff, who you can also contact if the problem persists.
We apologise for any inconvenience.

However I didn't get any mails from the board. And all the other php Files like forumdisplay.php etc work.
The inserted code seems okay. I only installed one other style yesterday - this can't be the problem, can it?
Please help!

-DLoH-hammer
Fri 11th May '01, 11:50am
its the same error but i post the email text i got from my forum

with clean index.php forum runs but i cant reinstall the hack it causes above error

almighty one
Fri 11th May '01, 2:11pm
i had allt he errors too but now i cn not view the peoples names or number of posts it just has an empty space there instead of name and number :(

insdel
Fri 11th May '01, 4:00pm
just got some error mails from my server and they are ecactly the same ones -DLoH-hammer and almighty one got.
Now it works too, but there is an empty space instead of the username that sould show up.
Seems that's a bug if it applies to us all.

AS_Eagle_1
Fri 11th May '01, 4:09pm
I had the same probs like the others. I make a search in my DB and found the toppost24, toppostall, topposttoday templates twice or more in the template table. I delete them and reinstall the hack. now it runs.

insdel
Fri 11th May '01, 4:40pm
deleting the top* tables and re-installing the hack as AS_Eagle_1 suggested did not work for me. I still do not get valid output from the script - only the stats of today are show up correctly. The others do not even show up :(

tubedogg
Fri 11th May '01, 8:22pm
Originally posted by -DLoH-hammer
get this error message

Database error in vBulletin: Invalid SQL: SELECT user.username AS uuname,COUNT(*) AS
posts,userid.userid AS uuid FROM post,user WHERE dateline<=989532000 AND dateline>=989445600 AND
post.userid>0 AND user.userid=post.userid GROUP BY post.username ORDER BY posts DESC
mysql error: Unknown table 'userid' in field list
mysql error number: 1109
Date: Friday 11th of May 2001 03:39:10 PM
Script: /forum/index.php

In functions.php, find
// ###################### Start gettopall #######################
function gettopall() {
global $DB_site, $topall;
$today = mktime(0,0,0); $yesterday = $today-86400;
$topt = $DB_site->query_first("SELECT username,COUNT(*) AS threads,userid FROM thread,user WHERE dateline<=$today AND dateline>=$yesterday AND postuserid>0 AND postuserid=userid GROUP BY postusername ORDER BY threads DESC");
$topp = $DB_site->query_first("SELECT user.username AS uuname,COUNT(*) AS posts,userid.userid AS uuid FROM post,user WHERE dateline<=$today AND dateline>=$yesterday AND post.userid>0 AND user.userid=post.userid GROUP BY post.username ORDER BY posts DESC");
and replace it with
// ###################### Start gettopall #######################
function gettopall() {
global $DB_site, $topall;
$today = mktime(0,0,0); $yesterday = $today-86400;
$topt = $DB_site->query_first("SELECT username,COUNT(*) AS threads,userid FROM thread,user WHERE dateline<=$today AND dateline>=$yesterday AND postuserid>0 AND postuserid=userid GROUP BY postusername ORDER BY threads DESC");
$topp = $DB_site->query_first("SELECT user.username AS uuname,COUNT(*) AS posts,user.userid AS uuid FROM post,user WHERE dateline<=$today AND dateline>=$yesterday AND post.userid>0 AND user.userid=post.userid GROUP BY post.username ORDER BY posts DESC");

You should not run install bits more than once, however at this point it will not hurt anything.

tubedogg
Fri 11th May '01, 8:25pm
For the rest of you, please read my previous message ^^^^ and make those changes to your functions.php file. I have updated the install file with the new instructions; if you wish, you can upload that to your admin directory and go to it in a browser to view them, however DO NOT click the install bits link again if you have already done so.

jojo85
Sat 12th May '01, 1:05am
Originally posted by tubedogg
OK did you modify your functions.php (in your admin directory) and reupload that to the server?

Yes the double equal sign is correct.


hey tubbedog,it is possible to add this hack to a non-vb page?

tubedogg
Sat 12th May '01, 1:27am
Not currently. However there is a top poster's script in my sig that works for pages outside of vBulletin.

NickyNet
Sat 12th May '01, 4:56am
tubedogg,

great hack

thank you

jojo85
Sat 12th May '01, 6:53am
Originally posted by tubedogg
Not currently. However there is a top poster's script in my sig that works for pages outside of vBulletin.

Yes i know,thx very much guy :)

Froschie
Sat 12th May '01, 12:28pm
I have Installed your Top Poster script on our Board... (http://ra.tribes.de/vb)
could it be, that your scirpt doen´t work correct ?


Yesterday's Top Poster: Froschie, with 4 posts yesterday
Yesterday's Top Thread Starter: Melvin, with 3 threads started yesterday
Today's Top Poster at this hour: Froschie, with 12 posts today
Today's Top Thread Starter at this hour: Melvin, with 4 threads started today
Most posts in one day: Froschie, with 4 posts on 12.05.2001
Most threads starting in one day: Melvin, with 3 threads started on 12.05.2001


Today's Top Poster at this hour: Froschie, with 12 posts today .... so far it is correct.. but view the Line Most Pots in one day... the is the Entry from yesterday with 4.... but today I have 12 so the Date for the Most Posts in one day must be today !!!!!


even in your Demonstration Picture on the First Site of this Thread there is this Error....
or is this no Error ??

Froschie
Sat 12th May '01, 2:31pm
from functions.php

// ###################### Start gettop24
...
$ttopt = $DB_site->query_first("SELECT username,COUNT(*) AS threads,userid FROM thread,user WHERE dateline<=$today AND dateline>=$yesterday AND postuserid>0 AND postuserid=userid GROUP BY postusername ORDER BY threads DESC");
$ttopp = $DB_site->query_first("SELECT user.username AS uuname,COUNT(*) AS posts,user.userid AS uuid FROM post,user WHERE dateline<=$today AND dateline>=$yesterday AND post.userid>0 AND user.userid=post.userid GROUP BY post.username ORDER BY posts DESC");
...

// ###################### Start gettopall
...
$topt = $DB_site->query_first("SELECT username,COUNT(*) AS threads,userid FROM thread,user WHERE dateline<=$today AND dateline>=$yesterday AND postuserid>0 AND postuserid=userid GROUP BY postusername ORDER BY threads DESC");
$topp = $DB_site->query_first("SELECT user.username AS uuname,COUNT(*) AS posts,user.userid AS uuid FROM post,user WHERE dateline<=$today AND dateline>=$yesterday AND post.userid>0 AND user.userid=post.userid GROUP BY post.username ORDER BY posts DESC");
...


so the MySQL Request for Yesterday and for All Time are equal... hmmm this must be the error.. because of the "WHERE dateline<=$today AND dateline>=$yesterday" the result must be equal...

so I understand PHP / MySQL but my coding capability is not so good.. but I think this MySQL Request must be done in an Loop for every day...

but this would not be very good for the Forum Speed... so I think the resolution can be (only my thoughts about it, may be you know a better way (I think so)) that with the installation of the script that in this moment the install script creates a template Field in the Database, where it writes the Values for All Time...
and in the normal Code sequenzen in the functions.php could be an entry, that the script updates the Template "All Time" Record to the new Value if "Today" is higher than "All Time"....

is this correct ?

tubedogg
Sat 12th May '01, 9:14pm
The result is equal yes, because it's looking for the same info.

Your are basically correct about how it works (writing to the template and all).

The problem you mention was an oversight on my part. I used $today when I should have used $yesterday.

To fix it, find in functions.php
$toptd = $today; $toptc = $topt[userid];
and replace it with
$toptd = $yesterday; $toptc = $topt[userid];
Then find
$toppd = $today; $toppc = $topp[uuid];
and replace it with
$toppd = $yesterday; $toppc = $topp[uuid];

I've updated the install file in the first post with this too.

Sarge
Sun 13th May '01, 4:02am
Mine seems to work. Maybe it is because of the excellent install job I did :)

Good hack

NickyNet
Sun 13th May '01, 6:23am
@tubedogg,

i just replaced the codes in my functions.php...

and i have now this: (sorry is in german;))

13.05.2001

Die meisten Beiträge geschrieben am einen Tag: Nicky, mit 6 Beiträgen am 13.05.2001
Die meisten Themen gestarten am einen Tag: LiTLe-LiOn, mit 2 Themen am 13.05.2001


14.05.2001

Die meisten Beiträge geschrieben am einen Tag: Citycobra, mit 6 Beiträgen am 13.05.2001
Die meisten Themen gestarten am einen Tag: Nicky, mit 2 Themen am 13.05.2001


well i installed the updated hack...

top poster for one day i'll get from yesterday :confused:

insdel
Sun 13th May '01, 6:42am
Still got problems again after changing the code...
Before it seemed to work okay, but after i replaced the strings above. It does show up nothing again.
I'm pretty confused now :)

Froschie
Sun 13th May '01, 6:19pm
so here is the Top Poster script from today and yesterday (23:30)
you can see that "most posts in one day" is equal to "yesterday's"


13.05.2001
Yesterday's Top Poster: Froschie, with 17 posts yesterday
Yesterday's Top Thread Starter: RA-Cyb, with 5 threads started yesterday
Today's Top Poster at this hour: Froschie, with 10 posts today
Today's Top Thread Starter at this hour: Melvin, with 4 threads started today
Most posts in one day: Froschie, with 17 posts on 13.05.2001
Most threads starting in one day: RA-Cyb, with 5 threads started on 13.05.2001

14.05.2001
Yesterday's Top Poster: Froschie, with 10 posts yesterday
Yesterday's Top Thread Starter: Melvin, with 4 threads started yesterday
Today's Top Poster at this hour: No one yet, with 0 posts today
Today's Top Thread Starter at this hour: No one yet, with 0 threads started today
Most posts in one day: Froschie, with 10 posts on 13.05.2001
Most threads starting in one day: Melvin, with 4 threads started on 13.05.2001


the fault is in the MySQL Request, which is equl to the Request for "yesterday" (which I posted yesterday)


so what do you think is the resulution ? I have no time for coding until Tuesday but, after this I can code something but my Resolution with an MySQL request for every day since start of the Forum would make very intensive MySQL Requests...
so a resolution with an Template would be fine....
but for that, I don´t have the coding capability....

so I hope you can code something.... your Code changes, you posted yesterday, don´t changed anything in the MySQl request...



or could it be something different
on your "demo" image at the first thread Page is "all time top poster" and in your newer script Versions "most post in one day"

what means the one day ? in the last 24h ? or on ANY Day in the past ?

(sorry when a sentence don´t make sense, but I can not perfectly english)

tubedogg
Sun 13th May '01, 8:42pm
There is NO FAULT with the query for the top posters. It checks the currently "record" and compares that to the previous day's post and thread numbers. If, during the previous 24 hours, there was someone who more posts or threads, it replaces the old record with the new record.
When you install the hack, it looks at the day prior to the installation time and sets the record based on that. Then, on the second day it is installed, it compares the record to the day you installed the hack. And on the third day, it compares the record to the second day. And so on and so on. It does not look back beyond the day prior to the day you installed the hack.

The problem here is the installation of the new code, which reset the stats. Wait three days and look at it each day. It should start recording correctly. If it does not, then please come back and show me the stats for each day.

Kier
Sun 13th May '01, 10:38pm
Closed by request.