<?php
$page_title = "SS Select Test Case";
$page_h1 = "Select String Search Test Case";
include "ft_ss_need_logs.php";
/*
printf ("Have tool %d, engine %d, data set %d\n",$need_tool,
	$need_se, $need_ds);
*/

if ($need_tool == 1){
	header ('Location: ft_ss_record_tool.php?mess=xx');
	exit;
}
if ($need_ds == 1){
	header ('Location: ft_ss_data_set.php?mess=xx');
	exit;
}
if ($need_se == 1){
	header ('Location: ft_ss_get_engine.php?mess=xx');
	exit;
}
$dribble = fopen('/tmp/dribble-select.txt','w');
fprintf ($dribble,"Root DIR is %s\n",$root);
fprintf ($dribble,"Have tool %d, engine %d, data set %d\n",$need_tool,
	$need_se, $need_ds);
$engine = chop($engine[0]);
$ds = chop($ds[0]);
$tool[0] = chop($tool[0]);
$tool[1] = chop($tool[1]);
fprintf($dribble,"Tool %s\n",$tool[0]);
fprintf($dribble,"Tool Version %s\n",$tool[1]);
fprintf($dribble,"Engine %s\n",$engine);
fprintf($dribble,"Data Set %s\n",$ds);
fprintf ($dribble, "<br>Start of form items list<br>\n");

$base = $root; /* <<<<<== need to fix path */
$base = $root . $engine . '/' . $ds;
if (!file_exists($root.$engine)){
	mkdir($root.$engine, 0777, true);
}
if (!file_exists($base)){
	mkdir($base, 0777, true);
}

?>
<p>Select the case you want to run,
then submit to see what settings are needed for the search
and the strings to search for.
<?php
	printf("<p>Testing Search Engine %s",$engine);
	printf(" on Data Set %s</P>",$ds);
	$case_desc ['FT-SS-01'] = 'Search ASCII';
	$case_desc ['FT-SS-02'] = 'Search Ignore Case';
	$case_desc ['FT-SS-03'] = 'Search for Words';
	$case_desc ['FT-SS-04'] = 'Search Logical AND';
	$case_desc ['FT-SS-05'] = 'Search Logical OR';
	$case_desc ['FT-SS-06'] = 'Search Logical NOT';
	$case_desc ['FT-SS-07-NoBOM'] = 'Search Unicode 16 with no Byte-order-mark';
	$case_desc ['FT-SS-07-Norm'] = 'Normalized search of Unicode with diacritcs and ligatures';
	$case_desc ['FT-SS-07-CJK-char'] = 'Search Unicode Chinese/Japanese ideograms (Asian)';
	$case_desc ['FT-SS-07-CJK-hangul'] = 'Search Unicode CJK Korean Hangul (Asian)';
	$case_desc ['FT-SS-07-CJK-kana'] = 'Search Unicode CJK Japanese phonetic Kana (Asian)';
	$case_desc ['FT-SS-07-Cyrillic'] = 'Search Unicode Cyrillic (Russian)';
	$case_desc ['FT-SS-07-Latin'] = 'Search Unicode Latin (French & German)';
	$case_desc ['FT-SS-07-RTL'] = 'Search Unicode RTL (Arabic)';
	$case_desc ['FT-SS-08-Email'] = 'Search Tool-defined Queries: Email Address';
	$case_desc ['FT-SS-08-Phone'] = 'Search Tool-defined Queries: Telephone Number';
	$case_desc ['FT-SS-08-SS'] = 'Search Tool-defined Queries: Social Security';
	$case_desc ['FT-SS-09-Doc'] = 'Search Formatted Document Text';
	$case_desc ['FT-SS-09-Frag'] = 'Search Fragmented File';
	$case_desc ['FT-SS-09-Lost'] = 'Search Inaccessable (lost) Areas';
	$case_desc ['FT-SS-09-MFT'] = 'Search File in MFT';
	$case_desc ['FT-SS-09-Meta'] = 'Search file name substring in Meta-data';
	$case_desc ['FT-SS-09-Stem'] = 'Search for matches to word stem';
	$case_desc ['FT-SS-10-Hex'] = 'Search Hexadecimal Character Match';
	$case_desc ['FT-SS-10-Regex'] = 'Search Pattern Character Match';
	$ignore ['FT-SS-09-Frag'] = 'Search Fragmented File';
	$ignore ['FT-SS-09-Lost'] = 'Search Inaccessable (lost) Areas';
	$ignore ['FT-SS-09-MFT'] = 'Search File in MFT';

	$row = <<<END
	<tr><td>
	<input type="radio" name="case_to_run" value="%s" required>
	%s</td> <td> %s <td> %s </td>
	</tr>
END;

?>

<form method="POST"
action="/stringsearch/res.php">
<table border='1'><tbody>
<tr><th>Case</th>
<th>Case Status</th>
<th>Case Description</th></tr>

<?php
	foreach ($case_desc as $ix => $desc){
		if (!((strcmp($ds,'UNIX') == 0) and (isset($ignore[$ix])))){
		/*
		if (!isset($ignore[$ix])){
		*/
		$state = 'Pending';
		if (file_exists($base.'/'.$ix.'.txt')){
			$state = 'Done';
		}
		printf ($row,$ix,$ix,$state,$desc);
		}
	}
	printf ('</table>');
	/*
	$dir = $base;
	echo '<br>LIST: '.$dir."\n";
	if ($dirh = opendir($dir)){
		echo "Open OK\n";
		while (($f = readdir($dirh)) !== false){
			echo '<br>';
			if (file_exists($base.'/'.$f)){
				echo " $f exists in $base ";
			}
			echo $f;
			echo " OK\n";
		}
	}
	echo " <br> DONE\n";
	*/
?>
<input value="Show Instructions for Running Case" type="submit"> </p>
</form>

	<p>
	<a href="/stringsearch/string-search.php">
	Return to String Search Home Page</a><br>
	</p>
<?php
	include "ft_ss_tail.php";
?>
