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