Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Password protected directory-Script

Quote Reply
Password protected directory-Script
Hello, I rencently found this Java script to password protect a page. Could this be use with the Links Manager ? If so, it says to insert it at the top of the page where you want to have password protection...? What page should that be ? and would it work ?

Here is the script and instructions that came with it->

Set up multiple username and passwords for members:

Add the code to your "enter" page, if they get it wrong, they stay, if they get it right, they can go it. You can set up multiple username and password in the script, like a member list.

Example:

Click here to run the script
The user name is: user1
The password is: pass1
If you type the incorrect login it will redirect you back here

The Code

Just copy and paste this script after the <HEAD> tag of your page:

<script language="JavaScript">
// More scripts at http://www.java-scripts.com

<!--
//Reaplace correct.html to whatever page you wan't them to access.
var goodURL = "correct.html"

alert("To access the following document, you must pass a "
+"members-only, authorization test.\n \n At the appropriate "
+"time, enter in your username and password.")

var username = prompt("Enter in your username","")
var password = prompt("Enter in your password","")

if (username == null &#0124; &#0124; password == null) {

alert("Authenification failed!!!")
history.back();
}

else {
var combo = username + password
var total = combo.toLowerCase()

//Edit these to your own usernames and passwords.
if (total == "user1pass1" &#0124; &#0124; total == "user2pass2" &#0124; &#0124; total == "user3pass3") {

alert("You passed authenification! Come right in")
location = goodURL
}
else {
alert("Authenification failed!!!")
history.back();
}
}
//-->
</script>




------------------
P.Espinoza
Qdice.com
Quote Reply
Re: Password protected directory-Script In reply to
Nope...Not really. Basically, the javascript you have shown is similar to some of the cgi based password protection scripts found in the cgi-resources.com directory. It is basically a redirection script. People can still find your admin.cgi page by spidering your site.

The better solution is to do the following:

1) Use the Admin Shut-Off Mod in the Resource Center.

2) Change the permission of your admin.cgi to 444 when you are not using it.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------