Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> How To Protect A Directory From Being Viewed, without admin username and password
Albus Dumbledore
post 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 biggrin.gif hopefully

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?
Go to the top of the page
 
+Quote Post
remuslupin
post 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.)
Go to the top of the page
 
+Quote Post
master_bacarra
post 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
Spam Patrol



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.
Go to the top of the page
 
+Quote Post
Xplicid
post 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.
Go to the top of the page
 
+Quote Post
Dooga
post Jun 29 2006, 08:55 PM
Post #5


Super Moderator
Group Icon

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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Make Yourself Admin On A Computer(26)
  2. Wordpress 1.5 - Restricting Single Posts(1)
  3. Making A Webserver Directory Listing(6)
  4. Making Winrar Archives(11)
  5. Get Rid Of Password Expiry(6)
  6. How To Stop Image Hot Linking(17)
  7. Several Ideas For Easing Pc Lab Admin(0)
  8. Php Script To Make A Link List(6)
  9. Unencrypted But Invisible File Storage(0)
  10. How To Set A Password In Bios(2)
  11. Change Your Computer Password(5)
  12. Simple Javascript And Password System(5)
  13. Make A Moderately-secure Password System Using Javascript(2)


 



- Lo-Fi Version Time is now: 16th May 2008 - 06:07 PM