<!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 - Format Your Log Drive 'FT-LOGS'</title>";
} elseif ($ref == "hwb"){ // called from hwb page
	echo "<title>Federated Testing - Test a Hardware Write Block Tool - Format Your Log Drive 'FT-LOGS'</title>";
} elseif ($ref == "md"){ // called from md page
	echo "<title>Federated Testing - Test a Mobile Device Tool - Format Your Log Drive 'FT-LOGS'</title>";
} elseif ($ref == "ss"){ // called from ss page
	echo "<title>Federated Testing - Test a String Search Tool - Format Your Log Drive 'FT-LOGS'</title>";
} elseif ($ref == "fmp"){ // called from fmp page
	echo "<title>Federated Testing - Test a Forensic Media Prep Tool - Format Your Log Drive 'FT-LOGS'</title>";
} else {
	echo "<title>Federated Testing - Format Your Log Drive 'FT-LOGS'</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>
<script src="/FedTest/HTDOCS/js/ft-global.js"></script>
</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';
} elseif ($ref == "fmp"){
	include './include/fmp-global.php';
}
?>
		    	</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 " > Setting Your Log Drive 'FT-LOGS'</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>Setting up  Your Log Drive 'FT-LOGS' (1 of 2)</h1>";
} else {
	echo "<h1>Log Drive Ready 'FT-LOGS' (2 of 2)</h1>";	
}

$mac = '/FedTest/cgi-bin';
$linux = '/FedTest/cgi-bin';
$scriptname = 'get_common.py';

if (file_exists($linux."/".$scriptname)){
	$cgi_path = $linux;
} else if (file_exists($mac."/".$scriptname)){
	$cgi_path = $mac;
} else {
	echo "<p><b>Error:</b> problem finding required cgi script: <i>$scriptname</i></p>\n";
	exit();	
}

