<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<?php
// formatyourthumb requires a ref parameter be passed. The value for ref lets the page know whether it 
// should try to 'appear' as a disk imaging, hwb, etc. page
$ref = $_GET["ref"];
if ($ref == "di"){ // formatyourthumb called from disk imaging page
	echo "<title>Federated Testing - Test a Disk Imaging Tool - Generate Test Report</title>";
} elseif ($ref == "hwb"){ // called from hwb page
	echo "<title>Federated Testing - Test a Hardware Write Block Tool - Generate Test Report</title>";
} elseif ($ref == "md"){ // called from md page
	echo "<title>Federated Testing - Test a Mobile Device Tool - Generate Test Report</title>";
} elseif ($ref == "ss"){ // called from ss page
	echo "<title>Federated Testing - Test a String Search Tool - Generate Test Report</title>";
} elseif ($ref == "fmp"){ // called from md page
	echo "<title>Federated Testing - Test a Forensic Media Prep Tool - Generate Test Report</title>";
} else {
	echo "<title>Federated Testing - Generate Test Report</title>";
} 	
?>

<link rel="stylesheet" type="text/css" href="css/reset.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/main_style.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/layout.css" media="screen" />
<style>
//  a.no_ul:link {text-decoration:none;}
//a.no_ul:hover {text-decoration:underline;}
</style>
</head>
<body id="menu3">
	<div id="mainWrapper">
		<div id="topBannerContainer">
			<div id="logoContainer">
			<!--	<a class="logo" title="National Institute of Standards and Technology" href="http://www.nist.gov/index.html">National Institute of Standards and Technology</a>
				<a class="sub-logo" title="Health Information Technology" href="http://www.nist.gov/healthcare/">Health Information Technology</a>-->
				<img src="/images/banner.png" alt="CFTT Federated Testing - NIST">
			</div>
            <!-- Menu Starts-->
			<div id="menuContainer">
<?php
// formatyourthumb requires a ref parameter be passed. The value for ref lets the page know whether it 
// should try to 'appear' as a disk imaging, hwb, etc. page
$ref = "";
if (array_key_exists('ref', $_GET) ){		
	$ref = $_GET["ref"];
} else {
	echo "<p><b>Error:</b> <i>".$_SERVER['SCRIPT_NAME']."</i> called with no value for ref (e.g., di, hwb, etc.)</p>\n";
	exit();			
}
include './include/global.php';
print_main_horizontal_menu_contents();
?>
			</div>
            <!-- Menu Ends-->
		</div>
		<!-- TopBanner Ends-->
	  
		<!-- Main Content Starts-->	
		<div id="subContentContainer">
		  <div id="leftContent">
		    <div id="leftLinks">
            <div>
<?php
if ($ref == "di"){
	include './include/di-global.php';
	print_di_sidebar_menu_contents(); // print out the sidebar menu
} elseif ($ref == "hwb"){
	include './include/hwb-global.php';
	print_hwb_sidebar_menu_contents(); // print out the sidebar menu	
} elseif ($ref == "md"){
	include './include/mdt-global.php';
	//print_md_sidebar_menu_contents(); // print out the sidebar menu	
} elseif ($ref == "ss"){
	include './include/ss-sidebar-menu.php';
	//print_ss_sidebar_menu_contents(); // print out the sidebar menu	
} elseif ($ref == "fmp"){
	include './include/fmp-global.php';
	//print_fmp_sidebar_menu_contents(); // print out the sidebar menu	
}			
?>
		    </div>
		    </div>
		  </div>	
          		
		  <div id="rightContent">

<?php
echo '<div id="breadcrumb"><a href="/Federated_Testing_Home_Page.php" class="nav">Home</a> >';
if ($ref == "di"){ // formatyourthumb called from disk imaging page
	echo '<a href="/diskimaging" class="nav"> Disk Imaging Testing Home</a>';
} elseif ($ref == "hwb"){ // called from hwb page
	echo '<a href="/hardwarewriteblock" class="nav"> Hardware Write Block Testing Home</a>';
} elseif ($ref == "md"){ // called from md page
	echo '<a href="/mobiledevice/mdt.php" class="nav"> Mobile Device Testing Home</a>';
} elseif ($ref == "ss"){ // called from ss page
	echo '<a href="/stringsearch/string-search.php" class="nav"> String Search Testing Home</a>';
} elseif ($ref == "fmp"){ // called from fmp page
	echo '<a href="/mediawipe/fmp.php" class="nav"> Forensic Media Prep Testing Home</a>';
}
echo " > Generate Test Report</div>"; 

// try to get a value for $state (which page we're on) off the current page's url
// No value: page state 0; state = 1: page state 1
$state = "";
if (array_key_exists('state', $_GET) ){		
	$state = $_GET["state"];
}

