<?php
# this script requires previously import of func.inc and menu.inc

#### pnum2par converts (x.x.x) to 00000x000x000x# etc. and appends $new as 0000
function pnum2par( $pnum, $new ){
	if( empty( $pnum ) || $pnum == "()" ) return "";
	if( substr( $pnum, 0, 1 ) == "(" ) $pnum = substr( $pnum, 1 );
	$i = strlen( $pnum ) - 1;
	if( substr( $pnum, $i ) == ")" ) $pnum = substr( $pnum, 0, $i );
	$tok = strtok( $pnum, "." );
	if( $tok ) $res = fill( $tok, 6 );
	while( $tok ){
		$tok = strtok( "." );
		if( $tok ) $res .= fill( $tok, 4 );
	}
	if( $new > 0 ) $res .= fill( $new, 4 );
	return $res."#";
}

#### par2pnum converts 00000x000x000x# to x.x.x etc.
function par2pnum( $ps ){
	if( !strpos( $ps, "#" )) return "";
	$pnum = fmt( substr( $ps, 0, 6 ));
	for( $i = 6, $j = 1; substr( $ps, $i, 1 ) <> "#"; $i += 4 ) {
		$pnum .= ".".fmt( substr( $ps, $i, 4 ));
		$j++;
	}	
	return $pnum;
}

#### strip all tags except <br>, <b>, <i>, <font color='*'>, <a href='*'>
function save_html( $txt ){
	$c1 = chr( 207 );
	$c2 = chr( 208 );
	$txt = str_replace( $c1, '', $txt );
	$txt = str_replace( $c2, '', $txt );
	$txt = eregi_replace( '<br>', $c1."br$c2", $txt );
	$txt = eregi_replace( '<b>', $c1."b$c2", $txt );
	$txt = eregi_replace( '</b>', $c1."/b$c2", $txt );
	$txt = eregi_replace( '<i>', $c1."i$c2", $txt );
	$txt = eregi_replace( '</i>', $c1."/i$c2", $txt );
	$txt = eregi_replace( '<font color=([[:alnum:]|"|\'|#]+)>', $c1."font color=\\1$c2", $txt );
	$txt = eregi_replace( '</font>', $c1."/font$c2", $txt );
#	$txt = eregi_replace( '<a href=([[:alnum:]|"|\'|/|#|-|_|:|.]+)>', $c1."a href=\\1$c2", $txt );
	$txt = eregi_replace( '<a href=([^>]+)>([^<]+)</a>', $c1."a href=\\1$c2\\2$c1/a$c2", $txt );
#	$txt = eregi_replace( '</a>', $c1."/a$c2", $txt );
	$txt = strip_tags( $txt );
	$txt = str_replace( $c1, '<', $txt );
	$txt = str_replace( $c2, '>', $txt );
	return( $txt );
}

#### formats string using simple commands #=<br>, !=<b>, %=<i>, *=red, >=link
function html_format( $txt ){
	$arr = explode( ' ', $txt );
	$r = '';
	while( list( $k, $t ) = each( $arr )){
		if( !empty( $t )) {
			$s1 = substr( $t, 1, 1 );	# second char
			$sn = substr( $t, 1 );		# string except first char
			switch( substr( $t, 0, 1 )){	# first char
			case '#':
				if( empty( $sn )) $r .= '<br>';
				if( $sn == '#' ) $r .= '<br><br>';
			break;
			case '!':
				$r .= "<b>$sn</b> ";
			break;
			case '%':
				$r .= "<i>$sn</i> ";
			break;
			case '*':
				$r .= "<font color='red'>$sn</font> ";
			break;
			case '>':
				$p = strpos( $sn, '|' );
				$s1 = $sn;
				if( $p ) {
					$s1 = substr( $sn, 0, $p );
					$s2 = substr( $sn, $p+1 );
				}
				if( $p && !empty( $s2 )) {
					$r .= "<a href='$s1'>$s2</a> ";
				} else {
					$r .= "<a href='$s1'>$s1</a> ";
				}
			break;
			default:
				$r .= "$t ";
			}
		}
	}
	$r = str_replace( '</b> <b>', ' ', $r );
	$r = str_replace( '</i> <i>', ' ', $r );
	$r = str_replace( "</font> <font color='red'>", ' ', $r );
	return( $r );
}