if ($state != "1"){
	// page state 0, i.e., print form with list attached devices, user selects device they 
	// want to format

	// if called w/ test_again parameter, display additional warning to copy files off drive b4 cont.
	if (array_key_exists('test_again', $_GET) ){		
		echo '<p><img src="/images/sign_warning-24x24.png" alt="" height="22" width="22" style="margin:0px 0;">';
		echo ' <span style="color:red;"><b>IMPORTANT!!! If you are re-using a log drive (used for ';
		echo 'previous tests) you need to COPY ANY TEST DATA OFF THE DRIVE BEFORE PROCEEDING OR IT ';
		echo 'WILL BE LOST!</b></span></p>';
	} elseif (array_key_exists('start_over', $_GET) ){		
		echo '<p><img src="/images/info_black-128x128.png" alt="" height="24" width="22" style="margin:-2px 0;">';
		echo " <b>TO CLEAR YOUR LOG DRIVE AND START OVER: 1) select your drive from the list of devices below and 2) click 'Format drive' to re-format it and clear its contents.";
		echo '</b></p>';
	}
	echo "<p>Use this page to prepare your log drive. To run the NIST tests, we created a log drive (aka local disk or your thumb drive) for storing ";
	echo "log files and other test information. The log file folder is located under the FedTest dirctory ";
	echo " in \" a sub directory\" and set to \"FedTest\media\cftt\FT-LOGS\" <i><u>for our web pages and programs to interact with it.</u></i></p>";
	echo "<p>To create the files need in your log drive: click 'Format drive' to begin.</p>";
	#echo "<ol><li>insert your flash drive</li>";
	#echo "<li>press 'F5' to refresh the list of attached devices</li>";
	#echo "<li>select your flash drive from the list of devices below ";
	#echo " click 'Format drive' to format your drive. ";
//	echo "<img src=\"/images/lightbulb_on-24x24.png\" alt=\"\" style=\"margin:0px 0;\"><i>NOTE: if your ";
	#echo '<br><img src="/images/info_black-128x128.png" alt="" height="24" width="22" style="margin:-3px 0;"><i>NOTE: if your ';
	#echo "flash drive (e.g., sdb) contains a partition (e.g., sdb1), it's okay to select either<br> sdb or sdb1.</i></li></ol>";
//	echo '<p><img src="/images/sign_stop-24x24.png" alt="" height="22" width="22" style="margin:0px 0;">&nbsp;';
	echo '<p><img src="/images/sign_warning-24x24.png" alt="" height="22" width="22" style="margin:0px 0;">&nbsp;';
	echo '<span style="color:red;"><b>IMPORTANT!!! This step must be done first. It will create ';
	echo "the log drive structure needed during testing.</b></span></p>";

	echo '<form method="POST" action="formatyourthumb.php?ref='.$ref.'&state=1">';
	
	$ret_string = "python $cgi_path/$scriptname viewform na true";
	if (!$ret_string) {
		// get_common.py should query linux for a list of attached devices and print
		// a table. If ret_string is empty, let the user know (something went wrong?).
		#echo "<p><b>Error:</b> no content returned from <i>$scriptname</i> for 'viewform'!</p>\n";
	} else {
		// print the devices table 
		echo $ret_string;
	
		//echo '<p><img src="/images/sign_stop-24x24.png" alt="" height="22" width="22" style="margin:0px 0;">&nbsp;<span style="color:red;"><b>IMPORTANT!!! This action will repartition ';
		//echo "your thumb drive AND ANY DATA ON THE DEVICE WILL BE LOST!</b></span><br>";
	
		echo '&nbsp;&nbsp;&nbsp;&nbsp;<input value="Format drive" type="submit"></p><br>';
	}

	echo '</form>';	

} else {
	// page state 1, i.e., retrieve the linux device name to format passed from form on page 0,
	// attempt format that device	

	$device = "";
	if (array_key_exists('device', $_POST) ){		
		$device = $_POST["device"];
	}

	if ($device){ // case: format user's thumb drive

		//echo "<br><br>";
		$scriptname = 'fmt-logs.py';
		// call fmt-logs.py to format $device. fmt-logs will dd 0s to the first sector and
		// sleep for 1 second (removes the thumb's icon from the gui), then format it FAT
		$ret_string = `sudo $cgi_path/$scriptname $device`;
		if (!$ret_string) {
			// fmt-logs.py prints should print some status info. If 
			// ret_string is empty, let the user know (something went wrong?).
			echo "<p><b>Error:</b> <i>$scriptname</i> encountered an error configuring $device</p>\n";
		} else {
			echo $ret_string;
		}
//		echo "<br><br><p>Success! Your log drive is now ready to be used! Mount it ";
//		echo "by clicking on the device icon in the launch bar (you can close or ";
//		echo " minimize the 'Home Folder' application window that opens).</p>";
//		echo "<br><br><p>Success! Your log drive is now ready to be used! Mount it ";
//		echo 'now by clicking on the device icon, <br>e.g., <img src="/images/FT-LOGS.png" alt="Home" width="20%" height="20%" style="margin:-3px 0 0 0;">';
//		echo " in the launch bar (you can close or ";
//		echo " minimize the 'Home Folder' application window that opens).</p>";
//		echo "<br><br><p>Success! Your log drive is now ready to be used!</p>";
//		echo '<p style="color: red;"><img src="/images/sign_warning-24x24.png" alt="" height="22" width="22" style="margin:0px 0;">&nbsp;Mount your log drive ';
		echo '<p><img src="/images/sign_warning-24x24.png" alt="" height="22" width="22" style="margin:0px 0;">&nbsp; Mount your log drive ';
		echo 'now by clicking on the device icon, e.g., <img src="/images/FT-LOGS.png" alt="Home" width="15%" height="15%" style="margin:-3px 0 0 0;">';
		echo " in the <br>launch bar (you can close or ";
		echo " minimize the 'Home Folder' application window that opens).</p>";
			
	} else { // case: user didn't select a device. print error.		
		#echo "<p><b>Error:</b> no device selected. Please return to the previous page and select ";
		#echo "the device you want to format.</p>\n";				
	}

/*	echo '<p>Click to return to <a href="./index.php" class="nav">Disk Imaging&nbsp;&nbsp;<img src="/images/home-16x16.png" alt="Home" ';
	echo 'width="16" height="16" style="position:relative;top:-4px;"></a></p>';*/	

	if ($ref == "di"){ // formatyourthumb called from disk imaging page
		echo '<p><img src="/images/info_black-128x128.png" alt="" height="24" width="22" style="margin:-3px 0;"> Click <a href="/diskimaging/customizetest.php" class="nav">Generate Test Cases &amp; Start Testing</a> to continue to the next step to generate the list of tests to run for the tool and start testing.</p>';
	} elseif ($ref == "hwb"){ // called from hwb page
		echo '<p><img src="/images/info_black-128x128.png" alt="" height="24" width="22" style="margin:-3px 0;"> Click <a href="/hardwarewriteblock/writeblocktype.php" class="nav">Generate Test Cases &amp; Start Testing</a> to continue to the next step to generate your test cases and start testing.</p>';
	} elseif ($ref == "md"){ // called from md page
//		echo '<p>Click to <a href="/mobiledevice/mdt.php" class="nav">return to the Mobile Device Home Page</a></p>';
		echo '<p><img src="/images/info_black-128x128.png" alt="" height="24" width="22" style="margin:-3px 0;"> Click \'<a href="/mobiledevice/mdt.php" class="nav">Mobile Device &nbsp;<img src="/images/home-16x16.png" alt="Home" width="16" height="16" style="margin:2px 0;"></a>\' to return to the Mobile Device Home Page and continue with the next step.</p>';
	} elseif ($ref == "ss"){ // called from ss page
		echo '<p><img src="/images/info_black-128x128.png" alt="" height="24" width="22" style="margin:-3px 0;"> ';
		echo 'Click <a href="/stringsearch/customizetest.php" class="nav">Generate Test Cases &amp; Start Testing</a>';
		echo ' to continue to the next step to generate the list of test cases to run for the tool and start testing.</p>';
	} elseif ($ref == "fmp"){ // called from fmp page
		echo '<p><img src="/images/info_black-128x128.png" alt="" height="24" width="22"
		style="margin:-3px 0;"> Click <a href="/mediaprep/fmp.php"
		class="nav">Forensic Media Prep Home </a> to continue to the next step to generate
		your test cases and start testing.</p>';
	}
}
?>

<p></p>
<br>

		  </div>
		<!-- Main Content Ends-->
		</div>
		<div class="push"></div>
	</div>
    <!-- Footer Starts-->
	<?php
     $fn = $_SERVER["SCRIPT_FILENAME"];
	  print_footer_contents($fn);
	?> 
    <!-- Footer Ends-->
</body>
</html>
