59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * empty_trash.php |
5 | * |
35586184 |
6 | * Handles deleting messages from the trash folder without |
7 | * deleting subfolders. |
8 | * |
47ccfad4 |
9 | * @copyright © 1999-2006 The SquirrelMail Project Team |
4b4abf93 |
10 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
30967a1e |
11 | * @version $Id$ |
8f6f9ba5 |
12 | * @package squirrelmail |
35586184 |
13 | */ |
ef870322 |
14 | |
30967a1e |
15 | /** |
16 | * Path for SquirrelMail required files. |
17 | * @ignore |
18 | */ |
86725763 |
19 | define('SM_PATH','../'); |
20 | |
21 | /* SquirrelMail required files. */ |
08185f2a |
22 | require_once(SM_PATH . 'include/validate.php'); |
86725763 |
23 | require_once(SM_PATH . 'functions/display_messages.php'); |
24 | require_once(SM_PATH . 'functions/imap.php'); |
86725763 |
25 | require_once(SM_PATH . 'functions/tree.php'); |
d3cdb279 |
26 | |
a32985a5 |
27 | /* get those globals */ |
28 | |
f38b7cf0 |
29 | sqgetGlobalVar('username', $username, SQ_SESSION); |
30 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
31 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
32 | sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); |
a32985a5 |
33 | |
34 | /* finished globals */ |
35 | |
65c3ec94 |
36 | $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
37 | |
65c3ec94 |
38 | $mailbox = $trash_folder; |
39 | $boxes = sqimap_mailbox_list($imap_stream); |
d92b6f31 |
40 | |
65c3ec94 |
41 | /* |
42 | * According to RFC2060, a DELETE command should NOT remove inferiors (sub folders) |
43 | * so lets go through the list of subfolders and remove them before removing the |
44 | * parent. |
45 | */ |
46 | |
47 | /** First create the top node in the tree **/ |
c9acef51 |
48 | $numboxes = count($boxes); |
49 | for ($i = 0; $i < $numboxes; $i++) { |
50 | if (($boxes[$i]['unformatted'] == $mailbox) && (strlen($boxes[$i]['unformatted']) == strlen($mailbox))) { |
51 | $foldersTree[0]['value'] = $mailbox; |
52 | $foldersTree[0]['doIHaveChildren'] = false; |
65c3ec94 |
53 | continue; |
54 | } |
55 | } |
56 | /* |
57 | * Now create the nodes for subfolders of the parent folder |
58 | * You can tell that it is a subfolder by tacking the mailbox delimiter |
59 | * on the end of the $mailbox string, and compare to that. |
60 | */ |
61 | $j = 0; |
c9acef51 |
62 | for ($i = 0; $i < $numboxes; $i++) { |
63 | if (substr($boxes[$i]['unformatted'], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) { |
64 | addChildNodeToTree($boxes[$i]['unformatted'], $boxes[$i]['unformatted-dm'], $foldersTree); |
65c3ec94 |
65 | } |
66 | } |
0a1d5f3a |
67 | |
65c3ec94 |
68 | // now lets go through the tree and delete the folders |
69 | walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree); |
a1eb6f89 |
70 | sqimap_logout($imap_stream); |
71 | |
72 | // close session properly before redirecting |
73 | session_write_close(); |
a11899fd |
74 | |
65c3ec94 |
75 | $location = get_location(); |
dcc1cc82 |
76 | header ("Location: $location/left_main.php"); |
e9f8ea4e |
77 | |
f8a1ed5a |
78 | ?> |