cfig_random error after upgrade to 2.1.1 cfig_random error after upgrade to 2.1.1
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

cfig_random error after upgrade to 2.1.1

Started by gmc, March 11, 2009, 05:11:16 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gmc

I think I've worked through my problems as I was gathering the doc to type this... but noting a change I didn't need to make in 1.6.2 that I didn't see doc'd anywhere... (or I missed it...)
I've been a CPG user since 2004.. and CPMFETCH since 2006 - used on multiple websites

Upgraded CPG to 1.4.21 successfully....
Attempted to upgrade CPMFETCH to 2.0.0.
Upgrades were to 'clean' directories (preserved only albums folder and database)

install.php worked fine and produced images from the gallery.
Received messages from cfimageget.php noted in post:
  http://forum.coppermine-gallery.net/index.php/topic,44327.0.html :
 
QuoteCF-Error  CF-Error
Warning: Cannot modify header information - headers already sent by (output started at /home/gmcdesign/www/bkgallery/cpmfetch_200/cpmfetch_dao.php:1314) in /home/gmcdesign/www/bkgallery/cpmfetch_200/cfimageget.php on line 260

Warning: Cannot modify header information - headers already sent by (output started at /home/gmcdesign/www/bkgallery/cpmfetch_200/cpmfetch_dao.php:1314) in /home/gmcdesign/www/bkgallery/cpmfetch_200/cfimageget.php on line 261

Noted comment about V2.1.1 being uploaded to correct problem, and found note in 2.1.1 release notes:
QuoteChanges to cfimageget
2007-06-20 05:43  wbchmura
   * .: Fixes to make it compatible with cpmfetch 2.x. Also added in
     normal as alias to int, cat as an alias to category.

So I upgraded to developers version 2.1.1...
install.php worked once again...
cfimageget.php now works fine...
cfig_random.php produced error:
Quotecfimageget.php is not enabled. Edit the file to change the ALLOW_DIRECT_ACCESS line to be true.
However, cfimageget.php contains:
// CHANGE THIS TO TRUE IF PEOPLE ARE ALLOWED QUERIES THROUGH HERE
$ALLOW_DIRECT_ACCESS = true;


Chasing where the error message gets produced - the code appears to be enforcing calling script name as well:
if ($ALLOW_DIRECT_ACCESS && substr($_SERVER['SCRIPT_FILENAME'],-14) == "cfimageget.php") {

I altered code in CFIMAGEGET.PHP to:
if ($ALLOW_DIRECT_ACCESS && (substr($_SERVER['SCRIPT_FILENAME'],-14) == "cfimageget.php"   ||
                             substr($_SERVER['SCRIPT_FILENAME'],-15) == "cfig_random.php")) {

Is there something I missed that would have eliminated the need for a code change?
The same code appears to be in place with V1.6.2 - but I didn't run into this situation there??

I understand 2.1.1 is not the stable version, but appears from doc that 2.0.0 cfimageget.php had a problem - and I heavily use this portion of the code.

Gallery is at:  http://bkgallery.gmcdesign.com
You can run install.php if needed - no overrides made to config file.  (I assume I should rename this file after install to prevent others from running...)
http://bkgallery.gmcdesign.com/cpmfetch/cfimageget.php and http://bkgallery.gmcdesign.com/cpmfetch/cfig_random.php now both produce images...
Thanks for all the efforts on CPMFETCH...
Greg
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

gmc

Well... the changes I made below did allow the random images to be displayed... Didn't jump out at me on the site listed below - but made same changes on another site - and appears setting the source to restrict random images to certain categories or albums isn't being honored...
The pieces appear to be there - I can't figure out why its not working.  I must be missing something...

Working with site http://www.skymasters.org - with the gallery in subdomain http://gallery.skymasters.org for this post.
(virtually all photos on main site are served via cpmfetch with calls to the gallery - heavily using the album and category filtering to display relevant pictures... Right now they are all just random photos...  I have some custom code that converts keywords to album and category numbers - so pages don't need to change as new albums are added - just the common code.  I've eliminated that code in the examples below to insure it isn't the issue...)

I created a copy of cfig_random.php named cfig1_random.php (and adjusted the check in cfimageget.php for $_SERVER['SCRIPT_FILENAME' to accept the new filename).
The only other change was to restrict the source to a single album before making the call for a random image via:
$cpmfetch->setSourceString("album=68");
$cpmfetch->getRandom();

This can be invoked with url:  http://gallery.skymasters.org/cpmfetch/cfig1_random.php
If working properly, the pictures returned should all be model airplanes flying at an indoor soccer arena... no outdoor photos - no water - etc...

Following through the code in cfimageget.php:
    function getRandom( ) {
        $resultset = $this->cpm->getRandomImageFrom($this->getSourceString(),1);               
        $this->_dumpPhoto($resultset); 
    }

goes to get the source string...
    function getSourceString( ) {
        $fullString = "";
       
        if ($this->albumSelection == "" && $this->categorySelection == "") {
            $fullString = $this->sourceString;
        } elseif ( $this->albumSelection != "" && $this->categorySelection == "") {
            $fullString = "album=" . $this->albumSelection;
        } elseif ( $this->categorySelection != "" && $this->albumSelection == "") {
            $fullString = "cat=" . $this->categorySelection;
        } else {
            $fullString = "cat=" . $this->categorySelection . ":album=" . $this->albumSelection;
        }
   
        return ($fullString);
    }

since no calls were made to set the albumSelection or categorySelection - the sourceString should be returned here...

On to getRandomImageFrom in cpmfetch_dao.php...
function getRandomImageFrom ($source, $count) {
    $resultset = array();

    if (is_numeric($count)) {

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

makeSourceSQL appears to parse and build sql based on keywords in source...
Don't see why it isn't working...

Tried another approach and created cgif2_random.php - url:  http://gallery.skymasters.org/cpmfetch/cfig2_random.php
Replaced:
$cpmfetch->setSourceString("album=68");
with
$cpmfetch->setAlbumSelection("68");
but still see the same problem...
Not sure where to go from here... Any help/suggestions would be welcome.

I saw another thread - http://forum.coppermine-gallery.net/index.php/topic,56038.0.html - where vuud indicated in January that "There is a total rebuild in the works... "   Should I be waiting for that?

(vvud - I also picked up a D90 in January... upgrade from D70.  Very nice camera.)

Thanks for the help!
Greg
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

gmc

I had to backoff my production gallery to cpmfetch 1.6.4 from 2.1.1 since I haven't been able to resolve the problem...
I have a test subdomain where you can still see the error... It is a smaller gallery (to save space), but still shows the problem.

URLS:
testgallery.skymasters.org - base gallery
testgallery.skymasters.org/cpmfetch/cfig_random.php - random pics from gallery requested - works fine
testgallery.skymasters.org/cpmfetch/cfig1_random.php - random pics from single album requested
(If working properly, the pictures returned should all be model airplanes flying at an indoor soccer arena... no outdoor photos - no water - etc...)
testgallery.skymasters.org/cpmfetch/cfig2_random.php - same as above but uses setAlbumSelection instead of setSourceString
testweb.skymasters.org/events/indoor/ - page that attempts actual display on site... 6 thumbnails appear on page - all should be 'indoor' flying.

Additional comments in my previous posts for what I have looked at and tried...
Thanks!
Greg
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money