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: Limiting TopRatedMedia by days  (Read 3769 times)

0 Members and 1 Guest are viewing this topic.

Steve-R

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 38
Limiting TopRatedMedia by days
« on: January 08, 2008, 12:25:52 pm »

I want to limit what is shown by the code below, to pictures that where uploaded in the last 3 days


Code: [Select]
<?php    

  
include_once "./cpmfetch/cpmfetch.php";
  
$objCpm = new cpm("./cpmfetch/cpmfetch_config.php");
  
$options = array("subtitle" => "{{pTitle}} <br />by {{pOwner_name}}<br /><br />{{pCtimeFormatted}}<br />  Pic Rating : {{pPic_Rating}} <br /> Votes : {{pVotes}} <hr />",
                
"imagesize" => "thumb");
  
$objCpm->cpm_viewTopRatedMediaFrom ("cat=1",100,1,$options);
  
$objCpm->cpm_close();

?>


The above code in use

http://www.photocumbria.com/SdGall/bbbbb.php

I have already managed to change the sort order to votes rather than pic rating, and to limit pics shown to those that actually have votes on them (before it showed 100, whether they had votes or not) by changing this in cpmfetch_dao.php

Code: [Select]
function getTopRatedMediaFrom ($source, $count = 1) {
$resultset = array();
if (is_numeric($count)) {

$sourceSql = $this->makeSourceSql($source);

if ($sourceSql != "") $sourceSql = " AND " . $sourceSql;

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

$resultset = $this->dbExecuteSql($sqlcode);
$this->addPathInfo($resultset);
}
elseif ($this->cfg['cfDebugMode'] == 'true'){
debugPrint("Non numeric count submitted");
}

return ($resultset);
}

To this:

Code: [Select]
function getTopRatedMediaFrom ($source, $count = 1) {
$resultset = array();
if (is_numeric($count)) {

$sourceSql = $this->makeSourceSql($source);

if ($sourceSql != "") $sourceSql = " AND " . $sourceSql;

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

$resultset = $this->dbExecuteSql($sqlcode);
$this->addPathInfo($resultset);
}
elseif ($this->cfg['cfDebugMode'] == 'true'){
debugPrint("Non numeric count submitted");
}

return ($resultset);
}



I've looked at using $timestamp but that requires a set date to work from as far as I can tell, then I looked at using $numberOfDays. Can I use this number of days somehow in the code top of page here or would I need to edit the function "getTopRatedMediaFrom" in cpmfetch_dao.php...or am I missing an even simpler fix?


Many thanks in advance!

Steve...:)
« Last Edit: January 23, 2008, 09:19:46 am by Joachim Müller »
Logged

Steve-R

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 38
Re: Limiting TopRatedMedia by days
« Reply #1 on: January 22, 2008, 01:46:13 pm »

Solved

In cpmfetch_dao.php I changed in the "getTopRatedMediaFrom" function

This
Code: [Select]
. $this->filetypefilter ." AND p.approved='YES' AND p.pic_rating > 0 "

To this:
Code: [Select]
. $this->filetypefilter ." AND p.approved='YES' AND p.pic_rating > 0 AND ctime > UNIX_TIMESTAMP() - 172800

This limits what is shown to the last two days.

Steve...:)
Logged
Pages: [1]   Go Up
 

Page created in 0.016 seconds with 15 queries.