Search the Community
Showing results for tags 'obfuscate'.
-
I have a wordpress site. I found this plugin which searches the page once wordpress has spit it out and obfuscates all emails it can find. I'm a noob, so bear with me here. This is the code: <?php /* Plugin Name: Make Safe Plugin URI: http://wordpress.org/extend/plugins/makesafe Description: Obfuscates email addresses. Version: 1.0 Author: Loud Dog Author URI: http://www.louddog.com */ if (!class_exists("LoudDog_MakeSafe")) { class LoudDog_MakeSafe { function __construct() { if (is_admin()) return; add_action('init', array($this, 'start'), 10); } function start() { ob_start(array($this, 'filter')); } function filter($content) { preg_match_all('/<a.*href="(mailto:.*?)".*?>(.*?)<\/a>/', $content, $matches); for ($ndx = 0; $ndx < count($matches[0]); $ndx++) { $email = ''; foreach(str_split($matches[1][$ndx]) as $chr) { $email .= rand(0,1) ? $chr : "".ord($chr).";"; } $text = ''; foreach(str_split($matches[2][$ndx]) as $chr) { $text .= rand(0,1) ? $chr : "".ord($chr).";"; } $code = str_split("<a href='$email'>$text</a>", 7); $code = "document.write(\"".implode('"+"', $code)."\");"; $code = str_split($code); $code = array_map('ord', $code); $code = array_map('dechex', $code); $code = "\x".implode("\x", $code); $code = "<script type='text/javascript'>"."eval(unescape('$code'));"."</script>"; $content = str_replace($matches[0][$ndx], $code, $content); } return $content; } } new LoudDog_MakeSafe(); } What I'm hoping is able to be done is have this search for a specific text instead. I have another plugin that spits out the url to mp3 files. I'd like to obfuscate any url ending with a ".mp3" in it. Mind you, the plugin doesn't actually post links, as in "<a href>" tags. I'm trying to prevent folks from finding the location to the mp3 file by viewing the source code. I'd just like to have those urls obfuscated. If that's too difficult, I'd settle for obfuscating anything that contains "http://www.mydomain.com/folder" in it. Is this something that PHP is able to do? Can the above code be modified simply to achieve this? If not, any suggestions are welcome! Thank you. ~Quest~