This commit has been accessed 660 times via Git panel.
commit 275d2912066e03ef94c70e73cb5f8889a02684bc
tree 641dc0525be392ba5601b9f1f0433794c08566e8
parent f00c88a11778035390311e9e09fc1a5b9e4e12c5
author Engels Antonio <engels@majcms.org> 1317391564 +0800
committer Engels Antonio <engels@majcms.org> 1317391564 +0800
Add auto-cleanup of incoming file attach folders
diff --git a/folders.php b/folders.php
index 799ac24..f1e822d 100644
--- a/folders.php
+++ b/folders.php
@@ -13,6 +13,7 @@ $mbox = imap_open($conn, $_SESSION['logged_uid'], $_SESSION['logged_key'], OP_HA
echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
echo "<form method=\"post\">";
+echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"new\" value=\"1\">";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-new.png\"></td><td>Compose</td></tr>";
echo "</form>";
@@ -23,6 +24,7 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
if ($mbox_prev >= 0) {
echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_prev\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
@@ -45,6 +47,7 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
}
echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_next\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
@@ -66,6 +69,7 @@ if ($_POST['box'] == "Trash") {
if ($trash_status->messages > 0) {
echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"emt\" value=\"1\">";
echo "<input type=\"hidden\" name=\"box\" value=\"Trash\">";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/trashcan_purge.png\"></td><td><nobr>Empty Trash</nobr></td></tr>";
@@ -80,6 +84,7 @@ echo "<div style=\"height: 4px;\"></div>";
echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"0\" callpadding=\"0\">";
echo "<form method=\"post\">";
+echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"dig\" value=\"1\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-search.png\"></td><td>Search</td></tr>";
@@ -115,6 +120,8 @@ if (is_array($folders)) {
echo "<tr><form method=\"post\"><td align=\"center\"><input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
+
if ((!isset($_POST['box']) and ($folder == "INBOX")) or (isset($_POST['box']) and ($_POST['box'] == $folder))) {
echo "<input type=\"image\" src=\"images/folder-open.png\"></td></form>";
echo "<td><nobr><b>$folder</b> $status_folder</nobr></td></tr>";
diff --git a/index.php b/index.php
index 860bcb6..0170b78 100644
--- a/index.php
+++ b/index.php
@@ -191,6 +191,12 @@ if (isset($_SESSION['logged_uid'])) {
echo "<tr><td colspan=\"3\" valign=\"top\">";
if ($_SESSION['logged_lvl'] == "subscriber") {
+
+ $fileUsr = sha1($_SESSION['logged_uid']);
+
+ if (isset($_POST['fdir']) and file_exists("attach/$fileUsr/{$_POST['fdir']}")) {
+ rmdirr("attach/$fileUsr/{$_POST['fdir']}");
+ }
$usr_query = mysql_query("select * from users where id='{$_SESSION['logged_uid']}'");
$usr_data = mysql_fetch_row($usr_query);
diff --git a/read.php b/read.php
index a6c361b..41bc949 100644
--- a/read.php
+++ b/read.php
@@ -106,16 +106,17 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
echo "</div>";
-
echo "<div class=\"spacer\"></div>";
-
+
+ $fileDir = sha1(microtime(true));
echo "<div class=\"message\" style=\"padding: 2px;\">";
echo "<table border=\"0\" cellspacing=\"0\" cellpadidng=\"0\" width=\"100%\"><tr>";
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
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\">";
@@ -139,6 +140,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<td></td>";
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
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\">";
@@ -155,6 +157,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<td width=\"5\"></td>";
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
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\">";
@@ -173,6 +176,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
if (strpos($header->toaddress,",")) {
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
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\">";
@@ -190,6 +194,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
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\">";
@@ -207,6 +212,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
if ($msgno_next != "") {
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno_next\">";
echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
@@ -224,6 +230,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
if ($msgno_prev != "") {
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno_prev\">";
echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
@@ -300,8 +307,10 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$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);
+ //$filePath = $_SERVER['SERVER_NAME'] . $do_fromaddress[0] . $do_toaddress[0] . $header_subject . microtime(true);
+ //$filePath = "attach/" . sha1($filePath);
+
+ $filePath = "attach/$fileUsr/$fileDir";
$struct = imap_fetchstructure($mbox, $msgno);
tree 641dc0525be392ba5601b9f1f0433794c08566e8
parent f00c88a11778035390311e9e09fc1a5b9e4e12c5
author Engels Antonio <engels@majcms.org> 1317391564 +0800
committer Engels Antonio <engels@majcms.org> 1317391564 +0800
Add auto-cleanup of incoming file attach folders
diff --git a/folders.php b/folders.php
index 799ac24..f1e822d 100644
--- a/folders.php
+++ b/folders.php
@@ -13,6 +13,7 @@ $mbox = imap_open($conn, $_SESSION['logged_uid'], $_SESSION['logged_key'], OP_HA
echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
echo "<form method=\"post\">";
+echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"new\" value=\"1\">";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-new.png\"></td><td>Compose</td></tr>";
echo "</form>";
@@ -23,6 +24,7 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
if ($mbox_prev >= 0) {
echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_prev\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
@@ -45,6 +47,7 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
}
echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_next\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
@@ -66,6 +69,7 @@ if ($_POST['box'] == "Trash") {
if ($trash_status->messages > 0) {
echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"emt\" value=\"1\">";
echo "<input type=\"hidden\" name=\"box\" value=\"Trash\">";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/trashcan_purge.png\"></td><td><nobr>Empty Trash</nobr></td></tr>";
@@ -80,6 +84,7 @@ echo "<div style=\"height: 4px;\"></div>";
echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"0\" callpadding=\"0\">";
echo "<form method=\"post\">";
+echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"dig\" value=\"1\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-search.png\"></td><td>Search</td></tr>";
@@ -115,6 +120,8 @@ if (is_array($folders)) {
echo "<tr><form method=\"post\"><td align=\"center\"><input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
+
if ((!isset($_POST['box']) and ($folder == "INBOX")) or (isset($_POST['box']) and ($_POST['box'] == $folder))) {
echo "<input type=\"image\" src=\"images/folder-open.png\"></td></form>";
echo "<td><nobr><b>$folder</b> $status_folder</nobr></td></tr>";
diff --git a/index.php b/index.php
index 860bcb6..0170b78 100644
--- a/index.php
+++ b/index.php
@@ -191,6 +191,12 @@ if (isset($_SESSION['logged_uid'])) {
echo "<tr><td colspan=\"3\" valign=\"top\">";
if ($_SESSION['logged_lvl'] == "subscriber") {
+
+ $fileUsr = sha1($_SESSION['logged_uid']);
+
+ if (isset($_POST['fdir']) and file_exists("attach/$fileUsr/{$_POST['fdir']}")) {
+ rmdirr("attach/$fileUsr/{$_POST['fdir']}");
+ }
$usr_query = mysql_query("select * from users where id='{$_SESSION['logged_uid']}'");
$usr_data = mysql_fetch_row($usr_query);
diff --git a/read.php b/read.php
index a6c361b..41bc949 100644
--- a/read.php
+++ b/read.php
@@ -106,16 +106,17 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
echo "</div>";
-
echo "<div class=\"spacer\"></div>";
-
+
+ $fileDir = sha1(microtime(true));
echo "<div class=\"message\" style=\"padding: 2px;\">";
echo "<table border=\"0\" cellspacing=\"0\" cellpadidng=\"0\" width=\"100%\"><tr>";
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
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\">";
@@ -139,6 +140,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<td></td>";
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
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\">";
@@ -155,6 +157,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<td width=\"5\"></td>";
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
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\">";
@@ -173,6 +176,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
if (strpos($header->toaddress,",")) {
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
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\">";
@@ -190,6 +194,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
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\">";
@@ -207,6 +212,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
if ($msgno_next != "") {
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno_next\">";
echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
@@ -224,6 +230,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
if ($msgno_prev != "") {
echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"fdir\" value=\"$fileDir\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno_prev\">";
echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
@@ -300,8 +307,10 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$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);
+ //$filePath = $_SERVER['SERVER_NAME'] . $do_fromaddress[0] . $do_toaddress[0] . $header_subject . microtime(true);
+ //$filePath = "attach/" . sha1($filePath);
+
+ $filePath = "attach/$fileUsr/$fileDir";
$struct = imap_fetchstructure($mbox, $msgno);