I want to limit what is shown by the code below, to pictures that where uploaded in the last 3 days
<?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
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:
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...:)
Solved
In cpmfetch_dao.php I changed in the "getTopRatedMediaFrom" function
This
. $this->filetypefilter ." AND p.approved='YES' AND p.pic_rating > 0 "
To this:
. $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...:)