How To Protect A Directory From Being Viewed - without admin username and password

free web hosting
Open Discussion > CONTRIBUTE > Tutorials

How To Protect A Directory From Being Viewed - without admin username and password

Albus Dumbledore
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?

 

 

 


Reply

remuslupin
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.)

Reply

master_bacarra
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.

Reply

Xplicid
Correct me if I'm wrong but isnt that just PHP getting the details from the .htaccess and .htpasswd files.

Either way, nice script.

Reply

Dooga
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.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. "user account" "protect a directory" password windows - 563.28 hr back. (1)
  2. set password directory admin/login.php - 776.26 hr back. (1)
Similar Topics

Keywords : protect, directory, viewed, admin, username, password

  1. How To Remember Complex Passwords
    Use the BEST password system ever! (11)
  2. Make A Moderately-secure Password System Using Javascript
    using file redirection to hide the password. (4)
    JavaScript is very handy at making forms, allowing for much more customization and easier ways to
    send data. So making Login forms using JavaScript may seem to many to be a very feasable idea.
    However, JavaScript is very bad at protecting Passwords, as since the passwords are not encypted and
    the whole JavaScript code is in the page, a person could just view the Page Source and find out
    everything. Even if you use an external JavaScript, it would still be poor as the file name for the
    external JavaScript would still be revealed. But I have an answer! There is a rela....
  3. Simple Javascript And Password System
    How to protect your pages with password (9)
    The quickest way to get a password protection system up and running is to use a Prompt box in
    JavaScript that has a title like "Enter your Email Address". Only you and the relevant users know
    what the password should be, could even be one each, that can be sorted out at the next page then
    pass the "input" directly through the url by changing the .href, like
    http://www.iSource.net.nz/users/?leTmeIn= The page that then processes this should also check for
    the referring page, and three fails from an IP if you like the php (the next page): CODE
    <?php // processdo....
  4. Change Your Computer Password
    Change Your Computer Password (6)
    This Topic will teach how can you change your without knowing your old Passward 1. Click "Start"
    Then Click "Run". 2. In the dialog box type in "CMD" and select "OK". (Opens Command Prompt) Or you
    can manually open CMD by navigating to "C:\WINDOWS\system32\cmd.exe". 3. Once
    Command Prompt is open, type in "net user" and hit enter. This will display all user accounts. 4.
    Now type in the following command: " net user (ACCOUNTNAME) * " and hit enter Example: net user
    Trap * (Dont forget to add the asterisk) 5. Now it will ask for a new password, enter....
  5. How To Set A Password In Bios
    the password is asked during start up (2)
    first let me tell you what is setting a password in bios is the password set at bios is asked when
    you start your pc even before your operating system is booted heres the steps 1.as soon as you start
    your pc press 'del' or 'Esc' continiously and you'll find the bios screen
    2.when you spot the bios screen go to the security section in security section there are two option
    of setting password 1.admin pass - you can't del this pass in bios without knowing the
    password(only for advanced users) 2.user pass - you can delete bthis password from bios ev....
  6. Unencrypted But Invisible File Storage
    It can have a password, it can be unlocked. (0)
    This method works, but unfortunately compression software can open the file without the password.
    Also, you can try creating a new user account. When it asks "Make files and folders private?" click
    Yes, make private. Name the new user account anything using NO spaces/uppercase letters, but not
    something like "privatefiles" or something like that. Try accessing the files in C:\Documents
    and Settings\ >. You cannot open the folder. Now to ensure that user is always hidden in My
    Computer, click Start > Run. 1. Type in command.com . This should bring up a blac....
  7. Php Script To Make A Link List
    From the list of the Directory Files (6)
    Well, it has been a while since I have added anything to the Tutorial Sectiion, so here is another
    script for the members to enjoy. This one creates a list of links from the contents of the directory
    which it is run from. For instance, if you run it from the public_html folder, then all the files
    (not the Directores) are listed and linked so when you click on the link, that file is parsed and
    output to the browser. Here is the code: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    An XHTML 1.0 Strict Page to List the files in this directory ....
  8. Several Ideas For Easing Pc Lab Admin
    From an experienced admin/helpdesk guy (0)
    Like many techs I've been chewing on ways to reduce the time it takes to maintain a big
    collection of "public" computers with common configs. We already use Ghost, which is wonderful, but
    there are opportunities for improvement, so... Some things to try: 1. Basic Windows precautions
    help - XPsp2 Firewall, default acct has only User rights, not Power/Admin, etc. You can freeze
    a config (make it fix itself daily) using Reborn cards from www.lenten.com or the like.
    Software solutions like DeepFreeze from Faronics are another popular way to "lock down" p....
  9. How To Stop Image Hot Linking
    for a selected directory. (17)
    Those of you that don't know what is meant by 'hotlinking', it is when someone directly
    links to an image on your site so it will display on their site. This is what is called
    'bandwidth theft' and being as accounts here have a limit on bandwidth, your bandwidth limit
    could be exceeded by someone else hotlinking to your images. As most users of cPanel will know,
    there is an option to disable hotlinking of images in the "Site Management Tools" section.
    However, this disables hotlinking to all directories, what if you only want to disable hotlinki....
  10. Get Rid Of Password Expiry
    Windows xp (6)
    In this tut i'm going to tell u how to remove the psswd expiry in windows xp * Go to Start|Run
    and type Control userpasswords2 * Go to Advanced tab in the user accounts window * Again select
    the Advanced button under the Advanced user management header. * Now click on the User in the Local
    Users and Groups. * On the right pane you will see the list of all user account * Right click on
    the user name for which you want to change the setting and select the Properties option. *
    Now click in the General tab check on the password never expires option. * Clic....
  11. Making Winrar Archives
    and adding password to winrar archives (13)
    **** This tutorial will show you how to put files into .rar Archive and pass worded (if wanted)
    **** What You Will Need Before continuing you will need a couple of thing, first of all you
    need WINRAR , which is a very powerful archive manager. It can reduce size for you email
    attachments, decompress RAR, ZIP and other types of files downloaded from the internet. You can get
    winrar at http://www.rarlabs.com The other thing is that make sure your using Windows XP because
    this is what I used to make this tutorial. I think it works with any other windows not....
  12. Making A Webserver Directory Listing
    Helps you organise your webserver (6)
    I recentely installed IIS with PHP and MySQL on my pc (previous I used UniServer, but that
    doesn't matter here). But I had always to go to http://localhost/websiteiwanted or I had to
    create a shortcut on my desktop for every site so I decided to create an "overviewpage". It shows
    all the websites in your wwwroot with a link to them. If you have folders you don't want to be
    included, you extense the && check (but I'll explain this lateron) Here's the total code:
    CODE <ul> <table cellpadding="3" cellspacing="3" border="....
  13. Wordpress 1.5 - Restricting Single Posts
    Without having to enter a password for each post (1)
    This is a mini tutorial on how to tweak WordPress 1.5 so that anonymous readers or registered users
    below a certain level (set by you) cannot view posts that you want to hide from them. They
    won't even know that the posts exist. This is assuming that either 1. you are running a
    blog/site that is meant to be administered by only one person (ie, you). OR 2. you want to let some
    people co-author with you, but still need some posts to be restricted (more of a bloggers'
    privacy issue). First Step : Download the Post Levels Plugin from http://fortes.com/projects....
  14. Multiple Admin Login (php)
    This is a script that doesnt requre SQL (3)
    first off make a login.html page Code: QUOTE Admin Login Username: Password:
    then make a check.php page Code: QUOTE $admin1 = "admin1"; //
    first admin username $adm_pass1 = "password1"; // first admin password $admin2 =
    "admin2"; // second admin username $adm_pass2 = "password2"; // second admin password
    if(($username == $admin1 && $password == $adm_pass1) || ($username ==
    $admin2 && $password == $adm_pass2)){ echo "Congratulations " . $_POST . " ....
  15. [php]password Protect W/o Db
    A good php tutorial (13)
    Hello all, I found this script actually on another website. But I modded it and added some things.
    Heres the code and stuff. Open a new file in your text editor and paste in this code. CODE
    <?php { echo '<form name='pp' method='post'
    action='check.php'> Username:<input type='text' name='user'
    value=''><br> Password:<input type='password'
    name='pass' value=''><br> <input type='submit'
    value='Login'> </form>&....
  16. Make Yourself Admin On A Computer
    (28)
    Last year, my whole family used one computer, and I could never install anything because my account
    was limited, and my parents were scared I would download a virus. One day I decided to try and find
    a way to make myself able to install stuff, and I found out, but because of my parents carelessness.
    It doesn't work if the Administrator, the one that doesn't show up on logon has a password.
    Here's how to do it: Restart your computer, and when it first starts press f8, it's f5 on
    some computers, and then select run Windows in safe mode with networking, a....

    1. Looking for protect, directory, viewed, admin, username, password

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for protect, directory, viewed, admin, username, password

*MORE FROM TRAP17.COM*
advertisement



How To Protect A Directory From Being Viewed - without admin username and password



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE