G2 + Roxen + PHP as CGI == broken links

WBTMagnum

Joined: 2005-08-30
Posts: 3
Posted: Tue, 2005-08-30 13:46

hi there,

i am using roxen webserver while running PHP as CGI.

the installation for G2 worked like a charm. i can also access the installation, but when i try to access any of the links provided on this page i end up with broken links. E.g. the links are rewritten to: http://tools.wienfluss.net/cgi-bin/php/gallery2/...

the part "/cgi-bin/php/" stems from the fact that i have to redirect the http request to the PHP binary - that's how roxen runs PHP scripts.

from my point of view, the simpliest solution would be to use relative paths for the links. is there any way to force G2 to use relative paths?

the "trick" mentioned in this forum post (FAQ Gallery:c.22) didn't work for me. G2 was still using absolute links. is there any other way or do i have to stick with G1?

thanks in advance for your help/comments,
sascha

----

Gallery URL (optional): http://tools.wienfluss.net/gallery2/
Gallery version: G2RC2-typical
Webserver (with version): Roxen 4.0.325
Datatabase (with version): MySQL 4.1.10a
PHP version (eg 4.2.1): 4.3.10
phpinfo URL (optional):
Graphics Toolkit(s):
Operating system: Suse 9.3
Web browser/version: Opera 8.0, FF 1.04, IE 6.01
G1 version (for migration bugs):

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-08-30 18:35

can you post a link to phpinfo?
we need to know what $_SERVER variables tell us the base url to use for this webserver.. if you just want to fix your site you can edit modules/core/classes/GalleryUrlGenerator.class, function getCurrentRequestUri()

 
WBTMagnum

Joined: 2005-08-30
Posts: 3
Posted: Tue, 2005-08-30 19:27

here's the link to the phpinfo:
http://gallery.wienfluss.net/phpinfo.php

if you need more information, just ask.

thanks for the tipp with GalleryUrlGenerator.class. i added the following line marked with (+)

}
(+)$path = str_replace("/cgi-bin/php/","/",$path);
return GalleryUtilities::htmlEntityDecode($path);

now G2 works like a charm.

thanks a lot,
sascha

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-08-30 21:51

Can you try this patch instead and let us know if it also works?

Index: modules/core/classes/GalleryUrlGenerator.class
===================================================================
RCS file: /cvsroot/gallery/gallery2/modules/core/classes/GalleryUrlGenerator.class,v
retrieving revision 1.88
diff -u -r1.88 GalleryUrlGenerator.class
--- modules/core/classes/GalleryUrlGenerator.class      23 Aug 2005 03:49:03 -0000      1.88
+++ modules/core/classes/GalleryUrlGenerator.class      30 Aug 2005 21:50:06 -0000
@@ -138,7 +138,12 @@
        if (!($path = GalleryUtilities::getServerVar('REQUEST_URI')) &&
                ($path = GalleryUtilities::getServerVar('SCRIPT_NAME'))) {
            if (($tmp = GalleryUtilities::getServerVar('PATH_INFO')) && $tmp != $path) {
-               $path .= $tmp;
+               if (substr($path, -4) == '/php') {
+                   /* Roxen php-cgi has php itself in SCRIPT_NAME and uri in PATH_INFO */
+                   $path = $tmp;
+               } else {
+                   $path .= $tmp;
+               }
            }
            if ($tmp = GalleryUtilities::getServerVar('QUERY_STRING')) {
                $path .= '?' . $tmp;

(in this diff format lines with - are removed and lines with + are added)

 
WBTMagnum

Joined: 2005-08-30
Posts: 3
Posted: Wed, 2005-08-31 10:46
mindless wrote:
Can you try this patch instead and let us know if it also works?
[snipped]

hi,

i applied your patch - works great.

thanks a lot for the fast support.

regards,
sascha

 
ephantom

Joined: 2004-06-29
Posts: 11
Posted: Thu, 2007-05-24 00:41

mindless, is the gole of your script to detect the ".php" in gallery2/main.php or the "/php" in "/cgi-bin/php/"?
All my tests show that substr($path, -4) finds ".php" at the end of main.php. Your compare statement is looking for "/php".
The reason I ask is that I have a similar problem to WBTMagnum, I'm using redirects from roxen's redirect module.
However instead of using "/cgi-bin/php/" as my redirect binary I'm using "/cgi-bin/php-orcas" so I need to modify your script accordingly.
I've been able to get WBTMagnum script to work with $path = str_replace("/cgi-bin/php-orcas/","/",$path); but I haven't been able to modify your patch so that it works. Unfortunately I'm not an expert at php, only a beginner.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2007-05-24 14:22

the latter, it is checking for a path to the php binary.

 
ephantom

Joined: 2004-06-29
Posts: 11
Posted: Thu, 2007-05-24 18:46

The below modification works for my scripts. Assuming the redirect always starts with "/cgi-bin/php" the following fix should work for WBTMagnum redirects too.

/* Fix for Roxen php redirects. Assumes roxen redirect path starts with /cgi-bin/php */
/* finds a group of 4 characters 9 characters into the $path string */ 
if (substr($path, 8, 4) == '/php') {

Thanks for the clarification mindless.