This blob has been accessed 352 times via Git panel.
- <?php
- session_start();
- if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
- exit;
- }
- require_once("core.php");
- if (!isset($_POST['box']) or empty($_POST['box'])) {
- $folder = "INBOX";
- }
- else {
- $folder = trim(strip_tags($_POST['box']));
- }
- $host = "{127.0.0.1:143/imap/notls/norsh}";
- $mbox = @imap_open("{$host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
- if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])) {
- $msgno = trim(strip_tags($_POST['msg']));
- $header = imap_headerinfo($mbox, $msgno);
- $header_subject = $header->subject;
- $header_fromaddress = $header->senderaddress;
- $header_date = $header->date;
- $header_toaddress = $header->toaddress;
- $header_ccaddress = $header->ccaddress;
- $reply_quote = wordwrap(trim(get_part($mbox, $msgno, "TEXT/PLAIN")),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) {
- $reply_cc ="";
- }
- else {
- $reply_cc = $header->ccaddress;
- }
- $reply_subject = $header->subject;
- if ($_POST['rep'] == 2) {
- $reply_to = "";
- $reply_subject = "Fwd: " . $reply_subject;
- $reply_subject = str_replace("Fwd: Fwd: ","Fwd: ",$reply_subject);
- }
- else {
- $reply_subject = "Re: " . $reply_subject;
- $reply_subject = str_replace("Re: Re: ","Re: ",$reply_subject);
- }
- $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);
- $header_fetch = imap_fetchheader($mbox,$msgno);
- $header_raw_lines = explode("\r\n",$header_fetch);
- foreach ($header_raw_lines as $header_raw_line) {
- $header_tos[] = str_replace("X-Original-To: ","",$header_raw_line);
- }
- /*
- if (strstr($header_raw_line,"Delivered-To:")) {
- $header_tos[] = str_replace("Delivered-To: ","",$header_raw_line);
- }
- */
- }
- $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=\"800\"><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 (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)) {
- echo "<option";
- if ($row[id] == $header_tos[0]) {
- echo " selected";
- }
- 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 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 class=\"input\" type=\"text\" name=\"reply_subj\" value=\"$reply_subject\" required></td></tr>";
- echo "<tr><td></td><td><textarea class=\"input\" name=\"reply_body\" rows=\"$reply_quote_rows\">";
- if ($_POST['rep'] == 2) {
- echo "---------------------------------------- Begin Forwarded Message ----------------------------------------\r\n";
- echo $reply_quote;
- $filePath = "filedrop/" . sha1($_SERVER['SERVER_NAME']) ."/" . sha1($header->subject);
- 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\">";
- echo "<tr><td></td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\"></div><div class=\"label\">send</div></td></tr>";
- echo "</table>";
- echo "</form>";
- echo "</td></tr>";
- echo "</table>";
- imap_close($mbox);
- }
- ?>
- <iframe name="filedrop" src="filedrop.php" frameborder="0" scrolling="0" width="0" height="0"></iframe>
- <table border="0" cellspcaing="0" cellpadding="0">
- <form enctype="multipart/form-data" action="filedrop.php" method="post" target="filedrop">
- <tr><td>
- <input type="hidden" name="filedrop_box" value="<?php echo $filedrop_box; ?>">
- <input type="file" name="filedrop_obj">
- <input type="submit">
- </td></tr>
- </form>
- </table>
- </div>