<?php
$newby=-1;
require("includes/.htconfig.php");
$menu="<FORM action=$script method=post>";
$menu.="<INPUT name=query><INPUT type=submit name=command value=Run>";
$menu.="<INPUT type=submit name=command value=Map>";
$menu.="<INPUT type=submit name=command value=PHPinfo>";
$menu.="<INPUT type=submit name=command value=Log>";
$menu.="<INPUT type=submit name=command value=Errors>";
$menu.="<INPUT type=submit name=command value=GetURL>";
$menu.="</FORM>";
echo "The position of nda4 is ".getnewby("nda4");

if (isset($_REQUEST["table"]))
{
  echo $menu;
  if (isset($_REQUEST["limit"]))
    echo spill_table($_REQUEST["table"],1,$_REQUEST["limit"]);
  else
    echo spill_table($_REQUEST["table"],1,5);
}
else if (isset($_REQUEST["command"]) && $_REQUEST["command"] == "Run")
{
  echo $menu;
  $query=$_REQUEST["query"];
  echo spill_query_results($query,"Results of<BR>$query",1,100);
}
else if (isset($_REQUEST["command"]) && $_REQUEST["command"] == "PHPinfo")
{
  echo $menu;
  phpinfo();
}
else if (isset($_REQUEST["command"]) && $_REQUEST["command"] == "Log")
{
  echo $menu;
  $content=file_get_contents(LOGFILENAME);
  echo "<H2>The log file at ".LOGFILENAME."</H2><PRE>$content</PRE>";
}
else if (isset($_REQUEST["command"]) && $_REQUEST["command"] == "Errors")
{
  echo $menu;
  $content=file_get_contents(ERRORFILENAME);
  echo "<H2>The error file at ".ERRORFILENAME."</H2><PRE>$content</PRE>";
}
else if (isset($_REQUEST["command"]) && $_REQUEST["command"] == "GetURL")
{
  echo $menu;
  $URL=$_REQUEST["query"];
  if (strlen($URL) <1) $URL="https://www.reliableid.com/ValID/userDetails.php";
  $content=file_get_contents($URL);
  echo "<H2>The results from $URL</H2><PRE>$content</PRE>";
}
else if (isset($_REQUEST["command"]) && $_REQUEST["command"] == "Map")
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=
      <?=GOOGLEKEY?>"
      type="text/javascript"></script>
    <script type="text/javascript">

      //<![CDATA[

    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
      }
    }

    //]]>
    </script>
  </head>
  <body onload="load()" onunload="GUnload()">
    <?=$menu?>
    <div id="map" style="width:500px;height:300px"></div>
  </body>
</html>
<?PHP
}
else    ##no map
{
echo $menu;
echo spill_table("enrollee",1,22);
}
echo "<BR>Or you can choose a table to display:";
$res=mysql_query("SHOW TABLES FROM ".DB);
if ($res)
{
  echo "<TABLE><TR><TH>Four rows</TH><TH>Twenty rows</TH></TR>";
  while($row=mysql_fetch_array($res))
    echo "<TR><TD><A href=$script?table=".$row["Tables_in_".DB].">".$row["Tables_in_".DB]
    ."</A></TD><TD><A href=$script?table=".$row["Tables_in_".DB]."&limit=20>".$row["Tables_in_".DB]
    ."</A></TD>";
  echo "</TABLE>";
}
else
  echo reporterror("Trying to show the tables in the database","SQL SHOW TABLES");
?>