| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * right_main.php |
| 5 | * |
| 6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
| 7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 8 | * |
| 9 | * $Id$ |
| 10 | */ |
| 11 | |
| 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'); |
| 16 | |
| 17 | function s_opt( $val, $sel, $tit ) { |
| 18 | echo " <option value=\"$val\""; |
| 19 | if ( $sel ) { |
| 20 | echo ' selected'; |
| 21 | } |
| 22 | echo ">$tit</option>\n"; |
| 23 | } |
| 24 | |
| 25 | displayPageHeader($color, $mailbox); |
| 26 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
| 27 | |
| 28 | do_hook('search_before_form'); |
| 29 | echo "<br>\n". |
| 30 | " <table width=\"95%\" align=center cellpadding=2 cellspacing=0 border=0>\n". |
| 31 | " <tr><td bgcolor=\"$color[0]\">\n". |
| 32 | " <center><b>"._("Search")."</b></center>\n". |
| 33 | " </td></tr>\n". |
| 34 | ' <tr><td align=center>'. |
| 35 | |
| 36 | "<FORM ACTION=\"$PHP_SELF\" NAME=s>\n". |
| 37 | " <TABLE WIDTH=\"75%\">\n". |
| 38 | " <TR>\n". |
| 39 | " <TD WIDTH=\"33%\">\n". |
| 40 | ' <TT><SMALL><SELECT NAME="mailbox">'; |
| 41 | |
| 42 | $boxes = sqimap_mailbox_list($imapConnection); |
| 43 | for ($i = 0; $i < count($boxes); $i++) { |
| 44 | if (!in_array('noselect', $boxes[$i]['flags'])) { |
| 45 | $box = $boxes[$i]['unformatted']; |
| 46 | $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']); |
| 47 | if ($mailbox == $box) { |
| 48 | echo " <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n"; |
| 49 | } else { |
| 50 | echo " <OPTION VALUE=\"$box\">$box2</OPTION>\n"; |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | echo ' </SELECT></SMALL></TT>'. |
| 55 | " </TD>\n". |
| 56 | " <TD ALIGN=\"CENTER\" WIDTH=\"33%\">\n"; |
| 57 | if (!isset($what)) { |
| 58 | $what = ''; |
| 59 | } |
| 60 | $what_disp = ereg_replace(',', ' ', $what); |
| 61 | $what_disp = str_replace('\\\\', '\\', $what_disp); |
| 62 | $what_disp = str_replace('\\"', '"', $what_disp); |
| 63 | $what_disp = str_replace('"', '"', $what_disp); |
| 64 | echo " <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what\" VALUE=\"$what_disp\">\n". |
| 65 | '</TD>'. |
| 66 | "<TD ALIGN=\"RIGHT\" WIDTH=\"33%\">\n". |
| 67 | '<SELECT NAME="where">'; |
| 68 | |
| 69 | s_opt( 'BODY', ($where == 'BODY'), _("Body") ); |
| 70 | s_opt( 'TEXT', ($where == 'TEXT'), _("Everywhere") ); |
| 71 | s_opt( 'SUBJECT', ($where == 'SUBJECT'), _("Subject") ); |
| 72 | s_opt( 'FROM', ($where == 'FROM'), _("From") ); |
| 73 | s_opt( 'CC', ($where == 'CC'), _("Cc") ); |
| 74 | s_opt( 'TO', ($where == 'TO'), _("To") ); |
| 75 | |
| 76 | echo " </SELECT>\n" . |
| 77 | " </TD>\n". |
| 78 | " <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n". |
| 79 | " <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n". |
| 80 | " </TD>\n". |
| 81 | " </TR>\n". |
| 82 | " </TABLE>\n". |
| 83 | "</FORM>". |
| 84 | "</td></tr></table>"; |
| 85 | do_hook("search_after_form"); |
| 86 | if (isset($where) && $where && isset($what) && $what) { |
| 87 | sqimap_mailbox_select($imapConnection, $mailbox); |
| 88 | sqimap_search($imapConnection, $where, $what, $mailbox, $color); |
| 89 | } |
| 90 | do_hook("search_bottom"); |
| 91 | sqimap_logout ($imapConnection); |
| 92 | |
| 93 | echo '</body></html>'; |
| 94 | |
| 95 | ?> |