HTTPS and Random Photo Blocks

scottg

Joined: 2003-03-09
Posts: 2
Posted: Sun, 2003-03-09 05:44

Hello,

I am using GeekLog and Gallery and have integrated them with Gallery/GeekLog integration. All is working well with them. I then added a random photo block that was made for GeekLog and Gallery.
It appears everything is working in that a random photo is sleceted and a link to the gallery wrapped in geeklog is generated. The problem is that the url to the thumbnail photo and the url for the link in the thumbnail to open that album in Gallery wrapped in Geeklog does not include the "s" in https, so the thumbnail will not display and the link to Gallery wrapped in Geeklog starts with http:// which is a dead link on my machine. I am using https becuase my ISP blocks port 80 inbound.

I am using GeekLog 1.3.7sr1, Gallery 1.3.3, and Gallery Random Photo Block for Geeklog Rev 1.0, Apache 1.3.27, PHP 4.1.2, Mac OS X 10.2.4

The code block appears to make reference to the same functions used in the Nuke code block variations. The block calls makeAlbumUrl - a function in the gallery util.php file. This function in turn calls makeGalleryUrl() function.

From my config.php:
$gallery->app->photoAlbumURL = "https://ginsblog.sytes.net/gallery"

I beleive this is working well because Gallery / Geeklog integration works and wrapps in nicely under https. It seems that if this were wrong, that would be broken too? The script generates the correct link paths in the url, all thats missing is the http "s". I can click on the place where the thumb is supposed to be and it opens the page to a dead link, insert the "s", and all is well.

I also notice that in the Gallery init.pgp at line 88:
/*
* Detect if we're running under SSL and adjust the URL accordingly.
*/
if (stristr($HTTP_SERVER_VARS["HTTPS"], "on")) {
$gallery->app->photoAlbumURL =
eregi_replace("^http:", "https:", $gallery->app->photoAlbumURL);
$gallery->app->albumDirURL =
eregi_replace("^http:", "https:", $gallery->app->albumDirURL);
} else {
$gallery->app->photoAlbumURL =
eregi_replace("^https:", "http:", $gallery->app->photoAlbumURL);
$gallery->app->albumDirURL =
eregi_replace("^https:", "http:", $gallery->app->albumDirURL);
}

Is there a way to use / reuse this funtion. This seems to work, if it is in fact the reason Gallery stand alone and wrapped in GL works under https, which I can confirm.

Seems this could or should perhaps be part of the block code?

Finally, in the mean time, is there a way to do anything to make it default to https?

Thanks to anyone who can help. The page the problem is at is https://ginsblog.sytes.net

Scottg

 
scottg

Joined: 2003-03-09
Posts: 2
Posted: Sat, 2003-03-22 03:31

I payed for some donation based support from Bharat of the Gallery Project. This is what he came up with and everything is working now. Bharat refers to line number 142 below, that is the number as he found in in MY lib.custom.php. This is really line number 20 in a pristine php_GalleryRandomPhoto.php file that is part of the package available from Blaine. It is also the second line of uncommented code in the php block code.

Thanks to Blaine and Bharat for your help and I highly reccomend a donation based support mechanism. It is a geat way to support the development effort, get problems addressed and fixed and see them rolled back into the software for everyone.

From Bharat:
Ok, it's fixed. It turned out to be a pretty interesting problem.
The "init.php" script was never intended to be included from inside
another function so it was trying to use the $HTTP_SERVER_VARS variable
to determine whether or not you were in SSL mode, but that variable
was not declared to be in the global scope (since we never expected
to be inside a function at that point). This probably works for 99%
of Geeklog users as-is because by default when that variable isn't
available in the global scope it assumes that you're not in SSL mode.
In short, the script wasn't intended to be used the way that it's being
used so it wasn't operating exactly right in all cases.

I made the smallest possible fix to resolve the problem. Basically,
I editted lib-custom.php and on line 142 I changed:

global $_CONF, $GALLERY_BASEDIR;

to:

global $_CONF, $GALLERY_BASEDIR, $HTTP_SERVER_VARS;

And voila, now it works. Enjoy.

-Bharat