function display_message($auth_user, $accountid, $messageid, $fullheaders)
{
    //show an email message
    global $table_width;
    $buttons = array();
    $buttons[0] = 'reply';
    $buttons[1] = 'reply-all';
    $buttons[2] = 'forward';
    $buttons[3] = 'delete';
    if ($fullheaders) {
        $buttons[4] = 'hide-headers';
    } else {
        $buttons[4] = 'show-headers';
    }
    $message = retrieve_message($auth_user, $accountid, $messageid, $fullheaders);
    if (sizeof($message) == 0) {
        echo "<p style=\"padding-bottom: 100px\">Cannot retrieve message number " . $messageid . ".</p>";
    } else {
        $message = pretty_all($message);
    }
    ?>
  <table width="<?php 
    echo $table_width;
    ?>
" cellpadding="4" cellspacing="0" border="0">
  <tr>
    <td bgcolor="#cccccc"><strong>Subject:</strong></td>
    <td bgcolor="#cccccc"><strong><?php 
    echo $message[subject];
    ?>
</strong></td>
  </tr>
  <tr>
    <td bgcolor="#cccccc"><strong>From:</strong></td>
    <td bgcolor="#cccccc"><strong><?php 
    echo $message[fromaddress];
    ?>
</strong></td>
  </tr>
  <tr>
    <td bgcolor="#cccccc"><strong>To:</strong></td>
    <td bgcolor="#cccccc"><strong><?php 
    echo $message[toaddress];
    ?>
</strong></td>
  </tr>
  <tr>
    <td bgcolor="#cccccc"><strong>CC:</strong></td>
    <td bgcolor="#cccccc"><strong><?php 
    echo $message[ccaddress];
    ?>
</strong></td>
  </tr>
  <tr>
    <td bgcolor="#cccccc"><strong>Received:</strong></td>
    <td bgcolor="#cccccc"><strong><?php 
    echo $message[date];
    ?>
</strong></td>
  </tr>
  </table>

  <?php 
    display_toolbar($buttons, "&messageid={$messageid}");
    ?>
  <table width="<?php 
    echo $table_width;
    ?>
" cellpadding="4" cellspacing="0" border="0">
  <tr>
    <td bgcolor="#cccccc">
    <?php 
    echo $message[fullheaders];
    ?>
    </td>
  </tr>
  </table>

  <table width="<?php 
    echo $table_width;
    ?>
" cellpadding="4" cellspacing="0" border="0">
  <tr>
    <td>
    <?php 
    echo $message[body];
    ?>
    </td>
  </tr>
  </table>
<?php 
}
if (!check_admin_user()) {
    echo 'You do not seem to be authorized to use this page.';
    exit;
}
// set up the admin toolbar buttons
$buttons = array();
$buttons[0] = 'change-password';
$buttons[1] = 'create-list';
$buttons[2] = 'create-mail';
$buttons[3] = 'view-mail';
$buttons[4] = 'log-out';
$buttons[5] = 'show-all-lists';
$buttons[6] = 'show-my-lists';
$buttons[7] = 'show-other-lists';
do_html_header('Pyramid-MLM - Upload Files');
display_toolbar($buttons);
// check that the page is being called with the required data
if (!$HTTP_POST_FILES['userfile']['name'][0] || !$HTTP_POST_FILES['userfile']['name'][1] || !$HTTP_POST_VARS['subject'] || !$HTTP_POST_VARS['list']) {
    echo 'Problem: You did not fill out the form fully. The images are the 
            only optional fields.  Each message needs a subject, text version 
            and an HTML version.';
    do_html_footer();
    exit;
}
$list = $HTTP_POST_VARS['list'];
$subject = $HTTP_POST_VARS['subject'];
if (!db_connect()) {
    echo '<p>Could not connect to db</p>';
    do_html_footer();
    exit;
}
function display_message($auth_user, $accountid, $messageid, $fullheaders)
{
    //show an email message
    global $table_width;
    $buttons = array();
    $buttons[0] = 'reply';
    $buttons[1] = 'reply-all';
    $buttons[2] = 'forward';
    $buttons[3] = 'delete';
    if ($fullheaders) {
        $buttons[4] = 'hide-headers';
    } else {
        $buttons[4] = 'show-headers';
    }
    $message = retrieve_message($auth_user, $accountid, $messageid, $fullheaders);
    if (sizeof($message) == 0) {
        echo "cannot retrieve message number {$messageid}" . '.<br /><br /><br /><br /><br />';
    } else {
        $message = pretty_all($message);
        ?>
  <table width = <?php 
        echo $table_width;
        ?>
 cellpadding = 4 cellspacing = 0  border = 0>
  <tr>
    <td bgcolor = '#cccccc'>
      <b> Subject: </b>
    </td>
    <td bgcolor = '#cccccc'>
      <b> <?php 
        echo $message[subject];
        ?>
 </b>
    </td>
  </tr>
  <tr>
    <td bgcolor = '#cccccc'>
      <b> From: </b>
    </td>
    <td bgcolor = '#cccccc'>
      <b> <?php 
        echo $message[fromaddress];
        ?>
 </b>
    </td>
  </tr>
  <tr>
    <td bgcolor = '#cccccc'>
      <b> To: </b>
    </td>
    <td bgcolor = '#cccccc'>
      <b> <?php 
        echo $message[toaddress];
        ?>
 </b>
    </td>
  </tr>
  <tr>
    <td bgcolor = '#cccccc'>
      <b> CC: </b>
    </td>
    <td bgcolor = '#cccccc'>
      <b> <?php 
        echo $message[ccaddress];
        ?>
 </b>
    </td>
  </tr>
  <tr>    
    <td bgcolor = '#cccccc'>
      <b> Received: </b>
    </td>
    <td bgcolor = '#cccccc'>
      <b> <?php 
        echo $message[date];
        ?>
 </b>
    </td>
  </tr>
  </table>
  
  <?php 
        display_toolbar($buttons, "&messageid={$messageid}");
        ?>
  <table width = <?php 
        echo $table_width;
        ?>
 cellpadding = 4 cellspacing = 0  border = 0>
  <tr>
    <td bgcolor = '#cccccc'>
  
    <?php 
        echo $message[fullheaders];
        ?>
  
    </td>
  </tr>
  </table>
  
  <table width = <?php 
        echo $table_width;
        ?>
 cellpadding = 4 cellspacing = 0  border = 0>
  <tr>
    <td>
  
    <?php 
        echo $message[body];
        ?>
  
    </td>
  </tr>
  </table>
<?php 
    }
}