c61bb006 |
1 | <?php |
245a6892 |
2 | |
35586184 |
3 | /** |
4 | * right_main.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * $Id$ |
10 | */ |
2d367c68 |
11 | |
35586184 |
12 | require_once('../src/validate.php'); |
13 | require_once('../functions/imap.php'); |
14 | require_once('../functions/imap_search.php'); |
15 | require_once('../functions/array.php'); |
c61bb006 |
16 | |
29eb5486 |
17 | function s_opt( $val, $sel, $tit ) { |
18 | echo " <option value=\"$val\""; |
0d672ac0 |
19 | if ( $sel == $val ) { |
bd9bbfef |
20 | echo ' selected'; |
99d2a184 |
21 | } |
29eb5486 |
22 | echo ">$tit</option>\n"; |
23 | } |
99d2a184 |
24 | |
0d672ac0 |
25 | /* ------------------------ main ------------------------ */ |
26 | |
29eb5486 |
27 | displayPageHeader($color, $mailbox); |
28 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
c61bb006 |
29 | |
0d672ac0 |
30 | if( !isset( $search_memory ) ) { |
31 | $search_memory = 0; |
32 | } |
33 | |
29eb5486 |
34 | do_hook('search_before_form'); |
35 | echo "<br>\n". |
0d672ac0 |
36 | " <table width=\"95%\" align=center cellpadding=2 cellspacing=0 border=0>\n". |
37 | " <tr><td bgcolor=\"$color[0]\">\n". |
38 | " <center><b>"._("Search")."</b></center>\n". |
39 | " </td></tr>\n". |
40 | ' <tr><td align=center>'; |
c61bb006 |
41 | |
0d672ac0 |
42 | for ( $form = 0; $form <= $search_memory; $form++ ) { |
c61bb006 |
43 | |
0d672ac0 |
44 | $frm = "$form"; |
45 | $what = "what$frm"; |
46 | $where = "where$frm"; |
47 | |
48 | if( $search_memory > 0 ) { |
49 | if ( $$what == '' ) { |
50 | $$what = getPref($data_dir, $username, "search_what$frm", '' ); |
51 | $$where = getPref($data_dir, $username, "search_where$frm", '' ); |
29eb5486 |
52 | } else { |
0d672ac0 |
53 | setpref( $data_dir, $username, "search_what$frm", $$what ); |
54 | setpref( $data_dir, $username, "search_where$frm", $$where ); |
55 | } |
29eb5486 |
56 | } |
0d672ac0 |
57 | echo " <TABLE WIDTH=\"75%\" cellpadding=0 cellspacing=0>\n"; |
58 | if( !($form == 0 && $search_memory > 0) ) { |
29eb5486 |
59 | |
0d672ac0 |
60 | echo "<FORM ACTION=\"$PHP_SELF\" NAME=s>\n". |
61 | "<input type=hidden name=pos value=\"$frm\">". |
62 | " <TR>\n". |
63 | " <TD WIDTH=\"33%\">\n". |
64 | ' <TT><SMALL><SELECT NAME="mailbox">'; |
65 | |
66 | $boxes = sqimap_mailbox_list($imapConnection); |
67 | |
68 | for ($i = 0; $i < count($boxes); $i++) { |
69 | if (!in_array('noselect', $boxes[$i]['flags'])) { |
70 | $box = $boxes[$i]['unformatted']; |
71 | $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']); |
72 | if ($mailbox == $box) { |
73 | echo " <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n"; |
74 | } else { |
75 | echo " <OPTION VALUE=\"$box\">$box2</OPTION>\n"; |
76 | } |
77 | } |
78 | } |
79 | echo ' </SELECT></SMALL></TT>'. |
80 | " </TD>\n". |
81 | " <TD ALIGN=\"CENTER\" WIDTH=\"33%\">\n"; |
82 | if (!isset($$what)) { |
83 | $$what = ''; |
84 | } |
85 | $what_disp = str_replace(',', ' ', $$what); |
86 | $what_disp = str_replace('\\\\', '\\', $what_disp); |
87 | $what_disp = str_replace('\\"', '"', $what_disp); |
88 | $what_disp = str_replace('"', '"', $what_disp); |
89 | echo " <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what$frm\" VALUE=\"$what_disp\">\n". |
90 | '</TD>'. |
91 | "<TD ALIGN=\"RIGHT\" WIDTH=\"33%\">\n". |
92 | "<SELECT NAME=\"where$frm\">"; |
93 | |
94 | s_opt( 'BODY', $$where, _("Body") ); |
95 | s_opt( 'TEXT', $$where, _("Everywhere") ); |
96 | s_opt( 'SUBJECT', $$where, _("Subject") ); |
97 | s_opt( 'FROM', $$where, _("From") ); |
98 | s_opt( 'CC', $$where, _("Cc") ); |
99 | s_opt( 'TO', $$where, _("To") ); |
100 | |
101 | echo " </SELECT>\n" . |
102 | " </TD>\n". |
103 | " <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n". |
104 | " <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n". |
105 | " </TD>\n". |
106 | " </TR>\n". |
107 | '</FORM>'; |
108 | } |
109 | echo " </TABLE>\n"; |
110 | } |
29eb5486 |
111 | |
0d672ac0 |
112 | echo "</td></tr></table>"; |
29eb5486 |
113 | do_hook("search_after_form"); |
0d672ac0 |
114 | if( !isset( $pos ) ) { |
115 | $pos = $frm; |
116 | } |
117 | $what = "what$pos"; |
118 | $where = "where$pos"; |
119 | |
120 | if (isset($$where) && $$where && isset($$what) && $$what) { |
29eb5486 |
121 | sqimap_mailbox_select($imapConnection, $mailbox); |
0d672ac0 |
122 | sqimap_search($imapConnection, $$where, $$what, $mailbox, $color); |
29eb5486 |
123 | } |
124 | do_hook("search_bottom"); |
125 | sqimap_logout ($imapConnection); |
99d2a184 |
126 | |
29eb5486 |
127 | echo '</body></html>'; |
99d2a184 |
128 | |
0d672ac0 |
129 | ?> |