vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   Mini Mods - IMG Cacher - SSL Keeper - Mixed Content Block Solution (https://vborg.vbsupport.ru/showthread.php?t=288060)

MegaManSec 09-19-2012 10:00 PM

IMG Cacher - SSL Keeper - Mixed Content Block Solution
 
1 Attachment(s)
Pretty much you use this when you want to keep the SSL certificete working on pages that people may use [IMG] tag's without https://.

When you use SSL on your forum, and somebody embeds an image from a non-ssl host, lots of browsers will give you a warning and say the website is unsafe ---this is a solution to that problem.

Specifically, Mozilla has a 'Mixed Content Blocker', which makes it so if you are on an https:// website, it won't load any content on the same domain, using http://.



NOTE: MAKE SURE THE .HTACCESS FILE IN cache-img/ IS WORKING!



Upload the files into your root directory, and that's it.

Then you need to create a plugin (admincp -> plugins & products -> add new plugin)
Hook location: bbcode_img_match
Title: SSL IMG Cacher
Execution order: 5
Plugin PHP Code:
Code:

$link_parsed = parse_url($link);
if ($link_parsed['host'] != '[LINK_TO_YOUR_WEBSITE]')
{
 $link = $this->registry->options['bburl'] . '/cache.php?img=' . urlencode($link);
 $retval = ($fullsize ? '<div class="size_fullsize">' : '')  . '<img src="' .  $link . '" border="0" alt="" />' . ($fullsize ? '</div>' : '');
}

Plugin is active: Yes


edit "[LINK_TO_YOUR_WEBSITE]" - Without http, example: www.dragonbyte-tech.com or www.internot.info etc. etc.

Then you are done.

It should be secure as the actual directory for the images is not available.(deny from all in htaccess)


I would also suggest adding this to robots.txt
Code:

User-agent: *
Disallow: /cache.php

Also I suggest you add something like this to .htaccess:
Code:

<FilesMatch "cache\.php$">
Header set Cache-Control "max-age=86400, public"
</FilesMatch>

======
I only give support to people who have pressed 'installed' this.
======


Source&stuff can be found here: https://github.com/MegaManSec/IMG

For vB3.8 solution, go here: https://vborg.vbsupport.ru/showthrea...75#post2411575 (Thanks to Kh99)

sivaganeshk 09-23-2012 05:44 AM

Quote:

When you use SSL on your forum, and somebody embeds an image from a non-ssl host, lots of browsers will give you a warning and say the website is unsafe(which is untrue) - this is a solution to that problem.
Thanks.
Is there a similar solution to loads adsense in SSL forum without any warning?

MegaManSec 09-23-2012 07:18 AM

Quote:

Originally Posted by sivaganeshk (Post 2367819)
Thanks.
Is there a similar solution to loads adsense in SSL forum without any warning?

I'll give you an example of how to do it.

This is mine:
Code:

<script type="text/javascript"><!--
google_ad_client = "ca-pub-8761986403507850";
/* bugabuse */
google_ad_slot = "9327213821";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

edit this part:
Code:

src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
and make it https:// :p

DoDe 09-23-2012 07:36 AM

The embedded image appears in the cache_img directory but it doesn't appear in the posted thread. How to make it appear there?

MegaManSec 09-23-2012 07:41 AM

Quote:

Originally Posted by DoDe (Post 2367831)
The embedded image appears in the cache_img directory but it doesn't appear in the posted thread. How to make it appear there?

Code:

Then you need to create a plugin (admincp -> plugins & products -> add new plugin)
Hook location: bbcode_img_match
Title: SSL IMG Cacher
Execution order: 5
Plugin PHP Code:

this part. if you've already done that and it doesn't work, PM me some credentials for me to login to your forum (and a link to the forum) and I'll have a look.

sivaganeshk 09-23-2012 07:44 AM

Quote:

Originally Posted by loaep (Post 2367828)
I'll give you an example of how to do it.

This is mine:
Code:

<script type="text/javascript"><!--
google_ad_client = "ca-pub-8761986403507850";
/* bugabuse */
google_ad_slot = "9327213821";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

edit this part:
Code:

src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
and make it https:// :p

LoL. but editing the adsense code may lead to account ban. I searched about it few months ago.. :erm:

MegaManSec 09-23-2012 07:47 AM

Quote:

Originally Posted by sivaganeshk (Post 2367833)
LoL. but editing the adsense code may lead to account ban. I searched about it few months ago.. :erm:

replacing http with https will not cause a ban.

MegaManSec 09-23-2012 08:14 AM

Please re-download the modification. I forgot to update a part of the code for it to actually work.

Once you've re-downloaded it, it will work.

DoDe 09-23-2012 08:20 AM

Ok, thanks!

Edited: It's working now,

thanks again :up: !

Dorgham 11-02-2012 01:33 AM

Great work
product has been added successfully
Thank you

LifesGreatestGift 01-19-2013 02:48 AM

This is AWESOME! :)

