boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Total No. Of Comments And Posts

 
Post new topic   Reply to topic    boardom Forum Index -> How to ?
View previous topic :: View next topic  
Author Message
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Thu Jul 25, 2002 9:06 am    Post subject: Total No. Of Comments And Posts Reply with quote

Can i know how to make it display the total no. of comments and posts?
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
M@2T



Joined: 23 Apr 2002
Posts: 63
Location: England

PostPosted: Thu Jul 25, 2002 1:59 pm    Post subject: Reply with quote

I was thinking exactly the same last week :)

And Adam of http://www.adamwalker.34sp.com Has the answer :)

I use this on my site on the left and it works like a charm.

403 comments
97 posts written
5 user online
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Fri Jul 26, 2002 1:16 am    Post subject: Reply with quote

Thanks, got the code working =)
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Edlef



Joined: 16 Mar 2002
Posts: 71

PostPosted: Sat Jul 27, 2002 10:15 am    Post subject: Where? Reply with quote

am i blind? i could not find the hack on adams site
ive searched the archive and the faqs, whats the name of the hack??
tia
Edlef
Back to top
View user's profile Send private message Visit poster's website
adamwalker



Joined: 07 Apr 2002
Posts: 125
Location: England

PostPosted: Sat Jul 27, 2002 10:41 am    Post subject: loads stuff Reply with quote

hey. i dont actually remember releasing this one. I write so much stuff i prob have and forgot about it... well here is the full code for my title bar....

This is my total downloads script (this is not a b2 hack)

Code:

<?php
 $result2 = mysql_fetch_row(mysql_query("SELECT SUM(file_dls) FROM file_files"));
echo $result2[0];
?>


What it does is that my downloads script logs each time a file is downloaded and it adds up the total thats logged in file_dls

NEXT

Total usersonline

Code:
   <?php

$timeoutseconds = 300;

$timestamp = time();
$timeout = $timestamp-$timeoutseconds;
?>
                    Downloads ::

$insert1 = mysql_db_query($dbname, "INSERT INTO b2_useronline VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF')");
if(!($insert1)) {
 print "Useronline Insert Failed";
}
$delete1 = mysql_db_query($dbname, "DELETE FROM b2_useronline WHERE timestamp<$timeout");
if(!($delete1)) {
 print "Useronline Delete Failed";
}
$result1 = mysql_db_query($dbname, "SELECT DISTINCT ip FROM b2_useronline WHERE file='$PHP_SELF'");
if(!($result1)) {
 print "Useronline Select Error";
}
$user1 = mysql_num_rows($result1);


if($user1 == 1) {
 print("$user1 user online\n");
} else {
 print("$user1 users online\n");
}

?>



This adds the total users visiting that page on your site and reports it back in the form of "2 users online". Ive set it to use the values from my b2config.php


YOU NEED TO CREATE THIS TABLE FIRST

Code:
CREATE TABLE b2_useronline (
   timestamp int(15) NOT NULL,
   ip varchar(40) NOT NULL,
   file varchar(100) NOT NULL,
   PRIMARY KEY (timestamp),
   KEY ip (ip),
   KEY file (file)
);




NEXT

Code:

                    <?php

$resultposts = mysql_db_query($dbname, "SELECT DISTINCT ID FROM b2posts");

$userposts = mysql_num_rows($resultposts);

 print("$userposts posts written\n"); ?>
                    ::
                    <?php


this selects the total posts written in your database (if your tables arnt the default then the above "b2posts" needs to b changed

NEXT

Code:
<?php

$resultposts1 = mysql_db_query($dbname, "SELECT DISTINCT comment_ID FROM b2comments");

$userposts1 = mysql_num_rows($resultposts1);

 print("$userposts1 comments\n");  ?>


this plain and simply counts the comments written

and finally ( not b2 )

the name of each of my affiliates are stored in a text file and this bit of code counts each line
Code:

  <?php
print count(file("inc/affiliate.inc"))+1;

?>


[/i]
_________________
Shameless Plug - For all your B2 template and hack needs visit www.adamwalker.34sp.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
adamwalker



Joined: 07 Apr 2002
Posts: 125
Location: England

PostPosted: Sat Jul 27, 2002 11:12 am    Post subject: important Reply with quote

NOTE. BACKUP UR SITE FIRST. This code is just dev code. nothing more.
_________________
Shameless Plug - For all your B2 template and hack needs visit www.adamwalker.34sp.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Sat Jul 27, 2002 5:46 pm    Post subject: Reply with quote

adamwalker, somehow or rather i think u release it i think i found it on your site=)
[php:1:e96b310893]$resultposts = mysql_db_query($dbname, "SELECT DISTINCT ID FROM b2posts");
$resultcomments = mysql_db_query($dbname, "SELECT DISTINCT comment_ID FROM b2comments");
$totalposts = mysql_num_rows($resultposts);
$totalcomments = mysql_num_rows($resultcomments);
[/php:1:e96b310893]
remember to change the table name
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> How to ? All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group