Go Back   Novahq.net Forum > phphq.Net > phphq.Net Forums
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-05-2010, 07:13 AM
paulus is offline paulus
Registered User

Join Date: Apr 2010
Posts: 5

phUloader v1.3 CHMOD settings

Hi,
Happy easter for everyone!
This is the first time I'm trying to implement a php script instead of the usual javascripts. I can read a php script but I'm not able (yet) to write such a script myself.
I love this script because of its simplicity and the fact that it offers a lot of options I'm looking for, but ................. I'm stuck because Apache seems to be the owner of uploaded files (CHMOD 0600) The person who uploads a file can access it by clicking on the URL in the html output. Suppose someone else uploads a file to my site. I'm not the owner and therefore I cant access it.
On 06.23.2008 Scott explained to Yogi how to adapt the phUploader script v1.2 in order to make the script change the CHMOD settings of uploaded files to 0755.
Because the code of v1.3 differs from v1.2 and mainly because it's security issue I prefer to pose the question to you experts instead of experimenting.
Thanks in advance for your kind help.
Regards
Paul
Reply With Quote
  #2  
Old 04-05-2010, 08:28 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,922

There are a few thing you can do to help your situation. The first is to CHMOD your files after upload.

After this: (line 246)
PHP Code:
                    If(move_uploaded_file($_FILES['file']['tmp_name'][$i],$folder.$file_name[$i].".".$file_ext[$i])) { 
ADD This:
PHP Code:
@chmod($folder.$file_name[$i].".".$file_ext[$i], 0755); 
If that does not solve your issue you may want to play around with the chown function. http://php.net/manual/en/function.chown.php but I've personally never had to use it. It would work the same way as chmod, you'd add it below your chmod function. Example:

PHP Code:
If(move_uploaded_file($_FILES['file']['tmp_name'][$i],$folder.$file_name[$i].".".$file_ext[$i])) {
    
chmod($folder.$file_name[$i].".".$file_ext[$i], 0755);
    
chown($folder.$file_name[$i].".".$file_ext[$i], "YOUR_LINUX_USER_NAME"
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #3  
Old 04-05-2010, 09:18 AM
paulus is offline paulus
Registered User

Join Date: Apr 2010
Posts: 5

Thanks Scott
Your @chmod(....etc) suggestion solved my problem.
Paul
Reply With Quote
  #4  
Old 04-05-2010, 01:07 PM
paulus is offline paulus
Registered User

Join Date: Apr 2010
Posts: 5

Sorry Scott, I was too fast confirming that the @chmod(....etc) suggestion solved my problem.
What happens now is way above my capacity.
The sizes of the files send and received are different.
I've uploaded a .doc file, size: 22,528 bytes and received 22,549 bytes.
I've uploaded a .jpg file, size: 5,837 bytes and received 5,847 bytes.
I'm not able to open the word document (Office error message "try to open and repair" which doesn't work) and the jpg image is distorted (some parts invisible, some parts greyed out).
Same problem with uploaded pdf (shows a blank page), zip and rar (unable to open) files
When I remove the @chmod line the file size doesn't change, but I can't download them (initial CHMOD 0600 problem)
Any idea what happens here?
Paul
Reply With Quote
  #5  
Old 04-06-2010, 04:36 AM
paulus is offline paulus
Registered User

Join Date: Apr 2010
Posts: 5

Hi Scott,
This morning I contacted my hosting company.
I found out that due to security issues (shared webhosting) they configured PHP in safe_mode.
They told me that the script probably doesn’t assign a specific owner of the uploaded files and therefore automatically Apache becomes the owner. The support guy suggested that under these conditions perhaps changing ownership after uploading could damage the files.
Hope this extra info helps solving the problem.
Paul
Reply With Quote
  #6  
Old 04-06-2010, 07:55 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,922

That's when the chown function posted above would come in handy. That way right after upload you can give yourself ownership of the file.
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #7  
Old 04-13-2010, 03:34 AM
paulus is offline paulus
Registered User

Join Date: Apr 2010
Posts: 5

Hi Scott,
I've been abroad for a few days so I wasn't able to check immediately chown.
Well, it works fine now.
Thanks for your kind and professional help.
Paul
Reply With Quote
Reply


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

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
JO: AW v1.0 - v1.1 Update Released! J-Factor News 0 12-03-2007 02:14 PM
Photoshop settings and pc settings? Roshi Sigs and Graphics 9 03-04-2007 01:05 PM
i chmod it werewolf phphq.Net Forums 2 11-13-2005 07:39 AM
Uploader Chmod Death Sentinals phphq.Net Forums 3 01-26-2005 01:00 AM
Chmod Df2Aus Feedback / Novahq.net Support 1 03-06-2002 01:33 AM


All times are GMT -5. The time now is 10:48 PM.




Powered by vBulletin®