258 lines
9.7 KiB
HTML
258 lines
9.7 KiB
HTML
<!--startcut ==============================================-->
|
|
<!-- *** BEGIN HTML header *** -->
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML><HEAD>
|
|
<title>Displaying CVS Version Control Numbers in Webpages LG #64</title>
|
|
</HEAD>
|
|
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
|
|
ALINK="#FF0000">
|
|
<!-- *** END HTML header *** -->
|
|
|
|
<CENTER>
|
|
<A HREF="http://www.linuxgazette.com/">
|
|
<H1><IMG ALT="LINUX GAZETTE" SRC="../gx/lglogo.png"
|
|
WIDTH="600" HEIGHT="124" border="0"></H1></A>
|
|
|
|
<!-- *** BEGIN navbar *** -->
|
|
<IMG ALT="" SRC="../gx/navbar/left.jpg" WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="bottom"><A HREF="kohli.html"><IMG ALT="[ Prev ]" SRC="../gx/navbar/prev.jpg" WIDTH="16" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="index.html"><IMG ALT="[ Table of Contents ]" SRC="../gx/navbar/toc.jpg" WIDTH="220" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../index.html"><IMG ALT="[ Front Page ]" SRC="../gx/navbar/frontpage.jpg" WIDTH="137" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue64/nielsen.html"><IMG ALT="[ Talkback ]" SRC="../gx/navbar/talkback.jpg" WIDTH="121" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../faq/index.html"><IMG ALT="[ FAQ ]" SRC="./../gx/navbar/faq.jpg"WIDTH="62" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="okopnik.html"><IMG ALT="[ Next ]" SRC="../gx/navbar/next.jpg" WIDTH="15" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><IMG ALT="" SRC="../gx/navbar/right.jpg" WIDTH="15" HEIGHT="45" ALIGN="bottom">
|
|
<!-- *** END navbar *** -->
|
|
<P>
|
|
</CENTER>
|
|
|
|
<!--endcut ============================================================-->
|
|
|
|
<H4 ALIGN="center">
|
|
"Linux Gazette...<I>making Linux just a little more fun!</I>"
|
|
</H4>
|
|
|
|
<P> <HR> <P>
|
|
<!--===================================================================-->
|
|
|
|
<center>
|
|
<H1><font color="maroon">Displaying CVS Version Control Numbers in Webpages</font></H1>
|
|
<H4>By <a href="mailto:info@gnujobs.com">Mark Nielsen</a></H4>
|
|
</center>
|
|
<P> <HR> <P>
|
|
|
|
<!-- END header -->
|
|
|
|
|
|
|
|
|
|
<ol>
|
|
<li>
|
|
<a href="#Introduction">Introduction</a></li>
|
|
<li><a href="#perl">Perl script displaying version number</a></li>
|
|
<li><a href="#security">Security</a></li>
|
|
<li>
|
|
<a href="#Conclusion">Conclusion</a></li>
|
|
<li>
|
|
<a href="#REF">References</a></li>
|
|
</ol>
|
|
|
|
|
|
<h3>
|
|
<a NAME="Introduction"></a>Introduction</h3>
|
|
For a few years, I have been writing articles. A silly person named
|
|
Phil Hunter from <a href="http://www.colug.net">Central Ohio Linux
|
|
User Group</a> suggested to me several times to put version control
|
|
on the articles. Of course, that is just one more thing to do in a long
|
|
list of things to do. As usual, when certain things come together, then
|
|
I pick up on old ideas and make them happen. The conditions were the
|
|
following:
|
|
<ol>
|
|
<li> After working at Cisco in the EMAN and INFOSEC groups, I learned how to
|
|
use CVS in some detail. I printed out the CVS manual
|
|
<a href="http://genericbooks.com/Literature/Documents/pdf/Books/cvs_book.pdf">
|
|
available at genericbooks.com</a>. Now I use CVS for everything I do. </li>
|
|
<li>After using SSI, PHP, Mason, ASP, EmbPerl, ePerl, and other Perl
|
|
server side include modules for Apache for quite a few years,
|
|
it became trivial to create a Perl script to open of a CVS file, read it
|
|
contents, and print out the results.
|
|
</li>
|
|
<li> I have a lot of documents, and it is time I keep version control. </li>
|
|
</ol>
|
|
|
|
<h3>
|
|
<a NAME="perl"></a>Perl script displaying version number</h3>
|
|
|
|
In order to make it easy so that every document can use the same
|
|
command, I use this server side include command that comes with
|
|
Apache. PHP, Perl ASP, Mason, and other server side scripting
|
|
languages also have similar commands.
|
|
<pre>
|
|
<!--#include virtual="/ssi/cvs_version.pl" -->
|
|
</pre>
|
|
<p>
|
|
I also have it configured so that all webpage can use server side includes
|
|
commands by putting this into my apache httpd.conf file.
|
|
<pre>
|
|
|
|
<Directory "/usr/local/apache_gnujobs/htdocs">
|
|
|
|
Options All Indexes FollowSymLinks MultiViews ExecCGI Includes
|
|
|
|
AllowOverride All
|
|
|
|
Order allow,deny
|
|
Allow from all
|
|
</Directory>
|
|
|
|
AddType text/html .shtml
|
|
AddHandler server-parsed .shtml .html .htm .shtm
|
|
</pre>
|
|
<p>
|
|
Here is a
|
|
<a href="misc/nielsen/cvs_version.pl.txt">
|
|
text version of the perl script</a>, or you can also
|
|
copy and paste it from this document below.
|
|
|
|
<pre>
|
|
#!/usr/bin/perl
|
|
|
|
print "Content-type: text/html\n\n\n\n";
|
|
|
|
### Get the name of the file being requested.
|
|
my $Temp = $ENV{'REQUEST_URI'};
|
|
my $Cvs = $Temp;
|
|
|
|
### Split the url by "/".
|
|
my (@Junk) = split(/\//, $Cvs);
|
|
|
|
### Get the end of the url, which is the filename.
|
|
my $File = pop @Junk;
|
|
$Cvs =~ s/[^\/]+$//g;
|
|
|
|
### Attach the document root directory so we get the complete path to the
|
|
### file on our computer server. Also, attach the CVS/Entries name so that
|
|
### we get the CVS information.
|
|
$Cvs = $ENV{'DOCUMENT_ROOT'} . $Cvs . "CVS/Entries";
|
|
|
|
### Open the file, and if we find a match, record it to $Match
|
|
my $Match = "";
|
|
open(FILE,$Cvs);
|
|
while (my $Line = <FILE>)
|
|
{
|
|
if ($Line =~ /$File/) {$Match = $Line; chomp $Line}
|
|
}
|
|
close FILE;
|
|
|
|
### If match is not found, print not found, otherwise get the information.
|
|
if ($Match eq "") {print "No CVS information found. '$File'\n";}
|
|
else
|
|
{
|
|
### Get the information we want and print it out.
|
|
my ($Junk,$File,$Version,$Date,@Junk) = split(/\//, $Match);
|
|
print "Version <b>$Version</b> : Date Last Changed <b>$Date</b>\n";
|
|
}
|
|
|
|
</pre>
|
|
|
|
|
|
<h3>
|
|
<a NAME="security"></a>
|
|
Security</h3>
|
|
There is a potential problem with security when you use my perl script above.
|
|
Anybody can read your files located in the CVS directories. I don't know
|
|
if this is a big concern to most people, and it really isn't a concern to me,
|
|
but just in case, I blocked reading of the files in any CVS directory by
|
|
using these commands in my httpd.conf file for my Apache webserver. This is
|
|
a simple way of doing it. I am not going to have
|
|
any files or directories that end their names with the words
|
|
"Root", "CVS", "Repository", or "Entries", so to me it works fine.
|
|
|
|
<pre>
|
|
<Files ~ "CVS$">
|
|
Order allow,deny
|
|
Deny from all
|
|
</Files>
|
|
<Files ~ "Root$">
|
|
Order allow,deny
|
|
Deny from all
|
|
</Files>
|
|
<Files ~ "Repository$">
|
|
Order allow,deny
|
|
Deny from all
|
|
</Files>
|
|
<Files ~ "Entries$">
|
|
Order allow,deny
|
|
Deny from all
|
|
</Files>
|
|
</pre>
|
|
|
|
<h3>
|
|
<a NAME="Conclusion"></a>Conclusion</h3>
|
|
Using CVS to manage version control of documents, programs, and scripts is
|
|
great. Using CVS and my perl script to display the version number of the
|
|
document is a satisfactory way of keeping version control of your documents.
|
|
I have no need to make it more advanced, so it works for me.
|
|
<p>
|
|
Some silly things to do:
|
|
<ol>
|
|
<li> Check to see if CVS directory and files exist before opening up to
|
|
read them. Doesn't matter since I assume the person putting in the
|
|
server side include command should know what they are doing and it wouldn't
|
|
really do anything bad anyways. </li>
|
|
<li>Use a better regular expression match which will make the webserver
|
|
reject "/CVS/" anywhere in the requested url from the client browser.
|
|
This would be better than rejecting only specific files. This doesn't
|
|
matter to me.</li>
|
|
<li>This doesn't work with Alias in the httpd.conf file. At least, I don't
|
|
think it does. </li>
|
|
<li> Check to see if the date of the file matches the date in CVS.
|
|
This lets you know if your document is out of sync with the CVS
|
|
respository. This isn't important to me.
|
|
</li>
|
|
</ol>
|
|
<p>
|
|
|
|
<h3>
|
|
<a NAME="REF"></a>References</h3>
|
|
|
|
<ol>
|
|
<li>
|
|
If this article
|
|
changes, it will be available here
|
|
<a href="http://www.gnujobs.com/Articles/16/CVS_SSI.html">
|
|
http://www.gnujobs.com/Articles/15/CVS_SSI.html.</a></li>
|
|
<li><a href ="../issue57/nielsen.html">
|
|
CVS: Concurrent Versions System</a> by Mark Nielsen </a>
|
|
|
|
</ol>
|
|
|
|
|
|
<p>
|
|
<i> Mark works as an independent consultant donating time to causes like
|
|
GNUJobs.com, writing articles, writing free software, and working
|
|
as a volunteer at <a href="http://www.eastmont.net">eastmont.net</a>.</i>
|
|
<p>
|
|
<i>Copyright © 1/2001 Mark Nielsen</i>
|
|
<br>Article
|
|
|
|
Version <b>1.3</b> : Date Last Changed <b>Sun Feb 25 21:13:16 2001</b>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- *** BEGIN copyright *** -->
|
|
<P> <hr> <!-- P -->
|
|
<H5 ALIGN=center>
|
|
|
|
Copyright © 2001, Mark Nielsen.<BR>
|
|
Copying license <A HREF="../copying.html">http://www.linuxgazette.com/copying.html</A><BR>
|
|
Published in Issue 64 of <i>Linux Gazette</i>, March 2001</H5>
|
|
<!-- *** END copyright *** -->
|
|
|
|
<!--startcut ==========================================================-->
|
|
<HR><P>
|
|
<CENTER>
|
|
<!-- *** BEGIN navbar *** -->
|
|
<IMG ALT="" SRC="../gx/navbar/left.jpg" WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="bottom"><A HREF="kohli.html"><IMG ALT="[ Prev ]" SRC="../gx/navbar/prev.jpg" WIDTH="16" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="index.html"><IMG ALT="[ Table of Contents ]" SRC="../gx/navbar/toc.jpg" WIDTH="220" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../index.html"><IMG ALT="[ Front Page ]" SRC="../gx/navbar/frontpage.jpg" WIDTH="137" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue64/nielsen.html"><IMG ALT="[ Talkback ]" SRC="../gx/navbar/talkback.jpg" WIDTH="121" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../faq/index.html"><IMG ALT="[ FAQ ]" SRC="./../gx/navbar/faq.jpg"WIDTH="62" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="okopnik.html"><IMG ALT="[ Next ]" SRC="../gx/navbar/next.jpg" WIDTH="15" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><IMG ALT="" SRC="../gx/navbar/right.jpg" WIDTH="15" HEIGHT="45" ALIGN="bottom">
|
|
<!-- *** END navbar *** -->
|
|
</CENTER>
|
|
</BODY></HTML>
|
|
<!--endcut ============================================================-->
|