- arsort($read_list);
-
- $query = "$sid FETCH $msgs_str RFC822.SIZE\r\n";
- fputs ($imap_stream, $query);
- $sizesin_list = sqimap_read_data_list($imap_stream, $sid, true, $response, $message);
-
- foreach ($sizesin_list as $r) {
- if (!eregi("^\\* ([0-9]+) FETCH", $r[0], $regs)) {
- set_up_language($squirrelmail_language);
- echo "<br><b><font color=$color[2]>\n";
- echo _("ERROR : Could not complete request.");
- echo "</b><br>\n";
- echo _("Unknown response from IMAP server: ") . ' 2.';
- echo $r[0] . "</font><br>\n";
- exit;
- }
- if (!count($id2index[$regs[1]])) {
- set_up_language($squirrelmail_language);
- echo "<br><b><font color=$color[2]>\n";
- echo _("ERROR : Could not complete request.");
- echo "</b><br>\n";
- echo _("Unknown messagenumber in reply from server: ");
- echo $regs[1] . "</font><br>\n";
- exit;
- }
- $sizes_list[$id2index[$regs[1]]] = $r;
- }
- arsort($sizes_list);
-
- for ($msgi = 0; $msgi < $maxmsg; $msgi++) {
- $subject = _("(no subject)");
- $from = _("Unknown Sender");
- $priority = 0;
- $messageid = "<>";
- $cc = "";
- $to = "";
- $date = "";
- $type[0] = "";
- $type[1] = "";
- $inrepto = "";
- $read = $read_list[$msgi];
-
- $prevline = false;
- foreach ($read as $read_part) {
- //unfold multi-line headers
- while ($prevline && strspn($read_part, "\t ") > 0) {
- $read_part = substr($prevline, 0, -2) . ' ' . ltrim($read_part);
- }
- $prevline = $read_part;
- if (eregi ("^to:(.*)$", $read_part, $regs)) {
- $to = $regs[1];
- } else if (eregi ("^from:(.*)$", $read_part, $regs)) {
- $from = $regs[1];
- } else if (eregi ("^x-priority:(.*)$", $read_part, $regs)) {
- $priority = trim($regs[1]);
- } else if (eregi ("^message-id:(.*)$", $read_part, $regs)) {
- $messageid = trim($regs[1]);
- } else if (eregi ("^cc:(.*)$", $read_part, $regs)) {
- $cc = $regs[1];
- } else if (eregi ("^date:(.*)$", $read_part, $regs)) {
- $date = $regs[1];
- } else if (eregi ("^subject:(.*)$", $read_part, $regs)) {
- $subject = htmlspecialchars(trim($regs[1]));
- if ($subject == "") {
- $subject = _("(no subject)");
- }
- } else if (eregi ("^content-type:(.*)$", $read_part, $regs)) {
- $type = strtolower(trim($regs[1]));
- if ($pos = strpos($type, ";")) {
- $type = substr($type, 0, $pos);
- }
- $type = explode("/", $type);
- if (!isset($type[1])) {
- $type[1] = '';
- }
- } else if (eregi ("^in-reply-to:(.*)$", $read_part, $regs)) {
- $inrepto = trim($regs[1]);
+ if ( $value == 'urgent' || $value == 'high' ) {
+ return 1;
+ } elseif ( $value == 'non-urgent' || $value == 'low' ) {
+ return 5;
+ }
+ return 3;
+}
+
+/**
+ * Parses a string in an imap response. String starts with " or { which means it
+ * can handle double quoted strings and literal strings
+ *
+ * @param string $read imap response
+ * @param integer $i (reference) offset in string
+ * @return string $s parsed string without the double quotes or literal count
+ */
+function parseString($read,&$i) {
+ $char = $read{$i};
+ $s = '';
+ if ($char == '"') {
+ $iPos = ++$i;
+ while (true) {
+ $iPos = strpos($read,'"',$iPos);
+ if (!$iPos) break;
+ if ($iPos && $read{$iPos -1} != '\\') {
+ $s = substr($read,$i,($iPos-$i));
+ $i = $iPos;
+ break;