Support » Plugin: Cloudflare » [Plugin: CloudFlare] Newest version (1.3.0) of plugin gives error

  • I’ve run the Cloudflare plugin for a long time, but when I updated to the newest version (1.3.0), I got the following error, which displayed at the top of my site:

    Warning: file_put_contents(ipv4_list.txt) [function.file-put-contents]: failed to open stream: Permission denied in /home/livmommy/public_html/wp-content/plugins/cloudflare/cloudflare.php on line 62

    Obviously, I uninstalled this version and tried going back to the previous one, but I didn’t see it listed in the previous versions section of WordPress, so I’ve uninstalled it until there is a fix.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Same here. This is due to writing permissions on your (and mine) ISP, as the folder the plugins is trying to write the file with the list of CloudFlare IPs isn’t allowed by server. I fixed mine by changing a few lines in the “cloudflare.php” file so that it writes and reads from a place WordPress is allowed to, namely, the temp folder. Here’s the fix:

    Open cloudflare.php, and look at lines 47, 48 and 62. In the three, where it says "ipv4_list.txt", change it to get_temp_dir().'ipv4_list.txt', so that the end result looks like this:

    Line 47: $ipv4_file_data = @file_get_contents(get_temp_dir().'ipv4_list.txt');
    Line 48: $last_modified = @filemtime(get_temp_dir().'ipv4_list.txt');
    Line 62: file_put_contents(get_temp_dir().'ipv4_list.txt', $live_ips_v4_list);

    For those who know how to use patch, here’s a slightly improved diff of the above fix:

    diff -pu cloudflare.php.orig cloudflare.php
    --- cloudflare.php.orig 2012-05-12 11:07:42.506415000 +0000
    +++ cloudflare.php      2012-05-12 11:34:13.962826950 +0000
    @@ -43,9 +43,10 @@ function cloudflare_init() {
         // Let's get the IPs from the official cloudflare IPv4 list URL, which has the latest up to date list.
         $request_file_refresh = FALSE;
    +    $ipv4_list_file = get_temp_dir() . 'ipv4_list.txt';
    -    $ipv4_file_data = @file_get_contents("ipv4_list.txt");
    -    $last_modified = @filemtime("ipv4_list.txt");
    +    $ipv4_file_data = @file_get_contents($ipv4_list_file);
    +    $last_modified = @filemtime($ipv4_list_file);
         if ($last_modified === FALSE) {
             $request_file_refresh = TRUE;
         } else {
    @@ -59,7 +60,7 @@ function cloudflare_init() {
             $live_ips_v4_list = @file_get_contents("");
             if ($live_ips_v4_list !== FALSE && trim($live_ips_v4_list) != "") {
    -            file_put_contents("ipv4_list.txt", $live_ips_v4_list);
    +            file_put_contents($ipv4_list_file, $live_ips_v4_list);
                 $cf_ip_ranges = explode("\n", $live_ips_v4_list);
             } else {
                 // Use the default static list for now, until we are able to access the live updated list again.

    I believe once the CloudFlare guys read this they’ll release in short time a fixed 1.3.1 version.

    By the way: in some ISPs file system performance is worse than database performance. So, I’d like it if this plugins wrote the IPs to the database rather than to a text file. Also, what about 🙂

    Wow! Great fix Alexander! Thanks so much for the speedy help! 🙂

    Thanks, Alexander! You rock!

    Our engineer pushed a fix for this. If you’re still having issues for some reason, however, removing and then re-installing the plugin should also work.

    Thanks for the reports!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: CloudFlare] Newest version (1.3.0) of plugin gives error’ is closed to new replies.