This commit has been accessed 587 times via Git panel.
commit 2dc399d976c773474023943cf29c110df720fb31
tree b20e27dc4408e2d852637c39513ee32bdda3c45b
parent f62cb53bf0b47125acabadb5af83b5f5a820d4f6
author Engels Antonio <engels@majcms.org> 1323092800 +0800
committer Engels Antonio <engels@majcms.org> 1323092800 +0800
Fix missing filedrop list in reply and forward
diff --git a/index.php b/index.php
index 30de31b..da83266 100644
--- a/index.php
+++ b/index.php
@@ -786,7 +786,7 @@ if (isset($_SESSION['logged_uid'])) {
if ($_SESSION['logged_lvl'] == "subscriber") {
- $filedrop_box = sha1(microtime(true));
+ $filedrop_box = sha1(microtime(true));
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
diff --git a/read.php b/read.php
index ca6f018..3fa97d2 100644
--- a/read.php
+++ b/read.php
@@ -275,30 +275,6 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<div class=\"message\">";
- $dataTxt = get_part($mbox, $msgno, "TEXT/PLAIN");
- $dataHtml = get_part($mbox, $msgno, "TEXT/HTML");
-
- if ($dataHtml != "") {
- $msgBody = $dataHtml;
- }
- else {
- $msgBody = trim($dataTxt);
- $msgBody = ereg_replace("\n","<br>",$msgBody);
- $msgBody = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i","$1http://$2",$msgBody);
- $msgBody = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</a>",$msgBody);
- $msgBody = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<a href=\"mailto:$1\">$1</a>",$msgBody);
- }
-
- $msgBody = mb_convert_encoding($msgBody,"UTF-8","auto");
- $msgBody = mb_convert_encoding($msgBody,"UTF-8","UTF-8");
-
- echo $msgBody;
-
- echo "</div>";
-
- $do_fromaddress = extract_emails_from($header->fromaddress);
- $do_toaddress = extract_emails_from($header->toaddress);
-
$filePath = "attach/o/$fileUsr/$fileDir";
$struct = imap_fetchstructure($mbox, $msgno);
@@ -332,8 +308,74 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
}
}
+
+ if (($contentPart->subtype == "GIF") or ($contentPart->subtype == "JPEG") or ($contentPart->subtype == "PNG")) {
+
+ if ($contentPart->bytes > 0) {
+
+ $contentDP = $contentPart->parameters;
+
+ if ($contentDP[0]->attribute == "name") {
+
+ $fileName = $contentDP[0]->value;
+ $fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$fileName);
+
+ $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n));
+
+ if (!file_exists($filePath)) {
+ mkdir($filePath,0700,1);
+ }
+
+ if (!file_exists("$filePath/$fileName")) {
+ file_put_contents("$filePath/$fileName",$fileContent);
+ }
+
+ if (!is_image("$filePath/$fileName")) {
+ unlink("$filePath/$fileName");
+ }
+ }
+ }
+ }
+ }
+
+ $dataTxt = get_part($mbox, $msgno, "TEXT/PLAIN");
+ $dataHtml = get_part($mbox, $msgno, "TEXT/HTML");
+
+ if ($dataHtml != "") {
+ $msgBody = $dataHtml;
+ }
+ else {
+ $msgBody = trim($dataTxt);
+ $msgBody = ereg_replace("\n","<br>",$msgBody);
+ $msgBody = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i","$1http://$2",$msgBody);
+ $msgBody = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</a>",$msgBody);
+ $msgBody = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<a href=\"mailto:$1\">$1</a>",$msgBody);
+ }
+
+ // http://www.phpclasses.org/discuss/package/3324/thread/11/
+
+ if (stristr($msgBody,'src="cid:')) {
+
+ $cid_pass1 = '/src="cid:(.*?)"/si';
+ preg_match($cid_pass1,$msgBody,$cid_out1);
+
+ $cid_pass2 = '/@(.*?)"/si';
+ preg_match($cid_pass2,$cid_out1[0],$cid_out2);
+
+ $msgBody = str_ireplace($cid_out2[0],'"',$msgBody);
+ $msgBody = str_ireplace('src="cid:',"src=\"$filePath/",$msgBody);
}
+ $msgBody = mb_convert_encoding($msgBody,"UTF-8","auto");
+ $msgBody = mb_convert_encoding($msgBody,"UTF-8","UTF-8");
+
+ echo $msgBody;
+
+ echo "</div>";
+
+ //$do_fromaddress = extract_emails_from($header->fromaddress);
+ //$do_toaddress = extract_emails_from($header->toaddress);
+
if (file_exists("$filePath")) {
$fileAttachments = glob("$filePath/*");
diff --git a/send.php b/send.php
index a3142f7..cdcc1dc 100644
--- a/send.php
+++ b/send.php
@@ -227,8 +227,6 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
<div class="message">
-<iframe name="filedrop" src="filedrop.php" frameborder="0" scrolling="0" width="0" height="0"></iframe>
-
<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>
@@ -245,3 +243,22 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
</table>
</div>
+
+<script>
+<!--
+function calcHeight(iframe_id)
+{
+ var iframe_height=document.getElementById(iframe_id).contentWindow.document.body.scrollHeight;
+
+ if (iframe_height<9)
+ {
+ document.getElementById(iframe_id).height=0;
+ }
+ else {
+ document.getElementById(iframe_id).height=iframe_height;
+ }
+}
+//-->
+</script>
+
+<iframe id="filedrop" onLoad="calcHeight('filedrop');" name="filedrop" src="filedrop.php" frameborder="0" scrolling="0" width="100%" height="0"></iframe>
tree b20e27dc4408e2d852637c39513ee32bdda3c45b
parent f62cb53bf0b47125acabadb5af83b5f5a820d4f6
author Engels Antonio <engels@majcms.org> 1323092800 +0800
committer Engels Antonio <engels@majcms.org> 1323092800 +0800
Fix missing filedrop list in reply and forward
diff --git a/index.php b/index.php
index 30de31b..da83266 100644
--- a/index.php
+++ b/index.php
@@ -786,7 +786,7 @@ if (isset($_SESSION['logged_uid'])) {
if ($_SESSION['logged_lvl'] == "subscriber") {
- $filedrop_box = sha1(microtime(true));
+ $filedrop_box = sha1(microtime(true));
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
diff --git a/read.php b/read.php
index ca6f018..3fa97d2 100644
--- a/read.php
+++ b/read.php
@@ -275,30 +275,6 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<div class=\"message\">";
- $dataTxt = get_part($mbox, $msgno, "TEXT/PLAIN");
- $dataHtml = get_part($mbox, $msgno, "TEXT/HTML");
-
- if ($dataHtml != "") {
- $msgBody = $dataHtml;
- }
- else {
- $msgBody = trim($dataTxt);
- $msgBody = ereg_replace("\n","<br>",$msgBody);
- $msgBody = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i","$1http://$2",$msgBody);
- $msgBody = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</a>",$msgBody);
- $msgBody = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<a href=\"mailto:$1\">$1</a>",$msgBody);
- }
-
- $msgBody = mb_convert_encoding($msgBody,"UTF-8","auto");
- $msgBody = mb_convert_encoding($msgBody,"UTF-8","UTF-8");
-
- echo $msgBody;
-
- echo "</div>";
-
- $do_fromaddress = extract_emails_from($header->fromaddress);
- $do_toaddress = extract_emails_from($header->toaddress);
-
$filePath = "attach/o/$fileUsr/$fileDir";
$struct = imap_fetchstructure($mbox, $msgno);
@@ -332,8 +308,74 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
}
}
+
+ if (($contentPart->subtype == "GIF") or ($contentPart->subtype == "JPEG") or ($contentPart->subtype == "PNG")) {
+
+ if ($contentPart->bytes > 0) {
+
+ $contentDP = $contentPart->parameters;
+
+ if ($contentDP[0]->attribute == "name") {
+
+ $fileName = $contentDP[0]->value;
+ $fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$fileName);
+
+ $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n));
+
+ if (!file_exists($filePath)) {
+ mkdir($filePath,0700,1);
+ }
+
+ if (!file_exists("$filePath/$fileName")) {
+ file_put_contents("$filePath/$fileName",$fileContent);
+ }
+
+ if (!is_image("$filePath/$fileName")) {
+ unlink("$filePath/$fileName");
+ }
+ }
+ }
+ }
+ }
+
+ $dataTxt = get_part($mbox, $msgno, "TEXT/PLAIN");
+ $dataHtml = get_part($mbox, $msgno, "TEXT/HTML");
+
+ if ($dataHtml != "") {
+ $msgBody = $dataHtml;
+ }
+ else {
+ $msgBody = trim($dataTxt);
+ $msgBody = ereg_replace("\n","<br>",$msgBody);
+ $msgBody = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i","$1http://$2",$msgBody);
+ $msgBody = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</a>",$msgBody);
+ $msgBody = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<a href=\"mailto:$1\">$1</a>",$msgBody);
+ }
+
+ // http://www.phpclasses.org/discuss/package/3324/thread/11/
+
+ if (stristr($msgBody,'src="cid:')) {
+
+ $cid_pass1 = '/src="cid:(.*?)"/si';
+ preg_match($cid_pass1,$msgBody,$cid_out1);
+
+ $cid_pass2 = '/@(.*?)"/si';
+ preg_match($cid_pass2,$cid_out1[0],$cid_out2);
+
+ $msgBody = str_ireplace($cid_out2[0],'"',$msgBody);
+ $msgBody = str_ireplace('src="cid:',"src=\"$filePath/",$msgBody);
}
+ $msgBody = mb_convert_encoding($msgBody,"UTF-8","auto");
+ $msgBody = mb_convert_encoding($msgBody,"UTF-8","UTF-8");
+
+ echo $msgBody;
+
+ echo "</div>";
+
+ //$do_fromaddress = extract_emails_from($header->fromaddress);
+ //$do_toaddress = extract_emails_from($header->toaddress);
+
if (file_exists("$filePath")) {
$fileAttachments = glob("$filePath/*");
diff --git a/send.php b/send.php
index a3142f7..cdcc1dc 100644
--- a/send.php
+++ b/send.php
@@ -227,8 +227,6 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
<div class="message">
-<iframe name="filedrop" src="filedrop.php" frameborder="0" scrolling="0" width="0" height="0"></iframe>
-
<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>
@@ -245,3 +243,22 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
</table>
</div>
+
+<script>
+<!--
+function calcHeight(iframe_id)
+{
+ var iframe_height=document.getElementById(iframe_id).contentWindow.document.body.scrollHeight;
+
+ if (iframe_height<9)
+ {
+ document.getElementById(iframe_id).height=0;
+ }
+ else {
+ document.getElementById(iframe_id).height=iframe_height;
+ }
+}
+//-->
+</script>
+
+<iframe id="filedrop" onLoad="calcHeight('filedrop');" name="filedrop" src="filedrop.php" frameborder="0" scrolling="0" width="100%" height="0"></iframe>