~ubuntu-branches/ubuntu/hardy/squirrelmail/hardy-updates

« back to all changes in this revision

Viewing changes to plugins/message_details/message_details_bottom.php

  • Committer: Bazaar Package Importer
  • Author(s): Thijs Kinkhorst
  • Date: 2005-02-06 21:41:51 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050206214151-z4n1o8mnttgzuj0y
Tags: 2:1.4.4-3
* Move default_pref config file from /var to /etc, as per Debian policy
  (Closes: #293281)
* [JvW] (finally) override two lintian warnings about nonstandard
  permissions that are intentional (Closes: #293366)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
 
3
 
/** Message Source  
 
2
/**
 
3
 * Message Details plugin - bottom frame with message structure and rfc822 body
4
4
 *
5
5
 * Plugin to view the RFC822 raw message output and the bodystructure of a message
6
6
 *
7
 
 * Copyright (c) 2002 Marc Groot Koerkamp, The Netherlands
8
7
 * Licensed under the GNU GPL. For full terms see the file COPYING.
9
 
 * 
10
 
 * $Id: message_details_bottom.php,v 1.12 2003/10/27 22:24:40 tassium Exp $
 
8
 *
 
9
 * @author Marc Groot Koerkamp
 
10
 * @copyright Copyright &copy; 2002 Marc Groot Koerkamp, The Netherlands
 
11
 * @copyright Copyright &copy; 2004-2005 The SquirrelMail Project Team
 
12
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 
13
 * @version $Id: message_details_bottom.php,v 1.10.2.3 2004/12/27 15:03:58 kink Exp $
11
14
 * @package plugins
12
15
 * @subpackage message_details
13
16
 */
19
22
require_once(SM_PATH . 'include/validate.php');
20
23
require_once(SM_PATH . 'functions/imap.php');
21
24
require_once(SM_PATH . 'functions/mime.php');
22
 
require_once(SM_PATH . 'config/config.php');
23
 
require_once(SM_PATH . 'functions/prefs.php');
24
25
 
25
26
global $color, $uid_support;
26
27
 
31
32
sqgetGlobalVar('key', $key, SQ_COOKIE);
32
33
sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
33
34
 
 
35
/**
 
36
 * Calculates id of MIME entity
 
37
 * @param string $entString
 
38
 * @param integer $direction
 
39
 * @return string
 
40
 * @access private
 
41
 */
34
42
function CalcEntity($entString, $direction) {
35
43
    $result = $entString;
36
44
    if ($direction == -1) {
61
69
    return ($result);
62
70
}
63
71
 
64
 
function returnTime($start) {
65
 
 $stop = gettimeofday();
66
 
 $timepassed =  1000000 * ($stop['sec'] - $start['sec']) + $stop['usec'] - $start['usec'];
67
 
 return $timepassed;
68
 
}
69
 
 
70
 
function GetMimeProperties($header) {
71
 
}
72
 
 
73
72
$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
74
73
$read = sqimap_mailbox_select($imapConnection, $mailbox);
75
 
$start = gettimeofday();
76
74
$body = sqimap_run_command($imapConnection, "FETCH $passed_id RFC822",true, $response, $readmessage, $uid_support);
77
75
$message_body = '';
78
76
$header = false;
104
102
        } else if ($messageheader) {
105
103
            if ($header) {
106
104
                $header=false;
107
 
                $end = "\n \n".'</div>'."\n \n".'<div class="ent_body" ID="'.$entStr.'B">'."\n \n"; 
 
105
                $end = "\n \n".'</div>'."\n \n".'<div class="ent_body" id="'.$entStr.'B">'."\n \n"; 
108
106
            }
109
107
            $mimepart = -$header;
110
108
            $bnd_end = false;
116
114
        } else {
117
115
            if ($header) {
118
116
                $pre = '';
119
 
                $end = "\n \n".'</div>'."\n \n".'<div class="ent_body" ID="'.$entStr.'B">'."\n \n"; 
 
117
                $end = "\n \n".'</div>'."\n \n".'<div class="ent_body" id="'.$entStr.'B">'."\n \n"; 
120
118
            }
121
119
            $header = false;
122
120
            $mimepart=true;
128
126
            $messageheaderstart=true;
129
127
            if ($pre != '<b>') {
130
128
                $pre = '<i><font color ='."$color[1]>";
131
 
                $end = '</i></font>';
 
129
                $end = '</font></i>';
132
130
            }
133
131
        }     
134
132
        if (!$messageheader && !$header ) {
140
138
        $end = '';
141
139
    }
142
140
    if (  ( $header || $messageheader) && (preg_match("/^.*boundary=\"?(.+(?=\")|.+).*/i",$line,$reg)) )  {
143
 
        $bnd = $reg[1];
144
 
        $bndreg = $bnd;    
145
 
        $bndreg = str_replace("\\","\\\\",$bndreg);     
146
 
        $bndreg = str_replace("?","\\?",$bndreg);
147
 
        $bndreg = str_replace("+","\\+",$bndreg);               
148
 
        $bndreg = str_replace(".","\\.",$bndreg);                       
149
 
        $bndreg = str_replace("/","\\/",$bndreg);
150
 
        $bndreg = str_replace("-","\\-",$bndreg);
151
 
        $bndreg = str_replace("(","\\(",$bndreg);
152
 
        $bndreg = str_replace(")","\\)",$bndreg);
 
141
        $bnd = $reg[1];
 
142
        $bndreg = $bnd;    
 
143
        $bndreg = str_replace("\\","\\\\",$bndreg);     
 
144
        $bndreg = str_replace("?","\\?",$bndreg);
 
145
        $bndreg = str_replace("+","\\+",$bndreg);               
 
146
        $bndreg = str_replace(".","\\.",$bndreg);                       
 
147
        $bndreg = str_replace("/","\\/",$bndreg);
 
148
        $bndreg = str_replace("-","\\-",$bndreg);
 
149
        $bndreg = str_replace("(","\\(",$bndreg);
 
150
        $bndreg = str_replace(")","\\)",$bndreg);
153
151
 
154
 
        $boundaries[] = array( 'bnd' => $bnd, 'bndreg' => $bndreg);
155
 
        $messageheader = false;
156
 
        $messageheaderstart=false;
157
 
        $mimepart=false;
158
 
        if ($entStr=='') {
159
 
            $entStr='0';
160
 
        } else {
161
 
            $entStr = CalcEntity("$entStr",1);
162
 
        }
 
152
        $boundaries[] = array( 'bnd' => $bnd, 'bndreg' => $bndreg);
 
153
        $messageheader = false;
 
154
        $messageheaderstart=false;
 
155
        $mimepart=false;
 
156
        if ($entStr=='') {
 
157
            $entStr='0';
 
158
        } else {
 
159
            $entStr = CalcEntity("$entStr",1);
 
160
        }
163
161
    }
164
162
    
165
163
    if (($line != '' && $line{0} == '-' || $header)  && isset($boundaries[0])) {
176
174
                    $bndend = true;
177
175
            }
178
176
            if ($bndend) {
179
 
                $entStr = CalcEntity("$entStr",-1);
180
 
                array_pop($boundaries);
181
 
                $pre .= '<b><font color ='."$color[2]>";
182
 
                $end .= '</font></b>';
183
 
                $header = true;
184
 
                $mimepart = false;
185
 
                $bnd_end = true;
186
 
                $encoding = '';
 
177
            $entStr = CalcEntity("$entStr",-1);
 
178
            array_pop($boundaries);
 
179
            $pre .= '<b><font color ='."$color[2]>";
 
180
            $end .= '</font></b>';
 
181
            $header = true;
 
182
            $mimepart = false;
 
183
            $bnd_end = true;
 
184
            $encoding = '';
187
185
            } else {
188
 
                $header = true;
189
 
                $bnd_end = false;
190
 
                $entStr = CalcEntity("$entStr",0);
191
 
                $content_indx++;
192
 
                $content[$content_indx]=array();                
193
 
                $content[$content_indx]['ent'] = '<A HREF="#'."$entStr \">$entStr".'</a>';
194
 
                $pre .= "\n \n".'</div>'."\n \n".'<div class="entheader" ID="'.$entStr.'H"><a name="'."$entStr".'"><b><font color ='."$color[2]>";
195
 
                $end .= '</font></b>'."\n";
196
 
                $header = true;
197
 
                $mimepart = false;
198
 
                $encoding = '';
 
186
            $header = true;
 
187
            $bnd_end = false;
 
188
            $entStr = CalcEntity("$entStr",0);
 
189
            $content_indx++;
 
190
            $content[$content_indx]=array();            
 
191
            $content[$content_indx]['ent'] = '<a href="#'."$entStr \">$entStr".'</a>';
 
192
            $pre .= "\n \n".'</div>'."\n \n".'<div class="entheader" id="'.
 
193
                $entStr.'H"><a name="'."$entStr".'"><b><font color ='."$color[2]>";
 
194
            $end .= '</font></b>'."\n";
 
195
            $header = true;
 
196
            $mimepart = false;
 
197
            $encoding = '';
199
198
            }
200
199
        }  else {
201
200
            if ($header) {
243
242
    }   
244
243
*/
245
244
    $line = htmlspecialchars($line);
246
 
    $message_body .= "$pre"."$line"."$end".'<BR>'."\r\n";
 
245
    $message_body .= "$pre"."$line"."$end".'<br />'."\r\n";
247
246
}
248
 
//echo returnTime($start).'<BR>';
 
247
 
249
248
$xtra = <<<ECHO
250
249
 
251
 
<STYLE>
 
250
<style>
252
251
 
253
252
<!--
254
253
.ent_body {
265
264
}
266
265
//-->
267
266
 
268
 
</STYLE>
 
267
</style>
269
268
 
270
269
ECHO;
271
270
 
274
273
echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n";
275
274
echo '<code>'."\n";
276
275
echo '<font face = "monospace">'."\n";
277
 
echo '<BR>'."\n";
278
 
 
279
 
 
280
 
//session_register("entities");
281
 
//$keys = array_keys($entities);
282
 
//$start = gettimeofday();
283
 
//foreach ($keys as $key) {
284
 
//    if (isset($entities[$key])) {
285
 
//    if ($entities[$key]['encoding'] == 'base64') {
286
 
//      echo '<img src="message_viewentity.php?ent='.$entities[$key]['entity'].'&amp;name='.$entities[$key]['name'].'"><br>';
287
 
//    }
288
 
//    }
289
 
//}
290
 
//session_unregister("entities");
 
276
echo '<br />'."\n";
291
277
 
292
278
if (count($content) > 0) {
293
 
    echo '<h2> Bodystructure </h2>'."\n\n";
 
279
    echo '<h2>' . _("Bodystructure") . "</h2>\n\n";
294
280
    echo '<table border=1 width="98%"><thead>'.
295
281
          '<tr bgcolor="'."$color[7]".'">'.
296
 
            '<td><b><font color="'."$color[5]".'">Entity</font></b></td>'.
297
 
            '<td><b><font color="'."$color[5]".'">Content-Type</font></b></td>'.
298
 
            '<td><b><font color="'."$color[5]".'">Name</font></b></td>'.
299
 
            '<td><b><font color="'."$color[5]".'">Encoding</font></b></td>'.
 
282
            '<td><b><font color="'."$color[5]".'">' . _("Entity") . '</font></b></td>'.
 
283
            '<td><b><font color="'."$color[5]".'">' . _("Content-Type") . '</font></b></td>'.
 
284
            '<td><b><font color="'."$color[5]".'">' . _("Name") . '</font></b></td>'.
 
285
            '<td><b><font color="'."$color[5]".'">' . _("Encoding") . '</font></b></td>'.
300
286
 
301
287
          '</tr>'.
302
288
          '</thead><tbody>';
318
304
    }
319
305
    echo '</tbody></table><br>'."\n";
320
306
}
321
 
echo '<h2> RFC822 Message body </h2>'."\n\n";
 
307
echo '<h2>' . _("RFC822 Message body") . "</h2>\n\n";
322
308
echo '<div><div class="header">'."\n\n";
323
309
echo $message_body;
324
310
echo '</div></div></font></code></body></html>';