vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   this should be very simple..... (https://vborg.vbsupport.ru/showthread.php?t=36968)

TaP 04-04-2002 03:33 AM

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!

Neo 04-04-2002 04:46 AM

top tem list for what

TaP 04-05-2002 01:21 AM

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

mr e 04-05-2002 02:05 AM

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

TaP 04-05-2002 03:37 AM

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

TaP 04-05-2002 03:45 AM

ok this might help alittle.... all i want is the first hack below working with the second hack

Code:

*********************************
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



Code:


<?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/showt...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,$dbpassword) 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>");

?>


FWC 04-05-2002 04:06 AM

Quote:

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.

TaP 04-05-2002 04:30 AM

i dont understand.???

FWC 04-05-2002 05:01 AM

Quote:

Originally posted by TaP
i dont understand.???
You need to replace userid and username in that query with postuserid and postusername.

TaP 04-05-2002 05:37 AM

same error..... cant you show a complete peice? im still a bit confused

FWC 04-05-2002 04:30 PM

Quote:

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:
Code:

SELECT postuserid,postusername,replycount FROM thread WHERE forumid=14 ORDER BY replycount DESC LIMIT 10
I am not sure what you are really looking for, though.

TaP 04-05-2002 07:27 PM

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]

FWC 04-05-2002 07:54 PM

OK, before we go any further. What exactly are you trying to do? What do you want a top ten list of?

mr e 04-05-2002 08:03 PM

Well until my forum is back up I'm kind of guessing here, but try this.

PHP Code:

// 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

TaP 04-05-2002 10:24 PM

v

TaP 04-05-2002 10:24 PM

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

TaP 04-05-2002 10:28 PM

»
»

is what i get were i inserted the $top10post and $top10name

mr e 04-06-2002 02:08 AM

Well the "forumid = #" part you have to put in the number of the forum id you want it to use.

TaP 04-06-2002 03:38 AM

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?


All times are GMT. The time now is 03:01 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01905 seconds
  • Memory Usage 1,795KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (19)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete