Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 08-25-2001, 11:55 PM
TheProfessor TheProfessor is offline
 
Join Date: Jan 2003
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, here it is, the statistics hack:

Create a file named stats.php. insert the following lines:

PHP Code:
<?php
// Boardstatistics scripted by Znaper (e-mail: [email]webmaster@znapers-board.de[/email])

require('./global.php');

// get total members
$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$numbermembers=$numbersmembers['users'];

// get active members
$snonposters=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user WHERE posts=0');
$nonposters=$snonposters['users'];
$activemembers=$numbermembers-$nonposters;
$activityrate=sprintf("%.2f",(100*$activemembers/$numbermembers));

// get total posts
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=$countposts['posts'];

// get total threads
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=$countthreads['threads'];

// get total thread views
$boardviews $DB_site->query_first("SELECT SUM(views) AS threadviews FROM thread");
$totalviews $boardviews[threadviews];

// get total pms
$totalpms $DB_site->query_first("SELECT count(*) as pmcount FROM privatemessage"); 
$totalpm $totalpms[pmcount];

// thanks to AA for the following lines:
// get Top 10 Posters of the last 30 days
if (isset($days)==and $days==0) { $days=30; }

$datecut=time()-($days*86400);

$posts=$DB_site->query("SELECT DISTINCT(userid),COUNT(postid) AS posts
                          FROM post
                         WHERE userid > 0 AND post.dateline>=
$datecut
                      GROUP BY userid
                      ORDER BY posts DESC
                         LIMIT 10"
);

while (
$user=$DB_site->fetch_array($posts)) {

$result=$DB_site->query_first("SELECT username
                                   FROM user
                                  WHERE userid=
$user[userid]");
                                  
$topposters.="<tr><td><a href=\"member.php?action=getinfo&userid=$user[userid]\">$result[username]</a></td><td>$user[posts]</td></tr>";
                                  }
                                  
// thanks to AA for the following lines:
// get Top 10 Posters of the last 24 hours
if (isset($days2)==and $days2==0) { $days2=1; }

$datecut2=time()-($days2*86400);

$posts2=$DB_site->query("SELECT DISTINCT(userid),COUNT(postid) AS posts
                          FROM post
                         WHERE userid > 0 AND post.dateline>=
$datecut2
                      GROUP BY userid
                      ORDER BY posts DESC
                         LIMIT 10"
);

while (
$user2=$DB_site->fetch_array($posts2)) {

$result2=$DB_site->query_first("SELECT username
                                   FROM user
                                  WHERE userid=
$user2[userid]");
                                  
$toplastposters.="<tr><td><a href=\"member.php?action=getinfo&userid=$user2[userid]\">$result2[username]</a></td><td>$user2[posts]</td></tr>";
                                  }
                                  

$co="Statistics-Hack ? 2001 by <a href=\"mailto:webmaster@znapers-board.de\">Znaper</a>, thanks to AA";
$templatesused "";
// Only one template is used so load it when called
eval("dooutput(\"".gettemplate("boardstatistics")."\");");

// free used memory
unset($user);
$DB_site->free_result($posts);
unset(
$user2);
$DB_site->free_result($posts2);

?>
Save this file the root directory of your board.

Next create a template namend boardstatistics. Insert the following lines into the template:

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<
html>
<
head>
  
<
title>$bbtitle Boardstatistics</title>
  
$headinclude
</head>
<
body>

$header
<br>

<
table cellpadding="0" cellspacing="0" border="1" width="100%" align="center">
<
tr><td bgcolor="#00496C" align="center"><font face="verdana, arial, helvetica" size="2"  color="Silver"><b>BOARDSTATISTIK</b></td></tr>
<
tr><td bgcolor="#000333">
<
normalfont>
  <
b>?</bRegistered Members: <b>$numbermembers</b><br>
  <
b>?</b0-Posters: <b>$nonposters</b><br>
  <
b>?</bActive Members: <b>$activemembers</b><br>
  <
b>?</bActive rate of all Members: <b>$activityrate %</b><br>
  <
b>?</bTotal Threads: <b>$totalthreads</bthreads<br>
  <
b>?</bTotal Posts: <b>$totalposts</bposts<br>
  <
b>?</bTotal Views: <b>$totalviews</bviews<br>
<
br>
  <
b>?</b> <b>$totalpm</b> Private Messages are stored in our Mailboxes!
<
br><br><center>
<
table><tr><td valign="top">

<
table cellpadding="2" align="center" bordercolor="#000040" border="-1">
<
tr bgcolor="#00496C"><td colspan=2 align=center><b>Top10 Poster of the last 30 days</b></td></tr>
<
tr bgcolor="#00496C"><td>Username</td><td>posts</td></tr>
$topposters</table>
</
td><td valign="top">

<
table cellpadding="2" align="center" bordercolor="#000040" border="-1">
<
tr bgcolor="#00496C"><td colspan=2 align=center><b>Top Poster of the last 24 hours</b></td></tr>
<
tr bgcolor="#00496C"><td>Username</td><td>Posts</td></tr>
$toplastposters</table>
</
td></tr></table>
<
br><br></center>
</
font></normalfont>
</
td></tr></table>

$footer
<center>$co</center>
</
body>
</
html
Now just call stats.php. Furthermore place a link in on of your templates so members can view the stats. I suggest forumhome ...

Greetings, The Professor!
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:17 AM.


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.08773 seconds
  • Memory Usage 3,217KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (24)post_thanks_box
  • (24)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (24)post_thanks_postbit_info
  • (24)postbit
  • (20)postbit_onlinestatus
  • (24)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete