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 */
Comments
Nightly build: http://www.zenphoto.org/files/nightly/
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 */
2) Body Code
<!-- Start Album Password code -->
<?php
$albumtitle = getAlbumTitle();
$prevalbumtitle = $_SESSION['pvtalbum'];
if ($albumtitle !== $prevalbumtitle) {
if (!empty($pvt_password)){
$pvt_auth_required = true;
}
}
if ($pvt_auth_required){
include("$pvt_passwordfile");
} else {
include("$album_image_file");
}
?>
<!-- End Album Password code -->