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 displayPageHeader($color, $mailbox);
28 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
30 if( !isset( $search_memory ) ) {
34 do_hook('search_before_form');
36 " <table width=\"95%\" align=center cellpadding=2 cellspacing=0 border=0>\n".
37 " <tr><td bgcolor=\"$color[0]\">\n".
38 " <center><b>"._("Search")."</b></center>\n".
40 ' <tr><td align=center>';
42 for ( $form = 0; $form <= $search_memory; $form++
) {
48 if( $search_memory > 0 ) {
50 $
$what = getPref($data_dir, $username, "search_what$frm", '' );
51 $
$where = getPref($data_dir, $username, "search_where$frm", '' );
53 setpref( $data_dir, $username, "search_what$frm", $
$what );
54 setpref( $data_dir, $username, "search_where$frm", $
$where );
57 echo " <TABLE WIDTH=\"75%\" cellpadding=0 cellspacing=0>\n";
58 if( !($form == 0 && $search_memory > 0) ) {
60 echo "<FORM ACTION=\"$PHP_SELF\" NAME=s>\n".
61 "<input type=hidden name=pos value=\"$frm\">".
63 " <TD WIDTH=\"33%\">\n".
64 ' <TT><SMALL><SELECT NAME="mailbox">';
66 $boxes = sqimap_mailbox_list($imapConnection);
68 for ($i = 0; $i < count($boxes); $i++
) {
69 if (!in_array('noselect', $boxes[$i]['flags'])) {
70 $box = $boxes[$i]['unformatted'];
71 $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
72 if ($mailbox == $box) {
73 echo " <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
75 echo " <OPTION VALUE=\"$box\">$box2</OPTION>\n";
79 echo ' </SELECT></SMALL></TT>'.
81 " <TD ALIGN=\"CENTER\" WIDTH=\"33%\">\n";
85 $what_disp = str_replace(',', ' ', $
$what);
86 $what_disp = str_replace('\\\\', '\\', $what_disp);
87 $what_disp = str_replace('\\"', '"', $what_disp);
88 $what_disp = str_replace('"', '"', $what_disp);
89 echo " <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what$frm\" VALUE=\"$what_disp\">\n".
91 "<TD ALIGN=\"RIGHT\" WIDTH=\"33%\">\n".
92 "<SELECT NAME=\"where$frm\">";
94 s_opt( 'BODY', $
$where, _("Body") );
95 s_opt( 'TEXT', $
$where, _("Everywhere") );
96 s_opt( 'SUBJECT', $
$where, _("Subject") );
97 s_opt( 'FROM', $
$where, _("From") );
98 s_opt( 'CC', $
$where, _("Cc") );
99 s_opt( 'TO', $
$where, _("To") );
101 echo " </SELECT>\n" .
103 " <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n".
104 " <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n".
112 echo "</td></tr></table>";
113 do_hook("search_after_form");
114 if( !isset( $pos ) ) {
118 $where = "where$pos";
120 if (isset($
$where) && $
$where && isset($
$what) && $
$what) {
121 sqimap_mailbox_select($imapConnection, $mailbox);
122 sqimap_search($imapConnection, $
$where, $
$what, $mailbox, $color);
124 do_hook("search_bottom");
125 sqimap_logout ($imapConnection);
127 echo '</body></html>';