View Full Version : this should be very simple.....
i got a already made hack that couts the number of theads you started in a certain section... i was wondering if any one could take the code.... and make a top 10 list for it???? it should be very simple i belive
thanks for your time... if you can please post here and i will post the code to work from
Thanks!
kinda like
Top 10 Posters
Username Posts
joe 8
make 6
john 5
fred 1
stinky 1
jack 0
barney 0
juan 0
but it would be like a top 10 thread for certain forums on the board
Ok I don't know if this will work cuz I don't know a whole lot about php but it's modeled after the Top 5 Hack. If it don't work sorry, I just kinda guessed a bit and my forum is down :(, but if it doesn't work I would like to see a working one to see what I did wrong. I hope I at least got close. :D
Find this
$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$numbermembers=number_format($numbersmembers['users']);
Add Under That
// Top 10 Posters in a certain thread
$top10 = $DB_site->query('SELECT userid,username,posts FROM thread WHERE forumid=# ORDER BY posts DESC LIMIT 10');
while ($top10thread = mysql_fetch_array($top10)):
++$top10threadnbsp;
$top10name .= "? <a href=member.php?s=$session[sessionhash]&action=getinfo&userid=$top10thread[userid]>$top10thread[username]</a><br>";
$top10post .= "$top10thread[posts]<br>";
endwhile;
// End Top 10 Posters in a certain thread
Put these on your main page(index.php) somewhere.
$top10thread is the list of users with the most posts
$top10name is there names
$top10post is the amt of posts each user has
i get this error
Database error in vBulletin 2.2.4:
Invalid SQL: SELECT userid,username,posts FROM thread WHERE forumid=14 ORDER BY posts DESC LIMIT 10
mysql error: Unknown column 'userid' in 'field list'
mysql error number: 1054
ok this might help alittle.... all i want is the first hack below working with the second hack
*********************************
In showthread.php, replace this:
*********************************
$getpostids=$DB_site->query("
SELECT post.postid FROM post
WHERE post.threadid='$threadid' AND post.visible=1
ORDER BY dateline $postorder LIMIT ".($limitlower-1).",$perpage
");
if ($limitupper>$totalposts) {
$limitupper=$totalposts;
if ($limitlower>$totalposts) {
$limitlower=$totalposts-$perpage;
}
}
if ($limitlower<=0) {
$limitlower=1;
}
$postids="post.postid IN (0";
while ($post=$DB_site->fetch_array($getpostids)) {
$postids.=",".$post['postid'];
}
$postids.=")";
*********************************
with this:
*********************************
$getpostids=$DB_site->query("
SELECT post.postid,post.userid AS postuserid FROM post
WHERE post.threadid='$threadid' AND post.visible=1
ORDER BY dateline $postorder LIMIT ".($limitlower-1).",$perpage
");
if ($limitupper>$totalposts) {
$limitupper=$totalposts;
if ($limitlower>$totalposts) {
$limitlower=$totalposts-$perpage;
}
}
if ($limitlower<=0) {
$limitlower=1;
}
$postids="post.postid IN (0";
$hackuserids="(0";
while ($post=$DB_site->fetch_array($getpostids)) {
$postids.=",".$post['postid'];
$hackuserids.=",".$post['postuserid'];
}
$postids.=")";
$hackuserids.=")";
$hacks=array();
$hackcounts=$DB_site->query("SELECT postuserid,COUNT(*) AS totalhacks FROM thread WHERE forumid IN (x) AND postuserid IN $hackuserids GROUP BY postuserid");
while ($hackcount=$DB_site->fetch_array($hackcounts)) {
if (!isset($hackcount[totalhacks]))
$hackcount[totalhacks]=0;
$hacks["$hackcount[postuserid]"]=$hackcount[totalhacks];
}
$hacks[0]=0;
*********************************
Still in showthread.php, add this:
*********************************
if ($hacks["$post[userid]"]!='') {
$post[hacks]="<a href=\"member.php?s=$session[sessionhash]&action=getinfo&userid=$post[userid]\">".$hacks["$post[userid]"]."</a>";
} else {
$post[hacks]=0;
}
*********************************
right after this:
*********************************
while ($post=$DB_site->fetch_array($posts) and $counter++<$perpage) {
*********************************
Then use $post[hacks] in the postbit template to show the number of threads the user started in that forum. It will link to the user profile if he has more than 0 threads.
i want that code above to display in this type of form
<?php
//..........Top X Posters v0.0.4..........\\
//......by Kevin (kevin@tubescan.com)......\\
// For vBulletin version 2, beta 3
// (c) 2001 Jelsoft Enterprises, Ltd.
// vBulletin.com thread: http://www.vbulletin.com/forum/showthread.php?threadid=12067
///////////// CHANGE LOG /////////////
//
// New in version 0.0.4
// -- Fixed alternating colors so they are horizontal, not vertical
// -- Changed $path to $url and $path2 to $path to make variables easier
// -- Added a seperate header row color
//
// New in version 0.0.3
// -- Added option to exclude admins from list of posters
//
// New in version 0.0.2
// -- Fixed a small bug with the path.
//
// New in version 0.0.1
// -- Released! :)
//
/////////// END CHANGE LOG ///////////
//////// CONFIG EXPLANATION //////////
//
// a] $maxposters > This is the number of posters you want to show.
// b] $hc > The head row color.
// c] $bc1 and $bc2 > These are the first and second alternating color.
// d] $text and $link > Set the colors of the main text and the color of the links. Make sure this color is visible on both alternating colors.
// e] $font > This is the font(s) to use for display. You can set specific fonts (e.g. Verdana, Arial, etc.) or general font-families (e.g. sans-serif, serif).
// f] $fontsize > Set a point size for your font. Size 8 is about equivelant to <font size=1>. Anything below about 6 will basically be undreadable, so be careful.
// g] $url > This is the URL to your board directory. This is not the path to config.php! Do not put a trailing slash, either.
// h] $path > This *is* the path to your config.php file. This should include the /admin part. NO TRAILING SLASH! (May need a leading slash)
// i] $admins > Set this to "1" to show admins on the list of top posters. Set this to "0" to NOT show admins on the list.
//
////// END CONFIG EXPLANATION ////////
/////////////// CONFIG ///////////////
//
$maxposters = "10"; // change this to the number of posters you want to show. for a top 10 listing, set it to 10, etc.
$hc = "#990000"; // change to head row color.
$bc1 = "#777777"; // change to first alternating color.
$bc2 = "#555555"; // change to second alternating color.
$text = "#CCCCCC"; // change to text color.
$link = "#EEEEEE"; // change to link color.
$font = "Verdana,Helvetica,sans-serif"; // change to fonts you want. use serif or sans-serif for general, or use specific fonts names.
$fontsize = "8pt"; // change to font size you want. 8 is about the minimum; go up from there. 1 will not even show up.
$url = "http://www.webserver.org/vb/forums"; // path to your board files. (e.g. index.php, member.php, etc.) may need a starting slash. *do not* put an ending slash on!
$path = "/home/pathforconfig/vb"; // path to your config.php file. may need a starting slash. *do not* put an ending slash on!
$admins = "1"; // change this to "0" to leave admins off the list of top posters.
//
///////////// END CONFIG /////////////
require("$path/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord) or die("Unable to connect to database");
mysql_select_db($dbname) or die("Unable to select database $dbname");
if ($admins == "1") {
$exq = mysql_query("SELECT usergroupid FROM usergroup WHERE cancontrolpanel='1'");
$exr = mysql_result($exq,0,0);
$exn = "WHERE usergroupid<>$exr";
}
echo("<table border=0 cellpadding=4 cellspacing=0><tr><td align=\"center\" bgcolor=\"$hc\"><b style=\"color: $text; font-family: $font; font-size: $fontsize\"><i>Username</i></b></td><td align=\"center\" bgcolor=\"$hc\"><b style=\"color: $text; font-family: $font; font-size: $fontsize\"><i>Posts</i></b></td></tr>");
$postsresult = mysql_query("SELECT username,posts,userid FROM user $exn ORDER BY posts desc LIMIT 0,$maxposters") or die("Unable to complete query");
while ($topposters = mysql_fetch_array($postsresult)):
if (($counter++ % 2) != 0) {
$bc=$bc1;
} else {
$bc=$bc2;
}
echo("<tr><td align=\"center\" bgcolor=\"$bc\" style=\"color: $text; font-family: $font; font-size: $fontsize\"><a href=\"$url/member.php?&action=getinfo&userid=$topposters[userid]\" style=\"color: $link\">$topposters[username]</a></td><td align=\"center\" bgcolor=\"$bc\" style=\"color: $text; font-family: $font; font-size: $fontsize\">$topposters[posts]</td></tr>");
endwhile;
echo("</table>");
?>
Originally posted by TaP
i get this error
Database error in vBulletin 2.2.4:
Invalid SQL: SELECT userid,username,posts FROM thread WHERE forumid=14 ORDER BY posts DESC LIMIT 10
mysql error: Unknown column 'userid' in 'field list'
mysql error number: 1054 In the thread table the values are postuserid and postusername.
Originally posted by TaP
i dont understand.??? You need to replace userid and username in that query with postuserid and postusername.
same error..... cant you show a complete peice? im still a bit confused
Originally posted by TaP
same error..... cant you show a complete peice? im still a bit confused This will give you the ten most replied to threads in forum 14:SELECT postuserid,postusername,replycount FROM thread WHERE forumid=14 ORDER BY replycount DESC LIMIT 10I am not sure what you are really looking for, though.
ok that worked i dont get error any more
but in the templates when i add
$top10thread
it doesnt show any thing
i also tried
$top10thread[posts]
OK, before we go any further. What exactly are you trying to do? What do you want a top ten list of?
Well until my forum is back up I'm kind of guessing here, but try this.
// Top 10 Posters in a certain thread
$top10 = $DB_site->query('SELECT postuserid,forumid,postusername,posts FROM thread WHERE forumid = # ORDER BY posts DESC LIMIT 10');
while ($top10thread = mysql_fetch_array($top10)):
++$top10threadnbsp;
$top10name .= "? <a href=member.php?s=$session[sessionhash]&action=getinfo&userid=$top10thread[userid]>$top10thread[username]</a><br>";
$top10post .= "$top10thread[posts]<br>";
endwhile;
// End Top 10 Posters in a certain thread
Then put $top10post and $top10name on your index.php
Database error in vBulletin 2.2.4:
Invalid SQL: SELECT postuserid,forumid,postusername,posts FROM thread WHERE forumid = # ORDER BY posts DESC LIMIT 10
mysql error: You have an error in your SQL syntax near '' at line 1
»
»
is what i get were i inserted the $top10post and $top10name
Well the "forumid = #" part you have to put in the number of the forum id you want it to use.
i did and i got the above..... is there any way you can just make the first hack on the back on the first page incorperate into the second hack?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.