Source for file empty_trash.php

Documentation is available at 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-2012 The SquirrelMail Project Team
  10.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11.  * @version $Id: empty_trash.php 14248 2012-01-02 00:18:17Z pdontthink $
  12.  * @package squirrelmail
  13.  */
  14.  
  15. /** This is the empty_trash page */
  16. define('PAGE_NAME''empty_trash');
  17.  
  18. /**
  19.  * Path for SquirrelMail required files.
  20.  * @ignore
  21.  */
  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'$usernameSQ_SESSION);
  33. sqgetGlobalVar('key'$keySQ_COOKIE);
  34. sqgetGlobalVar('delimiter'$delimiterSQ_SESSION);
  35. sqgetGlobalVar('onetimepad'$onetimepadSQ_SESSION);
  36.  
  37. /* finished globals */
  38.  
  39. // first do a security check
  40. if (!sqgetGlobalVar('smtoken',$submitted_tokenSQ_FORM))
  41.     $submitted_token '';
  42. sm_validate_security_token($submitted_token3600TRUE);
  43.  
  44. $imap_stream sqimap_login($username$key$imapServerAddress$imapPort0);
  45.  
  46. sqimap_mailbox_list($imap_stream);
  47.  
  48. $mailbox $trash_folder;
  49. $boxes sqimap_mailbox_list($imap_stream);
  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.  
  57. /** First create the top node in the tree **/
  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']0strlen($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
  80. walkTreeInPreOrderEmptyTrash(0$imap_stream$foldersTree);
  81. sqimap_logout($imap_stream);
  82.  
  83. // close session properly before redirecting
  84.  
  85. $location get_location();
  86. // force_refresh = 1 in case trash contains deleted mailboxes
  87. header ("Location: $location/left_main.php?force_refresh=1");

Documentation generated on Wed, 19 Jun 2013 04:22:05 +0200 by phpDocumentor 1.4.3