This commit has been accessed 591 times via Git panel.
commit 8e2ba22bb1eb9e3da108cbcbe854066b068934fc
tree bea685a0edc8c1409e781429f703c104ea93783f
parent dcbb305fdf4be71d58471e99472d17949b24addb
author Engels Antonio <engels@majcms.org> 1319133759 +0800
committer Engels Antonio <engels@majcms.org> 1319133759 +0800
Add Base64 file attachment support
diff --git a/index.php b/index.php
index 8612c9a..5870843 100644
--- a/index.php
+++ b/index.php
@@ -768,7 +768,6 @@ if (isset($_SESSION['logged_uid'])) {
if ($_SESSION['logged_lvl'] == "subscriber") {
- //$filedrop_box = date("YmdHis");
$filedrop_box = sha1(microtime(true));
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
@@ -781,12 +780,33 @@ if (isset($_SESSION['logged_uid'])) {
$reply_body = trim($_POST['reply_body']);
$reply_headers = "From: $reply_from\r\nX-Mailer: Kartero/1.0 (PHP/" . phpversion() . ")";
+ if (isset($_POST['reply_cc']) and !empty($_POST['reply_cc'])) {
+
+ $reply_cc = trim($_POST['reply_cc']);
+
+ $reply_headers = "$reply_headers\r\nCc: $reply_cc";
+ }
+
+ if (isset($_POST['reply_bcc']) and !empty($_POST['reply_bcc'])) {
+
+ $reply_bcc = trim($_POST['reply_bcc']);
+
+ $reply_headers = "$reply_headers\r\nBcc: $reply_bcc";
+ }
+
if (isset($_POST['filedrop_box']) and !empty($_POST['filedrop_box'])) {
$do_filedrop_box = $_POST['filedrop_box'];
if (file_exists(".tmp/$do_filedrop_box") and (count(glob(".tmp/$do_filedrop_dir/$do_filedrop_box/*")) > 0)) {
+$mime_boundary = md5(microtime(true));
+
+$reply_headers .= "\r\nMIME-Version: 1.0";
+$reply_headers .= "\r\nContent-Type: multipart/mixed; boundary=\"{$mime_boundary}\"";
+$reply_body = "\r\nThis is a multi-part message in MIME format.\r\n\r\n--{$mime_boundary}\r\nContent-type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: 8bit\r\n{$reply_body}";
+
+
$do_reply_from = extract_emails_from($reply_from);
$do_reply_to = extract_emails_from($reply_to);
@@ -801,25 +821,26 @@ if (isset($_SESSION['logged_uid'])) {
sort($do_filedrop_msg);
reset($do_filedrop_msg);
- foreach ($do_filedrop_msg as $do_filedrop_put) {
+/*
+ foreach ($do_filedrop_msg as $do_filedrop_put) {
- $reply_body = $reply_body . "\r\n\r\n" . str_replace("filedrop/$filedrop_box/","",$do_filedrop_put) . " (" . HumanReadableFilesize(filesize($do_filedrop_put)) . ")\r\n" . "http://" . $_SERVER['SERVER_NAME'] . "/$do_filedrop_put";
- }
- }
- }
-
- if (isset($_POST['reply_cc']) and !empty($_POST['reply_cc'])) {
-
- $reply_cc = trim($_POST['reply_cc']);
-
- $reply_headers = "$reply_headers\r\nCc: $reply_cc";
- }
+ $do_filedrop_nom = str_replace("filedrop/$filedrop_box/","",$do_filedrop_put);
- if (isset($_POST['reply_bcc']) and !empty($_POST['reply_bcc'])) {
-
- $reply_bcc = trim($_POST['reply_bcc']);
-
- $reply_headers = "$reply_headers\r\nBcc: $reply_bcc";
+ $reply_body = $reply_body . "\r\n\r\n$do_filedrop_nom (" . HumanReadableFilesize(filesize($do_filedrop_put)) . ")\r\n" . "http://" . $_SERVER['SERVER_NAME'] . "/$do_filedrop_put";
+ }
+*/
+
+ foreach ($do_filedrop_msg as $do_filedrop_put) {
+
+ $do_filedrop_nom = str_replace("filedrop/$filedrop_box/","",$do_filedrop_put);
+
+ $reply_body = $reply_body . "\r\n\r\n--{$mime_boundary}\r\nContent-Type: application/octet-stream; name=\"$do_filedrop_nom\"\r\nContent-Disposition: attachment; filename=\"$do_filedrop_nom\"\r\nContent-Transfer-Encoding: base64\r\n\r\n" . chunk_split(base64_encode(file_get_contents($do_filedrop_put)));
+ }
+
+ $reply_body = $reply_body . "--{$mime_boundary}--";
+
+ rmdirr("filedrop/$filedrop_box");
+ }
}
$reply_body = preg_replace("#(?<!\r)\n#si", "\r\n", $reply_body);
tree bea685a0edc8c1409e781429f703c104ea93783f
parent dcbb305fdf4be71d58471e99472d17949b24addb
author Engels Antonio <engels@majcms.org> 1319133759 +0800
committer Engels Antonio <engels@majcms.org> 1319133759 +0800
Add Base64 file attachment support
diff --git a/index.php b/index.php
index 8612c9a..5870843 100644
--- a/index.php
+++ b/index.php
@@ -768,7 +768,6 @@ if (isset($_SESSION['logged_uid'])) {
if ($_SESSION['logged_lvl'] == "subscriber") {
- //$filedrop_box = date("YmdHis");
$filedrop_box = sha1(microtime(true));
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
@@ -781,12 +780,33 @@ if (isset($_SESSION['logged_uid'])) {
$reply_body = trim($_POST['reply_body']);
$reply_headers = "From: $reply_from\r\nX-Mailer: Kartero/1.0 (PHP/" . phpversion() . ")";
+ if (isset($_POST['reply_cc']) and !empty($_POST['reply_cc'])) {
+
+ $reply_cc = trim($_POST['reply_cc']);
+
+ $reply_headers = "$reply_headers\r\nCc: $reply_cc";
+ }
+
+ if (isset($_POST['reply_bcc']) and !empty($_POST['reply_bcc'])) {
+
+ $reply_bcc = trim($_POST['reply_bcc']);
+
+ $reply_headers = "$reply_headers\r\nBcc: $reply_bcc";
+ }
+
if (isset($_POST['filedrop_box']) and !empty($_POST['filedrop_box'])) {
$do_filedrop_box = $_POST['filedrop_box'];
if (file_exists(".tmp/$do_filedrop_box") and (count(glob(".tmp/$do_filedrop_dir/$do_filedrop_box/*")) > 0)) {
+$mime_boundary = md5(microtime(true));
+
+$reply_headers .= "\r\nMIME-Version: 1.0";
+$reply_headers .= "\r\nContent-Type: multipart/mixed; boundary=\"{$mime_boundary}\"";
+$reply_body = "\r\nThis is a multi-part message in MIME format.\r\n\r\n--{$mime_boundary}\r\nContent-type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: 8bit\r\n{$reply_body}";
+
+
$do_reply_from = extract_emails_from($reply_from);
$do_reply_to = extract_emails_from($reply_to);
@@ -801,25 +821,26 @@ if (isset($_SESSION['logged_uid'])) {
sort($do_filedrop_msg);
reset($do_filedrop_msg);
- foreach ($do_filedrop_msg as $do_filedrop_put) {
+/*
+ foreach ($do_filedrop_msg as $do_filedrop_put) {
- $reply_body = $reply_body . "\r\n\r\n" . str_replace("filedrop/$filedrop_box/","",$do_filedrop_put) . " (" . HumanReadableFilesize(filesize($do_filedrop_put)) . ")\r\n" . "http://" . $_SERVER['SERVER_NAME'] . "/$do_filedrop_put";
- }
- }
- }
-
- if (isset($_POST['reply_cc']) and !empty($_POST['reply_cc'])) {
-
- $reply_cc = trim($_POST['reply_cc']);
-
- $reply_headers = "$reply_headers\r\nCc: $reply_cc";
- }
+ $do_filedrop_nom = str_replace("filedrop/$filedrop_box/","",$do_filedrop_put);
- if (isset($_POST['reply_bcc']) and !empty($_POST['reply_bcc'])) {
-
- $reply_bcc = trim($_POST['reply_bcc']);
-
- $reply_headers = "$reply_headers\r\nBcc: $reply_bcc";
+ $reply_body = $reply_body . "\r\n\r\n$do_filedrop_nom (" . HumanReadableFilesize(filesize($do_filedrop_put)) . ")\r\n" . "http://" . $_SERVER['SERVER_NAME'] . "/$do_filedrop_put";
+ }
+*/
+
+ foreach ($do_filedrop_msg as $do_filedrop_put) {
+
+ $do_filedrop_nom = str_replace("filedrop/$filedrop_box/","",$do_filedrop_put);
+
+ $reply_body = $reply_body . "\r\n\r\n--{$mime_boundary}\r\nContent-Type: application/octet-stream; name=\"$do_filedrop_nom\"\r\nContent-Disposition: attachment; filename=\"$do_filedrop_nom\"\r\nContent-Transfer-Encoding: base64\r\n\r\n" . chunk_split(base64_encode(file_get_contents($do_filedrop_put)));
+ }
+
+ $reply_body = $reply_body . "--{$mime_boundary}--";
+
+ rmdirr("filedrop/$filedrop_box");
+ }
}
$reply_body = preg_replace("#(?<!\r)\n#si", "\r\n", $reply_body);