Current location: Hot Scripts Forums » Programming Languages » PHP » ? on users accessing a directory


? on users accessing a directory

Reply
  #1 (permalink)  
Old 10-16-03, 10:38 AM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
? on users accessing a directory

Was wondering about password protecting a folder/directory. Lets say I set up a website like this...

Main Directory...
file-intro.html
file-member sign up form
file-sign in form
folder-public area
folder-member area

Basically, anyone can access the public directory, but a viewer has to add themselves as a member via the form to access the member directory. The intro.html gives the viewer a choice between the public or member area. The sign up form adds their info to the db, the sign in form gives them access to the members folder. How can you pass protect the member folder/directory so that it queries the db for their sign in info (ex. member name & password)? This is so no one can access any files inside the folder before becoming a member. Does .htaccess do this, or is it only for one password? Sessions? I've found a few member-auth scripts, but they seem pretty massive, or don't seem to let you designate the directory you are led to after signing in, and I wasnt sure about protecting each page inside the folder. Hope I explained this clearly. Thnx.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-17-03, 03:53 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
I think there is no pretect-folder script up there yet , and I think it's not possible ...
you have to protect all files inside this folder ..
and yes you have to use sessions or cookies , in my current script I've used cookie method , and it's not that difficult! all you have to do is to define a function that checks for the cookie ! if the user has no cookie it will show error message and redierct him to login page ..
all you have to do is define this function and then call it in all the pages you want to protect ...
also you can have multi-privilaged system using the same method by defining a function to check that ..

sadly the script I wrote isn't in this machine I am using right now , or I would love to show it for you to give you a better view of what I mean
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 10-17-03, 11:44 AM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Thanks for the response. Also, I should have mentioned that, after signing in, the user would be directed to an index.shtml file, not a php file. Does this change the way this needs to be set up?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 10-18-03, 12:14 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
I don't know how shtml files work so I am afraid I can't tell something useful
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 10-18-03, 12:22 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Well, shtml is basically the same as html. The "s" just lets the server add includes into the page. So a setup for html pages should work for shtml, but I can't find a good solution for multiple users to get access to a standard html/shtml page. I dont like the idea of manually adding users to the htpassword file, or converting the pages to php since I'm more comfortable with html. A member-info type of form that goes to a php script that would add users to the htpass file would be ideal. Essentially I want it all automatically done, but feel I may not have too many options. Like I said, this is the first I've dealt with password-type areas, so I'm open to suggestions.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 10-18-03, 12:29 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
it is possible to have all passwords and users in a flat file ! but it NOT recommended because it is %1000 UN-Secure .. and may get hacked easily ..
but still possible to do ...
but having a plain html files that do protection is not possible ..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 10-18-03, 12:34 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Any idea how difficult, or time-consuming, to convert html pages to php? Thinking this might be the best alternative.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 10-18-03, 12:47 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
not a single hour on conveting !!!
all you have to do is beging your file with php tag '<?php'
and close it once you finish !!
an example to show what I mean :
PHP Code:

<?php

$ex
='Hello world';
//now we will close the tag to put plain HTMLs
?> 
<HTML>
<HEAD>
<TITLE> <?php echo $ex// we started them and closed them again just to print the variable 
?> 
</TITLE>
<BODY>
#lot's of plain HTMLS 
#
#
#end of HTMLs
<?php for ( $ .... //some php process ?>
</BODY>
</HTML>
as you can see php is colored while the other HTML in black which means php parser will NOT touch them unless they are inside the tags
now we have php and html in the same file and still will be excutable normaly .. just name your files with PHP and it shall work fine ..
hope I didn't confuse you
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]

Last edited by NeverMind; 10-18-03 at 12:50 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 10-18-03, 12:56 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
That is quick. Couple of questions...

Can an if/else statement be added to check the member name/password then, so that if they dont match the page doesnt display, and if they do, it does display?

The purpose of this: <?php for ( $ .... //some php process ?>

I have some knowledge of php/mysql querys, but not much knowledge of straight php coding, so I apologize for sounding totally ignorant here (which I am).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 10-18-03, 01:06 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
Quote:
Can an if/else statement be added to check the member name/password then, so that if they dont match the page doesnt display, and if they do, it does display?
yes you can ..

Quote:
The purpose of this: <?php for ( $ .... //some php process ?>
it was just an example to show that you can use EVERY php process in your compined pages

and hey !! you are no ignorant !! because asking for knowladge is good
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
i know how to delete a file! but how to delete a directory? forcer JavaScript 3 01-28-04 08:00 AM
Upload to user-defined directory? tom PHP 1 09-26-03 12:14 PM
managing linux users from php asinclair PHP 0 09-22-03 07:08 AM
Showing images in a directory Bob PHP 4 08-25-03 09:16 AM
retrieve directory Greg PHP 3 06-19-03 04:10 AM


All times are GMT -5. The time now is 06:33 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.