View Single Post
Old 07-20-2003, 05:47 PM   PM User | #46
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
Since this is so popular and simple, yet people somehow still have problems getting it to work, I've also added a VBScript file you can run, which will prompt you for the username, password, and URL of the protected page.

It will then create the javascript password file for people unfamiliar with javascript. All you need to do then, is put the password file in the same directory as login.htm and auth.htm.

The URL is not validated, so if the resulting password file doesn't work, you probably typed the URL wrong.

The .zip file is attached to this message.

Just double click on the "PasswordHelper.vbs" VBScript file and follow the instructions to create your password file(s). You need to run this file locally, and then upload the password file(s) to your website.

Note: VBScript is a ©Microsoft technology, so this file will only work on Windows!

This file is safe to run. If you get any warnings, or are concerned, you can open the .vbs file with notepad, and make sure that the code matches the following:

Code:

Option Explicit
Dim UserName, Password, RedirectPage
Dim fs, f
While NOT IsAlphaNumeric(Username)
	If Username <> "" AND NOT IsAlphaNumeric(Username) Then
		MsgBox "Username must be alphanumeric, without spaces!",16,"Password Helper"
	End If
	Username = InputBox("Enter Username:","Password Helper")
Wend
While NOT IsAlphaNumeric(Password)
	If Password <> "" AND NOT IsAlphaNumeric(Password) Then
		MsgBox "Password must be alphanumeric, without spaces!",16,"Password Helper"
	End If
	Password = InputBox("Enter Password:","Password Helper")
Wend
While RedirectPage = ""
	RedirectPage = InputBox("Please enter the URL of the password protected page:","Password Helper")
Wend
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(LCase(Trim(Username)) & LCase(Trim(Password)) & ".js",2,True)
f.WriteLine("auth = true;")
f.Write("redirect = """ & RedirectPage & """;")
Set f = Nothing
Set fs = Nothing
MsgBox "Password file created!",0,"Password Helper"

Function IsAlphaNumeric(str)
	Dim ianRegEx
	Set ianRegEx = New RegExp
	ianRegEx.Pattern = "^[a-zA-Z0-9]+$"
	ianRegEx.Global = True
	IsAlphaNumeric = ianRegEx.Test(str)
End Function
Attached Files
File Type: zip jslogin.zip (1.9 KB, 620 views)
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)

Last edited by whammy; 07-20-2003 at 06:08 PM..
whammy is offline   Reply With Quote