displaying images on a different domain displaying images on a different domain
 

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

displaying images on a different domain

Started by iain sherriff, July 31, 2008, 05:10:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

iain sherriff

The installation of cpmfetch was faultless  :)

My gallery is at
lo-rdz.co.uk
[so lo-rdz.co.uk/cpmfetch/ ]

My phpbb3 board is at
lowriderforums.com/forum

I have put the code

<?php
  
include "http://www.lo-rdz.co.uk/cpmfetch/cpmfetch.php";
  
$objCpm = new cpm("http://www.lo-rdz.co.uk/cpmfetch/cpmfetch_config.php");
  
$objCpm->cpm_viewLastAddedMedia(1,4);
  
$objCpm->cpm_close();
?>


where i want the images to display................ but nothing shows.
The code is in the .html template [overall_header.html] and is inside the DIV whre you can see the grey bar below the nav section

http://www.lowriderforums.com/forum

What have I missed or need to change plese?

poubao

You have missed to read this cpmfetch
try to use relative path like this: ./cpmfetch/cpmfetch.php  and ./cpmfetch/cpmfetch_config.php
poubao :D
L'incohérence de ceux qui nous dirigent, l'incompétence de ceux qui nous commandent,sont un vibrant hommage pour ceux qui exécutent.
                                          **Général Patton**

iain sherriff

are you saying that I can only use this to display images in a page on the same domain as the cpm ? 

iain sherriff

Quote from: iain sherriff on July 31, 2008, 06:53:47 PM
are you saying that I can only use this to display images in a page on the same domain as the cpm ? 

reading the docs agin I guess you are......... it doesnt actually say you cant use different domains but all the examples given are on the same domain..........

capecodgal

it works on different domains and different servers but think about what you are asking for.... you need to use a relative path in cpmfetch so how are you going to do that on a remote server? You can't to my knowledge unless someone knows something different I would love to see how that would work

here's how I made it work - IFRAMES

example create your cpmfetch code in a php file on the server that has the cpmfetch on it. then on the other domain / server use an iframe script to call the php file with the code in it

sure there are other ways- this is just how **I** made mine work

example:

http://disneystarsnetwork.com

the latest photos and videos are all pulled from other domains (same server in this case) but you get the idea this will work on other servers as well

muskrat

I've found a way to do this with php, but I'm not sure how clever I am at explaining it.

The problem I had was that for every page on website where I wanted pictures displayed from a different category or album combination, I needed to create a new cpmfetch page on the coppermine website, and then include or get_file_contents it using php. It got tedious after a while with more than a handful of pages. So this is what I did.

1. Add a /cpmfetch/cpmfetch-new.php file on your coppermine website with display configuration you want on display website.
2. On display website, add a file called images-or-something.php that you will include on any page you want to have images from your coppermine website. If you're familiar with php, then save it in your /includes/ folder if you have one. It should have the following php lines:

$copperminepath = "http://www.yourcopperminewebsite/cpmfetch/cpmfetch-new.php";
$coppermineimages = file_get_contents($copperminepath);
echo $coppermineimages;


3. On pages where you want images displayed, just include the file from #2.

This works for me on my shared server configuration which won't allow me to fopen, include, fread etc from another domain name, even if it's on the same account. I can't guarantee it works in all situations.

If you want variable output depending on the page content, here's what I did.

4. I have the variable $album which I set in php in header of page before html e.g.

$album = 1
$album = 1,2,3 (yes I think it works when you do this).
etc

Now, go back to step 2, add a ? at the end of the path string, then you can add the $album value as a URL variable to pass through to your coppermine site.

$copperminepath = "http://www.yourcopperminewebsite/cpmfetch/cpmfetch-new.php?";
if(isset($album)) {$copperminepath .= 'album='.$album;}
$coppermineimages = file_get_contents($copperminepath);
echo $coppermineimages;


5. In your cpmfetch-new.php file, you need to GET the variables for processing e.g.

if(isset($_GET['album')) {$album=$_GET['album'];}

Then somewhere in your code, you need this line

$objCpm->cpm_viewRandomMediaFromAlbum(1, 2, $album, $cpmoptions);

Which takes 1 row of 2 images from the albums specified by $album, according to your $cpmoptions array for formatting.

This can be extended to categories also, maybe both. And of course some of the coding can be modified to check if variables are set or not, to sanitize them, etc. I'm only trying to give the general idea.

I tried to do this with both albums and cats and the cpm_viewRandomMediaFrom() function but couldn't get it to work, so have used the cpm_viewRandomMediaFromAlbum and ...FromCategory functions separately.

Sorry if you're not familiar with php, I don't know an easy way to explain how to do this then :(.

muskrat

Quote from: muskrat on May 30, 2010, 07:30:13 PM$album = 1,2,3 (yes I think it works when you do this).
A minor update, that line should read

$album = "1,2,3"; or $album = '1,2,3';

i.e. variable needs to be a string. With just one album (or category), quotation marks are not necessary.