#!/usr/bin/perl

require "config.idx";

$long = $ENV{'QUERY_STRING'};

if ($long) {
	@pairs=split(/&/,$long);
	foreach $item(@pairs) {
		($name,$content)=split (/=/,$item,2);
		$content=~tr/+/ /;
		$content=~ s/%(..)/pack("c",hex($1))/ge;
		if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$content; }
		else { $INPUT{$name} = $content; }
	}
}
else {
	read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
	@pairs = split(/&/, $buffer);
	foreach $pair (@pairs) {
		($name, $value) = split(/=/, $pair);
		$value =~ tr/+/ /;
		$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
		if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; }
		else { $INPUT{$name} = $value; }
	}
}

&checklogin;

print qq~
<html>
<head>
<title>Connect.EagleSold.com - Admin Tools</title>
~;

&header;


print qq~
<td valign="top" width="581">
<img src="images/headers/transaction_manager.gif" height="33" width="581" alt="My Transaction Manager"><br><br>
~;

print qq~
<br>
<table border="0" cellpadding="3" cellspacing="1" width="100%">
<tr>
<td valign="top" width="100%">
<font size="4">Board Email Directory</font><br><br>
~;


use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;

my $aasth = $dbh->prepare("select * from trans_boarddirectory GROUP BY email ORDER BY company ASC");
$aasth->execute;

while ($data_ref = $aasth->fetchrow_hashref()) {
%email_data = %$data_ref;

print qq~
$email_data{email},
~;

}

print qq~
</td>
</tr>
</table>
~;
&footer;