<!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" />
<script>
function ck_mobile(f)
{
	var r =f.elements['selected_device'];
	if (r[r.length-1].checked) {
		mess = ''
		if (f.model.value == '') mess += '\nYou need to enter phome model'
		if (f.make.value == '') mess += '\nYou need to enter phome make'
		if (f.os_version.value == '') mess += '\nYou need to enter phome OS version'
		if (f.firmware.value == '') mess += '\nYou need to enter phome firmware'
		if (mess == '') return true
		alert (mess)
		return false
	}
	return true
}
function ck_selection(f)
{
#	ok = false
	ok = true
	var r =f.elements['selected_device'];
	for (ix = 0, lx = r.length; ix < lx; ix++){
		if (r[ix].checked) {ok = true}
	}
	if (ok) return true
	alert('No device selected, You have to select a device');
	alert(r)
	return false;
}
function ck_selection1(f)
{
	mess = 'fix this mess';
	if (f.selected_device.value == '')
	{
		alert('You need to select a device');
		return false;
	}
	mess += ':\n'+f;
	mess += ':\n'+f.selected_device[0].value;
	alert(mess+': '+f.selected_device.value);
	return false;
}
function ck_tool (f)
{
	mess = '';
	if (f.toolname.value == '') {mess += 'You need to enter tool name.';};
	if (f.toolversion.value == '') {mess += '\nYou need to enter tool version.';};
	if (mess == '' ) {return true;};
	alert(mess);
	return false;
}
</script>
<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; Creating/Editing Mobile Device List</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">Creating/Editing Mobile Device List</h1>';
	//<!--<h2 style="font-size:1.7em; color:#008000">Describe Mobile Devices</h2>-->
	//<!--<h2 style="font-size:1.7em; color:#008000">Describing Mobile Devices</h2>-->
	echo '<h2 style="font-size:1.7em; color:#008000">Adding, Updating or Deleting a Mobile Device</h2>';
	//<!--<h1>Creating/Editing Mobile Device List</h1>-->
	
	echo '<div style="padding: 0em 1em .25em .5em; background: #eeeeee url(/images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x;">';
	//<!-- ======================================================== -->

	echo '<p>Use this page to record your list of test devices. You may add a new device to the list, revise an existing device description, or delete a device.';
	//<!--Use this page to either: (1) Describe a new device, (2) revise a device description, or (3) delete a device.-->
	echo '</p><ul>';
	//<!--<li><b>Describe A Device:</b>-->
	echo '<li><b>Add a new device:</b>';
	echo " fill out the fields in the form after the '<i>List of Test Devices</i>' table to describe the device. ";
	echo "Then select the '<i>Add New Device</i>' button to save it to the list. ";
	echo "<li>As for testing SIM/UICC card acquisition, this is optional. If you want to test SIM/UICC card acquisition, ";
	echo "select one or more phones that have a SIM/UICC card. ";
	echo "</li><li><b>Revise an existing device:</b> revise an existing device description by first selecting the device you want ";
	echo "to change from the '<i>List of Test Devices</i>' table and filling out only the description fields that you want to change. If you ";
	echo "leave a field blank then the current value of the field is unchanged, however, the OS, Network and SIM/UICC ";
	echo "fields have default values and must always be set to the value you want.  Click the '<i>Update Selected Device</i>' ";
	echo "button to apply the changes.";
	echo "</li>";
	echo "<li><b>Delete a device:</b> first select the device you want ";
	echo "to remove from the '<i>List of Test Devices</i>' table then click the '<i>Delete Selected Device</i>' button to remove it. ";
	echo "</ul>";

	echo '<form method="POST" onsubmit="return ck_mobile(this)" action="ft_mdt_update_device.php">';

	$have_phones = FALSE;

	$config_name = sprintf ("%s/mdt-config.txt",$root);
	$dev_name = sprintf ("%s/devices.txt",$root);
	/*
	printf ('<br>FILES: %s %s',$config_name,$dev_name);
	*/
	if (file_exists($dev_name)){
		$dfile = fopen(sprintf("%s/devices.txt",$root),"r");
		/*
		echo sprintf("<br>open %s<br>",$root);
		*/
		$p_line = fgets($dfile);
		while (!feof($dfile)){
			/*
			printf ("<br>LINE: %s",$p_line);
			*/
			$the_phones [] = $p_line;
			$p_line = fgets($dfile);
			$have_phones = TRUE;
		}
	}
	/*
	echo "<br>Start of phone list";
	if ($have_phones)
		{ echo '<br>have phones';
		foreach ($the_phones as $q){
			$p = explode(';',$q);
			echo "<br>";
			echo $p[0];
			echo ' ';
			echo $p[1];
			printf (" %s %s\n",$p[2],$p[3]);
		}
	}
	else { echo '<br>No phones';}
	echo "<br>End of phone list<br>";
	*/

	echo '<p><i>List of Test Devices</i></p>';
	echo '<table class="bordered_table" style="position:relative;top:-13px;">';
	/*<!--<table>
	<caption>
	Known Mobile Devices
	</caption>
	-->*/
	echo "<tbody><tr>";
	echo "<th><b>Select</b></th><th><b>Make</b></th><th><b>Model</b></th>";
	echo "<th><b>OS</b></th><th><b>Version</b></th><th><b>Firmware</b></th>";
	echo "<th><b>Network</b></th><th><b>SIM/UICC</b></th>";
	echo "</tr>";
	/*<!--
	<tr> <td> <input name="selected_device" value="phone01" type="radio"> </td>
	<td> ****MAKER*** </td>
	<td> ****MODEL**** </td>
	<td> iOS </td>
	<td> ****OS-VERSION*** </td>
	<td> ****FIRMWARE**** </td>
	<td> CDMA </td>
	<td> SIM/UICC </td>
	</tr>
	-->*/

	$sim['sim'] = "SIM/UICC";
	$sim['nosim'] = "No SIM/UICC";
	if ($have_phones){
		foreach ($the_phones as $q){
			$p = explode(';',$q);
			//echo $sim[$p[7]];
			//echo "AAA".trim($p[7])."AAA";
			printf ('<tr> <td> <input name="selected_device"');
			printf (' value=%s type="radio"> </td>',$p[0]);
			printf ("<td>%s</td>",$p[1]);
			printf ("<td>%s</td>",$p[2]);
			printf ("<td>%s</td>",$p[3]);
			printf ("<td>%s</td>",$p[4]);
			printf ("<td>%s</td>",$p[5]);
			printf ("<td>%s</td>",$p[6]);
			printf ("<td>%s</td></tr>", $sim[trim($p[7])]);
		}
	} else {
	//	echo '<tr><td><input checked="checked" name="selected_device" value="new_device" type="radio"></td><td colspan="7" align="center">Enter Another Device</td></tr>';
	//	echo '<tr><td colspan="8" align="center">No Devices - fill out the fields in the form below and click \'Add New Device\' to add a device.</td></tr>';
		echo '<tr><td colspan="8" align="center"><i>No devices - complete the form below and click \'Add New Device\' to add a device.</i></td></tr>';
	}

	echo "</tbody></table>";
	//<!--<h2>Make edits or describe new device:</h2>-->
	//<!--<h2>Describe a new device or edit an existing device:</h2>-->
	echo '<h3 style="font-size:1.6em; color:#9D0F19"> <b>Describe a new device or edit an existing device:</b></h3>';
	echo '<p> Enter the device manufacturer: <input name="make" type="text"><br></p>';
	echo '<p> Enter the device model and model number: <input name="model" type="text"><br></p>';
	echo '<p>Select the device OS: <select name="os">';
	echo '<option selected="selected" value="iOS">iOS</option>';
	echo '<option value="Android">Android</option>';
	echo '<option value="Other">Other</option>';
	echo '</select></p>';
	echo '<p> Enter the device OS Version: <input name="os_version" type="text"><br></p>';
	echo '<p> Enter the device firmware: <input name="firmware" type="text"><br></p>';
	echo '<p>Select the device network: <select name="network">';
	echo '<option selected="selected" value="CDMA">CDMA</option>';
	echo '<option value="CDMA/GSM">CDMA/GSM</option>';
	echo '<option value="GSM">GSM</option>';
	echo '</select><br></p>';
	echo '<p><input checked="" name="has_sim" value="sim" type="radio"> Test SIM/UICC card acquisition with this phone<br>';
	echo '<input checked="checked" name="has_sim" value="nosim" type="radio"> No test of SIM/UICC card acquisition test</p>';

	//<!-- ======================================================== -->
	echo '</div>';

	echo '<br><p>';
	//<!--<input value="Add New Device" name="update" type="submit">-->
	echo '<input value="Add New Device" name="new" type="submit"> ';
	echo '<input value="Update Selected Device" name="update" type="submit"> ';
	echo '<input value="Delete Selected Device" name="delete" type="submit">';
	echo '</p></form>';
}
?>

<!--
	<p>
	<a href="mdt.php">
	Return to Mobile Device Home Page</a><br>
	</p>
-->
<br>
		        
		</div>
		<div class="push"></div>
	</div>
    <!-- Footer Starts-->
   <!-- Footer Starts-->
        <?php
     $fn = $_SERVER["SCRIPT_FILENAME"];
          print_footer_contents($fn);
        ?>
    <!-- Footer Ends-->

    <!-- Footer Ends-->
<!--
	<div class="footer"><div class="footerContentsWrapper"><p>The National Institute of Standards and Technology (NIST) is an agency of
 the U.S. Commerce Department.</p><br><br><p class="links"><a href="../Federated_Testing_Home_Page.php">Home</a>
 &nbsp;/&nbsp; <a href="http://localhost/about.php">About</a> &nbsp;/&nbsp;
<a href="mobile-definitions.html">Glossary of Mobile Device Terms</a>
&nbsp;/&nbsp; <a href="http://localhost/FAQ.php">FAQs</a> &nbsp;/&nbsp;
<a href="http://localhost/contacts.php">Contacts</a><br><br>Federated Testing Version:
1.1-3<br>Release Date: --/--/201-</p></div></div>    <!-- Footer Ends-->



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