View previous topic :: View next topic |
Author |
Message |
Candle
Joined: 23 Dec 2002 Posts: 547
|
Posted: Thu Apr 24, 2003 11:18 pm Post subject: password protected blog hack |
|
|
Ok I think I seen somewhere that someone wanted to password protected their blog ?
Well found some code that will do that to any page you want to put a passwd to it .
Can have as many passwds as you want .
2 parts for installing this script:
1. Save this first information in a file (ex. login.pwd).
2. Include the include tag to the PHP document you want to secure.
Code: | SAVE THIS IN A FILE:
<?php
if(!isset($PHP_AUTH_USER)) {
Header("WWW-Authenticate: Basic realm=\"Title of the restricted area?\"");
Header("HTTP/1.0 401 Unauthorized");
exit;
} else {
if (
($PHP_AUTH_USER == "username01" && $PHP_AUTH_PW == "password01") ||
($PHP_AUTH_USER == "username02" && $PHP_AUTH_PW == "password02") ||
($PHP_AUTH_USER == "username03" && $PHP_AUTH_PW == "password03")
) {
} else {
Header("WWW-Authenticate: Basic realm=\"Try again!\"");
Header("HTTP/1.0 401 Unauthorized");
Print "
PRINT SOME HTML HERE WICH WILL BE SHOWN IF YOU ENTER WRONG USER/PASS 3 TIMES.
";
exit;
}
}
?>
|
Code: | <?php
include("source/to/login.file");
?> |
_________________ My Game Forum

Last edited by Candle on Thu May 01, 2003 5:03 am; edited 1 time in total |
|
Back to top |
|
 |
Ruud
Joined: 12 Oct 2002 Posts: 77
|
Posted: Mon Apr 28, 2003 12:51 am Post subject: |
|
|
Excellent one. Quite elegant to use, nice and simple.
Ruud |
|
Back to top |
|
 |
gooified
Joined: 09 Jul 2003 Posts: 19
|
Posted: Wed Jul 09, 2003 11:29 pm Post subject: |
|
|
could someone exlain this in idiot terms?
like when you say name the file "blah blah" can you be more specific? i have no concept of php whatsoever... and i really would like this to work for me. =/ |
|
Back to top |
|
 |
Candle
Joined: 23 Dec 2002 Posts: 547
|
Posted: Wed Jul 09, 2003 11:46 pm Post subject: ........... |
|
|
Ok copy the first code and name it login.pwd ( i would name it to something else .pwd)
Then you put this at the top of the page to password protect it
<?php
include("source/to/login.file");
?>
So if your login.pwd is in your the same folder as your index just do at the top
<?php
include("what you name it.pwd");
?>
then change the usersnames and passwords here .
($PHP_AUTH_USER == "username01" && $PHP_AUTH_PW == "password01") ||
($PHP_AUTH_USER == "username02" && $PHP_AUTH_PW == "password02") ||
($PHP_AUTH_USER == "username03" && $PHP_AUTH_PW == "password03") _________________ My Game Forum
 |
|
Back to top |
|
 |
gooified
Joined: 09 Jul 2003 Posts: 19
|
Posted: Wed Jul 09, 2003 11:53 pm Post subject: |
|
|
thank you soooooo much!
i feel like an idiot lol... but thanks again. =) |
|
Back to top |
|
 |
Candle
Joined: 23 Dec 2002 Posts: 547
|
Posted: Wed Jul 09, 2003 11:54 pm Post subject: ,,,,,,,,,, |
|
|
Your welcome . _________________ My Game Forum
 |
|
Back to top |
|
 |
|