Curl กับ safe_mode หรือ open_basedir

If you are trying to use CURLOPT_FOLLOWLOCATION and you get this warning:
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set…

then you will want to read which says “Disabled CURLOPT_FOLLOWLOCATION in curl when open_basedir or safe_mode are enabled.” as of PHP 4.4.4/5.1.5.  This is due to the fact that curl is not part of PHP and doesn’t know the values of open_basedir or safe_mode, so you could comprimise your webserver operating in safe_mode by redirecting (using header(‘Location: …’)) to “file://” urls, which curl would have gladly retrieved.


Leave a Reply

Your email address will not be published. Required fields are marked *