2fb69f6da38091833ad80ad12e354b3b9381d01f
[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 echo "<br>
32 <table width=95% align=center cellpadding=2 cellspacing=0 border=0>
33 <tr><td bgcolor=\"$color[0]\">
34 <center><b>"._("Search")."</b></center>
35 </td></tr>
36 <tr><td align=center>";
37
38 echo "<FORM ACTION=\"search.php\">\n";
39 echo " <TABLE WIDTH=75%>\n";
40 echo " <TR>\n";
41 echo " <TD WIDTH=33%>\n";
42 echo " <TT><SMALL><SELECT NAME=\"mailbox\">";
43
44 $boxes = sqimap_mailbox_list($imapConnection);
45 for ($i = 0; $i < count($boxes); $i++) {
46 if ($boxes[$i]["flags"][0] != "noselect" && $boxes[$i]["flags"][1] != "noselect" && $boxes[$i]["flags"][2] != "noselect") {
47 $box = $boxes[$i]["unformatted"];
48 $box2 = replace_spaces($boxes[$i]["formatted"]);
49 if ($mailbox == $box)
50 echo " <OPTION VALUE=\"$box\" SELECTED>$box2\n";
51 else
52 echo " <OPTION VALUE=\"$box\">$box2\n";
53 }
54 }
55 echo " </SELECT></SMALL></TT>";
56 echo " </TD>\n";
57 echo " <TD ALIGN=\"CENTER\" WIDTH=33%>\n";
58 $what_disp = ereg_replace(",", " ", $what);
59 $what_disp = str_replace("\\\\", "\\", $what_disp);
60 $what_disp = str_replace("\\\"", "\"", $what_disp);
61 $what_disp = str_replace("\"", "&quot;", $what_disp);
62 echo " <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what\" VALUE=\"$what_disp\">\n";
63 echo " </TD>";
64 echo " <TD ALIGN=\"RIGHT\" WIDTH=33%>\n";
65 echo " <SELECT NAME=\"where\">";
66
67 if ($where == "BODY") echo " <OPTION VALUE=\"BODY\" SELECTED>"._("Body")."\n";
68 else echo " <OPTION VALUE=\"BODY\">"._("Body")."\n";
69
70 if ($where == "TEXT") echo " <OPTION VALUE=\"TEXT\" SELECTED>"._("Everywhere")."\n";
71 else echo " <OPTION VALUE=\"TEXT\">"._("Everywhere")."\n";
72
73 if ($where == "SUBJECT") echo " <OPTION VALUE=\"SUBJECT\" SELECTED>"._("Subject")."\n";
74 else echo " <OPTION VALUE=\"SUBJECT\">"._("Subject")."\n";
75
76 if ($where == "FROM") echo " <OPTION VALUE=\"FROM\" SELECTED>"._("From")."\n";
77 else echo " <OPTION VALUE=\"FROM\">"._("From")."\n";
78
79 if ($where == "CC") echo " <OPTION VALUE=\"Cc\" SELECTED>"._("Cc")."\n";
80 else echo " <OPTION VALUE=\"CC\">"._("Cc")."\n";
81
82 if ($where == "TO") echo " <OPTION VALUE=\"TO\" SELECTED>"._("To")."\n";
83 else echo " <OPTION VALUE=\"TO\">"._("To")."\n";
84
85 echo " </SELECT>\n";
86 echo " </TD>\n";
87 echo " <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n";
88 echo " <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n";
89 echo " </TD>\n";
90 echo " </TR>\n";
91 echo " </TABLE>\n";
92 echo "</FORM>";
93 echo "</td></tr></table>";
94 if ($where && $what) {
95 sqimap_mailbox_select($imapConnection, $mailbox);
96 sqimap_search($imapConnection, $where, $what, $mailbox, $color);
97 }
98 sqimap_logout ($imapConnection);
99 ?>
100 </body></html>