I have a dir on my server that has dir listing enabled. I want this enabled so all I have to do is add files to be viewed by clients. I have an asp password page that links to the dir and sets a cookie on the clients machine.
What I'd like to do is have a default page in the dir that makes sure the cookie is set before opening the dir for viewing. I tried using default.asp page in the dir to check for the cookie it works fine but when I have it in there the dir is not visible. I realize this is proper but is there a way to make the dir visible only if the client has the cookie? this is the code for the pages;
Password Page
Verification page
page in the dir
All help will be greatly appreciated.
What I'd like to do is have a default page in the dir that makes sure the cookie is set before opening the dir for viewing. I tried using default.asp page in the dir to check for the cookie it works fine but when I have it in there the dir is not visible. I realize this is proper but is there a way to make the dir visible only if the client has the cookie? this is the code for the pages;
Password Page
Code:
<%Language=VBScript%>
<html>
<head><title>PicturesPassword</title></head>
<body bgcolor="#333399" text="#CCCCCC" link="#009900" vlink="#0099CC">
<div align = "center">
<p> Enter your name and password</p>
<form method="post" action="/picsPW.asp">
Your name: <input type="text" name="name" size="20"><BR>
Your Password: <input type="password" name="pass" size="15"><BR>
<input type="Submit" value="Submit">
</form>
</div>
<!--#include virtual="/274/Glens_IncludeA.asp" -->
</body>
</html>
Verification page
Code:
<%Language=VBScript%>
<html>
<head>
<title> Password Checker</title>
</head>
<body>
<!--#include virtual ="\274\Glens_IncludeA.asp"-->
<%
OK = Request.form("pass")
response.cookies("Client")="test"
response.cookies("Client").expires = date + 1
Session("userID")= OK
Dim MyArray(4,1),password,name,i,test
password = request.form("pass")
name = request.form("name")
MyArray(0,1) = "Karen"
MyArray(1,1) = "Paul"
MyArray(2,1) = "Janet"
MyArray(3,1) = "Rita"
MyArray(4,1) = "Glen"
MyArray(0,0) = "Karen"
MyArray(1,0) = "Paul"
MyArray(2,0) = "Janet"
MyArray(3,0) = "Rita"
MyArray(4,0) = "Glen"
for i = 0 to 4
If MyArray(i,1) + MyArray(i,0) = name + password Then
test=true
Exit For
End If
next
If test = true then
response.addheader"Refresh","5;URL= [URL unfurl="true"]http://www.Myserver.com/Pictures"[/URL]
Else
response.addheader"Refresh","5;URL= PicsPW2.htm"
end if
response.write "Hi "&name&" Checking you're password, If correct You'll see the pics in 5 seconds."
%>
</body>
</html>
page in the dir
Code:
<%Language=VBScript%>
<html><head><title> Validate</title></head><body>
<%
If request.cookies("Client")="" then
Response.redirect "[URL unfurl="true"]http://www.myserver/PicturesPassword.htm"[/URL]
end if%>
</body>
</html>