", $dsp);
- $dsp = eregi_replace("<excerpt>", "", $dsp);
- $dsp = eregi_replace("</excerpt>", " ", $dsp);
- /* Lang: Language is ignored */
- $dsp = eregi_replace("<lang><param>[^&]*</param>", "", $dsp);
- $dsp = eregi_replace("</lang>", "", $dsp);
- /* FontFamily */
- $dsp = eregi_replace("<fontfamily><param>([^&]*)</param>", "", $dsp);
- $dsp = eregi_replace("</fontfamily>", " ", $dsp);
- /* color */
- while (eregi("<color><param>([^&]*)</param>", $dsp, $regs))
- {
- // regs[1] = xxxx,yyyy,zzzz or colorname
- $c = explode(",", $regs[1]);
- if (count($c) == 1)
- $color = $c[0];
- else
- {
- // First 2 chars of 4char hex string is string /256
- $color = "#" .
- substr($c[0], 0, 2) .
- substr($c[1], 0, 2) .
- substr($c[2], 0, 2);
- }
- $dsp = eregi_replace("<color><param>[^&]*</param>", "", $dsp);
- }
- $dsp = eregi_replace("</color>", " ", $dsp);
- /* Now remove any unrecognised s */
- $dsp = eregi_replace("<param>[^&]*</param>", "", $dsp);
- /* And last, remove any unknown tags */
- $dsp = eregi_replace("<[^&]*>", "", $dsp);
- /* Now finish the work on << */
- $dsp = eregi_replace("<", "<", $dsp);
- /* Do the newlines */
- while (ereg("\n\n", $dsp))
- $dsp = ereg_replace("\n\n", " \n", $dsp);
- while (ereg("\r\n\r\n", $dsp))
- $dsp = ereg_replace("\r\n\r\n", " \r\n", $dsp);
- /* text/enriched must start with filled text according to RFC */
- $dsp = "$dsp
";
- return $dsp;
-}
-
-function make_safe_html($dsp)
-{
- $hidetag = array (
- '!doctype',
- 'html',
- 'head',
- 'meta',
- 'body'
- );
- foreach ($hidetag as $tag)
- {
- $dsp = eregi_replace("<\\s*(/?)\\s*$tag([^>]*)>",
- "", $dsp);
- }
- $hideelt = array (
- 'title',
- 'style'
- );
- foreach ($hideelt as $tag)
- {
- $dsp = eregi_replace("<\\s*$tag([^>]*)>",
- "", $dsp);
- }
- return $dsp;
-}
-
-function do_inline_display($msgnum, $part_no, $encoding, $charset, $type, $safe = 0)
-{
- global $mailbox, $msgnum;
- global $folder;
-
- /* $safe means: Safe to display in an HTML form.
- not safe is largely unchanged. */
-
- $dsp = imap_fetchbody($mailbox, $msgnum, $part_no);
- if ($encoding == "base64") {
- $dsp = imap_base64($dsp);
- }
- if ($encoding == "qprint") {
- $dsp = my_imap_qprint($dsp);
- }
- if (!$safe)
- {
- /* Done, no further processing. */
- echo $dsp;
- }
- else
- {
- $dsp = make_utf8($dsp, $charset);
- if (strtolower($type) == "text/plain")
- {
- /* For text/plain we assume the user took care of line breaks;
- */
- $dsp = htmlspecialchars($dsp);
- $dsp = make_clickable($dsp);
- echo "$dsp ";
- }
- else if (strtolower($type) == "text/enriched")
- {
- $dsp = enriched_to_html($dsp);
- echo $dsp;
- }
- else if (strtolower($type) == "text/html")
- {
- $struct = imap_fetchstructure($mailbox, $msgnum);
- while (ereg("cid:([^\"]*)", $dsp, $regs))
- {
- $dsp = ereg_replace("cid:" . $regs[1], cid_name($struct, $regs[1]), $dsp);
- }
- $dsp = make_safe_html($dsp);
- echo $dsp;
- }
- else
- {
- /* For unknown types, we just display exactly as sent, so here
- we do use . */
- $dsp = htmlspecialchars($dsp);
- echo "\n$dsp \n";
- }
- }
-}
-
-function inline_display($de_part, $part_no)
-{
- global $mailbox, $msgnum, $folder;
-
-
- $mime_type = get_mime_type($de_part);
- $type = $mime_type . "/" . $de_part->subtype;
- $mime_encoding = get_mime_encoding($de_part);
- $charset = get_charset($de_part);
-
- /* Default, simple mail */
- if (strtolower($type) == "text/plain")
- {
- $ret = 1;
- }
- /* Smart types we know of */
- elseif ((strtolower($type) == "text/enriched") or
- (strtolower($type) == "text/html"))
- {
- output_bound(L_MIME_SECTION . ":" , "$mime_type/$de_part->subtype");
- $ret = 1;
- }
- /* All other types: return 0 as we don't know whether we displayed
- anything useful for the user. */
- else
- {
- output_bound(L_MIME_SECTION . ":" , "$mime_type/$de_part->subtype");
- $ret = 0;
- }
- /* This is not really useful
- print "" . L_MESSAGE . "
\n";
- */
-
- /* Embedded objects have a fixed height, which means embedded scrolbars.
- That's not worth it.
- print "\n";
- */
-
- do_inline_display($msgnum, $part_no, $mime_encoding,
- $charset, $type, 1);
- /*
- echo " \n";
- */
- return $ret;
-}
-
-function output_bound($title, $str)
-{
- body_left_end();
- body_row_end();
-
- title_start();
- title_left();
- echo $title;
- title_left_end();
- title_data();
- echo $str;
- title_data_end();
- body_row('class="rowon"');
- body_left('colspan="2" class="body"');
-}
-
-
-function cid_name($struct, $cid_to_find, $numprefix="")
-{
- global $folder, $msgnum;
- global $cidsdone;
- $name = "";
- $numparts = !$struct->parts ? "1" : count($struct->parts);
- for($i = 0; $i < $numparts; $i++)
- {
- $part = !$struct->parts[$i] ? $part = $struct : $part = $struct->parts[$i];
-
- if ($part->parts)
- {
- $subpartnum = $i + 1;
- $name .= cid_name($part, $cid_to_find, $numprefix . $subpartnum . ".");
- if ($name)
- {
- return $name;
- }
- }
- else
- {
- $cid = $part->ifid ? $part->id : "";
- if ($cid == $cid_to_find || $cid == "<$cid_to_find>")
- {
- $subpartnum = $i + 1;
- $att_name = get_att_name($part);
- $name .= "view_image.php?folder=" . $folder
- . "&msgnum=$msgnum&part_no=" . $numprefix
- . $subpartnum
- . "&type=$part->subtype&name=$att_name";
- $cidsdone[$cid] = 1;
- return $name;
- }
- }
- }
- // Not found, leave it as it is
- return $cid_to_find;
-}
-
-/* ciddone is set for an inline image that is processed. If the image data
- appears later in the message, it doesn't have to be displayed again.
- This is not entirely correct, because when the image data appears first,
- it is displayed, and again later as inline.
-*/
-function ciddone($part)
-{
- global $cidsdone;
- $cid = $part->ifid ? $part->id : "";
- if ($cid == "")
- return 0;
- return $cidsdone[$cid];
-}
-
-function image_display($folder, $msgnum, $de_part, $part_no, $att_name)
-{
- output_bound(L_IMAGE . ":" , $att_name);
- echo "\n subtype&name=$att_name\">\n \n";
-}
-
-// function make_clickable rewritten to follow
-// RFC 1738 (URLs)
-// RFC 2822 (Internet Message formats)
-function make_clickable($text)
-{
- global $folder;
-
- // schemes in URLs that we will recognise. These are schemes commonly
- // supported by browsers, others are not necessary.
- $schemes = array (
- // official
- "ftp",
- "http",
- "gopher",
- "news",
- "nntp",
- "telnet",
- "wais",
- "file",
- "https",
- "tn3270",
- // common?
- "aim",
- "irc"
- // DON'T include script types for security
- );
-
- // Turn & into st that does not contain an &, and is
- // not appearing in text. Then the URL matcher can exclude &s; so > and
- // < are not matched.
- do {
- $rep = "!=!" . rand() . "!=!";
- } while (eregi($rep, $text));
- $ret = eregi_replace("&", $rep, $text);
- // RFC 1738, but restrict to common schemes
- $schemere = implode("|", $schemes);
- $ret = eregi_replace(
- '(' . "($schemere)" . ':[-$_.+!*\'(),;/?:@=~[:alnum:]#]+)',
- "\\1 ", $ret);
- // One more as it is used a lot: something without a scheme, which is
- // always http://.
- // Try not to match too much, so demand . and /
- // make sure it is surrounded by blanks
- $ret = eregi_replace(
- '(^|[[:space:]])([[:alnum:]]+\.[[:alnum:]\.]+/[-$_.+!*\'(),;/?:@=~[:alnum:]#]+)([[:space:]]|$)',
- "\\1\\2 \\3", $ret);
- $ret = eregi_replace($rep, "&", $ret);
- $ret = eregi_replace(
- '([-!#$%&\'*+/=?^_`{|}~[:alnum:]]+@[-a-zA-Z0-9.]+)',
- "\\1 ", $ret);
- return($ret);
-}
-
-
-function self_with_param($paramname, $value)
-{
- global $HTTP_SERVER_VARS;
- $url = $HTTP_SERVER_VARS["REQUEST_URI"];
- /* first strip out the old value of $paramname */
- $url = ereg_replace("\&$paramname=[^&]*", "", $url);
- $url = ereg_replace("$paramname=[^&]*\&", "", $url);
- $url = ereg_replace("\?$paramname=[^&]*", "", $url);
- /* Then insert the new one */
- /* Note: $value != "" is FALSE when $value is the string "0". You gotta
- love PHP... */
- if ($value != "" or $value == "0")
- {
- if (strpos($url, "?"))
- $url .= "&";
- else
- $url .= "?";
- $url .= "$paramname=$value";
- }
- return htmlspecialchars($url);
-}
-
-function login_prompt()
-{
- Header("WWW-Authenticate: Basic realm=\"" . PROG_NAME . "\"");
- Header("HTTP/1.0 401 Unauthorized");
- echo " ";
- exit;
-}
-
-include('layout.inc');
-
-if ((!$PHP_AUTH_USER) or (!$PHP_AUTH_PW) or ($time > time()))
-{
- login_prompt();
-}
-else
-{
- if($PHP_AUTH_USER && $PHP_AUTH_PW)
- {
- $user = $PHP_AUTH_USER;
- $pass = $PHP_AUTH_PW;
- $folder = !$folder ? "INBOX" : $folder;
- $mailbox = mailbox_log_in($folder);
-
- if(!$mailbox)
- {
- login_prompt();
- }
- }
-}
-
-?>
+charset == "default")
+ $output .= $element[$i]->text;
+ else
+ {
+ $output .= make_utf8($element[$i]->text, $element[$i]->charset);
+ }
+ }
+ }
+ return $output;
+}
+
+function make_address_list($header_arr)
+{
+ $out = array();
+ if (is_array($header_arr) && count($header_arr))
+ {
+ foreach ($header_arr as $adr)
+ {
+ $out[] = imap_rfc822_write_address($adr->mailbox, $adr->host, $adr->personal);
+ }
+ }
+ return $out;
+}
+
+function make_formaddress_list($header_arr)
+{
+ $list = make_address_list($header_arr);
+ $l = array();
+ foreach ($list as $adr)
+ {
+ $l[] = htmlentities(decode_header_string($adr));
+ }
+ return implode(", ", $l);
+}
+
+
+function make_clickable_list($header_arr, $folder)
+{
+ $list = make_address_list($header_arr);
+ $l = array();
+ foreach ($list as $adr)
+ {
+ if (DISPLAY_FULL_ADDR)
+ $linkdisplay = hemlspecialchars(decode_header_string($adr));
+ else
+ $linkdisplay = strip_tags(str_replace("\"","",$adr));
+ $l[] = ""
+ . "$linkdisplay ";
+ }
+ return implode(", ", $l);
+}
+
+function list_folders( $mailbox )
+{
+ $mailboxes = imap_listmailbox($mailbox, IMAP_STR, FILTER . "*");
+ if($mailboxes)
+ {
+ sort($mailboxes);
+ $num_boxes = count($mailboxes);
+ if (FILTER != "INBOX" && NO_INBOX_EXPLICIT != 1) { echo "INBOX"; }
+ for ($index = 0; $index < $num_boxes; $index++)
+ {
+ $nm = substr($mailboxes[$index], strrpos($mailboxes[$index], "}") + 1, strlen($mailboxes[$index]));
+ echo " ";
+ if ($nm != "INBOX")
+ {
+ echo deconstruct_folder_str($nm);
+ }
+ else
+ {
+ echo "INBOX";
+ }
+ echo "\n";
+ }
+ }
+ else
+ {
+ echo " INBOX";
+ }
+}
+
+function get_mime_type($de_part)
+{
+ switch ($de_part->type)
+ {
+ case TYPETEXT: $mime_type = "text"; break;
+ case TYPEMULTIPART: $mime_type = "multipart"; break;
+ case TYPEMESSAGE: $mime_type = "message"; break;
+ case TYPEAPPLICATION: $mime_type = "application"; break;
+ case TYPEAUDIO: $mime_type = "audio"; break;
+ case TYPEIMAGE: $mime_type = "image"; break;
+ case TYPEVIDEO: $mime_type = "video"; break;
+ case TYPEMODEL: $mime_type = "model"; break;
+ default: $mime_type = "unknown";
+ }
+ return $mime_type;
+}
+
+function get_mime_encoding($de_part)
+{
+ switch ($de_part->encoding)
+ {
+ case ENCBASE64: $mime_encoding = "base64"; break;
+ case ENCQUOTEDPRINTABLE: $mime_encoding = "qprint"; break;
+ case ENCOTHER: $mime_encoding = "other"; break;
+ default: $mime_encoding = "other";
+ }
+ return $mime_encoding;
+}
+
+function get_charset($de_part)
+{
+ $charset = "US-ASCII";
+ for ($i = 0; $i < count($de_part->parameters); $i++)
+ {
+ $param = $de_part->parameters[$i];
+ if ($param->attribute == "CHARSET")
+ {
+ $charset = $param->value;
+ }
+ }
+ return $charset;
+}
+
+
+function make_utf8($str, $charset)
+{
+ /* Try, but at least return something! */
+ if (function_exists('iconv'))
+ {
+ if (!$charset)
+ $charset="US-ASCII";
+ $charset = strtoupper($charset);
+ /* Do some processing to catch sloppy charsets */
+ $charset = ereg_replace("^WINDOWS-", "CP", $charset);
+ /* Found in the wild: "CHINESEBIG5" */
+ $charset = ereg_replace("^CHINESE", "", $charset);
+ $out = iconv($charset, "UTF-8", $str);
+ if ($out)
+ return $out;
+ }
+ return $str;
+}
+
+
+function get_att_name($de_part)
+{
+ $att_name = 0;
+ $att_filename = "Unknown";
+ for ($i = 0; $i < count($de_part->parameters); $i++)
+ {
+ $param = $de_part->parameters[$i];
+ if ($param->attribute == "NAME")
+ {
+ $att_name = $param->value;
+ }
+ }
+ for ($i = 0; $i < count($de_part->dparameters); $i++)
+ {
+ $param = $de_part->dparameters[$i];
+ if ($param->attribute == "FILENAME")
+ {
+ $att_filename = $param->value;
+ }
+ }
+ if ($att_name)
+ return $att_name;
+ else
+ return $att_filename;
+}
+
+function attach_display($de_part, $part_no)
+{
+ global $mailbox, $folder, $msgnum;
+ $mime_type = get_mime_type($de_part);
+ $mime_encoding = get_mime_encoding($de_part);
+
+ $att_name = get_att_name($de_part);
+ $url_att_name = urlencode($att_name);
+
+ $jnk = "$att_name ";
+ return $jnk;
+}
+
+/* imap_qprint doesn't handle soft returns correctly */
+function my_imap_qprint($dsp)
+{
+ $dsp = str_replace("=\r\n", "", $dsp);
+ $dsp = imap_qprint($dsp);
+ return $dsp;
+}
+
+function enriched_to_html($dsp)
+{
+ // Convert to HMTL
+ /* Double << is <. Using < makes sure it is no longer taken
+ as a command start, as & will become $amp; Later we replace
+ < with < */
+ $dsp = str_replace("<<", "<", $dsp);
+ $dsp = htmlspecialchars($dsp);
+ // Simple ones
+ $dsp = eregi_replace("<bold>", "", $dsp);
+ $dsp = eregi_replace("</bold>", " ", $dsp);
+ $dsp = eregi_replace("<italic>", "", $dsp);
+ $dsp = eregi_replace("</italic>", " ", $dsp);
+ $dsp = eregi_replace("<underline>", "", $dsp);
+ $dsp = eregi_replace("</underline>", " ", $dsp);
+ $dsp = eregi_replace("<fixed>", "", $dsp);
+ $dsp = eregi_replace("</fixed>", " ", $dsp);
+ $dsp = eregi_replace("<smaller>", "", $dsp);
+ $dsp = eregi_replace("</smaller>", " ", $dsp);
+ $dsp = eregi_replace("<bigger>", "", $dsp);
+ $dsp = eregi_replace("</bigger>", " ", $dsp);
+ $dsp = eregi_replace("<center>", "", $dsp);
+ $dsp = eregi_replace("</center>", "
", $dsp);
+ $dsp = eregi_replace("<flushleft>", "", $dsp);
+ $dsp = eregi_replace("</flushleft>", "
", $dsp);
+ $dsp = eregi_replace("<flushright>", "", $dsp);
+ $dsp = eregi_replace("</flushright>", "
", $dsp);
+ $dsp = eregi_replace("<flushboth>", "", $dsp);
+ $dsp = eregi_replace("</flushboth>", "
", $dsp);
+ /* nofill -> pre. TODO: Within this block, no newline replacing
+ should be done. */
+ $dsp = eregi_replace("<nofill>", "", $dsp);
+ $dsp = eregi_replace("</nofill>", " ", $dsp);
+ /* Paraindent -> blockquote
+ Not entriely correct: there is a param telling what kind
+ of indenting to do, which we don't support.
+ Another thing: My params cannot contain an & char, which
+ might be a problem.
+ */
+ $dsp = eregi_replace("<paraindent><param>[^&]*</param>", "", $dsp);
+ $dsp = eregi_replace("</paraindent>", " ", $dsp);
+ /* Excerpt can optionally have a param telling where excerpt
+ comes from. */
+ $dsp = eregi_replace("<excerpt><param>([^&]*)</param>", " \\\\1", $dsp);
+ $dsp = eregi_replace("<excerpt>", "", $dsp);
+ $dsp = eregi_replace("</excerpt>", " ", $dsp);
+ /* Lang: Language is ignored */
+ $dsp = eregi_replace("<lang><param>[^&]*</param>", "", $dsp);
+ $dsp = eregi_replace("</lang>", "", $dsp);
+ /* FontFamily */
+ $dsp = eregi_replace("<fontfamily><param>([^&]*)</param>", "", $dsp);
+ $dsp = eregi_replace("</fontfamily>", " ", $dsp);
+ /* color */
+ while (eregi("<color><param>([^&]*)</param>", $dsp, $regs))
+ {
+ // regs[1] = xxxx,yyyy,zzzz or colorname
+ $c = explode(",", $regs[1]);
+ if (count($c) == 1)
+ $color = $c[0];
+ else
+ {
+ // First 2 chars of 4char hex string is string /256
+ $color = "#" .
+ substr($c[0], 0, 2) .
+ substr($c[1], 0, 2) .
+ substr($c[2], 0, 2);
+ }
+ $dsp = eregi_replace("<color><param>[^&]*</param>", "", $dsp);
+ }
+ $dsp = eregi_replace("</color>", " ", $dsp);
+ /* Now remove any unrecognised s */
+ $dsp = eregi_replace("<param>[^&]*</param>", "", $dsp);
+ /* And last, remove any unknown tags */
+ $dsp = eregi_replace("<[^&]*>", "", $dsp);
+ /* Now finish the work on << */
+ $dsp = eregi_replace("<", "<", $dsp);
+ /* Do the newlines */
+ while (ereg("\n\n", $dsp))
+ $dsp = ereg_replace("\n\n", " \n", $dsp);
+ while (ereg("\r\n\r\n", $dsp))
+ $dsp = ereg_replace("\r\n\r\n", " \r\n", $dsp);
+ /* text/enriched must start with filled text according to RFC */
+ $dsp = "$dsp
";
+ return $dsp;
+}
+
+function make_safe_html($dsp)
+{
+ $hidetag = array (
+ '!doctype',
+ 'html',
+ 'head',
+ 'meta',
+ 'body'
+ );
+ foreach ($hidetag as $tag)
+ {
+ $dsp = eregi_replace("<\\s*(/?)\\s*$tag([^>]*)>",
+ "", $dsp);
+ }
+ $hideelt = array (
+ 'title',
+ 'style'
+ );
+ foreach ($hideelt as $tag)
+ {
+ $dsp = eregi_replace("<\\s*$tag([^>]*)>",
+ "", $dsp);
+ }
+ return $dsp;
+}
+
+function do_inline_display($msgnum, $part_no, $encoding, $charset, $type, $safe = 0)
+{
+ global $mailbox, $msgnum;
+ global $folder;
+
+ /* $safe means: Safe to display in an HTML form.
+ not safe is largely unchanged. */
+
+ $dsp = imap_fetchbody($mailbox, $msgnum, $part_no);
+ if ($encoding == "base64") {
+ $dsp = imap_base64($dsp);
+ }
+ if ($encoding == "qprint") {
+ $dsp = my_imap_qprint($dsp);
+ }
+ if (!$safe)
+ {
+ /* Done, no further processing. */
+ echo $dsp;
+ }
+ else
+ {
+ $dsp = make_utf8($dsp, $charset);
+ if (strtolower($type) == "text/plain")
+ {
+ /* For text/plain we exhibit the line break behavior defined
+ in the config.inc
+ */
+ if (WRAP_AT_COLUMN)
+ $dsp = forcelinebreaks($dsp,WRAP_AT_COLUMN);
+ $dsp = htmlspecialchars($dsp);
+ $dsp = make_clickable($dsp);
+ echo "$dsp ";
+ }
+ else if (strtolower($type) == "text/enriched")
+ {
+ $dsp = enriched_to_html($dsp);
+ echo $dsp;
+ }
+ else if (strtolower($type) == "text/html")
+ {
+ $struct = imap_fetchstructure($mailbox, $msgnum);
+ while (ereg("cid:([^\"]*)", $dsp, $regs))
+ {
+ /* WARNING: MAKE SURE you quotemeta() on $regs[1]. They can
+ (and often do) contain $ characters.
+ */
+ $dsp = ereg_replace("cid:" . quotemeta($regs[1]), cid_name($struct, $regs[1]), $dsp);
+ }
+ $dsp = make_safe_html($dsp);
+ echo $dsp;
+ }
+ else
+ {
+ /* For unknown types, we just display exactly as sent, so here
+ we do use . */
+ $dsp = htmlspecialchars($dsp);
+ echo "\n$dsp \n";
+ }
+ }
+}
+
+function inline_display($de_part, $part_no)
+{
+ global $mailbox, $msgnum, $folder;
+
+
+ $mime_type = get_mime_type($de_part);
+ $type = $mime_type . "/" . $de_part->subtype;
+ $mime_encoding = get_mime_encoding($de_part);
+ $charset = get_charset($de_part);
+
+ /* Default, simple mail */
+ if (strtolower($type) == "text/plain")
+ {
+ $ret = 1;
+ }
+ /* Smart types we know of */
+ elseif ((strtolower($type) == "text/enriched") or
+ (strtolower($type) == "text/html"))
+ {
+ output_bound(L_MIME_SECTION . ":" , "$mime_type/$de_part->subtype");
+ $ret = 1;
+ }
+ /* All other types: return 0 as we don't know whether we displayed
+ anything useful for the user. */
+ else
+ {
+ output_bound(L_MIME_SECTION . ":" , "$mime_type/$de_part->subtype");
+ $ret = 0;
+ }
+ /* This is not really useful
+ print "" . L_MESSAGE . "
\n";
+ */
+
+ /* Embedded objects have a fixed height, which means embedded scrolbars.
+ That's not worth it.
+ print "\n";
+ */
+
+ do_inline_display($msgnum, $part_no, $mime_encoding,
+ $charset, $type, 1);
+ /*
+ echo " \n";
+ */
+ return $ret;
+}
+
+function output_bound($title, $str)
+{
+ body_left_end();
+ body_row_end();
+
+ title_start();
+ title_left();
+ echo $title;
+ title_left_end();
+ title_data();
+ echo $str;
+ title_data_end();
+ body_row('class="rowon"');
+ body_left('colspan="2" class="body"');
+}
+
+
+function cid_name($struct, $cid_to_find, $numprefix="")
+{
+ global $folder, $msgnum;
+ global $cidsdone;
+ $name = "";
+ $numparts = !$struct->parts ? "1" : count($struct->parts);
+ for($i = 0; $i < $numparts; $i++)
+ {
+ $part = !$struct->parts[$i] ? $part = $struct : $part = $struct->parts[$i];
+
+ if ($part->parts)
+ {
+ $subpartnum = $i + 1;
+ $name .= cid_name($part, $cid_to_find, $numprefix . $subpartnum . ".");
+ if ($name)
+ {
+ return $name;
+ }
+ }
+ else
+ {
+ $cid = $part->ifid ? $part->id : "";
+ if ($cid == $cid_to_find || $cid == "<$cid_to_find>")
+ {
+ $subpartnum = $i + 1;
+ $att_name = get_att_name($part);
+ $name .= "view_image.php?folder=" . $folder
+ . "&msgnum=$msgnum&part_no=" . $numprefix
+ . $subpartnum
+ . "&type=$part->subtype&name=$att_name";
+ $cidsdone[$cid] = 1;
+ return $name;
+ }
+ }
+ }
+ // Not found, leave it as it is
+ return $cid_to_find;
+}
+
+/* ciddone is set for an inline image that is processed. If the image data
+ appears later in the message, it doesn't have to be displayed again.
+ This is not entirely correct, because when the image data appears first,
+ it is displayed, and again later as inline.
+*/
+function ciddone($part)
+{
+ global $cidsdone;
+ $cid = $part->ifid ? $part->id : "";
+ if ($cid == "")
+ return 0;
+ return $cidsdone[$cid];
+}
+
+function image_display($folder, $msgnum, $de_part, $part_no, $att_name)
+{
+ output_bound(L_IMAGE . ":" , $att_name);
+ echo "\n subtype&name=$att_name\">\n \n";
+}
+
+// function make_clickable rewritten to follow
+// RFC 1738 (URLs)
+// RFC 2822 (Internet Message formats)
+function make_clickable($text)
+{
+ global $folder;
+
+ // schemes in URLs that we will recognise. These are schemes commonly
+ // supported by browsers, others are not necessary.
+ $schemes = array (
+ // official
+ "ftp",
+ "http",
+ "gopher",
+ "news",
+ "nntp",
+ "telnet",
+ "wais",
+ "file",
+ "https",
+ "tn3270",
+ // common?
+ "aim",
+ "irc"
+ // DON'T include script types for security
+ );
+
+ // Turn & into st that does not contain an &, and is
+ // not appearing in text. Then the URL matcher can exclude &s; so > and
+ // < are not matched.
+ do {
+ $rep = "!=!" . rand() . "!=!";
+ } while (eregi($rep, $text));
+ $ret = eregi_replace("&", $rep, $text);
+ // RFC 1738, but restrict to common schemes
+ $schemere = implode("|", $schemes);
+ $ret = eregi_replace(
+ '(' . "($schemere)" . ':[-$_.+!*\'(),;/?:@=~[:alnum:]#]+)',
+ "\\1 ", $ret);
+ // One more as it is used a lot: something without a scheme, which is
+ // always http://.
+ // Try not to match too much, so demand . and /
+ // make sure it is surrounded by blanks
+ $ret = eregi_replace(
+ '(^|[[:space:]])([[:alnum:]]+\.[[:alnum:]\.]+/[-$_.+!*\'(),;/?:@=~[:alnum:]#]+)([[:space:]]|$)',
+ "\\1\\2 \\3", $ret);
+ $ret = eregi_replace($rep, "&", $ret);
+ $ret = eregi_replace(
+ '([-!#$%&\'*+/=?^_`{|}~[:alnum:]]+@[-a-zA-Z0-9.]+)',
+ "\\1 ", $ret);
+ return($ret);
+}
+
+
+function self_with_param($paramname, $value)
+{
+ global $HTTP_SERVER_VARS;
+ $url = $HTTP_SERVER_VARS["REQUEST_URI"];
+ /* first strip out the old value of $paramname */
+ $url = ereg_replace("\&$paramname=[^&]*", "", $url);
+ $url = ereg_replace("$paramname=[^&]*\&", "", $url);
+ $url = ereg_replace("\?$paramname=[^&]*", "", $url);
+ /* Then insert the new one */
+ /* Note: $value != "" is FALSE when $value is the string "0". You gotta
+ love PHP... */
+ if ($value != "" or $value == "0")
+ {
+ if (strpos($url, "?"))
+ $url .= "&";
+ else
+ $url .= "?";
+ $url .= "$paramname=$value";
+ }
+ return htmlspecialchars($url);
+}
+
+function forcelinebreaks($dsp,$charcount) {
+ /* lastLB = lask-known line break (absolute position)
+ nextSP = next-known space, if any (relative to lastLB)
+ nextLB = next-known line break, if any (relative to lastLB)
+ walkback = the last space prior to the $charcount position
+ */
+ $lastLB = 0;
+ $dsptemp = "";
+ for ($n = 0; $n < strlen($dsp); $n++) {
+ if (strcmp(substr($dsp,$n,1), "\n") == 0)
+ $lastLB = $n;
+ $nextSP = strpos(substr($dsp,$lastLB), " ");
+ $nextLB = strpos(substr($dsp,$lastLB), "\n");
+ if (($nextSP > $charcount) && ($nextLB > $charcount)) {
+ // Jump ahead to the next space or newline.
+ if ($nextSP > $nextLB) {
+ # closest is newline, go there.
+ $dsptemp .= substr($dsp,$n,$nextLB + 1);
+ $lastLB = $nextLB + $n;
+ $n = $lastLB + 1;
+ } else {
+ # closest is space, go there.
+ $dsptemp .= substr($dsp,$n,$nextSP) . "\n";
+ $lastLB = $nextSP + $n;
+ $n = $lastLB;
+ } // end if nextSP > nextLB
+ } else if ($nextSP < 1) {
+ // do nothing (don't walk back!). just keep walking the string.
+ } else if ($n - $lastLB > $charcount) {
+ // walk backwards on the string to the last space
+ $walkback = strrpos(substr($dsp,$lastLB,$charcount)," ");
+ $curpos = $lastLB + $walkback;
+ $dsptemp = substr($dsptemp,0,$curpos) . "\n";
+ $lastLB = $curpos + 1;
+ $n = $lastLB;
+ } // end if nextSP > charcount
+ $dsptemp .= substr($dsp,$n,1);
+ } // end for n < strlen($dsp)
+ return $dsptemp;
+} //End function forcelinebreaks
+
+function login_prompt()
+{
+ Header("WWW-Authenticate: Basic realm=\"" . PROG_NAME . "\"");
+ Header("HTTP/1.0 401 Unauthorized");
+ echo " ";
+ exit;
+}
+
+include('layout.inc');
+
+if ((!$PHP_AUTH_USER) or (!$PHP_AUTH_PW) or ($time > time()))
+{
+ login_prompt();
+}
+else
+{
+ if($PHP_AUTH_USER && $PHP_AUTH_PW)
+ {
+ $user = $PHP_AUTH_USER;
+ $pass = $PHP_AUTH_PW;
+ $folder = !$folder ? "INBOX" : $folder;
+ $mailbox = mailbox_log_in($folder);
+
+ if(!$mailbox)
+ login_prompt();
+ }
+}
+
+?>
diff -ruN ../am222/index.php ./index.php
--- ../am222/index.php 2004-09-07 03:40:42.000000000 -0400
+++ ./index.php 2004-09-09 22:24:09.000000000 -0400
@@ -235,6 +235,7 @@
echo " ";
title_left_end();
}
+ if (DISPLAY_TO_FIELD || $issentmail) {
title_left();
echo "";
title_left_end();
+ }
title_left();
echo " to)
echo make_clickable_list($msg->to, $folder);
else
echo L_NO_TO;
body_left_end();
- body_left();
- echo date(L_DATE_FORMAT, $msg->udate);
+ }
+ body_left('class="row-small"');
+ echo "".date(L_DATE_FORMAT, $msg->udate)." ";
body_left_end();
- body_left();
- echo "$size\n";
+ body_left('class="row-small"');
+ echo "$size \n";
body_left_end();
body_row_end();
}
diff -ruN ../am222/lang/en.lang.inc ./lang/en.lang.inc
--- ../am222/lang/en.lang.inc 2003-10-21 08:03:28.000000000 -0400
+++ ./lang/en.lang.inc 2004-09-09 23:39:27.000000000 -0400
@@ -1,69 +1,69 @@
-
+
diff -ruN ../am222/layout.inc ./layout.inc
--- ../am222/layout.inc 2004-09-01 10:00:08.000000000 -0400
+++ ./layout.inc 2004-09-09 21:07:57.000000000 -0400
@@ -1,167 +1,167 @@
-
-
-
-}
-
-function header_start()
-{
-?>
-
-
-
-
- >
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+}
+
+function header_start()
+{
+?>
+
+
+
+
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -ruN ../am222/logout.php ./logout.php
--- ../am222/logout.php 2003-10-21 08:03:35.000000000 -0400
+++ ./logout.php 2004-09-09 23:53:23.000000000 -0400
@@ -1,5 +1,5 @@
-
+
diff -ruN ../am222/send_message.php ./send_message.php
--- ../am222/send_message.php 2004-09-01 08:42:50.000000000 -0400
+++ ./send_message.php 2004-09-09 23:41:00.000000000 -0400
@@ -1,112 +1,129 @@
-
+\n";
+ $to .= "@" . SERVER_SUFFIX;
+ } else {
+echo "Defaulting to IMAP server " . IMAP_SERVER . " \n";
+ $to .= "@" . IMAP_SERVER;
+ }
+ }
+ $mailheaders .= "To: ".removecrlf($to)."\r\n";
+
+ $cc = stripslashes($cc);
+ $mailheaders .= "Cc: ".removecrlf($cc)."\r\n";
+
+ // Do subject earlier to accomodate buggy Mozilla mail summary box,
+ // according to Laird Bedore (lmbedore@vectorstar.com)
+ $mailheaders .= "Subject: " . removecrlf(stripslashes($subject)) . "\r\n";
+
+ $mailheaders .= "X-Mailer: " . VERSION . "\r\n";
+
+ $msg_body = stripslashes($body);
+ $msg_body = imap_8bit($msg_body);
+
+ if (( $attach != "none" ) && ( $attach != "" ) and (is_uploaded_file($attach)))
+ {
+ $file = fopen($attach, "r");
+ $contents = fread($file, $attach_size);
+ $encoded_attach = chunk_split(base64_encode($contents));
+ fclose($file);
+
+ $mailheaders .= "MIME-version: 1.0\r\n";
+ $mailheaders .= "Content-type: multipart/mixed; ";
+ $mailheaders .= "boundary=\"$boundary\"\r\n";
+ $mailheaders .= "Content-transfer-encoding: 7BIT\r\n";
+ $mailheaders .= "X-attachments: $attach_name\r\n";
+
+ $body_top = "--$boundary\r\n";
+ $body_top .= "Content-type: text/plain; charset=UTF-8\r\n";
+ $body_top .= "Content-transfer-encoding: quoted-printable\r\n";
+ $body_top .= "Content-description: Mail message body\r\n\r\n";
+
+ $msg_body = $body_top . $msg_body;
+
+ $msg_body .= "\r\n\r\n--$boundary\r\n";
+ $msg_body .= "Content-type: $attach_type; name=\"$attach_name\"\r\n";
+ $msg_body .= "Content-Transfer-Encoding: BASE64\r\n";
+ $msg_body .= "Content-disposition: attachment; filename=\"$attach_name\"\r\n\r\n";
+ $msg_body .= "$encoded_attach\r\n";
+ $msg_body .= "--$boundary--\r\n";
+ }
+ else
+ {
+ $mailheaders .= "MIME-version: 1.0\r\n";
+ $mailheaders .= "Content-type: text/plain; charset=UTF-8\r\n";
+ $mailheaders .= "Content-transfer-encoding: quoted-printable\r\n";
+ }
+
+ $mailheaders .= "\r\n";
+
+ if (is_string(SERVER_SUFFIX))
+ $from_user = FORCE_FROM ? "$user@" . SERVER_SUFFIX : $user;
+ else
+ $from_user = FORCE_FROM ? "$user@" . IMAP_SERVER : $user;
+ mailfrom($from_user, $msg_body, $mailheaders);
+
+ // add message to the sent mail folder
+ if(is_string(SENT_MAIL))
+ {
+ $mailbox = mailbox_log_in(SENT_MAIL);
+ $snt_folder = construct_folder_str(SENT_MAIL);
+
+ if(imap_last_error())
+ {
+ //if there was an error, it was because there was no sent mail folder
+ //we'll just create one here, then re-login
+
+ imap_createmailbox($mailbox, IMAP_STR . "$snt_folder");
+ $mailbox = mailbox_log_in(SENT_MAIL);
+ }
+
+ if (is_string(SERVER_SUFFIX))
+ $waxer = imap_append($mailbox, IMAP_STR. "$snt_folder", "From: $user@" . SERVER_SUFFIX . "\r\n" . $mailheaders . $msg_body);
+ else
+ $waxer = imap_append($mailbox, IMAP_STR. "$snt_folder", "From: $user@" . IMAP_SERVER . "\r\n" . $mailheaders . $msg_body);
+ }
+
+ if ($msgnum != "")
+ {
+ header("Location: message.php?folder=" . $folder . "&msgnum=" . $msgnum);
+ }
+ else
+ {
+ header("Location: index.php?folder=" . $folder);
+ }
+?>
diff -ruN ../am222/style.php ./style.php
--- ../am222/style.php 2004-09-07 06:15:58.000000000 -0400
+++ ./style.php 2004-09-09 22:27:25.000000000 -0400
@@ -1,66 +1,70 @@
-
+
diff -ruN ../am222/themes/blackandblue.theme.inc ./themes/blackandblue.theme.inc
--- ../am222/themes/blackandblue.theme.inc 1969-12-31 19:00:00.000000000 -0500
+++ ./themes/blackandblue.theme.inc 2004-09-09 21:31:45.000000000 -0400
@@ -0,0 +1,35 @@
+
diff -ruN ../am222/themes/default.template.inc ./themes/default.template.inc
--- ../am222/themes/default.template.inc 2004-09-07 06:19:39.000000000 -0400
+++ ./themes/default.template.inc 2004-09-09 21:54:30.000000000 -0400
@@ -1,20 +1,16 @@
-
-
-
-
-
- AeroMail
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+