_parseUri is not generic enough - regexp needs to be fixed

sven111

Joined: 2005-05-15
Posts: 10
Posted: Mon, 2006-06-12 06:54

I have problem with my site being like this: http://myhosting.com/myprofilename/gallery2 I cannot make baseUri setting at config.php to get that myprofilename - part through and so I started using grep -i to find out where the baseUri - setting is parsed.

I found that _parseUri at ./modules/core/classes/GalleryUrlGenerator.class is the one that parses that setting. And there it was - no extra dirs seemed to be allowed by the current regexp. Only string between the two last '/' is interpreted as path.

I would much appreciate any help with this.

EDIT: this line here is the one that needs to be fixed: preg_match('{^(/(?:.*/)?)?([^/]*)$}', $file, $matches)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2006-06-12 07:06

nope, it allows for any number of nested folders.

and there's a unittest that ensures that this works correctly.

but the trailing '/' is necessary.

1. why are you looking at baseUri at all? you don't need to set baseUri yourself.
2. if you set baseUri yourself, set it to http://myhosting.com/myprofilename/gallery2/ and not to http://myhosting.com/myprofilename/gallery2 (notice the trailing /).

 
sven111

Joined: 2005-05-15
Posts: 10
Posted: Mon, 2006-06-12 09:59

My apology if that regexp was fine in this case. Here is the background how I started to think that - I have complicated setting here. I have an Apache server that acts as a reverse proxy to local servers.

One of those local ones is that myprofilename and is set as directory location in Apache conf, using Location directive. At first I tried with default settings (baseUri and galleryBaseUrl left empty). Then Gallery directed me to local ip address of the Apache server (192.168.0.xxx). Not at every point - I could login to admin section, click on links at the left but then when I clicked Save at Site admin->General settings, the url at browser changed to this: 192.168.xxx.xxx/gallery2.

I think my apache reverse proxy configuration needs something - could it be that urls at cookies are not rewritten properly?

 
sven111

Joined: 2005-05-15
Posts: 10
Posted: Mon, 2006-06-12 16:47

Still have the problem :( I think my reverse proxy configuration is OK, since everything else works fine. I also have Joomla CMS in there and all the submit buttons work ok. Now when I try without setting $gallery->setConfig('baseUri', 'http://mysite/g2/gallery2/'); I get taken to reverse proxy page, like this: http://192.168.0.100/gallery2/main.php, with error 404. Now when I set that baseUri, I get a bit ahead, but always g2 part is cut out of the url so the final url at browser is this: http://mysite/gallery2/main.php.

 
sven111

Joined: 2005-05-15
Posts: 10
Posted: Mon, 2006-06-12 18:37

Yeah! I hacked it a bit and got it working! Where is the line "return $this->_currentUrl[$forceDirect];" at ./modules/core/classes/GalleryUrlGenerator.class - I replaced that line with "return 'http://mysite/g2/gallery2/'; and url is fine then.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2006-06-12 22:26

- G2 generates relative URLs where it can. it removes the host part of all URLs and sometimes even the path. it does a good job at this.
we do this to keep our generated HTML as small as possible. funny enough URLs make up a big part of our generated HTML.

- maybe there's some edge case in your case that we don't cover correctly. can't reproduce it though.
i know, it's working for you now with this small hack so the motivation to really fix it is not that big. however, if you eventually find out what the problem was, doesn't matter when that is :) , please let us know.
thanks!

 
sven111

Joined: 2005-05-15
Posts: 10
Posted: Tue, 2006-06-13 11:25

ok, I'll update my experiences here to let you know how this problem is. Now I have spotted a small clitch in my hack - I must always add main.php to http://myhost/g2/gallery2/, just index.php seems to take me to 192.168.0.100 address again. EDIT - fixed that with Apache mod_rewrite at reverse proxy server.

Gallery bridge doesn't work right - I can click on an image at gallery in Joomla and see it, but when I log in to Gallery backend, I am getting that problem with 192.168.0.100 again - it is the url where I am redirected. Also the same happens after I click on Save - buttons inside Gallery. But in standalone it works fine so I have disabled Gallery login in Joomla altogether.

New problem is that even Gallery - link that I can click takes me to 192.168.0.100 - page. I checked the HTML code and there is a link like this: "/g2/index.php?option=com_gallery2&Itemid=35&g2_GALLERYSID=TMP_SESSION_ID_DI_NOISSES_PMT". I guess somehow I must remove that first / because the same Gallery link at standalone is just this: "main.php?g2_highlightId=30&g2_navId=x2bacd7fa" and it works fine.

 
sven111

Joined: 2005-05-15
Posts: 10
Posted: Wed, 2006-06-14 14:44

Now I solved the last problem. This was caused because I used Gallery2 locally for my tests. Now I tried it with proper URL, like mysite.fi and then clicking on Gallery link in Joomla-G2bridge did not call for 192.168.0.100 anymore. I also tried to run gallery without my modification of ./modules/core/classes/GalleryUrlGenerator.class and then I had the older problem back again. So I left that modification.

I also tried to enter the address to baseUri and removed my modification - and then Gallery again cut out that g2 from url when I tried to login. So I left baseUri empty.

The only problem that is left is with Gallery2 bridge - when I allow login at Joomla via bridge, it adds extra g2 to url it calls when POST sends the login/password.