View Single Post
  #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
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01301 seconds
  • Memory Usage 1,876KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete