phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] old/squirrelmail COPYING, 1.1 AUTHORS, 1.1 README, 1


From: skwashd
Subject: [Phpgroupware-cvs] old/squirrelmail COPYING, 1.1 AUTHORS, 1.1 README, 1.1 compose.php, 1.1 folders_create.php, 1.1 folders.php, 1.1 download.php, 1.1 folders_delete.php, 1.1 folders_rename_do.php, 1.1 search.php, 1.1 read_body.php, 1.1 preferences_translate.php, 1.1 index.php, 1.1 folders_subscribe.php, 1.1 folders_rename_getname.php, 1.1 preferences_display.php, 1.1 preferences_email.php, 1.1 preferences_index_order.php, 1.1 preferences_highlight.php, 1.1 preferences_folder.php, 1.1
Date: Thu, 5 May 2005 02:56:00 +0200

Update of old/squirrelmail

Added Files:
     Branch: MAIN
            COPYING 
            AUTHORS 
            README 
            compose.php 
            folders_create.php 
            folders.php 
            download.php 
            folders_delete.php 
            folders_rename_do.php 
            search.php 
            read_body.php 
            preferences_translate.php 
            index.php 
            folders_subscribe.php 
            folders_rename_getname.php 
            preferences_display.php 
            preferences_email.php 
            preferences_index_order.php 
            preferences_highlight.php 
            preferences_folder.php 

Log Message:
cvs clean up

====================================================
Index: COPYING
                    GNU GENERAL PUBLIC LICENSE
                       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
                          675 Mass Ave, Cambridge, MA 02139, USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

                    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

                            NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

                     END OF TERMS AND CONDITIONS

====================================================
Index: AUTHORS
 Developers:
 -----------
   Luke Ehresman <address@hidden>     http://www.css.tayloru.edu/~lehresma
   Nathan Ehresman <address@hidden> http://www.css.tayloru.edu/~nehresma
   Gustav Foseid <address@hidden>  http://www.initio.no
   Pål Løberg <address@hidden>       http://www.initio.no
   Shane Wilson
   Steve Gare                                http://www.xantara.co.uk
   Gerrit Padgham <address@hidden>
   Matt Phillips <address@hidden>
   Lewis Bergman
   Bryan Stalcup <address@hidden>
   Tyler Akins

 Translations:
 -------------
   Norwegian:    Gustav Foseid <address@hidden>
   German:       Chris Thil <address@hidden>
   Russian:      Konstantin Riabitsev <address@hidden>
   Polish:       Lukasz Klimek <address@hidden>
   Swedish:      Tobias Ekbom <address@hidden>
   Dutch:        Arjen Halma <address@hidden>
   Portuguese (Brazil): Henrique Moura <address@hidden>
   French        Ali Nedjimi <address@hidden>
   Italian       Aldo Moresco <address@hidden>
   Spanish       Hernan Collazo <address@hidden>
   Korean        Jong-II Kim <address@hidden>
   Czech         Ondrej Sury <address@hidden>
   Catalan       Josep Sanz <address@hidden>
   Serbian       Boris Manojlovic <address@hidden>
   Taiwan        Ching <address@hidden>
   Danish        Claus Rasmussen <address@hidden>
   Finnish       Teemu Junnila <address@hidden>

 Significant Contributions:
 --------------------------
   i18n support:        Sergiusz Pawlowicz
   SquirrelMail logo:   Libor Kopecky <address@hidden>
   Web Site Admin/PR:   Paul Joseph Thompson <address@hidden>
   FAQ Maintenance:     Peter Hutnick <address@hidden>

   Code contributions:  Konstantin Riabitsev <address@hidden>
                        Alex Bleeker <address@hidden>
                        Jan-Pieter Cornet <address@hidden>
                        John Williams <address@hidden>
                        Ondrej Sury <address@hidden>
                        Damien Sandras <address@hidden>
                        Martin Jespersen <address@hidden>
                        David Whittington <address@hidden>
                        Many others...

(We have tried to keep this up to date to give credit where it is due.
If you feel that you have wrongfully been left off this list, contact
address@hidden)

====================================================
Index: README
SquirrelMail
http://www.squirrelmail.org

Introduction:
-------------
SquirrelMail is a standards-based webmail package written in PHP4. It
includes built-in pure PHP support for the IMAP and SMTP protocols, and all
pages render in pure HTML 4.0 (with no Javascript) for maximum compatibility
across browsers. It has very few requirements and is very easy to configure
and install. SquirrelMail has a all the functionality you would want from an
email client, including strong MIME support, address books, and folder
manipulation.

Why did you guys create SquirrelMail?  The need arose in our organization
for the access of email and address books from anywhere in the world.
Obviously a web interface is ideal for this, given that the user has access
to the Internet.  After reviewing several open source projects, we realized
that we were going to need to do some fairly major customizations to get
things to be a nice fit for our needs.  So the decision was made to create
our own for some of these reasons, and for fun (we really like PHP4).  We
decided to open source the project to contribute to the community that has
contributed so much to us.  Since then, it has grown much bigger than we
ever imagined, and we have an awesome development team who are actively
working on the project.

We would love to hear from you!  The nature of open source projects make it
hard to know who all is using your product.  It is always nice when we get
emails from people just telling us that they're using SquirrelMail.  If you
have a few minutes, please send us an email to let us know!  You can send it
to our mailing list:  address@hidden

You can also go to the page below and fill out a small form to get listed
with the list of people already using SquirrelMail (free advertising).

   http://www.squirrelmail.org/index.php3?page=16

Contact:
--------
It is pretty easy to get in contact with the developers if you need help or
if you find bugs that need to be reported.  The best way to contact us would
be through our mailing list which is actively monitored.  Just send an email
to:

   address@hidden

If you wish to actually subscribe to our mailing list, please visit our web
page for instructions (http://www.squirrelmail.org) and go to the section
titled "Mailing List".

Installation:
-------------
For detailed instructions on how to install SquirrelMail on your server,
please refer to the INSTALL document in the same directory as this document.

Licensing:
----------
This product is distributed under the GPL.  Please read through the file
COPYING for more information about our license.

====================================================
Index: compose.php
<?php
   /**
    ** compose.php
    **
    **  Copyright (c) 1999-2000 The SquirrelMail development team
    **  Licensed under the GNU GPL. For full terms see the file COPYING.
    **
    ** This code sends a mail.
    **
    ** There are 3 modes of operation:
    **  - Start new mail
    **  - Add an attachment
    **  - Send mail
    **
    ** $Id: compose.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $
    **/

   $enablePHPGW = 1;


        // store the value of $mailbox, because it will overwriten
        $MAILBOX = $mailbox;
        if(isset($send))
        {
                $phpgw_info["flags"] = array("currentapp" => "squirrelmail", 
"enable_network_class" => True,
                        "enable_nextmatchs_class" => True,"noheader" => True, 
"nonavbar" => True);
        }
        else
        {
                $phpgw_info["flags"] = array("currentapp" => "squirrelmail", 
"enable_network_class" => True,
                        "enable_nextmatchs_class" => True);
        }
        include("../header.inc.php");

        $mailbox = $MAILBOX;

        $phpgw->session->restore();


        if (!isset($strings_php))
        {
                include(PHPGW_APP_ROOT . '/inc/strings.php');
        }

        if (!isset($config_php))
        {
                include(PHPGW_APP_ROOT . '/config/config.php');
        }

        if (!isset($page_header_php))
        {
                include(PHPGW_APP_ROOT . '/inc/page_header.php');
        }

        if (!isset($imap_php))
        {
                include(PHPGW_APP_ROOT . '/inc/imap.php');
        }

        if (!isset($date_php))
        {
                include(PHPGW_APP_ROOT . '/inc/date.php');
        }

        if (!isset($mime_php))
        {
                include(PHPGW_APP_ROOT . '/inc/mime.php');
        }

        if (!isset($smtp_php))
        {
                include(PHPGW_APP_ROOT . '/inc/smtp.php');
        }

        if (!isset($display_messages_php))
        {
                include(PHPGW_APP_ROOT . '/inc/display_messages.php');
        }

        if (!isset($auth_php))
        {
                include (PHPGW_APP_ROOT . '/inc/auth.php');
        }

        if (!isset($plugin_php))
        {
                include (PHPGW_APP_ROOT . '/inc/plugin.php');
        }

        include(PHPGW_APP_ROOT . '/src/load_prefs.php');

        if (!isset($attachments))
                $attachments = array();

        // This function is used when not sending or adding attachments
        function newMail ()
        {
                global $forward_id, $imapConnection, $msg, $ent_num, $body_ary, 
$body, $query_RB_addr,
                        $reply_id, $send_to, $send_to_cc, $mailbox, 
$send_to_bcc, $editor_size;

                $send_to = sqStripSlashes(decodeHeader($send_to));
                $send_to_cc = sqStripSlashes(decodeHeader($send_to_cc));
                $send_to_bcc = sqStripSlashes(decodeHeader($send_to_bcc));

                if ($forward_id)
                        $id = $forward_id;
                elseif ($reply_id)
                        $id = $reply_id;

                if (isset($id) && !isset($query_RB_addr))
                {
                        sqimap_mailbox_select($imapConnection, $mailbox);
                        $message = sqimap_get_message($imapConnection, $id, 
$mailbox);
                        $orig_header = $message->header;
                        if ($ent_num)
                                $message = getEntity($message, $ent_num);

                        if ($message->header->type0 == "text" || 
$message->header->type1 == "message")
                        {
                                if ($ent_num)
                                        $body = 
decodeBody(mime_fetch_body($imapConnection, $id, $ent_num), 
$message->header->encoding);
                                else
                                        $body = 
decodeBody(mime_fetch_body($imapConnection, $id, 1), 
$message->header->encoding);
                        }
                        else
                        {
                                $body = "";
                        }

                        if ($message->header->type1 == "html")
                                $body = strip_tags($body);

                        sqUnWordWrap($body);
                        $body_ary = explode("\n", $body);
                        $i = count($body_ary) - 1;
                        while (isset($body_ary[$i]) && ereg("^[>\s]*$", 
$body_ary[$i]))
                        {
                                unset($body_ary[$i]);
                                $i --;
                        }

                        $body = "";
                        for ($i=0; $i < count($body_ary); $i++)
                        {
                                if (! $forward_id)
                                {
                                        if (ereg('^[\s>]+', $body_ary[$i]))
                                        {
                                                $body_ary[$i] = '>' . 
$body_ary[$i];
                                        }
                                        else
                                        {
                                                $body_ary[$i] = '> ' . 
$body_ary[$i];
                                        }
                                }
                                sqWordWrap($body_ary[$i], $editor_size - 1);
                                $body .= $body_ary[$i] . "\n";
                                $body_ary[$i] = '';
                        }

                        if ($forward_id)
                        {
                                $bodyTop =  "-------- " . lang("Original 
Message") . " --------\n\n";
                                $bodyTop .= lang("Subject") . ": " . 
$orig_header->subject . "\n";
                                $bodyTop .= lang("From") . ": " . 
$orig_header->from . "\n";
                                $bodyTop .= lang("To") . ": " . 
$orig_header->to[0] . "\n";
                                if (count($orig_header->to) > 1)
                                {
                                        for ($x=1; $x < 
count($orig_header->to); $x++)
                                        {
                                                $bodyTop .= "         " . 
$orig_header->to[$x] . "\n";
                                        }
                                }
                                $bodyTop .= "\n";

                                $bodyBottom  = "\n-------- " . lang("Original 
Message") . " --------\n";
                                $body = $bodyTop . $body . $bodyBottom;
                        }
                        return;
                }

                if (!$send_to)
                {
                        $send_to = sqimap_find_email($send_to);
                }

                /** This formats a CC string if they hit "reply all" **/
                if ($send_to_cc != "")
                {
                        $send_to_cc = ereg_replace( '"[^"]*"', "", $send_to_cc);
                        $send_to_cc = ereg_replace(";", ",", $send_to_cc);
                        $sendcc = explode(",", $send_to_cc);
                        $send_to_cc = "";

                        for ($i = 0; $i < count($sendcc); $i++)
                        {
                                $sendcc[$i] = trim($sendcc[$i]);
                                if ($sendcc[$i] == "")
                                        continue;

                                $sendcc[$i] = sqimap_find_email($sendcc[$i]);
                                $whofrom = 
sqimap_find_displayable_name($msg["HEADER"]["FROM"]);
                                $whoreplyto = 
sqimap_find_email($msg["HEADER"]["REPLYTO"]);

                                if ((strtolower(trim($sendcc[$i])) != 
strtolower(trim($whofrom))) &&
                                        (strtolower(trim($sendcc[$i])) != 
strtolower(trim($whoreplyto))) &&
                                        (trim($sendcc[$i]) != ""))
                                {
                                        $send_to_cc .= trim($sendcc[$i]) . ", ";
                                }
                        }
                        $send_to_cc = trim($send_to_cc);
                        if (substr($send_to_cc, -1) == ",")
                        {
                                $send_to_cc = substr($send_to_cc, 0, 
strlen($send_to_cc) - 1);
                        }
                }
        } // function newMail()

   function getAttachments($message) {
      global $mailbox, $attachments, $attachment_dir, $imapConnection,
             $ent_num, $forward_id;
//address@hidden: added phpgw, $message
      global $phpgw, $message;

      if (!$message) {
           sqimap_mailbox_select($imapConnection, $mailbox);
           $message = sqimap_get_message($imapConnection, $forward_id, 
$mailbox); }

      if (!$message->entities) {
      if ($message->header->entity_id != $ent_num) {
      $filename = decodeHeader($message->header->filename);

      if ($filename == "")
              $filename = "untitled-".$message->header->entity_id;

      $localfilename = md5($filename.", $REMOTE_IP, REMOTE_PORT, $UNIQUE_ID, 
extra-stuff here" . time());

//address@hidden: added separator
        $sep = $phpgw->common->filesystem_separator();
        // Write File Info
//address@hidden: added separator ($sep)
        $fp = fopen ($attachment_dir.$sep.$localfilename.".info", "w");
        fputs ($fp, 
strtolower($message->header->type0)."/".strtolower($message->header->type1)."\n".$filename."\n");
        fclose ($fp);

        // Write Attachment to file
//address@hidden: added separator ($sep)
        $fp = fopen ($attachment_dir.$sep.$localfilename, "w");
      fputs ($fp, decodeBody(mime_fetch_body($imapConnection, $forward_id, 
$message->header->entity_id), $message->header->encoding));
      fclose ($fp);

      $attachments[$localfilename] = $filename;

      }
      } else {
              for ($i = 0; $i < count($message->entities); $i++) {
              getAttachments($message->entities[$i]);
              }
      }
      return;
      }

        function showInputForm ()
        {
                global $send_to, $send_to_cc, $reply_subj, $forward_subj, $body,
                        $passed_body, $color, $use_signature, $signature, 
$editor_size,
                        $attachments, $subject, $newmail, 
$use_javascript_addr_book,
                        $send_to_bcc, $reply_id, $mailbox, 
$from_htmladdr_search,
                        $location_of_buttons, $phpgw, $phpgw_info;

                $subject = sqStripSlashes(decodeHeader($subject));
                $reply_subj = decodeHeader($reply_subj);
                $forward_subj = decodeHeader($forward_subj);
                $body = sqStripSlashes($body);

                /* RB if ($use_javascript_addr_book)
                {
                        echo "\n<SCRIPT LANGUAGE=JavaScript><!--\n";
                        echo "function open_abook() { \n";
                        echo "  var nwin = 
window.open(\"addrbook_popup.php\",\"abookpopup\",";
                        echo 
"\"width=670,height=300,resizable=yes,scrollbars=yes\");\n";
                        echo "  if((!nwin.opener) && (document.windows != 
null))\n";
                        echo "    nwin.opener = document.windows;\n";
                        echo "}\n";
                        echo "// --></SCRIPT>\n\n";
                } */


      echo "\n<FORM name=compose action=\"" . 
$phpgw->link('/squirrelmail/compose.php') . "\" METHOD=POST 
ENCTYPE=\"multipart/form-data\"";
      do_hook("compose_form");
          echo ">\n";
      if ($reply_id) {
         echo "<input type=hidden name=reply_id value=$reply_id>\n";
      }
      printf("<INPUT TYPE=hidden NAME=mailbox VALUE=\"%s\">\n", 
htmlspecialchars($mailbox));
      echo "<TABLE WIDTH=\"100%\" ALIGN=center CELLSPACING=0 BORDER=0>\n";

      if ($location_of_buttons == 'top') showComposeButtonRow();

      echo "   <TR>\n";
      echo "      <TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
      echo lang("to").":";
      echo "      </TD><TD BGCOLOR=\"$color[4]\">\n";
      printf("         <INPUT TYPE=text NAME=\"send_to\" VALUE=\"%s\" 
SIZE=60><BR>\n",
             htmlspecialchars($send_to));
      echo "      </TD>\n";
      echo "   </TR>\n";
      echo "   <TR>\n";
      echo "      <TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
      echo lang("cc").":";
      echo "      </TD><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
      printf("         <INPUT TYPE=text NAME=\"send_to_cc\" SIZE=60 
VALUE=\"%s\"><BR>\n",
             htmlspecialchars($send_to_cc));
      echo "      </TD>\n";
      echo "   </TR>\n";
      echo "   <TR>\n";
      echo "      <TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
      echo lang("BCC").":";
      echo "      </TD><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
      printf("         <INPUT TYPE=text NAME=\"send_to_bcc\" VALUE=\"%s\" 
SIZE=60><BR>\n",
             htmlspecialchars($send_to_bcc));
      echo "</TD></TR>\n";

      echo "   <TR>\n";
      echo "      <TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
      echo lang("Subject").":";
      echo "      </TD><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
      if ($reply_subj) {
         $reply_subj = str_replace("\"", "'", $reply_subj);
         $reply_subj = sqStripSlashes($reply_subj);
         $reply_subj = trim($reply_subj);
         if (substr(strtolower($reply_subj), 0, 3) != "re:")
            $reply_subj = "Re: $reply_subj";
         printf("         <INPUT TYPE=text NAME=subject SIZE=60 VALUE=\"%s\">",
                htmlspecialchars($reply_subj));
      } else if ($forward_subj) {
         $forward_subj = str_replace("\"", "'", $forward_subj);
         $forward_subj = sqStripSlashes($forward_subj);
         $forward_subj = trim($forward_subj);
         if ((substr(strtolower($forward_subj), 0, 4) != "fwd:") &&
             (substr(strtolower($forward_subj), 0, 5) != "[fwd:") &&
             (substr(strtolower($forward_subj), 0, 6) != "[ fwd:"))
            $forward_subj = "[Fwd: $forward_subj]";
         printf("         <INPUT TYPE=text NAME=subject SIZE=60 VALUE=\"%s\">",
                htmlspecialchars($forward_subj));
      } else {
          printf("         <INPUT TYPE=text NAME=subject SIZE=60 VALUE=\"%s\">",
                htmlspecialchars($subject));
      }
      echo "</td></tr>\n\n";

      if ($location_of_buttons == 'between') showComposeButtonRow();

      echo "   <TR>\n";
      echo "      <TD BGCOLOR=\"$color[4]\" COLSPAN=2>\n";
      echo "         &nbsp;&nbsp;<TEXTAREA NAME=body ROWS=20 
COLS=\"$editor_size\" WRAP=HARD>";
      if ($reply_subj) echo "> ".htmlspecialchars($send_to)." 
".lang("wrote").":\n>\n";
      echo htmlspecialchars($body);
      if ($use_signature == true && $newmail == true && 
!isset($from_htmladdr_search)) {
         echo "\n\n-- \n" . htmlspecialchars($signature);
      }
      echo "</TEXTAREA><BR>\n";
      echo "      </TD>\n";
      echo "   </TR>\n";

      if ($location_of_buttons == 'bottom')
         showComposeButtonRow();
      else {
         echo "   <TR><TD>&nbsp;</TD><TD ALIGN=LEFT><INPUT TYPE=SUBMIT 
NAME=send VALUE=\"".lang("Send")."\"></TD></TR>\n";
      }

      // This code is for attachments
      echo "   <tr>\n";
      echo "     <TD BGCOLOR=\"$color[0]\" VALIGN=TOP ALIGN=RIGHT>\n";
      echo "      <SMALL><BR></SMALL>".lang("Attach").":";
      echo "      </td><td ALIGN=left BGCOLOR=\"$color[0]\">\n";
      echo "      <INPUT NAME=\"attachfile\" SIZE=48 TYPE=\"file\">\n";
      echo "      &nbsp;&nbsp;<input type=\"submit\" name=\"attach\"";
      echo " value=\"" . lang("Add") ."\">\n";
      echo "     </td>\n";
      echo "   </tr>\n";
//echo "Attachments:". count($attachments) . "<P>";
      if (isset($attachments) && count($attachments)>0) {
         echo "<tr><td bgcolor=\"$color[0]\" align=right>\n";
         echo "&nbsp;";
         echo "</td><td align=left bgcolor=\"$color[0]\">";
         while (list($localname, $remotename) = each($attachments)) {
            echo "<input type=\"checkbox\" name=\"delete[]\" 
value=\"$localname\">\n";
            echo "$remotename <input type=\"hidden\" 
name=\"attachments[$localname]\" value=\"$remotename\"><br>\n";
         }

         echo "<input type=\"submit\" name=\"do_delete\" value=\"".lang("Delete 
selected attachments")."\">\n";
         echo "</td></tr>";
      }
      // End of attachment code

      echo "</TABLE>\n";
      echo "</FORM>";
      do_hook("compose_bottom");
   }

        $sb2 = CreateObject('phpgwapi.sbox2');

        function showComposeButtonRow()
        {
                global $use_javascript_addr_book;
                echo "   <TR><td>\n   </td><td>\n";

                /* RB if ($use_javascript_addr_book)
                {
                        echo "      <SCRIPT LANGUAGE=JavaScript><!--\n 
document.write(\"";
                        echo "         <input type=button 
value=\\\"".lang("Addresses")."\\\" onclick='javascript:open_abook();'>\");";
                        echo "         // --></SCRIPT><NOSCRIPT>\n";
                        echo "         <input type=submit 
name=\"html_addr_search\" value=\"".lang("Addresses")."\">";
                        echo "      </NOSCRIPT>\n";
                }
                else
                {
                        echo "      <input type=submit 
name=\"html_addr_search\" value=\"".lang("Addresses")."\">";
                } */

                global $query_RB_addr,$sb2;
                $arr = $sb2->getEmail('RB_addr',0,$query_RB_addr);
                while (list($k,$val) = each($arr))
                {
                        if ($k != 'RB_addr_nojs')
                                echo $val." &nbsp; \n";
                }
                if ($query_RB_addr && isset($arr['RB_addr_OK']))
                {
                        // yes we have selectbox with addresses
                        echo '<input type=submit name="RB_addr_To" value="To"> 
&nbsp; '."\n";
                        echo '<input type=submit name="RB_addr_Cc" value="Cc"> 
&nbsp; '."\n";
                }
                else
                {
                        echo $arr['RB_addr_nojs']." &nbsp; \n";
                }

                echo "\n    <INPUT TYPE=SUBMIT NAME=send VALUE=\"". 
lang("Send") . "\">\n";

                do_hook("compose_button_row");

                echo "   </TD>\n";
                echo "   </TR>\n\n";
        }

   function showSentForm () {
      echo "<BR><BR><BR><CENTER><B>Message Sent!</B><BR><BR>";
      echo "You will be automatically forwarded.<BR>If not, <A 
HREF=\"index.php\">click here</A>";
      echo "</CENTER>";
   }

   function checkInput ($show) {
      /** I implemented the $show variable because the error messages
          were getting sent before the page header.  So, I check once
          using $show=false, and then when i'm ready to display the
          error message, show=true **/
      global $send_to, $show, $color;

      if ($send_to == "") {
         if ($show)
            plain_error_message(lang("You have not filled in the \"To:\" 
field."), $color);
         return false;
      }
      return true;
   } // function checkInput()


   // True if FAILURE
   function saveAttachedFiles()
   {
      global $HTTP_POST_FILES, $attachments, $phpgw, $phpgw_info;
      global $failed, $mailbox, $send_to, $send_to_cc, $send_to_bcc, $subject, 
$body, $attachfile,
                $imapConnection, $boxes, $send, $reply_id, $color, $id_RB_addr, 
$RB_addr_To, $RB_addr_Cc,
                $attach, $do_delete, $delete, $smtpErrors, $ent_num, 
$translated_setup;

      $localfilename = GenerateRandomString(32, '', 7);
      $sep = $phpgw->common->filesystem_separator();

      $HTTP_POST_FILES['attachfile']['tmp_name'];
      $phpgw_info["server"]["temp_dir"] . $sep . $localfilename;

      if (address@hidden($HTTP_POST_FILES['attachfile']['tmp_name'], 
$phpgw_info["server"]["temp_dir"] . $sep . $localfilename)) {
         if (!copy($HTTP_POST_FILES['attachfile']['tmp_name'], 
$phpgw_info["server"]["temp_dir"] . $sep . $localfilename)) {
            return true;
         }
      }

      if (!isset($failed) || !$failed) {
         // Write information about the file
         $fp = fopen ($phpgw_info["server"]["temp_dir"] . $sep . 
$localfilename.".info", "w");
         fputs ($fp, 
$HTTP_POST_FILES['attachfile']['type']."\n".$HTTP_POST_FILES['attachfile']['name']."\n");
         fclose ($fp);

         $attachments[$localfilename] = $HTTP_POST_FILES['attachfile']['name'];
      }
    }

        if (isset($mailbox))     $mailbox = trim($mailbox);
        if (isset($send_to))     $send_to = trim($send_to);
        if (isset($send_to_cc))  $send_to_cc = trim($send_to_cc);
        if (isset($send_to_bcc)) $send_to_bcc = trim($send_to_bcc);
        if (isset($subject))     $subject = trim($subject);
        if (isset($body))        $body = trim($body);
        if (isset($attachfile))  $attachfile = trim($attachfile);

        if (!isset($mailbox) || $mailbox == "" || ($mailbox == "None"))
                $mailbox = "INBOX";

        if (isset($HTTP_POST_VARS["query_RB_addr"]))
        {
                // the signature is already included in the body at this stage
                $use_signature = false;
        }

        $debugLK = 0;


        //address@hidden: there are cases where boxes is not an array
        if (!isset($imapConnection))  {
                // this should be set already lars kneschke 2001-09-09
                //$key      = 
$phpgw_info['user']['preferences']['email']['passwd'];
                //$username = 
$phpgw_info['user']['preferences']['email']['userid'];
                $imapConnection = sqimap_login($username, $key, 
$imapServerAddress, $imapPort, 0);
        }
        if (!isset($boxes)) {
                $boxes = sqimap_mailbox_list($imapConnection);
                $phpgw->session->register("boxes");
        }

        if(isset($send))
        {
                if ($debugLK) print '$send set<br>';

                if (isset($HTTP_POST_FILES['attachfile']) &&
                        $HTTP_POST_FILES['attachfile']['tmp_name'] &&
                        $HTTP_POST_FILES['attachfile']['tmp_name'] != 'none' &&
                        $HTTP_POST_FILES['attachfile']['name'])
                {
                        $AttachFailure = saveAttachedFiles();
                }
                if (checkInput(false) && !isset($AttachFailure))
                {
                        $urlMailbox = urlencode (trim($mailbox));
                        if (! isset($reply_id)) $reply_id = 0;
                        sendMessage($send_to, $send_to_cc, $send_to_bcc, 
$subject, $body, $reply_id);
                        header ("Location: " . 
$phpgw->link('/squirrelmail/index.php',"mailbox=$urlMailbox&sort=$sort&startMessage=1"));
                }
                else
                {
                        //$imapConnection = sqimap_login($username, $key, 
$imapServerAddress, $imapPort, 0);

                        displayPageHeader($color, $mailbox);

                        if ($AttachFailure)
                                plain_error_message(lang("Could not move/copy 
file. File not attached"), $color);

                        checkInput(true);

                        showInputForm();
                        //sqimap_logout($imapConnection);
                }
        }
        else if ($id_RB_addr && ($RB_addr_To || $RB_addr_Cc))
        {
                if ($debugLK) print '$id_RB_addr && ($RB_addr_To || 
$RB_addr_Cc<br>';
                //$imapConnection = sqimap_login($username, $key, 
$imapServerAddress, $imapPort, 0);
                displayPageHeader($color, $mailbox);

                $send_to = sqStripSlashes($send_to);
                $send_to_cc = sqStripSlashes($send_to_cc);
                $send_to_bcc = sqStripSlashes($send_to_bcc);

                if ($RB_addr_To)
                {
                        if ($send_to) $send_to .= ', ';
                        $send_to .= $sb2->addr2email($id_RB_addr);
                }
                else
                {
                        if ($send_to_cc) $send_to_cc .= ', ';
                        $send_to_cc .= $sb2->addr2email($id_RB_addr);
                }
                // the signature is already included in the body at this stage
                $use_signature = false;
                showInputForm();
                //sqimap_logout($imapConnection);
        }
        else if (isset($attach))
        {
                if (saveAttachedFiles())
                        plain_error_message(lang("Could not move/copy file. 
File not attached"), $color);
                //$imapConnection = sqimap_login($username, $key, 
$imapServerAddress, $imapPort, 0);
                displayPageHeader($color, $mailbox);
                showInputForm();
                //sqimap_logout($imapConnection);
        }
        else if (isset($do_delete))
        {
                //$imapConnection = sqimap_login($username, $key, 
$imapServerAddress, $imapPort, 0);
                displayPageHeader($color, $mailbox);

                $sep = $phpgw->common->filesystem_separator();
                while (list($lkey, $localname) = each($delete))
                {
                        unset ($attachments[$localname]);
                        unlink ($phpgw_info["server"]["temp_dir"] . $sep . 
$localname);
                        unlink ($phpgw_info["server"]["temp_dir"] . $sep . 
$localname.".info");
                }

                showInputForm();
                //sqimap_logout($imapConnection);
        }
        else if (isset($smtpErrors))
        {
                //$imapConnection = sqimap_login($username, $key, 
$imapServerAddress, $imapPort, 0);
                displayPageHeader($color, $mailbox);

                $newmail = true;
                if ($forward_id && $ent_num)  getAttachments(0);

                newMail();
                showInputForm();
                //sqimap_logout($imapConnection);
        }
        else
        {
                if ($debugLK) print 'default<br>';
                $imapConnection = sqimap_login($username, $key, 
$imapServerAddress, $imapPort, 0);
                displayPageHeader($color, $mailbox);

                $newmail = true;

                if (isset($forward_id) && isset($ent_num))  getAttachments(0);

                newMail();
                showInputForm();
                sqimap_logout($imapConnection);
        }
/*
//address@hidden: inserted three next lines
   if (!isset($translated_setup) && !function_exists('translate_read_form') )
      include(PHPGW_APP_ROOT . "/inc/translate_setup.php");
   translate_read_form();
*/

        $phpgw->session->save();
        $phpgw->common->phpgw_footer();
?>

====================================================
Index: folders_create.php
<?php
   /**
    **  folders_create.php
    **
    **  Copyright (c) 1999-2000 The SquirrelMail development team
    **  Licensed under the GNU GPL. For full terms see the file COPYING.
    **
    **  Creates folders on the IMAP server.
    **  Called from folders.php
    **
    **  $Id: folders_create.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $
    **/

        // store the value of $mailbox, because it will overwriten
        $MAILBOX = $mailbox;
        $phpgw_info["flags"] = array(
                "currentapp" => "squirrelmail",
                'noheader'    => 'True',
                'nonavbar'    => 'True'
        );
        include("../header.inc.php");
        $mailbox = $MAILBOX;

        $phpgw->session->restore();

   if (!isset($strings_php))
      include(PHPGW_APP_ROOT . "/inc/strings.php");
   if (!isset($config_php))
      include(PHPGW_APP_ROOT . "/config/config.php");
   if (!isset($page_header_php))
      include(PHPGW_APP_ROOT . "/inc/page_header.php");
   if (!isset($imap_php))
      include(PHPGW_APP_ROOT . "/inc/imap.php");
   if (!isset($display_messages_php))
      include(PHPGW_APP_ROOT . "/inc/display_messages.php");

   include(PHPGW_APP_ROOT . "/src/load_prefs.php");

   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 
$imapPort, 0);
   $dm = sqimap_get_delimiter($imapConnection);

   if (strpos($folder_name, "\"") || strpos($folder_name, "\\") ||
       strpos($folder_name, "'") || strpos($folder_name, "$dm")) {
                print "<html><body bgcolor=$color[4]>";
      plain_error_message(lang("Illegal folder name.  Please select a different 
name.")."<BR><A HREF=\"../src/folders.php\">".lang("Click here to go 
back")."</A>.", $color);
      sqimap_logout($imapConnection);
      exit;
   }

   if (isset($contain_subs) && $contain_subs == true)
      $folder_name = "$folder_name$dm";

   if ($folder_prefix && (substr($folder_prefix, -1) != $dm)) {
      $folder_prefix = $folder_prefix . $dm;
   }
   if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != 
$folder_prefix)){
      $subfolder_orig = $subfolder;
      $subfolder = $folder_prefix . $subfolder;
   } else {
      $subfolder_orig = $subfolder;
   }

   if ((trim($subfolder_orig) == "[ None ]") || 
(trim(sqStripSlashes($subfolder_orig)) == "[ None ]")) {
      sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, "");
   } else {
      sqimap_mailbox_create ($imapConnection, $subfolder.$dm.$folder_name, "");
   }
   fputs($imapConnection, "1 logout\n");

   $location = get_location();
   header ("Location: 
".$phpgw->link('/squirrelmail/folders.php','success=create'));

   sqimap_logout($imapConnection);

   $phpgw->common->phpgw_footer();
?>


====================================================
Index: folders.php
<?php
   /**
    **  folders.php
    **
    **  Copyright (c) 1999-2000 The SquirrelMail development team
    **  Licensed under the GNU GPL. For full terms see the file COPYING.
    **
    **  Handles all interaction between the user and the other folder
    **  scripts which do most of the work. Also handles the Special
    **  Folders.
    **
    **  $Id: folders.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $
    **/

   $enablePHPGW = 1;

        // store the value of $mailbox, because it will overwriten
        $MAILBOX = $mailbox;
        $phpgw_info["flags"] = array("currentapp" => "squirrelmail", 
"enable_network_class" => True,
                        "enable_nextmatchs_class" => True);
        include("../header.inc.php");
        $mailbox = $MAILBOX;

        $phpgw->session->restore();

   if (!isset($strings_php))
      include(PHPGW_APP_ROOT . "/inc/strings.php");
   if (!isset($config_php))
      include(PHPGW_APP_ROOT . "/config/config.php");
   if (!isset($page_header_php))
      include(PHPGW_APP_ROOT . "/inc/page_header.php");
   if (!isset($imap_php))
      include(PHPGW_APP_ROOT . "/inc/imap.php");
   if (!isset($array_php))
      include(PHPGW_APP_ROOT . "/inc/array.php");
   if (!isset($plugin_php))
      include(PHPGW_APP_ROOT . "/inc/plugin.php");

   include(PHPGW_APP_ROOT . "/src/load_prefs.php");

#   displayPageHeader($imapConnection, $color, "None");

   echo "<br>";
   echo "<TABLE WIDTH=95% COLS=1 ALIGN=CENTER>\n";
   echo "   <TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><b>\n";
   echo lang("Folders");
   echo "   </b></TD></TR>\n";
   echo "</TABLE>\n";

   if ((isset($success) && $success) ||
       (isset($sent_create) && $sent_create == "true") ||
       (isset($trash_create) && $trash_create == "true")) {
      echo "<table width=100% align=center cellpadding=3 cellspacing=0 
border=0>\n";
      echo "   <tr><td><center>\n";
      if ($success == "subscribe") {
         echo "<b>" . lang("Subscribed successfully!") . "</b><br>";
      } else if ($success == "unsubscribe") {
         echo "<b>" . lang("Unsubscribed successfully!") . "</b><br>";
      } else if ($success == "delete") {
         echo "<b>" . lang("Deleted folder successfully!") . "</b><br>";
      } else if ($success == "create") {
         echo "<b>" . lang("Created folder successfully!") . "</b><br>";
      } else if ($success == "rename") {
         echo "<b>" . lang("Renamed successfully!") . "</b><br>";
      } else if (($sent_create == "true") || ($trash_create == "true")) {
         $imapConnection = sqimap_login($username, $key, $imapServerAddress, 
$imapPort, 0);
         if ($sent_create == "true") {
            sqimap_mailbox_create ($imapConnection, $sent_folder, "");
         }
         if ($trash_create == "true") {
            sqimap_mailbox_create ($imapConnection, $trash_folder, "");
         }
         sqimap_logout($imapConnection);
         echo lang("Folders created successfully!");
      }

      echo "   </center></td></tr>\n";
      echo "</table><br>\n";
   }
   $imapConnection = sqimap_login ($username, $key, $imapServerAddress, 
$imapPort, 0);
   $boxes = sqimap_mailbox_list($imapConnection);

   //display form option for creating Sent and Trash folder
   if ($imap_server_type == "cyrus" && ($sent_folder != "none" || $trash_folder 
!= "none")) {
      if ((!sqimap_mailbox_exists ($imapConnection, $sent_folder)) ||
          (!sqimap_mailbox_exists ($imapConnection, $trash_folder))) {
         echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 
border=0>\n";
         echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
         echo lang("Special Folder Options");
         echo "</B></TD></TR>";
         echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
         echo lang("In order for SquirrelMail to provide the full set of 
options you need to create the special folders listed below.  Just click the 
check box and hit the create button.");
         echo "<FORM ACTION=\"".$phpgw->link('/squirrelmail/folders.php')."\" 
METHOD=\"POST\">\n";
         if (!sqimap_mailbox_exists ($imapConnection, $sent_folder) && 
$sent_folder != "none") {
            echo lang("Create Sent") . "<INPUT TYPE=checkbox NAME=sent_create 
value=true><br>\n";
         }
         if (!sqimap_mailbox_exists ($imapConnection, $trash_folder) && 
$trash_folder != "none"){
            echo lang("Create Trash") . "<INPUT TYPE=checkbox NAME=trash_create 
value=true><br>\n";
         }
         echo "<INPUT TYPE=submit VALUE=".lang("Create").">";
         echo "</FORM></TD></TR></TABLE><br>";
      }
   }

   /** DELETING FOLDERS **/
   echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 
border=0>\n";
   echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
   echo lang("Delete Folder");
   echo "</B></TD></TR>";
   echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";

   $count_special_folders = 0;
       $num_max = 1;
       if (strtolower($imap_server_type) == "courier" || $move_to_trash)
               $num_max++;
       if ($move_to_sent)
               $num_max++;

   for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++) {
      if (strtolower($boxes[$p]["unformatted"]) == "inbox")
         $count_special_folders++;
      else if (strtolower($imap_server_type) == "courier" &&
               strtolower($boxes[$p]["unformatted"]) == "inbox.trash")
         $count_special_folders++;
      else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder)
         $count_special_folders++;
      else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder)
         $count_special_folders++;
   }

   if ($count_special_folders < count($boxes)) {
      echo "<FORM 
ACTION=\"".$phpgw->link('/squirrelmail/folders_delete.php')."\" 
METHOD=\"POST\">\n";
      echo "<TT><SELECT NAME=mailbox>\n";
      for ($i = 0; $i < count($boxes); $i++) {
         $use_folder = true;
         if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
             ($boxes[$i]["unformatted"] != $trash_folder) &&
             ($boxes[$i]["unformatted"] != $sent_folder) &&
             (strtolower($imap_server_type) != "courier" ||
              strtolower($boxes[$i]["unformatted"]) != "inbox.trash"))
            {
               $box = $boxes[$i]["unformatted-dm"];
               $box2 = replace_spaces($boxes[$i]["unformatted-disp"]);
               echo "         <OPTION VALUE=\"$box\">$box2\n";
            }
      }
      echo "</SELECT></TT>\n";
      echo "<INPUT TYPE=SUBMIT VALUE=\"";
      echo lang("Delete");
      echo "\">\n";
      echo "</FORM></TD></TR>\n";
   } else {
      echo lang("No folders found") . "<br><br></td><tr>";
   }

   echo "<tr><td bgcolor=\"$color[4]\">&nbsp;</td></tr>\n";

   /** CREATING FOLDERS **/
   echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
   echo lang("Create Folder");
   echo "</B></TD></TR>";
   echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
   echo "<FORM NAME=cf 
ACTION=\"".$phpgw->link('/squirrelmail/folders_create.php')."\" 
METHOD=\"POST\">\n";
   echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
   echo lang("as a subfolder of");
   echo "<BR>";
   echo "<TT><SELECT NAME=subfolder>\n";
   if (strtolower($imap_server_type) != "courier"){
     if ($default_sub_of_inbox == false)
       echo "<OPTION SELECTED>[ None ]\n";
     else
       echo "<OPTION>[ None ]\n";
   }

   for ($i = 0; $i < count($boxes); $i++) {
      if (count($boxes[$i]["flags"]) > 0) {
         $noinf = false;
         for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) {
            if ($boxes[$i]["flags"][$j] == "noinferiors") {
               $noinf = true;
               continue;
            }
         }
         if ($noinf == false) {
            if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && 
($default_sub_of_inbox == true)) {
               $box = $boxes[$i]["unformatted"];
               $box2 = replace_spaces($boxes[$i]["unformatted-disp"]);
               echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
            } else {
               $box = $boxes[$i]["unformatted"];
               $box2 = replace_spaces($boxes[$i]["unformatted-disp"]);
               if (strtolower($imap_server_type) != "courier" ||
                  strtolower($box) != "inbox.trash")
                echo "<OPTION VALUE=\"$box\">$box2\n";
            }
         }
      } else {
         if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && 
($default_sub_of_inbox == true)) {
            $box = $boxes[$i]["unformatted"];
            $box2 = replace_spaces($boxes[$i]["unformatted-disp"]);
            echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
         } else {
            $box = $boxes[$i]["unformatted"];
            $box2 = replace_spaces($boxes[$i]["unformatted-disp"]);
           if (strtolower($imap_server_type) != "courier" ||
               strtolower($box) != "inbox.trash")
             echo "<OPTION VALUE=\"$box\">$box2\n";
         }
      }
   }
   echo "</SELECT></TT><BR>\n";
   if ($show_contain_subfolders_option) {
      echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> &nbsp;";
      echo lang("Let this folder contain subfolders");
      echo "<BR>";
   }
   echo "<INPUT TYPE=SUBMIT VALUE=\"".lang("Create")."\">\n";
   echo "</FORM></TD></TR>\n";

   echo "<tr><td bgcolor=\"$color[4]\">&nbsp;</td></tr>\n";

   /** RENAMING FOLDERS **/
   echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
   echo lang("Rename a Folder");
   echo "</B></TD></TR>";
   echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
   if ($count_special_folders < count($boxes)) {
      echo "<FORM 
ACTION=\"".$phpgw->link('/squirrelmail/folders_rename_getname.php')."\" 
METHOD=\"POST\">\n";
      echo "<TT><SELECT NAME=old>\n";
      for ($i = 0; $i < count($boxes); $i++) {
         $use_folder = true;

         if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
             ($boxes[$i]["unformatted"] != $trash_folder)  &&
             ($boxes[$i]["unformatted"] != $sent_folder))
            {
               $box = $boxes[$i]["unformatted-dm"];
               $box2 = replace_spaces($boxes[$i]["unformatted-disp"]);
               if (strtolower($imap_server_type) != "courier" || 
strtolower($box) != "inbox.trash")
                  echo "<OPTION VALUE=\"$box\">$box2\n";
            }
      }
      echo "</SELECT></TT>\n";
      echo "<INPUT TYPE=SUBMIT VALUE=\"";
      echo lang("Rename");
      echo "\">\n";
      echo "</FORM></TD></TR>\n";
   } else {
      echo lang("No folders found") . "<br><br></td></tr>";
   }
   $boxes_sub = $boxes;

   echo "<tr><td bgcolor=\"$color[4]\">&nbsp;</td></tr></table>\n";

   /** UNSUBSCRIBE FOLDERS **/
   echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 
