<?
//
// this script is rather ugly i just put it together to give me a pretty
// interface to the conversations logged by pedbot.
//
mysql_connect("", "", "");
mysql_select_db("pedbot");
$font = "font face=\"arial\" size=2";
////
//// build choose sender buffer.
////
$sql_query = "SELECT distinct(sender) FROM log_conversations ORDER BY sender ASC";
$results = mysql_query($sql_query);
$send_buff = "<form name=\"sender\" method=\"post\" action=\"$PHP_SELF\">"
. "<select name=\"sender\" onChange=\"document.sender.submit()\">"
. "<option>-- sender --</option>";
while ($object = mysql_fetch_object($results)) {
if ($object->sender == $sender) $selected = "SELECTED";
else $selected = "";
$send_buff .= "<option value=\"{$object->sender}\" $selected>{$object->sender}</option>";
}
$send_buff .= "</select>";
$send_buff .= "</form>";
////
//// build choose recipient buffer.
////
$sql_query = "SELECT distinct(recipient) FROM log_conversations "
. "WHERE sender = '$sender' ORDER BY recipient";
$results = mysql_query($sql_query);
$reci_buff = "<form name=\"recipient\" method=\"post\" action=\"$PHP_SELF\">"
. "<input type=\"hidden\" name=\"sender\" value=\"$sender\">"
. "<select name=\"recipient\" onChange=\"document.recipient.submit()\">"
. "<option>-- recipient --</option>";
while ($object = mysql_fetch_object($results)) {
if ($object->recipient== $recipient) $selected = "SELECTED";
else $selected = "";
$reci_buff .= "<option value=\"{$object->recipient}\" $selected>{$object->recipient}</option>";
}
$reci_buff .= "</select>";
$reci_buff .= "</form>";
////
//// display choose sender / recipient drop down menus.
////
print <<<END
<table width="90%" border=0 cellpadding=2 cellspacing=2>
<tr>
<td>$send_buff</td>
<td>$reci_buff</td>
<td width="100%"> </td>
</tr>
</table>
END;
////
//// we have both sender and recipient.
////
if ($sender && $recipient) {
$sql_query = "SELECT * FROM log_conversations WHERE sender = '$sender' AND recipient = '$recipient' OR sender = '$recipient' AND recipient = '$sender' ORDER BY timestamp ASC";
$results = mysql_query($sql_query);
print "<table width=\"90%\" border=0 cellpadding=2 cellspacing=2>";
while ($object = mysql_fetch_object($results)) {
if ($object->sender == $sender) $color = "color=\"#0000FF\"";
else $color = "color=\"#FF0000\"";
print "<tr>";
print "<td nowrap><$font>" . date("n/j H:i.s", $object->timestamp) . "</font></td>";
print "<td width=\"100%\"><$font $color><b>{$object->sender}</b>: </font><$font>{$object->message}</font></td>";
print "</tr>";
}
print "</table>";
}
?>