vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Top Posters during XXXX (https://vborg.vbsupport.ru/showthread.php?t=11530)

Bane 03-16-2001 07:55 AM

I am using a php file to display the top ten posters:

PHP Code:

<?php 

require("global.php"); 

$db_link = @mysql_pconnect("$dbservername""$dbusername""$dbpassword"); 
mysql_select_db("$dbname"); 

?> 

<table cellpadding="4" cellspacing="1" width="100%"> 
<tr> 
<td><small><strong>TOP POSTERS</strong></small></td> 
<td align="center"><small><strong>POSTS</strong></small></td> 
</tr> 
<?php 
$top_post 
top_posters(); 
while( 
$row mysql_fetch_row($top_post) ) 

print(
'<tr>'); 
print(
'<td>'); 
print(
'<a href="member.php?s=&action=getinfo&userid='); 
print(
$row[0]); 
print(
'" target="_top">'); 
print(
$row[1]); 
print(
'</a></td>'); 
print(
'<td align="center">'); 
print(
$row[2]); 
print(
'</td>'); 
print(
'</tr>'); 

mysql_free_result ($top_post); 
?> 
</table> 

<?php 

function top_posters() 

$cur_time mktime(date(G), date(i), date(s), date(m), date(d), date(Y)); 
$query 'SELECT userid, username, posts ' 
'FROM user ' 
'ORDER BY posts DESC LIMIT 3'
$result mysql_query($query
or die(
'top_posters query failed'); 
return(
$result); 


?>

IRC may recognise this :)

My question is, is there a way to set this so it displays the top posters of the last 7 days and the number of posts during that time period?

I had tried changing some things and got the top list for last 7 days, but it would only display the total number of posts, not just for those 7 days..

I hope Im making sense.

03-16-2001 08:08 AM

I did something like this only I calculate based on the past 24 hours.

PHP Code:

$numberHighPostPerPage 10//set for this paste of teh script
$curTime localtime();
$uts time() - ($curTime[2]*3600 $curTime[1]*60 $curTime[0]);
$lts $uts - (86401);    // 3600 * 24 + 1 (to be completely honest about "yesterday")
unset($curTime);

$users $DB_site->query("
         SELECT post.userid, user.username, COUNT(post.userid) AS count
                FROM post
                LEFT JOIN user ON post.userid=user.userid
                WHERE dateline >= 
$lts AND dateline <= $uts
                GROUP BY post.userid
                ORDER BY count DESC
                LIMIT 
$numberHighPostPerPage"
         
);

while (
$user $DB_site->fetch_array$users ) )
{
       eval( 
"\$highpostbits .= \"".gettemplate("highpostbit")."\";");
       
$numhp++;
}
for ( ; 
$numhp $numberHighPostPerPage$numhp++ )
{
        
$user[userid] = "-1"$user[username] = "Unclaimed"$user[count] = "0";
        eval( 
"\$highpostbits .= \"".gettemplate("highpostbit")."\";");
}
eval( 
"\$highpost = \"".gettemplate("highpost")."\";"); 


Change the line:
$lts = $uts - (86401);

to:
$its = $uts - (604800);


Then add the templats: highpost, and highpostbit. In the highpost bit you can use $user[userid] $user[username] and $user[count].

What this will also do, if there are less then $numberHighPostPerPage top posters it will fill the remaining slots with "Unclaimed".


This is a part of the site integration script I am writing for my site.

03-16-2001 08:30 AM

Using

PHP Code:

<?php

$templatesused 
"highpost,highpostbit";
require (
"global.php");

$numberHighPostPerPage 10//set for this paste of the script
$curTime localtime();
$uts time() - ($curTime[2]*3600 $curTime[1]*60 $curTime[0]);
$lts $uts - (604800);    // 3600 * 24 + 1 (to be completely honest about "yesterday")
unset($curTime);

$users $DB_site->query("
         SELECT post.userid, user.username, COUNT(post.userid) AS count
                FROM post
                LEFT JOIN user ON post.userid=user.userid
                WHERE dateline >= 
$lts AND dateline <= $uts
                GROUP BY post.userid
                ORDER BY count DESC
                LIMIT 
$numberHighPostPerPage");

while (
$user $DB_site->fetch_array$users ) )
{
       eval( 
"$highpostbits .= \"".gettemplate("highpostbit")."\";");
       
$numhp++;
}
for ( ; 
$numhp $numberHighPostPerPage$numhp++ )
{
        
$user[userid] = "-1"$user[username] = "Unclaimed"$user[count] = "0";
        eval( 
"$highpostbits .= \"".gettemplate("highpostbit")."\";");
}
eval( 
"$highpost = \"".gettemplate("highpost")."\";");

?>



I get parse errors?

Quote:

Parse error: parse error in /www/influx9/forum/ztoppost.php(23) : eval()'d code on line 1

Parse error: parse error in /www/influx9/forum/ztoppost.php(23) : eval()'d code on line 1

Parse error: parse error in /www/influx9/forum/ztoppost.php(23) : eval()'d code on line 1

Parse error: parse error in /www/influx9/forum/ztoppost.php(23) : eval()'d code on line 1

Parse error: parse error in /www/influx9/forum/ztoppost.php(23) : eval()'d code on line 1

Parse error: parse error in /www/influx9/forum/ztoppost.php(23) : eval()'d code on line 1

Parse error: parse error in /www/influx9/forum/ztoppost.php(23) : eval()'d code on line 1

Parse error: parse error in /www/influx9/forum/ztoppost.php(23) : eval()'d code on line 1

Parse error: parse error in /www/influx9/forum/ztoppost.php(23) : eval()'d code on line 1

Parse error: parse error in /www/influx9/forum/ztoppost.php(23) : eval()'d code on line 1

Parse error: parse error in /www/influx9/forum/ztoppost.php(31) : eval()'d code on line 1

03-16-2001 11:49 AM

hey leadZERO

Can you post your templates?

03-16-2001 11:57 AM

The reason why you are getting parse errors is not because of a coding error on anyone's part.

It is a problem that vBulletin currently has with [ php ] blocks and escaped characters... watch this:

Code:

eval("\$bits .= \"".gettemplate("bit")."\";");
now the same code in a [ php ] block:
PHP Code:

eval("\$bits .= \"".gettemplate("bit")."\";"); 

As you can see, the code is not properly printed in the PHP block.

03-16-2001 12:05 PM

I did manage to get rid of the parse errors.. :) Trying to sort the templates now :p

03-16-2001 05:53 PM

Templates:

~highpost
<table width="165" border="0" cellspacing="0" cellpadding="0">
$highpostbits
</table>

~highpostbit
<tr bgcolor="#370000">
<td width="5"><img src="/images/spacer.gif" width="5"></td> <td><a href="/forum/member.php?s=$session[sessionhash]&action=getinfo&userid=$user[userid]"><font color="#E0E0E0">$user[username]</font></a></td>
<td>$user[count]</td>
<td width="5"><img src="/images/spacer.gif" width="5"></td>
</tr>

Those are copied straight from my templates, so just ignore things like my spacer GIF.

03-16-2001 07:26 PM

Works great leadZERO, I appreciate the help!

03-16-2001 10:42 PM

Quote:

Originally posted by Kier
As you can see, the code is not properly printed in the PHP block.
Maybe it's cause Freddie fixed it (haven't looked for this specifically in the Bug Fixes thread yet) but they look exactly the same to me...

03-17-2001 01:00 AM

The \ is missing before $bits


All times are GMT. The time now is 05:52 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.01161 seconds
  • Memory Usage 1,780KB
  • 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
  • (1)bbcode_code_printable
  • (4)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete