Hi, thank you for this wonderful project.

On servers that disable allow_url_fopen for security reasons (in my case, DreamHost), we need an alternative to the get_headers() function call, which reports:

# warning: get_headers() [function.get-headers]: URL file-access is disabled in the server configuration in /modules/private_upload/private_upload.module on line 130.
# warning: get_headers() [function.get-headers]: This function may only be used against URLs. in modules/private_upload/private_upload.module on line 130

It seems that uploaded files don't get uploaded into the private directory in this instance, they remain in the public directory.

Thanks for any help you can provide.

Peace

CommentFileSizeAuthor
#4 private_upload.patch2.54 KBiokevins

Comments

iokevins’s picture

It's probably obvious but the actual line number is 129 due to a debugging line I threw into the file.

iokevins’s picture

Assigned: Unassigned » iokevins

Here's a patch that resolves the failing call to get_headers(). I implement a new function, private_upload_is_publicly_accessible($url) which uses cURL to test the 200 & 302 HEAD status codes.

Here's the driver code I used to test:

// test
$url_array[0]="http://lalalala.com/aosenuthasonetuh"; // fail
$url_array[1]="http://yourwebsite.com/files/favicon.ico"; // succeed

foreach ($url_array as $value) {
  echo "Processing $value\n";
  $result = private_upload_is_publicly_accessible($value) ? 1 : 0;
  print "result is $result\n";
}

Peace

UPDATE: See below for latest patch.

iokevins’s picture

Status: Active » Needs review
iokevins’s picture

StatusFileSize
new2.54 KB

Bug fixes in the latest patch:

1) Status codes now recorded properly as strings and not integers
2) While(!feof($fp)) loop removed since comparing against headers other than the very first one might lead to incorrect results. It's also efficient.

Peace

starbow’s picture

Assigned: iokevins » Unassigned
Status: Needs review » Fixed

This is very cool work, and should help out the PHP4 folk, as well those on Dreamhost. Why do you call is cURL though? It doesn't use the libCurl library.

I am going to change around the logic a little bit, but I will incorporate your patch into the next beta.

thanks!

iokevins’s picture

Hi starbow,

You're welcome.

Honestly, I regret the confusion above (and in the patch) between the libCurl and PHP implementation. This represents my first foray into this functionality and the documentation represents my own confusion. I appreciate you letting me know it wasn't cURL--aside from minor embarrassment I've corrected a mistaken assumption.

Peace

starbow’s picture

Hi Schultkl,

Actually, I don't know much about curl one way or the other. I was just asking.

thanks again.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.