Possible bug? or my crap code? Possible bug? or my crap code?
 

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]

Main Menu

Possible bug? or my crap code?

Started by Steve-R, November 17, 2007, 06:22:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Steve-R

I have the following code working at the link below the code, you can see its set to Top Rated but I wonder if I have found a bug of sorts. Today I went through and removed al votes from the gallery and coppermine does not show any of the photos in its Top Rated area, but this script still does and it can be seen that all Pic ratings and votes are set at zero.

Is this a bug? Or is there a way to get round this.


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


Coppermines "Top Rated" area

http://www.photocumbria.com/SdGall/thumbnails.php?album=toprated&cat=0


Steve...:)

Steve-R

Anyone any ideas why the files with votes removed are still showing in cpmfetch but not in the top rated area of coppermine?

Steve...:)

Nibbler

Top rated meta album in Coppermine has a definable lower limit on the number of votes a file must have to be displayed. I expect cpmFetch does not do this, and simply sorts by rating/votes including the zeros.

Steve-R

The php file is in the first post, would it be possible to add some php at the end of the file to stop images showing that have zero votes?

OR

Is it possible to edit CPM Fetch to add the definable lower limit that must exist to display the pictures?

Many thanks in advance!

Steve...:)

Infernal

files with 0 votes still show because you have less pictures with votes then you want to show there
it happened to me to and that was the cause
and another thing if a picture has 1 vote of 5 it will appear above a picture that had 10 votes and 4.8

Steve-R

I've solved this one, topic can be marked as such. Here is how I did it.


In cpmfetch_dao.php

Find:


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);
}


Change to:


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);
}




This now only shows pictures that have one or more votes (and therefore has a pic-rating too) on it.

@ Infernal: Look at this line above . " ORDER BY p.votes DESC LIMIT 0,$count"; I changed it from p.pic_rating to p.votes  My list now shows in vote order.


Steve...:)