| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * view_header.php |
| 5 | * |
| 6 | * Copyright (c) 1999-2004 The SquirrelMail Project Team |
| 7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 8 | * |
| 9 | * This is the code to view the message header. |
| 10 | * |
| 11 | * @version $Id$ |
| 12 | * @package squirrelmail |
| 13 | */ |
| 14 | |
| 15 | /** |
| 16 | * Path for SquirrelMail required files. |
| 17 | * @ignore |
| 18 | */ |
| 19 | define('SM_PATH','../'); |
| 20 | |
| 21 | /* SquirrelMail required files. */ |
| 22 | require_once(SM_PATH . 'include/validate.php'); |
| 23 | require_once(SM_PATH . 'functions/global.php'); |
| 24 | require_once(SM_PATH . 'functions/imap.php'); |
| 25 | require_once(SM_PATH . 'functions/html.php'); |
| 26 | require_once(SM_PATH . 'functions/url_parser.php'); |
| 27 | |
| 28 | function parse_viewheader($imapConnection,$id, $passed_ent_id) { |
| 29 | |
| 30 | if (!$passed_ent_id) { |
| 31 | $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]", |
| 32 | true, $a, $b, TRUE); |
| 33 | } else { |
| 34 | $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]'; |
| 35 | $read=sqimap_run_command ($imapConnection, $query, |
| 36 | true, $a, $b, TRUE); |
| 37 | } |
| 38 | $cnum = 0; |
| 39 | for ($i=1; $i < count($read); $i++) { |
| 40 | $line = htmlspecialchars($read[$i]); |
| 41 | switch (true) { |
| 42 | case (eregi("^>", $line)): |
| 43 | $second[$i] = $line; |
| 44 | $first[$i] = ' '; |
| 45 | $cnum++; |
| 46 | break; |
| 47 | case (eregi("^[ |\t]", $line)): |
| 48 | $second[$i] = $line; |
| 49 | $first[$i] = ''; |
| 50 | break; |
| 51 | case (eregi("^([^:]+):(.+)", $line, $regs)): |
| 52 | $first[$i] = $regs[1] . ':'; |
| 53 | $second[$i] = $regs[2]; |
| 54 | $cnum++; |
| 55 | break; |
| 56 | default: |
| 57 | $second[$i] = trim($line); |
| 58 | $first[$i] = ''; |
| 59 | break; |
| 60 | } |
| 61 | } |
| 62 | for ($i=0; $i < count($second); $i = $j) { |
| 63 | $f = (isset($first[$i]) ? $first[$i] : ''); |
| 64 | $s = (isset($second[$i]) ? nl2br($second[$i]) : ''); |
| 65 | $j = $i + 1; |
| 66 | while (($first[$j] == '') && ($j < count($first))) { |
| 67 | $s .= ' ' . nl2br($second[$j]); |
| 68 | $j++; |
| 69 | } |
| 70 | $lowf=strtolower($f); |
| 71 | /* do not mark these headers as emailaddresses */ |
| 72 | if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') { |
| 73 | parseEmail($s); |
| 74 | } |
| 75 | if ($f) { |
| 76 | $header_output[] = array($f,$s); |
| 77 | } |
| 78 | } |
| 79 | sqimap_logout($imapConnection); |
| 80 | return $header_output; |
| 81 | } |
| 82 | |
| 83 | function view_header($header, $mailbox, $color) { |
| 84 | sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER); |
| 85 | $ret_addr = SM_PATH . 'src/read_body.php?'.$queryStr; |
| 86 | |
| 87 | displayPageHeader($color, $mailbox); |
| 88 | |
| 89 | echo '<br />' . |
| 90 | '<table width="100%" cellpadding="2" cellspacing="0" border="0" '. |
| 91 | 'align="center">' . "\n" . |
| 92 | '<tr><td bgcolor="'.$color[9].'" width="100%" align="center"><b>'. |
| 93 | _("Viewing Full Header") . '</b> - '. |
| 94 | '<a href="'; |
| 95 | echo_template_var($ret_addr); |
| 96 | echo '">' ._("View message") . "</a></b></td></tr></table>\n"; |
| 97 | |
| 98 | echo_template_var($header, |
| 99 | array( |
| 100 | '<table width="99%" cellpadding="2" cellspacing="0" border="0" '. |
| 101 | "align=center>\n".'<tr><td>', |
| 102 | '<nobr><tt><b>', |
| 103 | '</b>', |
| 104 | '</tt></nobr>', |
| 105 | '</td></tr></table>'."\n" |
| 106 | ) |
| 107 | ); |
| 108 | echo '</body></html>'; |
| 109 | } |
| 110 | |
| 111 | /* get global vars */ |
| 112 | if ( sqgetGlobalVar('passed_id', $temp, SQ_GET) ) { |
| 113 | $passed_id = (int) $temp; |
| 114 | } |
| 115 | if ( sqgetGlobalVar('mailbox', $temp, SQ_GET) ) { |
| 116 | $mailbox = $temp; |
| 117 | } |
| 118 | if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) { |
| 119 | $passed_ent_id = ''; |
| 120 | } |
| 121 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
| 122 | sqgetGlobalVar('username', $username, SQ_SESSION); |
| 123 | sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); |
| 124 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
| 125 | |
| 126 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, |
| 127 | $imapPort, 0); |
| 128 | $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true); |
| 129 | |
| 130 | $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id); |
| 131 | view_header($header, $mailbox, $color); |
| 132 | |
| 133 | ?> |