Password Protect

2»

Comments

  • kwanbis Member
    You mean:

    1) open album.php, and look for the code for the thumbnails, in the default, it would be like this:

    <div id="images">
    <?php while (next_image()): ?>
    <div class="image">
    <div class="imagethumb">" title="<?php echo getImageTitle();?>"><?php printImageThumb(getImageTitle()); ?></div>
    </div>
    <?php endwhile; ?>
    </div>

    2) Above the first like of the code in (1), copy the code:

    <?php
    if ($newwws_askforpassword){
    include("$newwws_passwordfile");
    } else {
    /* place the original thumbs generating code here */
    /* or include another php-file with the thumbs-code */
    include("$newwws_thumbs_php");
    }
    ?>

    3) move the code of (1), bellow the lines of (2) that say:
    /* place the original thumbs generating code here */
    /* or include another php-file with the thumbs-code */

    It would end like this:

    <?php
    if ($newwws_askforpassword){
    include("$newwws_passwordfile");
    } else {
    /* place the original thumbs generating code here */
    /* or include another php-file with the thumbs-code */

    /* MOVED CODE STARTS HERE, IN UPPER CASE TO BETTER SEE IT */
    <DIV ID="IMAGES">
    <?PHP WHILE (NEXT_IMAGE()): ?>
    <DIV CLASS="IMAGE">
    <DIV CLASS="IMAGETHUMB"><A HREF="<?PHP ECHO GETIMAGELINKURL();?>" TITLE="<?PHP ECHO GETIMAGETITLE();?>"><?PHP PRINTIMAGETHUMB(GETIMAGETITLE()); ?></A></DIV>
    </DIV>
    <?PHP ENDWHILE; ?>
    </DIV>
    /* MOVED CODE ENDS HERE, IN UPPER CASE TO BETTER SEE IT */

    include("$newwws_thumbs_php");
    }
    ?>

    RIGHT?
  • That looks good, but make sure you put in the proper opening `<?php` and closing `?>` for PHP to work properly. Should end up looking like this:

    `<?php<br />
    if ($newwws_askforpassword){

    include("$newwws_passwordfile");

    } else { ?>



    <?php } ?>`
  • kwanbis Member
    thanks. I think my very bad explanation is better than the one on the hacks, and with your notes about closing, better, so maybe it can be added to the instructions. I don't know if i can.
  • kwanbis Member
    i still don't get it correct, where should the include be? Here is how i have it now, with all that is inside the <body> </body>

    <div id="main">

    <div id="gallerytitle">
    <h2><span>" title="Gallery Index"><?php echo getGalleryTitle();?> | </span> <?php printAlbumTitle(true);?></h2>
    </div>

    <?php printAlbumDesc(true); ?>

    <?php
    if ($newwws_askforpassword){
    include("$newwws_passwordfile");
    } else {
    /* place the original thumbs generating code here */
    /* or include another php-file with the thumbs-code */

    <div id="images">
    <?php while (next_image()): ?>
    <div class="image">
    <div class="imagethumb">" title="<?php echo getImageTitle();?>"><?php printImageThumb(getImageTitle()); ?></div>
    </div>
    <?php endwhile; ?>
    </div>
    <?php } ?>

    include("$newwws_thumbs_php");

    <?php printPageListWithNav("« prev", "next »"); ?>

    <div id="enableSorting">
    <?php printSortableAlbumLink('Click to sort album', 'Manual sorting', NULL, 'sort'); ?>
    </div>

    </div>

    <div id="credit"><?php printAdminLink('Admin', '', ' | '); ?>Powered by zenphoto</div>
  • @kwanbis-

    You don't need to include the include (ha!). That last include is if you wish to abstract the thumbs generating code into a separate file. Note in my example it doesn't exist, so it is an optional step.

    Try that. That's probably why it isn't working.
  • yvan Member
    hi thinkdreams

    i was able to follow the instructions but i have one problem that I hope you can help me with. I am never able to see the login screen the cookie gets set and it goes right into the pictures without putting the password. here is how my code looks at the if statement where $newwws_askforpassword gets checked:

    `

    if ($newwws_askforpassword){

    include($newwws_passwordfile);

    }

    else

    { ?>



    <?php } ?>

    `

    I also put the following line so that you can see what i mean

    `

    var_dump($newwws_askforpassword); print "
    "; var_dump($newwws_passwordfile); print "
    ";

    `

    the link for the page is

    http://www.frejol.com/zenphotosec/index.php?album=_caiman

    thank you very much in advance

    yvan
  • I'm not seeing anything but an error currently on that page. You might check your code syntax. Something seems to be misplaced.
  • yvan Member
    thanks for the reply thinkdreams,

    It must be maybe that i am hosting the zenphoto on a windows server but i changed the underscore for a # on the album folders and it now works. also i changed the code to use the # instead of an underscore

    `

    <?php<br />
    #========================[Private album]===========================

    /* $newwws_password is set in the album specific configuration file, but */

    /* if the name of an album starts starts with an underscore, we consider it to be */

    /* a private album too. The default-password will be zen */

    if (substr(getAlbumTitle(), 0, 1) == "#" && empty($newwws_password)) $newwws_password = "zen";

    /* Check if this is a private album and ask for a password */

    $newwws_passwordfile = $themepath . "/" . $theme . "/" . "newwws_password.php";

    if (empty($newwws_password)){

    $newwws_askforpassword = false;

    } else {

    $newwws_askforpassword = true;

    }

    $newwws_password_soll = $newwws_password;

    $newwws_password_ist = $_POST['newwws_pw'];

    if($_COOKIE["newwws_".strtolower(str_replace(" ", "#", getAlbumTitle()))] == "OK") $newwws_password_ist = $newwws_password_soll;

    if ($newwws_password_ist == $newwws_password_soll) {

    $newwws_askforpassword = false;

    setcookie ("newwws_".strtolower(str_replace(" ", "#", getAlbumTitle())),"OK",time()+1800, "/");

    }

    ?>

    `

    with an underscore it just does not work, mmmmm and i copied and paste on my sterile theme exactly the same code on the instructions. but anyway I replied just for giving a heads up for anyone encountering the same problem. thanks for the great hack

    yvan

  • gekow Member
    Ok, I got that working, nice trick. I just want to mention, that you need to mark subalbums of a private album each one individual as private.
    Oh, and the thumbnail of the hidden album is shown to the public, wich is a little pitty, because afaik we are not able to sort and do this stuff on subalbums(?)

    geKow
  • I'm using the Default-Password theme right now but want to use the Default-Dark Theme and add the password protect script.

    I've managed to do Steps 1 and 2; upon Step 3, I am able to get it working but it doesn't ask for a password upon clicking the Album. Yes; I have ensured there is an _ before the album name, I even changed it to a "." to check if that'd help.

    My code for Step 3 is shown below... if anyoen could help, that'd be great! Thx!

    <?php
    if ($newwws_askforpassword){
    include($newwws_passwordfile);
    }
    else
    { ?>
    <div id="images">
    <?php while (next_image(false, $firstPageImages)): ?>
    <div class="image">
    <div class="imagethumb">" title="<?php echo getImageTitle();?>">
    <?php printImageThumb(getImageTitle()); ?>
    </div>
    </div>
    <?php endwhile; ?>
    </div>
    <?php } ?>
  • Instructions for ZP 1.1+

    In order to get it working just take the password.php and album_images files from default-pass and drop them in default.

    Open up album_images and fill it with this:

    `





    <?php while (next_image(false, $firstPageImages)): ?>



    <?php endwhile; ?>



    `

    add this to the top of your album.php:

    `

    <?php<br />
    if (substr(getAlbumTitle(), 0, 1) == "_" && empty($newwws_password)) $newwws_password = "zen";

    /* Check if this is a private album and ask for a password */

    $newwws_passwordfile = $themepath . "/" . $theme . "/" . "password.php";

    $album_image_file = $themepath . "/" . $theme . "/" . "album_images.php";

    if (empty($newwws_password)){

    $newwws_authenticated = false;

    } else {

    $newwws_authenticated = true;

    }

    $newwws_password_soll = $newwws_password;

    $newwws_password_ist = $_POST['newwws_pw'];

    if($_COOKIE["newwws_".strtolower(str_replace(" ", "_", getAlbumTitle()))] == "OK") $newwws_password_ist = $newwws_password_soll;

    if ($newwws_password_ist == $newwws_password_soll) {

    $newwws_authenticated = false;

    setcookie ("newwws_".strtolower(str_replace(" ", "_", getAlbumTitle())),"OK",time()+1800, "/");

    }

    ?>

    `

    and in album.php replace the albums and images DIVS with:

    `

    <?php<br />
    if ($newwws_authenticated){

    include("$newwws_passwordfile");

    } else {

    include("$album_image_file");

    }

    ?>

    `
Sign In or Register to comment.