#104 new
kodap

Cache alternative hack to file_get_contents

Reported by kodap | August 29th, 2008 @ 09:49 PM

I noticed some people have problems (as I did) to sucessfully cache the images because some servers (including Dreamhost) have disabled "allow_url_fopen" option, and so it doesn't allow cache of images to store them on your own server. To use CURL function instead as file_get_contents, replace the line (around line 775):

$contents = @file_get_contents($url);

with this:

$ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $contents = curl_exec($ch); curl_close($ch); ?

And images will start being cached on on your server (if you create and Chmod your cache folder to 777)!

Comments and changes to this ticket

  • Guillermo Rauch

    Guillermo Rauch August 29th, 2008 @ 11:25 PM

    Thanks for the heads up. I'll be reviewing this situation and potentially including the patch.

  • Mark

    Mark August 30th, 2008 @ 03:56 AM

    Perfect!

    Thanks for this, even though it's still in RC stages it really is a superb tool.

    MeG

  • Mark

    Mark August 30th, 2008 @ 04:03 AM

    Just a side note from forums I have been reading:

    "phpBB forums are now the new target for the hackers... many phpBB based sites are being defaced in these days.

    Most of the problems are related to REGISTER_GLOBALS, but today I've discovered a new issue.

    One site has being hacked trough the CACHE folder which has 777 permissions... so a file has been modified in there and the site defaced.

    I suggest to put HTACCESS in your CACHE folder and try to set 775 as CHMOD for both CACHE and files in there...

    Everything should continue to work, but your files should be protected from this kind of attacks. If you're having problems after changing CHMOD put everything back to 777. "

  • Mark

    Mark August 30th, 2008 @ 04:09 AM

    Having posted that, I don't think you can do much about it as the reader won't be able to access if a htaccess file is placed in the folder.

  • kodap

    kodap August 30th, 2008 @ 05:55 AM

    Note that saying "hack" wasn't meant to refer at the actions of hackers, it's a "do-it-yourself hack" to modify scripts. It's commonly misinterpreted these days on the programming community. anyway, thanks for concerning

  • Mark

    Mark August 30th, 2008 @ 08:24 AM

    No don't worry, although I know nohing about programming I do know the terms. And I did not misunderstand your meaning! :)

  • Mark

    Mark August 30th, 2008 @ 08:28 AM

    Also, thanks for sharing this "hack", I wish I'd have taken the time to learn php. I know little about it. Action scripting is about the only code I know other than xml/html.

  • kodap

    kodap August 30th, 2008 @ 01:20 PM

    I know Nothing about php, just the basics... I found this fix here: http://wiki.dreamhost.com/index.... and just changed the things i found proper...

    Thanks!

  • Ricardo Rauch

    Ricardo Rauch April 15th, 2010 @ 08:50 AM

    • Assigned user changed from “Guillermo Rauch” to “Ricardo Rauch”

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

WP-o-Matic project.

People watching this ticket

Pages