Added windows-1253 and utf-8 decoding
[squirrelmail.git] / src / folders_subscribe.php
... / ...
CommitLineData
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. */
16define('SM_PATH','../');
17
18/* SquirrelMail required files. */
19require_once(SM_PATH . 'include/validate.php');
20require_once(SM_PATH . 'functions/imap.php');
21require_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$location = get_location();
34
35if (!isset($mailbox) || !isset($mailbox[0]) || $mailbox[0] == '') {
36 header("Location: $location/folders.php");
37
38 exit(0);
39}
40
41$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
42
43if ($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 for ($i=0; $i < count($mailbox); $i++) {
55 $mailbox[$i] = trim($mailbox[$i]);
56 sqimap_subscribe ($imapConnection, $mailbox[$i]);
57 }
58 $success = 'subscribe';
59} else {
60 for ($i=0; $i < count($mailbox); $i++) {
61 $mailbox[$i] = trim($mailbox[$i]);
62 sqimap_unsubscribe ($imapConnection, $mailbox[$i]);
63 }
64 $success = 'unsubscribe';
65}
66
67sqimap_logout($imapConnection);
68header("Location: $location/folders.php?success=$success");
69
70?>