Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Vraxor

Pages: [1]
1
Hi all,

I did already forgot about this little modification I did. I was in fact the first little mod I did ever in PHP.

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!!!

Cheers,
Vraxor

2
Hi all,

I have a question about the "new images" at the main page of 4images.

As I currently have a digital art site and one of the categories is Ecards.
Now would i like to upload many Ecards there, but I would not like to see them apear in the new images list. Is this possible?

Also am I thinking about creating a downloads category where users can upload there own files to share, but I don't want that to appear at the new images too, so is it possible to exclude some categories from the new images and if so could someone point me in the right direction.

I don't know if it has already been done by someone, but if someone could give me some help getting started, I know where to search and then I hope to be able to figure the rest out myself.

Cheers,
Vraxor

3
Hi all,

I know that there already are many posting on this topic, but I finally succeeded in getting it to work. So this is more or less a tutorial.

This is what you have to do.

1.  Open Details.php
2. add after:
Code: [Select]
     $site_db->query($sql);
      $commentid = $site_db->get_insert_id();
      update_comment_count($id, $user_info['user_id']);


Add this:
Code: [Select]
   $sql = "SELECT image_name FROM ".IMAGES_TABLE." WHERE image_id = $id";
    $image_name = $site_db->query($sql);
    $sql = "SELECT user_id FROM ".IMAGES_TABLE." WHERE image_id = $id";
    $user_id = $site_db->query($sql);
   
    $recipient_name = $image_row['user_name'];
    $recipient_email = $image_row['user_email'];
    $image_url = $script_url."/details.php?".URL_IMAGE_ID."=".$id."";
   
       // Start Emailer für comments
    include(ROOT_PATH.'includes/email.php');
    $site_email = new Email();
    $site_email->set_to($recipient_email);
    $site_email->set_from($config['site_email'], $config['site_name']);
    $site_email->set_subject("Comment Posted");
    $site_email->register_vars(array(
      "user_name" => $image_row['user_name'],
      "recipient_name" => $recipient_name,
      "image_name" => $image_row['image_name'],
      "comment_date" => format_date($config['date_format']." ".$config['time_format'], $current_time),
      "site_name" => $config['site_name'],
      "image_url" => $image_url,
          ));
    $site_email->set_body("comment_email", $config['language_dir']);
    $site_email->send_email();


Make sure that you posted it before:
Code: [Select]
   }
  }
  unset($row);
  unset($spam_row);
}

//-----------------------------------------------------
//--- Show Comments -----------------------------------
//-----------------------------------------------------


3. Now you have to make a mail template called comment_email.html

put this in the comment_email.html:

Code: [Select]
Dear {user_name},

someone posted a comment on {image_name} at {site_name}.
To view the comment go to: {image_url}
Date: {comment_date}

------
Best regards, {site_name}


save this mail template in:  [ROOT]/Lang/[your_language]/email/

This should be all.

Note:
    Always back-up any file you begin to edit.
    I cannot be held responsible for any data loss or any other problem that might  happen after editing files like I explained above.
    I do not have much php knowledge so I expect that there will be some improvements possible in the code I just gave. If you have any additions or improvements to the code I posted, please feel free to reply.[/list:u]

    I hope you all like this addition.

    Cheers,
    Vraxor

4
Discussion & Troubleshooting / Settings
« on: November 11, 2002, 06:10:30 PM »
Hi Jan,

I have problems too. If I look at the settings page in the admin section I cannot set some settings.

This is the way it looks:



I hope you can help me out on this one, because I can't change the settings, even after I changed the settings.php file.

Cheers,
Vraxor

5
Hi all,

This request already had a topic, but at the moment the feature suddenly becomes highly needed and I just hope to find some help with it.

I would like to be notefied by mail when someone gives a comment on one of my images. This feature should work for al visitors as well, so not only on my images.

I already get the script to send mail, but I can't get the right receipent to receive it and in most cases I can't get it to fill in any receipent at all. Since I do not have my own mail server it is very hard for me to work on this as my mail provider starts complaining about all failed mail attempts :)

I really hope someone can help me on this one, cause I believe it is possible and it would just make it so much more fun to be notified when comments have been posted.

Cheers,
Vraxor

6
Mods & Plugins (Releases & Support) / [Mod] Toplist altered
« on: November 05, 2002, 10:08:02 AM »
Yesterday I started changing the code of 4 images for the first time and with succes. I altered the Toplist to show a top 10 of Most commented images.

I also added some lines to the top.php file to show the thumbnails, this last edit took me many hours since I do not have any programming skills yet, I'm a quick learner so I will be able to mange soon enough I think ;-)

Feel free to take a look and if enough people love the way I changed the toplist I might write a tutorial here.

to view the toplist: http://haunter.student.utwente.nl/Terrarevolution/galleries/top.php

Cheers,
Vraxor

Pages: [1]