![]() |
|
Password Protect - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: Password Protect (/thread-1119.html) |
Password Protect - caseyd1020 - 2007-05-05 I am having the same problem as gilou, I do not know where to put the code in step 3. Password Protect - jm - 2007-05-08 [b]tdevlin[/b], any news? Simple password creation is keeping me from moving my client's site from Gallery2 (terrible, ugly beast) to zenphoto. Developing themes in Gallery2 shortens your life! ![]() Adding a password input alongside the album at creation isn't hard, but storing and calling the data is what I can't figure out. Password Protect - Guest - 2007-05-08 I am also looking for this feature. However I have always password-protected my galleries with a .htaccess file (most of you can probably use cpanel for that). I actually have zenphoto installed twice: zenphotopublic and zenphotoprivate Password Protect - jm - 2007-05-08 A few ideas: [list] [*]an input for a .htpasswd writer. This seems the easiest, so I'll try to work something out later on. [*]Add another field to the table, `albums`. Write to it at album creation. [/list] Password Protect - jm - 2007-05-09 OK, I think I made a little bit of progress using an htaccess & htpasswd solution. My stumbling block right now is how to manage multiple logins/pwds. Edit: OK, I'm definitely not smart enough for this. Is anyone else willing to develop this? I'll donate money for this functionality - I just need it soon. Password Protect - La0c00n - 2007-05-09 @jm: i've replied to you on the Trac of zenphoto ! Password Protect - kwanbis - 2007-05-15 Sorry, i'm looking at the ZenphotoHacks, and in the step 3 says someting i don't get. I have my newwws_password.php with the code of step 2, and i have album.php at this state: <?php if (!defined('WEBPATH')) die(); ?> <?php #========================[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, "/"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title><?php printGalleryTitle(); ?> | <?php echo getAlbumTitle();?></title> <link rel="stylesheet" href="<?php echo $_zp_themeroot ?>/zen.css" type="text/css" /> <?php zenJavascript(); ?> </head> <body> <div id="main"> <div id="gallerytitle"> <h2><span><a>" title="Gallery Index"><?php echo getGalleryTitle();?></a> | </span> <?php printAlbumTitle(true);?></h2> </div> <?php printAlbumDesc(true); ?> <div id="images"> <?php while (next_image()): ?> <div class="image"> <div class="imagethumb"><a>" title="<?php echo getImageTitle();?>"><?php printImageThumb(getImageTitle()); ?></a></div> </div> <?php endwhile; ?> </div> <?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> </body> </html> Password Protect - kwanbis - 2007-05-15 (looks like all of us newbies don't get step 3) Password Protect - kwanbis - 2007-05-15 and before somebody responds, where do i set the password? Password Protect - thinkdreams - 2007-05-15 @kwanbis- I have it working on my gallery at http://www.thinkdreams.com/devzen. Make sure you name all the galleries you want to password protect with underscores `_`. The code you need to add (which may look different in whatever theme you use) is (and this is based on default theme): `<?php if ($newwws_askforpassword){ include("$newwws_passwordfile"); } else { ?> <?php while (next_image()): ?> <div class="image"> <div class="imagethumb">"><?php printImageThumb(getImageTitle()); ?> </div> <?php endwhile; ?> </div> <?php } ?>` What I did was add in the lines miriam mentioned: `<?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"); } ?>` right above the lines in the default theme that look like: ` <?php while (next_image()): ?> <div class="image"> <div class="imagethumb">"><?php printImageThumb(getImageTitle()); ?> </div> <?php endwhile; ?> </div>` which generate the thumbnails you see in the album display page. Then just cut n paste the thumbnail code into the "miriam" code shown above (making sure to use proper php script start and end statements (`<?php` and `?>`). Once that's done, it should work fine. Hopefully that will get you started on the right path. Password Protect - thinkdreams - 2007-05-15 Oh, and the password is set in the very top of the album.php once you make the code changes. Look for: `$newwws_password = "zen";` at or around line 6 in the album.php. And if anyone looks at my gallery, the password is bob, not zen. I was experimenting. I chose "bob". Don't know why.
Password Protect - kwanbis - 2007-05-16 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"><a>" title="<?php echo getImageTitle();?>"><?php printImageThumb(getImageTitle()); ?></a></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? Password Protect - thinkdreams - 2007-05-16 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 if ($newwws_askforpassword){ include("$newwws_passwordfile"); } else { ?> <?php while (next_image()): ?> <div class="image"> <div class="imagethumb">"><?php printImageThumb(getImageTitle()); ?> </div> <?php endwhile; ?> </div> <?php } ?>` Password Protect - kwanbis - 2007-05-16 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. Password Protect - kwanbis - 2007-05-17 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><a>" title="Gallery Index"><?php echo getGalleryTitle();?></a> | </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"><a>" title="<?php echo getImageTitle();?>"><?php printImageThumb(getImageTitle()); ?></a></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> Password Protect - thinkdreams - 2007-05-17 @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. Password Protect - yvan - 2007-06-11 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 while (next_image()): ?> <div class="image"> <div class="imagethumb"><a>" title="<?php echo getImageTitle();?>"> <?php printImageThumb(getImageTitle()); ?></a> </div> <?php endwhile; ?> </div> <?php } ?> ` I also put the following line so that you can see what i mean ` var_dump($newwws_askforpassword); print "<br/>"; var_dump($newwws_passwordfile); print "<br/>"; ` the link for the page is http://www.frejol.com/zenphotosec/index.php?album=_caiman thank you very much in advance yvan Password Protect - thinkdreams - 2007-06-12 I'm not seeing anything but an error currently on that page. You might check your code syntax. Something seems to be misplaced. Password Protect - yvan - 2007-06-12 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 #========================[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 Password Protect - gekow - 2007-06-14 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 |