View previous topic :: View next topic |
Author |
Message |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Thu Jul 25, 2002 9:06 am Post subject: Total No. Of Comments And Posts |
|
|
Can i know how to make it display the total no. of comments and posts? _________________
++ GamerZ.Per.Sg - Complex Simplicity |
|
Back to top |
|
 |
M@2T
Joined: 23 Apr 2002 Posts: 63 Location: England
|
Posted: Thu Jul 25, 2002 1:59 pm Post subject: |
|
|
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 |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Fri Jul 26, 2002 1:16 am Post subject: |
|
|
Thanks, got the code working =) _________________
++ GamerZ.Per.Sg - Complex Simplicity |
|
Back to top |
|
 |
Edlef
Joined: 16 Mar 2002 Posts: 71
|
Posted: Sat Jul 27, 2002 10:15 am Post subject: Where? |
|
|
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 |
|
 |
adamwalker
Joined: 07 Apr 2002 Posts: 125 Location: England
|
Posted: Sat Jul 27, 2002 10:41 am Post subject: loads stuff |
|
|
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 |
|
 |
adamwalker
Joined: 07 Apr 2002 Posts: 125 Location: England
|
Posted: Sat Jul 27, 2002 11:12 am Post subject: important |
|
|
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 |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Sat Jul 27, 2002 5:46 pm Post subject: |
|
|
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 |
|
 |
|