Getting ready for 1.2.0 release.
[squirrelmail.git] / src / search.php
CommitLineData
c61bb006 1<?php
245a6892 2
35586184 3/**
4 * right_main.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * $Id$
10 */
2d367c68 11
35586184 12require_once('../src/validate.php');
13require_once('../functions/imap.php');
14require_once('../functions/imap_search.php');
15require_once('../functions/array.php');
c61bb006 16
29eb5486 17function s_opt( $val, $sel, $tit ) {
18 echo " <option value=\"$val\"";
19 if ( $sel ) {
20 echo 'selected';
99d2a184 21 }
29eb5486 22 echo ">$tit</option>\n";
23}
99d2a184 24
29eb5486 25displayPageHeader($color, $mailbox);
26$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
c61bb006 27
29eb5486 28do_hook('search_before_form');
29echo "<br>\n".
30 " <table width=95% align=center cellpadding=2 cellspacing=0 border=0>\n".
31 " <tr><td bgcolor=\"$color[0]\">\n".
32 " <center><b>"._("Search")."</b></center>\n".
33 " </td></tr>\n".
34 ' <tr><td align=center>'.
c61bb006 35
29eb5486 36 "<FORM ACTION=\"$PHP_SELF\" NAME=s>\n".
37 " <TABLE WIDTH=\"75%\">\n".
38 " <TR>\n".
39 " <TD WIDTH=\"33%\">\n".
40 ' <TT><SMALL><SELECT NAME="mailbox">';
c61bb006 41
29eb5486 42$boxes = sqimap_mailbox_list($imapConnection);
43for ($i = 0; $i < count($boxes); $i++) {
44 if (!in_array('noselect', $boxes[$i]['flags'])) {
45 $box = $boxes[$i]['unformatted'];
46 $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
47 if ($mailbox == $box) {
6dc0e464 48 echo " <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
29eb5486 49 } else {
6dc0e464 50 echo " <OPTION VALUE=\"$box\">$box2</OPTION>\n";
29eb5486 51 }
52 }
53}
54echo ' </SELECT></SMALL></TT>'.
55 " </TD>\n".
56 " <TD ALIGN=\"CENTER\" WIDTH=\"33%\">\n";
57if (!isset($what)) {
58 $what = '';
59}
60$what_disp = ereg_replace(',', ' ', $what);
61$what_disp = str_replace('\\\\', '\\', $what_disp);
62$what_disp = str_replace('\\"', '"', $what_disp);
63$what_disp = str_replace('"', '&quot;', $what_disp);
64echo " <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what\" VALUE=\"$what_disp\">\n".
65 '</TD>'.
66 "<TD ALIGN=\"RIGHT\" WIDTH=\"33%\">\n".
67 '<SELECT NAME="where">';
68
69s_opt( 'BODY', ($where == 'BODY'), _("Body") );
70s_opt( 'TEXT', ($where == 'TEXT'), _("Everywhere") );
71s_opt( 'SUBJECT', ($where == 'SUBJECT'), _("Subject") );
72s_opt( 'FROM', ($where == 'FROM'), _("From") );
73s_opt( 'CC', ($where == 'CC'), _("Cc") );
74s_opt( 'TO', ($where == 'TO'), _("To") );
75
76echo " </SELECT>\n" .
77 " </TD>\n".
78 " <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n".
79 " <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n".
80 " </TD>\n".
81 " </TR>\n".
82 " </TABLE>\n".
83 "</FORM>".
84 "</td></tr></table>";
85do_hook("search_after_form");
86if (isset($where) && $where && isset($what) && $what) {
87 sqimap_mailbox_select($imapConnection, $mailbox);
88 sqimap_search($imapConnection, $where, $what, $mailbox, $color);
89}
90do_hook("search_bottom");
91sqimap_logout ($imapConnection);
99d2a184 92
29eb5486 93echo '</body></html>';
99d2a184 94
15e6162e 95?>