Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-07-2006, 06:43 PM
New Pligger
 
Join Date: Feb 2006
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
Count script.

Counts how many users, and stories that are submited to your site.

1st step, make a count.php and put the following simple code:

PHP Code:
<?php
// Count script by LG-2. Gets the rows in MySQL and outputs them.
mysql_select_db($db);
$result mysql_query"SELECT * FROM users" )
or die(
"SELECT Error: ".mysql_error());
$num_rows mysql_num_rows($result);
$result2 mysql_query"SELECT link_id FROM links" )
or die(
"SELECT Error: ".mysql_error());
$num_links mysql_num_rows($result2);
?>
Open libs/html1.php and after all the comments add:

PHP Code:
include('count.php'); 
.

Now 3rd step I feel bad about but I havent messed with smarty much so I haven't been able to add it to smarty.

Open index.php and look where you want to put the code to output the number. I know this is going to be a little complicated but here's an example of how I did it:

PHP Code:
    echo '<center><table width="90%" height="20" border="0" cellspacing="0" cellpadding="0" bgcolor="#f1f1f1">
                                          <tr>
                                            <td width="2%" valign="top"><img src="/images/newscorner3.gif" width="20" height="20" /></td>
                                            <td width="96%"><div align="center"><font class="h5red"><a href=shakeit.php>Buscar Otras Noticias</a> / <a href=submit.php>Zumba una Noticia!</a> / </font></right><font class="thiscat"><strong><a href="topusers.php">Usuarios registrados:</a> </strong></font>'

                                            echo 
"<font class=h5red>$num_rows / </font> ";
                                            echo 
'<font class="thiscat"><strong><a href="topstories.php">Historias Publicadas:</a> </strong></font>';
                                            echo 
"<font class=h5red>$num_links</font>";

                                            echo 
'</td><td width="2%" valign="top"><img src="/images/newscorner4.gif" width="20" height="20" /></td>
                                          </tr>
                                        </table></center><p><font class="thiscat">* Estas noticias son publicadas por los usuarios.<br> 
* Cualquier pregunta o para reportar un error (bug), por favor enviale un email a LG-2 <a href="mailto:lg2@zumbalo.com">(lg2@zumbalo.com)</a>.</font><br>
<font class="h5red"><a href="tuts.php">Aprende a usar esta pagina!</a></font><p>'

$num_rows is the variable for the user count.
$num_links is the variable for the stories count.

Now the stories might display a bigger number than the stories that actually appear and that is because it also count the discarted stories. Is also good to run the meneame.net script.

Last edited by LG-2; 03-07-2006 at 06:47 PM..
Reply With Quote
The Following User Says Thank You to LG-2 For This Useful Post:
  #2 (permalink)  
Old 03-07-2006, 11:45 PM
Constant Pligger
 
Join Date: Jan 2006
Posts: 197
Thanks: 1
Thanked 0 Times in 0 Posts
LG-2, wonderful! thanks for sharing
Reply With Quote
  #3 (permalink)  
Old 03-08-2006, 03:40 PM
New Pligger
 
Join Date: Feb 2006
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
Thanks jejeje no prob. :-D. More to come soon!
Reply With Quote
  #4 (permalink)  
Old 03-21-2006, 02:16 PM
New Pligger
 
Join Date: Mar 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
What version of pligg did you add this code too because I am using 6 and I am trying to find out where you can post this snippit of code.
Reply With Quote
  #5 (permalink)  
Old 03-26-2006, 07:34 PM
New Pligger
 
Join Date: Feb 2006
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
Quote:
Originally Posted by new_start
What version of pligg did you add this code too because I am using 6 and I am trying to find out where you can post this snippit of code.
Its version 6 but my Pligg has been edited alot... but you can add it to the footer after print_summary
Reply With Quote
  #6 (permalink)  
Old 10-09-2006, 12:19 AM
Casual Pligger
 
Join Date: May 2006
Posts: 30
Thanks: 8
Thanked 10 Times in 6 Posts
Thumbs up updated Count Script

this is an update to LG's script
just gives the users alot more information than just total members and links...

it also gives a total for comments, categories, pageviews, tags and votes!


--------------------------------

1st step, make a count.php and put the following simple code:

PHP Code:
<?php
// Count script by LG-2. Gets the rows in MySQL and outputs them.
mysql_select_db($db);
$result mysql_query"SELECT * FROM users" )
or die(
"SELECT Error: ".mysql_error());
$num_rows mysql_num_rows($result);
$result2 mysql_query"SELECT link_id FROM links" )
or die(
"SELECT Error: ".mysql_error());
$num_links mysql_num_rows($result2);
$result3 mysql_query"SELECT comment_id FROM comments" )
or die(
"SELECT Error: ".mysql_error());
$num_comments mysql_num_rows($result3);
$result4 mysql_query"SELECT category__auto_id FROM categories" )
or die(
"SELECT Error: ".mysql_error());
$num_categories mysql_num_rows($result4);
$result5 mysql_query"SELECT pv_id FROM pageviews" )
or die(
"SELECT Error: ".mysql_error());
$num_pageviews mysql_num_rows($result5);
$result6 mysql_query"SELECT tag_link_id FROM tags" )
or die(
"SELECT Error: ".mysql_error());
$num_tags mysql_num_rows($result6);
$result7 mysql_query"SELECT vote_id FROM votes" )
or die(
"SELECT Error: ".mysql_error());
$num_votes mysql_num_rows($result7);
?>

2nd step is to place this somewere on your site (of course change the text to fit your personal site)
I myself put it in libs/sidebarstories.php...

PHP Code:
include('count.php'); 

            echo 
" TVB Members: <font class=h5red>$num_rows  </font> <br>";
            echo 
"TVB Videos: <font class=h5red>$num_links</font><br>";
            echo 
"TVB Votes: <font class=h5red>$num_votes</font><br>";
            echo 
"TVB Comments: <font class=h5red>$num_comments</font><br>";
            echo 
"TVB Categories: <font class=h5red>$num_categories</font><br>";
            echo 
"TVB Tags: <font class=h5red>$num_tags</font><br>";
            echo 
"TVB Page Views: <font class=h5red>$num_pageviews</font>"
just wanted to share this update with the community
thatvideoblog.com
Reply With Quote
The Following 4 Users Say Thank You to chad90382 For This Useful Post:
  #7 (permalink)  
Old 10-10-2006, 02:19 AM
kbeeveer46's Avatar
Pligg Developer/Admin
Pligg Version: 0
Pligg Template: none
 
Join Date: Jun 2006
Location: Muncie, Indiana
Posts: 3,547
Thanks: 254
Thanked 649 Times in 513 Posts
Thanks a lot. We will definately add this to Pligg somehow.
__________________
I accept donations for my time helping users like you on the forum and IRC.
Reply With Quote
Reply

Thread Tools
Display Modes
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
[mod] count clicks instead of votes abcdefgary Modification Tutorials 8 06-14-2008 11:34 PM
[Mod] Category Count - Final Geoserv Modification Tutorials 24 04-21-2008 09:10 PM
Internal Server Error cvcxl Bug Report 2 02-29-2008 06:51 PM
Premature end of script headers d4dirty Bug Report 3 01-03-2008 10:22 AM
Injecting values from Pligg into Google Script aaronpais Modification Tutorials 4 06-02-2007 04:23 PM


Search Engine Friendly URLs by vBSEO 3.2.0