<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CFTT Federated Testing CD - test a Mobile Device tool</title>
<!--
<link rel="stylesheet" type="text/css" href="tool-name_files/reset.css" media="screen">
<link rel="stylesheet" type="text/css" href="tool-name_files/main_style.css" media="screen">
<link rel="stylesheet" type="text/css" href="tool-name_files/layout.css" media="screen">
<script src="jquery-1.10.2.js"></script>
<script src="jquery-ui.js"></script>
-->
<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>
	table, th, td {
	   border-collapse: collapse;
	   border: 1px solid black;
	   } 
	tr {
	   border-collapse: collapse;
	   border: 2px solid black;
	   } 
</style>
</head>
<body id="menu1">
	<div id="mainWrapper">
		<div id="topBannerContainer">
			<div id="logoContainer">
  				<img src="../images/banner.png" alt="CFTT Federated Testing - NIST">
			</div>
            <!-- Menu Starts-->
			<div id="menuContainer">
                          <?php
                                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
include '../include/mdt-global.php';
?>
		    </div>
		    </div>
		  </div>			
		  <div id="rightContent">
<!--		    <div id="breadcrumb"><a href="../Federated_Testing_Home_Page.php">Home</a> > Test a disk imaging tool</div>-->
			<div id="breadcrumb"><a href="../Federated_Testing_Home_Page.php" class="nav">Home</a> &gt; <a href="/mobiledevice/mdt.php" class="nav"> Mobile Device Testing Home</a> &gt; Recording Device Setup</div>

<?php
	
$continue = 1;

// is_ftlogs_mounted() returns the path to where we should store log files (e.g.,  
// /tmp or /media/FT-LOGS). It also checks if the user has mounted their log drive.
// is_ftlogs_mounted() will return 0/false and print an error message if the 
// user's log drive is not mounted
$root = is_ftlogs_mounted(FALSE);

if (!$root) { 
	// if the user's log drive isn't mounted, don't continue
	$continue = 0;
}
	
