News:

Wondering if this will always be free?  See why free is better.

Main Menu

Image Host Whitelist

Started by Juo, July 24, 2009, 05:06:11 PM

Previous topic - Next topic

Juo

I was wondering if there is a way to check posts when members try and make them for services they have used within [img] hosting tags, im pretty sick of my members hotlinking files from over peoples websites and wanted to create a whitelist of admin approved image hosting services? this would be images.mydomain.com

Is this possible?

Thanks :)

Arantor

#1
If it's a fixed domain that isn't going to change, it would be possible to modify the img tag to only handle such URLs, and not embed pictures from other domains.

In fact, let's do just that.

In Sources/Subs.php, find:

array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<img src="$1" alt="{alt}"{width}{height} class="bbc_img" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),
array(
'tag' => 'img',
'type' => 'unparsed_content',
'content' => '<img src="$1" alt="" class="bbc_img" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),


Replace it with, making sure to change http://intranet to the domain of your choice.


array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<img src="$1" alt="{alt}"{width}{height} class="bbc_img" />',
'validate' => create_function('&$tag, &$data, $disabled', '
$data = strtr($data, array(\'<br />\' => \'\'));
$domain = "http://intranet/";
if(substr($data, 0, strlen($domain)) != $domain) {
$tag[\'content\'] = \'$1\';
}
'),
'disabled_content' => '($1)',
),
array(
'tag' => 'img',
'type' => 'unparsed_content',
'content' => '<img src="$1" alt="" class="bbc_img" />',
'validate' => create_function('&$tag, &$data, $disabled', '
$data = strtr($data, array(\'<br />\' => \'\'));
$domain = "http://intranet/";
if(substr($data, 0, strlen($domain)) != $domain) {
$tag[\'content\'] = \'$1\';
}
'),
'disabled_content' => '($1)',
),


For img links on http://intranet they will be converted to images, but for any other domain - it just leaves the URL in its place. The instructions are for 2.0 but it should be virtually the same on 1.1 though I haven't checked or tried it.

EDIT: I have made a more powerful version into a mod that lets you specify multiple domains, plus paths, and this is on the mod site waiting to be approved. When it is approved it will be available from here.
Holder of controversial views, all of which my own.


Juo

wow that's insane, not only a fix but a modification thanks so much Arantor you have no idea how much I appreciate this :)

Arantor

No worries - the mod isn't approved yet but it's done ready for then.
Holder of controversial views, all of which my own.


Juo

Now using this on my forum and its excellent thanks so much :D
Topic Solved!

Advertisement: