Source for file folders_subscribe.php

Documentation is available at folders_subscribe.php

  1. <?php
  2.  
  3. /**
  4.  * folders_subscribe.php
  5.  *
  6.  * Subscribe and unsubcribe from folders.
  7.  * Called from folders.php
  8.  *
  9.  * @copyright 1999-2014 The SquirrelMail Project Team
  10.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11.  * @version $Id: folders_subscribe.php 14436 2014-01-21 21:30:59Z pdontthink $
  12.  * @package squirrelmail
  13.  */
  14.  
  15. /** This is the folders_subscribe page */
  16. define('PAGE_NAME''folders_subscribe');
  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/global.php');
  27. require_once(SM_PATH 'functions/imap.php');
  28. require_once(SM_PATH 'functions/display_messages.php');
  29.  
  30. /* globals */
  31. sqgetGlobalVar('key',       $key,           SQ_COOKIE);
  32. sqgetGlobalVar('username',  $username,      SQ_SESSION);
  33. sqgetGlobalVar('onetimepad',$onetimepad,    SQ_SESSION);
  34. sqgetGlobalVar('method',    $method,        SQ_GET);
  35. sqgetGlobalVar('mailbox',   $mailbox,       SQ_POST);
  36. if (!sqgetGlobalVar('smtoken',$submitted_tokenSQ_POST)) {
  37.     $submitted_token '';
  38. }
  39. /* end globals */
  40.  
  41. // first, validate security token
  42. sm_validate_security_token($submitted_token-1TRUE);
  43.  
  44. $location get_location();
  45.  
  46. if (!isset($mailbox|| !isset($mailbox[0]|| $mailbox[0== ''{
  47.     header("Location: $location/folders.php");
  48.  
  49.     exit(0);
  50. }
  51.  
  52. global $imap_stream_options// in case not defined in config
  53. $imapConnection sqimap_login($username$key$imapServerAddress$imapPort0$imap_stream_options);
  54.  
  55. if ($method == 'sub'{
  56.     if($no_list_for_subscribe && $imap_server_type == 'cyrus'{
  57.        /* Cyrus, atleast, does not typically allow subscription to
  58.         * nonexistent folders (this is an optional part of IMAP),
  59.         * lets catch it here and report back cleanly. */
  60.        if(!sqimap_mailbox_exists($imapConnection$mailbox[0])) {
  61.           header("Location: $location/folders.php?success=subscribe-doesnotexist");
  62.           sqimap_logout($imapConnection);
  63.           exit(0);
  64.        }
  65.     }
  66.     for ($i=0$i count($mailbox)$i++{
  67.         $mailbox[$itrim($mailbox[$i]);
  68.         sqimap_subscribe ($imapConnection$mailbox[$i]);
  69.     }
  70.     $success 'subscribe';
  71. else {
  72.     for ($i=0$i count($mailbox)$i++{
  73.         $mailbox[$itrim($mailbox[$i]);
  74.         sqimap_unsubscribe ($imapConnection$mailbox[$i]);
  75.     }
  76.     $success 'unsubscribe';
  77. }
  78.  
  79. sqimap_logout($imapConnection);
  80. header("Location: $location/folders.php?success=$success");

Documentation generated on Thu, 31 Jul 2014 04:20:55 +0200 by phpDocumentor 1.4.3