include ( "../config/names.php" );
?>
文章
 include( "../config/topbar.php") ; ?>
function viewsons( $bbsid, $pid, $status )
{
	$sql = "SELECT pid, postime"
		." FROM $bbsid WHERE $status prid=$pid ORDER BY postime ASC" ;
	$query=mysql_query( $sql );
	
	while( $array=mysql_fetch_row( $query ) )
	{
		echo viewpaper( $bbsid, $array[0] ) ;
		viewsons( $bbsid, $array[0], $status ) ;
	}
}
function viewfirst( $bbsid, $pid, $start, $end , $status )
{
	$sql = "SELECT pid, postime"
		." FROM $bbsid WHERE $status prid=$pid ORDER BY postime ASC" ;
	$query=mysql_query( $sql );
	
	$pn = mysql_num_rows( $query ) ;
	for($n=0; $array=mysql_fetch_row( $query ) ; $n++ )
	{
		if( $n < $start ) continue ;
		if( $n ==$end   ) break ;
		echo viewpaper( $bbsid, $array[0] ) ;
		viewsons( $bbsid, $array[0], $status ) ;
	}
	return $pn ;
}
	include ( "viewtop.php" );
	include ( "paperlist.php" );
	include ( "viewpaper.php" );
	//global $iamaster ;
	//global $secrflag ;
	//global $masters ;
	$status='';
	if( $iamaster == 0 )
	{
		$status ='status<>9 AND' ;
	
		if( $secrflag )
		{
		
			$as='';
			for( $i=0; $masters[$i]!=''; $i++)
			{
				$m=addSlashes( $masters[$i] );
				$as .= " OR author=\"$m\"";
			}
			$status = "$status ( author=\"$_SESSION[uname]\" $as ) AND";
		}
	}
	echo "
";
	$bbsid = $_GET[bbsid];
	$pid = $_GET[pid] ;
	paperlink( $_GET[bbsid], $_GET[pid] );
	$page = $_GET[page] ;
	if( $page=='' ) $page=0;
	else $page--;
	if( $page == 0 )
	{
		echo viewpaper( $_GET[bbsid], $_GET[pid] );
		$pn=viewfirst( $_GET[bbsid], $_GET[pid], 0, $page_size-1 , $status );
	}
	else
	{
		$start = $page * $page_size ;
		$end   = $start + $page_size ;
		$pn=viewfirst( $_GET[bbsid], $_GET[pid], $start-1, $end-1 , $status );
	}
	
	$pn++ ;
	if( $pn > $page_size )
	{
		$pages = "
页码 ";
		$nn=1 ;
		for( $n=0; $n<$pn; $n += $page_size, $nn++  )
		{
			if( $nn == $page+1 )
			$pages .=" $nn";
			else
			$pages .=" $nn";
		}
		echo "$pages";
	}
	// 回复
	echo "";
	echo "";
	
?>
 include( "../config/bottom.php") ; ?>