<?php
include( "func.inc" );
include( "mnum.inc" );

$t = getmsg( 13, $lang );

#### check if member exists by email #################################
function get_member( $e, &$mid, &$fname, &$lname, &$subscr, &$bounce ){
	if( empty( $e )) return FALSE;
	if( !$id = mysql_query( "select memb_id, first_n, last_n, subscr, bounce
		from member where email = '$e'" )) {
		echo "Error No. 101: ".mysql_errno().": ".mysql_error();
		exit;
	}
	if( $row = mysql_fetch_array( $id )){
		$mid = $row[ 'memb_id' ];
		$fname = $row[ 'first_n' ];
		$lname = $row[ 'last_n' ];
		$subscr = dt_de( $row[ 'subscr' ]);
		$bounce = $row[ 'bounce' ];
		return TRUE;
	}
	return FALSE;
}
#### reads mid by email ##############################################
function get_mid( $e ){
	if( empty( $e )) return FALSE;
	if( !$id = mysql_query( "select memb_id from member where email = '$e'" )) {
		echo "Error No. 102: ".mysql_errno().": ".mysql_error();
		exit;
	}
	if( $row = mysql_fetch_array( $id )) return( $row[ 'memb_id' ]);
	return FALSE;
}
#### reads password ##################################################
function get_passwd( $mid ){
	if( !$id = mysql_query( "select passwd from member where memb_id = $mid" )) {
		echo "Error No. 103: ".mysql_errno().": ".mysql_error();
		exit;
	}
	if( $row = mysql_fetch_array( $id )) return( $row[ 'passwd' ] );
	return 0;
}

#### reads titlabb ###################################################
function get_titlabb( $pid ){
	if( !$id = mysql_query( "select titlabb from metatext where proj_id = $pid" )) {
		echo "Error No. 104: ".mysql_errno().": ".mysql_error();
		exit;
	}
	if( $row = mysql_fetch_array( $id )) return( $row[ 'titlabb' ] );
	return 0;
}

#### add a new project to a given member #############################
function add_proj( $pid, $mid ){
	global $fn, $ln, $e, $domain, $fqdomain, $t;
	$titlabb = get_titlabb( $pid );
	if( empty( $pid ) || empty( $mid )){
		echo "Empty values pid='$pid', mid='$mid'";
		return FALSE;
	}
	if( !mysql_query( "insert into projmemb values( $pid, $mid, 0 )" )){
		echo "Error No. 105: ".mysql_errno().": ".mysql_error();
		return FALSE;
	}
	update_member_num( $pid );
	$titllow = strtolower( $titlabb );
	$maillist = "$titllow@$domain";
	$t1 = $t[63];
	eval( "\$t1 = \"$t1\";" );
	$t2 = $t[60].phpversion();
	eval( "\$t2 = \"$t2\";" );
	mail( $e, "$t[64] '$titlabb'", $t1, $t2 );
	return TRUE;
}

#### remove project from given member ################################
function remove_proj( $pid, $mid ){
	global $fn, $ln, $e, $domain, $fqdomain, $t;
	$titlabb = get_titlabb( $pid );
	if( empty( $pid ) || empty( $mid )){
		echo "Empty values pid='$pid', mid='$mid'";
		return FALSE;
	}
	if( !mysql_query( "delete from projmemb 
		where proj_id = $pid and memb_id = $mid" )){
		echo "Error No. 105: ".mysql_errno().": ".mysql_error();
		return FALSE;
	}
	update_member_num( $pid );
	$t1 = $t[65];
	eval( "\$t1 = \"$t1\";" );
	$t2 = $t[60].phpversion();
	eval( "\$t2 = \"$t2\";" );
	mail( $e, "$t[66] '$titlabb'", $t1, $t2 );
	return TRUE;
}

$r = 'Unknown Error';

########################
# special: leave ot    #
########################

if( $action == 'goodbye' ){	# check, if yet project member
	$res = '';
	if( !$id = mysql_query( "select proj_id from projmemb 
		where memb_id = $mid" )) {
		echo "Error No. 1001: ".mysql_errno().": ".mysql_error();
		exit;
	}
	if( mysql_fetch_row( $id )) {
		$res = 'yet_memb';
		$action = '';
	}
}

########################
# header for no action #
########################

if( !empty( $res ) || empty( $action )) {
	if( !head( $t[0].' $xfn $xln', '', $xid, $xpar )) exit;
#	$mid = $xpar[ 'mid' ]; 
	$e = $xpar[ 'xem' ];
#	$fn = $xpar[ 'xfn' ]; $ln = $xpar[ 'xln' ]; $dt = dt_de( $xpar[ 'xdt' ] );
	get_member( $e, $mid, $fn, $ln, $dt, $bn );
}

########################
# process action       #
########################

switch( $action ){

case 'chg_save':
	$res = '';
	$wd = get_passwd( $mid );
	if( empty( $fn_new ) || empty( $ln_new )){
		$res = 'new_err_names';
	}
	elseif( empty( $e_new ) || empty( $wd_new )){
		$res = 'email_pw_empty';
	}
	elseif( !check_email( $e_new )){
		$res = 'email_wrong_fmt';
	}
	elseif(( $e_new != $e ) || ( $wd_new != $wd ) || ( $fn_new != $fn )
		|| ( $ln_new != $ln ) || $dt_new || $bn_new ) {
	
		if(( $e_new != $e ) && get_mid( $e_new )) {
			$res = 'member_exists';
		} else {
			$qry = "update member set ";
			$qry .= "first_n = '$fn_new', last_n = '$ln_new', ";
			$qry .= "email = '$e_new', passwd = '$wd_new'";
			if( $bn_new ) {
				$qry .= ', bounce = 0';
				$bn = 0;
			}
			if( $dt_new ){
				$qry .= ", subscr = now()";
				$dt = date( "d.m.Y" );
			}
			if( !mysql_query( $qry." where memb_id = $mid" )) {
				echo "Error No. 1: ".mysql_errno().": ".mysql_error();
				exit;
			}
			if( $e_new != $e ){
				$t1 = $t[61];
				eval( "\$t1 = \"$t1\";" );
				$t2 = $t[60].phpversion();
				eval( "\$t2 = \"$t2\";" );
				mail( $e_new, $t[62], $t1, $t2 );
			}
			$fn = $fn_new; $ln = $ln_new; $e = $e_new;
			$qry = "update session set xfn = '$fn', xln = '$ln', xem = '$e'";
			if( $dt_new ){
				$qry .= ", xdt = now()";
			}
			if( !mysql_query( $qry." where m_id = $mid" )) {
				echo "Error No. 2: ".mysql_errno().": ".mysql_error();
				exit;
			}
			$res = 'data_changed';
		}
	}
	$action = '';
break;
case 'pj_del':
	if( !remove_proj( $pid, $mid )) $res = 'unknown_error'; else $res = 'rem_proj';
	$ta = get_titlabb( $pid );
	$action = '';
break;
case 'pj_ins':
	if( !add_proj( $pid, $mid )) $res = 'unknown_error'; else $res = 'add_proj';
	$ta = get_titlabb( $pid );
	$action = '';
break;
case 'goodbye':
	if( !mysql_query( "delete from member where memb_id = $mid" )){
		echo "Error No. 4: ".mysql_errno().": ".mysql_error();
		exit;
	} else {
		$res = 'bye_memb';
	}
	$action = '';
break;
case 'welcome':
	if( empty( $fn_new ) || empty( $ln_new )){
		$res = 'new_err_names';
	}
	elseif( empty( $e_new ) || empty( $wd_new )){
		$res = 'email_pw_empty';
	}
	elseif( !check_email( $e_new )){
		$res = 'email_wrong_fmt';
	}
	elseif( get_mid( $e_new )){
		$res = 'new_exists';
	}
	else {
		# insert new member
		if( !mysql_query( "insert into member( 
			last_n, first_n, email, passwd, subscr )
			values( '$ln_new', '$fn_new', '$e_new', '$wd_new', now())" )){
			echo "Error No. 5: ".mysql_errno().": ".mysql_error();
			exit;
		}
		$t1 = $t[67];
$fn = $fn_new; $ln = $ln_new;
		eval( "\$t1 = \"$t1\";" );
		$t2 = $t[60].phpversion();
		eval( "\$t2 = \"$t2\";" );
		mail( $e_new, $t[68], $t1, $t2 );
		$res = "new_inserted";
	}
break;
case 'new_pw':
	$e = $e_new;
	if( get_member( $e, $mid, $fn, $ln, $dt, $bn )){
		$wd = get_passwd( $mid );
		$t1 = $t[69];
		eval( "\$t1 = \"$t1\";" );
		$t2 = $t[60].phpversion();
		eval( "\$t2 = \"$t2\";" );
		mail( $e, $t[70], $t1, $t2 );
		$res = "new_pw_sent";
	}
	else {
		$res = "new_pw_no_memb";
	}
break;
}

########################
# prepare result string#
########################

switch( $res ){
	case 'new_err_names':
	case 'email_pw_empty':
	case 'email_wrong_fmt':
	case 'member_exists':
	case 'new_exists':
	case 'yet_memb':
	case 'new_pw_no_memb':
	case 'unknown_error';
		$r = "<font color='$_fg3'><b>".$t[75].": </b>";
	break;
	case 'data_changed':
	case 'rem_proj':
	case 'add_proj':
	case 'bye_memb':
	case 'new_inserted':
	case 'new_pw_sent':
		$r = "<font color='$_fg4'><b>".$t[76].": </b>";
	break;
}
switch( $res ){
	case 'new_err_names':
		if( empty( $fn_new ) ){
			$field = 'Vorname';
			if( empty( $ln_new )) $field .= '&laquo; und das Feld &raquo;Nachname';
		} else {
			$field = 'Nachname';
		}
		$r .= $t[77];
		eval( "\$r = \"$r\";" );
		if( $action == 'welcome' ){
			$xid = 0;
			if( !head( $t[75], '', $xid, $xpar )) exit;
			$res = 'stop_page';
		}
	break;
	case 'email_pw_empty':
		if( empty( $e_new )) {
			$field = 'E-Mail-Adresse';
			if( empty( $wd_new )) $field .= '&laquo; und das Feld &raquo;Passwort';
		} else {
			$field = 'Passwort';
		}
		$r .= $t[78];
		eval( "\$r = \"$r\";" );
		if( $action == 'welcome' ){
			$xid = 0;
			if( !head( $t[75], '', $xid, $xpar )) exit;
			$res = 'stop_page';
		}
	break;
	case 'email_wrong_fmt':
		$r .= $t[79];
		eval( "\$r = \"$r\";" );
		if( $action == 'welcome' ){
			$xid = 0;
			if( !head( $t[75], '', $xid, $xpar )) exit;
			$res = 'stop_page';
		}
	break;
	case 'member_exists':
		$r .= $t[80];
		eval( "\$r = \"$r\";" );
	break;
	case 'yet_memb':
		$r .= $t[81];
		eval( "\$r = \"$r\";" );
	break;
	case 'new_exists':
		$xid = 0;
		$x = $t[82];
		eval( "\$x = \"$x\";" );
		if( !head( $x, '', $xid, $xpar )) exit;
		$r .= $t[83];
		eval( "\$r = \"$r\";" );
		$res = 'stop_page';
	break;
	case 'new_pw_no_memb':
		$xid = 0;
		$x = $t[84];
		eval( "\$x = \"$x\";" );
		if( !head( $x, '', $xid, $xpar )) exit;
		$r .= $t[85];
		eval( "\$r = \"$r\";" );
		$res = 'stop_page';
	break;
	case 'unknown_error':
		$r .= $t[86];
		eval( "\$r = \"$r\";" );
	break;
}
switch( $res ){
	case 'data_changed':
		$r .= $t[90];
		eval( "\$r = \"$r\";" );
	break;
	case 'rem_proj':
		$maillist = strtolower( $ta )."@$domain";
		$r .= $t[91];
		eval( "\$r = \"$r\";" );
	break;
	case 'add_proj':
		$maillist = strtolower( $ta )."@$domain";
		$r .= $t[92];
		eval( "\$r = \"$r\";" );
	break;
	case 'bye_memb':
		$xid = 0;
		if( !head( $t[93], '', $xid, $xpar )) exit;
		echo "<font $_fontbulk><p>".$t[94]."</p></font>\n";
		foot();
		exit;
	break;
	case 'new_inserted'	;
		$xid = '';
		$xem = $e_new;	# global var for head due to start session
		$xwd = $wd_new;
		if( !head( $t[95], '', $xid, $xpar )) exit;
		$mid = $xpar[ 'mid' ]; $e = $xpar[ 'xem' ];
		$fn = $xpar[ 'xfn' ]; $ln = $xpar[ 'xln' ]; $dt = dt_de( $xpar[ 'xdt' ] );
		$r .= $t[96];
		eval( "\$r = \"$r\";" );
	break;
	case 'new_pw_sent':
		$xid = 0;
		if( !head( $t[97], '', $xid, $xpar )) exit;
		$r .= $t[98];
		eval( "\$r = \"$r\";" );
		$res = 'stop_page';
	
	break;
}

########################
# display result       #
########################

if( !empty( $res ) || empty( $action )) {
	echo "<br>\n";
	if( !empty( $res )){
		echo "<table width=100% bgcolor='$_bg5'><tr><td>\n";
		echo "<font $_fontbulk>\n";
		echo "<b>$t[73]:</b>";
		echo "</font></td></tr>\n<tr><td>\n";
		echo "<font $_fontbulk>\n";
		echo "$r</font>\n";
		echo "</font></td></tr></table>\n<br>";
		if( $res == 'stop_page' ){ foot(); exit; }
	}
	echo "<table width=100% bgcolor='$_bg3'>\n";
	echo "<tr><td colspan=3 bgcolor='$_bg5'>\n";
	echo "<font $_fontbulk>\n";
	echo "<b>$t[1]:</b>";
        echo "</font></td></tr>\n<tr><td width=20%><font $_fontbulk>";
	echo "$t[2]:</font></td>\n<td width=20%><font $_fontbulk>";
	echo "$fn $ln";
	echo "</font></td>\n<td rowspan=5 width=60%>";
	echo "<table><tr><td><font $_fontbulk>";
	echo "<ul><form action='/member.phtml?xid=$xid' method=post>\n";
	echo "<input type='hidden' name='action' value='chg_req'>";
	echo "<input type='submit' value='$t[28]'></form></ul>";
	echo "</font></td>\n<td><font $_fontbulk>";
	echo "<ul><form action='/member.phtml?xid=$xid' method=post>\n";
	echo "<input type='hidden' name='action' value='goodbye'>";
	echo "<input type='hidden' name='mid' value=$mid>";
	echo "<input type='submit' value='$t[29]'></form>\n";
        echo "</ul></font></td></tr></table>\n";
	echo "</td></tr>\n<tr><td><font $_fontbulk>";
	echo "$t[3]:</font></td>\n<td><font $_fontbulk>";
	echo $e;
        echo "</font></td></tr>\n<tr><td><font $_fontbulk>";
	echo "$t[4]:</font></td>\n<td><font $_fontbulk>* (";
	echo "$t[5])</font></td></tr>\n<tr><td><font $_fontbulk>";
	echo "$t[6]:</font></td>\n<td><font $_fontbulk>$dt";
	echo "</font></td></tr>\n<tr><td><font $_fontbulk>";
	if( $bn ) $bn = "<b><font color='red'>$bn << $t[74]</font></b>";
	echo "$t[7]:</font></td>\n<td><font $_fontbulk>$bn";
        echo "</font></td></tr>\n<tr><td colspan=3 bgcolor='$_page'>&nbsp;";
        echo "</td></tr>\n<tr><td colspan=3 bgcolor='$_bg5'>";
	echo "<font $_fontbulk><b>$t[10]:</b>";
        echo "</font></td></tr>\n<tr><td><font $_fontbulk>";
	echo "$t[11]:</font></td>\n<td><font $_fontbulk>";
	echo "($t[12])";
        echo "</font></td>\n<td rowspan=1><font $_fontbulk>";
	echo "<ul>($t[13])</ul>";
        echo "</font></td></tr>\n<tr><td colspan=3 bgcolor='$_page'>&nbsp;";
        echo "</td></tr>\n<tr><td colspan=3 bgcolor='$_bg5'>";
	echo "<font $_fontbulk><b>$t[30]:</b>";
	echo "</font></td></tr>\n";
	$qry = 'select t.titlabb, t.title, t.link from metatext t, projmemb p ';
	$qry .= "where t.proj_id = p.proj_id and p.memb_id = $mid ";
	$qry .= 'and p.ismaint = 0 and t.status = "act"';
	if( !$id = mysql_query( $qry )) {
		echo "Error No. 11: ".mysql_errno().": ".mysql_error();
		exit;
	}
	$i = mysql_num_rows( $id );
	$j = 0;
	while( $row = mysql_fetch_array( $id )){
		$ta = $row[ 'titlabb' ];
		$ti = $row[ 'title' ];
		$lk = lnkxid( $row[ 'link' ], $xid );
		echo "<tr><td colspan=2><font $_fontbulk>";
		echo "<a href='$lk'>$ta: $ti</a></font></td>";
		if( !$j++ ){
		        echo "\n<td rowspan=$i>";
			echo "<font $_fontbulk>\n";
			echo "<form action='/member.phtml?xid=$xid' method=post>\n";
			echo "<input type='hidden' name='action' value='pj_list'>\n";
			echo "<ul><input type='submit' value='".$t[28]."'></ul></form>\n";
        		echo "</font></td></tr>\n";
		} else {
			echo "</tr>\n";
		}
	}
	if( !$i ){
		echo "<tr><td colspan=2><font $_fontbulk>($t[31])</font></td>\n";
		echo "<td><font $_fontbulk>\n";
		echo "<form action='/member.phtml?xid=$xid' method=post>\n";
		echo "<input type='hidden' name='action' value='pj_list'>\n";
		echo "<ul><input type='submit' value='$t[28]'></ul></form>\n";
        	echo "</font></td></tr>\n";
	}
        echo "<tr><td colspan=3 bgcolor='$_page'>&nbsp;";
        echo "</td></tr>\n<tr><td colspan=3 bgcolor='$_bg5'>";
	echo "<font $_fontbulk><b>".$t[32].":</b>";
        echo "</font></td></tr>\n";
	$qry = 'select t.titlabb, t.title, t.link from metatext t, projmemb p ';
	$qry .= 'where t.proj_id = p.proj_id and p.memb_id = ';
	$qry .= $xpar[ 'mid' ].' and p.ismaint = 1 and t.status = "act"';
	if( !$id = mysql_query( $qry )) {
		echo "Error No. 12: ".mysql_errno().": ".mysql_error();
		exit;
	}
	$i = mysql_num_rows( $id );
	$j = 0;
	while( $row = mysql_fetch_array( $id )){
		$ta = $row[ 'titlabb' ];
		$ti = $row[ 'title' ];
		$lk = lnkxid( $row[ 'link' ], $xid );
		echo "<tr><td colspan=2><font $_fontbulk>";
		echo "<a href='$lk'>$ta: $ti</a></font></td>";
		if( !$j++ ){
		        echo "\n<td rowspan=$i>";
			echo "<font $_fontbulk>\n";
			echo "<ul><a href='/maintainer.phtml?xid=$xid'><b>";
			echo "$t[33]</b></a></ul></font></td></tr>\n";
		} else {
			echo "</tr>\n";
		}
	}
	if( !$i ){
		echo "<tr><td colspan=2><font $_fontbulk>(";
		echo "$t[31])</font></td>\n<td>";
		echo "<font $_fontbulk>\n";
		echo "<ul><a href='/setupform.phtml?xid=$xid'><b>";
		echo "$t[34]</b></a></ul></font></td></tr>\n";
	}
	echo "</table>";
	foot();
	exit;
}

########################
# display change page  #
########################

switch( $action ){
	case 'chg_req':
		if( !head( $t[35].' $xfn $xln', '', $xid, $xpar )) exit;
#		$mid = $xpar[ 'mid' ];
		$e = $xpar[ 'xem' ];
#		$fn = $xpar[ 'xfn' ]; $ln = $xpar[ 'xln' ]; $dt = dt_de( $xpar[ 'xdt' ] );
		get_member( $e, $mid, $fn, $ln, $dt, $bn );
		$wd = get_passwd( $mid );
		echo "<center><form action='/member.phtml?xid=$xid' method='POST'>";
		echo "<table>\n<tr>\n<td>\n";
		echo "<font $_fontbulk>\n";
		echo "$t[2]: </font></td>\n<td>\n";
		echo "<font $_fontinpt>\n";
		echo "<input type='text' name='fn_new' size='10' maxlength='30' value='$fn'>\n";
		echo "<input type='text' name='ln_new' size='12' maxlength='50' ";
		echo "value='$ln'></font></td></tr>\n<tr>\n<td>\n";
		echo "<font $_fontbulk>\n";
		echo "$t[3]:</font></td>\n<td>\n";
		echo "<font $_fontinpt>\n";
		echo "<input type='text' name='e_new' size='24' maxlength='80' ";
		echo "value='$e'></font></td></tr>\n<tr>\n<td>\n";
		if( $bn ) {
			$bn = "<b><font color='red'>$bn</font></b>";
			echo "<font $_fontbulk color='red'>\n";
			echo "<b>$t[7]</b>: </font></td>\n<td>\n";
			echo "<font $_fontbulk>\n";
			echo "$bn &nbsp; <input type='checkbox' name='bn_new' value='1' checked>";
			echo "$t[52]</font></td></tr>\n<tr>\n<td>\n";
		}
		echo "<font $_fontbulk color='$_fg3'>\n";
		echo "$t[4]:</font></td>\n<td>\n";
		echo "<font $_fontinpt>\n";
		echo "<input type='password' name='wd_new' size='24' maxlength='80' ";
		echo "value='$wd'></font></td></tr>\n<tr>\n<td>\n";
		echo "<font $_fontbulk>\n";
		echo "$t[6]: </font></td>\n<td>\n";
		echo "<font $_fontbulk>\n";
		echo "<input type='radio' name='dt_new' value='0' checked> $dt &nbsp; ";
		echo "<input type='radio' name='dt_new' value='1'> $t[36]";
		echo "</font></td></tr>\n<tr>\n<td colspan=2 align=center>\n";
		echo "<font $_fontbulk>\n";
		echo "<input type='hidden' name='res' value=1>";
		echo "<input type='hidden' name='action' value='chg_save'>";
		echo "<input type='submit' value='$t[37]'>";
		echo "</font></td></tr></table></form></center>\n<br><br>\n";
		foot();
		exit;
	break;

	case 'pj_list':
		if( !head( $t[40].' $xfn $xln', '', $xid, $xpar )) exit;
		$mid = $xpar[ 'mid' ]; $e = $xpar[ 'xem' ];
		$fn = $xpar[ 'xfn' ]; $ln = $xpar[ 'xln' ]; $dt = dt_de( $xpar[ 'xdt' ] );
		echo "<font $_fontbulk>\n";
		echo "<p>$t[41]</p>\n";
		echo "<center>\n<table bgcolor='$_bg3' cellpadding=2>\n";
		echo "<tr bgcolor='$_bg2'>\n<td colspan=2 width=220>\n";
		echo "<font $_fontbulk>$t[42]</font></td>\n";
		echo "<td width=80>\n";
		echo "<font $_fontbulk>$t[43]</font></td>\n";
		echo "<td width=290>\n";
		echo "<font $_fontbulk>$t[44]</font></td>\n";
		echo "<td align='center' width=50>\n";
		echo "<font $_fontbulk>$t[45]</font></td></tr>\n";
		# select project data
		if( !$id = mysql_query( "select t.proj_id, t.memb_id, t.vers_id, t.title,
			t.titlabb, t.status, t.submit, t.link
			from metatext t, projmemb p
			where t.proj_id = p.proj_id and p.memb_id = $mid
			and ( t.status = 'act' or t.status = 'fin' )
			order by t.submit desc" )) {
			echo "Error No. 20: ".mysql_errno().": ".mysql_error();
			exit;
		}
		$is_maint = FALSE;
		$is_fin = FALSE;
		while( $row = mysql_fetch_array( $id )){
			if( !empty( $pjlist )) $pjlist .= ',';
			$pid = $row[ 'proj_id' ];
			$pjlist .= $pid;
			$titlabb = $row[ 'titlabb' ];
			$status = $row[ 'status' ];
			$vers_id = $row[ 'vers_id' ];
			$submit = date_de( $row[ 'submit' ]);
			$title = $row[ 'title' ];
			$link = lnkxid( $row[ 'link' ], $xid );
			$numact = 0;
			echo "<tr>\n<td width=200>\n";
			echo "<font $_fontbulk>";
			echo "<b><a href='$link'>$titlabb</a> ";
			if( $row[ 'memb_id' ] == $mid ){
				echo "<font color='$_fg3'>*</font>\n";
				$is_maint = TRUE;
			}
			if( $status == 'fin' ){
				echo "<font color='$_fg2'>*</font>\n";
			$is_fin = TRUE;
			}
			echo "</b></font></td>\n";
			echo "<td><font $_fontbulk>";
			echo "<b> $vers_id </b></font></td>\n";
			echo "<td><font $_fontbulk>";
			echo "$submit</font></td>\n";
			echo "<td width=290><font $_fontbulk>";
			echo "$title</font></td>\n";
			if( $row[ 'memb_id' ] == $mid ){
				echo "<td align='center'>-</td></tr>\n";
			}
			else {
				echo "<form action='/member.phtml?";
				echo "xid=$xid' method='post'>\n";
				echo "<td align='center'>";
				echo "<font $_fontfoot>";
				echo "<input type='hidden' name='pid' value=$pid>";
				echo "<input type='hidden' name='res' value=1>";
				echo "<input type='hidden' name='action' value='pj_del'>";
				echo "<input type='submit' value='$t[46]'>";
				echo "</font></td></form></tr>\n";
			}
		}
		echo "</table></center>\n";
		if( $is_maint ) echo "<font color='$_fg3'><b>*</b></font> $t[47]\n";
		if( $is_maint && $is_fin ) echo "<br>";
		if( $is_fin ) echo "<font color='$_fg2'><b>*</b></font> $t[48]\n";
		echo "<h3>$t[49]:</h3>\n";
		echo "<p>$t[50]</p>\n";
		echo "<center>\n<table bgcolor='$_bg3' cellpadding=2>\n";
		echo "<tr bgcolor='$_bg2'>\n<td colspan=2 width=220>\n";
		echo "<font $_fontbulk>$t[42]</font></td>\n";
		echo "<td width=80>\n";
		echo "<font $_fontbulk>$t[43]</font></td>\n";
		echo "<td width=290>\n";
		echo "<font $_fontbulk>$t[44]</font></td>\n";
		echo "<td align='center' width=50>\n";
		echo "<font $_fontbulk>$t[45]</font></td></tr>\n";
		# select project data
		if( empty( $pjlist )) $pjlist = "0"; # this should never happen!
		if( !$id = mysql_query( "select proj_id, vers_id, title, titlabb, submit, link
			from metatext where status = 'act'
			and proj_id in ($pjlist) = 0
			order by submit desc" )) {
			echo "Error No. 21: ".mysql_errno().": ".mysql_error();
			exit;
		}
		while( $row = mysql_fetch_array( $id )){
			$pid = $row[ 'proj_id' ];
			$titlabb = $row[ 'titlabb' ];
			$vers_id = $row[ 'vers_id' ];
			$submit = date_de( $row[ 'submit' ]);
			$title = $row[ 'title' ];
			$link = lnkxid( $row[ 'link' ], $xid );
			$numact = 0;
			echo "<tr>\n<td width=200>\n";
			echo "<font $_fontbulk>";
			echo "<b><a href='$link'>$titlabb</a></b></font></td>\n";
			echo "<td><font $_fontbulk>";
			echo "<b> $vers_id </b></font></td>\n";
			echo "<td><font $_fontbulk>";
			echo "$submit</font></td>\n";
			echo "<td width=290><font $_fontbulk>";
			echo "$title</font></td>\n";
			echo "<form action='/member.phtml?";
			echo "xid=$xid' method='post'>";
			echo "<td align='center'><font $_fontfoot>";
			echo "<input type='hidden' name='pid' value=$pid>";
			echo "<input type='hidden' name='res' value=1>";
			echo "<input type='hidden' name='action' value='pj_ins'>";
			echo "<input type='submit' value='$t[51]'>";
			echo "</font></td></form></tr>\n";
		}
		echo "</table></center>\n<p>&nbsp;</p>\n</font>";
		foot();
		exit;
	break;
}
?>
