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: [Solved]: Show best rated this month is not working  (Read 3701 times)

0 Members and 1 Guest are viewing this topic.

Peter R

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 26
[Solved]: Show best rated this month is not working
« on: February 23, 2009, 02:53:23 pm »

Since I found cpmFetch, I started to use it everywhere in the site. Great piece of code.
Now I want to show best three rated images, only picture posted in this month. This seems not hard, but is for me.
I call cpmFetch with:
$objCpm->cpm_viewTopRatedMediaFrom("cat=28",1, 3, $options)
This works fine, but is givng me best rated of all pictures, and not from the ones only added this month. For that, I made a small change in cpmfetch_dao.php
In the function function getTopRatedMediaFrom, I changed:

. $this->sqlTableSelect
. " WHERE 1 "
. $this->sqlUserDataLink
. $this->filetypefilter ." AND p.approved='YES' "
. $sourceSql . " {$this->privacyfilter} "
. " ORDER BY p.pic_rating DESC LIMIT 0,$count";

Into:
. $this->sqlTableSelect
. " WHERE 1 "
. $this->sqlUserDataLink
. $this->filetypefilter ." AND p.approved='YES' "
. " AND EXTRACT(YEAR_MONTH FROM mtime) = EXTRACT(YEAR_MONTH FROM CURRENT_DATE)"               
. $sourceSql . " {$this->privacyfilter} "
. " ORDER BY p.pic_rating DESC LIMIT 0,$count";

It looks very easy, but it is not working. I even get results from the last year?!? There are no php ore mySql errors, so  I miss some understanding about the working of cpmFetch or Coppermine.

How can I get this working correct?
« Last Edit: February 23, 2009, 10:12:20 pm by Nibbler »
Logged

Nibbler

  • Guest
Re: Show best rated this month is not working
« Reply #1 on: February 23, 2009, 03:01:29 pm »

mtime is the last viewed time. You want to be using ctime which is the upload date/time (as unix timestamp).
Logged

Peter R

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 26
Re: Show best rated this month is not working
« Reply #2 on: February 23, 2009, 10:10:10 pm »

> mtime is the last viewed time. You want to be using ctime
> which is the upload date/time (as unix timestamp).
Ha ha, well, that explains a lot.
And oh, I do hate unix timestamp. Some day, somebody started counting seconds and called it a time stamp.
Well, there is an advantage: this can easely be used to calculate GMT/UCT time. And because this gallery is multi continent, I want to keep it al GMT/UTC.

To complete this post:
In stead of my:
. " AND EXTRACT(YEAR_MONTH FROM mtime) = EXTRACT(YEAR_MONTH FROM CURRENT_DATE)"
use:
. " AND ctime > " . $timestamp

Above the line with $sqlcode = ......
put:
$timestamp = strtotime(gmdate("01-m-Y"));

Thanks for putting me on the right track.
Logged
Pages: [1]   Go Up
 

Page created in 0.017 seconds with 15 queries.