|
|
|
|
![]() ![]() |
Jun 22 2006, 03:57 AM
Post
#1
|
|
|
Hidden Secrets can't be told threw just words. One must feel what the other feels to truely understand... ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,523 Joined: 8-January 06 From: Sacramento California Member No.: 16,756 |
Well i ran across this script awhile back, and i am tired of storing it on my computer, so i am going to post it here and whenever i need it i will come here and get it
Anyways, it is a verry simple process just copy and paste this QUOTE <? if (($user) && ($passwort)) { # get url $url = $DOCUMENT_ROOT . dirname($PHP_SELF) . "/.htpasswd"; # make .htaccess and .htpasswd $htaccess_txt = "AuthType Basic" . "\n"; $htaccess_txt .= "AuthName \"protected area\"" . "\n"; $htaccess_txt .= "AuthUserFile $url" . "\n"; $htaccess_txt .= "require valid-user" . "\n"; $htpasswd_txt .= "$user:".crypt($passwort,CRYPT_STD_DES)."\n"; # save files $htaccess= fopen(".htaccess", "w"); $htpasswd= fopen(".htpasswd", "w"); fputs($htaccess, $htaccess_txt); fputs($htpasswd, $htpasswd_txt); fclose($htaccess); fclose($htpasswd); # output die ("OK!<HR>" . nl2br($htaccess_txt) . "<HR>" . nl2br($htpasswd_txt)); } ?> <HTML><HEAD><TITLE> MAKE .htaccess + .htpasswd </TITLE></HEAD> <BODY> <FORM METHOD="POST" ACTION="<? echo $PHP_SELF; ?>"> <p>Username: <INPUT TYPE="TEXT" NAME="user"></p> <p>Passwort: <INPUT TYPE="TEXT" NAME="passwort"></p> <p><INPUT TYPE="submit" VALUE="make"></p> </FORM> </BODY></HTML> into Notepad, or your local HTML editor, and save it as password.php (or whatever you want lol) then upload it to the directory you want to protect, for say your /image directory.. CHMOD it to 777 then go to http://yoursite.com/password.php and enter the admin username, and admin password then hit the submit button (or whatever the button is called) then it shall be created! easy enough? |
|
|
|
Jun 28 2006, 12:57 PM
Post
#2
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 10 Joined: 28-June 06 Member No.: 25,780 |
I havent tried, but im sure its a good one..
And also, for beginners, you can hide your directories by creating an empty (or full, what you want...) index.html file.. But by a offline browser, professionals can figure out the directories. (and i guess, if u have no link to these file which u want to hide, they cant know.) |
|
|
|
Jun 28 2006, 01:07 PM
Post
#3
|
|
|
I'm back... well, sort of. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 696 Joined: 26-December 05 From: somewhere in the middle of nowhere Member No.: 16,226 ![]() |
but what if you want to protect multiple directories? does this apply to the subdirectories under the directory which the file is placed? i would probably use it for my hosting account here at trap...
speaking of that... gonna get more points.... i'm running out of days, and i still don't have a connection at home. tsk. i don't know why my parents keep on restricting me when it comes to the internet. |
|
|
|
Jun 29 2006, 08:56 AM
Post
#4
|
|
|
Newbie ![]() Group: Members Posts: 1 Joined: 29-June 06 Member No.: 25,817 |
Correct me if I'm wrong but isnt that just PHP getting the details from the .htaccess and .htpasswd files.
Either way, nice script. |
|
|
|
Jun 29 2006, 08:55 PM
Post
#5
|
|
|
Super Moderator ![]() Group: [MODERATOR] Posts: 1,312 Joined: 26-December 04 From: Canada Member No.: 2,940 |
Cpanel has a built in function that allows you to set user passwords for each directory, if you want. It can also prevent someone viewing the contents of a directory without an index page.
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 16th May 2008 - 06:07 PM |