~ubuntu-branches/ubuntu/hardy/squirrelmail/hardy-updates

« back to all changes in this revision

Viewing changes to src/search.php

  • Committer: Bazaar Package Importer
  • Author(s): Thijs Kinkhorst
  • Date: 2006-08-11 13:53:20 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20060811135320-a54q8uf2ncuwc5es
Tags: 2:1.4.8-1
* New upstream release
  - Includes security fix: variable overwriting in compose.php
    by logged-in user [CVE-2006-4019]
  - Does not ship SquirrelMail developer's documentation anymore.

* Remove duplicate content from README.locales.
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 *
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
13
13
 */
37
37
sqgetGlobalVar('composenew' , $composenew, SQ_FORM);
38
38
sqgetGlobalVar('composesession' , $composesession , SQ_SESSION);
39
39
 
40
 
if (isset($_GET['mailbox'])) {
41
 
    $mailbox = strip_tags($_GET['mailbox']);
42
 
}
43
 
if (isset($_GET['submit'])) {
44
 
    $submit = strip_tags($_GET['submit']);
45
 
}
46
 
if (isset($_GET['what'])) {
47
 
    $what = $_GET['what'];
48
 
}
49
 
if (isset($_GET['where'])) {
50
 
    $where = strip_tags($_GET['where']);
51
 
}
52
 
if (isset($_GET['checkall'])) {
53
 
    $checkall = strip_tags($_GET['checkall']);
54
 
}
55
 
if (isset($_GET['count'])) {
56
 
    $count = strip_tags($_GET['count']);
 
40
if (!sqgetGlobalVar('mailbox',$mailbox,SQ_GET)) {
 
41
    unset($mailbox);
 
42
}
 
43
if (!sqgetGlobalVar('submit',$submit,SQ_GET)) {
 
44
    $submit = '';
 
45
}
 
46
if (!sqgetGlobalVar('what',$what,SQ_GET)) {
 
47
    $what='';
 
48
}
 
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
 
52
    $where = 'FROM';
 
53
}
 
54
// FIXME: what is this?
 
55
if (!sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
 
56
    unset($checkall);
 
57
}
 
58
if (sqgetGlobalVar('count',$count,SQ_GET)) {
 
59
    $count = (int) $count;
 
60
} else {
 
61
    unset($count);
57
62
}
58
63
/* end of get globals */
59
64
 
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);
 
197
    } else {
 
198
        // there are no saved searches. Function is used to save first search
 
199
        $saved_count = 1;
 
200
    }
191
201
    $attributes = get_recent ($username, $data_dir);
192
202
    $n = 0;
193
203
    foreach ($types as $key) {
274
284
    displayPageHeader($color, $mailbox);
275
285
}
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");
279
289
}
280
 
if ( !isset( $submit ) ) {
281
 
    $submit = '';
282
 
} else if ($submit == _("Search") && !empty($what)) {
 
290
 
 
291
if ($submit == _("Search") && !empty($what)) {
283
292
    if ($recent_count > 0) {
284
293
        update_recent($what, $where, $mailbox, $username, $data_dir);
285
294
    }
286
295
}
287
 
elseif ($submit == 'forget') {
 
296
elseif ($submit == 'forget' && isset($count)) {
288
297
    forget_recent($count, $username, $data_dir);
289
298
}
290
 
elseif ($submit == 'save') {
 
299
elseif ($submit == 'save' && isset($count)) {
291
300
    save_recent($count, $username, $data_dir);
292
301
}
293
 
elseif ($submit == 'delete') {
 
302
elseif ($submit == 'delete' && isset($count)) {
294
303
    delete_saved($count, $username, $data_dir);
295
304
}
296
305
 
317
326
    echo "<br />\n"
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' )
321
330
      )
322
331
    . html_tag( 'tr' )
323
332
    . html_tag( 'td' )
328
337
        } else {
329
338
            echo html_tag( 'tr', '', '', $color[4] );
330
339
        }
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
 
        .     '&amp;what=' . htmlspecialchars($saved_attributes['saved_what'][$i + 1])
338
 
        .     '&amp;where=' . htmlspecialchars($saved_attributes['saved_where'][$i + 1])
 
345
        .     '?mailbox=' . urlencode($saved_attributes['saved_folder'][$i + 1])
 
346
        .     '&amp;what=' . urlencode($saved_attributes['saved_what'][$i + 1])
 
347
        .     '&amp;where=' . urlencode($saved_attributes['saved_where'][$i + 1])
339
348
        .   '">' . _("edit") . '</a>'
340
349
        .   '&nbsp;|&nbsp;'
341
350
        .   '<a href="search.php'
375
384
            }
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&amp;submit=save\">"
383
392
               .     _("save")
399
408
    echo '</table></td></tr></table><br />';
400
409
}
401
410
 
402
 
 
 
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');
406
 
}
 
415
}*/
407
416
 
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
 *********************************************************************/
 
423
 
 
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;
416
 
}
 
427
}*/
417
428
 
418
429
/* There is a problem with registered vars in 4.1 */
419
430
/*
440
451
 
441
452
   echo '         </select>'.
442
453
        "       </td>\n";
443
 
if ( !isset( $what ) ) {
444
 
    $what = '';
445
 
}
446
 
if ( !isset( $where ) ) {
447
 
    $where = 'FROM';
448
 
}
449
 
 
450
 
 
 
454
 
 
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)) {
536
541
        echo '<br />'
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";
538
543
}
539
544
 
540
545
$allow_thread_sort = $old_value;