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