Author Topic: [Mod] Another Statistics Mod  (Read 25495 times)

0 Members and 1 Guest are viewing this topic.

Offline callimero

  • Newbie
  • *
  • Posts: 30
    • View Profile
[Mod] Another Statistics Mod
« on: May 12, 2005, 04:49:56 PM »
hallo,

ich habe alles so gemacht wie es hier beschrieben ist (glaub ich), die statistiken isnd aber nicht zu sehen.
woran kann das liegen www.netzpfosten.de

The idea is to show more statistics then the number of images and categories (which are shown by default).
This MOD will show:
- Number of Members
- Number of Image Votes
- Number of Image Hits
- Number of Image Comments
- Number of Image Downloads

All these are shown on totals, so it shows the total number of image hits over all images. You can see an example of it here: http://haunter.student.utwente.nl/Terrarevolution/galleries/index.php

// Ok, now lets get started

Creating the stats.php file
Make a new file called: stats.php
Save this empty file in the includes folder of 4images
Open stats.php with any code editor you like.

and copy past the following to your stats.php:
Code: [Select]
<?PHP

//-----------------------------------------------------
//--- Show number of Users ----------------------------
//-----------------------------------------------------
   $sql = "SELECT COUNT(*) as users
          FROM ".USERS_TABLE."
          WHERE user_id <> ".GUEST;
  $row = $site_db->query_firstrow($sql);

  $total_users = "".$lang['users']."<B> ".$row['users']."</B>\n";
 
  $site_template->register_vars("total_users", $total_users);
unset($total_users);

//-----------------------------------------------------
//--- Hits --------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_hits) AS sum
          FROM ".IMAGES_TABLE;
  $row = $site_db->query_firstrow($sql);

  $sum = (isset($row['sum'])) ? $row['sum'] : 0;
  $total_hits = "".$lang['total_hits']."<B> ".$row['sum']."</B>\n";
 
  $site_template->register_vars("total_hits", $total_hits);
unset($total_hits);

//-----------------------------------------------------
//--- Votes -------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_votes) AS sum
          FROM ".IMAGES_TABLE;
  $row = $site_db->query_firstrow($sql);

  $sum = (isset($row['sum'])) ? $row['sum'] : 0;
  $total_votes = "".$lang['total_votes']."<B> ".$row['sum']."</B>\n";
 
  $site_template->register_vars("total_votes", $total_votes);
unset($total_votes);

//-----------------------------------------------------
//--- Downloads ---------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_downloads) AS sum
          FROM ".IMAGES_TABLE;
  $row = $site_db->query_firstrow($sql);

  $sum = (isset($row['sum'])) ? $row['sum'] : 0;
  $total_downloads = "".$lang['total_downloads']."<B> ".$row['sum']."</B>\n";
 
  $site_template->register_vars("total_downloads", $total_downloads);
unset($total_downloads);

//-----------------------------------------------------
//--- Comments ----------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_comments) AS sum
          FROM ".IMAGES_TABLE;
  $row = $site_db->query_firstrow($sql);

  $sum = (isset($row['sum'])) ? $row['sum'] : 0;
  $total_comments = "".$lang['total_comments']."<B> ".$row['sum']."</B>\n";
 
  $site_template->register_vars("total_comments", $total_comments);
unset($total_comments);
?>

Now save the stats.php file.

ALWAYS BACKUP: any file you start editing as you might not be able to restore it when the mod doesn't work

Adding the statistics to the language files:

*NOTE* I only edited this in English, but you will have to copy this to any language you use and maybe translate the english.

Open the main.php file from the lang/[your language] folder of 4images.

Go all the way to the bottom of the file.

Find:
Code: [Select]
//-----------------------------------------------------
//--- Admin Links -------------------------------------
//-----------------------------------------------------
$lang['edit'] = "[Edit]";
$lang['delete'] = "[Delete]";

Add Before:
Code: [Select]
//-----------------------------------------------------
//--- Statistics --------------------------------------
//-----------------------------------------------------
$lang['users'] = "Total Members:";
$lang['total_hits'] = "Total Image Hits:";
$lang['total_votes'] = "Total Image Votes:";
$lang['total_downloads'] = "Total Image Downloads:";
$lang['total_comments'] = "Total Image Comments:";

Including the statistics in Index.php:

Open index.php in the root folder of 4images with any code editor you like.

Find:
Code: [Select]
require(ROOT_PATH.'includes/sessions.php');
Add after:
Code: [Select]
include(ROOT_PATH.'includes/stats.php');
Do the same for catergories.php, lightbox.php, top.php
(it might also work in memberlist.php, search.php, register.php etc. but I did not test them yet)

Now edit the template files that correspond with the php files you added the include to.

