Member
Member
tdaugharty   2007-12-01, 18:01
#1

I've modified the newws password code to offer a password per album from the database. Also instead of using a cookie to persist a session, I'm a using PHP session variable.

  1. Add a text column to the albums table called album_password
  2. Replace code in the album.php with the following

/ Start of Private Password for Albums /
$albumtitle = getAlbumTitle();
$albumpwd=query_single_row("SELECT DISTINCT album_password FROM zen_albums where title = \"$albumtitle\"");
$pvt_password = $albumpwd['album_password'];

/ $pvt_password = "fstop"; /
$pvt_passwordfile = $themepath . "/" . $theme . "/" . "password.php";
$album_image_file = $themepath . "/" . $theme . "/" . "album-images.php";

$pvt_password_post = $_POST['pvt_pw'];

session_start();

if (!empty($pvt_password)){
if ($pvt_password == $pvt_password_post) {
$_SESSION['pvtsess'] = 1;
$pvt_authenticated = false;
}
if (!isset($_SESSION['pvtsess'])) {
$pvt_authenticated = true;
} else {
$pvt_authenticated = false;
}
} else {
$pvt_authenticated = false;
}
/ End of Password for Private Albums /

Member
Member
aitf311   2007-12-01, 18:11
#2

tdaugharty: with the nightly build (svn), album and galleries password protection is possibly using the admin options tab for gallery and the edit tab for albums. Image protection is possible and I believe there is an example in effervescence+'s image.php.

Nightly build: http://www.zenphoto.org/files/nightly/

Member
Member
tdaugharty   2007-12-02, 01:55
#3

Here is my final code if anyone wants it for their own use

  1. Header Code
    / Start of Private Password for Albums /
    $albumtitle = getAlbumTitle();
    $pvt_passwordfile = $themepath . "/" . $theme . "/" . "password.php";
    $album_image_file = $themepath . "/" . $theme . "/" . "album-images.php";
    $albumpwd=query_single_row("select distinct album_password from zen_albums where title = \"$albumtitle\"");
    $pvt_password = $albumpwd['album_password'];

$pvt_password_post = $_POST['pvt_pw'];

session_start();

if (!empty($pvt_password)){
if ($pvt_password == $pvt_password_post) {
$_SESSION['pvtsess'] = true; $_SESSION['pvtalbum'] = getAlbumTitle();
$pvt_auth_required = false;
}
if (!isset($_SESSION['pvtsess'])) {
$pvt_auth_required = true;
} else {
$pvt_auth_required = false;
}
} else {
$pvt_auth_required = false;
}
/ End of Password for Private Albums /

  1. Body Code
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.