8
8
* @copyright © 1999-2006 The SquirrelMail Project Team
9
9
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
10
* @version $Id: search.php,v 1.92.2.16 2006/06/29 14:18:32 kink Exp $
10
* @version $Id: search.php,v 1.92.2.18 2006/07/27 18:58:48 tokul Exp $
11
11
* @package squirrelmail
12
12
* @subpackage search
37
37
sqgetGlobalVar('composenew' , $composenew, SQ_FORM);
38
38
sqgetGlobalVar('composesession' , $composesession , SQ_SESSION);
40
if (isset($_GET['mailbox'])) {
41
$mailbox = strip_tags($_GET['mailbox']);
43
if (isset($_GET['submit'])) {
44
$submit = strip_tags($_GET['submit']);
46
if (isset($_GET['what'])) {
47
$what = $_GET['what'];
49
if (isset($_GET['where'])) {
50
$where = strip_tags($_GET['where']);
52
if (isset($_GET['checkall'])) {
53
$checkall = strip_tags($_GET['checkall']);
55
if (isset($_GET['count'])) {
56
$count = strip_tags($_GET['count']);
40
if (!sqgetGlobalVar('mailbox',$mailbox,SQ_GET)) {
43
if (!sqgetGlobalVar('submit',$submit,SQ_GET)) {
46
if (!sqgetGlobalVar('what',$what,SQ_GET)) {
49
if (! sqgetGlobalVar('where',$where,SQ_GET) ||
50
! in_array( $where, array('BODY','TEXT','SUBJECT','FROM','CC','TO'))) {
51
// make sure that 'where' is one if standard IMAP SEARCH keywords
54
// FIXME: what is this?
55
if (!sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
58
if (sqgetGlobalVar('count',$count,SQ_GET)) {
59
$count = (int) $count;
58
63
/* end of get globals */
187
192
$saved_types = array(0 => 'saved_what', 1 => 'saved_where', 2 => 'saved_folder');
188
193
$saved_array = get_saved($username, $data_dir);
189
194
$save_index = $save_index -1;
190
$saved_count = (count($saved_array['saved_what']) + 1);
195
if (isset($saved_array['saved_what'])) {
196
$saved_count = (count($saved_array['saved_what']) + 1);
198
// there are no saved searches. Function is used to save first search
191
201
$attributes = get_recent ($username, $data_dir);
193
203
foreach ($types as $key) {
274
284
displayPageHeader($color, $mailbox);
276
286
/* See how the page was called and fire off correct function */
277
if ((!isset($submit) || empty($submit)) && !empty($what)) {
287
if (empty($submit) && !empty($what)) {
278
288
$submit = _("Search");
280
if ( !isset( $submit ) ) {
282
} else if ($submit == _("Search") && !empty($what)) {
291
if ($submit == _("Search") && !empty($what)) {
283
292
if ($recent_count > 0) {
284
293
update_recent($what, $where, $mailbox, $username, $data_dir);
287
elseif ($submit == 'forget') {
296
elseif ($submit == 'forget' && isset($count)) {
288
297
forget_recent($count, $username, $data_dir);
290
elseif ($submit == 'save') {
299
elseif ($submit == 'save' && isset($count)) {
291
300
save_recent($count, $username, $data_dir);
293
elseif ($submit == 'delete') {
302
elseif ($submit == 'delete' && isset($count)) {
294
303
delete_saved($count, $username, $data_dir);
318
327
. html_tag( 'table', '', 'center', $color[9], 'width="95%" cellpadding="1" cellspacing="1" border="0"' )
319
328
. html_tag( 'tr',
320
html_tag( 'td', '<b>Saved Searches</b>', 'center' )
329
html_tag( 'td', '<b>'._("Saved Searches") . '</b>', 'center' )
322
331
. html_tag( 'tr' )
323
332
. html_tag( 'td' )
329
338
echo html_tag( 'tr', '', '', $color[4] );
331
echo html_tag( 'td', imap_utf7_decode_local($saved_attributes['saved_folder'][$i + 1]), 'left', '', 'width="35%"' )
332
. html_tag( 'td', $saved_attributes['saved_what'][$i + 1], 'left' )
333
. html_tag( 'td', $saved_attributes['saved_where'][$i + 1], 'center' )
340
echo html_tag( 'td', htmlspecialchars(imap_utf7_decode_local($saved_attributes['saved_folder'][$i + 1])), 'left', '', 'width="35%"' )
341
. html_tag( 'td', htmlspecialchars($saved_attributes['saved_what'][$i + 1]), 'left' )
342
. html_tag( 'td', htmlspecialchars($saved_attributes['saved_where'][$i + 1]), 'center' )
334
343
. html_tag( 'td', '', 'right' )
335
344
. '<a href="search.php'
336
. '?mailbox=' . htmlspecialchars($saved_attributes['saved_folder'][$i + 1])
337
. '&what=' . htmlspecialchars($saved_attributes['saved_what'][$i + 1])
338
. '&where=' . htmlspecialchars($saved_attributes['saved_where'][$i + 1])
345
. '?mailbox=' . urlencode($saved_attributes['saved_folder'][$i + 1])
346
. '&what=' . urlencode($saved_attributes['saved_what'][$i + 1])
347
. '&where=' . urlencode($saved_attributes['saved_where'][$i + 1])
339
348
. '">' . _("edit") . '</a>'
340
349
. ' | '
341
350
. '<a href="search.php'
376
385
if (isset($attributes['search_what'][$i]) &&
377
386
!empty($attributes['search_what'][$i])) {
378
echo html_tag( 'td', imap_utf7_decode_local($attributes['search_folder'][$i]), 'left', '', 'width="35%"' )
387
echo html_tag( 'td', htmlspecialchars(imap_utf7_decode_local($attributes['search_folder'][$i])), 'left', '', 'width="35%"' )
379
388
. html_tag( 'td', htmlspecialchars($attributes['search_what'][$i]), 'left' )
380
. html_tag( 'td', $attributes['search_where'][$i], 'center' )
389
. html_tag( 'td', htmlspecialchars($attributes['search_where'][$i]), 'center' )
381
390
. html_tag( 'td', '', 'right' )
382
391
. "<a href=\"search.php?count=$i&submit=save\">"
399
408
echo '</table></td></tr></table><br />';
411
/** FIXME: remove or fix it. $newsort is not set and not extracted from request
403
412
if (isset($newsort)) {
404
413
$sort = $newsort;
405
414
sqsession_register($sort, 'sort');
408
417
/*********************************************************************
409
418
* Check to see if we can use cache or not. Currently the only time *
411
420
* used. Also check to make sure we actually have the array in the *
412
421
* registered session data. :) *
413
422
*********************************************************************/
424
/** FIXME: remove or fix it. $use_mailbox_cache is not set and not extracted from request
414
425
if (! isset($use_mailbox_cache)) {
415
426
$use_mailbox_cache = 0;
418
429
/* There is a problem with registered vars in 4.1 */
441
452
echo ' </select>'.
443
if ( !isset( $what ) ) {
446
if ( !isset( $where ) ) {
455
// FIXME: explain all str_replace calls.
451
456
$what_disp = str_replace(',', ' ', $what);
452
457
$what_disp = str_replace('\\\\', '\\', $what_disp);
453
458
$what_disp = str_replace('\\"', '"', $what_disp);
534
539
/* must have search terms to search */
535
540
if ($submit == _("Search") && empty($what)) {
537
. html_tag( 'div', '<b>Please enter something to search for</b>', 'center' ) . "\n";
542
. html_tag( 'div', '<b>' . _("Please enter something to search for") . '</b>', 'center' ) . "\n";
540
545
$allow_thread_sort = $old_value;