#### inserts new lines add word ends at the nearest blank 
#### from string part of length $l
function insert_nl( $str, $l, $c ){
	$str = eregi_replace( '<br>', "\n", $str );
	$k = 0;
	$s = '';
	if( $c ) $l -= 2;
	while( !empty( $str ) && ( $k++ < 1000 )){
		$i = $l;
		if( strlen( $str ) > $l ){
			$i = strpos( $str, "\n" );	# test existing newlines
			if(( $i > $l ) || ( $i == 0 )){
				$i = $l;
				while(( $i > 0 ) && ( substr( $str, $i, 1 ) <> ' ')) $i--;
			}
			if( $i == 0 ){
				$i = $l;
				while(( $i < ( $l*3 )) && ( substr( $str, $i, 1 ) <> ' ')) $i++;
			}
		}	
		if( $i == 0 ) $i = $l + 1;
		if( $c ) $s .= '> ';
		$s .= substr( $str, 0, $i )."\n";
		$str = substr( $str, ++$i );
	}
	return $s;
}

#### showtext displays the basetext
#### title, maintainer and status are only shown, if show_head is set
function showtext( $proj_id, $vers_id, $show_head ){

	# global vars from menu.inc etc.
	global $prt, $xid, $_fontbulk, $_fontinpt, $_fonthdln, $_bg5, $_fg3, $_fg4, $_fg5, $_x, $fn, $ln, $em, $hd,
	$_ini, $_act, $lang, $ot_maint, $domain, $fqdomain, $chg, $par, $comment, $action, $PHP_SELF;

	$t = getmsg( 22, $lang );

	if( $action == 'ascii' ){

		if( !$id = mysql_query( "select headln, text from paragraph
			where proj_id = $proj_id and vers_id = $vers_id
			and length( parastr ) < 8 order by parastr" )) {
			echo "Error 1:".mysql_errno().": ".mysql_error();
			exit;
		}
		while( $row = mysql_fetch_array( $id )) {
			$headln = $row[ "headln" ];
			if( !empty( $headln )) {
				$headln = str_replace( '&', '&amp;', $headln );
				$headln = str_replace( '<', '&lt;', $headln );
				$headln = str_replace( '>', '&gt;', $headln );
				echo "<p>$headln</p>\n\n";
			}
			$text = $row[ "text" ];
			$text = str_replace( '&', '&amp;', $text );
			$text = str_replace( '<', '&lt;', $text );
			$text = str_replace( '>', '&gt;', $text );
			$text = insert_nl( $text, 80, FALSE );
			echo "<p>$text</p>\n";
		}
		exit;
	}

	###################
	# making comments #
	###################

	# was a comment previously made?
	if( !empty( $comment )){
		$comment = str_replace( chr(13).chr(10), " ", $comment );
		$comment = str_replace( chr(10), " ", $comment );
		$comment = stripslashes( $comment );
		$comment = trim( save_html( html_format( $comment )));
	}

	# get user for insert, delete, update comment
	if(( !empty( $par ) && !empty( $comment )) || ( !empty( $chg ) && !empty( $em ))){
		if( !empty( $em )){
			if( !$id = mysql_query( "select memb_id, last_n, first_n
				from member where email = '$em'" )) {
				echo "Error 9: ".mysql_errno().": ".mysql_error();
				exit;
			};
			if( $row = mysql_fetch_array( $id )) {
				$mid = $row[ "memb_id" ];
				$fn = $row[ "first_n" ];
				$ln = $row[ "last_n" ];
			}
		}
		else {
			$em = "$t[0]@$domain";
		}
		if( empty( $fn ) && empty( $ln )){
			$fn = $t[1];
			$ln = $t[2];
		}
		if( empty( $fn )) $fn = "??";
		if( empty( $ln )) $ln = "??";
		if( empty( $mid )) $mid = 0;
	}

	# check if comment is sent again
	if( !empty( $par ) && !empty( $comment )){
		$i = 1;
		$pstr1 = pnum2par( $par, $i );		# first possible comment
		$pstr2 = pnum2par( $par, 9999 );	# last possible comment
		if( !$id = mysql_query( "select max( parastr ) as maxpstr
			from paragraph where proj_id = $proj_id and vers_id = $vers_id
			and parastr between '$pstr1' and '$pstr2'" )) {
			echo "Error 10: ".mysql_errno().": ".mysql_error();
			exit;
		};
		if( !$row = mysql_fetch_array( $id )) {
			$i = 0;
		} else {
			$pstr1 = $row[ 'maxpstr' ];
			$pstr2 = pnum2par( $pstr1, 0 );
			$i = (int) substr( $pstr2, -5, 4 );
		}
		if( !$id = mysql_query( "select headln, text 
			from paragraph where proj_id = $proj_id
			and vers_id = $vers_id and parastr = '$pstr1'" )) {
			echo "Error 11: ".mysql_errno().": ".mysql_error();
			exit;
		};
		if( $row = mysql_fetch_array( $id ) &&
			( $hd == $row[ 'headln' ]) && ( $comment == $row[ 'text' ])){
				$par = ''; $comment = '';
		}
	}
	$comment = addslashes( $comment );

	# user wants to insert a new comment
	if( !empty( $par ) && !empty( $comment )){
		$i += 1;

		eval( "\$x = \"$t[3]\";" );
		$txt = "$x:\n\n";
		$txt .= 'http://'.$fqdomain.$PHP_SELF."#$par\n> ($par)\n";

		$parastr = pnum2par( $par, 0 );	# referenced paragraph
		if( !$id = mysql_query( "select headln, text 
			from paragraph where proj_id = $proj_id
			and vers_id = $vers_id and parastr = '$parastr'" )) {
			echo "Error 13: ".mysql_errno().": ".mysql_error();
			exit;
		};
		if( !$row = mysql_fetch_array( $id )) {
			echo "Error 14: no_rows_selected";
			exit;
		}
		$txt .= insert_nl( strip_tags( eregi_replace( "<li>", "- ", $row[ "text" ])), 74, TRUE );
		$title = strip_tags( $row[ "headln" ]);

		if( !empty( $title )){
			if( empty( $hd )){
				$hd = $title;		# web input first!
				if( substr( $hd, 0, 3 ) != 'Re:' ) $hd = 'Re: '.$hd;
			}
		}
		$hd = trim( strip_tags( $hd ));

		$parastr = pnum2par( $par, $i );	# convert and append
		$send_by = dt_de( date( "Y/m/d H:i" )).", ";
		$send_by .= "<a href=\"mailto:$em\">$fn $ln</a>";

		while( !mysql_query( "insert into paragraph values(
			$proj_id, $vers_id, '$parastr', now(), 
			'$send_by', '$hd', '$comment' )" )){
			if(( mysql_errno() == 1062 ) && ( $i < 10000 )){
				$i++;
				$parastr = pnum2par( $par, $i );
			}
			else {
				echo "Error 16: ".mysql_errno().": ".mysql_error();
				exit;
			}
		}
		$par = par2pnum( $parastr );		

		$txt .= "\n$t[4]:\nhttp://";
		$txt .= $fqdomain.$PHP_SELF."#$par\n($par)\n";
		$buf = insert_nl( $comment, 74, FALSE );
#		$lst = strtolower($ta)."@$domain";
#		$hdr = "From: $em\nReply-To: $lst\nX-Mailer: PHP/".phpversion();
		if( !empty( $hd )){
			$par = $hd;
		} else {
			$par = "$t[5] $par";
		}

		# insert into par_mail for later sending: comment
		$txt = addslashes( $txt );
		if( !mysql_query( "insert into par_mail values(
			$proj_id, $mid, '$parastr', '$par', '$txt', '$buf' )" )){
			echo "Error 17: ".mysql_errno().": ".mysql_error();
			exit;
		}
		
		$par = '';	# do not open comment form again
	}

	# user wants to update or delete comment
	if( !empty( $chg ) && !empty( $em )){	# !empty( $em ) means: correction

		$hd = trim( strip_tags( $hd ));
		$parastr = pnum2par( $chg, 0 );	# referenced paragraph

		# empty comment means delete comment
		if( empty( $comment )){

			$par = substr( $parastr, 0, -1 );	# cut hashmark
			$l = strlen( $par );

			# check whether there ist no subcomment
			if( !$id = mysql_query( "select parastr 
				from paragraph where proj_id = $proj_id
				and vers_id = $vers_id
				and left( parastr, $l ) = '$par'
				and length( parastr ) > $l+1" )) {
				echo "Error 21: ".mysql_errno().": ".mysql_error();
				exit;
			};
			if( mysql_fetch_row( $id )){
				$par = 'error_subcoms';
			}
			else {
				if( !mysql_query( "delete from paragraph
					where proj_id = $proj_id
					and vers_id = $vers_id 
					and parastr = '$parastr'" )){
					echo "Error 22: ".mysql_errno().": ".mysql_error();
					exit;
				}
				if( !mysql_query( "delete from par_mail
					where proj_id = $proj_id
					and memb_id = $mid 
					and parastr = '$parastr'" )){
					echo "Error 23: ".mysql_errno().": ".mysql_error();
					exit;
				}

				$parastr = substr( $par, 0, -4 );	# cut last num
				$l = strlen( $parastr );

				# select all following comments incl. its subcomments
				if( !$id = mysql_query( "select parastr 
					from paragraph where proj_id = $proj_id
					and vers_id = $vers_id
					and left( parastr, $l ) = '$parastr'
					and left( parastr, $l+4 ) > '$par'" )) {
					echo "Error 24: ".mysql_errno().": ".mysql_error();
					exit;
				};

				# patch the parastr, pull all nums one step up
				while( $row = mysql_fetch_array( $id )) {
					$par = $row[ "parastr" ];
					$i = substr( $par, $l, 4 ) - 1;	# dec curr num
					$i = fill( $i, 4 );
					$lst = $parastr.$i.substr( $par, $l+4 );
					if( !mysql_query( "update paragraph
						set parastr = '$lst'
						where proj_id = $proj_id
						and vers_id = $vers_id 
						and parastr = '$par'" )){
						echo "Error 25: ".mysql_errno().": ".mysql_error();
						exit;
					}
					if( !mysql_query( "update par_mail
						set parastr = '$lst'
						where proj_id = $proj_id
						and memb_id = $mid 
						and parastr = '$par'" )){
						echo "Error 26: ".mysql_errno().": ".mysql_error();
						exit;
					}
				}
				$par = '';
				$chg = '';	# do not open correction form again
			}
		}
		else {
			if( !mysql_query( "update paragraph
				set headln = '$hd', text = '$comment'
				where proj_id = $proj_id
				and vers_id = $vers_id 
				and parastr = '$parastr'" )){
				echo "Error 27: ".mysql_errno().": ".mysql_error();
				exit;
			}
			$buf = insert_nl( $comment, 74, FALSE );
			if( !mysql_query( "update par_mail
				set subj = '$hd', ctext = '$buf'
				where proj_id = $proj_id
				and memb_id = $mid 
				and parastr = '$parastr'" )){
				echo "Error 28: ".mysql_errno().": ".mysql_error();
				exit;
			}
			$chg = '';	# do not open correction form again
		}
	}

	###################
	# generating page #
	###################

	if( !$id = mysql_query( "select m.last_n, m.first_n, m.email, m.passwd,
		t.title, t.titlabb, t.submit, t.status, t.descr, t.keywds
		from metatext t, member m where t.memb_id = m.memb_id
		and t.proj_id = $proj_id and t.vers_id = $vers_id" )) {
		echo "Error 2: ".mysql_errno().": ".mysql_error();
		exit;
	};

	if( !$row = mysql_fetch_array( $id )) {
		htmlhead( '?', '' );
		echo "<font $_fonthdln>\n";
		echo "<center><b>$t[42]</b></a></center><br></font>\n";
		echo "<font $_fontbulk><p>$t[43]: <a href='mailto:";
		echo "$ot_maint@$domain'>$ot_maint@$domain</a></p></font>";
		foot();
		exit;
	}

	$first_n = $row[ "first_n" ];
	$last_n = $row[ "last_n" ];
	$email = $row[ "email" ];
	$title = $row[ "title" ];
	$titlabb = $row[ "titlabb" ];
	$submit = date_de( $row[ "submit" ] );
	$year = substr( $submit, 6, 4 );
	$status = $row[ "status" ];
	$status = st_de( $status );
	if( $prt ){
		$txt = lnkxid( $PHP_SELF, $xid );
		htmlhead( $title, '' );
		echo "<font $_fonthdln>\n";
		echo "<center><a href='$txt'><b>$title</b></a></center></font>\n";
	} elseif( $show_head ) {
		$txt = lnkxid( 'index.phtml', $xid );
		head( "<a href='$txt'>$title</a>", $row[ "keywds" ], $xid, $xpar );
	}
	echo "<font $_fontbulk>\n";

	if( $par == 'error_subcoms' ){
		echo "<font $_fontbulk>\n";
		eval( "\$x = \"$t[6]\";" );
		echo "<p>$x</p>\n";
		echo "<p>$t[7] &nbsp; <a href='".lnkxid( "$PHP_SELF?chg=$chg", $xid );
		echo "#$chg'><b>... $t[8]</b></a> &nbsp; ";
		# prt=0 is a workaround due to caching effects (could be any flag...)
		echo "<a href='".lnkxid( "$PHP_SELF?prt=0", $xid );
		echo "#$chg'><b>... $t[9]</b></a></p></font>\n";
		foot();
		exit;
	}

	$logout = empty( $xid );
	if( $show_head && ( $status == $_act ) && !$logout && !$prt ){
		if( empty( $fn ) || empty( $ln )){
			if( !$id = mysql_query( "select last_n, first_n, email
				from member where memb_id = ".$xpar[ 'mid' ] )) {
				echo "Error 31: ".mysql_errno().": ".mysql_error();
				exit;
			};
			if( !$row = mysql_fetch_array( $id )) {
				echo "Error 32: no_rows_selected";
				exit;
			}
			$fn = $row[ 'first_n' ];
			$ln = $row[ 'last_n' ];
			$em = $row[ 'email' ];
		}
	}
	if( $show_head ){ 
		echo "<table width=100% cellspacing=4><tr><td>";
		echo "<font $_fontbulk>\n<font size=+1><b>$t[10]: ";
		echo "<a href='mailto:$email'>$first_n $last_n</a>, ";
		echo "$t[11] $vers_id, $submit</b>";
		echo "</font></font></td>\n";
		if(( $status == $_act ) && !$logout && !$prt ){
			echo "<td rowspan=2 align=right><font $_fontbulk>";
			eval( "\$x = \"$t[12]\";" );
			echo "<a href='/comments.phtml?xid=$xid&pid=$proj_id'>";
			echo "<b>$x</b></a></font></td>";
		} elseif(( $status == $_act ) && !$prt ) {
			echo "<td rowspan=2 align=right><font $_fontbulk>";
			echo add_xid( $t[13], $xid )."</font></td>";
		}
		echo "</tr>\n<tr><td><font $_fontbulk><font size=+1>";
		if( $prt ){
			echo "<b>$t[14]: ".date( 'd.m.Y, H:i' );
			echo "</b></font></font></td></tr>\n";
			echo "<tr><td><font $_fontbulk><font size=+1>";
			echo "<b>$t[15]: http://$fqdomain$PHP_SELF</b>";
		} else {
			echo "<b>$t[16]: $status &nbsp; <img src='/images/more.gif' ";
			echo "border=0 height=12 width=12> <a href='";
			$txt = "$PHP_SELF?prt=1";
			if( !empty( $action )) $txt .= "&action=$action";
			echo lnkxid( $txt, $xid );
			echo "'>$t[17]</a></b>";
		}
		echo "</font></font></td></tr></table>\n";
	}
#	echo "<font size=2>";

	$txt = "select parastr, send_by, headln, text, submit from paragraph ";
	$txt .= "where proj_id = $proj_id and vers_id = $vers_id ";
	if( substr( $action, 0, 4 ) == 'hide' ){
		$h = 1;
		if( $action != 'hideall' ) $h = (int)substr( $action, 4 );
		$j = (( $h - 1 ) * 4 ) + 8;
		$txt .= "and length( parastr ) < $j ";
	}
	# active text paragraph was clicked for comment
	if(( $status == $_act ) && ( !empty( $par ) || !empty( $chg ))){
		if( !empty( $par )){
			$h = pnum2par( $par, 0 );
		} else {
			$h = pnum2par( $chg, 0 );
		}
		$txt .= "and parastr = '$h'";
		echo "<p>(...)</p>\n";
	}
	$txt .= "order by parastr";
	if( !$id = mysql_query( $txt )) {
		echo "Datenbankfehler:".mysql_errno().": ".mysql_error();
		exit;
	}

	while( $row = mysql_fetch_array( $id )) {
		$ps = $row[ "parastr" ];
		$send_by = $row[ "send_by" ];
		$headln = $row[ "headln" ];
		$text = $row[ 'text' ];
		$tdiff = ( date( 'Y-m-d' ) == substr( $row[ "submit" ], 0, 10 ));
		if( $tdiff && date( 'G' ) > 5 ){
			$tdiff = substr( $row[ "submit" ], 11, 2 ) > 5;
		}
		for( $i = 6, $j = 1; substr( $ps, $i, 1 ) <> "#"; $i += 4 ) {
			echo "<ul>";
			$j++;
		}	

		$hd = strip_tags( stripslashes( $headln ));
		if(( $j == 1 ) && !empty( $headln )){
			echo "<h4>$headln</h4>\n";
			$headln = '';
		}
		echo "<p>";

		$pnum = par2pnum( $ps );

		# mark text to be corrected red
		if( $chg == $pnum ) echo "<font color='$_fg3'>";

		echo "<a name='$pnum'></a>";
		if( $show_head && !$prt ){
			if(( substr( $action, 0, 4 ) == 'hide' ) && ( $j == $h )){
				echo "<a href='".lnkxid( $PHP_SELF, $xid )."'>";
				echo "<img src='/images/blueplus.gif' border=0 height=12 ";
				echo "width=12 alt='[$t[18]]'></a>\n";
			} else {
				if( $j == 1 ){
					$txt = "[$t[19]]";
					echo "<a href='";
					echo lnkxid( "$PHP_SELF?action=hideall", $xid )."'>";
				} else {
					eval( "\$x = \"$t[20]\";" );
					$txt = "[$x]";
					echo "<a href='";
					echo lnkxid( "$PHP_SELF?action=hide$j", $xid )."'>";
				}
				echo "<img src='/images/blueminus.gif' border=0 height=12 ";
				echo "width=12 alt='$txt'></a>\n";
			}
		}

	 	echo "<b>($pnum) $headln</b>";
		if( !empty( $headln )) echo ', ';

		if( $j > 1 ) echo $send_by.': ';
		echo add_xid( $text, $xid );

		# end of red text mark
		if( $chg == $pnum ) echo "</font>";

		# show comment click link for active text
		if(( $status == $_act ) && ( $par != $pnum ) && ( $chg != $pnum  ) && !$prt ){

			$n = 0; $i = 0;
 			while( $i = strpos( strtolower($text), "</ul>", ++$i )) $n = $i;
			$i = strlen( $text ) - 7;
			if(( $i < 8 ) || ( $n < $i )) echo "<br>";

			# comments via http-link
			echo "<a href='".lnkxid( "$PHP_SELF?par=$pnum", $xid );
			echo "#$pnum' style='color:$_fg5'><img src='/images/arr.gif' ";
			echo "border=0 alt='$t[21]'>";
			echo "<b>$t[22]</b></a>";

			# member can change the comment for 12 hours
			if( $show_head && !$logout && eregi( $xpar[ 'xem' ], $send_by ) && $tdiff ){
				echo " <b>&amp; <a href='";
				echo lnkxid( "$PHP_SELF?chg=$pnum", $xid );
				echo "#$pnum'>$t[23]</a></b>";
			}
		}

		for( $i = 1; $i < $j; $i++) echo "</ul>";
		echo "</p>\n";

		# active text paragraph was clicked for comment
		if(( $status == $_act ) && (( $par == $pnum ) || ( $chg == $pnum ))){
			
			$txt = '';
			$hd = ereg_replace( "\"", "&quot;", $hd );
			if( $par == $pnum ){
				if( !empty( $hd ) && ( substr( $hd, 0, 3 ) != 'Re:' )) $hd = 'Re: '.$hd;
			}
			else {
				$txt = $text;
			}
			echo "<table cellpadding=2><form action='$PHP_SELF?xid=$xid#$pnum' ";
			echo "method='post'>\n<tr>\n<td>\n";
			echo "<font $_fontbulk>\n";
			echo "$t[24]:</font></td>\n";
			if(( $par == $pnum ) && ( $logout )){
				echo "<td><font $_fontinpt>\n";
				echo "<input type='text' name='fn' value='$fn' size=24>\n";
				echo "<input type='text' name='ln' value='$ln' size=35>\n";
				echo "</font></td></tr>\n<tr><td>";
				echo "<font $_fontbulk>$t[25]:</font>";
				echo "</td>\n<td><font $_fontinpt>";
				echo "<input type='text' name='em' value='$em' size=61>\n";
			}
			else {
				echo "<td bgcolor='white'><font $_fontbulk>\n";
				echo "&nbsp;$fn $ln</font></td></tr>\n<tr><td>";
				echo "<font $_fontbulk>$t[25]:</font>";
				echo "</td>\n<td bgcolor='white'>";
				echo "<font $_fontbulk>&nbsp;$em\n";
				echo "<input type='hidden' name='em' value='$em'>\n";
			}
			echo "</font></td></tr>\n<tr><td>\n";
			echo "<font $_fontbulk>\n";
			echo "$t[26]:</font></td>\n<td>\n";
			echo "<font $_fontinpt>\n";
			echo "<input type='text' name='hd' value='$hd' size=61>\n";
			echo "</font></td></tr>\n<tr><td valign=top>\n";
			echo "<font $_fontbulk ";
			if( $par == $pnum ){
				echo "color='$_fg5'>\n";
				echo "<input type='hidden' name='par' value='$pnum'>\n";
				echo "<b>$t[27]";
			}else{
				echo "color='$_fg3'>\n";
				echo "<input type='hidden' name='chg' value='$pnum'>\n";
				echo "<b>$t[28]";
			}
			echo " $t[29]<br>$pnum:<br><br><br><br><br>";
			echo "<a href='".lnkxid( $PHP_SELF, $xid );
			echo "#$par'>$t[30]</a></b></font></td>\n<td>\n";
			echo "<font $_fontinpt>\n";
			echo "<textarea name='comment' rows=8 cols=61 ";
			echo "wrap=virtual>$txt</textarea></font>\n";
			echo "<font $_fontbulk><center>";
			echo "<input type='submit' value='$t[31]'>\n";
			echo "</center></font></td></tr></form>\n";
			if( $chg == $pnum ){
				$pstr1 = pnum2par( $pnum, 0 );
				$pstr1 = substr( $pstr1, 0, strlen( $pstr1 )-5 ).'#';
				$pstr2 = par2pnum( $pstr1 );
				echo "<tr><td>&nbsp;</td><td><font $_fontbulk>\n";
				echo "<form action='$PHP_SELF?xid=$xid#$pstr2' method='post'>\n";
				echo "<input type='hidden' name='chg' value='$pnum'>\n";
				echo "<input type='hidden' name='em' value='$em'>\n";
				echo "<center><input type='submit' value='$t[32]'>\n";
				echo "</center></form></font></td></tr>\n";
			}
			$f1 = "<font color='$_fg4'>"; $f2 = '</font>';
			echo "<tr><td valign=top>";
			echo "<font $_fontbulk>\n";
			echo "$t[33]:</font></td>\n";
			echo "<td bgcolor='$_bg5'>";
			echo "<font $_fontbulk>\n";
			echo "' $f1#$f2 ' &nbsp; => $t[34]<br>\n";
			echo "' $f1!Wort$f2' &nbsp; => $t[35]<br>\n";
			echo "' $f1%Wort$f2' &nbsp; => $t[36]<br>\n";
			echo "' $f1*Wort$f2' &nbsp; => $t[37]<br>\n";
			eval( "\$x = \"$t[38]\";" );
			$x = add_xid( $x, $xid );
			echo "' $f1>http://$fqdomain$f2' &nbsp; => $x<br>\n";
			echo "' $f1>http://$fqdomain|$t[39]$f2' &nbsp; => $t[40] ";
			echo "<a href='".lnkxid( '/', $xid )."'>$t[39]</a><br>\n";
			echo "</font></td></tr></table>\n";
			echo "<p>(...)</p>\n";
		}

	}
	echo "</font>\n";
	if( $prt ){
		echo "<hr size=1 noshade width=100%>\n";
		echo "<font $_fontbulk>";
		echo "<p>$t[41] (c) $year $first_n $last_n</p>\n";
		echo add_xid( $_x[18], $xid );
		echo "</font>\n<br>";
	}
}
?>
