<?php

	include "library.php";

	$cxn = start_code();

	$cxn_common = db_common_login();



			/* get variables */

	$id = val( $_SESSION, "id" );

	$block = val( $_GET, "block" );
	$block_id = val( $_GET, "blockid" );

	$returnpoint = val( $_SESSION, "returnpoint" );

	$startpos = val( $_SESSION, "startpos" );

			/* start page */

	page_header( "", $cxn, $cxn_common );


			/* check parameters */

	crash_if_missing( $id, "id missing in block_go", $cxn );

	crash_if_missing( $block, "block missing in block_go", $cxn );

	crash_if_missing( $block_id, "block id missing in block_go", $cxn );

	crash_if_missing( $returnpoint, "return point missing in block go", $cxn );


	if ($block == "no")
		echo black( "Block cancelled<br><br>" );
	else
	{
			/* record the block */

		$date_blocked = date('Y-m-d');


			/* don't create another record if already blocked */

		if (! query_has_rows( "SELECT id FROM blocked_list WHERE blocker_id = ".$id." AND blockee_id = ".$block_id, $cxn ) )
		{
			$query = "INSERT INTO blocked_list (blocker_id, blockee_id, blocked_date) VALUES ( ".$id.", ".$block_id.", '".$date_blocked."' )";

			$result = run_query( $query, $cxn );
		}

		echo black( "Member blocked successfully<br><br>" );

	}

	show_return_point( $returnpoint, $startpos, $block_id );
	
?>