PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Everything works in my CMS, but there has been a problem when the client copies the topic content from his MS Word Documents on the Rich text area (I'm using Tiny MCE). This results in a post that has these MS tags in:
These tags cause Internet Explorer 6/7 (ugh..) to break the page layout. Firefox seems to gracefully ignore them.
Tiny MCE has a button to paste from an MS Word Document and removes all these tags, but the client most of the times forgets to use it, so it results into a broken CMS. Is there any server side way to remove those tags with PHP while keeping the rest of the rich html content?
There's a function called strip_tags() which does what you might expect - removes HTML from input. You can specify which tags to leave in, so strip out all the pointless <meta> tags etc, but keep in (for example) <p>, <b>, <a> etc.
The only drawback is that Word managed to infect these elements too, so you'll still end up with <p style="MSoNormal"> or something... still not sure how to get around that one besides a hard search and replace every time they submit text, to clean it.
But this removes the whole text and tags, it seems something is confusing the function. I guess it's better submitting a blank post than letting these tags in the content break the page.