index.php = home.html
categories.php = categories.html
lightbox.php = lightbox.html
top.php = top.html

you can find the templates inside the templates/default folder of 4images.

In the templates you can now use the following tags:

{total_users} - This will show the total number of members
{total_votes} - This will show the total number of image votes
{total_comments} - This will show the total number of image comments
{total_hits} - This will show the total number of image hits
{total_downloads} - This will show the total number of image downloads

Uploading all the edited files:

Now upload all files you editted to the right folder at your webserver.

This is a list of files you need to upload:
./index.php
./categories.php
./lightbox.php
./top.php
./includes/stats.php
./lang/ (any language you editted) /main.php
./templates/ (any templates you editted) /home.html
./templates/ (any templates you editted) /categories.html
./templates/ (any templates you editted) /lightbox.html
./templates/ (any templates you editted) /top.html

of course if you editted any more files then the once I mentioned above, you will need to upload them too.

I think this is it. Please note that it could be that I made an error somewhere in the directions above. As soon as you notice any error, please let me know and I will correct it as soon as possible.

Enjoy this little mod!!!
« Last Edit: June 01, 2005, 09:43:50 PM by Chris »

Offline Vincent

  • 4images Moderator
  • Addicted member
  • *****
  • Posts: 1.195
    • View Profile
    • www.foto-kocher.com
Re: Mod funktioniert nicht
« Reply #1 on: May 12, 2005, 05:41:11 PM »
Code: [Select]
{total_users} - This will show the total number of members
{total_votes} - This will show the total number of image votes
{total_comments} - This will show the total number of image comments
{total_hits} - This will show the total number of image hits
{total_downloads} - This will show the total number of image downloads
diesen code hast du integriert?
gruss
vincent
Beati pauperi spiritus

4images 1.7 // My Installed Mods


Offline terk

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: [Mod] Another Statistics Mod
« Reply #2 on: June 25, 2005, 09:46:55 AM »
I've got a question: Why this stats ain't working in details.html and some other?

TheOracle

  • Guest
Re: [Mod] Another Statistics Mod
« Reply #3 on: June 26, 2005, 06:35:23 AM »
Quote

I've got a question: Why this stats ain't working in details.html and some other?


Quote

Do the same for catergories.php, lightbox.php, top.php
(it might also work in memberlist.php, search.php, register.php etc. but I did not test them yet)


In your case, you'd need to add the entries in details.php file as well. ;)

Offline terk

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: [Mod] Another Statistics Mod
« Reply #4 on: June 26, 2005, 07:26:41 AM »
Yes, I did, it is working in categories.html , but not working in details.html

TheOracle

  • Guest
Re: [Mod] Another Statistics Mod
« Reply #5 on: June 26, 2005, 02:03:42 PM »
Did you tried in includes/page_header.php file ?

Offline terk

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: [Mod] Another Statistics Mod
« Reply #6 on: July 02, 2005, 06:34:14 AM »
What do you mean? I don't get it....

TheOracle

  • Guest
Re: [Mod] Another Statistics Mod
« Reply #7 on: July 02, 2005, 03:10:51 PM »
Quote

Yes, I did, it is working in categories.html , but not working in details.html


Did you tried adding these codes in the page_header.php file as well ? Once added, it should work over your details.html file.

Offline terk

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: [Mod] Another Statistics Mod
« Reply #8 on: July 05, 2005, 10:28:27 AM »
What do I gotta add?

These:
Code: [Select]
{total_users} - This will show the total number of members
{total_votes} - This will show the total number of image votes
{total_comments} - This will show the total number of image comments
{total_hits} - This will show the total number of image hits
{total_downloads} - This will show the total number of image downloads

? Or something else?

TheOracle

  • Guest
Re: [Mod] Another Statistics Mod
« Reply #9 on: July 05, 2005, 01:09:47 PM »
Actually - this part :

Quote

include(ROOT_PATH.'includes/stats.php');


Offline terk

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: [Mod] Another Statistics Mod
« Reply #10 on: July 06, 2005, 07:08:24 PM »
I'll try, thanks!

Offline Flo2005

  • Full Member
  • ***
  • Posts: 237
  • Copy & Paste Profi :)
    • View Profile
    • snuup.de! - Bilder - Sounds - Videos - fun4FREE!
Re: [Mod] Another Statistics Mod
« Reply #11 on: October 28, 2005, 05:01:48 PM »
Hi @ all, with this MOD I get an empty statistic table on these templates -> pm.html & memberlist.html what could be the reason for this? on all the other templates also for the guestbook.html it works fine  :?

Edit: Nobody tells me why - but now I find it out!

I´ve forget to add:

Code: [Select]
include(ROOT_PATH.'includes/stats.php');
in memberlist.php & pm.php  :wink:

Project offline