Logging in to Gallery from other web pages

eivind

Joined: 2002-08-22
Posts: 18
Posted: Fri, 2002-09-06 06:39

I am wondering if it is possible to log in to Gallery from a login script embedded in other web pages (standard html pages) than the Gallery main page. I have a website where I would like to hide Gallery completely from users that are not logged in. Upon logging in from another web page, I would like users to be transferred to the Gallery main page, and see Gallery and the albums they have permissions to view. Can the javascript used to log in to Gallery be modified to accomplish this? Any help is greatly appreciated:)

Cheers,

Eivind

 
psuter

Joined: 2002-11-27
Posts: 7
Posted: Sun, 2002-12-15 14:51

maybe this helps you out a little..

i have taken the login.php script and then modified it a little so now i am using it as my default.php file (which is displayed, when the directory for gallery is being opened) and there the user will be asked for his username and password. if you press the button, you will be logged in with your user/pwd you've just entered and then redirected to index.php.. i did this, because my gallery has no public albums.. so you always saw an empty border without anything.. i was getting tired to tell everybody to klick on the login link first, so i did this page.. here are the contents of my default.php file:

<?php
/*
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2002 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.
*/
?>
<?php
// Hack prevention.
if (!empty($HTTP_GET_VARS["GALLERY_BASEDIR"]) ||
!empty($HTTP_POST_VARS["GALLERY_BASEDIR"]) ||
!empty($HTTP_COOKIE_VARS["GALLERY_BASEDIR"])) {
print "Security violationn";
exit;
}
?>
<?php require($GALLERY_BASEDIR . "init.php"); ?>

<?php
// Security check.
$uname = removeTags($uname);
?>

<html>
<head>
<title>Login to <?php echo $gallery->app->galleryTitle?></title>
<?php echo getStyleSheetLink() ?>
</head>
<body>
<table width="100%" height="100%">
<tr><td>
<center>
<span class="popuphead">Login to <?php echo $gallery->app->galleryTitle?></span>
<br>
<br>
<?php
if ($submit) {
if ($uname &amp;&amp; $gallerypassword) {
$tmpUser = $gallery->userDB->getUserByUsername($uname);
if ($tmpUser &amp;&amp; $tmpUser->isCorrectPassword($gallerypassword)) {
$gallery->session->username = $uname;
//dismissAndReload();
echo "<BODY onLoad="self.location='".$gallery->app->photoAlbumURL."/index.php'">";
} else {
$invalid = 1;
$gallerypassword = null;
}
} else {
$error = 1;
}
}
?>

<?php echo makeFormIntro("default.php", array("name" => "login_form", "method" => "POST")); ?>
Bitte gib hier deinen Benutzernamen und Passwort ein um mein Album anzuschauen.
<p>
<table>
<?php if ($invalid) { ?>
<tr>
<td colspan=2>
<?php echo error("Invalid username or password"); ?>
</td>
</tr>
<?php } ?>

<tr>
<td>
Username
</td>
<td>
<input type=text name="uname" value=<?php echo $uname?>>
</td>
</tr>

<?php if ($error &amp;&amp; !$uname) { ?>
<tr>
<td colspan=2 align=center>
<?php echo error("You must specify a username"); ?>
</td>
</tr>
<?php } ?>

<tr>
<td>
Password
</td>
<td>
<input type=password name="gallerypassword">
</td>
</tr>

<?php if ($error &amp;&amp; !$gallerypassword) { ?>
<tr>
<td colspan=2 align=center>
<?php echo error("You must specify a password"); ?>
</td>
</tr>
<?php } ?>

</table>
<p>
<input type=submit name="submit" value="Login">
<input type=submit name="submit" value="Cancel" onclick='parent.close()'>
</form>

<script language="javascript1.2">
<!--
// position cursor in top form field
document.login_form.uname.focus();
//-->
</script>
</td></tr></table>
</body>
</html>

 
tuna

Joined: 2003-01-18
Posts: 21
Posted: Wed, 2003-03-05 03:47

I tried this on a login page that I made, it works with a mac, but all pc's don't reload the new page? It does send the username and password, but the page reloads with just the username filled out? Any suggestions? Liek I said, if you are on a mac, it reloads to index.php fine.

$gallery->session->username = $uname;
//dismissAndReload();
echo "<BODY onLoad="self.location=';".$gallery->app->photoAlbumURL."/index.php';">";

 
Gaile

Joined: 2002-07-20
Posts: 1301
Posted: Thu, 2003-04-03 07:38

Hi

Quote:
I have a website where I would like to hide Gallery completely from users that are not logged in. Upon logging in from another web page, I would like users to be transferred to the Gallery main page, and see Gallery and the albums they have permissions to view.

Try this:

1. Open Gallery's index.php and find this (it's at the bottom of the page):

include(${GALLERY_BASEDIR} . $include);
} else {
include("albums.php");
}

CHANGE IT TO THIS:

include(${GALLERY_BASEDIR} . $include);
} else {
include("login.php");
}

-- Now when you go to http://www.yourdomain.com/gallery/ - the login.php will load instead of the albums.php - which is what you want to see happen.

2. Make sure the BODY onLoad line reads as follows:

echo "<BODY onLoad="self.location='".$gallery->app->photoAlbumURL."/albums.php'">";

Now when someone enters their username and password the page should load with the albums they are allowed to see, as long as you set the permissions properly whenever you added a new album to the Gallery.

(I tried this on my test gallery on a PC and it worked. When I tried to go to mydomain.com/gallery/albums.php without being logged in, it showed me the albums.php, but with no albums (which is what it should do if only registered/logged in users can view albums). I don't have the mac on at the moment, but will try it out tomorrow to see if it works there too).

I don't think I forgot anything. Let me know how this works.

Gaile