Jump to content

File and Directory security

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
atrip25

atrip25

    Newbie

  • Members
  • PipPip
  • 26 posts
I'm working on a programm that will do the following:

Create a PHP page that allows the user to input their First and Last Name as a single field, Local Phone, and E-mail address.

The form should:
a. Parse the Name field into separate First and Last Name fields
b. Require all 4 elements (i.e. return an error if the form is not completely filled out).
c. Return the information to the user
d. Write the output of the form to a file containing the four fields. Name the output file exphp2.txt

I've got all but d actually working. When I submit the information, it returns the information via a web page, however I am getting an error "Warning: fopen(exphp2.txt) [function.fopen]: failed to open stream: Permission denied in /usr/home/.../exphp2.php on line 26
Can't open file

How would I go about setting up permissions on the directory or file that I am trying to modify?

#2
atrip25

atrip25

    Newbie

  • Members
  • PipPip
  • 26 posts
Disregard, it was the permissions on the text file. I'm good to go.:thumbup:

#3
atrip25

atrip25

    Newbie

  • Members
  • PipPip
  • 26 posts
I do have another question dealing on security. I currently have a web page that users can go to in order to upload a file to the server. Right now it is currently open to anyone and I want to change it to allow only one person to access it. I want to move the php file to a secure folder and only allow access to only that one person. How would I set that up.

#4
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
create a .htaccess file enabling password, or just put a password in your upload form, it's about the same safety.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#5
atrip25

atrip25

    Newbie

  • Members
  • PipPip
  • 26 posts
That would be want I was looking for. I have setup my .htaccess and htpasswd files and when I go to the secure folder via a url I am prompted with a username and password box to login, however when I put in the information I'm getting a 500 Internal Server Error. Is there more that I need to do or something I did wrong?

#6
atrip25

atrip25

    Newbie

  • Members
  • PipPip
  • 26 posts
I followed these instructions on setting it up.

.htaccess Tutorial

I should also note that I have both the html file and the php file that I am using inside the secure folder. Would this be a good way of doing it?

#7
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
are you sure that the path to your .htpasswd is the correct absolute path?
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#8
atrip25

atrip25

    Newbie

  • Members
  • PipPip
  • 26 posts
I'm not entirely sure what I did wrong. I deleted the directories and files and then recreated everything. It seems to be working now. Thanks for the help.