<?php
    require_once 'dbtools.php';
    
    $result = pg_query("select whitelisteddate, whitelistedby, address, comment from whitelist order by whitelisteddate, address");
    
    print("<div class=\"whitelistresok\" id=\"whitelistres\">");
    print("you weren't suppose to be able to see nor this");
    print("<p id=\"errormessage\">neither this</p>");
    print("</div>\n");

    print("<table class=\"histtable\">\n");
    print("<tr class=\"histtabhead\"><th><input type=\"checkbox\" name=\"toggleall\" id=\"toggleall\"></th><th>Date</th><th>Address</th><th>By Whom</th><th>Comment</th></tr>");
    $rowcount = 0;
    $maxlen = 48;
    while ($row = pg_fetch_array($result)) {
	if (strlen($row['comment']) > $maxlen) {
	    $row['comment'] = substr($row['envfrom'], 0, $maxlen);
	}
	print("<tr class=\"".getrowclass($rowcount,"sumtabrowlite", "sumtabrowdark")."\">");
	print("
	    <td class=\"histtabcellpassivecenter\">
		<input type=\"checkbox\" name=\"toggle-$rowcount\">
	    </td>");
        print("
	    <td class=\"histtabcellpassive\">"
		.$row['whitelisteddate'].
	    "</td>");
	print("
	    <td class=\"histtabcell\" onclick=\"javascript:document.getElementById('address-".$rowcount."').submit()\">
		<form action=\"relay.php\" method=\"post\" id=\"address-$rowcount\"\">
                    <input type=\"hidden\" name=\"relaypresip\" value=\"".$row['address']."\"/>
                    <input type=\"hidden\" name=\"gimmedates\" value=\"1\"/>
                </form>".$row['address'].
	    "</td>");
	print("
	    <td class=\"histtabcellpassive\">"
		.$row['whitelistedby'].
	    "</td>");
	print("
	    <td class=\"histtabcellpassive\">"
		.$row['comment'].
	    "</td>");
	print("</tr>\n");
	$rowcount++;
    }
    print("</table>\n");
    
    print("</div>\n");
?>
