Album Database Password - tdaugharty - 2007-12-01
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.
- Add a text column to the albums table called album_password
- 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 /
Album Database Password - aitf311 - 2007-12-01
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/
Album Database Password - tdaugharty - 2007-12-02
Here is my final code if anyone wants it for their own use
- 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 /
- Body Code
|