cvs commit: www/test/style print.css screen.css

jeroen at linuxfromscratch.org jeroen at linuxfromscratch.org
Wed Aug 6 03:57:39 PDT 2003


jeroen      03/08/06 04:57:39

  Modified:    test/blfs news-bottom.html
               test/images linuxfromscratch.png
               test/style print.css screen.css
  Added:       test/cgi-bin lfscounter.cgi
  Log:
  Reworked the lfscounter.cgi to fit in the new design. Added it to CVS now
  
  Revision  Changes    Path
  1.3       +1 -1      www/test/blfs/news-bottom.html
  
  Index: news-bottom.html
  ===================================================================
  RCS file: /home/cvsroot/www/test/blfs/news-bottom.html,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- news-bottom.html	5 Aug 2003 16:38:32 -0000	1.2
  +++ news-bottom.html	6 Aug 2003 10:57:38 -0000	1.3
  @@ -12,7 +12,7 @@
   	<ul>
   		<li><a href="http://validator.w3.org/check/referer"><img src="../images/xhtml-1.1.png" alt="Valid XHTML 1.1!" height="15" width="80" /></a></li>
   		<li><a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="../images/css.png" alt="Valid CSS!" height="15" width="80" /></a></li>
  -		<li><a href="http://feeds.archive.org/validator/check?url=http://test.linuxfromscratch.org/lfs/feed.rss"><img src="../images/rss.png" alt="Valid RSS!" width="80" height="15" /></a></li>
  +		<li><a href="http://feeds.archive.org/validator/check?url=http://test.linuxfromscratch.org/blfs/feed.rss"><img src="../images/rss.png" alt="Valid RSS!" width="80" height="15" /></a></li>
   	</ul>
   </div>
   
  
  
  
  1.1                  www/test/cgi-bin/lfscounter.cgi
  
  Index: lfscounter.cgi
  ===================================================================
  #!/usr/bin/perl -w
  
  my $table="users";
  
  my $me = "http://test.linuxfromscratch.org/cgi-bin/lfscounter.cgi";
  
  use DBI;
  use CGI;
  
  use strict;
  
  my $dbh;
  my $ch = new CGI;
  
  my $query;
  my $register;
  
  my $name_regex = '^(\w+[\s\w\-\.]*\w+)*$';
  my $first_lfs_regex = '^1\.x$|^1\.0$|^1\.1$|^1\.2$|^1\.3$|' .
  	'^2\.x$|^2\.0\-beta1$|^2\.0\-beta2$|^2\.0\-pre1$|^2\.x\.x$|^2\.1\.x$|' .
  	'^2\.1\.5$|^2\.2$|^2\.3\.x$|^2\.3\.1$|^2\.3\.2$|^2\.3\.3$|' .
  	'^2\.3\.4$|^2\.3\.5$|^2\.3\.5b$|^2\.3\.6$|^2\.3\.7$|' .
  	'^2\.4$|^2\.4\.x$|^2\.4\.1$|^2\.4\.2$|^2\.4\.3$|^2\.4\.4$|' .
  	'^3\.0\-prex$|^3\.0\-pre1$|^3\.0\-pre2$|^3\.0\-pre3$|^3\.0\-pre4$|' .
  	'^3\.0\-rcx$|^3\.0\-rc1$|^3\.0\-rc2$|^3\.x$|^3\.0$|^3\.1$|^3\.2\-rc1$|' .
  	'^3\.2\-rc2$|^3\.2$|^3\.3$|^4\.x$|^4\.0\-rc1$|^4\.0$|^4\.1$|^cvs$';
  my $cvs_date_regex = '^\d{8,8}$';
  my $id_regex = '^\d{1,5}$';
  my $order_by_regex = '^id$|^name$|^first_lfs$';
  my $position_regex = '^\d{1,5}$';
  my $increment_regex = '^\d{1,5}$';
  my $sort_order_regex = '^asc$|^desc$';
  my $name_length = "30";
  my $first_lfs_length = "9";
  my $cvs_date_length = "8";
  my $id_length = "5";
  my $order_by_length = "9";
  my $position_length = "5";
  my $increment_length = "5";
  my $sort_order_length = "4";
  
  sub PrintHTMLHeader() {
  	print "Content-type: text/html\n\n";
  
  	print <<EOF;
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  
  <head>
  	<title>Linux From Scratch Counter</title>
  	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  	<meta http-equiv="Content-Style-Type" content="text/css" />
  	<meta name="description" content="Linux From Scratch - build your own Linux distribution from scratch" />
  	<meta name="keywords" content="Linux, LinuxFromScratch, Linux From Scratch, build your own Linux, DIY Linux, do-it-yourself Linux, create your own Linux" />
  	<meta http-equiv="imagetoolbar" content="false" />
  	<meta name="MSSmartTagsPreventParsing" content="true" />
  	<link rel="stylesheet" type="text/css" href="../style/screen.css" media="screen" />
  	<link rel="stylesheet" type="text/css" href="../style/print.css" media="print" />
  	<link rel="icon" href="../images/favicon.ico" type="image/x-icon" />
  </head>
  
  <body id="body" class="root">
  
  <div id="header">
  	<ul id="sectionnav">
  		<li><a href="#index" class="hidden" accesskey="2">Skip to content</a></li>
  		<li><a href="lfs/index.html" accesskey="l"><span class="accesskey">L</span>FS</a></li>
  		<li><a href="../blfs/news.html" accesskey="b"><span class="accesskey">B</span>eyond LFS</a></li>
  		<li><a href="../alfs/news.html" accesskey="a"><span class="accesskey">A</span>utomated LFS</a></li>
  		<li><a href="../hints/news.html" accesskey="h"><span class="accesskey">H</span>ints</a></li>
  	</ul>
  	<h1><a href="../lfs/news.html" accesskey="l">Linux From Scratch</a></h1><span class="hidden"> - </span>
  	<h2><a href="../lfs/whatislfs.html">Your distro. Your rules.</a></h2>
  	<div id="search">
  		<form method="get" action="http://search.linuxfromscratch.org">
  		<p>
  			<label title="Enter your search terms"><input size="15" type="text" name="query" onfocus="if(this.value==this.defaultValue) this.value='';" value="enter text here" maxlength="255" accesskey="s" /></label>
  			<label title="Submit the search terms"><input type="submit" value="search" /></label><br />
  			<a href="../search.html" title="For more search options, click here" accesskey="4"><span class="accesskey">S</span>earch options</a>
  			</p>
  		</form>
  	</div>
  </div>
  
  <div id="container">
  <div id="rootcontent">
  	<em><a href="#generalnav" class="hidden">Skip to sitewide navigation</a></em>
  
  <h2>The Linux From Scratch Counter</h2>
  
  EOF
  }
  
  sub PrintHTMLFooter() {
  	print <<EOF;
  
  </div> <!-- end content -->
  
  <div id="footer">
  	<ul>
  		<li><a href="#header">Back to the top.</a></li>
  		<li>© 1998-2003  Gerard Beekmans.</li>
  		<li>Site design by Jeroen Coumans.</li>
  	</ul>
  	<ul>
  		<li><a href="http://validator.w3.org/check/referer"><img src="../images/xhtml-1.1.png" alt="Valid XHTML 1.1!" height="15" width="80" /></a></li>
  		<li><a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="../images/css.png" alt="Valid CSS!" height="15" width="80" /></a></li>
  	</ul>
  </div>
  
  <div id="generalnav">
  	<ul>
  		<li><h3>Contribute:</h3>
  			<ul>
  				<li><a href="../donation.html" title="We accept all donations, really">Make a donation</a></li>
  				<li><a href="http://linuxfromscratch.org/cgi-bin/lfscounter.cgi" class="currentpage" title="Register freely!">Register as LFS user</a></li>
  				<li><a href="../becomemirror.html" title="If you have some bandwidth to spare">Become a mirror</a></li>
  			</ul>
  		</li>
  		<li><h3>Help and contact:</h3>
  			<ul>
  				<li><a href="../faq/" title="Frequently Asked Questions (and answers!)">FAQ</a></li>
  				<li><a href="../search.html" title="Advanced search page">Search</a></li>
  				<li><a href="../irc.html" title="Yes we chat too">IRC</a></li>
  				<li><a href="../newsgroups.html" title="For following development and advanced support">News groups</a></li>
  				<li><a href="../mail.html" title="For following development and advanced support">Mailing lists</a></li>
  				<li><a href="../people.html" title="A list of user homepages hosted on LFS">People</a></li>
  			</ul>
  		</li>
  		<li><h3>About this website:</h3>
  			<ul>
  				<li><a href="index.html" title="Home (mirror list)" accesskey="1">Home (Mirror list)</a></li>
  				<li><a href="../sitemap.html" title="Structured overview of the website" accesskey="3">Sitemap</a></li>
  				<li><a href="../accesskeys.html" title="Speed up your browsing" accesskey="0">Accesskeys</a></li>
  				<li><a href="../website.html" title="Todo, general information and changelog">Website information</a></li>
  				<li><a href="mailto:website\@linuxfromscratch.org" title="Problems, questions or suggestions?" accesskey="9">Discuss this website</a></li>
  			</ul>
  		</li>
  	</ul>
  </div><!-- end generalnav -->
  </div><!-- end container -->
  
  </body>
  </html>
  
  EOF
  
  }
  
  sub PrintForm() {
  
  	my $sth;
  	my $sql_output;
  	my $total;
  
  	$sth = $dbh->prepare ("select count(id) from $table");
  	$sth->execute;
  
  	$sql_output = $sth->fetchrow_hashref();
  	$total = $sql_output->{'count(id)'};
  
  	print "<h3>LFS users registered so far: $total</h3>\n";
  
  	print <<EOF;
  <form method="post" action="$me">
  <p>
  <input type="hidden" name="register" value="1" />
  Registering as an LFS user is very easy. Just enter your name
  and select the first LFS version you have used, and click on
  <em>Register me</em>.</p>
  
  <p>If you can't remember the exact version you downloaded, just enter your best guess.</p>
  
  <table class="form">
  <tbody>
  <tr>
  	<th>Name:</th>
  	<td><input type="text" name="name" size="30" maxlength="30" /></td>
  </tr>
  
  <tr>
  	<th>First LFS Version:</th><td>
  <select name="first_lfs">
  <option value="1.x">1.x</option>
  <option value="1.0">1.0</option>
  <option value="1.1">1.1</option>
  <option value="1.2">1.2</option>
  <option value="1.3">1.3</option>
  <option value="2.x">2.x</option>
  <option value="2.0-beta1">2.0-beta1</option>
  <option value="2.0-beta2">2.0-beta2</option>
  <option value="2.0-pre1">2.0-pre1</option>
  <option value="2.x.x">2.x.x</option>
  <option value="2.1.x">2.1.x</option>
  <option value="2.1.5">2.1.5</option>
  <option value="2.2">2.2</option>
  <option value="2.3.x">2.3.x</option>
  <option value="2.3.1">2.3.1</option>
  <option value="2.3.2">2.3.2</option>
  <option value="2.3.3">2.3.3</option>
  <option value="2.3.4">2.3.4</option>
  <option value="2.3.5">2.3.5</option>
  <option value="2.3.5b">2.3.5b</option>
  <option value="2.3.6">2.3.6</option>
  <option value="2.3.7">2.3.7</option>
  <option value="2.4">2.4</option>
  <option value="2.4.x">2.4.x</option>
  <option value="2.4.1">2.4.1</option>
  <option value="2.4.2">2.4.2</option>
  <option value="2.4.3">2.4.3</option>
  <option value="2.4.4">2.4.4</option>
  <option value="3.0-prex">3.0-prex</option>
  <option value="3.0-pre1">3.0-pre1</option>
  <option value="3.0-pre2">3.0-pre2</option>
  <option value="3.0-pre3">3.0-pre3</option>
  <option value="3.0-pre4">3.0-pre4</option>
  <option value="3.0-rcx">3.0-rcx</option>
  <option value="3.0-rc1">3.0-rc1</option>
  <option value="3.0-rc2">3.0-rc2</option>
  <option value="3.x">3.x</option>
  <option value="3.0">3.0</option>
  <option value="3.1">3.1</option>
  <option value="3.2-rc1">3.2-rc1</option>
  <option value="3.2-rc2">3.2-rc2</option>
  <option value="3.2">3.2</option>
  <option value="3.3">3.3</option>
  <option value="4.x">4.x</option>
  <option value="4.0-rc1">4.0-rc1</option>
  <option value="4.0">4.0</option>
  <option value="4.1">4.1</option>
  <option value="cvs">CVS</option>
  </select></td>
  </tr>
  
  <tr>
  	<th>If CVS, enter CVS date ( <strong>yyyymmdd</strong> ):</th>
  	<td><input type="text" name="cvs_date" size="8" maxlength="8" /></td>
  </tr>
  
  </tbody>
  </table>
  <p class="submit"><input type="submit" value="Register me" /></p>
  </form>
  
  <br />
  
  <p><a id="query"></a>You can query the database to look for a particular userid, name or
  first lfs version used, or any combination of these. Just hitting the Query
  button without filling anything will result in the entire LFS users
  database to be shown.</p>
  
  <p>The value for <code>Name</code> will be matched according to this regular
  expression <code>^.*your_value.*</code> and will be case insensitive.</p>
  
  <form method="post" action="$me">
  <p><input type="hidden" name="query" value="1" /></p>
  <table class="form">
  <tbody>
  <tr>
  	<th>LFS ID:</th><td><input type="text" name="id"
  		size="5" maxlength="5" /></td>
  </tr>
  
  <tr>
  	<th>Name:</th><td><input type="text" name="name" size="30"
  		maxlength="30" /></td>
  </tr>
  
  <tr>
  	<th>First LFS Version:</th><td>
  <select name="first_lfs">
  <option></option>
  <option value="1.x">1.x</option>
  <option value="1.0">1.0</option>
  <option value="1.1">1.1</option>
  <option value="1.2">1.2</option>
  <option value="1.3">1.3</option>
  <option value="2.x">2.x</option>
  <option value="2.0-beta1">2.0-beta1</option>
  <option value="2.0-beta2">2.0-beta2</option>
  <option value="2.0-pre1">2.0-pre1</option>
  <option value="2.x.x">2.x.x</option>
  <option value="2.1.x">2.1.x</option>
  <option value="2.1.5">2.1.5</option>
  <option value="2.2">2.2</option>
  <option value="2.3.x">2.3.x</option>
  <option value="2.3.1">2.3.1</option>
  <option value="2.3.2">2.3.2</option>
  <option value="2.3.3">2.3.3</option>
  <option value="2.3.4">2.3.4</option>
  <option value="2.3.5">2.3.5</option>
  <option value="2.3.5b">2.3.5b</option>
  <option value="2.3.6">2.3.6</option>
  <option value="2.3.7">2.3.7</option>
  <option value="2.4">2.4</option>
  <option value="2.4.x">2.4.x</option>
  <option value="2.4.1">2.4.1</option>
  <option value="2.4.2">2.4.2</option>
  <option value="2.4.3">2.4.3</option>
  <option value="2.4.4">2.4.4</option>
  <option value="3.0-prex">3.0-prex</option>
  <option value="3.0-pre1">3.0-pre1</option>
  <option value="3.0-pre2">3.0-pre2</option>
  <option value="3.0-pre3">3.0-pre3</option>
  <option value="3.0-pre4">3.0-pre4</option>
  <option value="3.0-rcx">3.0-rcx</option>
  <option value="3.0-rc1">3.0-rc1</option>
  <option value="3.0-rc2">3.0-rc2</option>
  <option value="3.x">3.x</option>
  <option value="3.0">3.0</option>
  <option value="3.1">3.1</option>
  <option value="3.2-rc1">3.2-rc1</option>
  <option value="3.2-rc2">3.2-rc2</option>
  <option value="3.2">3.2</option>
  <option value="3.3">3.3</option>
  <option value="4.x">4.x</option>
  <option value="4.0-rc1">4.0-rc1</option>
  <option value="4.0">4.0</option>
  <option value="4.1">4.1</option>
  <option value="cvs">CVS</option>
  </select></td>
  </tr>
  
  <tr>
  	<th>If CVS, enter CVS date ( <strong>yyyymmdd</strong> ):</th>
  	<td><input type="text" name="cvs_date" size="8" maxlength="8" /></td>
  </tr>
  
  <tr>
  	<th>Sort the list by:</th>
  	<td><select name="order_by">
  		<option value="id">LFS ID</option>
  		<option value="name">Name</option>
  		<option value="first_lfs">First LFS Version</option>
  		</select>
  		<select name="sort_order">
  		<option value="asc">Ascending</option>
  		<option value="desc">Descending</option>
  		</select></td>
  </tr>
  
  <tr>
  	<th>Results per page:</th>
  	<td><select name="increment">
  		<option value="5">5</option>
  		<option value="10">10</option>
  		<option value="25">25</option>
  		<option value="50">50</option>
  		<option value="100">100</option>
  		</select></td>
  </tr>
  
  </tbody>
  </table>
  <p class="submit"><input type="submit" value="Query" /></p>
  </form>
  
  EOF
  }
  
  sub ConnectToDatabase() {
  
  	my $dbase = "mysql";
  	my $db_name ="lfscounter";
  	my $db_host = "belgarath.linuxfromscratch.org";
  	my $db_port = "3306";
  	my $db_user = "lfscounter";
  	my $db_pass = "12lfscounter34";
  
  	my $dsn = "DBI:$dbase:$db_name:$db_host:$db_port";
  	$dbh = DBI->connect($dsn, $db_user, $db_pass, { RaiseError => 1  });
  
  	$dbh->do("create table if not exists $table (id int not null
  				auto_increment, primary key (id), name char(30),
  				first_lfs char(13))");
  }
  
  sub Query {
  
  	my $id = $ch->param('id');
  	my $name = $ch->param('name');
  	my $first_lfs = $ch->param('first_lfs');
  	my $order_by = $ch->param('order_by');
  	if (!$order_by) { $order_by = "id"; }
  	my $sort_order = $ch->param('sort_order');
  	if (!$sort_order) { $sort_order = "asc"; }
  	my $cvs_date = $ch->param('cvs_date');
  
  	my @query_parts;
  
  	my $sth;
  	my $sql_output;
  
  	my $count_method = "count(id)";
  
  	my $sql_send;
  	my $lfs_users = 0;
  
  	my $total;
  
  	my $position = $ch->param('position');
  	if (!$position) { $position = 0; }
  	my $oldposition;
  
  	my $increment = $ch->param('increment');
  	if (!$increment) { $increment = 25; }
  
  	my $first_result;
  	my $last_result;
  
  	my @next_set;
  	my $next_url;
  	my @previous_set;
  	my $previous_url;
  
  	unless (CheckInput("Position", $position, $position_length, 1,
  							$position_regex)) {
  		return;
  	}
  
  	unless (CheckInput("Increment", $increment, $increment_length, 0,
  							$increment_regex)) {
  		return;
  	}
  
  	unless (CheckInput("Order By", $order_by, $order_by_length, 1,
  								$order_by_regex)) {
  		return;
  	}
  
  	unless (CheckInput("Sort Order", $sort_order, $sort_order_length, 1,
  								$sort_order_regex)) {
  		return;
  	}
  
  	if (!$id && !$name && !$first_lfs) {
  
  		$sql_send = "select $count_method from $table order by $order_by";
  		$sth = $dbh->prepare ($sql_send);
  		$sth->execute;
  
  		$sql_output = $sth->fetchrow_hashref();
  		$total = $sql_output->{$count_method};
  
  		$sql_send = "select * from $table order by $order_by $sort_order";
  
  	} elsif (CheckInput("LFS ID", $id, $id_length, 1, $id_regex) &&
  				CheckInput("Name", $name, $name_length, 1,
  								$name_regex) &&
  				CheckInput("First LFS Version", $first_lfs,
  								$first_lfs_length, 1, $first_lfs_regex)) {
  
  		if ($first_lfs eq "cvs") {
  			unless (CheckInput("CVS Date", $cvs_date, $cvs_date_length,
  									1, $cvs_date_regex)) {
  				return;
  			}
  		}
  
  		if ($id) { 
  			push (@query_parts, "id='$id'");
  			push (@next_set, "id=$id");
  		}
  
  		if ($name) {
  			push (@query_parts, "name regexp \"^.*$name.*\$\"");
  			push (@next_set, "name=$name");
  		}
  
  		if ( $first_lfs && ($first_lfs ne "cvs") ) {
  			push (@query_parts, "first_lfs='$first_lfs'");
  			push (@next_set, "first_lfs=$first_lfs");
  
  		} elsif ( ($first_lfs eq "cvs") && $cvs_date ) {
  			push (@query_parts, "first_lfs='$cvs_date'");
  			push (@next_set, "first_lfs=cvs");
  			push (@next_set, "cvs_date=$cvs_date");
  
  		} elsif ( ($first_lfs eq "cvs") && !$cvs_date) {
  			push (@query_parts, "first_lfs regexp \"^[0-9]{8}\$\"");
  		}
  
  		$sql_send = "select $count_method from $table where " .
  			join (" and ", at query_parts). " order by $order_by";
  		$sth = $dbh->prepare ($sql_send);
  		$sth->execute;
  
  		$sql_output = $sth->fetchrow_hashref();
  		$total = $sql_output->{$count_method};
  
  		$sql_send = "select * from $table where " .
  			join (" and ", at query_parts). " order by $order_by $sort_order";
  	}
  
  	if ($sql_send) {	
  
  		$sth = $dbh->prepare("$sql_send limit $position,$increment");
  		$sth->execute;
  
  		print "<table border=\"0\" cellspacing=\"0\"
  			class=\"bodytext\">\n";
  		print "<th align=\"left\">LFS ID</th>
  				<th align=\"left\">Name</th>
  				<th align=\"left\">First LFS
  			version</th>\n";
  		print "<tr><td colspan=\"3\"> </td></tr>\n";
  
  		while ($sql_output = $sth->fetchrow_hashref()) {
  			$lfs_users++;
  			print "<tr>";
  			print "<td>$sql_output->{'id'}</td>";
  			print "<td>$sql_output->{'name'}</td>";
  			print "<td>$sql_output->{'first_lfs'}</td>";
  			print "</tr>\n";
  		}
  
  		print "</tbody>
  </table>\n";
  
  		$first_result = $position + 1;
  		$last_result = $position + $lfs_users;
  
  		$oldposition = $position - $increment;
  		$position = $position + $increment;
  
  		push (@next_set, "query=1");
  		push (@next_set, "order_by=$order_by");
  		push (@next_set, "increment=$increment");
          push (@next_set, "sort_order=$sort_order");
  
  		@previous_set = @next_set;
  		push (@next_set, "position=$position");
  		push (@previous_set, "position=$oldposition");
  
  		print "<p>";
  
  		if ($oldposition >= 0) {
  			$previous_url = join ("&", @previous_set);
  			print "<a href=\"$me?$previous_url\">Previous</a> ";
  		}
  
  		if ($position < $total) {
  			$next_url = join ("&", @next_set);
  			print "<a href=\"$me?$next_url\">Next</a>";
  		}
  
  		print "</p>\n";
  
  		if (!$lfs_users) {
  			print "<p>Sorry, query unsuccessful</p>\n";
  		} else {
  			print "<p>Displaying $first_result - $last_result  out of
  				$total matches</p>\n";
  		}
  
  		print "<p><a href=\"$me\">Back</a></p>\n";
  
  	}		
  }
  
  sub RegisterUser() {
  
  	my $sth;
  	my $sql_output;
  
  	my $match_found = 0;
  
  	my $name = $ch->param('name');
  	my $first_lfs = $ch->param('first_lfs');
  	my $cvs_date = $ch->param('cvs_date');
  
  	my $total;
  
  	unless (CheckInput("Name", $name, $name_length, 0, $name_regex) &&
  			CheckInput("First LFS Version", $first_lfs, $first_lfs_length,
  							0, $first_lfs_regex)) {
  		return;
  	}
  
  	if ($first_lfs eq "cvs") {
  		unless (CheckInput("CVS Date", $cvs_date, $cvs_date_length,
  								0, $cvs_date_regex)) {
  			return;
  		}
  
  		if ($cvs_date < 20010124) {
  			print "<p>Invalid value for <strong>CVS date</strong></p>\n";
  			print "<p>Input string was: <strong>$cvs_date</strong> which is earlier
  					than CVS first became operational at
  					<strong>20010124</strong></p>\n";
  			print "<p><a href=\"$me\">Back</a></p>\n";
  			return;
  		} else {
  		$first_lfs = $cvs_date;
  		}
  	}
  		
  	$sth = $dbh->prepare("select * from $table");
  	$sth->execute;
  
  	while (($sql_output = $sth->fetchrow_hashref()) && !$match_found) {
  			
  		if (lc($name) eq lc($sql_output->{'name'})) { 
  			$match_found = 1;
  			print "<p>You have registered already:</p>\n";
  			print "<table border=\"0\" cellspacing=\"0\"
  				class=\"bodytext\">\n";
  			print "<th align=\"left\">LFS ID</th>
  				<th align=\"left\">Name</th>
  				<th align=\"left\">First LFS version</th>\n";
  			print "<tr><td colspan=\"3\"> </td></tr>\n";
  			print "<tr>";
  			print "<td>$sql_output->{'id'}</td>";
  			print "<td>$sql_output->{'name'}</td>";
  			print "<td>$sql_output->{'first_lfs'}</td>";
  			print "</tr>\n";
  			print "</tbody>
  </table>\n";
  			print "<p><a href=\"$me\">Back</a></p>\n";
  			return;
  		}
  	}
  
  	$dbh->do("insert into $table (name,first_lfs)
  				values ('$name','$first_lfs')");
  
  	$match_found = 0;
  
  	$sth = $dbh->prepare("select * from $table");
  	$sth->execute;
  
  	while (($sql_output = $sth->fetchrow_hashref()) && !$match_found) {
  		if (lc($name) eq lc($sql_output->{'name'})) {
  			$match_found = 1;
  			print "<p>Thanks for registering $name,
  				your LFS ID is: <strong>$sql_output->{'id'}</strong></p>\n";
  		}
  	}
  
  	if (!$match_found) {
  		print "<p>Something went wrong with the
  			registration.</p>\n";
  	}
  
  	print "<p><a href=\"$me\">Back</a></p>\n";
  }
  
  
  
  sub CheckInput {
  
  	my $var_name = shift;
  	my $var_contents = shift;
  	my $max_size = shift;
  	my $allow_null = shift;
  	my $allow_regex = shift;
  
  	if (!$allow_null && !$var_contents) {
  		print "<p>Please enter a value for <strong>$var_name</strong></p>\n";
  		print "<p><a href=\"$me\">Back</a></p>\n";
  		return 0;
  	}
  
  	if ($var_contents) {
  		unless ($var_contents =~ /$allow_regex/) {
  			print "<p>Invalid value for <strong>$var_name</strong></p>\n";
  			print "<p>Input string was: <strong>$var_contents</strong></p>\n";
  			print "which didn't match the following regular
  				expression:<br />\n";
  			print "<strong>$allow_regex</strong></p>\n";
  			print "<p><a href=\"$me\">Back</a></p>\n";
  			return 0;
  		}
  	}
  
  	if (length($var_contents) > $max_size) {
  		print "<p>Maximum length of $max_size for <strong>$var_name</strong>
  			exceeded</p>\n";
  		print "<p>Input string was: <strong>$var_contents</strong></p>\n";
  		print "<p>Input length was: ", length($var_contents), "\n";
  		print "<p><a href=\"$me\">Back</a></p>\n";
  		return 0;
  	}
  
  	return 1;
  }
  
  # Begin main
  
  ConnectToDatabase();
  PrintHTMLHeader();
  
  if (! $ch->param()) {
  	PrintForm(); 
  } else {
  	$register = $ch->param('register');
  	$query = $ch->param('query');
  	if ($register) {
  		RegisterUser();
  	} elsif ($query) {
  		Query();
  	} else {
  		print "<p>Invalid request. Please try again.</p>\n";
  		print "<p><a href=\"$me\">Back</a></p>\n";
  	}
  }
  
  PrintHTMLFooter();
  $dbh->disconnect;
  
  # End main
  
  
  
  1.3       +105 -95   www/test/images/linuxfromscratch.png
  
  	<<Binary file>>
  
  
  1.4       +8 -3      www/test/style/print.css
  
  Index: print.css
  ===================================================================
  RCS file: /home/cvsroot/www/test/style/print.css,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- print.css	25 Jul 2003 01:32:17 -0000	1.3
  +++ print.css	6 Aug 2003 10:57:38 -0000	1.4
  @@ -1,7 +1,7 @@
   /* Standard markup */
   
   body {
  -	font:	10pt "Bitstream Vera Sans", Lucida, luxi, arial, verdana, sans-serif;
  +	font:	10pt "Bitstream Vera Sans", Lucida, arial, verdana, helvetica, sans-serif;
   	background: #fff;
   	color: #000;
   	padding: 0;
  @@ -27,7 +27,7 @@
   	padding: 0.2em 0 0 0;
   	margin: 0;
   	color:  #30a;
  -	font-family: "Trebuchet MS", "Lucida Handwriting", "Arial Narrow", "Bitstream Vera Serif", "Lucida Serif", "Luxi Serif", serif;
  +	font-family: "Trebuchet MS", "Times New Roman", "Bitstream Vera Serif", "Times", serif;
   }
   
   h1 { font-size: 160%; font-family: "Bitstream Vera Sans Mono", "Lucida Console", "Lucida Sans Unicode", "Lucida Sans", "Andale Mono", "Arial", sans-serif;}
  @@ -85,7 +85,12 @@
   
   /* Positional markup */
   
  -#language, #search, #sectionnav, #projectnav, #generalnav  { display:none;}
  +#language, 
  +#search, 
  +#sectionnav, 
  +#projectnav, 
  +#generalnav, 
  +#pagenav  { display:none;}
   
   #header {height: auto;}
   
  
  
  
  1.30      +9 -0      www/test/style/screen.css
  
  Index: screen.css
  ===================================================================
  RCS file: /home/cvsroot/www/test/style/screen.css,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- screen.css	4 Aug 2003 23:24:05 -0000	1.29
  +++ screen.css	6 Aug 2003 10:57:39 -0000	1.30
  @@ -193,6 +193,15 @@
   	display: run-in;
   }
   
  +p.submit {
  +	text-align: center;
  +}
  +
  +table.form th {
  +	width: 30%;
  +	text-align: right;
  +}
  +
   /* Layout styling */
   
   #header {
  
  
  



More information about the website mailing list