hakkuo23 01-19-2013 04:00 AM

Here is a version that just displays the image, and doesn't save it, to save server space :)

PHP Code:

<?php

function curlHeaderCallback($query$header){
    global 
$mime;
    if(
stripos($header"content-type")!==false){
        
header(trim($header));
    }
    return 
strlen($header); 
}

$image $_GET['img'];

$query curl_init($image);
curl_setopt($queryCURLOPT_USERAGENT"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9");
curl_setopt($queryCURLOPT_CONNECTTIMEOUT ,0);
curl_setopt($queryCURLOPT_TIMEOUT10);
curl_setopt($queryCURLOPT_HEADERFUNCTION'curlHeaderCallback'); 
curl_setopt($queryCURLOPT_RETURNTRANSFER1);
$ret curl_exec($query);
echo 
$ret;


Fluke667 03-22-2013 03:08 PM

works on vb3.8 too with this:

https://vborg.vbsupport.ru/showthrea...75#post2411575


THX to kh99

bibbaman 03-26-2013 10:20 PM

Hiya, I installed the MOD. It's not working for me at the moment, the images are not saving in the cache directory do I need to CHMOD the folders to anything different from 755?

Regards Steve

bibbaman 03-27-2013 10:34 PM

I made a silly error with the uploading the whole folder instead of the contents of the folder. Now working very well cheers.

Quote:

Originally Posted by bibbaman (Post 2412468)
Hiya, I installed the MOD. It's not working for me at the moment, the images are not saving in the cache directory do I need to CHMOD the folders to anything different from 755?

Regards Steve


MegaManSec 04-08-2013 11:15 PM