// if the user's log drive isn't mounted, don't continue
if ($continue){		

	echo '<h1 style="font-size:1.8em">Recording Device Setup (2 of 3)</h1>';
	echo '<h2 style="font-size:1.7em; color:#008000">Documenting Device Setup</h2>';

	extract($_POST);	
	// check, did the user select a device to update?
	if (isset($selected_device)){
		
		$have_phones = FALSE;
		$dname = sprintf ("%s/devices.txt",$root);
		if (file_exists($dname)){
			$dfile = fopen($dname,"r");
			//echo "<br>open<br>";
			$p_line = fgets($dfile);
			while (!feof($dfile)){
				//$the_phones [] = $p_line;
				$pxp = explode(';',$p_line);
				$p_sim [$pxp[0]] = trim($pxp[7]);
				// if the current device is the selected device, get its make and model
				if ($pxp[0] == $selected_device){
					$manufacturer = $pxp[1];
					$model = $pxp[2];
				}
				$p_line = fgets($dfile);
				$have_phones = TRUE;
			}
			fclose($dfile);
		}
		
		//echo '<!------------------------------------------------------------- -->';
		//echo '<div style="padding: 0em 1em .25em .5em; background: #eeeeee url(/images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x;">';

		$setup_page_overview1 = <<<XXX
		Use this page to select and document the data types for the selected test device. For the selected device, for each data type in the '<i>Documenting Device Setup</i>' 
XXX;
		// does this phone have a sim?
		if ($p_sim[$selected_device] == 'sim'){
			$setup_page_overview2 = "and '<i>Documenting SIM/UICC Setup</i>' tables";	
		} else { // no sim (1 table, not 2)
			$setup_page_overview2 = "table";	
		}

		//$setup_page_overview3 = <<<XXX
		 //select either 'Populated' or 'Omitted.' By default the status for each data type is set to 'Populated.' Click the '<i>Update Setup for Selected Device</i>' button to continue.
//XXX;
		$setup_page_overview3 = <<<XXX
		 select either 'Populated' or 'Omitted.' By default the status for each data type is set to 'Populated.' Once you're finished, click the '<i>Update Setup for Selected Device</i>' button to save the setup to your log drive. 
XXX;

		$setup_page_overview = $setup_page_overview1.$setup_page_overview2.$setup_page_overview3;

		printf ("<p>%s</p>",$setup_page_overview);

		echo '<p><b>Selected Device:</b><br>';
		echo 'Manufacturer: <i>'.$manufacturer.'</i><br>';
		echo 'Model: <i>'.$model.'</i></p>';

		$pname = sprintf("%s/%s_init.txt",$root,$selected_device);
		if (file_exists($pname)){
		//	printf ("<br>Phone file is %s",$pname);
			$pfile = fopen($pname,"r");
			$init_line = fgets($pfile);
			while (!feof($pfile)){
				$x = explode(':',$init_line);
				/*
				printf ("<br>IX: %s %s",$x[0],$x[1]);
				*/
				$init_line = fgets($pfile);
				$state[$x[0]] = $x[1];
			}
			fclose ($pfile);
		}
		else {
			for ($ix = 0; $ix <= 56; ++$ix){
				$key = sprintf ("dev_init_%02d",$ix);
				$state[$key] = 'populated';
			}
			for ($ix = 0; $ix <= 13; ++$ix){
				$key = sprintf ("sim_init_%02d",$ix);
				$state[$key] = 'populated';
			}
		} 
		$klist = array_keys($state);
		/*
		echo '<br>';
		echo 'S T A T E';
		foreach ($klist as $key){
			echo '<br>';
			echo $key;
			echo ' ';
			echo $state[$key];
		}

		*/
		/*
		<tbody><tr>
		<td rowspan="10">Address Book Entries</td>
		<td>Regular Length</td>

			<td>
			<input checked="checked" name="dev_init_00" value="populated" type="radio">
			Populated</td>
			<td>
			<input name="dev_init_00" value="omitted" type="radio">
			Omitted</td>

		</tr><tr>
		<td>Maximum Length</td>

			<td>
			<input name="dev_init_01" value="populated" type="radio">
			Populated</td>
			<td>
			<input checked="checked" name="dev_init_01" value="omitted" type="radio">
			Omitted</td>

		z[] = '<td rowspan="10">Address Book Entries</td>';
		z[] = '<td>Regular Length</td>';
		z[] = '	<input  name="dev_init_00" value="populated" type="radio">';
		z[] = '<td>Maximum Length</td>';

		include '../include/mdt-setup.php';
		$z[] = '<td rowspan="10">Address Book Entries</td>';
		$z[] = '<td>Regular Length</td>';
		$z[] = '	<input %s name="dev_init_00" value="%s" type="radio">';
		$z[] = '<td>Maximum Length</td>';
		$z[] = '	<input  name="dev_init_01" value="%s" type="radio">';
		$z[] = '<td>Special Character</td>';
		$z[] = '	<input  name="dev_init_02" value="%s" type="radio">';
		$z[] = '<td>Blank Name</td>';
		$z[] = '	<input  name="dev_init_03" value="%s" type="radio">';
		$z[] = '<td>Regular Length, email</td>';
		$z[] = '	<input  name="dev_init_04" value="%s" type="radio">';
		$z[] = '<td>Regular Length, graphic</td>';
		$z[] = '	<input  name="dev_init_05" value="%s" type="radio">';
		$z[] = '<td>Regular Length, Address</td>';
		$z[] = '	<input  name="dev_init_06" value="%s" type="radio">';
		$z[] = '<td>Deleted Entry</td>';
		$z[] = '	<input  name="dev_init_07" value="%s" type="radio">';
		$z[] = '<td>Non-Latin Entry</td>';
		$z[] = '	<input  name="dev_init_08" value="%s" type="radio">';
		$z[] = '<td>Contact Groups</td>';
		$z[] = '	<input  name="dev_init_09" value="%s" type="radio">';
		*/

		$z[] = '<td rowspan="10">PIM Data: Contacts/Address Book Entries</td>';
		$z[] = '<td>Regular Length</td>';
		$z[] = '	<input %s  name="dev_init_00" value=%s type="radio">';
		$z[] = '<td>Maximum Length</td>';
		$z[] = '	<input %s  name="dev_init_01" value=%s type="radio">';
		$z[] = '<td>Special Character</td>';
		$z[] = '	<input %s  name="dev_init_02" value=%s type="radio">';
		$z[] = '<td>Blank Name</td>';
		$z[] = '	<input %s  name="dev_init_03" value=%s type="radio">';
		$z[] = '<td>Regular Length, email</td>';
		$z[] = '	<input %s  name="dev_init_04" value=%s type="radio">';
		$z[] = '<td>Regular Length, graphic</td>';
		$z[] = '	<input %s  name="dev_init_05" value=%s type="radio">';
		$z[] = '<td>Regular Length, Address</td>';
		$z[] = '	<input %s  name="dev_init_06" value=%s type="radio">';
		$z[] = '<td>Non-Latin Entry</td>';
		$z[] = '	<input %s  name="dev_init_07" value=%s type="radio">';
		$z[] = '<td>Contact Groups</td>';
		$z[] = '	<input %s  name="dev_init_08" value=%s type="radio">';
		$z[] = '<td>Deleted Entry</td>';
		$z[] = '	<input %s  name="dev_init_09" value=%s type="radio">';
		
//		$z[] = '<td rowspan="5">PIM Data: Datebook/Calendar, Memos</td>';
		$z[] = '<td rowspan="5">PIM Data: Calendar data, Memos</td>';
		$z[] = '<td>Regular Length</td>';
		$z[] = '	<input %s  name="dev_init_10" value=%s type="radio">';
		$z[] = '<td>Maximum Length</td>';
		$z[] = '	<input %s  name="dev_init_11" value=%s type="radio">';
		$z[] = '<td>Special Character</td>';
		$z[] = '	<input %s  name="dev_init_12" value=%s type="radio">';
		$z[] = '<td>Blank Entry</td>';
		$z[] = '	<input %s  name="dev_init_13" value=%s type="radio">';
		$z[] = '<td>Deleted Entry</td>';
		$z[] = '	<input %s  name="dev_init_14" value=%s type="radio">';
		
		$z[] = '<td rowspan="8">Stand-alone data files</td>';
		$z[] = '<td>Audio</td>';
		$z[] = '	<input %s  name="dev_init_39" value=%s type="radio">';
		$z[] = '<td>Graphic</td>';
		$z[] = '	<input %s  name="dev_init_40" value=%s type="radio">';
		$z[] = '<td>Video</td>';
		$z[] = '	<input %s  name="dev_init_41" value=%s type="radio">';
		$z[] = '<td>Documents</td>';
		$z[] = '	<input %s  name="dev_init_55" value=%s type="radio">';
		$z[] = '<td>Audio – Deleted</td>';
		$z[] = '	<input %s  name="dev_init_42" value=%s type="radio">';
		$z[] = '<td>Graphic - Deleted</td>';
		$z[] = '	<input %s  name="dev_init_43" value=%s type="radio">';
		$z[] = '<td>Video - Deleted</td>';
		$z[] = '	<input %s  name="dev_init_44" value=%s type="radio">';
		$z[] = '<td>Documents - Deleted</td>';
		$z[] = '	<input %s  name="dev_init_56" value=%s type="radio">';
		
		$z[] = '<td rowspan="6">Call Logs</td>';
		$z[] = '<td>Incoming</td>';
		$z[] = '	<input %s  name="dev_init_15" value=%s type="radio">';
		$z[] = '<td>Outgoing</td>';
		$z[] = '	<input %s  name="dev_init_16" value=%s type="radio">';
		$z[] = '<td>Missed</td>';
		$z[] = '	<input %s  name="dev_init_17" value=%s type="radio">';
		$z[] = '<td>Incoming – Deleted</td>';
		$z[] = '	<input %s  name="dev_init_18" value=%s type="radio">';
		$z[] = '<td>Outgoing – Deleted</td>';
		$z[] = '	<input %s  name="dev_init_19" value=%s type="radio">';
		$z[] = '<td>Missed   - Deleted</td>';
		$z[] = '	<input %s  name="dev_init_20" value=%s type="radio">';

		//		$z[] = '<td rowspan="11">Text Messages</td>';
		$z[] = '<td rowspan="12">SMS/EMS Messages</td>';
		$z[] = '<td>Incoming SMS – Read</td>';
		$z[] = '	<input %s  name="dev_init_21" value=%s type="radio">';
		$z[] = '<td>Incoming SMS – Unread</td>';
		$z[] = '	<input %s  name="dev_init_22" value=%s type="radio">';
		$z[] = '<td>Incoming SMS – Deleted</td>';
		$z[] = '	<input %s  name="dev_init_27" value=%s type="radio">';
		$z[] = '<td>Incoming EMS – Read</td>';
		$z[] = '	<input %s  name="dev_init_24" value=%s type="radio">';
		$z[] = '<td>Incoming EMS – Unread</td>';
		$z[] = '	<input %s  name="dev_init_25" value=%s type="radio">';
		$z[] = '<td>Incoming EMS – Deleted</td>';
		$z[] = '	<input %s  name="dev_init_29" value=%s type="radio">';		
		$z[] = '<td>Outgoing SMS</td>';
		$z[] = '	<input %s  name="dev_init_23" value=%s type="radio">';
		$z[] = '<td>Outgoing Group SMS</td>';
		$z[] = '	<input %s  name="dev_init_31" value=%s type="radio">';		
		$z[] = '<td>Outgoing SMS – Deleted</td>';
		$z[] = '	<input %s  name="dev_init_28" value=%s type="radio">';		
		$z[] = '<td>Outgoing EMS</td>';
		$z[] = '	<input %s  name="dev_init_26" value=%s type="radio">';
		$z[] = '<td>Outgoing Group EMS</td>';
		$z[] = '	<input %s  name="dev_init_54" value=%s type="radio">';
		$z[] = '<td>Outgoing EMS – Deleted</td>';
		$z[] = '	<input %s  name="dev_init_30" value=%s type="radio">';
		
//		$z[] = '<td>Non-Latin SMS/EMS</td>';
//		$z[] = '	<input %s  name="dev_init_31" value=%s type="radio">';
		
		$z[] = '<td rowspan="6">MMS Messages</td>';
		$z[] = '<td>Incoming Audio</td>';
		$z[] = '	<input %s  name="dev_init_32" value=%s type="radio">';
		$z[] = '<td>Incoming Graphic</td>';
		$z[] = '	<input %s  name="dev_init_33" value=%s type="radio">';
		$z[] = '<td>Incoming Video</td>';
		$z[] = '	<input %s  name="dev_init_34" value=%s type="radio">';
		$z[] = '<td>Outgoing Audio</td>';
		$z[] = '	<input %s  name="dev_init_35" value=%s type="radio">';
		$z[] = '<td>Outgoing Graphic</td>';
		$z[] = '	<input %s  name="dev_init_36" value=%s type="radio">';
		$z[] = '<td>Outgoing Video</td>';
		$z[] = '	<input %s  name="dev_init_37" value=%s type="radio">';

		$z[] = '<td rowspan="2">Location Data</td>';
		$z[] = '<td>GPS Coordinates</td>';
		$z[] = '	<input %s  name="dev_init_48" value=%s type="radio">';
		$z[] = '<td>Geo-tagged Data</td>';
		$z[] = '	<input %s  name="dev_init_49" value=%s type="radio">';
		
		$z[] = '<td rowspan="3">Browser/Email Data</td>';
		$z[] = '<td>Visited Sites</td>';
		$z[] = '	<input %s  name="dev_init_45" value=%s type="radio">';
		$z[] = '<td>Bookmarks</td>';
		$z[] = '	<input %s  name="dev_init_46" value=%s type="radio">';
		$z[] = '<td>Email</td>';
		$z[] = '	<input %s  name="dev_init_47" value=%s type="radio">';
				
		$z[] = '<td rowspan="4">Social Media Data</td>';
		$z[] = '<td>Application 1, e.g., Facebook</td>';
		$z[] = '	<input %s  name="dev_init_50" value=%s type="radio">';
		$z[] = '<td>Application 2, e.g., Twitter</td>';
		$z[] = '	<input %s  name="dev_init_51" value=%s type="radio">';
		$z[] = '<td>Application 3, e.g., LinkedIn</td>';
		$z[] = '	<input %s  name="dev_init_52" value=%s type="radio">';
		$z[] = '<td>Application 4, e.g., Instagram</td>';
		$z[] = '	<input %s  name="dev_init_53" value=%s type="radio">';

		$z[] = '<td rowspan="1">Other Applications of Interest</td>';
//		$z[] = '<td>Other Applications of Interest</td>';
		$z[] = '<td>Other Applications of Interest</td>';
		$z[] = '	<input %s  name="dev_init_38" value=%s type="radio">';
		
		$zz[] = '<td rowspan="5">Abbreviated Dialing Numbers (ADN)</td>';
		$zz[] = '<td>Regular Length</td>';
		$zz[] = '	<input %s  name="sim_init_00" value=%s type="radio">';
		$zz[] = '<td>Maximum Length</td>';
		$zz[] = '	<input %s  name="sim_init_01" value=%s type="radio">';
		$zz[] = '<td>Special Character</td>';
		$zz[] = '	<input %s  name="sim_init_02" value=%s type="radio">';
		$zz[] = '<td>Blank Name</td>';
		$zz[] = '	<input %s  name="sim_init_03" value=%s type="radio">';
		$zz[] = '<td>Non-ASCII Entry</td>';
		$zz[] = '	<input %s  name="sim_init_04" value=%s type="radio">';
		
		$zz[] = '<td rowspan="1">Call Logs</td>';
		$zz[] = '<td>Last Numbers Dialed (LND)</td>';
		$zz[] = '	<input %s  name="sim_init_05" value=%s type="radio">';
		
		$zz[] = '<td rowspan="8">Text Messages</td>';
		$zz[] = '<td>Incoming SMS - Read</td>';
		$zz[] = '	<input %s  name="sim_init_06" value=%s type="radio">';
		$zz[] = '<td>Incoming SMS - Unread</td>';
		$zz[] = '	<input %s  name="sim_init_07" value=%s type="radio">';
		$zz[] = '<td>Incoming SMS - Non-ASCII</td>';
		$zz[] = '	<input %s  name="sim_init_08" value=%s type="radio">';
		$zz[] = '<td>Incoming SMS - Deleted</td>';
		$zz[] = '	<input %s  name="sim_init_09" value=%s type="radio">';
		$zz[] = '<td>Incoming EMS - Read</td>';
		$zz[] = '	<input %s  name="sim_init_10" value=%s type="radio">';
		$zz[] = '<td>Incoming EMS - Unread</td>';
		$zz[] = '	<input %s  name="sim_init_11" value=%s type="radio">';
		$zz[] = '<td>Incoming EMS - Non-ASCII</td>';
		$zz[] = '	<input %s  name="sim_init_12" value=%s type="radio">';
		$zz[] = '<td>Incoming EMS - Deleted</td>';
		$zz[] = '	<input %s  name="sim_init_13" value=%s type="radio">';

		echo '<form method="POST" onsubmit="return ck_mobile(this)"';
		echo 'action="ft_mdt_update_setup.php">';
//		echo '<h3 style="font-size:1.6em; color:#9D0F19; position:relative;top:5px;"><b>Device Setup</b></h3>';
		echo '<p><i>Documenting Device Setup</i></p>';
		echo '<!------------------------------------------------------------- -->';
		echo '<div style="padding: 0em 1em 0em 0em; background: #eeeeee url(/images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x;">';
		echo '<table class="bordered_table" style="position:relative;top:-13px;">';
		//echo '<tr><th colspan="2" style="text-align: center;"><b>Data Type</b></th><th colspan="2" style="text-align: center;"><b>Status</b></th></tr>';
		echo '<tr><th colspan="2"><b>Data Type</b></th><th colspan="2"><b>Setup</b></th></tr>';
		echo '<tr>';
		$ckp = 'checked=checked';
		$cko = '';
		printf ('<input type="hidden" name="selected_device" value="%s">',$selected_device);
		foreach ($z as $x){
			if (strstr($x,'radio') == FALSE){
				printf ("%s\n",$x);
			}
			else {
				$xin = explode ('"',$x);
				$ckp = '';
				$cko = '';
				if (trim($state[$xin[1]]) == 'populated') $ckp = 'checked=checked';
				else $cko = 'checked=checked';
				printf ("<td>");
				/*
				printf("[%s] [%s]", $xin[1],$state[$xin[1]]);
				*/
				$q = sprintf("%s",$x);
				$qq = sprintf ($q,$ckp,"populated");
				printf ("%s %s</td>",$qq,"Populated");

				printf ("<td>");
				$q = sprintf("%s\n",$x);
				$qq = sprintf ($q,$cko,"omitted");
				printf ("%s %s</td>",$qq,"Omitted");
				printf ("</tr><tr>\n\n");
			}
		}
		echo '</tr>';
		echo '</table>';
		//<!------------------------------------------------------------- -->
		echo '</div><br>';

		// does the device have an associated sim/uicc?
		if ($p_sim[$selected_device] == 'sim'){
			//echo "<h1>SIM/UICC Setup</h1>";
			//echo "\n<table>";
//			echo '<h3 style="font-size:1.6em; color:#9D0F19; position:relative;top:5px;"><b>SIM/UICC Setup</b></h3>';
			echo '<p><i>Documenting SIM/UICC Setup</i></p>';
			echo '<!------------------------------------------------------------- -->';
			echo '<div style="padding: 0em 1em .25em 0em; background: #eeeeee url(/images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x;">';
			echo '<table class="bordered_table" style="position:relative;top:-13px;">';
			echo '<tr><th colspan="2"><b>Data Type</b></th><th colspan="2"><b>Setup</b></th></tr>';
			echo '<tr>';
			$ckp = 'checked=checked';
			$cko = '';
			foreach ($zz as $x){
				if (strstr($x,'radio') == FALSE){
					printf ("%s\n",$x);
				}
				else {
					$xin = explode ('"',$x);
					$ckp = '';
					$cko = '';
					if (trim($state[$xin[1]]) == 'populated') $ckp = 'checked=checked';
					else $cko = 'checked=checked';
					printf ("<td>");
					/*
					printf("[%s] [%s]", $xin[1],$state[$xin[1]]);
					*/
					$q = sprintf("%s",$x);
					$qq = sprintf ($q,$ckp,"populated");
					printf ("%s %s</td>",$qq,"Populated");

					printf ("<td>");
					$q = sprintf("%s\n",$x);
					$qq = sprintf ($q,$cko,"omitted");
					printf ("%s %s</td>",$qq,"Omitted");
					printf ("</tr><tr>\n\n");
				}
			}
			echo '</tr>';
			echo '</table>';
			//<!------------------------------------------------------------- -->
			echo '</div><br>';
		}
		//<!------------------------------------------------------------- -->
		//echo "</div>";
		echo '&nbsp;&nbsp;<input value="Update Setup for Selected Device" name="select" type="submit">';
		echo '</form>';
	} else { // go back and select a device...
			//echo "<p style=\"font-size:1em;\"><b>Error:</b> <b><i>No device selected. Please use ";
			echo "<p><b>Error:</b> <b><i>No device selected. Please use the browser's ";
			echo "back button to return to the previous page and select the device to ";
			echo "document.</i></b></p>\n";
	}
}
?>
	        
		</div>
		<div class="push"></div>
	</div>
    <!-- Footer Starts-->
        <?php
     $fn = $_SERVER["SCRIPT_FILENAME"];
          print_footer_contents($fn);
        ?>
    <!-- Footer Ends-->

</div></body></html>
