squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

empty_trash.php
Go to the documentation of this file.
1 <?php
2 
16 define('PAGE_NAME', 'empty_trash');
17 
22 define('SM_PATH','../');
23 
24 /* SquirrelMail required files. */
25 require_once(SM_PATH . 'include/validate.php');
26 require_once(SM_PATH . 'functions/display_messages.php');
27 require_once(SM_PATH . 'functions/imap.php');
28 require_once(SM_PATH . 'functions/tree.php');
29 
30 /* get those globals */
31 
32 sqgetGlobalVar('username', $username, SQ_SESSION);
33 sqgetGlobalVar('key', $key, SQ_COOKIE);
34 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
35 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
36 
37 /* finished globals */
38 
39 // first do a security check
40 if (!sqgetGlobalVar('smtoken',$submitted_token, SQ_FORM))
41  $submitted_token = '';
42 sm_validate_security_token($submitted_token, 3600, TRUE);
43 
45 
47 
50 
51 /*
52  * According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
53  * so lets go through the list of subfolders and remove them before removing the
54  * parent.
55  */
56 
58 $numboxes = count($boxes);
59 $foldersTree = array();
60 for ($i = 0; $i < $numboxes; $i++) {
61  if (($boxes[$i]['unformatted'] == $mailbox) && (strlen($boxes[$i]['unformatted']) == strlen($mailbox))) {
62  $foldersTree[0]['value'] = $mailbox;
63  $foldersTree[0]['doIHaveChildren'] = false;
64  continue;
65  }
66 }
67 /*
68  * Now create the nodes for subfolders of the parent folder
69  * You can tell that it is a subfolder by tacking the mailbox delimiter
70  * on the end of the $mailbox string, and compare to that.
71  */
72 $j = 0;
73 for ($i = 0; $i < $numboxes; $i++) {
74  if (substr($boxes[$i]['unformatted'], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) {
75  addChildNodeToTree($boxes[$i]['unformatted'], $boxes[$i]['unformatted-dm'], $foldersTree);
76  }
77 }
78 
79 // now lets go through the tree and delete the folders
82 
83 // close session properly before redirecting
84 session_write_close();
85 
87 // force_refresh = 1 in case trash contains deleted mailboxes
88 header ("Location: $location/left_main.php?force_refresh=1");
89 
sqgetGlobalVar
sqgetGlobalVar($name, &$value, $search=SQ_INORDER)
Definition: global.php:344
SM_PATH
const SM_PATH
Definition: empty_trash.php:22
$imapServerAddress
$imapServerAddress
Definition: config_default.php:202
sqimap_login
sqimap_login($username, $password, $imap_server_address, $imap_port, $hide)
Definition: imap_general.php:481
SQ_SESSION
const SQ_SESSION
Definition: global.php:18
$imap_stream
$imap_stream
Definition: empty_trash.php:44
$trash_folder
$trash_folder
Definition: config_default.php:394
$username
global $username
Definition: validate.php:55
walkTreeInPreOrderEmptyTrash
walkTreeInPreOrderEmptyTrash($index, $imap_stream, $tree)
Definition: tree.php:81
$mailbox
$mailbox
Definition: empty_trash.php:48
$boxes
$boxes
Definition: empty_trash.php:49
sm_validate_security_token
sm_validate_security_token($token, $validity_period=0, $show_error=FALSE)
Definition: strings.php:1405
sqimap_logout
sqimap_logout($imap_stream)
Definition: imap_general.php:639
$j
for($i=0; $i< $numboxes; $i++) $j
Definition: empty_trash.php:72
$imapPort
$imapPort
Definition: config_default.php:210
SQ_FORM
const SQ_FORM
Definition: global.php:21
addChildNodeToTree
addChildNodeToTree($comparisonValue, $value, &$tree)
Definition: tree.php:54
$numboxes
$numboxes
Definition: empty_trash.php:58
SQ_COOKIE
const SQ_COOKIE
Definition: global.php:19
get_location
get_location()
Definition: strings.php:340
$foldersTree
$foldersTree
Definition: empty_trash.php:59
sqimap_mailbox_list
sqimap_mailbox_list($imap_stream, $force=false)
Definition: imap_mailbox.php:597
$location
$location
Definition: empty_trash.php:86