Using CPMFetch in 2 Installations - can not redeclare class cpm Using CPMFetch in 2 Installations - can not redeclare class cpm
 

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

Using CPMFetch in 2 Installations - can not redeclare class cpm

Started by capecodgal, August 14, 2007, 05:24:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

capecodgal

Starting another thread since I ran into a second issue and didn't want to bog down the first thread

I have coppermine running out of 2 directories /photos and /videos

The cpmfetch in the /photos works like a charm no issues

I installed it in the /videos directory and set it up just like I did the first, made 1 small modification to the dao.php to only show jpg files
When I run the install I see the images, no problem and so far my jpg filter seems to be working as thats what I got
When I add the code to my php page It states:


Fatal error: Cannot redeclare class cpm in /home/user/public_html/videos/cpmfetch/cpmfetch.php on line 1698

ex: www.julianmcmahonfan.com/header2.php


Thanks in advance for any direction you can give-

Since the test page worked I am rather lost as to why it isn't working here unless it is because I have a few other includes from the /photos on the same page?

Some more info:

Both installs run on the same SQL user (different database but same user, as far as I know this is not considered bridged as they each have there own user tables)

Nibbler

Message means you are trying to load the script twice on the same page. Change it to include_once or require_once if you can't see where you are doing this.

capecodgal

hmmm ok I get what you are saying and you were right I did forget the include_once but it still doesn't work and I get the same error. If I take the exact same include and change the path to /photos rather than /videos it works so I think my code is right.... it could be the filter maybe I did that wrong since thats the only other difference. I had used the cm_dao.php to set the filter to .jpg only (I thought I did it right as the test page showed only JPG images). Was I not supposed to change the actual file and only add the filter to the include? When I read the docs I thought it said to add the filter to the file if it was going to be global on all includes from that directory

here is the exact code on the page:

the top one from /photos works but as soon as I go to /videos it doesn't work and I get the same error



<table width="100%" cellpadding="0" cellspacing="0" align="center">
<tr><td class="h1">Random Image Uploads</td></tr>
<tr><td class="side_content">
<center>
<?php 
include_once "./photos/cpmfetch/cpmfetch.php";
$objCpm = new cpm('./photos/cpmfetch/cpmfetch_config.php');
$options = array( 'windowtarget' => '_blank');
$objCpm->cpm_viewRandomMediaFrom("cat=5,45,47,6,12,13,15,16,17,19,46,43,44,48,49,27,25,8,9,26,28:album=0",2,2,$options);
$objCpm->cpm_close(); 
?>

</center>
</tr></td></table>



<table width="100%" cellpadding="0" cellspacing="0" align="center">
<tr><td class="h1">Latest Video Uploads</td></tr>
<tr><td class="side_content">
<center>
<?php 
include_once "./videos/cpmfetch/cpmfetch.php";
$objCpm = new cpm('./videos/cpmfetch/cpmfetch_config.php');
  
$objCpm->cpm_viewLastAddedMedia(1,1);
  
$objCpm->cpm_close();
?>

</center>
</tr></td></table>

capecodgal

took another look at this my .jpg filter was wrong but I have since gotten that working  ;D

If I only show the videos = no problem, only photos = no problem, multiple sets of functions (random, last, etc) from one install = no problem

Its as soon as I try to pull from a second install it breaks, whether it be the photos or the videos (I tried reversing them)

Here is the latest code I am using:

<table width="100%" cellpadding="0" cellspacing="0" align="center">
<tr><td class="h1">Latest Video Uploads</td></tr>
<tr><td class="side_content">
<center>

<?php
 
require_once "./videos/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./videos/cpmfetch/cpmfetch_config.php");
$options = array( 'imagesize' => 'thumb');
$objCpm->cpm_setfilter($filter ".jpg");
$objCpm->cpm_viewLastAddedMedia(2,1,$options,$filter);
$objCpm->cpm_close();
?>

</center>
</tr></td></table>

<table width="100%" cellpadding="0" cellspacing="0" align="center">
<tr><td class="h1">Latest Image Uploads</td></tr>
<tr><td class="side_content">
<center>

<?php
 
require_once "./photos/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./photos/cpmfetch/cpmfetch_config.php");
$options = array( 'imagesize' => 'thumb');
$objCpm->cpm_setfilter($filter ".jpg");
$objCpm->cpm_viewLastAddedMedia(2,1,$options,$filter);
$objCpm->cpm_close();
?>

</center>
</tr></td></table>





I am not trying to push just updating progress to make sure you have accurate info-

yazeft

hey, i've got this code but it doesnt seem to do the filter:

<?php
include "./gallery/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_setfilter($filter ".jpg");
$objCpm->cpm_viewRandomMedia(1,5, array('alttag' => '%t'),$filter);
?>


<?php
$objCpm
->cpm_formatStats("<b>%f</b> files with <b>%n</b> comments viewed <b>%v</b> times<br>");
$objCpm->cpm_setfilter($filter ".jpg");
$objCpm->cpm_viewLastAddedMedia(1,5, array('alttag' => '%t'),$filter);
$objCpm->cpm_close();
?>


these are in two different source files to work with smf on the homepage in 2 different sections.. i'm trying only to show .jpg from the gallery.

yazeft

i've just went through the error log in SMF and found this:

Quote8: Undefined property: cpm::$ AND ( p.filename like '%.jpg' OR p.filename like '%.JPG' OR
File: /home/me/public_html/gallery/cpmfetch/cpmfetch_dao.php
Line: 182

does this help?

capecodgal

Quote from: yazeft on August 15, 2007, 05:55:43 AM
i've just went through the error log in SMF and found this:

does this help?

in the docs it talks about older versions using the % symbol in the filters..... go read up on cpm_dao in the docs - I think that is your problem, maybe you need to add the % into your code. Mine worked without it.