1<?php
2    /*
3     * $Id: index.php 1470 2010-03-07 19:09:18Z dmorton $
4     *
5     * MAIA MAILGUARD LICENSE v.1.0
6     *
7     * Copyright 2004 by Robert LeBlanc <rjl@renaissoft.com>
8     *                   David Morton   <mortonda@dgrmm.net>
9     * All rights reserved.
10     *
11     * PREAMBLE
12     *
13     * This License is designed for users of Maia Mailguard
14     * ("the Software") who wish to support the Maia Mailguard project by
15     * leaving "Maia Mailguard" branding information in the HTML output
16     * of the pages generated by the Software, and providing links back
17     * to the Maia Mailguard home page.  Users who wish to remove this
18     * branding information should contact the copyright owner to obtain
19     * a Rebranding License.
20     *
21     * DEFINITION OF TERMS
22     *
23     * The "Software" refers to Maia Mailguard, including all of the
24     * associated PHP, Perl, and SQL scripts, documentation files, graphic
25     * icons and logo images.
26     *
27     * GRANT OF LICENSE
28     *
29     * Redistribution and use in source and binary forms, with or without
30     * modification, are permitted provided that the following conditions
31     * are met:
32     *
33     * 1. Redistributions of source code must retain the above copyright
34     *    notice, this list of conditions and the following disclaimer.
35     *
36     * 2. Redistributions in binary form must reproduce the above copyright
37     *    notice, this list of conditions and the following disclaimer in the
38     *    documentation and/or other materials provided with the distribution.
39     *
40     * 3. The end-user documentation included with the redistribution, if
41     *    any, must include the following acknowledgment:
42     *
43     *    "This product includes software developed by Robert LeBlanc
44     *    <rjl@renaissoft.com>."
45     *
46     *    Alternately, this acknowledgment may appear in the software itself,
47     *    if and wherever such third-party acknowledgments normally appear.
48     *
49     * 4. At least one of the following branding conventions must be used:
50     *
51     *    a. The Maia Mailguard logo appears in the page-top banner of
52     *       all HTML output pages in an unmodified form, and links
53     *       directly to the Maia Mailguard home page; or
54     *
55     *    b. The "Powered by Maia Mailguard" graphic appears in the HTML
56     *       output of all gateway pages that lead to this software,
57     *       linking directly to the Maia Mailguard home page; or
58     *
59     *    c. A separate Rebranding License is obtained from the copyright
60     *       owner, exempting the Licensee from 4(a) and 4(b), subject to
61     *       the additional conditions laid out in that license document.
62     *
63     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
64     * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
65     * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
66     * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
67     * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
68     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
69     * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
70     * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
71     * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
72     * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
73     * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74     *
75     */
76
77   require_once ("core.php");
78   require_once ("authcheck.php");
79   require_once ("maia_db.php");
80
81   // Test to see whether the user's browser accepts cookies or not,
82   // based on whether the session cookie can be read.  If not,
83   // we'll use the session id provided from the GET header.
84   if (isset($_COOKIE[session_name()])) {
85      $_SESSION["cookies"] = 1;
86      $sid = "";
87      $msid = "?";
88   } else {
89      $_SESSION["cookies"] = 0;
90      $sid = '?' . session_name() . '=' . session_id();
91      $msid = $sid . '&';
92   }
93   if (isset($_GET["action"])) {
94      parse_str($_SERVER["QUERY_STRING"],$url_params);
95      unset($url_params[session_name()]);
96      unset($url_params['action']);
97
98      header("Location: " . $_GET["action"] . $msid . http_build_query($url_params));
99   } else {
100      header("Location: welcome.php" . $sid);
101   }
102   exit();
103?>
104