WordPress.org

Ready to get started?Download WordPress

Forums

Imaguard
PHP 5.4 (13 posts)

  1. daveszt
    Member
    Posted 1 year ago #

    Hi Guys,

    Firstly, thanks for this wonderful plugin which has solved the recent Google images upgrade for us. I have 2 questions however:

    1) Our server is hosted with 1&1 who are currently in the process of upgrading to PHP 5.4. When we add the line AddHandler x-mapp-php6 .php in to our .htaccess file, it breaks your plugin. Is there a way we can solve this having both that line of code in and having your plugin working?

    2) We have various systems that pull in images from HeyUGuys like Facebook and Pinterest. I've tried adding what looks like their image CDN to the whitelist but the 'click to view' still appears. Is there a way round this and can you use wildcards in there? e.g. assets*.pinimg.com

    Facebook example is here: https://www.facebook.com/heyuguys and the site in question on which I run is http://www.heyuguys.co.uk.

    Thanks again.

    Dave

    http://wordpress.org/extend/plugins/imaguard/

  2. imaguard
    Member
    Plugin Author

    Posted 1 year ago #

    Hi there!

    Re question 1: Could you either post some more details or send us an email with the exact htaccess and the error messages received? I will look into it to see if we can solve it.

    Re question 2: You should find referrer details in your log files. Test by adding an image and see what hits you get in the logs and just whitelist those.

    We are considering adding the option to blacklist instead of whitelist to the next version. Meanwhile you can easily reverse the whitelist to a blacklist in your .htaccess file in WP root folder. Simply remove the ! indicating "not". This is what you should have now:

    # BEGIN imaguard
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yoursite\.com [NC]
    RewriteRule ^(.*)\.(jpg|png|jpeg|gif)$ /show-image/?img=/$1.$2 [R=301,NC,L]
    # END imaguard

    Here yoursite is being whitelisted (it's saying on condition NOT yoursite, then rewrite and enable Imaguard. Just change it to:

    # BEGIN imaguard
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?badsite\.com [NC]
    RewriteRule ^(.*)\.(jpg|png|jpeg|gif)$ /show-image/?img=/$1.$2 [R=301,NC,L]
    # END imaguard

    And you have reversed it to On condiotion badsite then activate Imaguard.

    Just remember that if you update Imaguard (settings or version) it will overwrite your changes, so keep a backup of your htaccessfile.

    Hope this helped!

  3. daveszt
    Member
    Posted 1 year ago #

    Awesome, thanks.

    So all I add to .htaccess for question one is the line:

    AddHandler x-mapp-php6 .php

    This then causes all images with overlay to have the error:

    The Image Cannot Be Displayed, http://XXXX.jpg Because It Contains Errors.

  4. daveszt
    Member
    Posted 1 year ago #

    p.s. just having a play with the code above and am struggling to get it working, mainly because this might as well be Greek to me! But if the domain i want the images to have the overlay on is: http://images.google.com, what would the code above be?

    D

  5. imaguard
    Member
    Plugin Author

    Posted 1 year ago #

    Are you logged into google when testing? Google has recently started sending empty referers more and more often when someone is logged in to google. Another reason to use a whitelist instead of a blacklist.

    You can of course block empty referrers but that may cause problems with search engines crawling your site. As an experiment, try:

    # BEGIN imaguard
    RewriteEngine on
    RewriteCond %{HTTP_USER_AGENT} ^-?$
    RewriteCond %{HTTP_REFERER} ^https?://(.+\.)?google\.com [NC]
    RewriteRule ^(.*)\.(jpg|png|jpeg|gif)$ /show-image/?img=/$1.$2 [R=301,NC,L]
    # END imaguard

    Might as I said cause crawler issues, but worth testing it out to see if you can get it to work.

    If you have cPanel installed, you can usually click on "latest visitors" test to open an image via google and check what referrer is set (you don't need cpanel to do this, but it has an easy link and then you just click refresh after the test to see what referrer was set.

  6. daveszt
    Member
    Posted 1 year ago #

    I think the main problem I have is that I want some subdomains to work and others not to.

    e.g. I want images.google.com to display the overlay, but mail.google.com not to. At the moment if you add a subdomain, it'll include the main domain in the .htaccess file e.g. google.com which encompasses all of Google's subdomains.

    D

  7. imaguard
    Member
    Plugin Author

    Posted 1 year ago #

    Hi again,

    Something like

    http(s)?://(.+\.)?google\.com

    would match http://google.com, http://www.google.com, https://google.com and https://www.google.com. If you just want it to match specific subdomains, simply type the entire domain:

    http(s)?://images\.google\.com

    This would match https://images.google.com and http://images.google.com.

    For more referrer domains, simply add more lines:

    # BEGIN imaguard
    RewriteEngine on
    RewriteCond %{HTTP_USER_AGENT} ^-?$
    RewriteCond %{HTTP_REFERER} ^http(s)?://images\.google\.com [NC]
    RewriteCond %{HTTP_REFERER} ^http(s)?://groups\.google\.com [NC]
    RewriteRule ^(.*)\.(jpg|png|jpeg|gif)$ /show-image/?img=/$1.$2 [R=301,NC,L]
    # END imaguard

    However, as I said Google is cheating more and more by simply sending an empty referrer. To catch those you must use ^-?$:

    # BEGIN imaguard
    RewriteEngine on
    RewriteCond %{HTTP_USER_AGENT} ^-?$
    RewriteCond %{HTTP_REFERER} ^http(s)?://images\.google\.com [NC]
    RewriteCond %{HTTP_REFERER} ^http(s)?://groups\.google\.com [NC]
    RewriteCond %{HTTP_REFERER} ^-?$ [NC]
    RewriteRule ^(.*)\.(jpg|png|jpeg|gif)$ /show-image/?img=/$1.$2 [R=301,NC,L]
    # END imaguard

    But as I said, this may impact how your site is crawled.

  8. imaguard
    Member
    Plugin Author

    Posted 1 year ago #

    Forgot to comment re php 5.4. Could you confirm that your host has bundles the GD lib with the php 5.4 install? It's required by Imaguard.

  9. daveszt
    Member
    Posted 1 year ago #

    Thanks again for all your help on this.

    I don't know about the GD lib. Host is 1&1 if that helps. They're pretty darn useless!!

  10. imaguard
    Member
    Plugin Author

    Posted 1 year ago #

    They don't have any info on the GD lib with php 5.4. What you can do is to create a new php file and just put this in it:

    <?php phpinfo (); ?>

    Is you save that as f ex yourdomain.com/test.php it will show you a list of installed libraries when you run it. You should have a section called GD and under that an entry called GD Version.

  11. daveszt
    Member
    Posted 1 year ago #

    This is what I get:

    gd
    GD Support 	enabled
    GD Version 	bundled (2.0.34 compatible)
    FreeType Support 	enabled
    FreeType Linkage 	with freetype
    FreeType Version 	2.4.2
    GIF Read Support 	enabled
    GIF Create Support 	enabled
    JPG Support 	enabled
    PNG Support 	enabled
    WBMP Support 	enabled
    XBM Support 	enabled
  12. imaguard
    Member
    Plugin Author

    Posted 1 year ago #

    Ok, that's not the issue then.

    When you have time you can try to stick the line

    error_reporting(E_ALL);

    into wp-content/plugins/imaguard/index.php in ir_detectpost function like this:

    function ir_detectpost($posts) {
    	error_reporting(E_ALL);
    
    	global $wp;
    	global $wp_query;

    Hopefully it will show a php error when you try to open the image again - not just the general "contains errors" error.

  13. daveszt
    Member
    Posted 1 year ago #

    OK, tried that and it brings up dozens of errors across the site but when I try the ?test it still comes up with that same error. I've had to turn it off for now as this is the live site we're playing with.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags