Verify Reply To still has its uses
[squirrelmail.git] / src / empty_trash.php
1 <?php
2
3 /**
4 * empty_trash.php
5 *
6 * Handles deleting messages from the trash folder without
7 * deleting subfolders.
8 *
9 * @copyright 1999-2011 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @version $Id$
12 * @package squirrelmail
13 */
14
15 /** This is the empty_trash page */
16 define('PAGE_NAME', 'empty_trash');
17
18 /**
19 * Include the SquirrelMail initialization file.
20 */
21 require('../include/init.php');
22
23 require(SM_PATH . 'functions/imap_general.php');
24 require(SM_PATH . 'functions/imap_messages.php');
25 require(SM_PATH . 'functions/tree.php');
26
27 /* get those globals */
28
29 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
30
31 /* finished globals */
32
33 // first do a security check
34 sqgetGlobalVar('smtoken', $submitted_token, SQ_GET, '');
35 sm_validate_security_token($submitted_token, 3600, TRUE);
36
37 $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
38
39 $mailbox = $trash_folder;
40 $boxes = sqimap_mailbox_list($imap_stream);
41
42 /*
43 * According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
44 * so lets go through the list of subfolders and remove them before removing the
45 * parent.
46 */
47
48 /** First create the top node in the tree **/
49 $numboxes = count($boxes);
50 for ($i = 0; $i < $numboxes; $i++) {
51 if (($boxes[$i]['unformatted'] == $mailbox) && (strlen($boxes[$i]['unformatted']) == strlen($mailbox))) {
52 $foldersTree[0]['value'] = $mailbox;
53 $foldersTree[0]['doIHaveChildren'] = false;
54 continue;
55 }
56 }
57 /*
58 * Now create the nodes for subfolders of the parent folder
59 * You can tell that it is a subfolder by tacking the mailbox delimiter
60 * on the end of the $mailbox string, and compare to that.
61 */
62 $j = 0;
63 for ($i = 0; $i < $numboxes; $i++) {
64 if (substr($boxes[$i]['unformatted'], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) {
65 addChildNodeToTree($boxes[$i]['unformatted'], $boxes[$i]['unformatted-dm'], $foldersTree);
66 }
67 }
68
69 // now lets go through the tree and delete the folders
70 walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
71 // update mailbox cache
72 $mailboxes=sqimap_get_mailboxes($imap_stream,true,$show_only_subscribed_folders);
73 sqimap_logout($imap_stream);
74
75 // close session properly before redirecting
76 session_write_close();
77
78 $location = get_location();
79 header ("Location: $location/left_main.php");
80