79da86acd8aa95417a0f5303185b7f571041dd99
[squirrelmail.git] / src / search.php
1 <?php
2
3 /* $Id$ */
4
5 session_start();
6
7 if(!isset($logged_in)) {
8 set_up_language($squirrelmail_language, true);
9 echo _("You must login first.");
10 exit;
11 }
12 if(!isset($username) || !isset($key)) {
13 include ('../themes/default_theme.php');
14 include ('../functions/display_messages.php');
15 printf('<html><BODY TEXT="%s" BGCOLOR="%s" LINK="%s" VLINK="%s" ALINK="%s">',
16 $color[8], $color[4], $color[7], $color[7], $color[7]);
17 plain_error_message(_("You need a valid user and password to access this page!")
18 . '<br><a href="../src/login.php">'
19 . _("Click here to log back in.") . '</a>.', $color);
20 echo '</body></html>';
21 exit;
22 }
23
24 if (!isset($strings_php))
25 include('../functions/strings.php');
26 if (!isset($i18n_php))
27 include('../functions/i18n.php');
28 if (!isset($config_php))
29 include('../config/config.php');
30 if (!isset($page_header_php))
31 include('../functions/page_header.php');
32 if (!isset($imap_php))
33 include('../functions/imap.php');
34 if (!isset($imap_search_php))
35 include('../functions/imap_search.php');
36 if (!isset($array_php))
37 include('../functions/array.php');
38
39 include('../src/load_prefs.php');
40
41 displayPageHeader($color, $mailbox);
42 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
43
44 do_hook('search_before_form');
45 echo "<br>\n";
46 echo " <table width=95% align=center cellpadding=2 cellspacing=0 border=0>\n";
47 echo " <tr><td bgcolor=\"$color[0]\">\n";
48 echo " <center><b>"._("Search")."</b></center>\n";
49 echo " </td></tr>\n";
50 echo ' <tr><td align=center>';
51
52 echo "<FORM ACTION=\"search.php\" NAME=s>\n";
53 echo " <TABLE WIDTH=75%>\n";
54 echo " <TR>\n";
55 echo " <TD WIDTH=33%>\n";
56 echo ' <TT><SMALL><SELECT NAME="mailbox">';
57
58 $boxes = sqimap_mailbox_list($imapConnection);
59 for ($i = 0; $i < count($boxes); $i++) {
60 if (!in_array('noselect', $boxes[$i]['flags'])) {
61 $box = $boxes[$i]['unformatted'];
62 $box2 = replace_spaces($boxes[$i]['unformatted-disp']);
63 if ($mailbox == $box)
64 echo " <OPTION VALUE=\"$box\" SELECTED>$box2\n";
65 else
66 echo " <OPTION VALUE=\"$box\">$box2\n";
67 }
68 }
69 echo ' </SELECT></SMALL></TT>';
70 echo " </TD>\n";
71 echo " <TD ALIGN=\"CENTER\" WIDTH=33%>\n";
72 if (!isset($what))
73 $what = '';
74 $what_disp = ereg_replace(',', ' ', $what);
75 $what_disp = str_replace('\\', '\', $what_disp);
76 $what_disp = str_replace('\"', '"', $what_disp);
77 $what_disp = str_replace('"', '&quot;', $what_disp);
78 echo " <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what\" VALUE=\"$what_disp\">\n";
79 echo ' </TD>';
80 echo " <TD ALIGN=\"RIGHT\" WIDTH=33%>\n";
81 echo ' <SELECT NAME="where">';
82
83 if (isset($where) && $where == 'BODY') echo ' <OPTION VALUE="BODY" SELECTED>'._("Body")."\n";
84 else echo ' <OPTION VALUE="BODY">'._("Body")."\n";
85
86 if (isset($where) && $where == 'TEXT') echo ' <OPTION VALUE="TEXT" SELECTED>'._("Everywhere")."\n";
87 else echo ' <OPTION VALUE="TEXT">'._("Everywhere")."\n";
88
89 if (isset($where) && $where == 'SUBJECT') echo ' <OPTION VALUE="SUBJECT" SELECTED>'._("Subject")."\n";
90 else echo ' <OPTION VALUE="SUBJECT">'._("Subject")."\n";
91
92 if (isset($where) && $where == 'FROM') echo ' <OPTION VALUE="FROM" SELECTED>'._("From")."\n";
93 else echo ' <OPTION VALUE="FROM">'._("From")."\n";
94
95 if (isset($where) && $where == 'CC') echo ' <OPTION VALUE="Cc" SELECTED>'._("Cc")."\n";
96 else echo ' <OPTION VALUE="CC">'._("Cc")."\n";
97
98 if (isset($where) && $where == 'TO') echo ' <OPTION VALUE="TO" SELECTED>'._("To")."\n";
99 else echo ' <OPTION VALUE="TO">'._("To")."\n";
100
101 echo " </SELECT>\n";
102 echo " </TD>\n";
103 echo " <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n";
104 echo " <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n";
105 echo " </TD>\n";
106 echo " </TR>\n";
107 echo " </TABLE>\n";
108 echo "</FORM>";
109 echo "</td></tr></table>";
110 do_hook("search_after_form");
111 if (isset($where) && $where && isset($what) && $what) {
112 sqimap_mailbox_select($imapConnection, $mailbox);
113 sqimap_search($imapConnection, $where, $what, $mailbox, $color);
114 }
115 do_hook("search_bottom");
116 sqimap_logout ($imapConnection);
117 ?>
118 </body></html>