<?php	// TWIG		TEST Script ?>
<?php

 $dbconfigfile="config/dbconfig.inc";
 if (is_readable($dbconfigfile)) {
  include($dbconfigfile);
  if (!$dbconfig["sqltype"]) { $dbconfig["sqltype"] = "mysql"; }
  include("features/" . $dbconfig["sqltype"] . ".db.inc");
 }
 include("features/common.inc");  // Common Functions
 include("config/config.inc");          // Global Configuration Variables

?>
<?php if (!$username && !$password):?>
<b>IMAP</b>:  Enter a username and password to connect to the IMAP server
(<code><?php echo $imap_server?>:<?php echo $imap_port?></code>)
<form action=<?php echo basename($PHP_SELF)?> method=POST>
<table>
 <tr>
  <td>Name<br><input name=username></td>
  <td>Password<br><input name=password type=password></td>
 </tr>
</table>
<input type=submit>
</form>
<hr>
<?php endif;?>

<b>Database</b>:<br>
server: <?php echo $dbconfig[sqlserver]?>:<?php echo $dbconfig[sqlport]?><br>
<?php
 $st="SELECT COUNT(*) FROM twig_todo";
 $rc=dbQuery($st);
 if ($rc) { echo "Working!"; } else { echo "Failed!"; }
?>
<hr>

<?php if ($username && $password):?>
<b>IMAP</b>:
<?php 
 if (!$imap_server) { $imap_server="localhost"; }
 if (!$imap_port) { $imap_port = 143; }
 $mbox = @imap_open("{$imap_server:$imap_port}INBOX",$username,$password);
 if ($mbox) { echo "Works!"; } else { echo "Failed!"; }
?>
<?php endif;?>
