This commit has been accessed 576 times via Git panel.
commit 1d1e43e8f41d87c09f134f37542ff81cbebb3e9f
tree 1f0bf1750f0ff2adfcf41b66e9f8bd33ecd25029
parent ce0702bdba2d56702b3f441759fd2127d5c78ed1
author Engels Antonio <engels@majcms.org> 1297798963 +0800
committer Engels Antonio <engels@majcms.org> 1297798963 +0800
Fix file attach sort and display
diff --git a/read.php b/read.php
index 0be4a2e..23a90a3 100644
--- a/read.php
+++ b/read.php
@@ -244,7 +244,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
echo "</div>";
-
+/*
foreach ($attachDisplay as $attachD => $attachE) {
if (strtolower($attachE) == "utf-8") {
@@ -259,26 +259,19 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
unset($attachDisplay[$attachD]);
}
}
-
- sort($attachDisplay);
+*/
reset($attachDisplay);
-
+
if (sizeof($attachDisplay) > 0) {
$filePath = "attachments/" . sha1($_SERVER['SERVER_NAME']) ."/" . sha1($header->subject);
- echo "<div class=\"spacer\"></div>";
-
- echo "<div class=\"message\" style=\"position: relative;\">";
-
-
- echo "<div style=\"position: absolute; top: -15; right: -15;\"><img src=\"images/attach.png\" border=\"0\" width=\"48\" height=\"48\"></div>";
-
- echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\">";
+ $fileAttachments = "";
for ($j=0;$j<sizeof($attachDisplay);$j++) {
- if (($dataHtml != "") and (strtolower($attachDisplay[$j]) != "utf-8") and (strtolower($attachDisplay[$j]) != "windows-1252")) {
+ if ($dataHtml != "") {
+
$file = $j;
$fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$file+2));
$fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$attachDisplay[$j]);
@@ -292,13 +285,32 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
$fileSize = filesize("$filePath/$fileName");
- $fileSize = HumanReadableFilesize($fileSize);
- echo "<tr><td><a href=\"$filePath/$fileName\"><img src=\"images/file.png\" border=\"0\" width=\"36\" height=\"36\"></a></td><td><a href=\"$fileName\">$fileName</a><br>$fileSize</td></tr>";
+
+ if ($fileSize > 0) {
+ $fileSize = HumanReadableFilesize($fileSize);
+ $fileAttachments = $fileAttachments . "\r\n<tr><td><a href=\"$filePath/$fileName\"><img src=\"images/file.png\" border=\"0\" width=\"36\" height=\"36\"></a></td><td><a href=\"$fileName\">$fileName</a><br>$fileSize</td></tr>\r\n";
+ }
+ else {
+ unlink("$filePath/$fileName");
+ }
}
}
- echo "</table>";
- echo "</div>";
+ if ($fileAttachments != "") {
+
+ echo "<div class=\"spacer\"></div>";
+
+ echo "<div class=\"message\" style=\"position: relative;\">";
+
+ echo "<div style=\"position: absolute; top: -15; right: -15;\"><img src=\"images/attach.png\" border=\"0\" width=\"48\" height=\"48\"></div>";
+
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\">";
+
+ echo "$fileAttachments";
+
+ echo "</table>";
+ echo "</div>";
+ }
}
echo "</td></tr></table>";
tree 1f0bf1750f0ff2adfcf41b66e9f8bd33ecd25029
parent ce0702bdba2d56702b3f441759fd2127d5c78ed1
author Engels Antonio <engels@majcms.org> 1297798963 +0800
committer Engels Antonio <engels@majcms.org> 1297798963 +0800
Fix file attach sort and display
diff --git a/read.php b/read.php
index 0be4a2e..23a90a3 100644
--- a/read.php
+++ b/read.php
@@ -244,7 +244,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
echo "</div>";
-
+/*
foreach ($attachDisplay as $attachD => $attachE) {
if (strtolower($attachE) == "utf-8") {
@@ -259,26 +259,19 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
unset($attachDisplay[$attachD]);
}
}
-
- sort($attachDisplay);
+*/
reset($attachDisplay);
-
+
if (sizeof($attachDisplay) > 0) {
$filePath = "attachments/" . sha1($_SERVER['SERVER_NAME']) ."/" . sha1($header->subject);
- echo "<div class=\"spacer\"></div>";
-
- echo "<div class=\"message\" style=\"position: relative;\">";
-
-
- echo "<div style=\"position: absolute; top: -15; right: -15;\"><img src=\"images/attach.png\" border=\"0\" width=\"48\" height=\"48\"></div>";
-
- echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\">";
+ $fileAttachments = "";
for ($j=0;$j<sizeof($attachDisplay);$j++) {
- if (($dataHtml != "") and (strtolower($attachDisplay[$j]) != "utf-8") and (strtolower($attachDisplay[$j]) != "windows-1252")) {
+ if ($dataHtml != "") {
+
$file = $j;
$fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$file+2));
$fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$attachDisplay[$j]);
@@ -292,13 +285,32 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
$fileSize = filesize("$filePath/$fileName");
- $fileSize = HumanReadableFilesize($fileSize);
- echo "<tr><td><a href=\"$filePath/$fileName\"><img src=\"images/file.png\" border=\"0\" width=\"36\" height=\"36\"></a></td><td><a href=\"$fileName\">$fileName</a><br>$fileSize</td></tr>";
+
+ if ($fileSize > 0) {
+ $fileSize = HumanReadableFilesize($fileSize);
+ $fileAttachments = $fileAttachments . "\r\n<tr><td><a href=\"$filePath/$fileName\"><img src=\"images/file.png\" border=\"0\" width=\"36\" height=\"36\"></a></td><td><a href=\"$fileName\">$fileName</a><br>$fileSize</td></tr>\r\n";
+ }
+ else {
+ unlink("$filePath/$fileName");
+ }
}
}
- echo "</table>";
- echo "</div>";
+ if ($fileAttachments != "") {
+
+ echo "<div class=\"spacer\"></div>";
+
+ echo "<div class=\"message\" style=\"position: relative;\">";
+
+ echo "<div style=\"position: absolute; top: -15; right: -15;\"><img src=\"images/attach.png\" border=\"0\" width=\"48\" height=\"48\"></div>";
+
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\">";
+
+ echo "$fileAttachments";
+
+ echo "</table>";
+ echo "</div>";
+ }
}
echo "</td></tr></table>";