Advanced search  

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]

Pages: [1]   Go Down

Author Topic: How I use cpmfetch V2.x inside img src ?  (Read 6066 times)

0 Members and 1 Guest are viewing this topic.

Zarzal

  • Coppermine novice
  • *
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 40
How I use cpmfetch V2.x inside img src ?
« on: July 05, 2007, 09:52:31 am »

Hello,
I use cpmfetch long time. Yesterday I change my webserver and by this way I have to upgrade something. Last version I work with was 1.9x and now I change to V2.0 release.
On my old days I use cpmfetch to display a randon image on my homepage (http://www.biker-reise.de/galerie.php) this way:
I write a littel php script (disp_scot.php) containing this:
Code: [Select]
<?php 
require_once "cfimageget.php";
$cpmfetch = new cfimageget();
$cpmfetch->setSourceString("cat=9");
$cpmfetch->getRandom();
?>
and use it at my page like this:
Code: [Select]
<a href="/gallerie/index.php?cat=9"><img src="/gallerie/cpmfetch/disp_scot.php" alt="random scot pics" align="left" /></a>The align=left is used to position the thumb in front of my text and let flow the text around the thumb.

Now I notice that this no longer work with V2.0 or I cannot find out how. All is changed :)
I bring my page to work by replacing the img src code with the propper php code:
Code: [Select]
<?php
include_once "./gallerie/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallerie/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_viewRandomMediaFrom('cat=9',14$options);
$objCpm->cpm_close();
?>
With this I display 4 random pictures direct from cpmfetch. This is a workaround for my but should not the final solution. I like to display one random picture as in my old code to use the alignment. Is there a way to use cpmfetch V2.0 with the img src tag ? I cannot find any examples how to do this.

Regards
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: How I use cpmfetch V2.x inside img src ?
« Reply #1 on: July 05, 2007, 11:16:51 pm »

Hello,
I use cpmfetch long time. Yesterday I change my webserver and by this way I have to upgrade something. Last version I work with was 1.9x and now I change to V2.0 release.
On my old days I use cpmfetch to display a randon image on my homepage (http://www.biker-reise.de/galerie.php) this way:
I write a littel php script (disp_scot.php) containing this:
Code: [Select]
<?php 
require_once "cfimageget.php";
$cpmfetch = new cfimageget();
$cpmfetch->setSourceString("cat=9");
$cpmfetch->getRandom();
?>
and use it at my page like this:
Code: [Select]
<a href="/gallerie/index.php?cat=9"><img src="/gallerie/cpmfetch/disp_scot.php" alt="random scot pics" align="left" /></a>The align=left is used to position the thumb in front of my text and let flow the text around the thumb.

Now I notice that this no longer work with V2.0 or I cannot find out how. All is changed :)
I bring my page to work by replacing the img src code with the propper php code:
Code: [Select]
<?php
include_once "./gallerie/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallerie/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_viewRandomMediaFrom('cat=9',14$options);
$objCpm->cpm_close();
?>
With this I display 4 random pictures direct from cpmfetch. This is a workaround for my but should not the final solution. I like to display one random picture as in my old code to use the alignment. Is there a way to use cpmfetch V2.0 with the img src tag ? I cannot find any examples how to do this.

Regards

You switched to doing it the normal way.  You should go back to using cfimageget and you can still do it.   Or should be able to anyway.  If not, tell me why...

Logged
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

Zarzal

  • Coppermine novice
  • *
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 40
Re: How I use cpmfetch V2.x inside img src ?
« Reply #2 on: July 06, 2007, 04:10:31 pm »

It seems that I have still some trouble on my new server to use it the old way. I get no image and I dont know why. I will investigate this weekend and will report what I find.
Logged

Zarzal

  • Coppermine novice
  • *
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 40
Re: How I use cpmfetch V2.x inside img src ?
« Reply #3 on: July 06, 2007, 04:22:58 pm »

it seems that something is wrong with fopen on my new server. Looks like security restrictions. If I try to call my little php file direct in IE56 I get:
Code: [Select]
<br />
<b>Warning</b>:  fopen(albums/userpics/robert/tag03/thumb_01JUN19222.jpg): failed to open stream: No such file or directory in <b>/path to my space/schottland-2003.de/gallerie/cpmfetch/cfimageget.php</b> on line <b>263</b><br />
Thats why I dont get a picture on my homepage.
Logged

Zarzal

  • Coppermine novice
  • *
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 40
Re: How I use cpmfetch V2.x inside img src ?
« Reply #4 on: July 06, 2007, 05:25:07 pm »

I found whats going on, but dont understand why :) If I change line 233 of cfimageget.php

//$filenametoshow = $_SERVER['DOCUMENT_ROOT'];
$filenametoshow .= $this->cpm->getImageToUse($row['pFilepath'],$row['pFilename'],$this->defaultsize);

to

//$filenametoshow = $_SERVER['DOCUMENT_ROOT'];
$filenametoshow = "http://www.mydomain.tld/coppermineroot/";
$filenametoshow .= $this->cpm->getImageToUse($row['pFilepath'],$row['pFilename'],$this->defaultsize);

it worked as it should. I try to fill out $urltocpm on top of the file but it seems that this is cleared somewhere while executing the script. The hardcode of the missing path statement fix my problem.
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: How I use cpmfetch V2.x inside img src ?
« Reply #5 on: July 06, 2007, 07:27:58 pm »

it seems that something is wrong with fopen on my new server. Looks like security restrictions. If I try to call my little php file direct in IE56 I get:
Code: [Select]
<br />
<b>Warning</b>:  fopen(albums/userpics/robert/tag03/thumb_01JUN19222.jpg): failed to open stream: No such file or directory in <b>/path to my space/schottland-2003.de/gallerie/cpmfetch/cfimageget.php</b> on line <b>263</b><br />
Thats why I dont get a picture on my homepage.


Which version do you have?  Try the latest dev version... there was a bug in 2.0 with cfimageget that I think matches this problem (if I recall correctly).
Logged
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

Zarzal

  • Coppermine novice
  • *
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 40
Re: How I use cpmfetch V2.x inside img src ?
« Reply #6 on: July 06, 2007, 11:29:25 pm »

I use V2.0 release. It seems you are right and there is a bug.
Now I run Dev 2.1.1 and it work as it should. Very nice, I learn a lot and use the cfimageget.php direct with parameter in my website instead using another external php file. I like it.
Thanks for support.

http://www.biker-reise.de/galerie.php
Logged
Pages: [1]   Go Up
 

Page created in 0.041 seconds with 19 queries.