6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
12 require_once('../src/validate.php');
13 require_once('../functions/imap.php');
14 require_once('../functions/imap_search.php');
15 require_once('../functions/array.php');
17 function s_opt( $val, $sel, $tit ) {
18 echo " <option value=\"$val\"";
22 echo ">$tit</option>\n";
25 /* ------------------------ main ------------------------ */
27 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
28 $boxes = sqimap_mailbox_list($imapConnection);
30 if( $mailbox == 'None' ) {
31 $mailbox = $boxes[0]['unformatted'];
34 displayPageHeader($color, $mailbox);
36 if( !isset( $search_memory ) ) {
40 do_hook('search_before_form');
42 " <table width=\"100%\" align=center cellpadding=2 cellspacing=0 border=0>\n".
43 " <tr><td bgcolor=\"$color[0]\">\n".
44 " <center><b>"._("Search")."</b></center>\n".
46 ' <tr><td align=center>';
48 if( $search_memory > 0 ) {
51 setpref( $data_dir, $username, 'search_pos', $pos );
53 $pos = getPref($data_dir, $username, 'search_pos', 0 );
58 for ( $form = 0; $form <= $search_memory; $form++
) {
64 if( $search_memory > 0 ) {
66 $
$what = getPref($data_dir, $username, "search_what$frm", '' );
67 $
$where = getPref($data_dir, $username, "search_where$frm", '' );
69 setpref( $data_dir, $username, "search_what$frm", $
$what );
70 setpref( $data_dir, $username, "search_where$frm", $
$where );
73 echo " <TABLE WIDTH=\"75%\" cellpadding=0 cellspacing=0>\n";
74 if( !($form == 0 && $search_memory > 0) ) {
82 echo "<FORM ACTION=\"$PHP_SELF\" NAME=s>\n".
83 "<input type=hidden name=pos value=\"$frm\">".
84 " <TR bgcolor=$act><td width=10></td>\n".
85 ' <TD><SELECT NAME="mailbox">';
87 for ($i = 0; $i < count($boxes); $i++
) {
88 if (!in_array('noselect', $boxes[$i]['flags'])) {
89 $box = $boxes[$i]['unformatted'];
90 $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
91 if ($mailbox == $box) {
92 echo " <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
94 echo " <OPTION VALUE=\"$box\">$box2</OPTION>\n";
100 " <TD ALIGN=\"CENTER\">\n";
101 if (!isset($
$what)) {
104 $what_disp = str_replace(',', ' ', $
$what);
105 $what_disp = str_replace('\\\\', '\\', $what_disp);
106 $what_disp = str_replace('\\"', '"', $what_disp);
107 $what_disp = str_replace('"', '"', $what_disp);
108 echo " <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what$frm\" VALUE=\"$what_disp\">\n".
110 "<TD ALIGN=\"RIGHT\">\n".
111 "<SELECT NAME=\"where$frm\">";
113 s_opt( 'BODY', $
$where, _("Body") );
114 s_opt( 'TEXT', $
$where, _("Everywhere") );
115 s_opt( 'SUBJECT', $
$where, _("Subject") );
116 s_opt( 'FROM', $
$where, _("From") );
117 s_opt( 'CC', $
$where, _("Cc") );
118 s_opt( 'TO', $
$where, _("To") );
120 echo " </SELECT>\n" .
122 " <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n".
123 " <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n".
131 echo "</td></tr></table>";
132 do_hook("search_after_form");
133 if( !isset( $pos ) ) {
137 $where = "where$pos";
139 if (isset($
$where) && $
$where && isset($
$what) && $
$what) {
140 sqimap_mailbox_select($imapConnection, $mailbox);
141 sqimap_search($imapConnection, $
$where, $
$what, $mailbox, $color, $pos);
143 do_hook("search_bottom");
144 sqimap_logout ($imapConnection);
146 echo '</body></html>';