This commit has been accessed 583 times via Git panel.
commit 4e13cccb839cbaa07368d84507fafc6a09c360ac
tree 09a2e7005530bd53812ade99b2ea5f6deb5db9ad
parent 275d2912066e03ef94c70e73cb5f8889a02684bc
author Engels Antonio <engels@majcms.org> 1317403343 +0800
committer Engels Antonio <engels@majcms.org> 1317403343 +0800
Use session for auto-cleanup of incoming file attach folders
diff --git a/folders.php b/folders.php
index f1e822d..799ac24 100644
--- a/folders.php
+++ b/folders.php
@@ -13,7 +13,6 @@ $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>";
@@ -24,7 +23,6 @@ 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\">";
@@ -47,7 +45,6 @@ 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\">";
@@ -69,7 +66,6 @@ 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>";
@@ -84,7 +80,6 @@ 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>";
@@ -120,8 +115,6 @@ 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 0170b78..e66608f 100644
--- a/index.php
+++ b/index.php
@@ -193,11 +193,12 @@ if (isset($_SESSION['logged_uid'])) {
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']}");
- }
+ if (isset($_SESSION['clean_up']) and file_exists("attach/$fileUsr/{$_SESSION['clean_up']}")) {
+ rmdirr("attach/$fileUsr/{$_SESSION['clean_up']}");
+ unset($_SESSION['clean_up']);
+ }
+
$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 41bc949..4c9a7bc 100644
--- a/read.php
+++ b/read.php
@@ -116,7 +116,6 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
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\">";
@@ -140,7 +139,6 @@ 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\">";
@@ -157,7 +155,6 @@ 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\">";
@@ -176,7 +173,6 @@ 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\">";
@@ -194,7 +190,6 @@ 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\">";
@@ -212,7 +207,6 @@ 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\">";
@@ -230,7 +224,6 @@ 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\">";
@@ -384,6 +377,8 @@ foreach ($struct->parts as $structP) {
echo "</table>";
echo "</div>";
+
+ $_SESSION['clean_up'] = $fileDir;
}
else {
rmdirr($filePath);
tree 09a2e7005530bd53812ade99b2ea5f6deb5db9ad
parent 275d2912066e03ef94c70e73cb5f8889a02684bc
author Engels Antonio <engels@majcms.org> 1317403343 +0800
committer Engels Antonio <engels@majcms.org> 1317403343 +0800
Use session for auto-cleanup of incoming file attach folders
diff --git a/folders.php b/folders.php
index f1e822d..799ac24 100644
--- a/folders.php
+++ b/folders.php
@@ -13,7 +13,6 @@ $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>";
@@ -24,7 +23,6 @@ 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\">";
@@ -47,7 +45,6 @@ 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\">";
@@ -69,7 +66,6 @@ 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>";
@@ -84,7 +80,6 @@ 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>";
@@ -120,8 +115,6 @@ 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 0170b78..e66608f 100644
--- a/index.php
+++ b/index.php
@@ -193,11 +193,12 @@ if (isset($_SESSION['logged_uid'])) {
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']}");
- }
+ if (isset($_SESSION['clean_up']) and file_exists("attach/$fileUsr/{$_SESSION['clean_up']}")) {
+ rmdirr("attach/$fileUsr/{$_SESSION['clean_up']}");
+ unset($_SESSION['clean_up']);
+ }
+
$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 41bc949..4c9a7bc 100644
--- a/read.php
+++ b/read.php
@@ -116,7 +116,6 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
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\">";
@@ -140,7 +139,6 @@ 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\">";
@@ -157,7 +155,6 @@ 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\">";
@@ -176,7 +173,6 @@ 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\">";
@@ -194,7 +190,6 @@ 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\">";
@@ -212,7 +207,6 @@ 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\">";
@@ -230,7 +224,6 @@ 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\">";
@@ -384,6 +377,8 @@ foreach ($struct->parts as $structP) {
echo "</table>";
echo "</div>";
+
+ $_SESSION['clean_up'] = $fileDir;
}
else {
rmdirr($filePath);