Feature Creep for Comments

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Feature Creep for Comments

Post by Ambush Commander »

I'd like to add the ability for users to add comments to my website. Seems innocuous enough, except that my application does not currently use databases and is built on the compilation of XHTML files into static HTML files to be served to the general public. So if I implement comments, I'll probably end up having to implement a whole bunch of features that I don't actually want to implement!

Therefore, before embarking on this treacherous journey, I'd like to pin down possible feature creep:

- Database credentials / abstraction layer (ugh) or XML data layer
- User login / OpenID / Gravatar
- Comment anti-spam / moderation interface / captcha

Anything else?
User avatar
kyberfabrikken
Forum Commoner
Posts: 84
Joined: Tue Jul 20, 2004 10:27 am

Post by kyberfabrikken »

I put up a blog-ish site recently, which is all static HTML files. The content come from XML-documents, and I then have a script to "bake" the site (Generate the static content; Eg. HTML and RSS). I wanted to allow comments, but I also liked the simple solution. So I created a script to post comments, which would stuff the comment in a database (SQLite), and mail me. I'd then go to a simple administration page, which shows un-approved comments, with an 'approve' and 'delete' button. After approving, I'd re-bake the site. Since I don't get thousands of comments a day, this is a really efficient way to avoid spam.
All in all, this took me a couple of hours to throw together, and it's completely bullet-proof. Some times, you don't need to pull out the big guns to make something work.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Shouldn't be a huge chore. If the compilation process is capable of being run automatically, then it just needs an extra trigger (approval of comment, or approval of anonymous comment by a web service - check out Akismet which is free). If the storage is going to be small, just use an XML file, otherwise a small database. The whole thing is already file based, so your backup system should cope.

User authentication is the part that will push you towards a more complex solution. Gravatar is a tiny feature - easy to add.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Glad to see this won't be too much trouble. I'm still worrying about the database abstraction layer though. A well designed one can save a lot of trouble, but they require quite a bit of initial investment to make. A mapper would be ideal, I think. (BTW, PHP 5)

Backing things up, actually, is a bit of a concern. The entire website runs out of a Subversion checkout, so code and HTML all are under version control (which is exactly the way I like it, and is the only method of backup). But I don't really see how I can "commit" comments into the SVN. Plus, I have to be careful not to publish sensitive user data like IP addresses.
Post Reply