I'm bumping this topic, as Mozilla is now blocking all webpages that isn't pure HTTPS. ( https://developer.mozilla.org/en-US/...ked_by_default )

skol 04-10-2013 10:24 AM

Quote:

Originally Posted by MegaManSec (Post 2415217)
I'm bumping this topic, as Mozilla is now blocking all webpages that isn't pure HTTPS. ( https://developer.mozilla.org/en-US/...ked_by_default )


It will not block "display content" like images, videos or audio.

MegaManSec 10-30-2013 09:11 PM

Quote:

Originally Posted by skol (Post 2415501)
It will not block "display content" like images, videos or audio.

It does now!

thetechgenius 08-20-2014 11:49 PM

I can't find the hook location "bbcode_img_match", its not listed in the Hook Locations. My vB version is 4.1.4.

However, when I open "class_bbcode.php" in Notepad++, I see this:

Code:


/**
        * Handles a match of the [img] tag that will be displayed as an actual image.
        *
        * @param        string        The URL to the image.
        *
        * @return        string        HTML representation of the tag.
        */
        function handle_bbcode_img_match($link, $fullsize = false)
        {
                $link = $this->strip_smilies(str_replace('\\"', '"', $link));

                // remove double spaces -- fixes issues with wordwrap
                $link = str_replace(array('  ', '"'), '', $link);

                return  ($fullsize ? '<div class="size_fullsize">' : '')  . '<img src="' .  $link . '" border="0" alt="" />'
                        . ($fullsize ? '</div>' : '');
        }

        /**

The "handle_bbcode_match" function, what is that? Should the "bbcode_match" hook location be in vB? Or am I missing something?


Edit:
I got it working by using this method: https://vborg.vbsupport.ru/showthrea...75#post2411575 (Thanks to Kh99), and I am on 4.1.4, it works great. *INSTALLED

Cadellin 09-06-2014 01:35 PM

Has anyone worked out how to expand this mod to cover custom bbcode which embeds images?

MegaManSec 04-23-2015 02:11 PM

Quote:

Originally Posted by Cadellin (Post 2513963)
Has anyone worked out how to expand this mod to cover custom bbcode which embeds images?

Just change the bbcode to include cache.php?img=

Fields 04-24-2015 01:14 PM

Looks great, but what's the difference to this mod?

https://vborg.vbsupport.ru/showthread.php?t=253309

Will there be a conflict when I use the Import External Images mod and yours at the same time?

ifitsmedia 04-25-2015 02:03 AM

I see you are using getimagesize to verify mime type, that's great.

Are there any other security considerations when using this?

pityocamptes 05-31-2015 04:16 AM

Great mod. How would I alter the mod, to have a specific image from a website that does not support https to my site, so that I do not get mixed content? Does this mod handle ALL instances of images, including images in widgets, or just for posts? Thanks.

friendlymela 10-08-2015 08:23 AM

this is useful

Duke49th 03-30-2016 03:12 AM

Works perfect - just...I needed to set CHMOD to 777 for the cache_img folder. (755 when uploaded)

Kane@airrifle 06-25-2016 08:52 AM

Is there a way to get this mod to ignore caching a forums own urls and to only cache external images?

Dave 06-25-2016 11:44 AM

Quote:

Originally Posted by Kane@airrifle (Post 2572471)
Is there a way to get this mod to ignore caching a forums own urls and to only cache external images?

It does that already. Look at the PHP code in the post of the author.

Kane@airrifle 06-25-2016 12:25 PM

:confused:.
The cache is filled with forum album/gallery sourced images from older thread/posts where the bbcode is posted sans https, it also 404s them.

.htaccess issue maybe?

Kane@airrifle 06-26-2016 11:27 PM

Sorted out the url problem. (SQL search and replace).

But, found a new issue. Whenever a poster edits a post in WYSIWYG mode all the image urls are saved with the cacher paths rather than the original image urls.

?

RichieBoy67 12-01-2016 06:47 PM

Quote:

Originally Posted by Kane@airrifle (Post 2572537)
Sorted out the url problem. (SQL search and replace).

But, found a new issue. Whenever a poster edits a post in WYSIWYG mode all the image urls are saved with the cacher paths rather than the original image urls.

?

Is this addressed?

Kane@airrifle 12-01-2016 08:04 PM

Quote:

Originally Posted by RichieBoy67 (Post 2578997)
Is this addressed?

Did not work out for me so I went with this instead: https://vborg.vbsupport.ru/showthread.php?t=253309

tuRiver 01-02-2017 02:44 PM

Hi, any ideas?
Facebook images are not working

https://www.turiver.com/foros/cache....Boe%3D58E2D4A8

tuRiver 01-02-2017 02:53 PM

I've made a little change, to avoid caching SSLs images.
----
$link_parsed = parse_url($link);
if ($link_parsed['scheme'] != 'https')
{
$link = $this->registry->options['bburl'] . '/cache.php?img=' . urlencode($link);
$retval = ($fullsize ? '<div class="size_fullsize">' : '') . '<img src="' . $link . '" border="0" alt="" />' . ($fullsize ? '</div>' : '');
}
----

kylek 01-06-2017 05:49 PM

Quote:

Originally Posted by hakkuo23 (Post 2397833)
Here is a version that just displays the image, and doesn't save it, to save server space :)

PHP Code:

<?phpfunction curlHeaderCallback($query, $header){    global $mime;    if(stripos($header, "content-type")!==false){        header(trim($header));    }    return strlen($header); }$image = $_GET['img'];$query = curl_init($image);curl_setopt($query, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9");curl_setopt($query, CURLOPT_CONNECTTIMEOUT ,0);curl_setopt($query, CURLOPT_TIMEOUT, 10);curl_setopt($query, CURLOPT_HEADERFUNCTION, 'curlHeaderCallback'); curl_setopt($query, CURLOPT_RETURNTRANSFER, 1);$ret = curl_exec($query);echo $ret;


Really need this, can you tell us what to do with this?

Stratis 01-13-2017 09:44 AM

Uninstalled, it has effect in domain upload center... [IMG] images with the forum domain. It would be nice if it had an option of whitelist.

Any way thanks

DSemen 01-17-2017 12:34 PM

Quote:

Originally Posted by hakkuo23 (Post 2397833)
Here is a version that just displays the image, and doesn't save it, to save server space :)

PHP Code:

<?php

function curlHeaderCallback($query$header){
    global 
$mime;
    if(
stripos($header"content-type")!==false){
        
header(trim($header));
    }
    return 
strlen($header); 
}

$image $_GET['img'];

$query curl_init($image);
curl_setopt($queryCURLOPT_USERAGENT"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9");
curl_setopt($queryCURLOPT_CONNECTTIMEOUT ,0);
curl_setopt($queryCURLOPT_TIMEOUT10);
curl_setopt($queryCURLOPT_HEADERFUNCTION'curlHeaderCallback'); 
curl_setopt($queryCURLOPT_RETURNTRANSFER1);
$ret curl_exec($query);
echo 
$ret;


Please tell me how to install it correctly.

adnedarn 01-22-2017 03:58 PM

For the "[LINK_TO_YOUR_WEBSITE]" part, does it matter if I put www.terraforums.com or www.terraforums.com/forums ? I didn't do the suggested edits to .htaccess or .robots yet since my testing is showing that images are being removed (which shows the page secured) but not replaced by images saved to my server.
Thanks,
Andrew

Dave 01-22-2017 04:51 PM

Quote:

Originally Posted by adnedarn (Post 2581204)
For the "[LINK_TO_YOUR_WEBSITE]" part, does it matter if I put www.terraforums.com or www.terraforums.com/forums ? I didn't do the suggested edits to .htaccess or .robots yet since my testing is showing that images are being removed (which shows the page secured) but not replaced by images saved to my server.
Thanks,
Andrew

It would be www.terraforums.com.

adnedarn 01-24-2017 01:33 AM

Thanks Dave! Any idea why I'm just getting all the images removed? The page is secure after, but no images so that doesn't help much. :p


All times are GMT. The time now is 10:30 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01517 seconds
  • Memory Usage 1,855KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_code_printable
  • (3)bbcode_php_printable
  • (15)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete