>>25
You're going about this several different kinds of wrong.
First, trying to build a CMS on top of a message board script is really really screwy, and I would suggest some psychoanalysis for that, but that's beside the point at the moment. Take a moment and think about what you're doing; it can [em]easily[/em] be handled with Kareha. It's a highly flexible script, more so than you might think. Supposing each file is a separate thread, and each post in that thread is a new revision of that file. (Or not -- you can even intermingle conversation [em]about[/em] the file with that if you're careful.) When writing the cache page for the thread, also output it (or maybe just the <code> sections) to a separate file on disk named $threadid-$postid.txt. Having done this, you can easily fetch any revision of a given file with a simple
wget $threadid-$postid.txt -- and with some symlinks you can even make it so you can
wget $threadid-CURRENT. That hack would be about 50 lines of code at the most.
If you want to get even more clever, you can put each thread into a separate directory, and symlink the thread directories to the thread title -- then you can
wget filename.ext/CURRENT, which would resolve to the most recent revision of the thread for that file.
However, this addition still won't make up for the fact that copy-and-paste into a <textarea> as the basic method of making a revision is really stupid, gives no inherent capability for contextual diffs, and generally yields far more inconveniences than benefits. Next line of business would be making a posting tool, so you can do something such as
repost $filename, which would fetch the thread index, find the proper thread for the file, and post a reply. There, you've got a basic CMS built on Kareha.