This blob has been accessed 314 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 = $header->subject;
- $header_fromaddress = $header->senderaddress;
- $header_date = $header->date;
- $header_toaddress = $header->toaddress;
- $header_ccaddress = $header->ccaddress;
- $reply_quote = trim(get_part($mbox, $msgno, "TEXT/PLAIN"));
- if ($_POST['rep'] != 2) {
- $reply_quote = wordwrap($reply_quote,75,"\r\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;
- }
- $reply_from = "$usr_name <{$_SESSION['logged_uid']}>";
- $reply_to = $header->reply_toaddress;
- if ($reply_to != "") {
- $reply_to = $header->reply_toaddress;
- }
- else {
- $reply_to = $header->fromaddress;
- }
- if (($_POST['rep'] == 3) and strpos($header->toaddress,",")) {
- $reply_to = $reply_to . ", " . $header->toaddress;
- }
- if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
- $reply_cc ="";
- }
- else {
- $reply_cc = $header->ccaddress;
- }
- $reply_subject = $header->subject;
- $reply_subject = str_replace("FWD: ","Fwd: ",$reply_subject);
- $reply_subject = str_replace("RE: ","Re: ",$reply_subject);
- if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
- $redirect_from = htmlentities($reply_to,ENT_QUOTES);
- $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);
- $reply_to = htmlentities($reply_to,ENT_QUOTES);
- $reply_subject = htmlentities($reply_subject,ENT_QUOTES);
- $reply_cc = htmlentities($reply_cc,ENT_QUOTES);
- 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("\r\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>";
- 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><input required class=\"input\" type=\"text\" name=\"reply_to\" value=\"$reply_to\" required></td></tr>";
- echo "<tr><td><b>Cc:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_cc\" value=\"$reply_cc\"></td></tr>";
- echo "<tr><td><b>Bcc:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_bcc\"></td></tr>";
- echo "<tr><td><b>Subject:</b></td><td><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><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 ----------------------------------------\r\n";
- echo "From: $header_fromaddress\r\n";
- echo "To: $header_toaddress\r\n";
- echo "Cc: $header_ccaddress\r\n";
- }
- echo "Date: $header_date\r\n";
- echo "Subject: $header_subject\r\n\r\n";
- }
- echo $reply_quote;
- $do_fromaddress = extract_emails_from($header->fromaddress);
- $do_toaddress = extract_emails_from($header->toaddress);
- $filePath = $_SERVER['SERVER_NAME'] . $do_fromaddress[0] . $do_toaddress[0] . $header->subject;
- $filePath = "filedrop/" . sha1($filePath);
- if (file_exists("$filePath")) {
- $fileNames = glob("$filePath/*");
- if (count($fileNames) > 0) {
- foreach ($fileNames as $fileName) {
- echo "\r\n\r\n" . str_replace("$filePath/","",$fileName) . " (" . HumanReadableFilesize(filesize($fileName)) . ")\r\n";
- echo "http://" . $_SERVER['SERVER_NAME'] . "/$fileName";
- }
- }
- }
- }
- else {
- $reply_personal = $header->fromaddress;
- echo "On $header_date, $reply_personal wrote:\r\n";
- foreach ($reply_quote_lines as $reply_quote_line) {
- $reply_quote_line = "> $reply_quote_line";
- $reply_quote_line = preg_replace("/(^> >)/",">>",$reply_quote_line);
- echo $reply_quote_line;
- }
- }
- 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 align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\" onclick=\"if (confirm('Send message?')) {return true;} else {return false;}\"></div><div class=\"label\">send</div></td></tr>";
- echo "</table>";
- echo "</form>";
- echo "</td></tr>";
- echo "</table>";
- }
- ?>
- <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\">";
- }
- ?>
- <input type="submit" name="filedrop_submit" value="Upload">
- </td>
- <td>
- </td></tr>
- </form>
- </table>
- </div>
- <iframe id="filedrop" name="filedrop" src="filedrop.php" frameborder="0" scrolling="0" width="100%" height="0"></iframe>