WordPress.org

Ready to get started?Download WordPress

Forums

Motivation Generator
[resolved] File access error (8 posts)

  1. TStone
    Member
    Posted 8 months ago #

    This plugin doesn't work, and it seems it has to do with the usage of getimagesize in the code which (I think) is dependent on "allow_url_fopen" beeing enabled, and on many shared hostings it is disabled for security reasons.

    In the admin settings, it show two errors in red:
    "File wp-content/plugins/motivation-generator/fonts/FreeSerif.ttf not found."
    and
    "/wp-content/uploads/posters/ Can not be created. Please check your file permissions."

    http://wordpress.org/plugins/motivation-generator/

  2. stepan1010
    Member
    Plugin Author

    Posted 7 months ago #

    Hey, TStone. Sorry for the late answer :)

    If you see two errors in red in the admin settings, that's most likely has to do with your file permissions. The first error (about the font) comes up if "file_exists" returns false and the second error comes up if "mkdir" returns false. It takes paths, not urls as arguments in both of these functions, so "allow_url_fopen" isn't the case here.

    What's interesting is the first error (about the font being not found). I use "plugin_dir_path" to determine the location of the plugin, so any custom names of "wp-content" shouldn't be the problem either.

    Could you please make sure you are allowed to create files and folders on your hosting? In case you are, please try reinstalling the plugin by removing it completely and downloading it again from wordpress.org.

    Thanks
    Stepan

  3. TStone
    Member
    Posted 7 months ago #

    The file permissions are fine.

    Whether the file paths are correct or not does not change the fact that you have getimagesize in the code. Which often is disabled because it is a security risk since it can be used for code injections. Even if everything else were perfect, there is no way that this plugin can function when "allow_url_fopen" is disabled.

    For it to function, getimagesize need to be replaced with a cURL solution. There's tons of examples on the net on how this is done. Two randomly chosen examples:
    http://roldanarts.com/2009/11/18/diego-roldan/blog/curl-vs-getimagesize-vs-filegetcontents
    http://goffgrafix.com/blog/index.php/2010/04/if-your-server-sets-the-allow_url_fopen-and-allow_url_include-php-directives-off/

  4. stepan1010
    Member
    Plugin Author

    Posted 7 months ago #

    Even if everything else were perfect, there is no way that this plugin can function when "allow_url_fopen" is disabled.

    That is true if (and only if) you pass a url as a parameter to getimagesize. All the examples you mentioned are talking about remote files, not the ones that are already on your server.

    Here is an example. The code below will work no matter what allow_url_fopen is set to:

    $arr = getimagesize("/var/www/testing/face.png");
    var_dump($arr);

    However, the following code will return false in case allow_url_fopen is disabled:

    $arr = getimagesize("http://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Strobel-bautista_crop_left.jpg/546px-Strobel-bautista_crop_left.jpg");
    
    var_dump($arr);
  5. TStone
    Member
    Posted 7 months ago #

    Well, you are probably right.
    Still, there is something that prevent your plugin from working, and it's not file permissions.
    http://file.tomstone.se/motivationgen.jpg

  6. stepan1010
    Member
    Plugin Author

    Posted 7 months ago #

    Thanks for the screenshot! Turns out there was an error when default directories were set so the plugin was looking for files and folders in wrong places. I've just committed the changes which fix it.

    Please remove the plugin completely through "Settings" -> "Plugins" and install it again. Make sure that you are installing version 1.3.6.

  7. TStone
    Member
    Posted 7 months ago #

    Now it works! :)

    Thank you!

  8. stepan1010
    Member
    Plugin Author

    Posted 7 months ago #

    Thank you for the feedback :)

Reply

You must log in to post.

About this Plugin

About this Topic