if ($state != "1"){
	echo "<h1 style=\"font-size:1.8em\">Generating a Test Report and Documenting Your Testing (1 of 2)</h1>";
} else {
	echo "<h1 style=\"font-size:1.8em\">Generating a Test Report and Documenting Your Testing (2 of 2)</h1>";	
}			  

if ($state != "1"){
	// page state 0, i.e., print form with button to write the test report to tester's
	// log drive

	// need to pass value for $path on to page state 1, grab off url
	$path = $_GET['path'];	
	

	echo "<p>Use this page to generate a test report that documents ";
	//echo "<p>Use this page to generate a test report for the tool/tool you tested that documents ";
	echo "the results of the tests you ran. Click the 'Write test report to log drive' button below ";
	echo "to generate and write a test report to your log drive. ";
	echo "You will need to open the generated report in a word processor and ";
	echo "make any required edits and add additional information as per the inline instructions in the report.</p>";
/*	echo "<p><img src=\"/images/info_black-128x128.png\" alt=\"\" height=\"24\" ";
	echo "width=\"24\" style=\"margin:0px 0;\"><i>The test report is ";
	echo "generated using the setup, analysis and tool log files stored in the setup and test cases ";
	echo "directories on your log drive.</i></p>"; */

	echo '<p><img src="/images/sign_warning-24x24.png" alt="" height="22" width="22" style="margin:0px 0;">&nbsp;';
	echo "<i>Make sure that your log ";
	echo "drive is attached and mounted before continuing. </p>";
	echo "<p><img src=\"/images/info_black-128x128.png\" alt=\"\" height=\"24\" ";
	echo "width=\"24\" style=\"margin:0px 0;\">Mount your log drive by clicking on its icon in the launch bar ";	
	echo "(you can close or minimize the 'Home Folder' application window that opens).";
	echo "</i></p>";

	echo '<form method="POST" action="/generatefinalreport.php?ref='.$ref.'&state=1&path='.$path.'">';
	echo '&nbsp;&nbsp;&nbsp;&nbsp;<input value="Write test report to log drive" type="submit"></p><br>';
	echo "</form>";

} else {
	// page state 1, i.e., try to generate and write a test report to the user's log drive
	$continue = 1;
	#$path = $_POST['path'];
	#$path = $_GET['path'];
	$path = '/FedTest/media/cftt/FT-LOGS';
	$filename = 'test-configuration.txt';
	//$path = trim_trailing_slash($path);

	if ($path == "") { // check for empty $path variable
		echo "<p><b>Error:</b> \$path is empty!</p>"; 
		$continue = 0;
	} else if (!file_exists($path)) { // check if log drive is mounted
		echo "<p><b>Error:</b> it seems that your log drive is ";
		echo "not mounted. Please mount it and press 'F5' to refresh this page. To mount your ";
		echo "log drive, click on its icon in the launch bar (you can close or minimize the 'Home ";
		echo "Folder' application window that opens)";
		echo "</p>\n";
		$continue = 0;
	} else if ((!$handle = fopen($path."/".$filename, 'r')) && ($ref == "di")) { // try to open the test-configuration file to see if readable
	// csr } else if ((!$handle = fopen($path."/".$filename, 'r')) && ($ref == "di")) { // try to open the test-configuration file to see if readable
		echo "<p><b>Error:</b> no test configuration file (".$filename.") exists on your log drive. ";
		echo "Please use the <a href=\"/diskimaging/customizetest.php\">Generate Test Cases &amp; Start ";
		echo "Testing</a> page to generate the list of tests to run to test your tool (the ";
		echo "test configuration will automatically be saved to your log drive).</p>";			
		$continue = 0;	
	}	
	//echo htmlspecialchars(print_r($_POST, true));
	if ($continue) {
		/*print_r($toolname);
		print_r($toolversion);
		print_r($ops);
		print_r($interface);*/
		//echo $interface[2];
		//echo htmlspecialchars(print_r($_POST, true));
	
		// we want to run the ft-di-get_test_status.py script, but the path to the script will be
		// different on mac vs linux. Figure out which path to use (if we're on a mac vs linux box).
		//$mac = '/Applications/MAMP/fedtesting/working/cgi-bin';
		//$linux = '/usr/lib/cgi-bin';
		$linux = '/FedTest/cgi-bin/';

		if ($ref == "di"){
			$scriptname = "ft-di-prt_test_report.py";
		} elseif ($ref == "hwb"){
			$scriptname = "ft_hwb_prt_test_report.py";
		} elseif ($ref == "md"){
			$scriptname = "ft_mdt_prt_test_report.py";
		} elseif ($ref == "ss"){
			$scriptname = "ft_ss_prt_test_report.py";
		} elseif ($ref == "fmp"){
			$scriptname = "ft_fmp_prt_test_report.py";
		}			
		
		if (file_exists($linux)){
			$cgi_path = $linux;
		} else if (file_exists($mac)){
			$cgi_path = $mac;
		} else {
			echo "<p><b>Error:</b> problem finding script <i>".$scriptname."</i></p>\n";
			exit();	
		}

		if ($ref == "di"){
			// ft-di-get_test_status.py should return the file name of the test report it wrote to  
			// the tester's log drive. If report_filename is non-empty, assume script success.
			//$ret_string = `python /Applications/MAMP/fedtesting/ben_take_2/cgi-bin/ft-di-get_test_status.py`;
			$report_filename = `python $cgi_path/$scriptname $filename $path $path`;
		} elseif ($ref == "hwb"){
			$report_filename = `python $cgi_path/$scriptname`;
		} elseif ($ref == "md"){
			//$report_filename = "python $cgi_path/$scriptname";
			$report_filename = passthru("/FedTest/cgi-bin/python /FedTest/cgi-bin/ft_mdt_prt_test_report.py");
			$report_filename = " shown above ";
			//$report_filename = `python $scriptname`;
		} elseif ($ref == "ss"){
			//$report_filename = `python $cgi_path/$scriptname`;
			$report_filename = passthru("/FedTest/cgi-bin/python /FedTest/cgi-bin/ft_ss_prt_test_report.py");
		} elseif ($ref == "fmp"){
			$report_filename = `python $cgi_path/$scriptname`;
		}	
		
		if ($report_filename) { 
			//echo $report_filename;	
			//echo "<p>Success! ".$report_filename." was successfully written to your log drive at ".$path.".</p>";
			//echo "<p>Success! Your test report, ".trim($report_filename).", was successfully written to your log drive.</p>";	
			echo '<p style="font-size: 1.3em;">Success! Your test report, <i>'.trim($report_filename).'</i>, was successfully written to your log drive.</p>';	
			echo '<p>Click <a href="/FedTest/media/FT-LOGS/'.$report_filename.'" target="_blank">here</a> (opens in a new browser ';
			echo 'tab) to preview the test report. </p>';
			echo '<p><img src="/images/sign_warning-24x24.png" height="22" width="22" style="margin:0px 0;">&nbsp;';
			//echo '<p><img src="/images/info_black-128x128.png" height="24" width="24" style="margin:0px 0;">';			
			echo "You now need to complete the generated report by opening it in a word processor, ";
			echo "making any required edits and adding additional information as per the inline instructions ";
			echo '(green italicized text) in the report. You can click ';
			//echo '<a href="/FedTest/media/FT-LOGS/'.$report_filename.'" target="_blank">here</a> (opens in a new browser tab) ';
			//echo '<a href="/FedTest/media/FT-LOGS/" target="_blank">here</a> (opens in a new browser tab) ';
			echo  'to view the skeleton report.</p>';
			
			echo '<p><img src="/images/info_black-128x128.png" height="24" width="24" style="margin:0px 0;">';
			echo "(Optional) after you've completed the test report, click ";
			echo "<a href=\"../shareyourresults.php?ref=".$ref."\">Share Your Results</a> for instructions on how ";
			echo "to share the test results, if approved by your management, with CFTT and the ";
			echo "forensics community!</p>";			
		} else {
			echo "<p><b>Error:</b> page encountered an error at <i>".$scriptname."</i>! Exiting!</p>\n";
			//exit();
		}

	}	//endif continue
}  //endif page state 1

