da284ff225dd9055d126ad47e2fcdcfa5e6d6d82
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=\"95%\" 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 for ( $form = 0; $form <= $search_memory; $form++
) {
54 if( $search_memory > 0 ) {
56 $
$what = getPref($data_dir, $username, "search_what$frm", '' );
57 $
$where = getPref($data_dir, $username, "search_where$frm", '' );
59 setpref( $data_dir, $username, "search_what$frm", $
$what );
60 setpref( $data_dir, $username, "search_where$frm", $
$where );
63 echo " <TABLE WIDTH=\"75%\" cellpadding=0 cellspacing=0>\n";
64 if( !($form == 0 && $search_memory > 0) ) {
66 echo "<FORM ACTION=\"$PHP_SELF\" NAME=s>\n".
67 "<input type=hidden name=pos value=\"$frm\">".
69 " <TD WIDTH=\"33%\">\n".
70 ' <TT><SMALL><SELECT NAME="mailbox">';
72 for ($i = 0; $i < count($boxes); $i++
) {
73 if (!in_array('noselect', $boxes[$i]['flags'])) {
74 $box = $boxes[$i]['unformatted'];
75 $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
76 if ($mailbox == $box) {
77 echo " <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
79 echo " <OPTION VALUE=\"$box\">$box2</OPTION>\n";
83 echo ' </SELECT></SMALL></TT>'.
85 " <TD ALIGN=\"CENTER\" WIDTH=\"33%\">\n";
89 $what_disp = str_replace(',', ' ', $
$what);
90 $what_disp = str_replace('\\\\', '\\', $what_disp);
91 $what_disp = str_replace('\\"', '"', $what_disp);
92 $what_disp = str_replace('"', '"', $what_disp);
93 echo " <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what$frm\" VALUE=\"$what_disp\">\n".
95 "<TD ALIGN=\"RIGHT\" WIDTH=\"33%\">\n".
96 "<SELECT NAME=\"where$frm\">";
98 s_opt( 'BODY', $
$where, _("Body") );
99 s_opt( 'TEXT', $
$where, _("Everywhere") );
100 s_opt( 'SUBJECT', $
$where, _("Subject") );
101 s_opt( 'FROM', $
$where, _("From") );
102 s_opt( 'CC', $
$where, _("Cc") );
103 s_opt( 'TO', $
$where, _("To") );
105 echo " </SELECT>\n" .
107 " <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n".
108 " <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n".
116 echo "</td></tr></table>";
117 do_hook("search_after_form");
118 if( !isset( $pos ) ) {
122 $where = "where$pos";
124 if (isset($
$where) && $
$where && isset($
$what) && $
$what) {
125 sqimap_mailbox_select($imapConnection, $mailbox);
126 sqimap_search($imapConnection, $
$where, $
$what, $mailbox, $color, $pos);
128 do_hook("search_bottom");
129 sqimap_logout ($imapConnection);
131 echo '</body></html>';