59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * folders_subscribe.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Subscribe and unsubcribe form folders. |
10 | * Called from folders.php |
11 | * |
12 | * $Id$ |
13 | */ |
ef870322 |
14 | |
86725763 |
15 | /* Path for SquirrelMail required files. */ |
16 | define('SM_PATH','../'); |
17 | |
18 | /* SquirrelMail required files. */ |
08185f2a |
19 | require_once(SM_PATH . 'include/validate.php'); |
86725763 |
20 | require_once(SM_PATH . 'functions/imap.php'); |
21 | require_once(SM_PATH . 'functions/display_messages.php'); |
11353192 |
22 | |
32f4e318 |
23 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
11353192 |
24 | |
32f4e318 |
25 | $location = get_location(); |
52ed2f88 |
26 | |
27 | if (!isset($mailbox) || !isset($mailbox[0]) || $mailbox[0] == "") { |
28 | header("Location: $location/folders.php"); |
29 | sqimap_logout($imapConnection); |
30 | exit(0); |
31 | } |
32 | |
32f4e318 |
33 | if ($method == 'sub') { |
52ed2f88 |
34 | if($no_list_for_subscribe && $imap_server_type == 'cyrus') { |
35 | /* Cyrus, atleast, does not typically allow subscription to |
36 | * nonexistent folders (this is an optional part of IMAP), |
37 | * lets catch it here and report back cleanly. */ |
38 | if(!sqimap_mailbox_exists($imapConnection, $mailbox[0])) { |
39 | header("Location: $location/folders.php?success=subscribe-doesnotexist"); |
40 | sqimap_logout($imapConnection); |
41 | exit(0); |
42 | } |
43 | } |
44 | |
32f4e318 |
45 | for ($i=0; $i < count($mailbox); $i++) { |
46 | $mailbox[$i] = trim($mailbox[$i]); |
47 | sqimap_subscribe ($imapConnection, $mailbox[$i]); |
48 | header("Location: $location/folders.php?success=subscribe"); |
49 | } |
50 | } else { |
51 | for ($i=0; $i < count($mailbox); $i++) { |
52 | $mailbox[$i] = trim($mailbox[$i]); |
53 | sqimap_unsubscribe ($imapConnection, $mailbox[$i]); |
54 | header("Location: $location/folders.php?success=unsubscribe"); |
55 | } |
56 | } |
32f4e318 |
57 | sqimap_logout($imapConnection); |
11353192 |
58 | |
32f4e318 |
59 | /* |
60 | displayPageHeader($color, 'None'); |
61 | echo "<BR><BR><BR><CENTER><B>"; |
62 | if ($method == "sub") { |
63 | echo _("Subscribed Successfully!"); |
64 | echo "</B><BR><BR>"; |
65 | echo _("You have been successfully subscribed."); |
66 | } else { |
67 | echo _("Unsubscribed Successfully!"); |
68 | echo "</B><BR><BR>"; |
69 | echo _("You have been successfully unsubscribed."); |
70 | } |
71 | echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>"; |
72 | echo _("Click here"); |
73 | echo "</A> "; |
74 | echo _("to continue."); |
75 | echo "</CENTER>"; |
76 | echo "</BODY></HTML>"; |
77 | */ |
f1177e37 |
78 | ?> |