[Gnucash-changes] more comments added and css link corrected

Neil Williams codehelp at cvs.gnucash.org
Sun May 9 12:54:38 EDT 2004


Log Message:
-----------
more comments added and css link corrected

Modified Files:
--------------
    mail-search:
        search-tips.html
        search.php

Revision Data
-------------
Index: search.php
===================================================================
RCS file: /home/cvs/cvsroot/mail-search/search.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -Lsearch.php -Lsearch.php -u -r1.9 -r1.10
--- search.php
+++ search.php
@@ -1,12 +1,12 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
 <html>
 <head>
-<link rel="stylesheet" href="/en/gnucash.css" type="text/css">
+<link rel="stylesheet" href="en/gnucash.css" type="text/css">
 <link rel="stylesheet" href="search.css" type="text/css">
 <link rel="icon" href="favicon.ico" type="image/x-icon">
 <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
 <meta name="author" content="Neil Williams">
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.gnucash.org/en/rss-feed.phtml">
 <title>GnuCash - Mailing List Archive Search</title>
 </head>
@@ -163,7 +163,8 @@
 a few hits per archive can cause timeout errors in PHP.
 Paginate these results according to every $resourcelimit number of files
 accessed - this is a calibration of server performance.
-Experimentation is recommended.  */
+Experimentation is recommended.
+*/
 $resourcelimit = 700;
 ########### end configuration #################
 
@@ -197,10 +198,12 @@
 $startmonth =	$_GET{"month"};   /* uses current month if empty */
 $startyear =	$_GET{"year"};    /* uses current year if empty */
 $period =	$_GET{"span"};    /* uses default_length if empty */
-$pager =	$_GET{"page"};
-/** useabstract - whether to use the quicker list or the longer abstract mode*/
+$pager =	$_GET{"page"};	  /* empty by default */
+/* useabstract - whether to use the quicker list or the longer abstract mode*/
 $useabstract = 	$_GET{"abstract"}; /* default is not to use abtracts */
 if($useabstract == "on") { $useabstract = 1; }
+$self = $_SERVER["PHP_SELF"];
+if(!$self) { $self = "search.php"; }
 
 /* List names and start dates
 These are not likely to change but the two arrays MUST be the same length
@@ -221,7 +224,8 @@
 value in $list if there is no match, use default instead.
 Prevents use of ../../../../etc/passwd etc.
 NOTE: This currently also prevents searches on more than one allowed archive,
-even though the engine itself can cope with more than one archive.
+by only checking for one match even though the engine itself can cope with
+more than one archive.
 */
 $assert_list = true;
 foreach($list_identities as $check) {
@@ -236,9 +240,9 @@
 $c = 0;
 
 /* build $lists from list_starts and list_identities
-to avoid problems with lists that start on the same day, the second value
+To avoid problems with lists that start on the same day, the second value
 in the time function is incremented. The second or minute values are
-not used in any part of the script, so a potential 3,600 lists can be
+not used in any part of the script, so a potential 3,599 lists can be
 handled in this function. The rest of the script/server will fail first!
 */
 
@@ -290,13 +294,8 @@
 if($termstring == "") {
 	print "<h1>Search the GnuCash mailing list archives</h1>";
 	print "<p><a href=\"search-tips.html\">Search tips</a> </p>\n";
-	/* get current month and year */
-	$month = gmdate("n");
-	$year = gmdate("Y");
-	$end = mktime(1,1,1,$month,1,$year);
-	print "<form method=\"get\" action=\"$PHP_SELF\" enctype=\"application/x-www-form-urlencoded\">\n";
+	print "<form method=\"get\" action=\"$self\" enctype=\"application/x-www-form-urlencoded\">\n";
 ?>
-
 <div>
 Text to find:
 <input type="text" name="terms" size="40"><br>
@@ -312,28 +311,24 @@
 	print "</select>\n";
 	print "<br>Select the month and the year to begin searching: ";
 	print "<select name=\"month\" size=\"1\">\n";
-	$month = 1;
 	$cur_month = gmdate("n");
 	$year = gmdate("Y");
-	$output = mktime(1,1,1,$month,1,$year);
 	/* To avoid problems with checking translated text values, use digits for month */
 	for($c=1;$c<13;$c++) {
 		$output = mktime(1,1,1,$c,1,$year);
 		print "<option value=\"";
 		print gmdate("n",$output);
-		if($c == $cur_month) {
-			print "\" selected>";
-		}
-		else {
-			print "\">";
-		}
+		if($c == $cur_month) { print "\" selected>"; }
+		else { print "\">"; }
 		print gmdate("M",$output);
 		print "</option>\n";
 	}
 	print "</select>\n";
 	print "Year: ";
 	$dates = array_keys($lists);
+	/* sort in ascending order, oldest first */
 	sort($dates);
+	/* how many years to offer */
 	$limit = $year - gmdate("Y",$dates[0]) + 1;
 	print "<select name=\"year\" size=\"1\">\n";
 	for($c=0;$c<$limit;$c++) {
@@ -359,9 +354,7 @@
 	}
 	print "</select> (1 = only search one archive.)\n";
 ?>
-
 </div>
-
 <div><br>
 <b>Show abstracts? </b><input type="checkbox" name="abstract" checked><br>
 Clear the checkbox for a faster search.<br><br>
@@ -418,8 +411,8 @@
 $pagerspan =	$period;
 
 if($period > 1) {
-	$period--;
-	if($startmonth < $period) {
+	$period--; /* start month already included */
+	if($startmonth < $period) { /* cope with year-end during search period */
 		$endmonth = $startmonth + 12 - $period;
 		$endyear = $startyear -1;
 	}
@@ -436,6 +429,7 @@
 $check = mktime(1,1,2,$endmonth,1,$endyear);
 while(list($key,$value) = each($lists)) {
 	if ($value == $list) {
+		/* if end month is prior to list start, use list start date instead */
 		if($key > $check) { $check = $key; }
 	}
 }
@@ -468,14 +462,12 @@
 
 $start = array();
 /* this is the actual search engine - all the rest is error handling! */
-// FIXME: accept more than one archive using a time period?
+
 foreach($monthlist as $foldername) {
 	$temp = $list . $foldername;
 	array_push($start, $temp);
 }
 
-$self = $_SERVER["PHP_SELF"];
-if(!$self) { $self = "search.php"; }
 $dirlist = array();
 $paging = array();
 
@@ -538,13 +530,13 @@
 $pagercount = count($dirlist);
 
 if($pager > 0) {
-	$pager = sprintf("%d",$pager);
+	$pager = sprintf("%d",$pager); /* lose the leading zeroes */
 }
 $paging = array_slice($dirlist, $pager, $resourcelimit);
-$more = TRUE;
+$more = TRUE; /* determines if further pages need to be offered */
 if ((count($paging) + $pager) == count($dirlist)) { $more = FALSE; }
 $hits = 0;
-$tally = 0;
+$tally = 0; /* number of files accessed so far */
 
 while((list(,$file) = each ($paging))&&($hits < $perpage)) {
 	$snip = array();
@@ -557,7 +549,7 @@
 		$title = ereg_replace("&amp;amp;","&amp;",$title);
 	}
 	if(eregi("title=\"([- a-z0-9\,\.:\*\&\%\^\$\!]*)\"\;",$content,$tag)) {
-		$title = htmlspecialchars($tag[1]); /*remove quote marks around message titles*/
+		$title = htmlspecialchars($tag[1]); /* remove quote marks around message titles */
 	}
 	$html = "";
 	$abstract = "";
@@ -566,9 +558,9 @@
 	$html = preg_replace("/&lt;/","",$html);
 	$content = preg_replace("/<a.*\/a>/i","",$html);
 	$snip = array();
-	eregi("<!--beginarticle-->(.*)<!--endarticle-->",$content,$snip);
+	eregi("<!--beginarticle-->(.*)<!--endarticle-->",$content,$snip); /* ignore message headers */
 	if($snip[1]) { $content = $snip[1]; }
-	if($boolean == "AND") {
+	if($boolean == "AND") { /* all terms must match */
 		for($i=0;$i<$termscount;$i++) {
 			if($case == "sensitive") {
 				if(ereg($terms[$i],$content)) { $d++; }
@@ -584,7 +576,7 @@
 			continue;
 		}
 	}
-	if($boolean == "OR") {
+	if($boolean == "OR") { /* only search until a term matches */
 		if($case == "sensitive") {
 			for($i=0;$i<$termscount;$i++) {
 				if(ereg($terms[$i],$content)) {
@@ -619,9 +611,7 @@
 /* Search engine has finished, output results */
 print "<h1>Search results</h1>";
 if($useabstract) {
-	print "<p>";
-	print "Archive messages are shown with a short abstract.";
-	print " </p>";
+	print "<p>Archive messages are shown with a short abstract.</p>";
 }
 
 if(($item == 0)||($item > 1)) {
@@ -638,24 +628,24 @@
 */
 if($more == TRUE) {
 	$pagercount = ($hits/$tally)*$pagercount;
-	$pagercount = sprintf("%d",$pagercount);
+	$pagercount = sprintf("%d",$pagercount); /* lose the decimal places */
 }
 
 $tally += $pager;
-
+/* show link to further pages if necessary */
 if($more == TRUE) {
-	print "<p><a href=\"$self?terms=$termlist&amp;month=$pagermonth&amp;year=$pageryear";
+	print "\n<p><a href=\"$self?terms=$termlist&amp;month=$pagermonth&amp;year=$pageryear";
 	print "&amp;archive=$pagerlist&amp;boolean=$boolean&amp;case=$case";
 	if($useabstract) { print "&amp;abstract=on"; }
 	else { print "&amp;abstract="; }
 	print "&amp;span=$pagerspan&amp;page=$tally";
-	print "\">Next page</a> of upto $perpage of approximately $pagercount results.<br>\n";
-	print "Total number of messages to search: $totalcount\n";
+	print "\">Next page</a>\n of upto $perpage of approximately $pagercount results.<br>\n";
+	print "Total number of messages to search: $totalcount\n</p>";
 }
 else {
 	print "<p>End of search.</p>\n";
 }
-print "</p>\n<p>Search terms: <b>$termstring</b><br>\n";
+print "<p>Search terms: <b>$termstring</b><br>\n";
 print "Case <b>$case</b></p>\n";
 print "<p><a href=\"$self\">New Search</a> </p>\n";
 print "<p>Archives searched:<br>\n";
Index: search-tips.html
===================================================================
RCS file: /home/cvs/cvsroot/mail-search/search-tips.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lsearch-tips.html -Lsearch-tips.html -u -r1.5 -r1.6
--- search-tips.html
+++ search-tips.html
@@ -6,7 +6,7 @@
 <link rel="icon" href="favicon.ico" type="image/x-icon">
 <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
 <meta name="author" content="Neil Williams">
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title>GnuCash - Archive search tips</title>
 </head>
 <body>


More information about the Gnucash-changes mailing list