* We now escape properly in strings
[squirrelmail.git] / src / search.php
CommitLineData
c61bb006 1<?php
245a6892 2
3 /* $Id$ */
4
c61bb006 5 session_start();
6
7 if(!isset($logged_in)) {
441f2d33 8 set_up_language($squirrelmail_language, true);
c61bb006 9 echo _("You must login first.");
10 exit;
11 }
12 if(!isset($username) || !isset($key)) {
91dc6e4e 13 include ('../themes/default_theme.php');
14 include ('../functions/display_messages.php');
10455998 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!")
91dc6e4e 18 . '<br><a href="../src/login.php">'
19 . _("Click here to log back in.") . '</a>.', $color);
20 echo '</body></html>';
c61bb006 21 exit;
22 }
23
245a6892 24 if (!isset($strings_php))
91dc6e4e 25 include('../functions/strings.php');
a3432f47 26 if (!isset($i18n_php))
91dc6e4e 27 include('../functions/i18n.php');
c61bb006 28 if (!isset($config_php))
91dc6e4e 29 include('../config/config.php');
c61bb006 30 if (!isset($page_header_php))
91dc6e4e 31 include('../functions/page_header.php');
c61bb006 32 if (!isset($imap_php))
91dc6e4e 33 include('../functions/imap.php');
1809bad8 34 if (!isset($imap_search_php))
91dc6e4e 35 include('../functions/imap_search.php');
c61bb006 36 if (!isset($array_php))
91dc6e4e 37 include('../functions/array.php');
c61bb006 38
91dc6e4e 39 include('../src/load_prefs.php');
c61bb006 40
41 displayPageHeader($color, $mailbox);
1809bad8 42 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
c61bb006 43
91dc6e4e 44 do_hook('search_before_form');
74a7d5b0 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";
91dc6e4e 50 echo ' <tr><td align=center>';
c61bb006 51
d7d3c4d4 52 echo "<FORM ACTION=\"search.php\" NAME=s>\n";
1809bad8 53 echo " <TABLE WIDTH=75%>\n";
54 echo " <TR>\n";
55 echo " <TD WIDTH=33%>\n";
91dc6e4e 56 echo ' <TT><SMALL><SELECT NAME="mailbox">';
c61bb006 57
1809bad8 58 $boxes = sqimap_mailbox_list($imapConnection);
59 for ($i = 0; $i < count($boxes); $i++) {
91dc6e4e 60 if (!in_array('noselect', $boxes[$i]['flags'])) {
61 $box = $boxes[$i]['unformatted'];
62 $box2 = replace_spaces($boxes[$i]['unformatted-disp']);
1809bad8 63 if ($mailbox == $box)
64 echo " <OPTION VALUE=\"$box\" SELECTED>$box2\n";
65 else
66 echo " <OPTION VALUE=\"$box\">$box2\n";
c61bb006 67 }
1809bad8 68 }
91dc6e4e 69 echo ' </SELECT></SMALL></TT>';
1809bad8 70 echo " </TD>\n";
71 echo " <TD ALIGN=\"CENTER\" WIDTH=33%>\n";
245a6892 72 if (!isset($what))
91dc6e4e 73 $what = '';
74 $what_disp = ereg_replace(',', ' ', $what);
6553723c 75 $what_disp = str_replace('\\\\', '\\', $what_disp);
76 $what_disp = str_replace('\\"', '"', $what_disp);
91dc6e4e 77 $what_disp = str_replace('"', '&quot;', $what_disp);
acb61cb4 78 echo " <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what\" VALUE=\"$what_disp\">\n";
91dc6e4e 79 echo ' </TD>';
1809bad8 80 echo " <TD ALIGN=\"RIGHT\" WIDTH=33%>\n";
91dc6e4e 81 echo ' <SELECT NAME="where">';
1809bad8 82
91dc6e4e 83 if (isset($where) && $where == 'BODY') echo ' <OPTION VALUE="BODY" SELECTED>'._("Body")."\n";
84 else echo ' <OPTION VALUE="BODY">'._("Body")."\n";
35678c48 85
91dc6e4e 86 if (isset($where) && $where == 'TEXT') echo ' <OPTION VALUE="TEXT" SELECTED>'._("Everywhere")."\n";
87 else echo ' <OPTION VALUE="TEXT">'._("Everywhere")."\n";
1809bad8 88
91dc6e4e 89 if (isset($where) && $where == 'SUBJECT') echo ' <OPTION VALUE="SUBJECT" SELECTED>'._("Subject")."\n";
90 else echo ' <OPTION VALUE="SUBJECT">'._("Subject")."\n";
1809bad8 91
91dc6e4e 92 if (isset($where) && $where == 'FROM') echo ' <OPTION VALUE="FROM" SELECTED>'._("From")."\n";
93 else echo ' <OPTION VALUE="FROM">'._("From")."\n";
1809bad8 94
91dc6e4e 95 if (isset($where) && $where == 'CC') echo ' <OPTION VALUE="Cc" SELECTED>'._("Cc")."\n";
96 else echo ' <OPTION VALUE="CC">'._("Cc")."\n";
35678c48 97
91dc6e4e 98 if (isset($where) && $where == 'TO') echo ' <OPTION VALUE="TO" SELECTED>'._("To")."\n";
99 else echo ' <OPTION VALUE="TO">'._("To")."\n";
1809bad8 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>";
06ad27a2 110 do_hook("search_after_form");
245a6892 111 if (isset($where) && $where && isset($what) && $what) {
1809bad8 112 sqimap_mailbox_select($imapConnection, $mailbox);
113 sqimap_search($imapConnection, $where, $what, $mailbox, $color);
114 }
06ad27a2 115 do_hook("search_bottom");
1809bad8 116 sqimap_logout ($imapConnection);
c61bb006 117?>
a1401db6 118</body></html>