mme42
12-10-2009, 09:16 AM
I've been trying to write a simple filter plug-in to replace certain host/domain names with a message for certain forums only.
I actually started trying to replace the whole hyperlinked URLs or even plain text links with a regular expression (https://vborg.vbsupport.ru/showthread.php?t=229799). But, it's a bit over my head. And, after asking about it over at Stackoverflow, I've gotten the idea that there might be a better way to do it even if I figured out the REGEX to use. So, until I can begin to understand that stuff more, I've decided to just start with a simple str_replace to at least filter the domain part.
I have the filter part working fine, but I'm not sure how to exclude certain forums. There are less forums that I'd like to exclude than include, so I went about it from perspective of excluding them. I'm not sure if I'm using the right variable for the forum ID or using it in the right way. Here's what I have so far:
$filteredhosts = array('hostname1', 'hostname2', 'hostname3');
$replacemessage = 'THIS LINK HAS BEEN FILTERED';
if ($foruminfo['forumid'] != array ('1','2','3','4','5','6','7','8')) $this->post['message'] = str_replace($filteredhosts, $replacemessage, $this->post['message']);
The hook location is postbit_display_complete and the execution order is 5 if that matters. So, I'm looking for the correct php forum ID variable and the correct way to use it in this situation if anybody can help.
Thanks. :D
I actually started trying to replace the whole hyperlinked URLs or even plain text links with a regular expression (https://vborg.vbsupport.ru/showthread.php?t=229799). But, it's a bit over my head. And, after asking about it over at Stackoverflow, I've gotten the idea that there might be a better way to do it even if I figured out the REGEX to use. So, until I can begin to understand that stuff more, I've decided to just start with a simple str_replace to at least filter the domain part.
I have the filter part working fine, but I'm not sure how to exclude certain forums. There are less forums that I'd like to exclude than include, so I went about it from perspective of excluding them. I'm not sure if I'm using the right variable for the forum ID or using it in the right way. Here's what I have so far:
$filteredhosts = array('hostname1', 'hostname2', 'hostname3');
$replacemessage = 'THIS LINK HAS BEEN FILTERED';
if ($foruminfo['forumid'] != array ('1','2','3','4','5','6','7','8')) $this->post['message'] = str_replace($filteredhosts, $replacemessage, $this->post['message']);
The hook location is postbit_display_complete and the execution order is 5 if that matters. So, I'm looking for the correct php forum ID variable and the correct way to use it in this situation if anybody can help.
Thanks. :D