Code cleanup brigage...
[squirrelmail.git] / src / search.php
1 <?php
2
3 /**
4 * right_main.php
5 *
6 * Copyright (c) 1999-2001 The Squirrelmail Development Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * $Id$
10 */
11
12 /*****************************************************************/
13 /*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
14 /*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
15 /*** + Base level indent should begin at left margin, as ***/
16 /*** the require_once below looks. ***/
17 /*** + All identation should consist of four space blocks ***/
18 /*** + Tab characters are evil. ***/
19 /*** + all comments should use "slash-star ... star-slash" ***/
20 /*** style -- no pound characters, no slash-slash style ***/
21 /*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
22 /*** ALWAYS USE { AND } CHARACTERS!!! ***/
23 /*** + Please use ' instead of ", when possible. Note " ***/
24 /*** should always be used in _( ) function calls. ***/
25 /*** Thank you for your help making the SM code more readable. ***/
26 /*****************************************************************/
27
28 require_once('../src/validate.php');
29 require_once('../functions/imap.php');
30 require_once('../functions/imap_search.php');
31 require_once('../functions/array.php');
32
33 function s_opt( $val, $sel, $tit ) {
34 echo " <option value=\"$val\"";
35 if ( $sel )
36 echo 'selected';
37 echo ">$tit</option>\n";
38 }
39
40 displayPageHeader($color, $mailbox);
41 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
42
43 do_hook('search_before_form');
44 echo "<br>\n".
45 " <table width=95% align=center cellpadding=2 cellspacing=0 border=0>\n".
46 " <tr><td bgcolor=\"$color[0]\">\n".
47 " <center><b>"._("Search")."</b></center>\n".
48 " </td></tr>\n".
49 ' <tr><td align=center>'.
50
51 "<FORM ACTION=\"search.php\" NAME=s>\n".
52 " <TABLE WIDTH=\"75%\">\n".
53 " <TR>\n".
54 " <TD WIDTH=\"33%\">\n".
55 ' <TT><SMALL><SELECT NAME="mailbox">';
56
57 $boxes = sqimap_mailbox_list($imapConnection);
58 for ($i = 0; $i < count($boxes); $i++) {
59 if (!in_array('noselect', $boxes[$i]['flags'])) {
60 $box = $boxes[$i]['unformatted'];
61 $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
62 if ($mailbox == $box)
63 echo " <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
64 else
65 echo " <OPTION VALUE=\"$box\">$box2</OPTION>\n";
66 }
67 }
68 echo ' </SELECT></SMALL></TT>'.
69 " </TD>\n".
70 " <TD ALIGN=\"CENTER\" WIDTH=\"33%\">\n";
71 if (!isset($what))
72 $what = '';
73 $what_disp = ereg_replace(',', ' ', $what);
74 $what_disp = str_replace('\\\\', '\\', $what_disp);
75 $what_disp = str_replace('\\"', '"', $what_disp);
76 $what_disp = str_replace('"', '&quot;', $what_disp);
77 echo " <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what\" VALUE=\"$what_disp\">\n".
78 '</TD>'.
79 "<TD ALIGN=\"RIGHT\" WIDTH=\"33%\">\n".
80 '<SELECT NAME="where">';
81
82 s_opt( 'BODY', ($where == 'BODY'), _("Body") );
83 s_opt( 'TEXT', ($where == 'TEXT'), _("Everywhere") );
84 s_opt( 'SUBJECT', ($where == 'SUBJECT'), _("Subject") );
85 s_opt( 'FROM', ($where == 'FROM'), _("From") );
86 s_opt( 'CC', ($where == 'CC'), _("Cc") );
87 s_opt( 'TO', ($where == 'TO'), _("To") );
88
89 echo " </SELECT>\n" .
90 " </TD>\n".
91 " <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n".
92 " <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n".
93 " </TD>\n".
94 " </TR>\n".
95 " </TABLE>\n".
96 "</FORM>".
97 "</td></tr></table>";
98 do_hook("search_after_form");
99 if (isset($where) && $where && isset($what) && $what) {
100 sqimap_mailbox_select($imapConnection, $mailbox);
101 sqimap_search($imapConnection, $where, $what, $mailbox, $color);
102 }
103 do_hook("search_bottom");
104 sqimap_logout ($imapConnection);
105 ?>
106 </body></html>