<?php
	session_start();
	
	$userID = $_SESSION['marry_userID'];
	$userPW = $_SESSION['marry_userPW'];
	$dbp = "userDB/";
	$filename = $dbp . $userID . ".txt";
	$cancel = $_POST['cancel'];
	
	if($cancel == "cancel") {
		//read userfile
		$file = fopen($filename,"r");
			$readed = fread($file,filesize($filename));
			fclose($file);
		$rearray = explode("\r\n",$readed);
		$target_file = $dbp . $rearray[7] . ".txt";
		
		//read targetfile
		$file1 = fopen($target_file,"r");
			$readed1 = fread($file1,filesize($target_file));
			fclose($file1);
		$rearray_target = explode("\r\n",$readed1);
		
		//do process
		$content =
			$rearray[0] . "\r\n" .
			$rearray[1] . "\r\n" .
			$rearray[2] . "\r\n" .
			$rearray[3] . "\r\n" .
			$rearray[4] . "\r\n" .
			$rearray[5] . "\r\n" .
			"\r\n"
			;
			
		$opn = fopen($filename,"w");
		$write = $content;
		fputs($opn,$write);
		fclose($opn);
							
		$content_target =
			$rearray_target[0] . "\r\n" .
			$rearray_target[1] . "\r\n" .
			$rearray_target[2] . "\r\n" .
			$rearray_target[3] . "\r\n" .
			"\r\n" .
			"\r\n" .
			$rearray_target[6] . "\r\n" .
			$rearray_target[7];
							
		$opn1 = fopen($target_file,"w");
		$write1 = $content_target;
		fputs($opn1,$write1);
		fclose($opn1);
		
		echo "un request succesful!";
	}
	else {
		echo "intruder reject.";
	}
?>

<meta name="viewport" content="width=device-width, initial-scale=1.0">