This file is indexed.

/usr/share/IlohaMail/source/view.php is in ilohamail 0.8.14-0rc3sid6.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<?php
/////////////////////////////////////////////////////////
//
//	source/view.php
//
//	(C)Copyright 2000-2002 Ryo Chijiiwa <Ryo@IlohaMail.org>
//
//		This file is part of IlohaMail.
//		IlohaMail is free software released under the GPL
//		license.  See enclosed file COPYING for details,
//		or see http://www.fsf.org/copyleft/gpl.html
//
/////////////////////////////////////////////////////////

/********************************************************

	AUTHOR: Ryo Chijiiwa <ryo@ilohamail.org>
	FILE: view.php
	PURPOSE:
		Display message part data (whether it be text, images, or whatever).  Decode as necessary.
		Sets HTTP "Content-Type" header as appropriate, so that the browser will (hopefully) know
		what to do with the data.
	PRE-CONDITIONS:
		$user - Session ID
		$folder - Folder in which message to open is in
		$id - Message ID (not UID)
		$part - IMAP (or MIME?) part code to view.

********************************************************/

include_once("../include/super2global.inc");
include_once("../include/nocache.inc");
include_once('../include/ryosimap.inc');

if ((isset($user))&&(isset($folder))){
	include_once("../include/session_auth.inc");
	include_once("../include/icl.inc");

	$view_conn=iil_Connect($host, $loginID, $password, $AUTH_MODE);
	if ($iil_errornum==-11){
		for ($i=0; (($i<10)&&(!$view_conn)); $i++){
			sleep(1);
			$view_conn=iil_Connect($host, $loginID, $password, $AUTH_MODE);
		}
	}
	if (!$view_conn){
		echo "failed\n".$iil_error;
		flush();
	}else{

		// Let's look for MSIE as it needs special treatment
		if  (strpos (getenv('HTTP_USER_AGENT'), "MSIE"))
			$DISPOSITION_MODE="inline";
		else
			$DISPOSITION_MODE="attachment";

		//get basic info
		include_once("../include/mime.inc");
		$header = iil_C_FetchHeader($view_conn, $folder, $id);
		$structure_str=iil_C_FetchStructureString($view_conn, $folder, $id);
		$structure=iml_GetRawStructureArray($structure_str);

		//if part id not specified but content-id is, 
		//find corresponding part id
		if (!isset($part) && $cid){
			if (!ereg("^<", $cid)) $cid = "<".$cid;
			if (!ereg(">$", $cid)) $cid.= ">";
			
			//fetch parts list
			$parts_list = iml_GetPartList($structure, "");
			
			//search for cid
			if (is_array($parts_list)){
				reset($parts_list);
				while(list($part_id,$part_a)=each($parts_list)){
					if ($part_a["id"]==$cid){
						$part = $part_id;
					}
				}
			}
			
			//we couldn't find part with cid, die
			if (!isset($part)) exit;
		}
		
		if (isset($source)){
			//show source
			header("Content-type: text/plain");
			iil_C_PrintSource(&$view_conn, $folder, $id, $part);
		}else if ($show_header){
			//show header
			header("Content-Type: text/plain");
			$header = iil_C_FetchPartHeader($view_conn, $folder, $id, $part);
			//$header = str_replace("\r", "", $header);
			//$header = str_replace("\n", "\r\n", $header);
			echo $header;
		}else if ($printer_friendly){
			//show printer friendly version
			include_once("../include/ryosimap.inc");
			include("../lang/".$my_prefs["charset"].".inc");

			//get message info
			$conn = $view_conn;
			
			$num_parts=iml_GetNumParts($structure, $part);
			$parent_type=iml_GetPartTypeCode($structure, $part);
			$uid = $header->uid;

			//get basic header fields
			$subject = encodeHTML(LangDecodeSubject($header->subject, $my_prefs["charset"]));
			$from = LangShowAddresses($header->from,  $my_prefs["charset"], $user);
			$to = LangShowAddresses($header->to,  $my_prefs["charset"], $user);
			if (!empty($header->cc)) $cc = LangShowAddresses($header->cc,  $my_prefs["charset"], $user);
			else $cc = "";

			header("Content-type: text/html");

			//output
			?>
			<html>
			<head><title><?php echo $subject ?></title></head>
			<body>
			<?php
			echo "<b>Subject:&nbsp;</b>$subject<br>\n";
			echo "<b>Date:&nbsp;</b>".htmlspecialchars($header->date)."<br>\n";
			echo "<b>From:&nbsp;</b>".$from."<br>\n";
			echo "<b>To:&nbsp;</b>".$to."<br>\n";
			if (!empty($cc)) echo "<b>CC:&nbsp;</b>".$cc."<br>\n";
//20094
			include("../include/read_message_handler.inc");
			?>
			</body>
			</html>
			<?php

		}else if(isset($tneffid)){
			//show ms-tnef

			include("../include/tnef_decoder.inc");			
			$type=iml_GetPartTypeCode($structure, $part);
			$typestring=iml_GetPartTypeString($structure, $part);
			list($type, $subtype) = explode("/", $typestring);
			$body=iil_C_FetchPartBody($view_conn, $folder, $id, $part);
			$encoding=iml_GetPartEncodingCode($structure, $part);
			if ($encoding == 3 ) $body=base64_decode($body);
			else if ($encoding == 4) $body=quoted_printable_decode($body);
			$charset=iml_GetPartCharset($structure, $part);
			if (strcasecmp($charset, "utf-8")==0){
				include_once("../include/utf8.inc");
				$is_unicode = true;
				$body = utf8ToUnicodeEntities($body);
			}else{
				$is_unicode = false;
			}
			//$body=LangConvert($body, $my_charset, $charset);
			$tnef_files=tnef_decode($body);
			header("Content-type: ".$tnef_files[$tneffid]['type0']."/".$tnef_files[$tneffid]['type1']."; name=\"".$tnef_files[$tneffid]['name']."\"");
			header("Content-Disposition: ".$DISPOSITION_MODE."; filename=\"".$tnef_files[$tneffid]['name']."\"");
			header("Expires: 0");
			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
			header("Pragma: public");
			echo($tnef_files[$tneffid]['stream']);
		}else{			
			$header_obj = $header;
			$type=iml_GetPartTypeCode($structure, $part);
			if ($is_html) $typestr = "text/html";
			else if (empty($part) || $part==0) $typestr = $header_obj->ctype;
			else $typestr = iml_GetPartTypeString($structure, $part);
			list($majortype, $subtype) = explode("/", $typestr);

			// structure string
			if ($show_struct){
				echo $structure_str;
					exit;
			}

			// format and send HTTP header
			if ($type==$MIME_APPLICATION){
				$name = str_replace("/",".",iml_GetPartName($structure, $part));
				header("Content-type: $typestr; name=\"".$name."\"");
				header("Content-Disposition: ".$DISPOSITION_MODE."; filename=\"".$name."\"");
				header("Expires: 0");
				header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
				header("Pragma: public");
			}else if ($type==$MIME_MESSAGE){
				$name=str_replace("/",".", iml_GetPartName($structure, $part));
				header("Content-Type: text/plain; name=\"".$name."\"");
			}else if ($type != $MIME_INVALID){
				$charset=iml_GetPartCharset($structure, $part);
				$name=str_replace("/",".", iml_GetPartName($structure, $part));
				$header="Content-type: $typestr";
				if (!empty($charset)) $header.="; charset=\"".$charset."\"";
				if (!empty($name)) $header.="; name=\"".$name."\"";
				header($header);
				if ($type!=$MIME_TEXT && $type!=$MIME_IMAGE){
					header("Content-Disposition: ".$DISPOSITION_MODE."; filename=\"".$name."\"");
					header("Expires: 0");
					header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
					header("Pragma: public");
				}else if (!empty($name)){
					header("Content-Disposition: inline; filename=\"".$name."\"");
				}
			}else{
				if ($debug) echo "Invalid type code!\n";
			}
			if ($debug) echo "Type code = $type ;\n";
			
			//check if text/html
			if ($type==$MIME_TEXT && strcasecmp($subtype, "html")==0){
				$is_html = true;
				$img_url = "view.php?user=$user&folder=$folder&id=$id&cid=";
				//echo "IS HTML<br>\n";
			}else{
				$is_html = false;
				//echo "IS NOT HTML $type $subtype <br>\n";
			}

			// send actual output
			if ($print){
				// straight output, no processing
				iil_C_PrintPartBody($view_conn, $folder, $id, $part);
				if ($debug) echo $view_conn->error;
			}else{
				// process as necessary, based on encoding
				$encoding=iml_GetPartEncodingCode($structure, $part);
				if ($debug) echo "Part code = $encoding;\n";

				if ($raw){
					iil_C_PrintPartBody($view_conn, $folder, $id, $part);
				}else if ($encoding==3){
					// base 64
					if ($debug) echo "Calling iil_C_PrintBase64Body\n"; flush();
					if ($is_html){
						$body = iil_C_FetchPartBody($view_conn, $folder, $id, $part);
						$body = ereg_replace("[^a-zA-Z0-9\/\+]", "", $body);
						$body = base64_decode($body);
						$body = eregi_replace("src=\"cid:", "src=\"".$img_url, $body);
						sanitizeHTML($body);
						echo $body;
					}else{
						iil_C_PrintBase64Body($view_conn, $folder, $id, $part);
					}
				}else if ($encoding == 4){
					// quoted printable
					$body = iil_C_FetchPartBody($view_conn, $folder, $id, $part);
					if ($debug) echo "Read ".strlen($body)." bytes\n";
					$body=quoted_printable_decode(str_replace("=\r\n","",$body));
					$charset=iml_GetPartCharset($structure, $part);
					if (strcasecmp($charset, "utf-8")==0){
						include_once("../include/utf8.inc");
						$body = utf8ToUnicodeEntities($body);
					}
					if ($is_html){
						sanitizeHTML($body);
						$body = eregi_replace("src=\"cid:", "src=\"".$img_url, $body);
					}
					echo $body;
				}else{
					// otherwise, just dump it out
					if ($is_html){
						$body = iil_C_FetchPartBody($view_conn, $folder, $id, $part);
						sanitizeHTML($body);
						$body = eregi_replace("src=\"cid:", "src=\"".$img_url, $body);
						echo $body;
					}else{
						iil_C_PrintPartBody($view_conn, $folder, $id, $part);
					}
				}
				if ($debug) echo $view_conn->error;
			}
		}
		iil_Close($view_conn);
	}
}
?>