View Full Version : array from file
rbmyr81
05-29-2004, 03:59 PM
hey- wasn't sure where to put this post but the subject explains it pretty well- is there any way in javascript to make an array, getting the values from an outside file or something... i'm on a free server with includes but not any password protection on my files... basically i want an array with the values not visible to someone viewing the source code- the purpose is to put my address on a contact info page, but to only allow certain people to view it, so i was thinking of making them enter their name and if it was one of the allowed names, they could see it...
Bobby
agent002
05-29-2004, 04:08 PM
hi there,
JavaScript questions belong to the client side scripting forum :)
Well, I only know one safe way to protect pages using JavaScript; you can see an online demo here (http://members.surfeu.fi/jerkku/htmlforums/login.html). It is a simple script that attempts to go to an URL with the password you typed, so you have the password in the filename. Of course, if you type the wrong password, you get a 404 error page. Put this code between the <head> and </head> tags:
<script type="text/javascript">
function loginForm(f){
location.href = 'password-'+escape(f.username.value)+'.html';
}
</script>
And then create a form similiar to this:
<form action="about:blank" method="post" onsubmit="loginForm(this); return false;">
Password: <input type="password" name="password"><br>
<input type="submit" value="Log in">
</form>
rbmyr81
05-29-2004, 04:48 PM
ok thanks but the only problem is i would have to create a page for each person hehe i dunno... if there was any other way to do it using a different language that might be useful... if i could figure out how to use it...
agent002
05-29-2004, 04:58 PM
Well, is every person going to see the same page? Then you wouldn't need to ask for a username at all, would you? :)
Yeah, JavaScript is certainly not the best way to go for password protection. If your server supports any server side language, like Perl (CGI), PHP, ASP or Python, choose one of them and write a script, or get one from hotscripts (http://www.hotscripts.com/).
rbmyr81
05-30-2004, 12:07 AM
yes, everyone will see the same page, but it has my address and stuff on it so i dont want it to be available to anyone who looks at it... to be honest, no one will really be looking at my site except the people who i talk to on im, but better to be safe than sorry...
agent002
05-30-2004, 04:05 AM
well, you see... the password is in the page address... so you can't know the page address without knowing the password? Let's say, it is www.yourdomain.com/password-weeblandbob.html. So the password is "weeblandbob". The script I suggested takes the password you typed from the input, makes a URL of it and attempts to redirect you there. So you don't need to type the URL manually.
rbmyr81
05-30-2004, 01:50 PM
yeah... i guess i could just give my email and have them email me for the password
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.