Added option to do data and attachment directory hashing, up to four levels. Will...
[squirrelmail.git] / src / search.php
CommitLineData
c61bb006 1<?php
245a6892 2
35586184 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 */
2d367c68 11
35586184 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/*****************************************************************/
245a6892 27
35586184 28require_once('../src/validate.php');
29require_once('../functions/imap.php');
30require_once('../functions/imap_search.php');
31require_once('../functions/array.php');
c61bb006 32
99d2a184 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
c61bb006 40 displayPageHeader($color, $mailbox);
1809bad8 41 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
c61bb006 42
91dc6e4e 43 do_hook('search_before_form');
99d2a184 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>'.
c61bb006 50
99d2a184 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">';
c61bb006 56
1809bad8 57 $boxes = sqimap_mailbox_list($imapConnection);
58 for ($i = 0; $i < count($boxes); $i++) {
6dc0e464 59 if (!in_array('noselect', $boxes[$i]['flags'])) {
91dc6e4e 60 $box = $boxes[$i]['unformatted'];
6dc0e464 61 $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
1809bad8 62 if ($mailbox == $box)
6dc0e464 63 echo " <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
1809bad8 64 else
6dc0e464 65 echo " <OPTION VALUE=\"$box\">$box2</OPTION>\n";
c61bb006 66 }
1809bad8 67 }
99d2a184 68 echo ' </SELECT></SMALL></TT>'.
69 " </TD>\n".
70 " <TD ALIGN=\"CENTER\" WIDTH=\"33%\">\n";
245a6892 71 if (!isset($what))
91dc6e4e 72 $what = '';
73 $what_disp = ereg_replace(',', ' ', $what);
6553723c 74 $what_disp = str_replace('\\\\', '\\', $what_disp);
75 $what_disp = str_replace('\\"', '"', $what_disp);
91dc6e4e 76 $what_disp = str_replace('"', '&quot;', $what_disp);
99d2a184 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>";
06ad27a2 98 do_hook("search_after_form");
245a6892 99 if (isset($where) && $where && isset($what) && $what) {
1809bad8 100 sqimap_mailbox_select($imapConnection, $mailbox);
101 sqimap_search($imapConnection, $where, $what, $mailbox, $color);
102 }
06ad27a2 103 do_hook("search_bottom");
1809bad8 104 sqimap_logout ($imapConnection);
c61bb006 105?>
35586184 106</body></html>