| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * folders_subscribe.php |
| 5 | * |
| 6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
| 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 | */ |
| 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/imap.php'); |
| 21 | require_once(SM_PATH . 'functions/display_messages.php'); |
| 22 | |
| 23 | /* globals */ |
| 24 | $username = $_SESSION['username']; |
| 25 | $key = $_COOKIE['key']; |
| 26 | $onetimepad = $_SESSION['onetimepad']; |
| 27 | |
| 28 | $method = $_GET['method']; |
| 29 | $mailbox = $_POST['mailbox']; |
| 30 | |
| 31 | /* end globals */ |
| 32 | |
| 33 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
| 34 | |
| 35 | $location = get_location(); |
| 36 | |
| 37 | if (!isset($mailbox) || !isset($mailbox[0]) || $mailbox[0] == "") { |
| 38 | header("Location: $location/folders.php"); |
| 39 | sqimap_logout($imapConnection); |
| 40 | exit(0); |
| 41 | } |
| 42 | |
| 43 | if ($method == 'sub') { |
| 44 | if($no_list_for_subscribe && $imap_server_type == 'cyrus') { |
| 45 | /* Cyrus, atleast, does not typically allow subscription to |
| 46 | * nonexistent folders (this is an optional part of IMAP), |
| 47 | * lets catch it here and report back cleanly. */ |
| 48 | if(!sqimap_mailbox_exists($imapConnection, $mailbox[0])) { |
| 49 | header("Location: $location/folders.php?success=subscribe-doesnotexist"); |
| 50 | sqimap_logout($imapConnection); |
| 51 | exit(0); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | for ($i=0; $i < count($mailbox); $i++) { |
| 56 | $mailbox[$i] = trim($mailbox[$i]); |
| 57 | sqimap_subscribe ($imapConnection, $mailbox[$i]); |
| 58 | header("Location: $location/folders.php?success=subscribe"); |
| 59 | } |
| 60 | } else { |
| 61 | for ($i=0; $i < count($mailbox); $i++) { |
| 62 | $mailbox[$i] = trim($mailbox[$i]); |
| 63 | sqimap_unsubscribe ($imapConnection, $mailbox[$i]); |
| 64 | header("Location: $location/folders.php?success=unsubscribe"); |
| 65 | } |
| 66 | } |
| 67 | sqimap_logout($imapConnection); |
| 68 | |
| 69 | /* |
| 70 | displayPageHeader($color, 'None'); |
| 71 | echo "<BR><BR><BR><CENTER><B>"; |
| 72 | if ($method == "sub") { |
| 73 | echo _("Subscribed Successfully!"); |
| 74 | echo "</B><BR><BR>"; |
| 75 | echo _("You have been successfully subscribed."); |
| 76 | } else { |
| 77 | echo _("Unsubscribed Successfully!"); |
| 78 | echo "</B><BR><BR>"; |
| 79 | echo _("You have been successfully unsubscribed."); |
| 80 | } |
| 81 | echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>"; |
| 82 | echo _("Click here"); |
| 83 | echo "</A> "; |
| 84 | echo _("to continue."); |
| 85 | echo "</CENTER>"; |
| 86 | echo "</BODY></HTML>"; |
| 87 | */ |
| 88 | ?> |