Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Fix How? Fontpress Wordpress Plugin Error "Warning: file_get_contents(C:./..) failed to open stream: Permission denied" on Win7 64 XAMPP 1.8.1 WP 3.5

Warning: file_get_contents(C:\Git\HG\xampp\htdocs\wordpress/wp-content/plugins/fontpress/cufon/..): 
failed to open stream: Permission denied in 
C:\Git\HG\xampp\htdocs\wordpress\wp-content\plugins\fontpress\functions.php on line 9

I am guessing this is due to some PHP related limited Ability or Permission issue on Windows 7 with XAMPP Windows W AMP/ LAMP Stack.

  • I've read about similar issues where permission needed to be changed 775 etc.
    • But, this is Windows 7 x64 with XAMPP 1.8.1 running Wordpress 3.5 Multi-Site Network.
  • What kind of permissions changes are needed?
    • Tried all kinds of permission fixes suggested in the comments below.
  • Would installing the plugin by uploading the ZIP file work/ apply right permissions?
    • Tried this out as well
  • A comment by someone on another thread somewhere about XAMP linked to this ticket

    XAMPP has an annoying issue working with WP Cron and fopen()
    

UPDATES:

Another thing I noticed is that there is a mix of both, forward "/" and backward "\" slashes in the path being accessed by

file_get_contents(C:\Git\HG\xampp\htdocs\wordpress/wp-content/plugins/fontpress/cufon/..) 

I hope that's not the cause, for this thing to fire up.

Some interesting updates and insights:

  • I added the suggested PHP code if (!is_dir($font_file)) { /*lines 9-11*/ } to wrap those lines using file-get-contents and it got fixed
  • Now I seem to have found another file-get-contents somewhere else causing another similar issue
  • Some additional information on issues PHP file-get-contents has on Windows:

andre-s at home dot nl - 1 year ago

If you are getting a failed to open stream message on your Windows machine check your HOSTS file.

127.0.0.1 localhost

must be in it and the IP6 line must be commented

# ::1 localhost

Here's a snippet of the PHP Code:

// get all the cufons from a folder
function fp_cufon_list() {
    $fonts = array();
    $cufon_list = scandir(FP_DIR."/cufon");

    foreach($cufon_list as $font_file){
        $file_content = file_get_contents(FP_DIR."/cufon/".$font_file); // <- Line No: 9
        if(preg_match('/font-family":"(.*?)"/i',$file_content,$match)){
            $fonts[$match[1]] = basename($font_file);
        }
    }
    return $fonts;
}

Sanitized Folder Tree for "Fontpress" Plugin (to give some idea of Structure):

+---classes
+---css
|   \---ui-wp-theme
|       \---images
+---cufon
|       Candela_Bold_400.font.js
|       ChunkFive_400.font.js
|       Colaborate-Medium_400.font.js
|       Daniel_400.font.js
|       Imperator_400.font.js
|       Luna_400.font.js
|       PT_Sans_Narrow_400.font.js
|       Quicksand_Light_300.font.js
|       Segan_300.font.js
|       tree.txt
|       Vegur_400.font.js
|       
+---fonts
|   +---Bebas_Neue_Regular
|   |       bebasneue-webfont.eot
|   |       bebasneue-webfont.svg
|   |       bebasneue-webfont.ttf
|   |       bebasneue-webfont.woff
|   |       
|   +---Blokletters_Balpen_Balpen
|   +---Capture_it_Regular
|   +---Chelsea_Regular
|   +---Cicle_Gordita
|   +---Colaborate_Thin_Regular
|   +---Fearless_Regular
|   +---GoodDog_Regular
|   +---Journal_Regular
|   +---Ubuntu_Title_Title
|   \---Walkway_SemiBold_Regular
+---img
+---js
|   +---colorpicker
|   |   +---images
|   |   \---js
|   \---iphone_checkbox
|       \---images
|           +---ios-style-checkboxes
|           \---iphone-style-checkboxes
\---temp

Thoughts/ Suggestions?

What can I do to fix this in terms of Permissions or PHP Code?

share|improve this question
Close-voted as off-topic. This is a PHP/Server configuration question, not a WordPress-specific question. – Chip Bennett Jan 29 at 13:28

closed as off topic by Chip Bennett, s_ha_dum, toscho Jan 29 at 14:38

Questions on WordPress Answers are expected to relate to WordPress within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

Assuming you're not using this machine for anything but local dev work, browse to the file or folder in question in Windows Explorer, right click on the file and choose "Properties" and browse to the "Security" tab and make sure that "SYSTEM" and "Everyone" have all permissions on this file and/or folder. You will need to be running Windows Explorer as an administrator.

share|improve this answer
I did this and it's still giving the same error. I've checked it twice for the Folder and there seems to be no change. – Alex S Jan 24 at 21:55
I did a little bit of digging. It looks like they are trying to use file_get_contents() on a directory, which is allowed under Unix, but not Windows. FontPress is a premium plugin. You should open a ticket on their support site – cpilko Jan 24 at 22:21
cpilko - Thank you. I've posted a ticket with them. I'll post back when I have a response or resolution from their end. – Alex S Jan 25 at 9:56
This is the response they posted back - You need to set your local server to allow the files management. Now it is blocking the file_get_contents function. - Is there a realistic way to go about doing this or will this method file_get_contents() have to be replaced/ rewritten. – Alex S Jan 25 at 21:15
Visit http://localhost/xampp/phpinfo.php in your browser and search for allow_url_fopen. This should show "On". If it does, you're server is allowing file management. Tell them to try again. If not, open the Loaded Configuration File (usually \xampp\php\php.ini), and find the line that starts allow_url_fopen and make sure it says allow_url_fopen = On. Save this file, restart Apache and retest. – cpilko Jan 25 at 21:37
show 10 more comments

Not the answer you're looking for? Browse other questions tagged or ask your own question.