Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Photo Of The Day  (Read 7252 times)

0 Members and 1 Guest are viewing this topic.

Rick X

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Photo Of The Day
« on: March 05, 2011, 03:10:19 pm »

My suggestion is to develop a system for photo of the day.

This is very important to take the coppermine to a higher level.

In my humble opinion the picture of the day would bring a lot of interest for users of any website in any language or culture.

Competition is inherent in human beings.

This routine would be based on the direct sum of the votes and a cron job and not so dependent on manual intervention.

That's it.

Thank you for your attention.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Photo Of The Day
« Reply #1 on: March 07, 2011, 12:02:18 pm »

This routine would be based on the direct sum of the votes and a cron job and not so dependent on manual intervention.
So the picture with the most votes will be every day the photo of the day? How exactly should it be determined? Where should it be displayed?
Logged

Rick X

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Photo Of The Day
« Reply #2 on: March 07, 2011, 04:31:41 pm »

So the picture with the most votes will be every day the photo of the day? How exactly should it be determined? Where should it be displayed?

Hi André. The picture with the most votes on that day will be the potd when the sun of votes of that day was the greater. Does not matter when the picture was posted. The sun of votes has to be made day by day. The picture should be displayed in the main page in normal size and caption: Photo of the Day - 99/99/9999.

Thank you.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Photo Of The Day
« Reply #3 on: March 07, 2011, 04:42:27 pm »

I doubt that this will become a core feature, as Coppermine doesn't stores the date/time when votes has been made by default. And there are more things to consider: What happens if there are no votes on that day? What happens if two pictures have the same votes on that day? Maybe some of the other devs have another opinion regarding this feature request.
Logged

Rick X

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Photo Of The Day
« Reply #4 on: March 07, 2011, 04:51:17 pm »

I doubt that this will become a core feature, as Coppermine doesn't stores the date/time when votes has been made by default.

1 - That should be added since this is the core of potd. Without this, no potd.

What happens if there are no votes on that day?

2 - In a site with a lot of users that will not happens but, if happens, no potd will be displayed.

What happens if two pictures have the same votes on that day?

3 - The first one (posted) woud be the photo of the day.

Thanks.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Photo Of The Day
« Reply #5 on: March 07, 2011, 04:57:08 pm »

If you need that feature urgently I think it can be already accomplished with cpg1.5.x without core code modification. I recommend to enable detailed voting stats and use anycontent.php to store your potd code.
Logged

Rick X

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Photo Of The Day
« Reply #6 on: March 07, 2011, 05:01:20 pm »

Thanks André.

I will try to code it.

Logged

Rick X

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Photo Of The Day
« Reply #7 on: March 18, 2011, 05:22:15 pm »

Well, I did the job.
I coded the photo of the day in a minimalistic way.
It´s fast and has to work as a cron job.
Where, in the forum, I can put the line guides?
Regards!
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Photo Of The Day
« Reply #8 on: March 18, 2011, 05:47:31 pm »

I suggest to post it right here in this thread. We can decide to move it to another place later, if needed.
Logged

Rick X

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Photo Of The Day
« Reply #9 on: March 18, 2011, 06:41:42 pm »

Guide to put a picture of the day on your site based on votes from the previous day.

Not for beginners.

1 - Create the a writable directory called potd

2 - Enable the statistics of votes in the admin panel

3 - In the album list view-> The content of the main page -> put anycontent where you want.

4 - Write the following php code and save it as you want into the root directory of Coopermine. Let's say saving with the name of photooftheday.php
<?php
define('IN_COPPERMINE', true);
require('include/init.inc.php');
 $result = cpg_db_query("select sum(rating) as total,pid as pid from ftp2011_vote_stats  where date(FROM_UNIXTIME(sdate,'%Y-%m-%d'))=date_sub(curdate(),INTERVAL 1 DAY) group by pid order by sum(rating) desc");

    if (!mysql_num_rows($result)) {
        cpg_die(CRITICAL_ERROR, sprintf("Nenhuma foto do dia"));
    }
    $CURRENT_ALBUM_DATA = mysql_fetch_assoc($result);
    mysql_free_result($result);
    $FotoDoDia=$CURRENT_ALBUM_DATA['pid'];
   $TotalDeVotos=$CURRENT_ALBUM_DATA['total'];
   echo $FotoDoDia.' - '.$TotalDeVotos;
   
   $info_photo_of_the_day=cpg_db_query("select filename,filepath from ftp2011_pictures where pid=".$FotoDoDia);
   $current_photo_of_the_day= mysql_fetch_assoc($info_photo_of_the_day);
   mysql_free_result($info_photo_of_the_day);
   $filename=$current_photo_of_the_day['filename'];
   $path_normal=$current_photo_of_the_day['filepath'];
   echo $filename.' - '.$path_normal;
   $final= '<a href=displayimage.php?pid='.$FotoDoDia.'><img border=0 src=albums/'.$path_normal.'normal_'.$filename.'></a>';
 
$c = "<root><pod>";
$c.= htmlentities('<a href=displayimage.php?pid='.$FotoDoDia.'><img border=0 src=albums/'.$path_normal.'normal_'.$filename.'></a>',ENT_QUOTES);
$c.= "</pod></root>";

file_put_contents("potd/potd.xml", $c);
?>


5 - Open the file anycontent.php and write the following code, right after the-> starttable ("100%", $ lang_index_php ['Welcome']);
if(file_exists('potd/potd.xml')) {
  $xmldoc = new DOMDocument();
  $xmldoc->load( 'potd/potd.xml' );
 
  $potds = $xmldoc->getElementsByTagName( "root" );
     foreach( $potds as $potd )
     {
     $fotos_do_dia = $potd->getElementsByTagName( "pod" );
     $foto_do_dia = $fotos_do_dia->item(0)->nodeValue;

     }
 
echo <<< EOT
    <tr>
        <td class="tableb" align="center">
            {$foto_do_dia}<br>
         Foto destaque
        </td>
    </tr>

EOT;
 }

6 - Make a cron job on your server (or on your host) scheduling the task to run everyday after midnight: http:///www.yoursite.com/photooftheday.php

7 - You must have the "normal" size photos enabled.

You can see it working here: http://www.fotopoint.com.br

It it´s cool if you have a lot of users voting.

I´m really sorry if my english is not so good...

Regards.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Photo Of The Day
« Reply #10 on: March 18, 2011, 09:08:24 pm »

Some things to optimize:
1. Instead of using hard coded table names we should use $CONFIG['TABLE_XYZ'].
2. Instead of using a cron job we could also update the data by adding something similar to Coppermine.
3. Instead of using an xml file, we should store the calculated data in the database.
4. There's a function that checks if an intermediate-sized picture exists (sometimes it isn't needed if the picture is small enough). So it will also work if you don't create intermediate-sized pictures.
5. Instead of calculating your potd once a day it could also be done on the fly.
Logged
Pages: [1]   Go Up
 

Page created in 0.029 seconds with 20 queries.