This blob has been accessed 488 times via Git panel.
- <?php
- require_once("core.php");
- if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
- exit;
- }
- if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])) {
- $msgno = trim(strip_tags($_POST['msg']));
- $header = imap_rfc822_parse_headers(imap_fetchbody($mbox,$msgno,0,FT_UID));
- $header_subject = imap_utf8($header->subject);
- $header_fromaddress = imap_utf8($header->senderaddress);
- $header_date = imap_utf8($header->date);
- $header_toaddress = imap_utf8($header->toaddress);
- $header_ccaddress = imap_utf8($header->ccaddress);
- $reply_quote = trim(get_part($mbox, $msgno, "TEXT/PLAIN"));
- $reply_quote = mb_convert_encoding($reply_quote,"UTF-8");
- if ($_POST['rep'] != 2) {
- $reply_quote = wordwrap($reply_quote,75,"\n");
- }
- $reply_quote_lines = explode("\n",$reply_quote);
- if (count($reply_quote_lines) < 10) {
- $reply_quote_rows = "10";
- }
- else {
- $reply_quote_rows = count($reply_quote_lines) + 1;
- }
- if ($folder != "Drafts") {
- $reply_from = "$usr_name <{$_SESSION['logged_uid']}>";
- $reply_to = imap_utf8($header->reply_toaddress);
- if ($reply_to != "") {
- $reply_to = imap_utf8($header->reply_toaddress);
- }
- else {
- $reply_to = imap_utf8($header->fromaddress);
- }
- if (($_POST['rep'] == 3) and strpos(imap_utf8($header->toaddress),",")) {
- $reply_to = $reply_to . ", " . imap_utf8($header->toaddress);
- }
- }
- else {
- $reply_from = imap_utf8($header->fromaddress);
- $reply_to = imap_utf8($header->toaddress);
- }
- if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
- $reply_cc ="";
- }
- else {
- $reply_cc = imap_utf8($header->ccaddress);
- }
- $reply_subject = imap_utf8($header->subject);
- $reply_subject = str_replace("FWD: ","Fwd: ",$reply_subject);
- $reply_subject = str_replace("RE: ","Re: ",$reply_subject);
- if ($folder != "Drafts") {
- if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
- $redirect_from = htmlentities($reply_to,ENT_QUOTES,"UTF-8");
- $reply_to = "";
- if ($_POST['rep'] == 2) {
- $reply_subject = "Fwd: " . $reply_subject;
- }
- }
- else {
- $reply_subject = "Re: " . $reply_subject;
- }
- }
- if (substr_count($reply_subject, "Fwd: ") > 1) {
- while (substr_count($reply_subject, "Fwd: ") > 1) {
- $reply_subject = substr_replace($reply_subject,"",strrpos($reply_subject,"Fwd: "),5);
- }
- }
- if (substr_count($reply_subject, "Re: ") > 1) {
- while (substr_count($reply_subject, "Re: ") > 1) {
- $reply_subject = substr_replace($reply_subject,"",strrpos($reply_subject,"Re: "),4);
- }
- }
- $reply_from = htmlentities($reply_from,ENT_QUOTES,"UTF-8");
- $reply_to = htmlentities($reply_to,ENT_QUOTES,"UTF-8");
- $reply_subject = htmlentities($reply_subject,ENT_QUOTES,"UTF-8");
- $reply_cc = htmlentities($reply_cc,ENT_QUOTES,"UTF-8");
- if ($folder == "Sent") {
- $header_tos = extract_emails_from($header_fromaddress);
- }
- else {
- $header_tos = extract_emails_from($header_toaddress);
- }
- $header_fetch = imap_fetchheader($mbox,$msgno,FT_UID);
- $header_raw_lines = explode("\n",$header_fetch);
- foreach ($header_raw_lines as $header_raw_line) {
- $header_x2 = str_replace("X-Original-To: ","",$header_raw_line);
- if ($header_x2 != $_SESSION['logged_uid']) {
- $header_tos[] = $header_x2;
- }
- unset($header_x2);
- }
- $header_d2 = str_replace("Delivered-To: ","",$header_raw_line);
- if ($header_d2 != $_SESSION['logged_uid']) {
- $header_tos[] = $header_d2;
- }
- unset($header_d2);
- }
- }
- $header_tos = array_values(array_unique($header_tos));
- $send_alias_query = mysql_query("select domains.id, aliases.id from aliases, domains where aliases.alias='{$_SESSION['logged_uid']}' and aliases.mode='1' and aliases.domain=domains.id and domains.mode='1' order by aliases.domain, aliases.id");
- echo "<title>Kartero - $folder - $reply_subject</title>";
- echo "<table border=\"0\" cellspacing=\"0\" callpadding=\"0\" width=\"100%\"><tr><td valign=\"top\">";
- echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\">";
- echo "<form method=\"post\">";
- if (($_POST['rep'] == 1) or ($_POST['rep'] == 3)) {
- echo "<input type=\"hidden\" name=\"ack\" value=\"1\">";
- }
- echo "<tr><td width=\"50\"><b>From:</b></td><td rowspan=\"7\" width=\"5\"></td><td colspan=\"2\">";
- if ($_POST['rep'] == 4) {
- echo "<input type=\"hidden\" name=\"redirect\" value=\"1\">";
- echo "<input class=\"input\" type=\"text\" name=\"reply_from\" value=\"$redirect_from\" readonly>";
- }
- else {
- if (mysql_num_rows($send_alias_query) > 0) {
- echo "<select class=\"input\" name=\"reply_from\">";
- echo "<option>$reply_from</option>";
- while ($row = mysql_fetch_assoc($send_alias_query)) {
- if ($row[id] == $header_tos[0]) {
- echo "<option selected>";
- }
- else {
- echo "<option>";
- }
- echo "$usr_name <$row[id]>";
- echo "</option>";
- }
- echo "</select>";
- }
- else {
- echo "<input class=\"input\" type=\"text\" name=\"reply_from\" value=\"$reply_from\" readonly>";
- }
- }
- echo "</td></tr>";
- mysql_free_result($send_alias_query);
- echo "<tr><td><b>To:</b></td><td colspan=\"2\"><input required class=\"input\" type=\"text\" name=\"reply_to\" value=\"$reply_to\" required></td></tr>";
- echo "<tr><td><b>Cc:</b></td><td colspan=\"2\"><input class=\"input\" type=\"text\" name=\"reply_cc\" value=\"$reply_cc\"></td></tr>";
- if ($folder != "Drafts") {
- echo "<tr><td><b>Bcc:</b></td><td colspan=\"2\"><input class=\"input\" type=\"text\" name=\"reply_bcc\"></td></tr>";
- }
- else {
- $reply_bcc = imap_utf8($header->bccaddress);
- echo "<tr><td><b>Bcc:</b></td><td colspan=\"2\"><input class=\"input\" type=\"text\" name=\"reply_bcc\" value=\"$reply_bcc\"></td></tr>";
- }
- echo "<tr><td><b>Subject:</b></td><td colspan=\"2\"><input required class=\"input\" type=\"text\" name=\"reply_subj\" value=\"$reply_subject\" required";
- if ($_POST['rep'] == 4) {
- echo " readonly";
- }
- echo "></td></tr>";
- echo "<tr><td></td><td colspan=\"2\"><textarea required class=\"input\" name=\"reply_body\" rows=\"$reply_quote_rows\"";
- if ($_POST['rep'] == 4) {
- echo " readonly=\"yes\"";
- }
- echo ">";
- if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
- if ($_POST['rep'] == 2) {
- echo "---------------------------------------- Begin Forwarded Message ----------------------------------------\n";
- echo "From: $header_fromaddress\n";
- echo "To: $header_toaddress\n";
- echo "Cc: $header_ccaddress\n";
- }
- echo "Date: $header_date\n";
- echo "Subject: $header_subject\n\n";
- }
- echo $reply_quote;
- }
- else {
- if ($folder != "Drafts") {
- $reply_personal = imap_utf8($header->fromaddress);
- echo "On $header_date, $reply_personal wrote:";
- foreach ($reply_quote_lines as $reply_quote_line) {
- $reply_quote_line = "> $reply_quote_line";
- $reply_quote_line = preg_replace("/(^> >)/",">>",$reply_quote_line);
- $reply_quote_line = preg_replace("/(^>> >)/",">>>",$reply_quote_line);
- echo "\n$reply_quote_line";
- }
- }
- else {
- echo $reply_quote;
- }
- }
- echo "</textarea></td></tr>";
- echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
- echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
- echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
- echo "<input type=\"hidden\" name=\"filedrop_box\" value=\"$filedrop_box\">";
- if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
- echo "<input type=\"hidden\" name=\"imap_search_query\" value=\"{$_POST['imap_search_query']}\">";
- echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
- }
- echo "<tr><td></td><td>";
- if ($_POST['rep'] != 4) {
- if ($folder == "Drafts") {
- $header_fetch = imap_utf8(imap_fetchheader($mbox,$msgno,FT_UID|FT_PREFETCHTEXT));
- $header_raw_lines = explode("\n",$header_fetch);
- foreach ($header_raw_lines as $header_raw_line) {
- $header_priority = $header_raw_line;
- }
- $header_priority = $header_raw_line;
- }
- $header_rr = $header_raw_line;
- }
- $header_rr = $header_raw_line;
- }
- $header_dr = $header_raw_line;
- }
- }
- echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
- if ($header_priority != "") {
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_hi\" checked></td><td valign=\"middle\">high priority</td>";
- }
- else {
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_hi\"></td><td valign=\"middle\">high priority</td>";
- }
- echo "<td width=\"10\"></td>";
- if ($header_rr != "") {
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_rr\" checked></td><td valign=\"middle\">read receipt</td>";
- }
- else {
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_rr\"></td><td valign=\"middle\">read receipt</td>";
- }
- echo "<td width=\"10\"></td>";
- if ($header_dr != "") {
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dr\" checked></td><td valign=\"middle\">delivery receipt</td>";
- }
- else {
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dr\"></td><td valign=\"middle\">delivery receipt</td>";
- }
- echo "<td width=\"10\"></td>";
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_sm\"></td><td valign=\"middle\">sign</td>";
- echo "<td width=\"10\"></td>";
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dm\" id=\"reply_dm\" onclick=\"if (this.checked) { document.getElementById('reply_go').innerHTML='save'; } else { document.getElementById('reply_go').innerHTML='send'; }\"></td><td valign=\"middle\">draft</td>";
- echo "</tr></table>";
- }
- else {
- echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_hi\"></td><td valign=\"middle\">high priority</td>";
- echo "<td width=\"10\"></td>";
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_rr\"></td><td valign=\"middle\">read receipt</td>";
- echo "<td width=\"10\"></td>";
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dr\"></td><td valign=\"middle\">delivery receipt</td>";
- echo "<td width=\"10\"></td>";
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_sm\"></td><td valign=\"middle\">sign</td>";
- echo "<td width=\"10\"></td>";
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dm\" id=\"reply_dm\" onclick=\"if (this.checked) { document.getElementById('reply_go').innerHTML='save'; } else { document.getElementById('reply_go').innerHTML='send'; }\"></td><td valign=\"middle\">draft</td>";
- echo "</tr></table>";
- }
- }
- if ($_POST['rep'] != 4) {
- echo "</td><td align=\"right\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><input type=\"image\" src=\"images/mail-reply.png\" onclick=\"if (document.getElementById('reply_dm').checked) { if (confirm('Save message?')) {return true;} else {return false;}} else { if (confirm('Send message?')) {return true;} else {return false;}}\"></td><td width=\"40\" align=\"center\" valign=\"middle\" id=\"reply_go\">send</td></tr></table></td></tr>";
- }
- else {
- echo "</td><td align=\"right\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><input type=\"image\" src=\"images/mail-reply.png\" onclick=\"if (confirm('Send message?')) {return true;} else {return false;}\"></td><td width=\"40\" align=\"center\" valign=\"middle\" id=\"reply_go\">send</td></tr></table></td></tr>";
- }
- echo "</table>";
- echo "</form>";
- echo "</td></tr>";
- echo "</table>";
- }
- if ($_POST['rep'] != 4) {
- if ($folder == "Drafts") {
- pass1_process($mbox, $msgno, "attach/i/$fileUsr/$filedrop_box");
- pass2_process($mbox, $msgno, "attach/i/$fileUsr/$filedrop_box");
- }
- ?>
- <table border="0" cellspacing="0" cellpadding="0">
- <form name="filedrop_form" enctype="multipart/form-data" action="filedrop.php" method="post" target="filedrop" onsubmit="this.elements['filedrop_submit'].disabled = true;document.getElementById('filedrop_wait').innerHTML = '<img src=images/ajax-loader.gif border=0 width=16 height=16 hspace=5>';">
- <tr><td>
- <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
- <input type="hidden" name="filedrop_box" value="<?php echo $filedrop_box; ?>">
- <?php
- if ($_POST['rep'] == 4) {
- echo "<input type=\"file\" name=\"filedrop_obj[]\" disabled>";
- }
- else {
- echo "<input type=\"file\" name=\"filedrop_obj[]\" multiple>";
- }
- ?>
- <input type="submit" name="filedrop_submit" value="Upload">
- </td>
- <td>
- </td></tr>
- </form>
- </table>
- </div>
- <iframe style="display: none;" id="filedrop" name="filedrop" src="filedrop.php" frameborder="0" scrolling="0" width="100%" height="0"></iframe>
- <?php
- }
- ?>