summaryrefslogtreecommitdiffstats
path: root/cgi/exilog_cgi_param.pm
blob: 594853030b0f50b3901ae47d899f6a80841a0b65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/perl -w
#
# This file is part of the exilog suite.
#
# http://duncanthrax.net/exilog/
#
# (c) Tom Kistner 2004
#
# See LICENSE for licensing information.
#

package exilog_cgi_param;
use strict;
use exilog_cgi_html;
use exilog_config;

use Data::Dumper;

BEGIN {
  use Exporter;
  use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);

  $VERSION     = 0.1;
  @ISA         = qw(Exporter);
  @EXPORT      = qw(
                      $param
                   );

  %EXPORT_TAGS = ();
  @EXPORT_OK   = qw();

  use vars qw( $param );
}

$param = _init_cgi_params();

sub _init_cgi_params {
  my $param = {};

  foreach ($q->param) {
    my @test = $q->param($_);

    if ((scalar @test) > 1) {
      $param->{$_} = \@test;
    }
    else {
      $param->{$_} = $test[0];
    };
  };

  # defaults
  my $defaults = {
    'tab' => 'messages',
    'qw' => [ 'messages',
              'errors',
              'deliveries',
              'deferrals',
              'rejects',
              'queue' ],
    'q_qw' => [ 'frozen',
                'deferred',
                'bounce' ],
    'ss' => '-all',
    'q_ss' => '-all',
    'tr' => '-10m',
    'q_tr' => '-5m',
    'qs' => "",
    'q_qs' => "",
    'sr' => [ keys %{ $config->{servers} } ],
    'q_sr' => [ keys %{ $config->{servers} } ]
  };

  foreach (keys %{ $defaults }) {
    $param->{$_} = $defaults->{$_} unless exists($param->{$_});
  };
  return $param;
};


1;