Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

globally searching and replacing strings in posts

Quote Reply
globally searching and replacing strings in posts
I have a client running Gossamer Forum. His members frequently post links to a particular retailer. He's set up an affiliate program with this retailer, and so that he gets a referrer commission on purchases that originate from his site.

What he'd like to do is go through all of the posts on the forum and add his affiliate id to the existing URL tags. I've come up with a short script to do this, but before I run it, I want to make sure that I'm not going to hose anything.

Is there any harm in updating gforum_Post.post_message directly, rather than via the web frontend?

thanks!
Quote Reply
Re: [tfinney] globally searching and replacing strings in posts In reply to
Hi,

post_message can be safely updated directly. Obviously you need to take care to be sure you don't accidentally delete any post body content, but as far as GForum is concerned updating the column directly is okay.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] globally searching and replacing strings in posts In reply to
It doesn't appear that gforum_Post can be directly updated, at least without some strangeness happening.

I have a script that looks at all of the post_message entries for a string that we'll say is 'Foo'. It then substitutes 'Foo' for 'Foo'.

After it runs, all of the messages contain 'Foo', not as a link, but the literal, escaped text.

After backing out my changes, I attempted to substitute '<a href="http://www.example.com">Foo</a>'. Once again, I got the literal text in the posts. Viewing source reveals that the greater than and less than signs around the tags are being dynamically transformed into the character entities, even though they appear as greater than and less than in the database.

But wait, it gets better.

If I edit a post after running the script, the link code magically works. Even though the text in post_message is exactly the same, Gossamer decides to display it as a link.

What am I missing?

thanks.
Quote Reply
Re: [tfinney] globally searching and replacing strings in posts In reply to
If the post_style is not set to 1 (Markup) or 3 (Markup and HTML), [url]...[/url] tags won't be converted, and if not 2 (HTML) or 3 (Markup and HTML), HTML will be escaped. It sounds like in these cases the posts are set to Plain text only (post_style = 0).

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com