A PHP Script for Viewing Text Files
I've been writing PHP scripts recently to interact with the Loom.cc anonymous electronic vault and trading system. I've wanted to be able to show off my code, and my emacs design text files, without requiring the download of a source TAR file. So I wrote a little script that displays a text file, with a fixed width font and word wrap, and, optionally, searching for a phrase and/or displaying line numbers.
Go to billstclair.com/loom/viewtext.php?file=viewtext.php to direct the script to view itself.
You can add line numbers by adding "&numbers=yes" to that URL.
You can search for a phrase, e.g. "replace", by adding "&search=replace" to the URL. Each instance of the search string becomes a link that you can click on to move to the next one.
Finally, such file viewers are security risks if you're not careful. But I was. Only files explicitly named in "viewtext.txt" may be viewed. That list is displayed if you leave off the "file": billstclair.com/loom/viewtext.php. This makes it easy to drop a copy of viewtext.php in a directory on your web site, and enter the names of the files you want to show in viewtext.txt in that directory.
Go wild!