function inbox($servr, $user, $passwd, $folder, $sort, $sortdir, $lang, $theme) { $mailhost = $servr; require 'conf.php'; $pop = @imap_open('{' . $mailhost . '}' . $folder, $user, $passwd); if ($pop == false) { return -1; } else { if (($num_messages = @imap_num_msg($pop)) == 0) { imap_close($pop); return 0; } else { //if ($sort != '' && $sortdir != '') $sorted = imap_sort($pop, $sort, $sortdir, SE_UID); for ($i = 0; $i < $num_messages; $i++) { $subject = $from = ''; $msgnum = $sorted[$i]; $ref_contenu_message = imap_header($pop, imap_msgno($pop, $msgnum)); $struct_msg = imap_fetchstructure($pop, imap_msgno($pop, $msgnum)); $subject_array = imap_mime_header_decode($ref_contenu_message->subject); for ($j = 0; $j < count($subject_array); $j++) { $subject .= $subject_array[$j]->text; } $from_array = imap_mime_header_decode($ref_contenu_message->fromaddress); for ($j = 0; $j < count($from_array); $j++) { $from .= $from_array[$j]->text; } if (is_Imap($mailhost)) { $msg_size = get_mail_size($struct_msg); } else { $msg_size = $struct_msg->bytes > 1000 ? ceil($struct_msg->bytes / 1000) : 1; } if ($struct_msg->type == 1) { if ($struct_msg->subtype == 'ALTERNATIVE' || $struct_msg->subtype == 'RELATED') { $attach = ' '; } else { $attach = '<img src="themes/' . $theme . '/img/attach.gif" height="28" width="27" alt="" />'; } } else { $attach = ' '; } // Check Status Line with UCB POP Server to // see if this is a new message. This is a // non-RFC standard line header. // Set this in conf.php if ($have_ucb_pop_server) { $header_msg = imap_fetchheader($pop, imap_msgno($pop, $msgnum)); $header_lines = explode("\r\n", $header_msg); while (list($k, $v) = each($header_lines)) { list($header_field, $header_value) = explode(':', $v); if ($header_field == 'Status') { $new_mail_from_header = $header_value; } } } else { if ($ref_contenu_message->Unseen == 'U' || $ref_contenu_message->Recent == 'N') { $new_mail_from_header = ''; } else { $new_mail_from_header = ' '; } } if ($new_mail_from_header == '') { $newmail = '<img src="themes/' . $theme . '/img/new.gif" alt="" height="17" width="17" />'; } else { $newmail = ' '; } $msg_list[$i] = array('new' => $newmail, 'number' => imap_msgno($pop, $msgnum), 'next' => imap_msgno($pop, $sorted[$i + 1]), 'prev' => imap_msgno($pop, $sorted[$i - 1]), 'attach' => $attach, 'from' => htmlspecialchars($from), 'subject' => htmlspecialchars($subject), 'date' => change_date(chop($ref_contenu_message->udate), $lang), 'size' => $msg_size, 'sort' => $sort, 'sortdir' => $sortdir); } imap_close($pop); return $msg_list; } } }
<?php $arrow = $sortdir == 0 ? 'up' : 'down'; $new_sortdir = $sortdir == 0 ? 1 : 0; $is_Imap = is_Imap($servr); ?> <table border="0" align="center" cellpadding="0" cellspacing="0" width="100%"> <tr><td bgcolor="<?php echo $glob_theme->inside_color; ?> "> <form method="post" action="delete.php" name="delete_form"> <input type="hidden" name="lang" value="<?php echo $lang; ?> " /> <table width="100%" cellpadding="2" cellspacing="1" border="0" bgcolor="<?php echo $glob_theme->inside_color; ?> "> <tr bgcolor="<?php echo $glob_theme->tr_color; ?> "> <td <?php if ($is_Imap || $have_ucb_pop_server) { echo 'colspan="4"'; } else { echo 'colspan="3"'; }