Protect Content Function

Hi everyone
Last night I wrote a function to protect content of my site
For whoever has a site and wants to use my function here is the function
* I used simple_html_dom class in this function, you can download it here Simple html DOM

function protect_images($text, $protect_images = true, $protect_text = true){
require("simple_html_dom.php");
$html = str_get_html($text);
$image_original = array();
$image_protected = array();
if ($protect_images)
foreach($html->find('img') as $element){
$src = $element->src;
$width = $element->width;
$width_p = $width + 2;
$height = $element->height;
$height_p = $height + 2;
$element->outertext = '

';
}
if ($protect_text)
return '

'.$html.'

';
else
return $html;
}
}

Advertisements

, , , ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: