User credentials when Gallery is embedded

paour
paour's picture

Joined: 2002-08-14
Posts: 1479
Posted: Sun, 2003-05-25 21:19

One of the most frequently asked questions about Gallery Remote, and one of the issues users complain most bitterly about (and rightly so), is the fact that when their Gallery is embedded inside a Content Management System such as PostNuke, GR cannot logon because of a "bad password".

The problem is that when Gallery is embedded, the user management is performed by the CMS, and the Gallery administrator forgets that Gallery can also be accessed stand-alone. And when Gallery is accessed stand-alone, it performs its own user management...

So, for all of you who have problems logging on to your Gallery through Gallery remote:

    make sure that the URL for the Gallery that you set in GR is the URL to the stand-alone version of Gallery, not the PostNuke Gallery module, for example.
    the username and password need to be credentials that work in stand-alone Gallery. You should test by doing this in a web browser.

I've made some cosmetic changes in the latest builds of Gallery and Gallery Remote to help users diagnose this, but for the process to work transparently (I realize some of you let users of the CMS upload images to your galleries, and don't want to have to manage those user accounts in stand-alone mode), I have to wait for GR 1.1, which will enter beta in the next couple weeks.[/]

[/]

 
paour
paour's picture

Joined: 2002-08-14
Posts: 1479
Posted: Thu, 2003-06-26 09:53

GR 1.1 is now in beta, please try it out.

 
akerin

Joined: 2002-12-11
Posts: 6
Posted: Fri, 2003-06-27 03:13

As there is no "native" URL when embedded in geeklog I do this to get remote to work:

1. geeklog install replaces init.php and util.php
2. get the original versions and rename them init2.php and util2.php
3. in gallery_remote2.php, replace the ref to init.php with init2.php -

require($GALLERY_BASEDIR . "init2.php");

4. in init2.php, replace the ref to util.php with util2.php
5. in init2.php, add the following


$GALLERY_EMBEDDED_INSIDE = "";

after the include config.php

6. This makes remote think that it is not embedded. Therefore the user and password must exist within gallery when not embedded.

This works well for me. Now to get publishXP working when embedded...

Alex Kerin

www.kerin.us

 
JoeA

Joined: 2003-08-18
Posts: 6
Posted: Mon, 2003-08-18 18:02

Thanks for solving my problem! I can now import files at the command line with galleryadd.pl. My next question is:

Are there any other features that won't work when gallery is
integrated with a portal such as Geeklog?

Thanks for your help!

Joe

 
docrock

Joined: 2003-02-05
Posts: 13
Posted: Wed, 2003-12-24 05:57

I di as follows and am still getting the invalid u/p message.

Cant some one post excatly where/how to add the :

$GALLERY_EMBEDDED_INSIDE = ""; 

after the include config.php.

Please post the entire code snippet. Thank You very much

Doc

 
joel558
joel558's picture

Joined: 2003-04-10
Posts: 93
Posted: Wed, 2003-12-24 09:49

not sure, but my guess would be after this code at line 94

if (fs_file_exists($GALLERY_BASEDIR . "config.php")) {
        global $gallery;
	include($GALLERY_BASEDIR . "config.php");
}
 
docrock

Joined: 2003-02-05
Posts: 13
Posted: Tue, 2003-12-30 12:32

$GALLERY_EMBEDDED_INSIDE = "";

Where exactly do i stick this line? Here is a snippit of what i did. I made all the other mods as per the instructions. The last one was a little vague.

if (fs_file_exists($GALLERY_BASEDIR . "config.php")) {
        global $gallery;
	include($GALLERY_BASEDIR . "config.php") ;
$GALLERY_EMBEDDED_INSIDE = ""; 
}

Is that right and if so any ideas on why it is still not functioning?

further down in the code it addresses :

if (isset($GALLERY_EMBEDDED_INSIDE) &&
	!strcmp($GALLERY_EMBEDDED_INSIDE, "nuke")) {
        include($GALLERY_BASEDIR . "classes/Database.php");

	if ($GALLERY_EMBEDDED_INSIDE_TYPE == 'postnuke') {
	/* We're in embedded in Postnuke */

Do I need to change this or any code in any way because i am using Geeklog?

Thanks for you help.

Happy NewYear :P

Doc

 
joel558
joel558's picture

Joined: 2003-04-10
Posts: 93
Posted: Sat, 2004-01-03 06:34

i'd assume it would work given the instructions above, unless something has changed in gallery since that person posted those instructions. i don't have geeklog so i'm not sure how that works.

you could try moving that line to just before that second peice of code you posted, or instead of
$GALLERY_EMBEDDED_INSIDE = "";
you could try
unset($GALLERY_EMBEDDED_INSIDE);
in either place

but that may not work in the new version of gallery either...

 
docrock

Joined: 2003-02-05
Posts: 13
Posted: Wed, 2004-01-07 21:34

I made the neccessary adjustments and still no dice. You somebody please look at my code and tell me what i am doing wrong:

<?php
/*
 * Gallery - a web based photo album viewer and editor
 * Copyright (C) 2000-2003 Bharat Mediratta
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Id: init.php,v 1.74 2003/10/13 11:30:46 beckettmw Exp $
 */
?>
<?php
// Hack prevention.
$sensitiveList = array("gallery", "GALLERY_BASEDIR");
foreach ($sensitiveList as $sensitive) {
	if (!empty($HTTP_GET_VARS[$sensitive]) ||
			!empty($HTTP_POST_VARS[$sensitive]) ||
			!empty($HTTP_COOKIE_VARS[$sensitive]) ||
			!empty($HTTP_POST_FILES[$sensitive])) {
		print _("Security violation") ."\n";
		exit;
	}
}
?>
<?php
/*
 * Turn down the error reporting to just critical errors for now.
 * In v1.2, we know that we'll have lots and lots of warnings if
 * error reporting is turned all the way up.  We'll fix this in v2.0
 */
error_reporting(E_ALL & ~E_NOTICE);

/*
 * Figure out if register_globals is on or off and save that info
 * for later
 */
$register_globals = ini_get("register_globals");
if (empty($register_globals) ||
        !strcasecmp($register_globals, "off") ||
        !strcasecmp($register_globals, "false")) {
    $gallery->register_globals = 0;
} else {
    $gallery->register_globals = 1;
}

/*
 * If register_globals is off, then extract all HTTP variables into the global
 * namespace.  
 */
if (!$gallery->register_globals) {
    if (is_array($HTTP_GET_VARS)) {
	extract($HTTP_GET_VARS);
    }

    if (is_array($HTTP_POST_VARS)) {
	extract($HTTP_POST_VARS);
    }

    if (is_array($HTTP_COOKIE_VARS)) {
	extract($HTTP_COOKIE_VARS);
    }

    if (is_array($HTTP_POST_FILES)) {
	foreach($HTTP_POST_FILES as $key => $value) {
	    ${$key."_name"} = $value["name"];
	    ${$key."_size"} = $value["size"];
	    ${$key."_type"} = $value["type"];
	    ${$key} = $value["tmp_name"];
	}
    }
}

require($GALLERY_BASEDIR . "Version.php");
require($GALLERY_BASEDIR . "util2.php");
/* Load bootstrap code */
if (getOS() == OS_WINDOWS) {
	include($GALLERY_BASEDIR . "platform/fs_win32.php");
} else {
	include($GALLERY_BASEDIR . "platform/fs_unix.php");
}


if (fs_file_exists($GALLERY_BASEDIR . "config.php")) {
        global $gallery;
	include($GALLERY_BASEDIR . "config.php") ;
unset($GALLERY_EMBEDDED_INSIDE); 
}
if (isset($gallery->app->devMode) && 
		$gallery->app->devMode == "yes") {
       	error_reporting(E_ALL);
} else {
       	error_reporting(E_ALL & ~E_NOTICE);
}

/*
 * Detect if we're running under SSL and adjust the URL accordingly.
 */
if(isset($gallery->app)) {
	if (isset($HTTP_SERVER_VARS["HTTPS"] ) && 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);
	}
}

/* 
 * Turn off magic quotes runtime as they interfere with saving and
 * restoring data from our file-based database files
 */
set_magic_quotes_runtime(0);


/* Load classes and session information */
require($GALLERY_BASEDIR . "classes/Album.php");
require($GALLERY_BASEDIR . "classes/Image.php");
require($GALLERY_BASEDIR . "classes/AlbumItem.php");
require($GALLERY_BASEDIR . "classes/AlbumDB.php");
require($GALLERY_BASEDIR . "classes/User.php");
require($GALLERY_BASEDIR . "classes/EverybodyUser.php");
require($GALLERY_BASEDIR . "classes/NobodyUser.php");
require($GALLERY_BASEDIR . "classes/LoggedInUser.php");
require($GALLERY_BASEDIR . "classes/UserDB.php");
require($GALLERY_BASEDIR . "classes/Comment.php");

if (!isset($GALLERY_NO_SESSIONS)) {
    require($GALLERY_BASEDIR . "session.php");
}

$gallerySanity = gallerySanityCheck();
initLanguage();

/* Make sure that Gallery is set up properly */
if ($gallerySanity != NULL) {
	include ("${GALLERY_BASEDIR}errors/$gallerySanity");
	exit;
}

if (isset($GALLERY_EMBEDDED_INSIDE) &&
	!strcmp($GALLERY_EMBEDDED_INSIDE, "nuke")) {
        include($GALLERY_BASEDIR . "classes/Database.php");

	if ($GALLERY_EMBEDDED_INSIDE_TYPE == 'postnuke') {
	/* We're in embedded in Postnuke */

	    if (!function_exists("pnUserGetVar")) {
		/* pre 0.7.1 */
		include($GALLERY_BASEDIR . "classes/postnuke/UserDB.php");
		include($GALLERY_BASEDIR . "classes/postnuke/User.php");
		
		$gallery->database{"db"} = $GLOBALS['dbconn'];
		$gallery->database{"prefix"} = $GLOBALS['pnconfig']['prefix'] . "_";
	    } else {
		/* 0.7.1 and beyond */
		include($GALLERY_BASEDIR . "classes/postnuke0.7.1/UserDB.php");
		include($GALLERY_BASEDIR . "classes/postnuke0.7.1/User.php");
	    }

	    /* Load our user database (and user object) */
	    $gallery->userDB = new PostNuke_UserDB;

	    if (isset($GLOBALS['user'])) {
		$gallery->session->username = $GLOBALS['user']; 
	    }
	    
	    if (isset($GLOBALS['user']) && is_user($GLOBALS['user'])) {
		$user_info = getusrinfo($GLOBALS['user']);
		$gallery->session->username = $user_info["uname"]; 
		$gallery->user = 
		    $gallery->userDB->getUserByUsername($gallery->session->username);
	    }
	} else {
	/* we're in phpnuke */
	    include($GALLERY_BASEDIR . "classes/database/mysql/Database.php");
	    include($GALLERY_BASEDIR . "classes/nuke5/UserDB.php");
	    include($GALLERY_BASEDIR . "classes/nuke5/User.php");

	    $gallery->database{"nuke"} = new MySQL_Database(
			$GLOBALS['dbhost'],
			$GLOBALS['dbuname'],
			$GLOBALS['dbpass'],
			$GLOBALS['dbname']);
	    if (isset($GLOBALS['user_prefix'])) {
		$gallery->database{"user_prefix"} = $GLOBALS['user_prefix'] . '_';
	    } else {
		$gallery->database{"user_prefix"} = $GLOBALS['prefix'] . '_';
	    }
	    $gallery->database{"prefix"} = $GLOBALS['prefix'] . '_';

            /* PHP-Nuke changed its "users" table field names in v.6.5 */
	    /* Select the appropriate field names */
	    if (isset($Version_Num) && $Version_Num >= 6.5) {
		$gallery->database{'fields'} =
			array ('name'  => 'name',
			       'uname' => 'username',
			       'email' => 'user_email',
			       'uid'   => 'user_id');
	    }
	    else {
		$gallery->database{'fields'} =
			array ('name'  => 'name',
			       'uname' => 'uname',
			       'email' => 'email',
			       'uid'   => 'uid');
	    }
	    
	    /* Load our user database (and user object) */
	    $gallery->userDB = new Nuke5_UserDB;
	    if ($GLOBALS['user']) {
		$gallery->session->username = $GLOBALS['user']; 
	    }
	    
	    if (isset($GLOBALS['admin']) && is_admin($GLOBALS['admin'])) {
		include($GALLERY_BASEDIR . "classes/nuke5/AdminUser.php");
		
		$gallery->user = new Nuke5_AdminUser($GLOBALS['admin']);
		$gallery->session->username = $gallery->user->getUsername();
	    } else if (is_user($GLOBALS['user'])) {
		$user_info = getusrinfo($GLOBALS['user']);
		$gallery->session->username =
			$user_info[$gallery->database{'fields'}{'uname'}]; 
		$gallery->user = 
			 $gallery->userDB->getUserByUsername($gallery->session->username);
	    }
	}
} else {
	include($GALLERY_BASEDIR . "classes/gallery/UserDB.php");
	include($GALLERY_BASEDIR . "classes/gallery/User.php");

	/* Load our user database (and user object) */
	$gallery->userDB = new Gallery_UserDB;

	/* Load their user object with their username as the key */
	if (isset($gallery->session->username)) {
		$gallery->user = 
			$gallery->userDB->getUserByUsername($gallery->session->username);
	}
}

/* If there's no specific user, they are the special Everybody user */
if (!isset($gallery->user)) {
	$gallery->user = $gallery->userDB->getEverybody();
	$gallery->session->username = "";
}

if (!isset($gallery->session->offline)) {
    $gallery->session->offline = FALSE;
}

if ($gallery->userDB->versionOutOfDate()) 
{
	include($GALLERY_BASEDIR . "upgrade_users.php");
	exit;
}

/* Load the correct album object */
if (!empty($gallery->session->albumName)) {
	$gallery->album = new Album;
	$ret = $gallery->album->load($gallery->session->albumName);
	if (!$ret) {
		$gallery->session->albumName = "";
	} else {
		if ($gallery->album->versionOutOfDate()) {
			include($GALLERY_BASEDIR . "upgrade_album.php");
			exit;
		}
	}
}
?>

I have checked for blank lines after code:
checked all the other files and damn i am lost.

Thanks
Doc

Geeklog 1.3.8-1.
Gallery v1.4-pl1 (intergrated)
MySQL version 4.0.15-standard
PHP version 4.3.1
RedHat 7.3
apache (1.3.27 (Unix))

 
joel558
joel558's picture

Joined: 2003-04-10
Posts: 93
Posted: Fri, 2004-01-09 18:49

you may have seen this already, if so, maybe this will help others... geeklog seems to have something to integrate gallery, you can find it here http://www.geeklog.net/article.php?story=20031228224244779 or here http://www.pigstye.net/gplugs/staticpages/index.php/20030301191703689

i'd guess this also allows gallery remote to work... but I'm not sure