border=0>\n";
   echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=3><B>";
   echo lang("Unsubscribe") . "/" . lang("Subscribe");
   echo "</B></TD></TR>";
   echo "<TR><TD BGCOLOR=\"$color[0]\" width=49% ALIGN=CENTER>";
   if ($count_special_folders < count($boxes)) {
      echo "<FORM 
ACTION=\"".$phpgw->link('/squirrelmail/folders_subscribe.php','method=unsub')."\"
 METHOD=\"POST\">\n";
      echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n";
      for ($i = 0; $i < count($boxes); $i++) {
         $use_folder = true;
         if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
             ($boxes[$i]["unformatted"] != $trash_folder) &&
             ($boxes[$i]["unformatted"] != $sent_folder))
            {
               $box = $boxes[$i]["unformatted-dm"];
               $box2 = replace_spaces($boxes[$i]["unformatted-disp"]);
               echo "         <OPTION VALUE=\"$box\">$box2\n";
            }
      }
      echo "</SELECT></TT><br>\n";
      echo "<INPUT TYPE=SUBMIT VALUE=\"";
      echo lang("Unsubscribe");
      echo "\">\n";
      echo "</FORM></TD>\n";
   } else {
      echo lang("No folders were found to unsubscribe from!") . "</td>";
   }
   $boxes_sub = $boxes;

   echo "<td bgcolor=\"$color[9]\" width=2%>&nbsp;</td>";

   /** SUBSCRIBE TO FOLDERS **/
   echo "<TD BGCOLOR=\"$color[0]\" widtn=49% ALIGN=CENTER>";
   $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 
1);
   $boxes_all = sqimap_mailbox_list_all ($imap_stream);

   $box = "";
   $box2 = "";
   for ($i = 0, $q = 0; $i < count($boxes_all); $i++) {
      $use_folder = true;
      for ($p = 0; $p < count ($boxes); $p++) {
         if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
            $use_folder = false;
            continue;
         } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
            $use_folder = false;
         }
      }
      if ($use_folder == true) {
         $box[$q] = $boxes_all[$i]["unformatted-dm"];
         $box2[$q] = $boxes_all[$i]["unformatted-disp"];
         $q++;
      }
   }
   sqimap_logout($imap_stream);

   if ($box && $box2) {
      echo "<FORM 
ACTION=\"".$phpgw->link('/squirrelmail/folders_subscribe.php','method=sub')."\" 
METHOD=\"POST\">\n";
      echo "<tt><select name=mailbox[] multiple size=8>";

      for ($q = 0; $q < count($box); $q++) {
         echo "         <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
      }
      echo "</select></tt><br>";
      echo "<INPUT TYPE=SUBMIT VALUE=\"". lang("Subscribe") . "\">\n";
      echo "</FORM></TD></TR></TABLE><BR>\n";
   } else {
      echo lang("No folders were found to subscribe to!") . 
"</td></tr></table>";
   }

   do_hook("folders_bottom");
   sqimap_logout($imapConnection);

   if ($enablePHPGW)
   {
        $phpgw->session->save();
        $phpgw->common->phpgw_footer();
   }
   else
   {
        print "</BODY></HTML>";
   }

?>

====================================================
Index: download.php
<?php
   /**
    **  download.php
    **
    **  Copyright (c) 1999-2000 The SquirrelMail development team
    **  Licensed under the GNU GPL. For full terms see the file COPYING.
    **
    **  Handles attachment downloads to the users computer.
    **  Also allows displaying of attachments when possible.
    **
    **  $Id: download.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $
    **/
   header("Pragma: ");
   header("Cache-Control: cache");

        // store the value of $mailbox, because it will overwriten
        $MAILBOX = $mailbox;
        $phpgw_info["flags"] = array(
                'noheader'    => 'True',
                'nonavbar'    => 'True',
                "currentapp" => "squirrelmail"
        );
        include("../header.inc.php");
        $mailbox = $MAILBOX;

        $phpgw->session->restore();


   if (!isset($strings_php))
      include(PHPGW_APP_ROOT . '/inc/strings.php');
   if (!isset($config_php))
      include(PHPGW_APP_ROOT . '/config/config.php');
   if (!isset($imap_php))
      include("./inc/imap.php");
   if (!isset($mime_php))
      include("./inc/mime.php");
   if (!isset($date_php))
      include("./inc/date.php");
   if (!isset($i18n_php))
      include("./inc/i18n.php");


   include("./src/load_prefs.php");

   function viewText($color, $body, $id, $entid, $mailbox, $type1, $wrap_at) {
      global $where, $what, $charset, $phpgw;
      global $startMessage, $imapConnection;

      //displayPageHeader($imapConnection, $color, "None");
      displayPageHeader($color, "None");

      echo "<BR><TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2 
ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">";
      echo "<B><CENTER>";
      echo lang("Viewing a text attachment") . " - ";
      if ($where && $what) {
         // from a search
         echo "<a 
href=\"".$phpgw->link('/squirrelmail/read_body.php',"mailbox=".urlencode($mailbox)."&passed_id=$id&where=".urlencode($where)."&what=".urlencode($what))."\">".
 lang("View message") . "</a>";
      } else {
         echo "<a 
href=\"".$phpgw->link('/squirrelmail/read_body.php',"mailbox=".urlencode($mailbox)."&passed_id=$id&startMessage=$startMessage&show_more=0")."\">".
 lang("View message") . "</a>";
      }

      $urlmailbox = urlencode($mailbox);
      echo "</b></td><tr><tr><td><CENTER><A 
HREF=\"".$phpgw->link('/squirrelmail/download.php',"absolute_dl=true&passed_id=$id&passed_ent_id=$entid&mailbox=$urlmailbox")."\">";
      echo lang("Download this as a file");
      echo "</A></CENTER><BR>";
      echo "</CENTER></B>";
      echo "</TD></TR></TABLE>";

      echo "<TABLE WIDTH=98% BORDER=0 CELLSPACING=0 CELLPADDING=2 
ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">";
      echo "<TR><TD BGCOLOR=\"$color[4]\"><TT>";

      if ($type1 != "html")
         translateText($body, $wrap_at, $charset);

      // this will help netscape linux
      $body = eregi_replace('base href','base hreff',$body);

      echo $body;

      echo "</TT></TD></TR></TABLE>";
   }

   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 
$imapPort, 0);
   sqimap_mailbox_select($imapConnection, $mailbox);

   // $message contains all information about the message
   // including header and body
   $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
   $top_header = $message->header;

   // lets redefine message as this particular entity that we wish to display.
   // it should hold only the header for this entity.  We need to fetch the body
   // yet before we can display anything.
   $message = getEntity($message, $passed_ent_id);

   $header = $message->header;

   $charset = $header->charset;
   $type0 = $header->type0;
   $type1 = $header->type1;
   $filename = decodeHeader($header->filename);

   if (strlen($filename) < 1) {
      if ($type1 == "plain" && $type0 == "text")                  $suffix = 
"txt";
      else if ($type1 == "richtext" && $type0 == "text")          $suffix = 
"rtf";
      else if ($type1 == "postscript" && $type0 == "application") $suffix = 
"ps";
      else if ($type1 == "message" && $type0 == "rfc822")         $suffix = 
"msg";
      else $suffix = $type1;

      $filename = "untitled$passed_ent_id.$suffix";
   }

   // Note:
   //    The following sections display the attachment in different
   //    ways depending on how they choose.  The first way will download
   //    under any circumstance.  This sets the Content-type to be
   //    applicatin/octet-stream, which should be interpreted by the
   //    browser as "download me".
   //      The second method (view) is used for images or other formats
   //    that should be able to be handled by the browser.  It will
   //    most likely display the attachment inline inside the browser.
   //      And finally, the third one will be used by default.  If it
   //    is displayable (text or html), it will load them up in a text
   //    viewer (built in to squirrelmail).  Otherwise, it sets the
   //    content-type as application/octet-stream

   if (isset($absolute_dl) && $absolute_dl == "true") {
      switch($type0) {
         case "text":
            $body = mime_fetch_body($imapConnection, $passed_id, 
$passed_ent_id);
            $body = decodeBody($body, $header->encoding);
            header("Content-Disposition: attachment; filename=\"$filename\"");
            header("Content-type: application/octet-stream; 
name=\"$filename\"");
            set_up_language(getPref($data_dir, $username, "language"));
            if ($type1 == "plain") {
               echo lang("Subject") . ": " . 
decodeHeader(sqStripSlashes($top_header->subject)) . "\n";
               echo "   " . lang("From") . ": " . 
decodeHeader(sqStripSlashes($top_header->from)) . "\n";
               echo "     " . lang("To") . ": " . 
decodeHeader(sqStripSlashes(getLineOfAddrs($top_header->to))) . "\n";
               echo "   " . lang("Date") . ": " . 
getLongDateString($top_header->date) . "\n\n";
            }
            echo trim($body);
            break;
         default:
            header("Content-Disposition: attachment; filename=\"$filename\"");
            header("Content-type: application/octet-stream; 
name=\"$filename\"");
            mime_print_body_lines ($imapConnection, $passed_id, $passed_ent_id, 
$header->encoding);
            break;
      }
   } else {
      switch ($type0) {
         case "text":
            if ($type1 == "plain" || $type1 == "html") {
                $phpgw->common->phpgw_header();
                echo parse_navbar();
                $body = mime_fetch_body($imapConnection, $passed_id, 
$passed_ent_id);
                $body = decodeBody($body, $header->encoding);
                include(PHPGW_APP_ROOT . "/inc/page_header.php");
                viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, 
$type1, $wrap_at);
            } else {
                $body = mime_fetch_body($imapConnection, $passed_id, 
$passed_ent_id);
                $body = decodeBody($body, $header->encoding);
                header("Content-type: $type0/$type1; name=\"$filename\"");
                header("Content-Disposition: attachment; 
filename=\"$filename\"");
                echo $body;
            }
            break;
         case "message":
            $phpgw->common->phpgw_header();
            echo parse_navbar();
            $body = mime_fetch_body($imapConnection, $passed_id, 
$passed_ent_id);
            $body = decodeBody($body, $header->encoding);
            include(PHPGW_APP_ROOT . '/inc/page_header.php');
            viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, 
$type1, $wrap_at);
            break;
         default:
            header("Content-type: $type0/$type1; name=\"$filename\"");
            header("Content-Disposition: attachment; filename=\"$filename\"");
            mime_print_body_lines ($imapConnection, $passed_id, $passed_ent_id, 
$header->encoding);
            break;
      }
   }

   sqimap_logout($imapConnection);
        $phpgw->session->save();
        // vcard doesn't need a footer
        if ($type1 != 'x-vcard') {
//address@hidden: disabled; the typical application/octet-stream doesn't want 
this
                //$phpgw->common->phpgw_footer();
        }


?>

====================================================
Index: folders_delete.php
<?php
   /**
    **  folders_delete.php
    **
    **  Copyright (c) 1999-2000 The SquirrelMail development team
    **  Licensed under the GNU GPL. For full terms see the file COPYING.
    **
    **  Deltes folders from the IMAP server.
    **  Called from the folders.php
    **
    **  $Id: folders_delete.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $
    **/

        // store the value of $mailbox, because it will overwriten
        $MAILBOX = $mailbox;
        $phpgw_info["flags"] = array(
                "currentapp" => "squirrelmail",
                'noheader'    => 'True',
                'nonavbar'    => 'True'
        );
        include("../header.inc.php");
        $mailbox = $MAILBOX;

        $phpgw->session->restore();



   /*
   *  Incoming values:
   *     $mailbox - selected mailbox from the form
   */

   if (!isset($strings_php))
      include(PHPGW_APP_ROOT . "/inc/strings.php");
   if (!isset($config_php))
      include(PHPGW_APP_ROOT . "/config/config.php");
   if (!isset($page_header_php))
      include(PHPGW_APP_ROOT . "/inc/page_header.php");
   if (!isset($imap_php))
      include(PHPGW_APP_ROOT . "/inc/imap.php");
   if (!isset($array_php))
      include(PHPGW_APP_ROOT . "/inc/array.php");
   if (!isset($tree_php))
      include(PHPGW_APP_ROOT . "/inc/tree.php");

   include(PHPGW_APP_ROOT . "/src/load_prefs.php");


   $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 
0);
   $boxes = sqimap_mailbox_list ($imap_stream);
   $dm = sqimap_get_delimiter($imap_stream);
   $mailbox = sqStripSlashes($mailbox);

   if (substr($mailbox, -1) == $dm)
      $mailbox_no_dm = substr($mailbox, 0, strlen($mailbox) - 1);
   else
      $mailbox_no_dm = $mailbox;

   /** lets see if we CAN move folders to the trash.. otherwise,
    ** just delete them **/

   // Courier IMAP doesn't like subfolders of Trash
   if (strtolower($imap_server_type) == "courier") {
      $can_move_to_trash = false;
   }

   // If it's already a subfolder of trash, we'll have to delete it
   else if(eregi("^".$trash_folder.".+", $mailbox)) {

      $can_move_to_trash = false;

   }

   // Otherwise, check if trash folder exits and support sub-folders
   else {
      for ($i = 0; $i < count($boxes); $i++) {
         if ($boxes[$i]["unformatted"] == $trash_folder) {
            $can_move_to_trash = true;
            for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) {
               if (strtolower($boxes[$i]["flags"][$j]) == "noinferiors")
                  $can_move_to_trash = false;
            }
         }
      }
   }

   /** First create the top node in the tree **/
   for ($i = 0;$i < count($boxes);$i++) {
      if (($boxes[$i]["unformatted-dm"] == $mailbox) && 
(strlen($boxes[$i]["unformatted-dm"]) == strlen($mailbox))) {
         $foldersTree[0]["value"] = $mailbox;
         $foldersTree[0]["doIHaveChildren"] = false;
         continue;
      }
   }
   // Now create the nodes for subfolders of the parent folder
   // You can tell that it is a subfolder by tacking the mailbox delimiter
   //    on the end of the $mailbox string, and compare to that.
   $j = 0;
   for ($i = 0;$i < count($boxes);$i++) {
      if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox_no_dm . $dm)) == 
($mailbox_no_dm . $dm)) {
         addChildNodeToTree($boxes[$i]["unformatted"], 
$boxes[$i]["unformatted-dm"], $foldersTree);
      }
   }
//   simpleWalkTreePre(0, $foldersTree);

   /** Lets start removing the folders and messages **/
   if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they 
wish to move messages to the trash **/
      walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imap_stream, 
$foldersTree, $dm, $mailbox);
      walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
   } else { /** if they do NOT wish to move messages to the trash (or cannot)**/
      walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
   }

   /** Log out this session **/
   sqimap_logout($imap_stream);

   $location = get_location();
   header ("Location: 
".$phpgw->link('/squirrelmail/folders.php','success=delete'));

?>

====================================================
Index: folders_rename_do.php
<?php
   /**
    **  folders_rename_do.php
    **
    **  Copyright (c) 1999-2000 The SquirrelMail development team
    **  Licensed under the GNU GPL. For full terms see the file COPYING.
    **
    **  Does the actual renaming of files on the IMAP server.
    **  Called from the folders.php
    **
    **  $Id: folders_rename_do.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $
    **/

        // store the value of $mailbox, because it will overwriten
        $MAILBOX = $mailbox;
        $phpgw_info["flags"] = array(
                'noheader'    => 'True',
                'nonavbar'    => 'True',
                "currentapp" => "squirrelmail"
        );
        include("../header.inc.php");
        $mailbox = $MAILBOX;

        $phpgw->session->restore();

   if (!isset($strings_php))
      include(PHPGW_APP_ROOT . '/inc/strings.php');
   if (!isset($config_php))
      include(PHPGW_APP_ROOT . "/config/config.php");
   if (!isset($page_header_php))
      include(PHPGW_APP_ROOT . '/inc/page_header.php');
   if (!isset($imap_php))
      include(PHPGW_APP_ROOT . '/inc/imap.php');

   include(PHPGW_APP_ROOT . "/src/load_prefs.php");


   if($old_name == $new_name) {
      $location = get_location();
      header ("Location: $location/folders.php");
      exit;
   }

   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 
$imapPort, 0);
   $dm = sqimap_get_delimiter($imapConnection);

   if (strpos($orig, $dm))
      $old_dir = substr($orig, 0, strrpos($orig, $dm));
   else
      $old_dir = "";

   if ($old_dir != "")
      $newone = "$old_dir$dm$new_name";
   else
      $newone = "$new_name";

   $orig = sqStripSlashes($orig);
   $newone = sqStripSlashes($newone);

   fputs ($imapConnection, ". RENAME \"$orig\" \"$newone\"\r\n");
   $data = sqimap_read_data($imapConnection, ".", true, $a, $b);

   // Renaming a folder doesn't renames the folder but leaves you unsubscribed
   //    at least on Cyrus IMAP servers.
   if (isset($isfolder)) {
      $newone = $newone.$dm;
      $orig = $orig.$dm;
   }
   sqimap_unsubscribe($imapConnection, $orig);
   sqimap_subscribe($imapConnection, $newone);

        fputs ($imapConnection, "a001 LIST \"\" \"$newone*\"\r\n");
   $data = sqimap_read_data($imapConnection, "a001", true, $a, $b);
   for ($i=0; $i < count($data); $i++)
   {
      $name = find_mailbox_name($data[$i]);

      if ($name != $newone) // don't try to resubscribe when renaming ab to abc
      {
        sqimap_unsubscribe($imapConnection, $name);
        $name = substr($name, strlen($orig));
        $name = $newone . $name;
        sqimap_subscribe($imapConnection, $name);
      }
   }

   /** Log out this session **/
   sqimap_logout($imapConnection);
   header ("Location: 
".$phpgw->link('/squirrelmail/folders.php','success=rename'));

?>

====================================================
Index: search.php
<?php

   /* $Id: search.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $ */

        $MAILBOX = $mailbox;
        $phpgw_info['flags'] = array(
                'currentapp'              => 'squirrelmail',
                'enable_network_class'    => True,
                'enable_nextmatchs_class' => True
        );
        include('../header.inc.php');
        $mailbox = $MAILBOX;

        if (!isset($strings_php))
        {
                include(PHPGW_APP_ROOT  . '/inc/strings.php');
        }

        if (!isset($i18n_php))
        {
                include(PHPGW_APP_ROOT  . '/inc/i18n.php');
        }

        if (!isset($config_php))
        {
                include(PHPGW_APP_ROOT  . '/config/config.php');
        }

        if (!isset($page_header_php))
        {
                include(PHPGW_APP_ROOT  . '/inc/page_header.php');
        }

        if (!isset($imap_php))
        {
                include(PHPGW_APP_ROOT  . '/inc/imap.php');
        }

        if (!isset($imap_search_php))
        {
                include(PHPGW_APP_ROOT  . '/inc/imap_search.php');
        }

        if (!isset($array_php))
        {
                include(PHPGW_APP_ROOT  . '/inc/array.php');
        }

   include(PHPGW_APP_ROOT  . '/src/load_prefs.php');

//address@hidden: first parm has been supressed and global parm boxes is needed
   //displayPageHeader($imapConnection, $color, $mailbox);
   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 
$imapPort, 0);
   $boxes = sqimap_mailbox_list($imapConnection);
   displayPageHeader($color, $mailbox);

   do_hook("search_before_form");
   echo "<br>\n";
   echo "      <table width=95% align=center cellpadding=2 cellspacing=0 
border=0>\n";
   echo "      <tr><td bgcolor=\"$color[0]\">\n";
   echo "          <center><b>".lang("Search")."</b></center>\n";
   echo "      </td></tr>\n";
   echo "      <tr><td align=center>";

   echo "<FORM ACTION=\"" . $phpgw->link('/squirrelmail/search.php') . "\" 
NAME=s method=\"POST\">\n";
   echo "   <TABLE WIDTH=75%>\n";
   echo "     <TR>\n";
   echo "       <TD WIDTH=33%>\n";
   echo "         <TT><SMALL><SELECT NAME=\"mailbox\">";

//address@hidden: already needed above in displayPageHeader
   //$boxes = sqimap_mailbox_list($imapConnection);
   for ($i = 0; $i < count($boxes); $i++) {
          if (!in_array("noselect", $boxes[$i]["flags"])) {
         $box = $boxes[$i]["unformatted"];
         $box2 = replace_spaces($boxes[$i]["formatted"]);
         if ($mailbox == $box)
            echo "         <OPTION VALUE=\"$box\" SELECTED>$box2\n";
         else
            echo "         <OPTION VALUE=\"$box\">$box2\n";
      }
   }
   echo "         </SELECT></SMALL></TT>";
   echo "       </TD>\n";
   echo "        <TD ALIGN=\"CENTER\" WIDTH=33%>\n";
   if (!isset($what))
       $what = "";
   $what_disp = ereg_replace(",", " ", $what);
   $what_disp = str_replace("\\\\", "\\", $what_disp);
   $what_disp = str_replace("\\\"", "\"", $what_disp);
   $what_disp = str_replace("\"", "&quot;", $what_disp);
   echo "          <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what\" 
VALUE=\"$what_disp\">\n";
   echo "        </TD>";
   echo "       <TD ALIGN=\"RIGHT\" WIDTH=33%>\n";
   echo "         <SELECT NAME=\"where\">";

   if (isset($where) && $where == "BODY") echo "           <OPTION 
VALUE=\"BODY\" SELECTED>".lang("Body")."\n";
   else echo "           <OPTION VALUE=\"BODY\">".lang("Body")."\n";

   if (isset($where) && $where == "TEXT") echo "           <OPTION 
VALUE=\"TEXT\" SELECTED>".lang("Everywhere")."\n";
   else echo "           <OPTION VALUE=\"TEXT\">".lang("Everywhere")."\n";

   if (isset($where) && $where == "SUBJECT") echo "           <OPTION 
VALUE=\"SUBJECT\" SELECTED>".lang("Subject")."\n";
   else echo "           <OPTION VALUE=\"SUBJECT\">".lang("Subject")."\n";

   if (isset($where) && $where == "FROM") echo "           <OPTION 
VALUE=\"FROM\" SELECTED>".lang("From")."\n";
   else echo "           <OPTION VALUE=\"FROM\">".lang("From")."\n";

   if (isset($where) && $where == "CC") echo "           <OPTION VALUE=\"Cc\" 
SELECTED>".lang("Cc")."\n";
   else echo "           <OPTION VALUE=\"CC\">".lang("Cc")."\n";

   if (isset($where) && $where == "TO") echo "           <OPTION VALUE=\"TO\" 
SELECTED>".lang("To")."\n";
   else echo "           <OPTION VALUE=\"TO\">".lang("To")."\n";

   echo "         </SELECT>\n";
   echo "        </TD>\n";
   echo "       <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n";
   echo "         <INPUT TYPE=\"submit\" VALUE=\"".lang("Search")."\">\n";
   echo "       </TD>\n";
   echo "     </TR>\n";
   echo "   </TABLE>\n";
   echo "</FORM>";
   echo "</td></tr></table>";
   do_hook("search_after_form");
   if (isset($where) && $where && isset($what) && $what) {
      sqimap_mailbox_select($imapConnection, $mailbox);
      sqimap_search($imapConnection, $where, $what, $mailbox, $color);
   }
   do_hook("search_bottom");
   sqimap_logout ($imapConnection);

        $phpgw->common->phpgw_footer();
?>
</body></html>

====================================================
Index: read_body.php
<?php
  /**
   ** read_body.php
   **
   **  Copyright (c) 1999-2000 The SquirrelMail development team
   **  Licensed under the GNU GPL. For full terms see the file COPYING.
   **
   **  This file is used for reading the msgs array and displaying
   **  the resulting emails in the right frame.
   **
   **  $Id: read_body.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $
   **/

        $enablePHPGW = 1;

        // store the value of $mailbox, because it will overwriten
        $MAILBOX = $mailbox;
        $phpgw_info['flags'] = array('currentapp' => 'squirrelmail');
        include('../header.inc.php');
        $mailbox = $MAILBOX;

        $phpgw->session->restore();

        if (!isset($strings_php))
        {
                include(PHPGW_APP_ROOT . '/inc/strings.php');
        }

        if (!isset($config_php))
        {
                include(PHPGW_APP_ROOT . '/config/config.php');
        }

        if (!isset($page_header_php))
        {
                include(PHPGW_APP_ROOT . '/inc/page_header.php');
        }

        if (!isset($imap_php))
        {
                include(PHPGW_APP_ROOT . '/inc/imap.php');
        }

        if (!isset($mime_php))
        {
                include(PHPGW_APP_ROOT . '/inc/mime.php');
        }

        if (!isset($date_php))
        {
                include(PHPGW_APP_ROOT . '/inc/date.php');
        }

        if (!isset($url_parser_php))
        {
                include(PHPGW_APP_ROOT . '/inc/url_parser.php');
        }

        include(PHPGW_APP_ROOT . '/src/load_prefs.php');


        function createAddressbookButton($_addressString)
        {
                global $phpgw, $phpgw_info, $PHP_SELF, $QUERY_STRING;

                // if last char == , => remove it
                if (strrpos ($_addressString, ",")+1 == strlen($_addressString))
                {
                        $_addressString = substr($_addressString,0, 
strlen($_addressString)-1);
                }

                #print "$_addressString<br>";

                // "Lars Kneschke" <address@hidden>
                if (preg_match("/^\"(.*)\".*<(.*)>/i",$_addressString , 
$matches))
                {
                        $linkData = array
                        (
                                'menuaction'    => 
'addressbook.uiaddressbook.add_email',
                                'add_email'     => urlencode($matches[2]),
                                'name'          => urlencode($matches[1]),
                                'referer'       => 
urlencode($PHP_SELF.'?'.$QUERY_STRING)
                        );
                        $link = $phpgw->link('/index.php',$linkData);
                        $image = '<img src="'.PHPGW_IMAGES.
                                        '/sm_envelope.gif" width="10" height="8"
                                        alt="'.lang("Add to address book").'" 
border="0" align="absmiddle">';
                        return sprintf('&nbsp;<a href="%s">%s</a>',
                                        $link, $image);
                }
                // Lars Kneschke <address@hidden>
                elseif (preg_match("/^(.*).*<(.*)>/i",$_addressString , 
$matches))
                {
                        $linkData = array
                        (
                                'menuaction'    => 
'addressbook.uiaddressbook.add_email',
                                'add_email'     => urlencode($matches[2]),
                                'name'          => urlencode($matches[1]),
                                'referer'       => 
urlencode($PHP_SELF.'?'.$QUERY_STRING)
                        );
                        $link = $phpgw->link('/index.php',$linkData);
                        $image = '<img src="'.PHPGW_IMAGES.
                                        '/sm_envelope.gif" width="10" height="8"
                                        alt="'.lang("Add to address book").'" 
border="0" align="absmiddle">';
                        return sprintf('&nbsp;<a href="%s">%s</a>',
                                        $link, $image);
                }
                // address@hidden (Lars Kneschke)
                elseif 
(preg_match("/^(address@hidden).*\((.*)\)/i",$_addressString , $matches))
                {
                        $linkData = array
                        (
                                'menuaction'    => 
'addressbook.uiaddressbook.add_email',
                                'add_email'     => urlencode($matches[2]),
                                'name'          => urlencode($matches[1]),
                                'referer'       => 
urlencode($PHP_SELF.'?'.$QUERY_STRING)
                        );
                        $link = $phpgw->link('/index.php',$linkData);
                        $image = '<img src="'.PHPGW_IMAGES.
                                        '/sm_envelope.gif" width="10" height="8"
                                        alt="'.lang("Add to address book").'" 
border="0" align="absmiddle">';
                        return sprintf('&nbsp;<a href="%s">%s</a>',
                                        $link, $image);
                }
                // address@hidden
                elseif (preg_match("/^(address@hidden)/i",$_addressString , 
$matches))
                {
                        $linkData = array
                        (
                                'menuaction'    => 
'addressbook.uiaddressbook.add_email',
                                'add_email'     => urlencode($matches[1]),
                                'referer'       => 
urlencode($PHP_SELF.'?'.$QUERY_STRING)
                        );
                        $link = $phpgw->link('/index.php',$linkData);
                        $image = '<img src="'.PHPGW_IMAGES.
                                        '/sm_envelope.gif" width="10" height="8"
                                        alt="'.lang("Add to address book").'" 
border="0" align="absmiddle">';
                        return sprintf('&nbsp;<a href="%s">%s</a>',
                                        $link, $image);
                }
        }

        function fillDataArray($_imapConnection, $_passed_id, $_mailbox)
        {
                global $phpgw, $where, $what, $show_more, $sort, $startMessage, 
$show_more_cc;

                // $message contains all information about the message
                // including header and body
                $message = sqimap_get_message($_imapConnection, $_passed_id, 
$_mailbox);
                $data["passed_id"] = $passed_id = $_passed_id;
                $data["mailbox"] = $_mailbox;

                /** translate the subject and mailbox into url-able text **/
                $data["subject"] = $message->header->subject;
                $data["url_subj"] = 
urlencode(trim(sqStripSlashes($message->header->subject)));
                $data["urlMailbox"] = $urlMailbox = urlencode($_mailbox);
                $data["url_replyto"] = urlencode($message->header->replyto);
                $data["url_replytoall"] = urlencode($message->header->replyto);

                // If we are replying to all, then find all other addresses and
                // add them to the list.  Remove duplicates.
                // This is somewhat messy, so I'll explain:
                // 1) Take all addresses (from, to, cc) (avoid nasty join 
errors here)
                $url_replytoall_extra_addrs = 
array_merge(array($message->header->from),
                                                $message->header->to, 
$message->header->cc);

                // 2) Make one big string out of them
                $url_replytoall_extra_addrs = join(';', 
$url_replytoall_extra_addrs);

                // 3) Parse that into an array of addresses
                $url_replytoall_extra_addrs = 
parseAddrs($url_replytoall_extra_addrs);

                // 4) Make them unique -- weed out duplicates
                // (Coded for PHP 4.0.0)
                $url_replytoall_extra_addrs = 
array_keys(array_flip($url_replytoall_extra_addrs));
                $data["url_replytoall_extra_addrs"] = 
array_keys(array_flip($url_replytoall_extra_addrs));

                // 5) Remove the addresses we'll be sending the message 'to'
                $url_replytoall_avoid_addrs = 
parseAddrs($message->header->replyto);
                foreach ($url_replytoall_avoid_addrs as $addr)
                {
                        foreach (array_keys($url_replytoall_extra_addrs, $addr) 
as $key_to_delete)
                        {
                                
unset($url_replytoall_extra_addrs[$key_to_delete]);
                        }
                }
                $data["url_replytoall_avoid_addrs"] = 
$url_replytoall_extra_addrs;

                // 6) Smoosh back into one nice line
                $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);

                // 7) urlencode() it
                $data["url_replytoallcc"] = urlencode($url_replytoallcc);

                #$data["dateString"] = 
getLongDateString($message->header->date);
                $data["dateString"] = 
