View previous topic :: View next topic |
Author |
Message |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Sun Apr 25, 2004 12:13 am Post subject: Locking out non local users! |
|
|
I just created a script that allows only localhost or 127.0.0.1
to access the Abyss Web Server , I know i catch on to PHP fast
lol , any way here it is , only localhost is granted permission.
Name this index.php
Code: |
<?php
if ($REMOTE_ADDR == "127.0.0.1") {
header("Location: /main.html");
}else{
print "Only localhost is allowed in!";
}
?>
|
If I can learn PHP so fast than you too can do the
exact same crap I do , Larry Ullman's books rule!
You have to check his books out , by the way
I didn't get that code from the book , I made it up
Edit: This code will only work inside index.php , if you want to
add this to your other php pages , you will need to insert that
code in every php page in order to validate all web pages in php.
Last edited by TRUSTAbyss on Sun Apr 25, 2004 12:25 am; edited 1 time in total |
|
Back to top |
|
|
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Sun Apr 25, 2004 12:21 am Post subject: |
|
|
... Which is great as long as your whole site is in PHP and no-one knows or guesses any direct links to anything... I guess you could use it to protect a small admin area but it's not really useful for protecting a whole site. |
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Sun Apr 25, 2004 12:28 am Post subject: |
|
|
Yeah , its just a small sample that I may add
to my File Uploader program when I create my
admin section , I thought you all might want that
piece of code I came up with , I think its cool!
Last edited by TRUSTAbyss on Sun Apr 25, 2004 12:56 am; edited 4 times in total |
|
Back to top |
|
|
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Sun Apr 25, 2004 12:55 am Post subject: |
|
|
At least this one doesn't require a database and also the
new redirection code that I posted does not work so im
a complete NewB to PHP but just wanted post code! |
|
Back to top |
|
|
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Sun Apr 25, 2004 1:00 am Post subject: |
|
|
You can also put the script on each page, checking if the referrer was from the main page.
That is also sort of easy to get around, but it is better than nothing. You can always use cookies. _________________ Bienvenidos! |
|
Back to top |
|
|
|