cpmfetch in two php-Blocks? cpmfetch in two php-Blocks?
 

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

cpmfetch in two php-Blocks?

Started by jensderknipser, March 04, 2007, 09:51:38 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

jensderknipser

Hi,

What's about this. I have a cpm-code in a php-block placed in the leftbar and as well another cpm-call placed on the frontpage. Each of them is doing its job, each of them means "either the one in the leftbar  o r  the one in the frontpage" - and this is my problem. Something wrong with my calls???

see code below:

leftbar-code
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/picts-online-live/cpg");
$options = array( 'imagelink' => 'none');
$objCpm->cpm_viewRandomMediaFrom(1,1, $source="cat=6:album=15", $options);
$objCpm->cpm_close();


code in the frontpage-block:
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/picts-online-live/cpg");
$options = array( 'imagesize' => 'large', 'imagelink' => 'none');
$objCpm->cpm_viewRandomMediaFrom(1,1, $source="cat=0:album=10", $options);
$objCpm->cpm_close();


Using cgp 1.4.9, smf1.1.2 bridged, cpmFetch1.6.4


Thanks in advance,
jens

vuud

Quote from: jensderknipser on March 04, 2007, 09:51:38 PM
Hi,

What's about this. I have a cpm-code in a php-block placed in the leftbar and as well another cpm-call placed on the frontpage. Each of them is doing its job, each of them means "either the one in the leftbar  o r  the one in the frontpage" - and this is my problem. Something wrong with my calls???

see code below:

leftbar-code
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/picts-online-live/cpg");
$options = array( 'imagelink' => 'none');
$objCpm->cpm_viewRandomMediaFrom(1,1, $source="cat=6:album=15", $options);
$objCpm->cpm_close();


code in the frontpage-block:
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/picts-online-live/cpg");
$options = array( 'imagesize' => 'large', 'imagelink' => 'none');
$objCpm->cpm_viewRandomMediaFrom(1,1, $source="cat=0:album=10", $options);
$objCpm->cpm_close();


Using cgp 1.4.9, smf1.1.2 bridged, cpmFetch1.6.4


Thanks in advance,
jens


Hi Jens,

First - the dev release is much better with bridged CPG galleries.  You will need to follow the release note instructions for installing and using.

Second - if this is all on the same PHP page, you can eliminate much of the code into something like this:


//Top of the page
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/picts-online-live/cpg");


... whatever in here...

//Left bar code
$options = array( 'imagelink' => 'none');
$objCpm->cpm_viewRandomMediaFrom(1,1, $source="cat=6:album=15", $options);


... whatever in here...

//frontpage-block:
$options = array( 'imagesize' => 'large', 'imagelink' => 'none');
$objCpm->cpm_viewRandomMediaFrom(1,1, $source="cat=0:album=10", $options);

... whatever in here...

//Bottom of page:
$objCpm->cpm_close();


Third, I have no idea what your original problem was... I could not understand what it was doing that you did not like.

Sorry.





Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jensderknipser

Hi Vuud,

thanks for the fast reply and your advice to install the developer-version. Will be done ;)

My problem is, that, if I have the block in the leftbar activated, the call on the frontpage-block won't be shown and viceversa. Means, that I now have to decide to show either the block in the leftbar or the block in the frontpage - it seems not be possible to run both at one time.

QuoteSecond - if this is all on the same PHP page, you can eliminate much of the code into something like this:

True, but the structure of TP-smf doesn't allow this. Everything is organised in elements like blocks or articles, and that's why I'm always talking about "blocks" etc - sorry. But anyway - I will try to solve it whith the developer-edition, sure there will be a solution....

I will post a report later after testing this out, ok?

ciao, jens

vuud

Quote from: jensderknipser on March 04, 2007, 10:30:47 PM
Hi Vuud,

thanks for the fast reply and your advice to install the developer-version. Will be done ;)

My problem is, that, if I have the block in the leftbar activated, the call on the frontpage-block won't be shown and viceversa. Means, that I now have to decide to show either the block in the leftbar or the block in the frontpage - it seems not be possible to run both at one time.

True, but the structure of TP-smf doesn't allow this. Everything is organised in elements like blocks or articles, and that's why I'm always talking about "blocks" etc - sorry. But anyway - I will try to solve it whith the developer-edition, sure there will be a solution....

I will post a report later after testing this out, ok?

ciao, jens

Ah, your working in the SMF template itself eh...

