Random block with no fopen(url)

personman

Joined: 2005-01-04
Posts: 14
Posted: Fri, 2005-09-16 12:34

I used to use the random photo block and I loved it, then I switched webhosts and the new host doesn't allow fopen() or include() with an url. I can't use a disk path because the blog and the gallery are on different servers. Dreamost docs say that cURL can be used instead. Has anyone run into this problem and found a workaround? Is there a way to call the random image using cURL rather than @readfile()? Thanks.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-09-16 13:46

yes, it works with curl:
(using forum search leads to) darn, can't find anything with the search function.
but yes, someone posted about 6 month ago how to do it with curl.

i've searched for curl and restricted the search to the g2 forums, didn't get anything useful. maybe someone else has more luck.

 
personman

Joined: 2005-01-04
Posts: 14
Posted: Fri, 2005-09-16 15:41

This did the trick:

<?php
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://www.personman.com/gallery/main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=title');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
echo $file_contents;
?>

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-09-16 15:59

can you edit your post? i just see an empty quote.

 
personman

Joined: 2005-01-04
Posts: 14
Posted: Fri, 2005-09-16 16:01

Sorry about that. It's fixed now.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-09-16 16:48
 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2005-09-22 02:08

is there a way to use @readfile() with a return instead of an echo?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-09-22 08:50

no.

on the same server, you can also use GalleryEmbed::getImageBlock() which of course return and doesn't echo.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2005-09-22 10:35

but how do I return just the random image and not the whole array? like the curl and @readfile above?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-09-22 10:42

you mean you just want the url, not more? that would be a (popular) feature request for the getImageBlock function.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2005-09-22 11:46

On my site I use the curl random image block, to point to my Geeklog G2 integration package with a url of /GL_Gallery2/index.php?g2_view=imageblock.External&g2_blocks=randomImage, but my problem is that not all geeklog owners will have curl enabled and the @readfile echos and not returns putting the image at the top of the page.
So I want to extract just the random photo from the imageblock(not the search, and dhtml tree actions... that stuff comes later)Kinda like the G1 random photo block.
I call the entire imageblock inside gallery (sidebarBlocksHtml).
Otherwise my homepage gets too crowded, that sidebar is huge with all the features enabled.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-09-22 12:03

so this is actually about the sidebar blocks?
search, dhtml album tree,. ... are not image blocks. these are just blocks that happen to be in your sidebar.

what i recommend:
- take a look at GalleryEmbed docs/EMBEDDING
- use GalleryEmbed::getImageBlock() for imageblocks

 
bzsolt

Joined: 2007-04-01
Posts: 43
Posted: Sun, 2007-10-28 15:41

Hi Guys,

I have fopen_url ON but my host disabled "http request back to the same server". Does that say anything to you? Any ideas how to solve this?

TIA!

 
bzsolt

Joined: 2007-04-01
Posts: 43
Posted: Fri, 2007-11-02 23:37

If you have same problem like me use: mod_g2bridge_image_v2.7.zip or later version from here: http://joomlacode.org/gf/project/gallery2_bridge/frs/