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');
16 require_once('../functions/strings.php');
18 function s_opt( $val, $sel, $tit ) {
19 echo " <option value=\"$val\"";
23 echo ">$tit</option>\n";
26 /* ------------------------ main ------------------------ */
28 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
29 $boxes = sqimap_mailbox_list($imapConnection);
31 if( $mailbox == 'None' ) {
32 $mailbox = $boxes[0]['unformatted'];
35 displayPageHeader($color, $mailbox);
37 if( !isset( $search_memory ) ) {
41 do_hook('search_before_form');
43 " <table width=\"100%\" align=center cellpadding=2 cellspacing=0 border=0>\n".
44 " <tr><td bgcolor=\"$color[0]\">\n".
45 " <center><b>"._("Search")."</b></center>\n".
47 ' <tr><td align=center>';
49 if( $search_memory > 0 ) {
52 setpref( $data_dir, $username, 'search_pos', $pos );
54 $pos = getPref($data_dir, $username, 'search_pos', 0 );
59 for ( $form = 0; $form <= $search_memory; $form++
) {
65 if( $search_memory > 0 ) {
67 $
$what = getPref($data_dir, $username, "search_what$frm", '' );
68 $
$where = getPref($data_dir, $username, "search_where$frm", '' );
70 setpref( $data_dir, $username, "search_what$frm", $
$what );
71 setpref( $data_dir, $username, "search_where$frm", $
$where );
74 echo " <TABLE WIDTH=\"75%\" cellpadding=0 cellspacing=0>\n";
75 if( !($form == 0 && $search_memory > 0) ) {
83 echo "<FORM ACTION=\"$PHP_SELF\" NAME=s>\n".
84 "<input type=hidden name=pos value=\"$frm\">".
85 " <TR bgcolor=$act><td width=10></td>\n".
86 ' <TD><SELECT NAME="mailbox">';
88 for ($i = 0; $i < count($boxes); $i++
) {
89 if (!in_array('noselect', $boxes[$i]['flags'])) {
90 $box = $boxes[$i]['unformatted'];
91 $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
92 if ($mailbox == $box) {
93 echo " <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
95 echo " <OPTION VALUE=\"$box\">$box2</OPTION>\n";
101 " <TD ALIGN=\"CENTER\">\n";
102 if (!isset($
$what)) {
105 $what_disp = str_replace(',', ' ', $
$what);
106 $what_disp = str_replace('\\\\', '\\', $what_disp);
107 $what_disp = str_replace('\\"', '"', $what_disp);
108 $what_disp = str_replace('"', '"', $what_disp);
109 echo " <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what$frm\" VALUE=\"$what_disp\">\n".
111 "<TD ALIGN=\"RIGHT\">\n".
112 "<SELECT NAME=\"where$frm\">";
114 s_opt( 'BODY', $
$where, _("Body") );
115 s_opt( 'TEXT', $
$where, _("Everywhere") );
116 s_opt( 'SUBJECT', $
$where, _("Subject") );
117 s_opt( 'FROM', $
$where, _("From") );
118 s_opt( 'CC', $
$where, _("Cc") );
119 s_opt( 'TO', $
$where, _("To") );
121 echo " </SELECT>\n" .
123 " <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n".
124 " <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n".
132 echo "</td></tr></table>";
133 do_hook("search_after_form");
134 if( !isset( $pos ) ) {
138 $where = "where$pos";
140 if (isset($
$where) && $
$where && isset($
$what) && $
$what) {
141 sqimap_mailbox_select($imapConnection, $mailbox);
142 sqimap_search($imapConnection, $
$where, $
$what, $mailbox, $color, $pos);
144 do_hook("search_bottom");
145 sqimap_logout ($imapConnection);
147 echo '</body></html>';