$phpgw->common->show_date($message->header->date);

                $ent_num = findDisplayEntity($message);
                $data["ent_num"] = findDisplayEntity($message);

                /** TEXT STRINGS DEFINITIONS **/
                $echo_more = lang("more");
                $echo_less = lang("less");

                /** FORMAT THE TO STRING **/
                $i = 0;
                $to_string = "";
                $to_ary = $message->header->to;
                while ($i < count($to_ary))
                {
                        $currentVal = decodeHeader($to_ary[$i]);
                        $to_ary[$i] = 
htmlspecialchars(decodeHeader($to_ary[$i]));

                        if ($to_string)
                                $to_string = 
"$to_string<BR>$to_ary[$i]".createAddressbookButton($currentVal);
                        else
                                $to_string = 
"$to_ary[$i]".createAddressbookButton($currentVal);

                        $i++;
                        if (count($to_ary) > 1)
                        {
                                if ($show_more == false)
                                {
                                        if ($i == 1)
                                        {
                                                if (isset($where) && 
isset($what))
                                                {
                                                        // from a search
                                                        $to_string = 
"$to_string&nbsp;(<A HREF=\"" . 
$phpgw->link('/squirrelmail/read_body.php',"mailbox=$urlMailbox&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what)."&show_more=1&show_more_cc=$show_more_cc")
 . "\">$echo_more</A>)";
                                                }
                                                else
                                                {
                                                        $to_string = 
"$to_string&nbsp;(<A HREF=\"" . 
$phpgw->link('/squirrelmail/read_body.php',"mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=1&show_more_cc=$show_more_cc")
 . "\">$echo_more</A>)";
                                                }
                                                $i = count($to_ary);
                                        }
                                }
                                else if ($i == 1)
                                {
                                        if (isset($where) && isset($what))
                                        {
                                                // from a search
                                                $to_string = 
"$to_string&nbsp;(<A HREF=\"" . 
$phpgw->link('/squirrelmail/read_body.php',"mailbox=$urlMailbox&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what)."&show_more=0&show_more_cc=$show_more_cc")
 . "\">$echo_less</A>)";
                                        }
                                        else
                                        {
                                                $to_string = 
"$to_string&nbsp;(<A HREF=\"" . 
$phpgw->link('/squirrelmail/read_body.php',"mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=0&show_more_cc=$show_more_cc")
 . "\">$echo_less</A>)";
                                        }
                                }
                        }
                }
                $data["to_string"] = $to_string;

                /** FORMAT THE CC STRING **/
                $i = 0;
                if (isset ($message->header->cc[0]) && 
trim($message->header->cc[0]))
                {
                        $cc_string = "";
                        $cc_ary = $message->header->cc;
                        while ($i < count(decodeHeader($cc_ary)))
                        {
                                $currentVal = decodeHeader($cc_ary[$i]);
                                $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
                                if ($cc_string)
                                        $cc_string = 
"$cc_string<BR>$cc_ary[$i]".createAddressbookButton($currentVal);
                                else
                                        $cc_string = 
"$cc_ary[$i]".createAddressbookButton($currentVal);

                                $i++;
                                if (count($cc_ary) > 1)
                                {
                                        if ($show_more_cc == false)
                                        {
                                                if ($i == 1)
                                                {
                                                        if (isset($where) && 
isset($what))
                                                        {
                                                                // from a search
                                                                $cc_string = 
"$cc_string&nbsp;(<A HREF=\"" . 
$phpgw->link('/squirrelmail/read_body.php',"mailbox=$urlMailbox&passed_id=$passed_id&what=".urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more")
 . "\">$echo_more</A>)";
                                                        }
                                                        else
                                                        {
                                                                $cc_string = 
"$cc_string&nbsp;(<A HREF=\"" . 
$phpgw->link('/squirrelmail/read_body.php',"mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more")
 . "\">$echo_more</A>)";
                                                        }
                                                        $i = count($cc_ary);
                                                }
                                        }
                                        else if ($i == 1)
                                        {
                                                if (isset($where) && 
isset($what))
                                                {
                                                        // from a search
                                                        $cc_string = 
"$cc_string&nbsp;(<A HREF=\"" . 
$phpgw->link('/squirrelmail/read_body.php',"mailbox=$urlMailbox&passed_id=$passed_id&what=".urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more")
 . "\">$echo_less</A>)";
                                                }
                                                else
                                                {
                                                        $cc_string = 
"$cc_string&nbsp;(<A HREF=\"" . 
$phpgw->link('/squirrelmail/read_body.php',"mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more")
 . "\">$echo_less</A>)";
                                                }
                                        }
                                }
                        }
                }
                $data["cc_string"] = $cc_string;
                /** make sure everything will display in HTML format **/
                $data["from_name"] = 
decodeHeader(htmlspecialchars($message->header->from));
                $data["from_name"] .= 
createAddressbookButton($message->header->from);
                $data["subject"] = 
decodeHeader(htmlspecialchars($message->header->subject));

                return $data;

        }

        // given an IMAP message id number, this will look it up in the cached 
and sorted msgs array and
        //    return the index.  used for finding the next and previous messages

        // returns the index of the next valid message from the array or -1 if 
not found
        function findNextMessage($_mailboxStatus, $_mailbox, 
$_currentArrayIndex)
        {
                $sortedList = $_mailboxStatus["$_mailbox"]["sortedList"];

                for ($i = 0; $i < count($sortedList); $i++)
                {
                        if ($sortedList[$i] == $_currentArrayIndex && 
$sortedList[$i+1])
                        {
                                #print (count($sortedList)-$i)-1;
                                #print "&nbsp;&nbsp;&nbsp;&nbsp;";
                                return $sortedList[$i+1];
                        }
                }
                return -1;
        }

        // returns the index of the previous message from the array or -1 if 
not found
        function findPreviousMessage($_mailboxStatus, $_mailbox, 
$_currentArrayIndex)
        {
                $sortedList = $_mailboxStatus["$_mailbox"]["sortedList"];

                for ($i = 0; $i < count($sortedList); $i++)
                {
                        if ($sortedList[$i] == $_currentArrayIndex && 
$sortedList[$i-1])
                        {
                                #print $i."&nbsp;|&nbsp;";
                                return $sortedList[$i-1];
                        }
                }
                #print "0&nbsp;|&nbsp;";
                return -1;
        }

        function viewMessageHeader($_data)
        {
                global $phpgw, $phpgw_info, $imapConnection, $startMessage, 
$show_more;

                $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
                $t->set_file(array('view_message' => 'view_message.tpl'));
                $t->set_block('view_message','message_header','message_header');
                $t->set_block('view_message','B_cc_data','B_cc_data');

                $t->set_var('th_bg', $phpgw_info['theme']['th_bg']);
                $t->set_var('row_on', $phpgw_info['theme']['row_on']);
                $t->set_var('row_off', $phpgw_info['theme']['row_off']);
                $t->set_var('bg01', $phpgw_info['theme']['bg01']);
                $t->set_var('bg02', $phpgw_info['theme']['bg02']);
                $t->set_var('bg03', $phpgw_info['theme']['bg03']);

                $t->set_var('lang_from', lang('from'));
                $t->set_var('lang_to', lang('to'));
                $t->set_var('lang_cc', lang('cc'));
                $t->set_var('lang_date', lang('date'));
                $t->set_var('lang_files', lang('files'));
                $t->set_var('lang_subject', lang('subject'));

                $t->set_var('from_data', $_data["from_name"]);
                $t->set_var('to_data_final', $_data["to_string"]);
                $t->set_var('subject_data', $_data["subject"]);
                $t->set_var('date_data', $_data["dateString"]);

                $urlMailbox = $_data["urlMailbox"];
                $where = $_data["where"];
                $what = $_data["what"];
                $passed_id = $_data["passed_id"];

                if (isset($where) && isset($what))
                {
                        // Got here from a search
                        $string = "<a href=\""
                        . 
$phpgw->link('/squirrelmail/read_body.php',"mailbox=$urlMailbox&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what)."&view_hdr=1")
 . "\">" . lang("View full header") . "</a>";
                }
                else
                {
                        $string =  "<a href=\""
                        . 
$phpgw->link('/squirrelmail/read_body.php',"mailbox=$urlMailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&view_hdr=1")
 . "\">" . lang("View full header") . "</a>";
                        $t->set_var('view_header', $string);
                }

                if ($_data["cc_string"])
                {
                        $t->set_var('cc_data_final',$_data["cc_string"]);
                        $cc_data = $t->parse('out','B_cc_data');
                        $t->set_var('cc_data',$cc_data);
                        $t->set_var('bg_date', $phpgw_info['theme']['row_off']);
                        $t->set_var('bg_subject', 
$phpgw_info['theme']['row_on']);
                }
                else
                {
                        $t->set_var('cc_data','');
                        $t->set_var('bg_date', $phpgw_info['theme']['row_on']);
                        $t->set_var('bg_subject', 
$phpgw_info['theme']['row_off']);
                }

                return $t->parse('out','message_header');
        }

        function viewMessageNavbar($_mailbox, $_mailboxStatus, $_data, 
$_currentArrayIndex, $_sort, $_startMessage)
        {
                global $phpgw, $phpgw_info, $imapConnection, $sent_folder;

                $svr_image_dir = PHPGW_IMAGES_DIR;

                $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
                $t->set_file(array('view_message' => 'view_message.tpl'));
                $t->set_block('view_message','message_navbar','message_navbar');
                #$t->set_block('view_message','column','column');

                $where = $_data["where"];
                $what = $_data["what"];
                $urlMailbox = $_data["urlMailbox"];
                $passed_id = $_data["passed_id"];
                $ent_num = $_data["ent_num"];
                $url_replyto = $_data["url_replyto"];
                $url_replytoall = $_data["url_replytoall"];
                $url_replytoallcc = $_data["url_replytoallcc"];
                $subject = $_data["subject"];
                $url_subj = $_data["url_subj"];

                if (isset($_where) && isset($_what))
                {
                        // search filter
                        
$t->set_var('link_messagelist',$phpgw->link('/squirrelmail/search.php',"where=".urlencode($where)."&what=".urlencode($what)."&mailbox=$urlMailbox"));
                        
$t->set_var('link_delete',$phpgw->link('/squirrelmail/src/delete_message.php',"mailbox=$urlMailbox&message=$passed_id&where=".urlencode($where)."&what=".urlencode($what)));
                        $t->set_var('left_arrow','');
                        $t->set_var('right_arrow','');
                }
                else
                {
                        
$t->set_var('link_messagelist',$phpgw->link('/squirrelmail/index.php',"sort=$_sort&startMessage=$_startMessage&mailbox=$urlMailbox"));
                        
$t->set_var('link_delete',$phpgw->link('/squirrelmail/src/delete_message.php',"mailbox=$urlMailbox&message=$passed_id&sort=$_sort&startMessage=$_startMessage"));

                        if ($_currentArrayIndex == -1)
                        {
                                $t->set_var('left_arrow',"<img border=\"0\" 
src=\"$svr_image_dir/left-grey.gif\" alt=\"".lang("no previous Message")."\" 
title=\"".lang("no previous Message")."\">");
                                $t->set_var('right_arrow',"<img border=\"0\" 
src=\"$svr_image_dir/right-grey.gif\" alt=\"".lang("no previous Message")."\" 
title=\"".lang("no previous Message")."\">");
                        }
                        else
                        {
                                $prev = findPreviousMessage($_mailboxStatus, 
$_mailbox, $_currentArrayIndex);
                                $next = findNextMessage($_mailboxStatus, 
$_mailbox, $_currentArrayIndex);

                                if ($prev != -1)
                                {
                                        #$message = 
sqimap_get_message_header($imapConnection, $prev, $mailbox);
                                        if($mailbox == $sent_folder)
                                                $hdr = sqimap_get_small_header 
($imapConnection, $prev, true);
                                        else
                                                $hdr = sqimap_get_small_header 
($imapConnection, $prev, false);
                                        $purl_subj = 
decodeHeader($hdr->subject);
                                        $leftArrow  = "<a href=\"" . 
$phpgw->link('/squirrelmail/read_body.php',"passed_id=$prev&mailbox=$urlMailbox&sort=$_sort&startMessage=$_startMessage&show_more=0")
 . "\">";
                                        $leftArrow .= "<img border=\"0\" 
src=\"$svr_image_dir/left.gif\" alt=\"$purl_subj\" title=\"$purl_subj\">";
                                        $leftArrow .= "</a>";
                                        $t->set_var('left_arrow',$leftArrow);
                                }
                                else
                                {
                                        $t->set_var('left_arrow',"<img 
border=\"0\" src=\"$svr_image_dir/left-grey.gif\" alt=\"".lang("no previous 
Message")."\" title=\"".lang("no previous Message")."\">");
                                }

                                if ($next != -1)
                                {
                                        #$message = 
sqimap_get_message_header($imapConnection, $next, $mailbox);
                                        if($mailbox == $sent_folder)
                                                $hdr = sqimap_get_small_header 
($imapConnection, $next, true);
                                        else
                                                $hdr = sqimap_get_small_header 
($imapConnection, $next, false);
                                        $nurl_subj = 
decodeHeader($hdr->subject);
                                        $rightArrow  = "<a href=\"" . 
$phpgw->link('/squirrelmail/read_body.php',"passed_id=$next&mailbox=$urlMailbox&sort=$_sort&startMessage=$_startMessage&show_more=0")
 . "\">";
                                        $rightArrow .= "<img border=\"0\" 
src=\"$svr_image_dir/right.gif\" alt=\"$nurl_subj\" title=\"$nurl_subj\">";
                                        $rightArrow .= "</a>";
                                        $t->set_var('right_arrow',$rightArrow);
                                }
                                else
                                {
                                        $t->set_var('right_arrow',"<img 
border=\"0\" src=\"$svr_image_dir/right-grey.gif\" alt=\"".lang("no next 
Message")."\" title=\"".lang("no next Message")."\">");
                                }
                        }
                }

                $linkData = array
                (
                        'menuaction'    => 'squirrelmail.uicompose.compose',
                        'mailbox'       => $urlMailbox
                );
                
$t->set_var('link_compose',$GLOBALS['phpgw']->link('/index.php',$linkData));

                $linkData = array
                (
                        'mailbox'       => $urlMailbox,
                        'startMessage'  => '1'
                );
                
$t->set_var("link_message_list",$GLOBALS['phpgw']->link('/squirrelmail/index.php',$linkData));
                $t->set_var('folder_name',$urlMailbox);
                $langArray = array
                        (
                                'lang_messagelist'      => lang('Message List'),
                                'lang_compose'          => lang('Compose'),
                                'lang_delete'           => lang('Delete'),
                                'lang_forward'          => lang('Forward'),
                                'lang_reply'            => lang('Reply'),
                                'lang_reply_all'        => lang('Reply All'),
                                'lang_back_to_folder'   => lang('back to 
folder'),
                                'app_image_path'        => PHPGW_IMAGES,
                                'link_reply'            => 
$phpgw->link('/squirrelmail/compose.php',"send_to=$url_replyto&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num"),
                                'link_reply_all'        => 
$phpgw->link('/squirrelmail/compose.php',"send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num"),
                                'link_forward'          => 
$phpgw->link('/squirrelmail/compose.php',"forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox&ent_num=$ent_num")
                        );

                $t->set_var('th_bg', $phpgw_info['theme']['navbar_bg']);
                $t->set_var($langArray);

                return $t->parse('out','message_navbar');
        }


// here we go!


        $imapConnection = sqimap_login($username, $key, $imapServerAddress, 
$imapPort, 0);
        sqimap_mailbox_select($imapConnection, $mailbox);
        do_hook("html_top");
        #displayPageHeader($color, $mailbox);


        if (isset($view_hdr))
        {
                fputs ($imapConnection, "a003 FETCH $passed_id 
BODY[HEADER]\r\n");
                $read = sqimap_read_data ($imapConnection, "a003", true, $a, 
$b);

                echo "<br>";
                echo "<table width=100% cellpadding=2 cellspacing=0 border=0 
align=center>\n";
                echo "   <TR><TD BGCOLOR=\"$color[9]\" WIDTH=100%><center><b>" 
. lang("Viewing full header") . "</b> - ";
                if (isset($where) && isset($what))
                {
                        // Got here from a search
                        echo "<a href=\"" . 
$phpgw->link('/squirrelmail/read_body.php',"mailbox=".urlencode($mailbox)."&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what))."\">";
                }
                else
                {
                        echo "<a href=\"" . 
$phpgw->link('/squirrelmail/read_body.php',"mailbox=".urlencode($mailbox)."&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more")
 . "\">";
                }
                echo "".lang("View message") . 
"</a></b></center></td></tr></table>\n";
                echo "<table width=99% cellpadding=2 cellspacing=0 border=0 
align=center>\n";
                echo "<tr><td>";

                $cnum = 0;
                for ($i=1; $i < count($read)-1; $i++)
                {
                        $line = htmlspecialchars($read[$i]);
                        if (eregi("^&gt;", $line))
                        {
                                $second[$i] = $line;
                                $first[$i] = "&nbsp;";
                                $cnum++;
                        }
                        else if (eregi("^[ |\t]", $line))
                        {
                                $second[$i] = $line;
                                $first[$i] = "";
                        }
                        else if (eregi("^([^:]+):(.+)", $line, $regs))
                        {
                                $first[$i] = $regs[1] . ":";
                                $second[$i] = $regs[2];
                                $cnum++;
                        }
                        else
                        {
                                $second[$i] = trim($line);
                                $first[$i] = "";
                        }
                }
                for ($i=0; $i < count($second); $i = $j)
                {
                        if (isset($first[$i])) $f = $first[$i];
                        if (isset($second[$i])) $s = nl2br($second[$i]);
                        $j = $i + 1;
                        while ($first[$j] == "" && $j < count($first))
                        {
                                $s .= "&nbsp;&nbsp;&nbsp;&nbsp;" . 
nl2br($second[$j]);
                                $j++;
                        }
                        parseEmail($s);

                        if (isset($f)) echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
                }
                echo "</td></tr></table>\n";
                echo "</body></html>";
                $phpgw->common->phpgw_footer();
                sqimap_logout($imapConnection);
                exit;
        }

        $currentArrayIndex = $passed_id;
        $data = fillDataArray($imapConnection, $passed_id, $mailbox);

        do_hook("read_body_top");

   echo "<TABLE CELLSPACING=0 WIDTH=100% BORDER=0 ALIGN=CENTER 
CELLPADDING=0>\n";
   echo "   <TR><TD>";

   print viewMessageNavbar($mailbox, $mailboxStatus, $data, $currentArrayIndex, 
$sort, $startMessage);

   echo "   </TD></TR>";
   echo "   <TR><TD CELLSPACING=0 WIDTH=100%>";

        print viewMessageHeader($data);

   do_hook("read_body_header");

   echo "   </TD></TR>";
   echo "</table>";
   echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=97% BORDER=0 ALIGN=CENTER 
CELLPADDING=0>\n";

   echo "   <TR><TD BGCOLOR=\"$color[4]\" WIDTH=100%>\n";
   echo "<BR>";

        if($header->phpgw_type[type]) {
                echo '<center><h1>THIS IS A 
phpGroupWare-'.strtoupper($header->phpgw_type[type]).' 
EMAIL</h1><hr></center><br>';
        }

   $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
   $body = formatBody($imapConnection, $message, $color, $wrap_at);

   echo $body;

        if($header->phpgw_type[type])
        {
                if(isset($header->phpgw_type[id]))
                {
                        $calendar_id = intval($header->phpgw_type[id]);
                        echo '<table align="center" width="100%"><tr><td 
align="center">';
                        
$phpgw->common->hook_single('email',$header->phpgw_type[type]);
                        echo '</td></tr></table>';
                }
        }

   echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=100% BORDER=0 ALIGN=CENTER 
CELLPADDING=0>\n";
   echo "   <TR><TD BGCOLOR=\"$color[9]\">&nbsp;</TD></TR>";
   echo "</TABLE>\n";

//address@hidden: inserted three next lines
   if (!isset($translated_setup) && !function_exists('translate_read_form') )
      include(PHPGW_APP_ROOT . "/inc/translate_setup.php");
   translate_read_form();

   do_hook("read_body_bottom");
   do_hook("html_bottom");
   sqimap_logout($imapConnection);

   $phpgw->common->phpgw_footer();
?>

====================================================
Index: preferences_translate.php
<?php
  /**************************************************************************\
  * phpGroupWare - E-Mail                                                    *
  * http://www.phpgroupware.org                                              *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

        /* $Id: preferences_translate.php,v 1.1 2005/05/05 00:56:40 skwashd Exp 
$ */

        $phpgw_info["flags"] = array(
                "currentapp" => "squirrelmail",
                "noheader" => True,
                "nonavbar" => True,
                "enable_nextmatchs_class" => True
        );

        include("../header.inc.php");

        if ($submit) {
                $phpgw->preferences->read_repository();
                $phpgw->preferences->add("squirrelmail","translate_server", 
$translate_server);
                $phpgw->preferences->add("squirrelmail","translate_location", 
$translate_location);
                $phpgw->preferences->add("squirrelmail","translate_show_read", 
$translate_show_read);
                $phpgw->preferences->add("squirrelmail","translate_show_send", 
$translate_show_send);
                
$phpgw->preferences->add("squirrelmail","translate_same_window", 
$translate_same_window);
                $phpgw->preferences->save_repository();
                Header("Location: " . $phpgw->link("/preferences/index.php"));
        }

        if (!isset($config_php))
                include(PHPGW_APP_ROOT . '/config/config.php');

        // preps
        $translate_server = 
$phpgw_info["user"]["preferences"]["squirrelmail"]["translate_server"];
        $translate_location = 
$phpgw_info["user"]["preferences"]["squirrelmail"]["translate_location"];
        $translate_show_read = 
$phpgw_info["user"]["preferences"]["squirrelmail"]["translate_show_read"];
        $translate_show_send = 
$phpgw_info["user"]["preferences"]["squirrelmail"]["translate_show_send"];
        $translate_same_window = 
$phpgw_info["user"]["preferences"]["squirrelmail"]["translate_same_window"];

        $translate_intro = '<ul>
           <li><b>Babelfish</b> -
               13 language pairs,
               maximum of 1000 characters translated,
               powered by Systran
               [ <a href="http://babelfish.altavista.com/";
               target="_blank">Babelfish</a> ]</li>
           <li><b>Go.com</b> -
               10 language pairs,
               maximum of 25 kilobytes translated,
               powered by Systran
               [ <a href="http://translator.go.com/";
               target="_blank">Translator.Go.com</a> ]</li>
           <li><b>Dictionary.com</b> -
               12 language pairs,
               no known limits,
               powered by Systran
               [ <a href="http://www.dictionary.com/translate";
               target="_blank">Dictionary.com</a> ]</li>
           <li><b>InterTran</b> -
               767 language pairs,
               no known limits,
               powered by Translation Experts\'s InterTran
               [ <a href="http://www.tranexp.com/";
               target="_blank">Translation Experts</a> ]</li>
           <li><b>GPLTrans</b> -
               8 language pairs,
               no known limits,
               powered by GPLTrans (free, open source)
               [ <a href="http://www.translator.cx/";
               target="_blank">GPLTrans</a> ]</li>
           <li><b>Free Translation</b> -
               10 language pairs,
               10 KBytes,
               rapid translations,
               [ <a href="http://www.freetranslation.com/";
               target="_blank">Free Translation</a> ]</li>
        </ul>';

        function TServerSelect($value, $Desc, $sel)
        {
               $val .= '<option value="' . $value . '"';
               if ($sel == $value) $val .= ' SELECTED';
               $val .= '>' . $Desc . "</option>\n";
               return $val;
        }
        $str = '<select name="translate_server">';
        $str .= TServerSelect('babelfish',      'Babelfish',    
$translate_server);
        $str .= TServerSelect('go',             'Go.com',       
$translate_server);
        $str .= TServerSelect('dictionary',     'Dictionary.com', 
$translate_server);
        $str .= TServerSelect('intertran',      'Intertran',    
$translate_server);
        $str .= TServerSelect('gpltrans',       'GPLTrans',     
$translate_server);
        $str .= TServerSelect('freetrans',      'FreeTrans',    
$translate_server);
        $str .= '</select>';
        $disp_translate_servers = $str;

        function TLocSelect($value, $Desc, $sel)
        {
               $val .= '<option value="' . $value . '"';
               if ($sel == $value) $val .= ' SELECTED';
               $val .= '>' . $Desc . "</option>\n";
               return $val;
        }
        $str = '<select name="translate_location">';
        $str .= TLocSelect('left',   lang('to the left'),   
$translate_location);
        $str .= TLocSelect('center', lang('in the center'), 
$translate_location);
        $str .= TLocSelect('right',  lang('to the right'),  
$translate_location);
        $str .= '</select>';
        $disp_translate_locations = $str;

        $str = '<input type=checkbox name="translate_show_read"';
        if ($translate_show_read) $str .=" CHECKED";
        $str .= '> When reading';
        $disp_translate_show_read = $str;

        $str = '<input type=checkbox name="translate_show_send"';
        if ($translate_show_send) $str .=" CHECKED";
        $str .= '> When composing';
        $disp_translate_show_send = $str;

        $str = '<input type=checkbox name="translate_same_window"';
        if ($translate_same_window) $str .=" CHECKED";
        $str .= '> Translate inside the SquirrelMail frames';
        $disp_translate_same_window = $str;


        // display and template
        $phpgw->common->phpgw_header();
        echo parse_navbar();

        if ($totalerrors) {
                echo "<p><center>" . $phpgw->common->error_list($errors) . 
"</center>";
        }

        $tmpl = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
        #$tmpl->set_unknowns('remove');

        $tmpl->set_file(array('body' => 'preferences_translate.tpl'));

        // var
        $var = Array
        (
                'th_bg'                 => $phpgw_info["theme"]["th_bg"],
                'tr_color1'             => $phpgw_info['theme']['row_on'],
                'tr_color2'             => $phpgw_info['theme']['row_off'],
                'link'                  => 
$phpgw->link('/squirrelmail/preferences_translate.php'),
                'translate_intro'       => $translate_intro,
                'translate_servers'     => $disp_translate_servers,
                'translate_locations'   => $disp_translate_locations,
                'translate_show_read'   => $disp_translate_show_read,
                'translate_show_send'   => $disp_translate_show_send,
                'translate_same_window' => $disp_translate_same_window,
        );

        $tmpl->set_var($var);

        // translations
        $translations = Array
        (
                'lang_translate_prefs'          => lang('Translation 
Preferences'),
                'lang_translation_server'       => lang('Translation server'),
                'lang_translation_location'     => lang('Translation location'),
                'lang_translation_show_read'    => lang('For received mail'),
                'lang_translation_show_send'    => lang('For mail to be send - 
not functional yet'),
                'lang_translation_same_window'  => lang('Same Window - not 
functional yet'),
                'lang_save'                     => lang('save'),
        );
        $tmpl->set_var($translations);

        $tmpl->pparse('out','body');

        $phpgw->common->phpgw_footer();
?>

====================================================
Index: index.php
<?php
   /**
    **  index.php
    **
    **  Copyright (c) 1999-2000 The SquirrelMail development team
    **  Licensed under the GNU GPL. For full terms see the file COPYING.
    **
    **  This is where the mailboxes are listed.  This controls most of what
    **  goes on in SquirrelMail.
    **
    **  $Id: index.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $
    **/

   $enablePHPGW = 1;

        // store the value of $mailbox, because it will overwriten
        $MAILBOX = $mailbox;
        $phpgw_info["flags"] = array("currentapp" => "squirrelmail", 
"enable_network_class" => True, "enable_nextmatchs_class" => True);
        include("../header.inc.php");
        $mailbox = $MAILBOX;

        $phpgw->session->restore();

   if (!isset($i18n_php))
      include(PHPGW_APP_ROOT . "/inc/i18n.php");
   if (!isset($strings_php))
      include(PHPGW_APP_ROOT . "/inc/strings.php");
   if (!isset($config_php))
      include(PHPGW_APP_ROOT . "/config/config.php");
   if (!isset($imap_php))
      include(PHPGW_APP_ROOT . "/inc/imap.php");
   if (!isset($date_php))
      include(PHPGW_APP_ROOT . "/inc/date.php");
   if (!isset($page_header_php))
      include(PHPGW_APP_ROOT . "/inc/page_header.php");
   if (!isset($array_php))
      include(PHPGW_APP_ROOT . "/inc/array.php");
   if (!isset($mime_php))
      include(PHPGW_APP_ROOT . "/inc/mime.php");
   if (!isset($mailbox_display_php))
      include(PHPGW_APP_ROOT . "/inc/mailbox_display.php");
   if (!isset($display_messages_php))
      include(PHPGW_APP_ROOT . "/inc/display_messages.php");
   if (!function_exists("ary_sort"))
      include(PHPGW_APP_ROOT . "/inc/array.php");

   if (!isset($tree_php))
      include(PHPGW_APP_ROOT . "/inc/tree.php");

   
/////////////////////////////////////////////////////////////////////////////////
   //
   // incoming variables from URL:
   //    $sort             Direction to sort by date
   //                         values:  0  -  descending order
   //                         values:  1  -  ascending order
   //    $startMessage     Message to start at
   //    $mailbox          Full Mailbox name
   //
   // incoming from cookie:
   //    $username         duh
   //    $key              pass
   //
   
/////////////////////////////////////////////////////////////////////////////////

        // If the page has been loaded without a specific mailbox,
        //   send them to the inbox
        if (!isset($mailbox))
        {
                $mailbox = "INBOX";
                $startMessage = 1;
        }

        // compensate for the UW vulnerability
        if ($imap_server_type == "uw" && strstr($mailbox, "../"))
        {
                $mailbox = "INBOX";
        }


        // how to sort the emails
        if (isset($newsort))
        {
                $sort = $newsort;
        }

        elseif(isset($mailboxStatus["$mailbox"]["sort"]))
        {
                $sort = $mailboxStatus["$mailbox"]["sort"];
        }
        else
        {
                $sort = 6;
        }

        // open a connection on the imap port (143)
        $imapConnection = sqimap_login($username, $key, $imapServerAddress, 
$imapPort, 0);

        /** If it was a successful login, lets load their preferences **/
        include(PHPGW_APP_ROOT . "/src/load_prefs.php");

        // store list of folders
        $boxes = sqimap_mailbox_list($imapConnection);
        $phpgw->session->register("boxes");

        sqimap_mailbox_select($imapConnection, $mailbox);


        // empty trash folder
        if (isset($expunge))
        {
                sqimap_mailbox_list($imapConnection);

                $mailbox = $trash_folder;
                $boxes = sqimap_mailbox_list($imapConnection);
                $dm = sqimap_get_delimiter($imapConnection);

                // According to RFC2060, a DELETE command should NOT remove 
inferiors (sub folders)
                //    so lets go through the list of subfolders and remove them 
before removing the
                //    parent.

                /** First create the top node in the tree **/
                for ($i = 0;$i < count($boxes);$i++)
                {
                        if (($boxes[$i]["unformatted"] == $mailbox) && 
(strlen($boxes[$i]["unformatted"]) == strlen($mailbox)))
                        {
                                $foldersTree[0]["value"] = $mailbox;
                                $foldersTree[0]["doIHaveChildren"] = false;
                                continue;
                        }
                }

                // Now create the nodes for subfolders of the parent folder
                // You can tell that it is a subfolder by tacking the mailbox 
delimiter
                //    on the end of the $mailbox string, and compare to that.
                $j = 0;
                for ($i = 0;$i < count($boxes);$i++)
                {
                        if (substr($boxes[$i]["unformatted"], 0, 
strlen($mailbox . $dm)) == ($mailbox . $dm))
                        {
                                addChildNodeToTree($boxes[$i]["unformatted"], 
$boxes[$i]["unformatted-dm"], $foldersTree);
                        }
                }

                // now lets go through the tree and delete the folders
                walkTreeInPreOrderEmptyTrash(0, $imapConnection, $foldersTree);
        }

        displayPageHeader($color, $mailbox);

        do_hook("right_main_after_header");

        if (! isset($use_mailbox_cache)) $use_mailbox_cache = 0;

        $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);

        showMessagesForMailbox($imapConnection, $mailbox, $numMessages, 
$startMessage, $sort, $color, $show_num, $use_mailbox_cache);

        sqimap_logout ($imapConnection);

        $phpgw->session->save();

        $phpgw->common->phpgw_footer();
?>

====================================================
Index: folders_subscribe.php
<?php
   /**
    **  folders_subscribe.php
    **
    **  Copyright (c) 1999-2000 The SquirrelMail development team
    **  Licensed under the GNU GPL. For full terms see the file COPYING.
    **
    **  Subscribe and unsubcribe form folders.
    **  Called from folders.php
    **
    **  $Id: folders_subscribe.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $
    **/

        // store the value of $mailbox, because it will overwriten
        $MAILBOX = $mailbox;
        $phpgw_info["flags"] = array(
                'noheader'    => 'True',
                'nonavbar'    => 'True',
                "currentapp" => "squirrelmail"
        );
        include("../header.inc.php");
        $mailbox = $MAILBOX;

        $phpgw->session->restore();

   if (!isset($strings_php))
      include(PHPGW_APP_ROOT . "/inc/strings.php");
   if (!isset($config_php))
      include(PHPGW_APP_ROOT . "/config/config.php");
   if (!isset($page_header_php))
      include(PHPGW_APP_ROOT . "/inc/page_header.php");
   if (!isset($imap_php))
      include(PHPGW_APP_ROOT . "/inc/imap.php");
   if (!isset($display_messages_php))
      include(PHPGW_APP_ROOT . "/inc/display_messages.php");

   include(PHPGW_APP_ROOT . "/src/load_prefs.php");

   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 
$imapPort, 0);
   $dm = sqimap_get_delimiter($imapConnection);

   $location = get_location();
   if ($method == "sub") {
      for ($i=0; $i < count($mailbox); $i++) {
         $mailbox[$i] = trim($mailbox[$i]);
         sqimap_subscribe ($imapConnection, $mailbox[$i]);
         header("Location: 
".$phpgw->link('/squirrelmail/folders.php','success=subscribe'));
      }
   } else {
      for ($i=0; $i < count($mailbox); $i++) {
         $mailbox[$i] = trim($mailbox[$i]);
         sqimap_unsubscribe ($imapConnection, $mailbox[$i]);
         header("Location: 
".$phpgw->link('/squirrelmail/folders.php','success=unsubscribe'));
      }
   }
   sqimap_logout($imapConnection);
   $phpgw->common->phpgw_footer();
?>


====================================================
Index: folders_rename_getname.php
<?php
   /**
    **  folders_rename_getname.php
    **
    **  Copyright (c) 1999-2000 The SquirrelMail development team
    **  Licensed under the GNU GPL. For full terms see the file COPYING.
    **
    **  Gets folder names and enables renaming
    **  Called from folders.php
    **
    **  $Id: folders_rename_getname.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $
    **/

        // store the value of $mailbox, because it will overwriten
        $MAILBOX = $mailbox;
        $phpgw_info["flags"] = array("currentapp" => "squirrelmail", 
"enable_network_class" => True, "enable_nextmatchs_class" => True);
        include("../header.inc.php");
        $mailbox = $MAILBOX;

        $phpgw->session->restore();

   if (!isset($strings_php))
      include(PHPGW_APP_ROOT . "/inc/strings.php");
   if (!isset($config_php))
      include(PHPGW_APP_ROOT . "/config/config.php");
   if (!isset($page_header_php))
      include(PHPGW_APP_ROOT . "/inc/page_header.php");
   if (!isset($imap_php))
      include(PHPGW_APP_ROOT . "/inc/imap.php");

   include(PHPGW_APP_ROOT . "/src/load_prefs.php");

   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 
$imapPort, 0);

   $dm = sqimap_get_delimiter($imapConnection);
   if (substr($old, strlen($old) - strlen($dm)) == $dm) {
      $isfolder = true;
      $old = substr($old, 0, strlen($old) - 1);
   }

   if (strpos($old, $dm)) {
      $old_name = substr($old, strrpos($old, $dm)+1, strlen($old));
      $old_parent = substr($old, 0, strrpos($old, $dm));
   } else {
      $old_name = $old;
      $old_parent = "";
   }

   $old_name = sqStripSlashes($old_name);

   displayPageHeader($imapConnection, $color, "None");
   echo "<br><TABLE align=center border=0 WIDTH=95% COLS=1>";
   echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
   echo lang("Rename a folder");
   echo "</B></TD></TR>";
   echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
   echo "<FORM 
ACTION=\"".$phpgw->link('/squirrelmail/folders_rename_do.php')."\" 
METHOD=\"POST\">\n";
   echo lang("New name:");
   echo "<br><B>$old_parent . </B><INPUT TYPE=TEXT SIZE=25 NAME=new_name 
VALUE=\"$old_name\"><BR>\n";
   if (isset($isfolder))
      echo "<INPUT TYPE=HIDDEN NAME=isfolder VALUE=\"true\">";
   printf("<INPUT TYPE=HIDDEN NAME=orig VALUE=\"%s\">\n", $old);
   printf("<INPUT TYPE=HIDDEN NAME=old_name VALUE=\"%s\">\n", $old_name);
   echo "<INPUT TYPE=SUBMIT VALUE=\"".lang("Submit")."\">\n";
   echo "</FORM><BR></TD></TR>";
   echo "</TABLE>";

   /** Log out this session **/
   sqimap_logout($imapConnection);

        $phpgw->common->phpgw_footer();

?>



====================================================
Index: preferences_display.php
<?php
  /**************************************************************************\
  * phpGroupWare - E-Mail                                                    *
  * http://www.phpgroupware.org                                              *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

  /* $Id: preferences_display.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $ */

  $phpgw_info["flags"] = array("currentapp" => "squirrelmail","noheader" => 
True, "nonavbar" => True,
                                                                                
                                                "enable_nextmatchs_class" => 
True);

  include("../header.inc.php");

  if ($submit) {
     $phpgw->preferences->read_repository();

     $phpgw->preferences->add("squirrelmail","wrapat");
     $phpgw->preferences->add("squirrelmail","editorsize");
     $phpgw->preferences->add("squirrelmail","button_new_location");

     $phpgw->preferences->save_repository();

     Header("Location: " . $phpgw->link("/preferences/index.php"));
  }

  $phpgw->common->phpgw_header();
  echo parse_navbar();

  if ($totalerrors) {
     echo "<p><center>" . $phpgw->common->error_list($errors) . "</center>";
  }

        $tmpl = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
        #$tmpl->set_unknowns('remove');

        $tmpl->set_file(array('body' => 'preferences_display.tpl'));

        $var = Array
        (
                'th_bg'                 => $phpgw_info["theme"]["th_bg"],
                'tr_color1'             => $phpgw_info['theme']['row_on'],
                'tr_color2'             => $phpgw_info['theme']['row_off'],
                'link'                  => 
$phpgw->link('/squirrelmail/preferences_display.php'),
                'wrapat'                => 
$phpgw_info["user"]["preferences"]["squirrelmail"]["wrapat"],
                'editorsize'            => 
$phpgw_info["user"]["preferences"]["squirrelmail"]["editorsize"],
                
$phpgw_info["user"]["preferences"]["squirrelmail"]["button_new_location"].'_selected'
 => 'SELECTED'
        );

        $tmpl->set_var($var);

        $translations = Array
        (
                'lang_save'             => lang('save'),
                'lang_wrap_at'          => lang('Wrap incoming text at'),
                'lang_size_editor'      => lang('Size of editor window'),
                'lang_location_button'  => lang('Location of buttons when 
composing'),
                'lang_option_1'         => lang('Before headers'),
                'lang_option_2'         => lang('Between headers and message 
body'),
                'lang_option_3'         => lang('After message body'),
                'lang_display_prefs'    => lang('Display Preferences')
        );
        $tmpl->set_var($translations);

        $tmpl->pparse('out','body');




        $phpgw->common->phpgw_footer(); ?>

====================================================
Index: preferences_email.php
<?php
  /**************************************************************************\
  * phpGroupWare - E-Mail                                                    *
  * http://www.phpgroupware.org                                              *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

        /* $Id: preferences_email.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $ */

        $phpgw_info["flags"] = array(
                'currentapp' => 'squirrelmail',
                'noheader'                => True,
                'nonavbar'                => True,
                'enable_nextmatchs_class' => True);

        include("../header.inc.php");

        // ----  Save Preferences to Repository  (if this is a submit)  -----
        if ($submit)
        {
                $phpgw->preferences->read_repository();

                // ----  Typical (Non-Custom) Preferences   -----

                
$phpgw->preferences->delete("squirrelmail","mainscreen_showmail");
                if ($mainscreen_showmail)
                {
                        
$phpgw->preferences->add("squirrelmail","mainscreen_showmail");
                }

                $phpgw->preferences->add("email","default_sorting");

                /* email sig must not have  '  nor  "  in it, as they screw up 
the preferences in class session
                    not an sql error, but the core bug lies somewhere in 
session caching */
                if (!is_object($GLOBALS['phpgw']->msg))
                {
                        $GLOBALS['phpgw']->msg = CreateObject('email.mail_msg');
                }

                if ($email_sig != '')
                {
                        /* get rid of the escape \ that magic_quotes HTTP POST 
will add, " becomes \" and  '  becomes  \'  */
                        $email_sig_clean = 
$GLOBALS['phpgw']->msg->stripslashes_gpc($email_sig);
                        /*// replace  '  and  "  with htmlspecialchars */
                        $email_sig_clean = 
$GLOBALS['phpgw']->msg->html_quotes_encode($email_sig_clean);
                        
$phpgw->preferences->add("email","email_sig",$email_sig_clean);
                }
                else
                {
                        // have it set, but be empty
                        $phpgw->preferences->add("email","email_sig");
                }

                // ----  Custom Preferences   -----
                // differ from account defaults set by administrator, should be 
unset if not using custom prefs
                $phpgw->preferences->delete("email","use_custom_settings");
                if (! $use_custom_settings)
                {
                        $phpgw->preferences->delete("email","userid");
                        $phpgw->preferences->delete("email","passwd");
                        $phpgw->preferences->delete("email","address");
                        $phpgw->preferences->delete("email","mail_server");
                        $phpgw->preferences->delete("email","mail_server_type");
                        $phpgw->preferences->delete("email","imap_server_type");
                        $phpgw->preferences->delete("email","mail_folder");
                }
                else
                {
                        $phpgw->preferences->add("email","use_custom_settings");
                        if ($userid)
                        {
                                $phpgw->preferences->add("email","userid");
                        }
                        else
                        {
                                // should probably be an error message here
                                $phpgw->preferences->delete("email","userid");
                        }
                        if ($passwd)
                        {
                                // INTERIM WORKAROUND: requires NO change to 
phpgwapi
                                // there were multiple problems with previous 
custom email passwd handling
                                //echo 'in pref page b4 strip: '.$passwd.'<br>';
                                $encrypted_passwd = 
$phpgw->msg->stripslashes_gpc($passwd);
                                //echo 'in pref page after strip: 
'.$encrypted_passwd.'<br>';
                                $encrypted_passwd = 
$phpgw->msg->encrypt_email_passwd($encrypted_passwd);
                                //echo 'encrypted_passwd: 
'.$encrypted_passwd.'<br>';
                                
$phpgw->preferences->add("email","passwd",$encrypted_passwd);
                                //$test_str = 'a test string';
                                //echo 'test_str before base64 decode: 
'.$test_str.'<br>';
                                //$test_str = base64_decode($test_str);
                                //echo 'test_str after base64 decode: 
'.$test_str.'<br>';

                                /* // CURRENT: does not need class common 
change,
                                // BUT CURRENT CODE IS BROKEN - waiting for api 
change to implement the above fix
                                //  get rid of the escape \ that magic_quotes 
HTTP POST will add, " becomes \" and  '  becomes  \'
                                $encrypted_passwd = 
$phpgw->msg->stripslashes_gpc($passwd);
                                $encrypted_passwd = 
$phpgw->common->encrypt($encrypted_passwd);
                                
$phpgw->preferences->add("email","passwd",$encrypted_passwd); */
                        }
                        else
                        {
                                // is not specified, LEAVE PASSWD ALONE, retain 
previous setting
                        }
                        if ($address)
                        {
                                $phpgw->preferences->add("email","address");
                        }
                        else
                        {
                                // should probably be an error message here
                                $phpgw->preferences->delete("email","address");
                        }
                        if ($mail_server)
                        {
                                $phpgw->preferences->add("email","mail_server");
                        }
                        else
                        {
                                // should probably be an error message here
                                
$phpgw->preferences->delete("email","mail_server");
                        }
                        if ($mail_server_type)
                        {
                                
$phpgw->preferences->add("email","mail_server_type");
                        }
                        else
                        {
                                // should probably be an error message here
                                
$phpgw->preferences->delete("email","mail_server_type");
                        }
                        if ($imap_server_type)
                        {
                                
$phpgw->preferences->add("email","imap_server_type");
                        }
                        else
                        {
                                // if ( (mail_server_type=='imap') || 
(mail_server_type=='imaps') ) then
                                // should probably be an error message here
                                
$phpgw->preferences->delete("email","imap_server_type");
                        }
                        if ($mail_folder)
                        {
                                $phpgw->preferences->add("email","mail_folder");
                        }
                        else
                        {
                                // if (imap_server_type=='UW-Maildir')  then
                                // should probably be an error message here
                                
$phpgw->preferences->delete("email","mail_folder");
                        }
                }

                $phpgw->preferences->save_repository();

                Header("Location: " . $phpgw->link("/preferences/index.php"));
        }

// ----  Show The Preferences Page   -----
        $phpgw->common->phpgw_header();
        echo parse_navbar();

        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
        $t->set_file(array(
                'T_preferences_out' => 'preferences_email.tpl'
        ));

        if ($totalerrors)
        {
                //echo "<p><center>" . $phpgw->common->error_list($errors) . 
"</center>";
                $pref_errors = '<p><center>"' 
.$phpgw->common->error_list($errors) .'"</center></p>';
        }
        else
        {
                $pref_errors = '';
        }

        $t->set_var('pref_errors',$pref_errors);
        $t->set_var('page_title',lang("E-Mail preferences"));

        // setup the form
        
$t->set_var('form_action',$phpgw->link('/squirrelmail/preferences_email.php'));
        // the "table header" row color
        $t->set_var('th_bg',$phpgw_info["theme"]["th_bg"]);

// ----  Typical (Non-Custom) Settings - Fill in HTML form -----
        // row1 = Email Sig
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        $t->set_var('bg_row1',$tr_color);
        $t->set_var('email_sig_blurb',lang("email signature"));
        $t->set_var('email_sig_textarea_name','email_sig');
        
//$t->set_var('email_sig_textarea_content',rawurldecode($phpgw_info["user"]["preferences"]["email"]["email_sig"]));
        
$t->set_var('email_sig_textarea_content',$phpgw_info["user"]["preferences"]["email"]["email_sig"]);

        // row2 = Sort Order
        // old_new means "lowest to highest", and new_old means "highest to 
lowest", which is imap-speak for reverse sorting
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        
$default_order_selected[$phpgw_info["user"]["preferences"]["email"]["default_sorting"]]
 = " selected";
        $sorting_select_options =
                 '<option value="old_new"' .$default_order_selected["old_new"] 
.'>oldest -> newest</option>' ."\n"
                .'<option value="new_old"' .$default_order_selected["new_old"] 
.'>newest -> oldest</option>' ."\n";
        $t->set_var('bg_row2',$tr_color);
        $t->set_var('sorting_blurb',lang("Default sorting order"));
        $t->set_var('sorting_select_name','default_sorting');
        $t->set_var('sorting_select_options',$sorting_select_options);

        // row3 = show sender's email address with name options
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        
$show_addresses_selected[$phpgw_info["user"]["preferences"]["email"]["show_addresses"]]
 = " selected";
        $show_addresses_select_options =
                 '<option value="none"' .$show_addresses_selected["none"] .'>' 
.lang('none') .'</option>' ."\n"
                .'<option value="from"' .$show_addresses_selected["from"] .'>' 
.lang('From') .'</option>' ."\n"
                .'<option value="replyto"' .$show_addresses_selected["replyto"] 
.'>' .lang('ReplyTo') .'</option>' ."\n";
        $t->set_var('bg_row3',$tr_color);
        $t->set_var('show_addresses_blurb',lang("Show sender's email address 
with name"));
        $t->set_var('show_addresses_select_name','show_addresses');
        
$t->set_var('show_addresses_select_options',$show_addresses_select_options);

        // row4 = show new messages on  main screen
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        if 
($phpgw_info["user"]["preferences"]["squirrelmail"]["mainscreen_showmail"])
        {
                $mainscreen_showmail_checked = 'checked';
        }
        else
        {
                $mainscreen_showmail_checked = '';
        }
        $t->set_var('bg_row4',$tr_color);
        $t->set_var('mainscreen_showmail_blurb',lang("show new messages on main 
screen"));
        $t->set_var('mainscreen_showmail_checkbox_name','mainscreen_showmail');
        $t->set_var('mainscreen_showmail_checkbox_value','True');
        $t->set_var('mainscreen_showmail_checked',$mainscreen_showmail_checked);

        // row5 = Send deleted messages to the trash
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        if ($phpgw_info["user"]["preferences"]["email"]["use_trash_folder"])
        {
                $use_trash_folder_checked = 'checked';
        }
        else
        {
                $use_trash_folder_checked = '';
        }
        $t->set_var('bg_row5',$tr_color);
        $t->set_var('use_trash_folder_blurb',lang("Send deleted messages to the 
trash"));
        $t->set_var('use_trash_folder_checkbox_name','use_trash_folder');
        $t->set_var('use_trash_folder_checkbox_value','True');
        $t->set_var('use_trash_folder_checked',$use_trash_folder_checked);

        // next section: Custom Email Settings
        $t->set_var('section_title',lang("Custom Email settings"));

// ----  Custom Settings - Fill in HTML form -----
        // row6 = use custon settings
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        if ($phpgw_info["user"]["preferences"]["email"]["use_custom_settings"])
        {
                $use_custom_settings_checked = 'checked';
        }
        else
        {
                $use_custom_settings_checked = '';
        }
        $t->set_var('bg_row6',$tr_color);
        $t->set_var('use_custom_settings_blurb',lang("Use custom settings") .' 
- ' .lang("Non-Standard"));
        $t->set_var('use_custom_settings_checkbox_name','use_custom_settings');
        $t->set_var('use_custom_settings_checkbox_value','True');
        $t->set_var('use_custom_settings_checked',$use_custom_settings_checked);

        // row7 = Email Account Name
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        $t->set_var('bg_row7',$tr_color);
        $t->set_var('userid_blurb',lang("Email Account Name"));
        $t->set_var('userid_text_name','userid');
        
$t->set_var('userid_text_value',$phpgw_info["user"]["preferences"]["email"]["userid"]);

        // row8 = Email Password
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        $t->set_var('bg_row8',$tr_color);
        $t->set_var('passwd_blurb',lang("Email Password"));
        $t->set_var('passwd_text_name','passwd');
        // FIXME: bug
        $t->set_var('passwd_text_value','');

        // row9 = Email Address
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        $t->set_var('bg_row9',$tr_color);
        $t->set_var('address_blurb',lang("Email address"));
        $t->set_var('address_text_name','address');
        
$t->set_var('address_text_value',$phpgw_info["user"]["preferences"]["email"]["address"]);

        // row10 = Mail Server
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        $t->set_var('bg_row10',$tr_color);
        $t->set_var('mail_server_blurb',lang("Mail Server"));
        $t->set_var('mail_server_text_name','mail_server');
        
$t->set_var('mail_server_text_value',$phpgw_info["user"]["preferences"]["email"]["mail_server"]);

        // row11 = Mail Server type
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        
$mail_server_type_selected[$phpgw_info["user"]["preferences"]["email"]["mail_server_type"]]
 = " selected";
        $mail_server_type_select_options =
                 '<option value="imap"' .$mail_server_type_selected["imap"] 
.'>IMAP</option>' ."\n"
                .'<option value="pop3"' .$mail_server_type_selected["pop3"] 
.'>POP-3</option>' ."\n"
                .'<option value="imaps"' .$mail_server_type_selected["imaps"] 
.'>IMAPS</option>' ."\n"
                .'<option value="pop3s"' .$mail_server_type_selected["pop3s"] 
.'>POP-3S</option>' ."\n";
        $t->set_var('bg_row11',$tr_color);
        $t->set_var('mail_server_type_blurb',lang("Mail Server type"));
        $t->set_var('mail_server_type_select_name','mail_server_type');
        
$t->set_var('mail_server_type_select_options',$mail_server_type_select_options);

        // row12 = IMAP Server Type
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        
$imap_server_type_selected[$phpgw_info["user"]["preferences"]["email"]["imap_server_type"]]
 = " selected";
        $imap_server_type_select_options =
                 '<option value="Cyrus"' .$imap_server_type_selected["Cyrus"] 
.'>Cyrus or Courier</option>' ."\n"
                .'<option value="UWash"' .$imap_server_type_selected["UWash"] 
.'>UWash</option>' ."\n"
                .'<option value="UW-Maildir"' 
.$imap_server_type_selected["UW-Maildir"] .'>UW-Maildir</option>' ."\n";
        $t->set_var('bg_row12',$tr_color);
        $t->set_var('imap_server_type_blurb',lang("IMAP Server Type") .' - ' 
.lang("If Applicable"));
        $t->set_var('imap_server_type_select_name','imap_server_type');
        
$t->set_var('imap_server_type_select_options',$imap_server_type_select_options);

        // row13 = Mail Folder(UW-Maildir)
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        $t->set_var('bg_row13',$tr_color);
        $t->set_var('mail_folder_blurb',lang("Mail Folder(UW-Maildir)"));
        $t->set_var('mail_folder_text_name','mail_folder');
        
$t->set_var('mail_folder_text_value',$phpgw_info["user"]["preferences"]["email"]["mail_folder"]);

        // the submit button for the form
        $t->set_var('btn_submit_name','submit');
        $t->set_var('btn_submit_value',lang("submit"));

        $t->pparse('out','T_preferences_out');

        $phpgw->common->phpgw_footer();
?>

====================================================
Index: preferences_index_order.php
<?php
  /**************************************************************************\
  * phpGroupWare - E-Mail                                                    *
  * http://www.phpgroupware.org                                              *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

  /* $Id: preferences_index_order.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $ */

        // store the value of $mailbox, because it will overwriten
        $MAILBOX = $mailbox;

        $phpgw_info["flags"] = array("currentapp" => "squirrelmail","noheader" 
=> True, "nonavbar" => True,
                "enable_nextmatchs_class" => True, "enable_network_class" => 
True);

        include("../header.inc.php");

        $mailbox = $MAILBOX;

        $phpgw->common->phpgw_header();
        echo parse_navbar();

        if ($totalerrors)
        {
                echo "<p><center>" . $phpgw->common->error_list($errors) . 
"</center>";
        }

        include "src/load_prefs.php";

        $available = array
                (
                        '1'     => lang("Checkbox"),
                        '2'     => lang("From"),
                        '3'     => lang("Date"),
                        '4'     => lang("Subject"),
                        '5'     => lang("Flags"),
                        '6'     => lang("Size")
                );

        if (! isset($method)) { $method = ""; }

        if ($method == "up" && $num > 1)
        {
                $prev = $num-1;
                $tmp = $index_order[$prev];
                $index_order[$prev] = $index_order[$num];
                $index_order[$num] = $tmp;
        }
        else if ($method == "down" && $num < count($index_order))
        {
                $next = $num++;
                $tmp = $index_order[$next];
                $index_order[$next] = $index_order[$num];
                $index_order[$num] = $tmp;
        }
        else if ($method == "remove" && $num)
        {
                for ($i=1; $i < 8; $i++)
                {
                        $phpgw->preferences->delete("squirrelmail","order$i");
                }
                $phpgw->preferences->save_repository();
                for ($j=1,$i=1; $i <= count($index_order); $i++)
                {
                        if ($i != $num)
                        {
                                $new_ary[$j] = $index_order[$i];
                                $j++;
                        }
                }
                $index_order = array();
                $index_order = $new_ary;
                if (count($index_order) < 1)
                {
                        include "src/load_prefs.php";
                }
        }
        else if ($method == "add" && $add)
        {
                $index_order[count($index_order)+1] = $add;
        }

        if ($method)
        {
                for ($i=1; $i <= count($index_order); $i++)
                {
                        $phpgw->preferences->add("squirrelmail","order$i", 
$index_order[$i]);
                }
                $phpgw->preferences->save_repository();
        }

        $colors = Array
        (
                '0'     => $phpgw_info['theme']['row_on'],
                '1'     => $phpgw_info['theme']['row_off']
        );


        if (count($index_order))
        {
                for ($i=1; $i <= count($index_order); $i++)
                {
                        $tmp = $index_order[$i];
                        $tableRows .= sprintf("<tr 
bgcolor=\"%s\">",$colors[$i%2]);
                        $link = 
$phpgw->link('/squirrelmail/preferences_index_order.php',"method=up&num=$i");
                        $tableRows .= "<td><small><a href=\"$link\">". 
lang("up") ."</a></small></td>\n";
                        $tableRows .= "<td><small>&nbsp;|&nbsp;</small></td>\n";
                        $link = 
$phpgw->link('/squirrelmail/preferences_index_order.php',"method=down&num=$i");
                        $tableRows .= "<td><small><a href=\"$link\">". 
lang("down") . "</a></small></td>\n";
                        $tableRows .= "<td><small>&nbsp;|&nbsp;</small></td>\n";
                        $tableRows .= "<td>";
                        // Always show the subject
                        if ($tmp != 4)
                        {
                                $link = 
$phpgw->link('/squirrelmail/preferences_index_order.php',"method=remove&num=$i");
                                $tableRows .= "<small><a href=\"$link\">" . 
lang("remove") . "</a></small>";
                        }
                        $tableRows .= "</td>\n";
                        $tableRows .= "<td><small>&nbsp;-&nbsp;</small></td>\n";
                        $tableRows .= "<td>" . $available[$tmp] . "</td>\n";
                        $tableRows .= "</tr>\n";
                }
        }

        if (count($index_order) != count($available))
        {
                $options = "<select name=add>\n";
                for ($i=1; $i <= count($available); $i++)
                {
                        $found = false;
                        for ($j=1; $j <= count($index_order); $j++)
                        {
                                if ($index_order[$j] == $i)
                                {
                                        $found = true;
                                }
                        }
                        if (!$found)
                        {
                                $options .= "<option 
value=$i>$available[$i]</option>\n";
                        }
                }
                $options .= "</select>\n";
                $options .= "<input type=hidden value=add name=method>\n";
                $options .= sprintf("<input type=submit value=\"%s\" 
name=\"submit\">\n",lang('add'));
        }

        $tmpl = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
        #$tmpl->set_unknowns('remove');

        $tmpl->set_file(array('body' => 'preferences_index_order.tpl'));

        $var = Array
        (
                'th_bg'                 => $phpgw_info["theme"]["th_bg"],
                'tr_color1'             => $phpgw_info['theme']['row_on'],
                'tr_color2'             => $phpgw_info['theme']['row_off'],
                'link'                  => 
$phpgw->link('/squirrelmail/preferences_index_order.php'),
                'link_back'             => 
$phpgw->link('/preferences/index.php'),
                'tablerows'             => $tableRows,
                'options'               => $options
        );

        $tmpl->set_var($var);

        $translations = Array
        (
                'lang_return'           => lang('Return to options page'),
                'lang_index_order'      => lang('Index Order'),
                'lang_description'      => lang("index_what_is")
        );
        $tmpl->set_var($translations);

        $tmpl->pparse('out','body');

        $phpgw->common->phpgw_footer();
?>

====================================================
Index: preferences_highlight.php
<?php
  /**************************************************************************\
  * phpGroupWare - E-Mail                                                    *
  * http://www.phpgroupware.org                                              *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

  /* $Id: preferences_highlight.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $ */

// store the value of $mailbox, because it will overwriten
        $MAILBOX = $mailbox;

        $phpgw_info["flags"] = array("currentapp" => "squirrelmail","noheader" 
=> True, "nonavbar" => True,
                "enable_nextmatchs_class" => True, "enable_network_class" => 
True);

        include("../header.inc.php");

        $mailbox = $MAILBOX;


        $phpgw->common->phpgw_header();
        echo parse_navbar();

        if ($totalerrors)
        {
                echo "<p><center>" . $phpgw->common->error_list($errors) . 
"</center>";
        }

        include "src/load_prefs.php";

        if (! isset($action))
                $action = '';

        if (! isset($message_highlight_list))
                $message_highlight_list = array();

        if ($action == "delete" && isset($theid))
        {
                removePref($data_dir, $username, "highlight$theid");
                $phpgw->preferences->delete("squirrelmail", "highlight$theid");
                $phpgw->preferences->save_repository();
        }
        else if ($action == "save")
        {
                if (!$theid) $theid = 0;
                $identname = ereg_replace(",", " ", $identname);
                $identname = str_replace("\\\\", "\\", $identname);
                $identname = str_replace("\\\"", "\"", $identname);
                $identname = str_replace("\"", "&quot;", $identname);
                if ($color_type == 1)
                        $newcolor = $newcolor_choose;
                else
                        $newcolor = $newcolor_input;

                $newcolor = ereg_replace(",", "", $newcolor);
                $newcolor = ereg_replace("#", "", $newcolor);
                $newcolor = "$newcolor";
                $value = ereg_replace(",", " ", $value);
                $value = str_replace("\\\\", "\\", $value);
                $value = str_replace("\\\"", "\"", $value);
                $value = str_replace("\"", "&quot;", $value);

                #setPref($data_dir, $username, "highlight$theid", 
$identname.",".$newcolor.",".$value.",".$match_type);
                $phpgw->preferences->add("squirrelmail","highlight$theid", 
$identname.",".$newcolor.",".$value.",".$match_type);
                $phpgw->preferences->save_repository();
                $message_highlight_list[$theid]["name"] = $identname;
                $message_highlight_list[$theid]["color"] = $newcolor;
                $message_highlight_list[$theid]["value"] = $value;
                $message_highlight_list[$theid]["match_type"] = $match_type;
        }

        include "src/load_prefs.php";

#       $tmpl = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
        #$tmpl->set_unknowns('remove');

#       $tmpl->set_file(array('body' => 'preferences_index_order.tpl'));

        $var = Array
        (
                'th_bg'                 => $phpgw_info["theme"]["th_bg"],
                'tr_color1'             => $phpgw_info['theme']['row_on'],
                'tr_color2'             => $phpgw_info['theme']['row_off'],
                'link'                  => 
$phpgw->link('/squirrelmail/preferences_index_order.php'),
                'link_back'             => 
$phpgw->link('/preferences/index.php'),
                'tablerows'             => $tableRows,
                'options'               => $options
        );

#       $tmpl->set_var($var);

        $translations = Array
        (
                'lang_return'           => lang('Return to options page'),
                'lang_description'      => lang("The index order is the order 
that the columns are arranged in the message index.  You can add, remove, and 
move columns around to customize them to fit your needs.")
        );
#       $tmpl->set_var($translations);

#       $tmpl->pparse('out','body');
?>
   <br>

<p><b><?php echo lang("Message Highlighting"); ?></b><hr><p>


<?php
   echo "<br><center>[<a href=\"". 
$phpgw->link('/squirrelmail/preferences_highlight.php','action=add')."\">" . 
lang("New") . "</a>]";
   echo " - [<a href=\"". 
$phpgw->link('/preferences/index.php')."\">".lang("Done")."</a>]</center><br>\n";
   if (count($message_highlight_list) >= 1) {
      echo "<table border=0 cellpadding=3 cellspacing=0 align=center 
width=80%>\n";
      for ($i=0; $i < count($message_highlight_list); $i++) {
         echo "<tr>\n";
         echo "   <td width=1% bgcolor=" . $color[4] . ">\n";
         echo "<nobr><small>[<a 
href=\"".$phpgw->link('/squirrelmail/preferences_highlight.php',"action=edit&theid=$i")."\">"
 . lang("Edit") . "</a>]&nbsp;[<a 
href=\"".$phpgw->link('/squirrelmail/preferences_highlight.php',"action=delete&theid=$i")."\">".lang("Delete")."</a>]</small></nobr>\n";
         echo "   </td>";
         echo "   <td bgcolor=" . $message_highlight_list[$i]["color"] . ">\n";
         echo "      " . $message_highlight_list[$i]["name"];
         echo "   </td>\n";
         echo "   <td bgcolor=" . $message_highlight_list[$i]["color"] . ">\n";
         echo "      ".$message_highlight_list[$i]["match_type"]." = " . 
$message_highlight_list[$i]["value"];
         echo "   </td>\n";
         echo "</tr>\n";
      }
      echo "</table>\n";
      echo "<br>\n";
   } else {
      echo "<center>" . lang("No highlighting is defined") . "</center><br>\n";
      echo "<br>\n";
   }
   if ($action == "edit" || $action == "add") {
      if (!isset($theid)) $theid = count($message_highlight_list);
          $message_highlight_list[$theid] = array();

      $color_list[0] = "4444aa";
      $color_list[1] = "44aa44";
      $color_list[2] = "aaaa44";
      $color_list[3] = "44aaaa";
      $color_list[4] = "aa44aa";
      $color_list[5] = "aaaaff";
      $color_list[6] = "aaffaa";
      $color_list[7] = "ffffaa";
      $color_list[8] = "aaffff";
      $color_list[9] = "ffaaff";
      $color_list[10] = "aaaaaa";
      $color_list[11] = "bfbfbf";
      $color_list[12] = "dfdfdf";
      $color_list[13] = "ffffff";

      $selected_input = "";

      for ($i=0; $i < 14; $i++) {
         ${"selected".$i} = "";
      }
      if (isset($message_highlight_list[$theid]["color"])) {
         for ($i=0; $i < 14; $i++) {
            if ($color_list[$i] == $message_highlight_list[$theid]["color"]) {
               $selected_choose = " checked";
               ${"selected".$i} = " selected";
               continue;
            }
             }
      }
      if (!isset($message_highlight_list[$theid]["color"]))
         $selected_choose = " checked";
      else if (!isset($selected_choose))
         $selected_input = " checked";

      echo "<form name=f method=post action=\"". 
$phpgw->link('/squirrelmail/preferences_highlight.php')."\">\n";
      echo "<input type=\"hidden\" value=\"save\" name=\"action\">\n";
      echo "<input type=\"hidden\" value=\"$theid\" name=\"theid\">\n";
      echo "<table width=80% align=center cellpadding=3 cellspacing=0 
border=0>\n";
      echo "   <tr bgcolor=\"$color[0]\">\n";
      echo "      <td align=right width=25%><b>\n";
      echo lang("Identifying name") . ":";
      echo "      </b></td>\n";
      echo "      <td width=75%>\n";
      if (isset($message_highlight_list[$theid]["name"]))
          $disp = $message_highlight_list[$theid]["name"];
      else
          $disp = "";
      $disp = str_replace("\\\\", "\\", $disp);
      $disp = str_replace("\\\"", "\"", $disp);
      $disp = str_replace("\"", "&quot;", $disp);
      echo "         <input type=\"text\" value=\"".$disp."\" 
name=\"identname\">";
      echo "      </td>\n";
      echo "   </tr>\n";
      echo "   <tr><td><small><small>&nbsp;</small></small></td></tr>\n";
      echo "   <tr bgcolor=\"$color[0]\">\n";
      echo "      <td align=right width=25%><b>\n";
      echo lang("Color") . ":";
      echo "      </b></td>\n";
      echo "      <td width=75%>\n";
      echo "         <input type=\"radio\" name=color_type 
value=1$selected_choose> &nbsp;<select name=newcolor_choose>\n";
      echo "            <option value=\"$color_list[0]\"$selected0>" . 
lang("Dark Blue") . "\n";
      echo "            <option value=\"$color_list[1]\"$selected1>" . 
lang("Dark Green") . "\n";
      echo "            <option value=\"$color_list[2]\"$selected2>" . 
lang("Dark Yellow") . "\n";
      echo "            <option value=\"$color_list[3]\"$selected3>" . 
lang("Dark Cyan") . "\n";
      echo "            <option value=\"$color_list[4]\"$selected4>" . 
lang("Dark Magenta") . "\n";
      echo "            <option value=\"$color_list[5]\"$selected5>" . 
lang("Light Blue") . "\n";
      echo "            <option value=\"$color_list[6]\"$selected6>" . 
lang("Light Green") . "\n";
      echo "            <option value=\"$color_list[7]\"$selected7>" . 
lang("Light Yellow") . "\n";
      echo "            <option value=\"$color_list[8]\"$selected8>" . 
lang("Light Cyan") . "\n";
      echo "            <option value=\"$color_list[9]\"$selected9>" . 
lang("Light Magenta") . "\n";
      echo "            <option value=\"$color_list[10]\"$selected10>" . 
lang("Dark Gray") . "\n";
      echo "            <option value=\"$color_list[11]\"$selected11>" . 
lang("Medium Gray") . "\n";
      echo "            <option value=\"$color_list[12]\"$selected12>" . 
lang("Light Gray") . "\n";
      echo "            <option value=\"$color_list[13]\"$selected13>" . 
lang("White") . "\n";
      echo "         </select><br>\n";
      echo "         <input type=\"radio\" name=color_type 
value=2$selected_input> &nbsp;". lang("Other:") ."<input type=\"text\" 
value=\"";
      if ($selected_input) echo $message_highlight_list[$theid]["color"];
      echo "\" name=\"newcolor_input\" size=7> ".lang("Ex: 63aa7f")."<br>\n";
      echo "      </td>\n";
      echo "   </tr>\n";
      echo "   <tr><td><small><small>&nbsp;</small></small></td></tr>\n";
      echo "   <tr bgcolor=\"$color[0]\">\n";
      echo "      <td align=right width=25%><b>\n";
      echo lang("Match") . ":";
      echo "      </b></td>\n";
      echo "      <td width=75%>\n";
      echo "         <select name=match_type>\n";
      if (isset($message_highlight_list[$theid]["match_type"]) && 
$message_highlight_list[$theid]["match_type"] == "from")    echo "            
<option value=\"from\" selected>From\n";
      else                                                         echo "       
     <option value=\"from\">From\n";
      if (isset($message_highlight_list[$theid]["match_type"]) && 
$message_highlight_list[$theid]["match_type"] == "to")      echo "            
<option value=\"to\" selected>To\n";
      else                                                         echo "       
     <option value=\"to\">To\n";
      if (isset($message_highlight_list[$theid]["match_type"]) && 
$message_highlight_list[$theid]["match_type"] == "cc")      echo "            
<option value=\"cc\" selected>Cc\n";
      else                                                         echo "       
     <option value=\"cc\">Cc\n";
      if (isset($message_highlight_list[$theid]["match_type"]) && 
$message_highlight_list[$theid]["match_type"] == "to_cc")   echo "            
<option value=\"to_cc\" selected>To or Cc\n";
      else                                                         echo "       
     <option value=\"to_cc\">To or Cc\n";
      if (isset($message_highlight_list[$theid]["match_type"]) && 
$message_highlight_list[$theid]["match_type"] == "subject") echo "            
<option value=\"subject\" selected>Subject\n";
      else                                                         echo "       
     <option value=\"subject\">Subject\n";
      echo "         </select>\n";
      if (isset($message_highlight_list[$theid]["value"]))
          $disp = $message_highlight_list[$theid]["value"];
      else
          $disp = '';
      $disp = str_replace("\\\\", "\\", $disp);
      $disp = str_replace("\\\"", "\"", $disp);
      $disp = str_replace("\"", "&quot;", $disp);
      echo "         <nobr><input type=\"text\" value=\"".$disp."\" 
name=\"value\">";
      echo "        <nobr></td>\n";
      echo "   </tr>\n";
      echo "</table>\n";
      echo "<center><input type=\"submit\" value=\"" . lang("Submit") . 
"\"></center>\n";
      echo "</form>\n";
      do_hook("options_highlight_bottom");
   }
?>
<?php
        $phpgw->common->phpgw_footer();
?>

====================================================
Index: preferences_folder.php
<?php
  /**************************************************************************\
  * phpGroupWare - E-Mail                                                    *
  * http://www.phpgroupware.org                                              *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

  /* $Id: preferences_folder.php,v 1.1 2005/05/05 00:56:40 skwashd Exp $ */

// store the value of $mailbox, because it will overwriten
        $MAILBOX = $mailbox;

        $phpgw_info["flags"] = array("currentapp" => "squirrelmail","noheader" 
=> True, "nonavbar" => True,
                "enable_nextmatchs_class" => True, "enable_network_class" => 
True);

        include("../header.inc.php");

        $mailbox = $MAILBOX;





        if ($submit)
        {
                $phpgw->preferences->read_repository();
                if ($trash != "none")
                {
                        
$phpgw->preferences->add("squirrelmail","move_to_trash", "true");
                        $phpgw->preferences->add("squirrelmail","trash_folder", 
$trash);
                }
                else
                {
                        
$phpgw->preferences->add("squirrelmail","move_to_trash", "0");
                        $phpgw->preferences->add("squirrelmail","trash_folder", 
"none");
                }

                if ($sent != "none")
                {
                        $phpgw->preferences->add("squirrelmail","move_to_sent", 
"true");
                        $phpgw->preferences->add("squirrelmail","sent_folder", 
$sent);
                }
                else
                {
                        $phpgw->preferences->add("squirrelmail","move_to_sent", 
"0");
                        $phpgw->preferences->add("squirrelmail","sent_folder", 
"none");
                }

                $phpgw->preferences->add("squirrelmail","unseennotify");
                $phpgw->preferences->add("squirrelmail","unseentype");


                $phpgw->preferences->save_repository();

                Header("Location: " . $phpgw->link("/preferences/index.php"));
        }

        $phpgw->common->phpgw_header();
        echo parse_navbar();
           if (!isset($strings_php))
              include(PHPGW_APP_ROOT . "/inc/strings.php");
           if (!isset($config_php))
              include(PHPGW_APP_ROOT . '/config/config.php');
           if (!isset($page_header_php))
              include(PHPGW_APP_ROOT . "/inc/page_header.php");
           if (!isset($display_messages_php))
              include(PHPGW_APP_ROOT . "/inc/display_messages.php");
           if (!isset($imap_php))
              include(PHPGW_APP_ROOT . "/inc/imap.php");
           if (!isset($array_php))
              include(PHPGW_APP_ROOT . "/inc/array.php");
           if (!isset($i18n_php))
              include(PHPGW_APP_ROOT . "/inc/i18n.php");
           if (!isset($plugin_php))
              include(PHPGW_APP_ROOT . "/inc/plugin.php");

        $load_prefs_php=1;

        if ($totalerrors)
        {
                echo "<p><center>" . $phpgw->common->error_list($errors) . 
"</center>";
        }

        $imapConnection = sqimap_login($username, $key, $imapServerAddress, 
$imapPort, 0);
        $boxes = sqimap_mailbox_list($imapConnection);
        sqimap_logout($imapConnection);

        if ($phpgw_info["user"]["preferences"]["squirrelmail"]["move_to_trash"] 
== true)
                $trashOptions = "<option value=none>" . lang("Don't use Trash");
        else
                $trashOptions = "<option value=none selected>" . lang("Don't 
use Trash");

        for ($i = 0; $i < count($boxes); $i++)
        {
                $use_folder = true;
                if (strtolower($boxes[$i]["unformatted"]) == "inbox")
                {
                        $use_folder = false;
                }

                if ($use_folder == true)
                {
                        $box = $boxes[$i]["unformatted-dm"];
                        $box2 = replace_spaces($boxes[$i]["formatted"]);
                        if (($boxes[$i]["unformatted"] == 
$phpgw_info["user"]["preferences"]["squirrelmail"]["trash_folder"]) &&
                                
($phpgw_info["user"]["preferences"]["squirrelmail"]["move_to_trash"] == true))
                                $trashOptions .= "         <OPTION SELECTED 
VALUE=\"$box\">$box2\n";
                        else
                                $trashOptions .= "         <OPTION 
VALUE=\"$box\">$box2\n";
                }
        }



        if ($phpgw_info["user"]["preferences"]["squirrelmail"]["move_to_sent"] 
== true)
                $sentOptions = "<option value=none>" . lang("Don't use Sent");
        else
                $sentOptions = "<option value=none selected>" . lang("Don't use 
Sent");

        for ($i = 0; $i < count($boxes); $i++)
        {
                $use_folder = true;
                if (strtolower($boxes[$i]["unformatted"]) == "inbox")
                {
                        $use_folder = false;
                }
                if ($use_folder == true)
                {
                        $box = $boxes[$i]["unformatted-dm"];
                        $box2 = replace_spaces($boxes[$i]["formatted"]);
                        if (($boxes[$i]["unformatted"] == 
$phpgw_info["user"]["preferences"]["squirrelmail"]["sent_folder"]) &&
                                
($phpgw_info["user"]["preferences"]["squirrelmail"]["move_to_sent"] == true))
                                $sentOptions .= "         <OPTION SELECTED 
VALUE=\"$box\">$box2\n";
                        else
                                $sentOptions .= "         <OPTION 
VALUE=\"$box\">$box2\n";
                }
        }



        $tmpl = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
        #$tmpl->set_unknowns('remove');

        $tmpl->set_file(array('body' => 'preferences_folder.tpl'));

        $var = Array
        (
                'th_bg'                 => $phpgw_info["theme"]["th_bg"],
                'tr_color1'             => $phpgw_info['theme']['row_on'],
                'tr_color2'             => $phpgw_info['theme']['row_off'],
                'link'                  => 
$phpgw->link('/squirrelmail/preferences_folder.php'),
                'wrapat'                => 
$phpgw_info["user"]["preferences"]["squirrelmail"]["wrapat"],
                'trash_options'         => $trashOptions,
                'sent_options'          => $sentOptions,
                
"notify".$phpgw_info["user"]["preferences"]["squirrelmail"]["unseennotify"]."_checked"
  => 'checked',
                
"type".$phpgw_info["user"]["preferences"]["squirrelmail"]["unseentype"]."_checked"
      => 'checked'
        );

        $tmpl->set_var($var);

        $translations = Array
        (
                'lang_save'             => lang('save'),
                'lang_folder_prefs'     => lang('Folder Preferences')
        );
        $tmpl->set_var($translations);

        $tmpl->pparse('out','body');




        $phpgw->common->phpgw_footer();
?>






reply via email to

[Prev in Thread] Current Thread [Next in Thread]