开发者

PHP image grab when allow_url_fopen=off

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 e开发者_Go百科xecute "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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