#! /usr/local/bin/perl

#
#	くずはすくりぷと Final Beta #3 (Preview Release 2)
#	 (書き込み検索用関数群)
#

###############################################################################
#  検索結果表示
###############################################################################

sub srcmessage {
	
	my $success = 0;
	
	&loadmessage( $FORM{'file'} );
	
	&prterror ( 'パラメータがありません。' ) if ( $FORM{'search'} eq '' );
	
	print <<EOF;
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<TITLE>$bbstitle</TITLE>
</HEAD>
$body
<HR>
EOF

	if ( $FORM{'mode'} eq 'thread2' ) {
		$i = @logdata;
		while ( $i >= 0 ) {
			&getmessage ( $logdata[$i] );
			if ( $FORM{'search'} eq $thread || $FORM{'search'} eq $postid ) {
				$success++;
				print &prtmessage ( 0, "$FORM{'file'}" );
			}
			$i--;
		}
	} else {
		foreach ( 0 .. @logdata - 1 ) {
			&getmessage ( $logdata[$_] );
			if ( $FORM{'mode'} eq 'search' ) {
				if ( $FORM{'search'} eq $user ) {
					$success++;
					print &prtmessage ( 0, "$FORM{'file'}" );
				}
			} elsif ( $FORM{'mode'} eq 'thread' ) {
				if ( $FORM{'search'} eq $thread || $FORM{'search'} eq $postid ) {
					$success++;
					print &prtmessage ( 0, "$FORM{'file'}" );
				}
			}
			$i++;
		}
	}
	
	if ( $success == 0 ) {
		print "<h3>指定されたメッセージが見つかりません。</h3><body></html>";
		exit;
	}
	
	print "</BODY>\n</HTML>";
	exit;
}

1;


__END__
