Printer Friendly Version Print this thread
Email this thread to a friend eMail this thread to a friend
Related Forum Posts
Featured Web Site Template

Hundreds More at Free Site Templates.com!

Web Site Partners
Sponsored Links
Jet City Software
 
Whos Here ?
There are 0 guests and 1 members in the forums right now.
Reflects user activity within the last 5 minutes
Moderator(s): Prowler, jcokos
Member Message

david68
Joined: May 16, 2005
# Posts: 144

View the profile for david68 Send david68 a private message

Posted: 11/03/2006 09:33 am
Edit Message Delete Message Reply to this message

Reason: Apparently, for reasons I don't understand (explain if you wish), the web server I use requires the folder I wish to COPY() files (.gif) from folder to folder using a PHP script needs to be 777 - which, if I understand correctly, allows hackers full access to my space. I seem to be able to write normal files using fopen to folders with perms of 755 (maybe less - default of folders is 755).

So, my question is: How do I copy /folder1/this.gif to /folder2/new.gif without using the COPY() command? I've looked for code and the examples I've found don't help me at all - I'm new to PHP. Thanks for any help you can give me.




Prowler
Moderator
Joined: Aug 14, 2000
# Posts: 1720

View the profile for Prowler Send Prowler a private message

Posted: 11/04/2006 12:20 am
Edit Message Delete Message Reply to this message

There are many ways of doing this. But we will start at the very beginning.

You can circumvent the directory permission (777) required to enable your server to write to the designated directory by changing the ownership to your server itself. That way you can live with the standard 755 or 644 permission mode.

Find out what name your server uses by looking at the owner column of the file written by your script. Use that name to own the directory. If you have shell access to the server, this is easy.


To copy without using the command copy(), you can load the content of the file ( binary or ASCII) into an array and write back the array where you need.
As I said earlier, there are many ways. I am suggesting the first way that came to me. smile



david68
Joined: May 16, 2005
# Posts: 144

View the profile for david68 Send david68 a private message

Posted: 11/04/2006 08:08 am
Edit Message Delete Message Reply to this message

Thanks. I don't have access to change ownership - it's a shared server. Some hosts work fine with standard perms of 755, this one, as others, does not. I've questioned as to why it is this way, but they say "for security reasons". (shrug)

I've read (googled) on how to copy files using arrays, but I'm new to PHP and it's a little over my head. I was hoping for some quick code to save me time. I'll continue to work on it smile Thanks for the reply.




david68
Joined: May 16, 2005
# Posts: 144

View the profile for david68 Send david68 a private message

Posted: 11/04/2006 11:28 am
Edit Message Delete Message Reply to this message

Ok, I wrote a routine which successfully copies a .GIF without using COPY() - except it actually has the same file permission problem.

1) My guestbook (PHP) script can write a text file to any folder and it works. Perms: PHP=644, File: 666, Folder of text file: 755.

The text file was pre-created, uploaded as 0k.
(there would be no way to do this for my copy routine)

2) My copy routine. I checked owners and the PHP script itself says I'm owner, the guestbook text file I am owner, the orignial GIF file I am owner, but the new GIF I created says "nobody" is the owner (code 66). Any way to tell PHP to create it under my ownership?

And why is it my PERL CGI scripts write normally. They can create files with perms of 644. Is PHP not set correctly?

Thanks. I hope someone has an answer for me.

[ Message was edited by: david68 11/04/2006 11:44 am ]




You are not permitted to post messages in this forum or topic, because of one or more of the following reasons:
  1. You have not yet logged in, or registered properly as a member
  2. You are a member, but no longer have posting rights.
  3. This is a private forum, for which you do not have permissions.

If you are a recent member, it's possible that you simply have not yet confirmed your account. Please check your email for a message entitled 'JimWorld Forums: Confirm Your Account' and follow the instructions contained within.

If you cannot find this message, click here to Re-Send it.

If you are still experiencing problem, please read the Login Assistance Article for some advice on what may be causing your login not to work properly.

Switch to Advanced Editor and ... Create a New Topic or Reply to this Thread

New posts Forum is locked
© 1995  ·  iWeb, Inc  ·  DBA JimWorld Productions