PDA

View Full Version : Trying to replace text in postbit


cric2k
11-15-2013, 11:26 AM
Hi,

I'm trying to resolve an issue where Google have banned Advertisements because of some dodgey images somewhere (the site is 500,000 pages and despite my best efforts at deleting I still haven't found one of the pages Google doesn't like).

I've come across this plugin which should do the job Google wants (I only show ads to guests) https://vborg.vbsupport.ru/showthread.php?t=256054&page=2 although it isn't working for me.

The code:

$this->post['pagetext_html'] = preg_replace('/\[IMG\](.*)\[\/IMG\]/im', construct_phrase($vbphrase['hideimg_message'], $session['sessionurl_q']), $this->post['pagetext_html']);

Is hooked into postbit_display_start, but is doing nothing (as the pagetext_html variable is either over written at a later stage, or not used).

So basically, however rough I do it (hard coding or whatever) I want to replace text in the string in the postbit to remove images for Guests. Anyone any ideas?

squidsk
11-15-2013, 08:58 PM
Your problem is post['pagetext_html'] is just that the html version of the post, your regex replacement is looking for the bbcode for image, which would have been previously replaced with the xhtml equivalent.

cric2k
11-16-2013, 08:21 AM
I've just figured out that I had have two problems. One of them was that another plugin was over writing the variable before it was displayed.

Now that I have disabled that plugin it appears that $post['pagetext_html'] is only populated in about 60% of threads (and the above regex replace works fine on it), on the other 40% of threads it seems this variable is not used.

I have no idea what the difference is between threads, I've tried clearing the cache etc - but it seems for a random number of entire threads the $post['pagetext_html'] variable is not used at all (it's coming back blank and something else I don't know is populating the postbit).

Anyone any ideas?

--------------- Added 1384596331 at 1384596331 ---------------

Got it, for some reason it's sometimes stored as $post['pagetext'] - the replace works on that also.