<?
	#---------------------------------------------------------------------#
	# This source code is (c)2000 White Pajamas, Inc                      #
	# see http://www.stonekeep.com/license.html for licensing information #
	#---------------------------------------------------------------------#

	#----------------------------------------------------------------------
	# $Id: publicutils.php3,v 1.13 2000/12/20 19:09:21 nclemons Exp $
	#----------------------------------------------------------------------
	
	include "./conf/keystone.conf.default";
	if (file_exists("./conf/keystone.conf")) {
		include "./conf/keystone.conf";
	}

	#
	# functions for use in public slip viewing utilities.
	#
	
	Function SelectBar() {
		Global $_parent, $_status, $sys_server, $publicfile, $curruser, $sys_col;
		echo "\n<!--Beginning of selectbar-->\n";
		echo "\n<tr bgcolor=$sys_col[visitor_hdr] valign=bottom><td bgcolor=#808080 align=center>\n";
		echo "<form method=\"post\" action=\"$publicfile?v_func=select\">\n";
		echo "<input type=submit value=\"Select\">\n";
		echo "<input type=hidden name=\"v_func\" value=\"select\">\n";

		if (Empty($_status)) {
			$_status="O";
		} 

		echo "<select name=_status>\n";
		$q = db_query("select flag,label from status");
		$sel = ($_select == "Any") ? "selected" : "";
		echo "<option value=\"Any\" $sel> Any\n";
		while ($row=db_fetch_array($q)) {
			$sel = ($row[flag] == $_status) ? "selected" : "";
			echo "<option value=\"$row[flag]\" $sel > $row[label]\n";
		}
		echo "</select>";

		echo "slips relating to: \n";
		echo "<select name=\"_parent\">";
		echo "<option value=\"\">Any topic\n";
		# PostgreSQL 6.3.2 requires the type be coerced because it
		# doesn't know whether to coerce the integer to varchar or
		# vice-versa.  This will probably not change in future 
		# versions....
		$qstring = "select "
			. "members.id,members.element,slips.sid,slips.problem "
			. "from slips,members ";
		if ($sys_server == "postgresql") {
			$qstring .= "where int4(members.element) = slips.sid AND ";
		} else {
			$qstring .= "where members.element = slips.sid AND ";
		}
		$qstring .= "members.id = 'quickslips'";

		$qsq = db_query("$qstring");
		if (db_numrows($qsq)) {
			while ($qsqdata = db_fetch_array($qsq)) {
				$sel = ($qsqdata[sid] == $_parent) ? "selected" : "";
				echo "<option value=\"$qsqdata[sid]\" $sel>";
				echo "$qsqdata[sid] - $qsqdata[problem]";
			}
		} else {
			echo "<option value=\"0\">No quickslips defined.";
		}
		echo "</select>";

		if ($curruser) {
			echo "for ";
			echo "<select name=_contact>";
			echo "<option value=\"$curruser\">$curruser</option>";
			echo "<option value=\"Any\">Any contact</option>";
			echo "</select>";
			echo "<input type=\"hidden\" name=\"login\" value=\"$curruser\">";
		}
			
		echo "</form>";
		echo "</td></tr>\n";
		echo "\n<!--End of selectbar-->\n";
	}
	
	Function Breaker($whatstring) {
		echo "\n<!--Beginning of breaker-->\n";
		echo "<tr><td bgcolor=#808080 width=100%>\n";
		echo "$whatstring\n";
		echo "</td></tr>\n";
		echo "\n<!--End of breaker-->\n";
	}
	
	Function LeftMenu() {
		Global $v_func,$sid,$publicfile,$login,$password,$sys_col;
		?>
		<td bgcolor=#80B0C0 width=10% valign=top>
		&nbsp;<p>
		<form method="post" action="<? echo $publicfile ?>">
		To make a new slip entry into Keystone select:
		<input type="hidden" name="v_func" value="addslip">
		<? if ($login) { ?>
		<input type="hidden" name="login" value="<? echo $login ?>">
		<input type="hidden" name="password" value="<? echo $password ?>">
		<? } ?>
		<input type="submit" value="Add a new slip">
			<hr>
		</form>
		<? if ($v_func == "zoom" || $v_func == "postfoll") { ?>
			<form method="post" action="<? echo $publicfile ?>">
			To add a followup to this slip, select: 
			<input type="hidden" name="v_func" value="addfollow">
			<? if ($login) { ?>
			<input type="hidden" name="login" value="<? echo $login ?>">
			<input type="hidden" name="password" value="<? echo $password ?>">
			<? } ?>
			<input type="hidden" name="sid"	value="<? echo $sid?>">
			<input type="submit" value="Add a followup">
			<hr>
			</form>
		<? } ?>
		<form method="post" action="<? echo $publicfile ?>">
		<? if ($login) { ?>
		<input type="hidden" name="login" value="<? echo $login ?>">
		<input type="hidden" name="password" value="<? echo $password ?>">
		<? } ?>
		To return to viewing the general listing of slips, select:
		<input type="submit" value="Browse all slips">
		<hr>
		</form>
		<form method="post" action="index.php3">
		To return to the general login screen for Keystone, select: 
		<input type="submit" value="Return to login">
		</form>
		<hr>
		<form method="post" action="<? echo $publicfile ?>">
		To jump to a specific slip number enter it here:
		<input type="text" name="sid" size=10><br>
		<? if ($login) { ?>
		<input type="hidden" name="login" value="<? echo $login ?>">
		<input type="hidden" name="password" value="<? echo $password ?>">
		<? } ?>
		<input type="hidden" name="v_func" value="zoom"><input type="submit" value="Go!">
		</form>
		</td>
		<?
	}
	
	Function ShowSlips() {
		Global $_status,$_parent,$stnames, $sys_datefmt, $publicfile, $login, $password, $sys_col;
		
		echo "\n<!--Beginning of ShowSlips-->\n";
		$exp1="";
		$exp2="";
		$sep="";
		$wclause="where";
		$and="";
		if (! Empty($_status)) {
			if ($_status != "Any") {
				$exp1 = "status='$_status'";
			}
		}

		if (! Empty($_contact)) {
			if ($_contact != "Any") {
				$exp3 = "contact='$_contact'";
			}
		}
		
		if (! Empty($_parent)) {
			$exp2 = "spid=$_parent";
		}
		
		if ((! Empty($exp1)) and (! Empty($exp2)) and (! Empty($exp2))) {
			$sep = " and ";
		}
		
		if (Empty($_status) or ($_status == "Any")) {
			if (Empty($exp1) and Empty($exp2)) {
				$wclause = "where is_public='$pval'" ;
			} else {
				$and = " and is_public='$pval'";
			}
		}

		if ($login) {
			$and .= " and ctag='$login'";
		}
		
		$qstring = "select * from slips $wclause $exp1 $sep $exp2 $and";

		echo "<tr><td bgcolor=#808080>";
		echo "<table width=100% border=1 cellspacing=1 cellpadding=2>";
#		echo "<tr bgcolor=#909090><td colspan=6>qstring is $qstring</td></tr>";
		echo "<tr bgcolor=$sys_col[visitor_hdr] valign=bottom>";
		echo "<th>Slip ID <br>Number</th>";
		echo "<th>Current Status</th>";
		echo "<th>Current<br>Tech</th>";
		echo "<th>Dates</th>";
		echo "<th>Description of Problem</th>";
		echo "<th>Last<br>Activity</th>";
		echo "</tr>";
		$slips = db_query($qstring);
		$rc = db_numrows($slips);
		$lastresult[0]=0;
		$lastresult[1]="$rc rows selected.";
		while ($sliprow = db_fetch_array($slips)) {
			echo "<tr bgcolor=#cca0a0 valign=top color=#ffffff fgcolor=#ffffff>";
			echo "<td nowrap>";
			if ($login) {
				echo "<table><tr><td>";
				echo "<form method=\"post\" action=\"$publicfile\">";
        echo "<input type=\"hidden\" name=\"login\" value=\"$login\">";
        echo "<input type=\"hidden\" name=\"password\" value=\"$password\">";
        echo "<input type=\"hidden\" name=\"v_func\" value=\"zoom\">";
				echo "<input type=\"hidden\" name=\"sid\" value=\"$sliprow[sid]\">";
				echo "<input type=\"submit\" value=\"$sliprow[sid]\">";
				echo "</td><td>";
				$endform = "</form></td></tr></table>";
			} else {
				echo "<a href=\"$publicfile?sid=$sliprow[sid]&v_func=zoom\">$sliprow[sid]</a>";
				$endform = "";
			}
			# $fh=db_query("select f_sid from followups where f_sid=$sliprow[sid]");
			$fc=$sliprow[num_follows];
			if ($fc > 0) {
				echo "<br>(fol: $fc )";
			}
			echo $endform;
			echo "</td>";
			$sttag=$sliprow[status];
			echo "<td>$stnames[$sttag]</td>";
			if ($sliprow[currtech]) {
				echo "<td>$sliprow[currtech]</td>\n";
			} else {
				echo "<td>&nbsp;</td>\n";
			}
			echo "<td nowrap>Open: " . date("$sys_datefmt",$sliprow[o_date]);
			if ($sliprow[o_tech]) {
				echo " by $sliprow[o_tech]";
			}
			if ($sliprow[c_date] > 0 ) {
				echo "<br>Closed: " . date("$sys_datefmt",$sliprow[c_date]);
				echo " by $sliprow[c_tech]";
			}
			echo "</td>";
			echo "<td>" . htmlspecialchars($sliprow[problem]) . "</td>";
			if (($sliprow[l_activity] <> $sliprow[o_date]) && ($sliprow[l_activity] > 0)) {
				echo "<td nowrap>" . date("$sys_datefmt",$sliprow[l_activity]);
				echo " by $sliprow[l_tech]</td>";
			} else {
				echo "<td></td>";
			}
			echo "</tr>\n";
		}
		echo "</font>";
		echo "</table></td></tr>";
		echo "\n<!--End  of ShowSlips-->\n";
	}
	
	Function SlipZoom($whatslip) {
		Global $stnames,$sys_v_preftext,$sys_datefmt,$sys_closedflag,$login,$password,$publicfile,$sys_col;
		if (! Empty($whatslip)) {
			$wclause = "where sid=$whatslip and is_public='1'";
			if ($login) {
				$wclause .= " and ctag='$login'";
			}
			$sinfo = db_query("select * from slips $wclause");
		} 
		if ( Empty($whatslip) || (db_numrows($sinfo) == 0)) {
			echo "<tr><td bgcolor=#808080 width=100% align=center>\n";
			echo "<p>&nbsp;<p>";
			echo "The slip you have selected either does not exist, or is not available ";
			echo "for public viewing.";
			echo "<p>&nbsp;<p>";
			echo "</td></tr>";
			return;
		}
		echo "<tr align=center><td bgcolor=#808080>\n";
		echo "<table width=100% border=0 cellspacing=0 cellpadding=5>\n";
		echo "<tr bgcolor=#808080 valign=top><td width=50% align=center>";
		echo "<table border=1 cellspacing=1 cellpadding=2 align=center>\n";
		echo "<tr bgcolor=$sys_col[visitor_hdr] valign=bottom>";
		echo "<th>Field</th>";
		echo "<th>Values</th>";
		echo "</tr>\n";
		$q=db_fetch_array($sinfo);
		$rt="<tr bgcolor=#cca0a0 valign=top><td align=right>";
		$ct="</td><td align=left>";
		$rcparms="align=left";
		echo "${rt} Slip ID Number:	${ct}$q[sid]</td></tr>\n";
		$pslipinfo = ($q[spid]==0) ? "None" : $q[spid];
		echo "${rt} Parent slip ID:	${ct}$pslipinfo</td></tr>\n";
		echo "${rt} Open Date:			${ct} ".date("$sys_datefmt",$q[o_date])."</td></tr>\n";
		echo "${rt} Opened by:			${ct} $q[o_tech]</td></tr>\n";
		if ($q[status] == '$sys_closedflag') {
			echo "${rt} Closed on:			${ct} ".date("$sys_datefmt",$q[c_date])."</td></tr>\n";
			echo "${rt} Closed by:			${ct} $q[c_tech]</td></tr>\n";
		}
		$ctechinfo = ($q[currtech]) ? $q[currtech] : "None assigned.";
		echo "${rt} Current Tech:		${ct} $ctechinfo</td></tr>\n";
		$sttxt=$q[status];
		echo "${rt} Status:					${ct} $stnames[$sttxt]</td></tr>\n";
		echo "${rt} Priority:				${ct} $q[priority]</td></tr>\n";
		$ctaginfo = ($q[ctag]) ? $q[ctag] : "No contact.";
		echo "${rt} Contact:				${ct} $ctaginfo</td></tr>\n";
		$grpinfo = ($q[grp]) ? $q[grp] : "No group.";
		echo "${rt} Group:					${ct} $grpinfo</td></tr>\n";
		echo "${rt} Last Activity		${ct} ";
		if ($q[l_activity] == 0) {
			echo "None since opening.";
		} else {
			echo date("$sys_datefmt",$q[l_activity])."</td></tr>\n";
		}
		echo "${rt} Last Activity by${ct} $q[l_tech]</td></tr>\n";
		
		echo "</table></td>\n";
		
		echo "<td width=50% align=left>";
		echo "<table border=1 cellspacing=1 cellpadding=2 align=center width=100%>";
		echo "<tr bgcolor=$sys_col[visitor_hdr]><td align=left><b>Problem</td></tr>";
		echo "<tr bgcolor=#cca0a0><td>". htmlspecialchars($q[problem]) . "</td></tr>";
		echo "</table><p>";
		echo "<table border=1 cellspacing=1 cellpadding=2 align=center width=100%>";
		echo "<tr bgcolor=$sys_col[visitor_hdr]><td align=left><b>Summary</td></tr>";
		echo "<tr bgcolor=#cca0a0><td>";
		echo ereg_replace("\n","<br>",StripSlashes(htmlspecialchars($q[summary])));
		echo "</table></td></tr>";
		echo "</table>";
		
		$f=db_query("select f_date,f_tech,f_text,f_seq from followups where f_sid=$whatslip and f_public=1 order by f_seq");
		if (db_numrows($f) > 0) {
			echo "&nbsp;<p>";
			echo "<table border=1 cellspacing=1 cellpadding=2 align=center width=80%>\n";
			echo "<tr bgcolor=$sys_col[visitor_hdr] valign=bottom>\n";
			echo "<th>Date</th><th>Technician</th><th>Text</th>\n";
			echo "</tr>";
			while ($finfo=db_fetch_array($f)) {
				echo "<tr bgcolor=#cca0a0 valign=top><td>";
				echo date("$sys_datefmt",$finfo[f_date]);
				echo "</td>";
				echo "<td>";
				echo $finfo[f_tech];
				if ($finfo[f_tech] == "ANONYMOUS") {
					echo "<br>(This followup was entered via the visitor web page.)";
				}
				echo "</td>";
				$txt = htmlspecialchars($finfo[f_text]);
				echo "<td>";
				echo ($sys_v_preftext) ? "<pre>" : "";
				echo ereg_replace("\n","<br>",stripslashes(htmlspecialchars($finfo[f_text])));
				echo "</pre></td>";
				echo "</tr>";
			}
			echo "</table>";
		}
		echo "<p>&nbsp;";

		# $q contains the current slip.
		$cquery = db_query("select * from slips where spid=$whatslip and is_public='1'");
		if (db_numrows($cquery)) {
			echo "<table border=1 cellspacing=1 cellpadding=2 align=center width=100%>";
			echo "<tr bgcolor=$sys_col[visitor_hdr]><td align=left colspan=6><b>Children</td></tr>";
			while ($info = db_fetch_array($cquery)) {
				echo "<tr bgcolor=#cca0a0 valign=top color=#ffffff fgcolor=#ffffff>";
				echo "<td nowrap><a href=\"$publicfile?sid=$info[sid]&v_func=zoom\">$info[sid]</a>";
				# $fh=db_query("select f_sid from followups where f_sid=$info[sid]");
				$fc=$info[num_follows];
				if ($fc > 0) {
					echo "<br>(fol: $fc )";
				}
				echo "</td>";
				$sttag=$info[status];
				echo "<td>$stnames[$sttag]</td>";
				echo "<td>$info[currtech]</td>\n";
				echo "<td nowrap>Open: " . date("$sys_datefmt",$info[o_date]);
				if ($info[o_tech]) {
					echo "<br>by $info[o_tech]";
				}
				if ($info[c_date] > 0 ) {
					echo "<br>Closed: " . date("$sys_datefmt",$info[c_date]);
					echo "<br>by $info[c_tech]";
				}
				echo "</td>";
				echo "<td>" . htmlspecialchars($info[problem]) . "</td>";
				if (($info[l_activity] <> $info[o_date]) && ($info[l_activity] > 0)) {
					echo "<td nowrap>" . date("$sys_datefmt",$info[l_activity]);
					echo "<br>by $info[l_tech]</td>";
				} else {
					echo "<td></td>";
				}
				echo "</tr>\n";
			}
			echo "</font>";
			echo "</table></td></tr>";
		}
	}
	
	Function AddForm() {
		Global $sys_usequickslips, $sys_server, $login, $publicfile, $password;
		echo "<tr><td bgcolor=#808080 width=100% align=center>\n";
		echo "<h3>Please note that public slips entered into this form<br>";
		echo "will not be immediately available for browsing until reviewed.</p>&nbsp;";
		echo "<form method=\"post\" action=\"$publicfile\">\n";
	 	if ($login) {
			echo "<input type=\"hidden\" name=\"login\" value=\"$login\">";
			echo "<input type=\"hidden\" name=\"password\" value=\"$password\">";
			echo "<input type=hidden name=_contact value=\"$login\">";
		}
		echo "</td></tr>";
		echo "<tr><td bgcolor=#808080 align=center>";
		echo "<table border=1 cellspacing=5 cellpadding=5>";
		if (! $login) {
			echo "<tr bgcolor=#a0a0a0><td align=right>";
			echo "Enter your e-mail address</td>";
			# FIXME: needs maxsize based on database query
			echo "<td><input name=_contact size=40></td></tr>";
		}
		echo "<tr bgcolor=#a0a0a0><td>Select which category this slip belongs to.</td>";
		echo "<td>";
		echo "<select name=\"_parent\">";
		echo "<option value=\"0\">Select...\n";
		if ($sys_usequickslips) {
			$qstring = "select "
				. "members.id,members.element,slips.sid,slips.problem "
				. "from slips,members ";
			if ($sys_server == "postgresql") {
				$qstring .= "where int4(members.element) = slips.sid AND ";
			} else {
				$qstring .= "where members.element = slips.sid AND ";
			}
			$qstring .= "members.id = 'quickslips'";
		} else {
			$qstring = "select sid,problem from slips where is_public='1' and spid=0";
		}
		$q = db_query($qstring);
		while ($row=db_fetch_array($q)) {
			$sel = ($row[sid] == $_parent) ? "selected" : "";
			echo "<option value=\"$row[sid]\" $sel> $row[problem]\n";
		}
		echo "</select>";
		echo "</td></tr>";
		
		echo "<tr bgcolor=#a0a0a0><td align=right>A one-line description</td>";
		# FIXME: needs maxsize based on database query
		echo "<td><input name=_problem size=60></td></tr>";
		echo "<tr  bgcolor=#a0a0a0 valign=top><td align=right>Details</td>";
		echo "<td><textarea rows=20 cols=50 name=_summary wrap=soft></textarea></td></tr>";
		echo "<tr bgcolor=#A0A0A0><td colspan=2 align=center>";
		echo "<input type=hidden name=v_func value=postit>";
		echo "<input type=submit value=\"Submit this slip\">";
		echo "</td></tr></form>";
		
		echo "</table>";
		
	}

	Function AddFollow($whatslip) {
		Global $sys_v_emailanyone,$sys_datefmt,$REMOTE_HOST,$login,$publicfile,$password;

		# Gotta retrieve the info on that slip...
		$sq = db_query("select * from slips where sid=$whatslip");
		$sinfo = db_fetch_array($sq);
		?>
			<tr valign=top><td bgcolor=#808080>
			<table width=100% bgcolor=#bbbbbb cellspacing=2>
			<form method="post" action="<? echo $publicfile ?>">
			<input type=hidden name="v_func" value="postfoll">
			<? if ($login) { ?>
			<input type="hidden" name="login" value="<? echo $login ?>">
			<input type="hidden" name="password" value="<? echo $password ?>">
			<?
			$contq = db_query("select email from contacts where tag='$login'");
			$continfo = db_fetch_array($contq);
			?>
			<input type=hidden name="f_tech" value="<? echo $continfo[email]?>"><br>
			<? } ?>
			<input type=hidden name="sid" value="<? echo $whatslip ?>">
			<tr valign=top>
				<td align=center colspan=2>
		 			Add a followup to slip <? echo $whatslip ?><br>
					( <? echo date("$sys_datefmt",time()) ?> )<br>
				</td>
			</tr>
			<tr bgcolor=#bbbbbb valign=top>
				<td bgcolor=#808080>
				<? if (! $login) { ?>
					<i>Your Email Address:</i><br>
					<input type=text name="f_tech" size=40 value="@<? echo $REMOTE_HOST?>"><br>
				<? } ?>
					<i>Followup Text:</i><br>
					<textarea name="f_text" rows=10 cols=70 wrap="soft"></textarea>
				</td>
				<td bgcolor=#808080 valign=center>
					<i>Followup to be available for public viewing?</i><br>
					<input type="radio" name="f_public" value="1" checked> Public <br>
					<input type="radio" name="f_public" value="0"> Private
					<hr>
					<i>Send email update to...</i><br>
					<input type=checkbox name=m_open value=N>Opened by<br>
					<input type=checkbox name=m_currtech value=N>Current Tech<br>
					<? if ($sys_v_emailanyone) { ?>
					<i>Or type in an address...</i><br>
					<input type=text name=m_other size=20><br>
					<? } ?>
				</td>
			</tr>
			<tr>
				<td colspan=2>
					<table width=100%>
						<tr bgcolor=#bbbbbb valign=top>
							<td>&nbsp;</td>
							<td bgcolor=#808080 valign=top colspan=2 align=center>
								<input type="submit" value="Post Followup">
							</td>
							<td>&nbsp;</td>
						</tr>
					</table>
				</td>
			</tr>
			</table>
		<?
	}

	
	Function PostSlip() {
		Global $_parent,$_contact,$_problem,$_summary,$sys_defpublic,$login,$sys_notify,$publicfile,$sys_url,$sys_col;
		$p_contact = addslashes($_contact);
		$p_problem = addslashes($_problem);
		$p_summary = addslashes($_summary);
		$p_now			=	time();
#		$qstring="insert into slips (spid,o_date,status,priority,o_tech,problem,summary,is_public,ctag) values ($_parent,$p_now,'U',9,'$p_contact','$p_problem','$p_summary','0','ANONYMOUS')";
		if ($login) {
			$contactreference = $login;
		} else {
			$contactreference = "ANONYMOUS";
		}
		$qstring="insert into slips (spid,o_date,status,priority,o_tech,problem,summary,is_public,l_activity,l_tech,ctag) values ($_parent,$p_now,'U',9,'$p_contact','$p_problem','$p_summary','$sys_defpublic','$p_now','$p_contact','$contactreference')";   
		$qhandle = db_query($qstring);
		$count = db_affected_rows($qhandle);
		$newsid = db_insertid($qhandle);
		RecalcSlip($_parent);
		echo "<tr><td bgcolor=#808080 width=100% align=center>\n";
		if ($count > 0) {
			echo "Thank you for your submission.<br>";
			echo "Your Slip ID is <b>$newsid</b><br>";
			echo "Use this number at a later date to check on the status of this entry.";
			if ("$sys_notify") {
				$m_other = "$sys_notify";
				$sid = $newsid;
				$f_process="sendmail";
				$m_incpriv = 1;
				include "./genmail.php3";
			}
		} else {
			echo "An error occured during the update.  Sorry, please try again later.";
		}
		echo "<br><a href=\"$publicfile\">Return to Browsing</a>";
	}

	Function PostFup($whatslip) {
		Global $f_public,$f_sid,$f_text,$f_tech,$sys_notify,$sys_url,$sys_datefmt,$REMOTE_HOST,$login;
		#
		# Much of this is lifted right from postfoll.php3.
		#

		$highseq = CalcHighSeq($whatslip) + 1 ;

		$f_date=time();
		$f_text=addslashes($f_text);
		$remotehost = $REMOTE_HOST ? "[$REMOTE_HOST]" : "";
		$whoposted = $login ? "CONTACT" : "ANONYMOUS";
		$f_text="(Comment from: $f_tech $remotehost)\n${f_text}";
		$flist = "f_sid,f_date,f_tech,f_text,f_seq,f_public";
		$vlist	=	"$whatslip,$f_date,'$whoposted','$f_text',$highseq,$f_public";
		$result = db_query("insert into followups ($flist) values ($vlist)");
		$lastresult[1]= "Added followup number $highseq to Slip # $whatslip.";

		# make sure the Last Activity column is updated showing the anon post.
		$sresult = db_query("update slips set l_tech='$f_tech',l_activity=$f_date where sid=$whatslip");

		# Update the counters.
		RecalcSlip($whatslip);
		
		# Generate mail if appropriate..
		
		if ("$sys_notify") {
			$m_other = "$sys_notify";
		}
		$sid=$whatslip;
		$f_process="sendmail";
		include "./genmail.php3";
		SlipZoom($whatslip);
	}
