note 80328 deleted from function.ob-start by cmb
| From: | cmb@php.net | Date: | Sun, 05 Jan 2020 08:15:01 +0000 |
| Subject: | note 80328 deleted from function.ob-start by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213745@lists.php.net to get a copy of this message | ||
Note Submitter: dale3h
----
Here's a simple way, using register_shutdown_function, to easily maintain your global output
filter:
File: outputfilter.inc.php
<?php
initOutputFilter();
function initOutputFilter() {
ob_start('cbOutputFilter');
register_shutdown_function('ob_end_flush');
}
function cbOutputFilter($output) {
$search = array(
'user@domain.com',
'user2@domain.com',
);
$replace = array(
'<img src="/images/nospam001.jpg" border="0" alt=""
/>',
'<img src="/images/nospam002.jpg" border="0" alt=""
/>',
);
return str_replace($search, $replace, $output);
}
?>
Just include it in your global file, or in each file you want to filter.
This one in particular replaces any occurrence of "user@domain.com" or
"user2@domain.com" with an image (that contains each email respectively), preventing spam
bots from picking it up.