If you can post an example, I can probably help some... but get up to the dev version.  I'd also recommend leaving the cpm_close() off of both when using it in a template.   You may also trying giving the $objCpm different names in each block...

$objCpmLB

and

$objCpmFB

They could be messing with each other.



Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jensderknipser

Hi Vuud,

QuoteIf you can post an example, I can probably help some...

sure. Take a look at the site here: http://www.picts-online.com Still testing-stage and currently only in german...  The appropriate codings were in my first post, if it helps? And see, at this site the leftbar-block isn't already installed resp. is deactivated, so that you might at least get an impression of what I'm trying to do via the frontpage there (uuuhhh - it's late in the evening and my english is getting "better and better"...).

I'll post a results-message tomorrow after changing everything as you recommended - getting closer to a solution step by step 8)

ciao, jens

jensderknipser

Hi Vuud,

OK, install of dev1.9.1 was succesful, but - sorry, I don't want to frustrate you here - the problem is still alive :o
So I'm going now to read the docs super-mega-carefully now in order to find my mistake, butI think you are right in suspecting conflicts between the two $objcpm-definitions. But doing so like you suggested is serving a blank page in the center and a completely missing box in the left panel. Strange, isn't it?

As I said before - step bey step... 8)
ciao, jens

vuud

Quote from: jensderknipser on March 05, 2007, 08:28:01 PM
Hi Vuud,

OK, install of dev1.9.1 was succesful, but - sorry, I don't want to frustrate you here - the problem is still alive :o
So I'm going now to read the docs super-mega-carefully now in order to find my mistake, butI think you are right in suspecting conflicts between the two $objcpm-definitions. But doing so like you suggested is serving a blank page in the center and a completely missing box in the left panel. Strange, isn't it?

As I said before - step bey step... 8)
ciao, jens


1.9.1 or 1.9.11

Big difference there...

I am not sure just the upgrade will help, but at least now we are using code I am recently familiar with and will be supporting.

You tried the renaming one of the objects?  Can you post the code that you are using now?

Thanks!
Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jensderknipser

Hi,
downloaded and installed 1.9.11 with no problems. After this I have changed the calls in both files (see below), and----well, let's try again ;)

leftbar:

echo '
<html>
<body>
<center>
';

include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("./cpmfetch/cpmfetch_config.php");
$options = array( 'imagelink' => 'none');
$objCpm->cpm_viewRandomMediaFrom(1,1, $source="cat=6:album=15", $options);
//$objCpm->cpm_close();

echo '
Das Pro-Portfolio dieses Monats kommt von dem Münchner Fotodesigner enzo. Mit freundlicher Unterstützung von Fineart-printer.
</center>
</body>
</html>
';


and this is the frontpage-code:
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("./cpmfetch/cpmfetch_config.php");
$options = array( 'imagesize' => 'large', 'imagelink' => 'none');
$objCpm->cpm_viewRandomMediaFromAlbum(1,1,$source="cat=0:album=10",$options);
//$objCpm->cpm_close();


Renaming the objects to i.e.
$objCpmLB->cpm_viewRandomMediaFromAlbum...

or respectively
$objCpmFB->cpm_viewRandomMediaFromAlbum...

ended in a blank frontpage resp. a totally missing box in the leftbar.

In the meantime I was already resetting the bridge with the cpg-bridge-assistant plus that I have made a DB-refresh via cpg, but even this actualisation had no effect...
VuuD, Thank you so much for your patience (and this genious script) I'm sure we'll get it.

ciao, jens

vuud

Quote from: jensderknipser on March 05, 2007, 10:41:39 PM
Hi,
downloaded and installed 1.9.11 with no problems. After this I have changed the calls in both files (see below), and----well, let's try again ;)

leftbar:

echo '
<html>
<body>
<center>
';

include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("./cpmfetch/cpmfetch_config.php");
$options = array( 'imagelink' => 'none');
$objCpm->cpm_viewRandomMediaFrom(1,1, $source="cat=6:album=15", $options);
//$objCpm->cpm_close();

echo '
Das Pro-Portfolio dieses Monats kommt von dem Münchner Fotodesigner enzo. Mit freundlicher Unterstützung von Fineart-printer.
</center>
</body>
</html>
';


and this is the frontpage-code:
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("./cpmfetch/cpmfetch_config.php");
$options = array( 'imagesize' => 'large', 'imagelink' => 'none');
$objCpm->cpm_viewRandomMediaFromAlbum(1,1,$source="cat=0:album=10",$options);
//$objCpm->cpm_close();


Renaming the objects to i.e.
$objCpmLB->cpm_viewRandomMediaFromAlbum...

or respectively
$objCpmFB->cpm_viewRandomMediaFromAlbum...

ended in a blank frontpage resp. a totally missing box in the leftbar.

In the meantime I was already resetting the bridge with the cpg-bridge-assistant plus that I have made a DB-refresh via cpg, but even this actualisation had no effect...
VuuD, Thank you so much for your patience (and this genious script) I'm sure we'll get it.

ciao, jens


You know, I am going to bet that error reporting is turned down in SMF and we are missing some helpful message PHP just wants to give us.

Try inserting this before both of those

error_reporting(E_ALL);
ini_set('display_errors',1);  // 0 is off, 1 is on

This will have PHP dump all errors and warnings.

I suspect we will see something about having the include twice...

Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jensderknipser

did that, activated both and voila:

QuoteFatal error: Cannot redeclare class cpm in /Applications/MAMP/htdocs/picts-online-live/cpmfetch/cpmfetch.php on line 33

Line#33-39 in my cpmfetch.php shows:
class cpm extends cpm_dao {

var $VERSION = "1.9.11";

var $optionHash = array(); //Contains the options submitted by the user
var $styleHash = array();
var $returntype = "print"; // print, html, resultset


It's interesting, that the text of the leftbar-box, embedded with 'echo 'xxxxx'; is parsed correctly, only the cpmcall isn't done?

vuud

Quote from: jensderknipser on March 05, 2007, 11:39:23 PM
did that, activated both and voila:

Line#33-39 in my cpmfetch.php shows:
class cpm extends cpm_dao {

var $VERSION = "1.9.11";

var $optionHash = array(); //Contains the options submitted by the user
var $styleHash = array();
var $returntype = "print"; // print, html, resultset


It's interesting, that the text of the leftbar-box, embedded with 'echo 'xxxxx'; is parsed correctly, only the cpmcall isn't done?


Its not in that file... its having the two includes.  The second include is trying to run that code again

Take the include out of the block you feel executes second... if you take it out of one and get an error about an unknown class, do the other one instead

Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jensderknipser

OK, this is what I did (hopefully understood everything?):

in the leftbar:
error_reporting(E_ALL);
ini_set('display_errors',1);  // 0 is off, 1 is on
//include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("./cpmfetch/cpmfetch_config.php");
$options = array( 'imagelink' => 'none');
$objCpm->cpm_viewRandomMediaFrom(1,1, $source="cat=6:album=15", $options);
//$objCpm->cpm_close();


result: no frontpage, just this in the leftbar:
Quote
Fatal error: Cannot instantiate non-existent class: cpm in /Applications/MAMP/htdocs/picts-online-live/Sources/Load.php(1736) : eval()'d code(35) : eval()'d code on line 10

Doing the same thing in the frontpage-block, so that both includes are taken out, gets the same result and error-message.

Leaving the include in the leftbar, in the frontpage-block commented out is giving Frontpage ok, leftbar only the text.

The code in my Sources/Load.php(1736) goes like this: (shown codeblock starts at #1733)
// Are we going to use eval?
if (empty($modSettings['disableTemplateEval']))
{
$file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false;
$settings['current_include_filename'] = $filename;
}
else
{
$file_found = file_exists($filename);

if ($once && $file_found)
require_once($filename);
elseif ($file_found)
require($filename);
}

if ($file_found !== true)
{
ob_end_clean();
if (!empty($modSettings['enableCompressedOutput']))
@ob_start('ob_gzhandler');
else
ob_start();

if (isset($_GET['debug']) && !WIRELESS)
header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));


Uuuuuh - does this help? and - would it help, if I send you the cpm-config via pm?

vuud

Quote from: jensderknipser on March 06, 2007, 12:11:53 AM
OK, this is what I did (hopefully understood everything?):

in the leftbar:
error_reporting(E_ALL);
ini_set('display_errors',1);  // 0 is off, 1 is on
//include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("./cpmfetch/cpmfetch_config.php");
$options = array( 'imagelink' => 'none');
$objCpm->cpm_viewRandomMediaFrom(1,1, $source="cat=6:album=15", $options);
//$objCpm->cpm_close();


result: no frontpage, just this in the leftbar:
Doing the same thing in the frontpage-block, so that both includes are taken out, gets the same result and error-message.

Leaving the include in the leftbar, in the frontpage-block commented out is giving Frontpage ok, leftbar only the text.

The code in my Sources/Load.php(1736) goes like this: (shown codeblock starts at #1733)
// Are we going to use eval?
if (empty($modSettings['disableTemplateEval']))
{
$file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false;
$settings['current_include_filename'] = $filename;
}
else
{
$file_found = file_exists($filename);

if ($once && $file_found)
require_once($filename);
elseif ($file_found)
require($filename);
}

if ($file_found !== true)
{
ob_end_clean();
if (!empty($modSettings['enableCompressedOutput']))
@ob_start('ob_gzhandler');
else
ob_start();

if (isset($_GET['debug']) && !WIRELESS)
header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));


Uuuuuh - does this help? and - would it help, if I send you the cpm-config via pm?



So put it back in the leftbar (the include)

Take it out of the frontpage

So then the leftbar works?  But what gets displayed in the frontpage?

Can you send me a link?


Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jensderknipser

Yees, I'll put the includes like you say; Yes, I'll send you a link; Yes, I'll do anything (almost) you're asking for - but please give me a break: it's here 1:00am, time for me to find a "fistfull of sleep" :D
As all these changes while our efforts where made on my local machine, I will update the data on the public server tomorrow, after this I will send you the link and admin-passwords so that you can examine everything you need to, ok?

Again, thanks a lot and good night for today/tonight... :)
jens

vuud

Quote from: jensderknipser on March 06, 2007, 01:09:32 AM
Yees, I'll put the includes like you say; Yes, I'll send you a link; Yes, I'll do anything (almost) you're asking for - but please give me a break: it's here 1:00am, time for me to find a "fistfull of sleep" :D
As all these changes while our efforts where made on my local machine, I will update the data on the public server tomorrow, after this I will send you the link and admin-passwords so that you can examine everything you need to, ok?

Again, thanks a lot and good night for today/tonight... :)
jens


Okay, look forward to hearing from you then
Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jensderknipser


vuud

Quote from: jensderknipser on March 06, 2007, 08:48:37 PM
Hi Vuud,

PM is sent to you 8)
jens

There is 30 minutes of my life I will never see again.

I did not know you were using CpmFetch for the article at the top - which was what was causing all of our problems.

I took the include out of that article and it all works.

In debugging, I am not sure what I deleted for the center block, but replaced it with cpmfetch.  You'll need to fix that.


Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jensderknipser

V U U D  :D

You're the heroe, the master, the best  :D :D :D :D :D

Thanks for solving this problem, it's perfect now! Plus you've preventing me from installing some extra-slideshows or whatever ;)...

So summarized can we say, that, if one's planning to put more than one calls into a page, do:
1. rename the objects?
2. delete the close in the first call /the one, which will be parsed first)?
3. delete the includes and the closes in the second and all following calls?
(just to keep it simple for a thumb user like me...)

QuoteThere is 30 minutes of my life I will never see again.
...scaring me - was it all such a clutter? Sorry for pushing you in such a horror :-[
Thanks for the great script and your overwhelming help - really!!!

ciao, jens

vuud

Quote from: jensderknipser on March 07, 2007, 11:09:07 PM
V U U D  :D

You're the heroe, the master, the best  :D :D :D :D :D

Thanks for solving this problem, it's perfect now! Plus you've preventing me from installing some extra-slideshows or whatever ;)...

So summarized can we say, that, if one's planning to put more than one calls into a page, do:
1. rename the objects?
2. delete the close in the first call /the one, which will be parsed first)?
3. delete the includes and the closes in the second and all following calls?
(just to keep it simple for a thumb user like me...)

Hmm, more like:

1) only do one include for the whole page (not each block)

2) only create one object if you are using the same gallery, but in your case the evals were causing issues, so yes, new objects each block (although if you do not need to this is wasteful)

3) Don't use a close... its optional mostly


Quote
...scaring me - was it all such a clutter? Sorry for pushing you in such a horror :-[
Thanks for the great script and your overwhelming help - really!!!

I thought you only had two cpmfetch things, there was the third tucked away in that article that caused all the problems.
Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jensderknipser

QuoteI thought you only had two cpmfetch things, there was the third tucked away in that article that caused all the problems.
:-[ :-[ :-[
jens