PDA

View Full Version : Login&protected area scripts


lynniedesign
04-03-2003, 03:15 AM
Hello. I have a website that I have been doing for my organization and I am a newbie at this, but I was hoping someone can help me with this particular problem of mine. I need help finding a script to password protect an area of my web site.

I'll need to be able to add users. Each user needs a unique username and password.

I'd also like it to go directly from a log in form on an html page directly to the password protected area. (without a pop up window asking for the username and password.)
I've been experimenting with ".htaccess" files and JavaScript but haven't been successful. Though when using .htaccess after clicking the submit button, it pops up another box asking for the username and password. I just would like it to go to the protected page.

Does someone have a script that would do what I describe? (And if you can, can you tell me where to put the script(s) into. I am thinking I need a password/username verification form, right?
And how should I put a script in the login html...)

or if not, could you point me towards someone or someplace that would?

Any help would be appreciated. Thanks.

YUPAPA
04-03-2003, 06:27 AM
HiHi~

I think the only way you can do is to code your site in perl :p
Cookies and Session would be helpful too.

What's wrong with .htaccess?

lynniedesign
04-03-2003, 07:49 AM
Thank you for your suggestions but the thing is that I don't really understand how to do htaccess exactly(I am a newbie at perl, cgi, php, htaccess-- stuff like that) but for what I need, is it better to do it in sessions or cookies? And if from which, where can I get help to do that? or scripts like that? I'm sorry I am just confused with stuff like this and it took me a slow while just to understand html coding. :confused:
thanks again for the suggestions.

YUPAPA
04-03-2003, 08:24 AM
If you don't mind the popup windows that asks for username and password, it would be very easy to setup.

First, you must know the full path to your protected directory (i.e /home/sites/my_username/protected)


Second, simply create two text files (under the password protected directory)
.htaccess
.htpasswd

For .htaccess put

AuthName "Password Protected"
AuthType Basic
AuthUserFile /home/sites/my_username/protected/.htpasswd
require valid-user

*Be sure to change the full path to the .htpasswd file for AuthUserFile

For .htpasswd put

yupapa:$1$6$1JSQqVNnwQ3v9jxfLuEIk1


The example above shows that the username and password is seperate with a colon.
username is yupapa
password is demopass

The password is encrypted and you will need a perl script to generate an encrypted password.


Now if you go to the password protected directory, it should ask you for username and password. Simply enter username 'yupapa' and password 'demopass'
Then you will be able to access to the password protected directory.

If you have got it working, I'll write a script for you to produce encrypted password for your .htpasswd file.

YUPAPA
04-03-2003, 08:28 AM
If you are new to perl and html, I recommend you use .htaccess because it doesn't require HTML and Perl Knowledge.

If you would like to do it without .htaccess, you will have to code everything in Perl.

lynniedesign
04-03-2003, 09:21 AM
The thing is that I don't want the pop up window. How then would I learn how to protect my pages in perl and have a login page with no popup windows asking for a username and passowrd and for that pasrticular user to just click the submit form and just go straight directly into the protected sites.
Is there a site or script out there where I can find these things to better understand what I am doing and to the mention of encrypting passwords, where can you suggest I find the coding for this?
I just didn't realize this is very complicated and thought htaccess would be the one I was looking for my site. Though thanks again for the support and suggestions. It helped. :)

YUPAPA
04-03-2003, 11:54 PM
You will need your site coded in perl to have a login form for your users to login.

TheTree
04-04-2003, 06:19 PM
Hi lynniedesign!!

I don't know if this will help, or not:

(Opening page----NOT pop-up)

<!-- DARK BLUE - #88B5E7 LIGHT BLUE - #C4DAF6 URL: http://theta-alphasigma.com/ -->
<HTML>
<HEAD>
<title>Login</title><base href="http://theta-alphasigma.com/"><link rel=stylesheet type=text/css href="http://theta-alphasigma.com/html_style.css">
</HEAD>
<BODY bgcolor=#88B5E7 leftmargin=0 topmargin=0 marginheight=0 marginwidth=0>
<TABLE cellpadding=0 cellspacing=0 border=0 width=760><FORM name=headerForm>
<form name="form1" action="http://theta-alphasigma.com/cgi-bin/login" method="POST">
<input type=hidden name="m_PR" value="33">
<input type=hidden name="m_CBURL" value="http://theta-alphasigma.com/auth/gateway?redirect=/cgi-auth/webshell">
<input type=hidden name="m_CBERRURL" value="http://theta-alphasigma.com/auth/gateway?redirect=/cgi-auth/webshell">
<input type=hidden name="m_LANG" value="1">
<input type=hidden name="Z" value="1049469464">
<input type=hidden name="m_AL" value="33">
&nbsp;<br></td></tr></table><center><H1>This area is Password Protected!</H1></center>
<table border=0 cellPadding=0 cellSpacing=0 width=266 align="center"><tr><td bgcolor=#C4DAF6><br><table width=100% border=0 cellPadding=0 cellSpacing=0 align=center><tr><td align=right><font>Member Name&nbsp;</font></td><td valign=center><input name="m_U" size=12 maxlength=32 value=""></td></tr><tr><td align=right><font>Password&nbsp</font></td><td valign=center><input type=password name="m_P" size=12 maxlength=20 value=""></td></tr><tr><td colspan=2 height=40 valign=middle align=center><input type=hidden name="m_AS" value="1">
<input type="Checkbox" checked=checked name="m_WS">&nbsp;<font class=small>Sign me in automatically<br></font></td></tr><tr><td colspan=2 height=40 align=center valign=middle><input type=submit value="Log In" width=10 style="background:88B5E7" style="color:black"></td></tr><tr><td colspan=2 height=30 align=center valign=top><font><a href="mailto:lynniedesign@theta-alphasigma.com?subject=Lost Password">Lost your password?</a></font></td></tr></table></td></tr></table></form>

</td>
</tr>
</table></td></tr></table>

</BODY>
</HTML>

*************************************************

Password Encryptor:

http://javascript.internet.com/passwords/
http://javascript.internet.com/passwords/character-encoder.html#source

<!-- TWO STEPS TO INSTALL CHARACTER ENCODER:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Mike McGrath (mike_mcgrath@lineone.net) -->
<!-- Web Site: http://website.lineone.net/~mike_mcgrath/ -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var str_in;
var str_out = "";
var num_in;
var num_out = "";
var e = "Enter Text!";

function str_to_num(form) {
num_out = "";
if(form.input.value == "") alert(e);
else {
str_in = escape(form.input.value);
for(i = 0; i < str_in.length; i++) {
num_out += str_in.charCodeAt(i) - 23;
}
form.output.value = num_out;
form.input.value = "";
}
}

function num_to_str(form) {
str_out = "";
if(form.output.value == "") alert(e)
else {
num_out = form.output.value;
for(i = 0; i < num_out.length; i += 2) {
num_in = parseInt(num_out.substr(i,[2])) + 23;
num_in = unescape('%' + num_in.toString(16));
str_out += num_in;
}
form.input.value = unescape(str_out);
form.output.value = "";
}
}
// End -->
</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<center>
<form name=encryptform>
<table>
<tr>
<td align=center>Original String</td>
<td> </td>
<td align=center>Encrypted Code</td>
</tr>
<tr>
<td align=center><input name=input type=text size=40 value="JavaScript Source"></td>
<td align=center>
<input type=button value="<--" onClick="javascript:num_to_str(this.form)"><br>
<input type=button value="-->" onClick="javascript:str_to_num(this.form)">
</td>
<td align=center><input name=output type=text size=40></td>
</tr>
</table>
</form>
</center>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 1.86 KB -->

***********************************************

I didn't write either of them-------the first one I've had for ages-----can't remember where I got it from.......

the second one has the related URLs, at the beginning of the script.......

Hope it helps!!!

TheTree