DO NOT buffer base64 encoded attachments before we decode them. Instead
[squirrelmail.git] / src / folders_subscribe.php
1 <?php
2
3 /**
4 * folders_subscribe.php
5 *
6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Subscribe and unsubcribe from folders.
10 * Called from folders.php
11 *
12 * $Id$
13 */
14
15 /* Path for SquirrelMail required files. */
16 define('SM_PATH','../');
17
18 /* SquirrelMail required files. */
19 require_once(SM_PATH . 'include/validate.php');
20 require_once(SM_PATH . 'functions/global.php');
21 require_once(SM_PATH . 'functions/imap.php');
22 require_once(SM_PATH . 'functions/display_messages.php');
23
24 /* globals */
25 sqgetGlobalVar('key', $key, SQ_COOKIE);
26 sqgetGlobalVar('username', $username, SQ_SESSION);
27 sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION);
28 sqgetGlobalVar('method', $method, SQ_GET);
29 sqgetGlobalVar('mailbox', $mailbox, SQ_POST);
30 /* end globals */
31
32 $location = get_location();
33
34 if (!isset($mailbox) || !isset($mailbox[0]) || $mailbox[0] == '') {
35 header("Location: $location/folders.php");
36
37 exit(0);
38 }
39
40 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
41
42 if ($method == 'sub') {
43 if($no_list_for_subscribe && $imap_server_type == 'cyrus') {
44 /* Cyrus, atleast, does not typically allow subscription to
45 * nonexistent folders (this is an optional part of IMAP),
46 * lets catch it here and report back cleanly. */
47 if(!sqimap_mailbox_exists($imapConnection, $mailbox[0])) {
48 header("Location: $location/folders.php?success=subscribe-doesnotexist");
49 sqimap_logout($imapConnection);
50 exit(0);
51 }
52 }
53 for ($i=0; $i < count($mailbox); $i++) {
54 $mailbox[$i] = trim($mailbox[$i]);
55 sqimap_subscribe ($imapConnection, $mailbox[$i]);
56 }
57 $success = 'subscribe';
58 } else {
59 for ($i=0; $i < count($mailbox); $i++) {
60 $mailbox[$i] = trim($mailbox[$i]);
61 sqimap_unsubscribe ($imapConnection, $mailbox[$i]);
62 }
63 $success = 'unsubscribe';
64 }
65
66 sqimap_logout($imapConnection);
67 header("Location: $location/folders.php?success=$success");
68
69 ?>