comments.pl
A CGI SCRIPT IN Perl BY JUSTIN BOSAR
Distribution notes: feel free to distribute, use, and modify this
code as you wish.
v1.7 24 April 2006
- Eliminated static html form used for posting. The "post comments" button at the
top of the page now submits to the script, which generates the form all dynamic-like.
The form displays in the current window and the pop-up is eliminated. In the future,
recent posts will be attached at the bottom of the dynamic form for easy quoting.
- Having a dynamic form allows me to tag each post with a identifier, which for now
is just a pseudo-random number based on the post time. This is the beginning of
a perma-link system to be attempted with the next patch. Since the seed only changes
once a second, there isn't any fancy checking to see if this number is truly unique,
but I haven't decided whether I want to spend any time on that. I might just change
it to a simple counter in the future.
- Before a new post is added, the identifier is checked, which should finally
provide reliable detection against accidental duplicate posts. The most common cause
is people refreshing on the script response. If you post data again, the same ID
will be sent and the post will be ignored (and the script response will update to
reflect this).
- Since the form and script response are no longer in a new window, the response page
has been updated and now provides a link back to the main forum page.
- Moved the buttons around, mostly just to annoy people. Script version put down
at the bottom of the forum where it belongs. Forum Archives now at the top.
- Hyperlinking improved using quantification, which may or may not be a real word.
This should prevent acronyms like U.S.A. from turning into links, even if you are
sneaky and prefix it. Also, links without sub-domains (http://digg.com) should pop
now.
- About those prefixes...for now, you'll need one. I'm looking into ways around this,
but the good news is that ftp and https links should now maintain their integrity and
not trigger wierd google searches anymore. http:// ftp:// and https:// needs to
precede your link, though other qualifications need to be met before it becomes active,
so posting http://blahblahblah will not result in a broken link. The problem I'm
balancing is that if I don't require a prefix, an assumption needs to be made about
which type it is, which before was always http, and this broke other links. Ideally,
you could specify https or ftp and that would override the assumption, but in all other
cases the prefix would be optional. However, I haven't been able to come up with a
regex that allows this without recursion errors. For example, if a post had prefixed
links and also non-prefixed links, the prefixed links would match twice. There should
be a look-behind assertion that handles this but I haven't got the syntax down yet.
- The security escapes for percent signs and pipes no longer create extra whitespace,
which was breaking links and just looking strange.
v1.6 8 January 2006
- Extensive additions to the archiving routines. When a new archive page is created,
a directory is updated with a link to the page and the number of posts moved, so that
all archived content can be accessed automatically. The link at the bottom of the
current page takes you to an html version of the directory, which groups files by year.
- Fixed a bug preventing the a poster from turning their text back to white after using
another color.
- When the script removes what it believes to be HTML code from a post, it now leaves a
"html deleted" message in its place, so that when "disappearing text" bugs are reported,
this regex function can be ruled out as the cause.
- Pipe characters in the post should no longer terminate rendering once the post is
archived. This has the the side effect of making the forum more ascii-art friendly.
Pipes are now removed from the name field.
- As a random security precaution, percent characters in the post are now escaped to
ansi character entity references. Percents are now removed from the name field.
- The archiver now uses the same post-formatting subroutine as the rest of the script,
eliminating a bunch of semi-redundant, hard-coded HTML in the perl.
v1.5 24 June 2004
- Made hyperlink detection significantly smarter, and reduced it to a single regex.
It now works with any number of URLs in a post, using either the http:// prefix
or not, in any combination. Detects most URLs that don't start with www. Supports
links in parentheses and links at the end of a sentence (trailing periods are properly
ignored, although trailing ?s may be included since this doesn't seem to break links
and may be used by PHP, etc.).
- Added some formatting variables to the top for portability. It's now easy to change
the colors of stuff.
- Formatting a post in html is now handled by a single function, whether the post
originates from the plain archive, the html root, or the submition form. This makes
formatting changes easy and reduces source length by over 50 lines.
v1.4.1 15 December 2003
- Reworked and improved duplicate post prevention, which now tests when writing to
the archive too.
- Made hyperlink detection a little smarter to avoid the Awww... bug.
- It is now possible for the month of October to occur!
v1.4 31 July 2003
- Extensive internal tweaking. The goal here is to make some progress towards
portability, to be tested with the SpooLAN site. Created many new variables at the
top of the file for the path, and other things. All static/explicit directories and
files previously written into the code are replaced by these variables. The sysop
can also specify a name for the forum, and the dynamic files should adopt this name.
This should allow for multiple forums.
- Changed the formatting slightly. All posts, even really short ones, now create a
full-width table so that the date is always on the right margin. The date is also
printed smaller. The heading for the forum HTML is changed to make more efficient use
of limited vertical space.
v1.3 13 July 2003
- in the middle of a month, the script now flushes posts from the previous month
into a new archive file, and truncates the .old file accordingly. This is an
entirely new subroutine. It also modifies the HTML response with feedback on the
month archived and the number of posts moved. Currently, the new file must be
manually linked.
- the rewrite of the time formatter introduced a Y2K-style bug which displayed the
year 2003 as 103, and the minute field was omitting leading zeroes, which looked
really funny. Both have been corrected. Also, the timezone shift failed to change
the day properly due to logic error. That modification is now done directly on the
epoch data returned from the time function, *before* it is formatted into something
human beings can actually read.
v1.2.3 9 July 2003
- the new time format failed when the month changed. Unfortunately, I'm still
not entirely sure why, so I re-wrote the entire section using a different
strategy which should be more efficient and reliable.
v1.2.2 17 June 2003
- formatting returns with ! as the metacharacter. Hopefully this will clash
less with DHTML stuff.
- the format in which the time is recorded has been changed. No more military time.
No more seconds. The time now placed after the year. I find this a little easier
to read, and it is good preparation for self-archiving, to be implemented in v1.3.
v1.2.1 22 May 2003
- patch to fix some bugs. previously, the hyperlinking would fail when links
contained "\" or "z". I mistakenly believed you could use certain zero-width
assertions in a character class, and I now know better.
- the ampersand formatting macros have been disabled because they seem to be
rather common in URLs. And nobody used them effectively anyway. Formatting
will return in v1.3 once I find a safer character.
- now, submitting space(s) for your name (or nothing at all) will display your name
as "Anonymous", but will allow the post unless this is abused in the future.
Submitting a space for the message causes the post to be ignored.
v1.2 21 February 2003
- http: and ftp: URLs are now turned into hyperlinks automatically when posted.
v1.1 10 July 2002
- added some code to help prevent duplicate posts when people double-click
on the submit button.
- made carriage return detection automatic. Should work for tabs too.
Updated the form to reflect this. Certain people can stop whining now ;)
v1.0 12 Jan 2002
- added support for a manually maintained archive.
- added some graphical buttons for posting.
- I consider the script ready for public launch at www.pulgaritrap.com.
In the near future I hope to add more formatting options, such as graphical
smiloids, and move variables out of code and into config/database files
for increased portability of the script (as with postnews.pl, this program
will be distributable by version 2.0).
v0.3 8 Jan 2002
- changed the message formatting a bit so it's easier to read, and the
font is consistent across browsers.
- started to add user-formatting commands (carriage returns, color, etc.).
v0.2 28 Aug 2001
- ability to render HTML in within posts removed, just in case someone
tries to get creative.
v0.1 27 Aug 2001
- script is first uploaded to www.pulgaritrap.com. Compilation/Syntax
errors are fixed. Closed beta testing begins, the hunt for logic
errors and other bugs commences.
-- end of file --
Back to Forum