<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- Using the RefDB interface general template this file processes
     deleting a reference entry, as well as adding and removing from
     personal reference lists
-->
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>RefDB query results</title>
        <link href="refdbqxhtml.css" type="text/css" rel="stylesheet"/>
    </head>
    <body>
        <h1>RefDB query results</h1>
        <div class="navigation">
            <h2>Navigation</h2>
            <ul class="navigationMenu">
                <li>
                    <a href="index.html">Login screen</a>
                </li>
                <li>
                    <a href="refdbquery.html">Search references</a>
                </li>
                <li>
                    <a href="refdbkajquery.html">Search keywords, authors, journals</a>
                </li>
                <li>
                    <a href="refdbadd.html">Add new references</a>
                </li>
                <li>
                    <a href="refdbdbquery.php">Change database</a>
                </li>
                <li>
                    <a href="external.php">Search external database</a>
                </li>
                <li>
                    <a href="refdbadmin.php">Administrative Interface</a>
                </li>
                <li>
                    <a href="refdblogout.php">Logout</a>
                </li>
            </ul>
        </div>
        <div class="content">
					<form action="refdbsearch.php" method="post" enctype="multipart/form-data">
		<?
			require_once("include.php");
			
			$database = $_SESSION["database"];
			$name = $_SESSION["name"];
			$passwd = $_SESSION["passwd"];
			$refdbc = $_SESSION["refdbc"];

			//begin to build the command to send to refdbc
			$cmd = "$refdbc -c stdout -d $database -u $name -w $passwd -C ";

			if( isset($deleteref) )  //if you're deleting a reference
			{
				$cmd = $cmd."deleteref ";
			}
			else if( isset($pickref) )  //if you're adding it to your personal list
			{
				$cmd = $cmd."pickref ";
			}
			else if( isset($unpickref) )	//if you're removing it from your personal list
			{	
				$cmd = $cmd."pickref -r ";
			}
			else //if somehow you get to this page not from the search results
			{
				print "Error!";
			}
			
			//This for loop concatenates the references to be deleted/added/removed 
			for( $checkboxNumber = 1; $checkboxNumber <= $numberOfCheckBoxes; $checkboxNumber++)
			{
				$checkIndex = "checkbox".$checkboxNumber;
				if( isset($_POST[$checkIndex] ) )  //if the box is checked
				{
					$number = $_POST[$checkIndex];
					$cmd = $cmd.$number." ";   //concatenate to the list
				}
			}

			exec($cmd, $lines);  //execute the command
			
			foreach($lines as $line) //print the output
			{
				print $line."<br/>\n";
			}
			print "<br/><br/>";
			//These variables are used if you return to the Search Results
			print "<p class='hidden'><input type='hidden' name='return' value='$terms'/></p>\n";
			print "<p class='hidden'><input type='hidden' name='scope' value='$scope'/></p>\n";
			print "<p class='hidden'><input type='submit' name='sendQuery' value='Return to Search Results'/></p>\n";
		?>
		</div>
       <div class="footer">
            <p><a href="http://refdb.sourceforge.net">RefDB</a> reference manager and bibliography
                tool V. <!--VERSION-->0.9.8-1<!--/VERSION--></p>
        </div>
</body>		

</html>

