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. |
|
| Login or register to post comments |

Posts: 32506
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.
Posts: 14
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;
?>
Posts: 32506
can you edit your post? i just see an empty quote.
Posts: 14
Sorry about that. It's fixed now.
Posts: 32506
thanks a lot for sharing!
i've added it to:
http://codex.gallery2.org/index.php/Gallery2:How_To_Use_The_External_Image_Block_When_url_fopen_Is_Disabled
Posts: 4115
is there a way to use @readfile() with a return instead of an echo?
Posts: 32506
no.
on the same server, you can also use GalleryEmbed::getImageBlock() which of course return and doesn't echo.
Posts: 4115
but how do I return just the random image and not the whole array? like the curl and @readfile above?
Posts: 32506
you mean you just want the url, not more? that would be a (popular) feature request for the getImageBlock function.
Posts: 4115
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.
Posts: 32506
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
Posts: 39
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!
Posts: 39
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/