?>
<!-- <form method="POST" action="printtestplan.php"> -->
<!--<br><br><br><br><br><br>-->
<!--<br><br><br><br>
   <input value="- button -" type="submit">
<?php
/*  // pass the simple variables to the next page
  echo "<input type=\"hidden\" name=\"toolname\" value=\"".$toolname."\" />\n";
  echo "<input type=\"hidden\" name=\"toolversion\" value=\"".$toolversion."\" />\n";  
  // pass array variables to the next page
foreach ($ops as $arrVal) {  
   echo "<input type=\"hidden\" name=\"ops[]\" value=\"".$arrVal."\" />\n";
}
foreach ($interface as $arrVal) {  
   echo "<input type=\"hidden\" name=\"interface[]\" value=\"".$arrVal."\" />\n";
}
//$python = `python /Applications/MAMP/fedtesting/ben_take_2/cgi-bin/scratch.py`;
//echo $python;*/
?> 
</form>-->
<!--
    <form method="POST"
      action="writetrtcfile.php">
      <input type="file" name="bob" value="bob">hi bob</input><br><br>
        <input value="Submit" type="submit"> </p>        
      <p>%Z% %M% Version %I% %H% %T% </p>
    </form>
-->
		  </div>
		<!-- Main Content Ends-->
		</div>
		<div class="push"></div>
	</div>
    <!-- Footer Starts-->
	<?php
//	  include 'include/global.php';
     $fn = $_SERVER["SCRIPT_FILENAME"];
	  print_footer_contents($fn);
	?> 
    <!-- Footer Ends-->
</body>
</html>
