[SOLVED] Random Block works on dev server, not on prod

coberg

Joined: 2005-12-13
Posts: 13
Posted: Thu, 2006-02-02 02:44

Gallery URL (optional but very useful): http://www.flagsonthe48.org/forums/modules.php?op=modload&name=gallery&file=index
Gallery version: 1.5.2
Apache version: 1.3.33
PHP version (don't just say PHP 4, please): 4.4.1
Graphics Toolkit: ImageMagick
Operating system: Debian
Web browser/version (if applicable): all
Gallery is embedded in phpBB 2.0.19

I recent moved this website over from another host where the image block was working well. Once I got it to the new host, it stopped working but only in the one way I needed it to work. If I simply link to the block-random.php file everything works well, but then when anyone clicks on the image, they go to the non-embedded version which I don't want. If I use the full embedded URL I get errors:

Quote:
main(/home/the8r/flagsonthe48.org/forums/modules.php?op=modload&name=gallery&file=index&include=block-random.php): failed to open stream: No such file or directory

main(): Failed opening '/home/the8r/flagsonthe48.org/forums/modules.php?op=modload&name=gallery&file=index&include=block-random.php' for inclusion (include_path='.:/usr/local/lib/php')

Oddly enough, when I use this exact configuration on my dev server (FC4, Apache 2.0.54, php 5.0.4) and point to the Gallery on the production server, it works fine!

I posted a sample of what I mean: http://www.flagsonthe48.org/testindex.php

Any help would be appreciated! Thanks!

 
ckdake
ckdake's picture

Joined: 2004-02-18
Posts: 2258
Posted: Wed, 2006-02-08 02:03

"when I use this exact configuration on my dev server (FC4, Apache 2.0.54, php 5.0.4) and point to the Gallery on the production server"

perhaps it has to do with url fopen versus local file fopen?

 
coberg

Joined: 2005-12-13
Posts: 13
Posted: Sun, 2006-02-12 21:15

Thought I would post the solution to this, since it was not found here. It turns out that with allow_url_fopen disabled, php has to be able to serve exactly what is written in the include, so if I reference the block-random.php file itself, we're all set. However, when Gallery is embedded in phpBB, the block-random.php file called within the modules.php page, so php has to parse all of the "?op=modload&name=gallery&file=index&include=block-random.php" - which it can't do, so it tries to call a file with all that extra information, which it can't do.

So the solution?

Use cURL. The code I used is:

Quote:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://example.com/forums/modules.php?op=modload&name=gallery&file=index&include=block-random.php');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?>

Problem solved.

 
Bobby Lei

Joined: 2006-03-01
Posts: 7
Posted: Wed, 2006-06-28 06:33
Quote:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://example.com/forums/modules.php?op=modload&name=gallery&file=index&include=block-random.php');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?>

Thanks!! Great solution, really handy a forum like this, also found another solution just ago, keep it coming!