views:

20

answers:

1

I am using thesis theme on my wordpress blog. I am hosting my blog at byethost which has allow_url_fopen=Off and allow_url_include=Off

In one of the function, code is trying to read an image url path. From what I understand, if fopen is ON, it will execute "if" case otherwise "else" case

  if ($thesis_design->image['fopen'])
     $image_path = $post_image['url'];
  else {
     $local_path = explode($_SERVER['SERVER_NAME'], $post_image['url']);
     $image_path = $_SERVER['DOCUMENT_ROOT'] . $local_path[1];
  }

With this code, it is not able to grab the image if I provide absolute path (i.e. http://brijux.com/images/example.jpg) but it can grab image with relative path (i.e images/example.jpg)

But if I comment out "if" case and use only the "else" case, it can grab image with the absolute path.

So my question is,

  1. if allow_url_fopen=Off, shouldn't it only execute the "else" part?
  2. how does it grab image file if I am only providing relative path in the "if" case?
A: 

If you use fopen and provide a relative path it treats the image as a local file. If you provide the 'absolute' path i.e. the URL then it goes through the loopback interface and grabs it like it's on the web.

akellehe
I am new to PHP so please bare with me. what does "$thesis_design->image['fopen']" check for the condition? What does it do if my host does not support fopen?
John Connor
I'm not sure what it would do. I'm not familiar with your object. You can use some print statements to learn a little bit more about it, though. Try: var_dump($thesis_design); to see what all is in there.
akellehe
It looks like $thesis_design->image['fopen'] is simply an array value that COULD be set elsewhere in the code. It is not guaranteed to be a check for the server capabilities. See if you can find in the code where the image array is generated.
mwotton