Cover V12, I08

Article
Figure 1
Figure 2
Listing 1
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6
Listing 7
Listing 8
Listing 9
Listing 10

aug2003.tar

Listing 8 Query page section of the reporting script

    # Create a new CGI object
$q = new CGI;    

# Display query page
    print $q->header(-type=>'text/html');           # HTTP header
    start_page('Query Page','Query Page');
    print $q->start_form(-action=>$q->url(-path_info=>1)),

    # Make a two-column table.  On the left, the query fields.
    # On the right, some display option fields.
    $q->start_table({-border=>'0',-width=>'100%'}),
    $q->start_Tr,
    $q->start_td({-width=>'50%'}),

    # User selection scrolling list
    $q->p('Select one or more users: '),
    $q->scrolling_list(-name=>'users',
        -values=>\@userlist,
        -default=>$userlist[0],
        -size=>7,
        -multiple=>true
        ),

    # Domain match string text field
    $q->p("Enter a destination string to match (slow):"),
    $q->textfield('domain_filter'),

    # URL path match string text field
    $q->p("Enter a URL path string to match (slow):"),
    $q->textfield('url_filter'),

    # Start date drop-down menus
    $q->p("Start date: "),
    $q->popup_menu(-name=>'beg_month',
        -values=>\@months,
        -default=>$thismonth),
    $q->popup_menu(-name=>'beg_day',
        -values=>\@days,
        -default=>1),
    $q->popup_menu(-name=>'beg_year',
        -values=>\@years,
        -default=>$thisyear),
    " at ",
    $q->popup_menu(-name=>'beg_hour',
        -values=>\@hours,
        -default=>0),
    ":",
    $q->popup_menu(-name=>'beg_minute',
        -values=>\@minutes,
        -default=>0),
    " o\'clock",

    # End date drop-down menus
    $q->p("End date: "),
    $q->popup_menu(-name=>'end_month',
        -values=>\@months,
        -default=>$thismonth),
    $q->popup_menu(-name=>'end_day',
        -values=>\@days,
        -default=>$thisday),
    $q->popup_menu(-name=>'end_year',
        -values=>\@years,
        -default=>$thisyear),
    " at ",
    $q->popup_menu(-name=>'end_hour',
        -values=>\@hours,
        -default=>$thishour),
    ":",
    $q->popup_menu(-name=>'end_minute',
        -values=>\@minutes,
        -default=>$thisminute),
    " o\'clock",
    $q->p;

    # Huck in some hidden fields
    $q->delete('target');    # Delete the "target" param from last POST
    print $q->hidden('target','query_report'),    # Where to go next
    $q->hidden('whence','query_page'),    # What page we're coming from
    $q->hidden('offset','0'),             # What page to start on (1)
    
    # Submit and reset buttons
    $q->submit,
    $q->reset,

    # Now start the right column for display preferences
    $q->end_td,
    $q->start_td({-width=>'50%'}),

    # Display options follow:
    $q->p('Preferences:'),
    $q->popup_menu(-name=>'num_lines',
        -values=>[10,25,50,100,250,500],
        -default=>100),
    " results per page",$q->br,
    $q->checkbox(-name=>'show_date',
        -checked=>1,
        -label=>"show the Date column"),$q->br,
    $q->checkbox(-name=>'show_firewall',
        -checked=>1,
        -label=>'show the Firewall column'),$q->br,
    $q->checkbox(-name=>'show_user',
        -checked=>1,
        -label=>'show the User column'),$q->br,
    $q->checkbox(-name=>'show_source',
        -checked=>1,
        -label=>'show the Source IP column'),$q->br,
    $q->checkbox(-name=>'show_dest',
        -checked=>1,
        -label=>'show the Domain column'),$q->br,
    $q->checkbox(-name=>'show_url',
        -checked=>1,
        -label=>'show the URL Path column'),$q->br,

    $q->hr;

    # Ask how to sort this stuff
    %radio_labels=('ASC'=>'Ascending','DESC'=>'Descending');
    %column_labels=(
        'count'=>'Count',
        'datetime'=>'Date',
        'firewall'=>'Firewall',
        'username'=>'Username',
        'sourceip'=>'Source IP',
        'domain'=>'Domain',
        'url'=>'URL Path');
    print $q->p('Sort by:'),
    $q->start_table, $q->start_Tr, $q->start_td,
    $q->popup_menu(-name=>'sort1',
        -values=>['count','datetime','firewall','username','sourceip','domain','url'],
        -labels=>\%column_labels,
        -default=>'count'),
    $q->end_td, $q->start_td,
    $q->radio_group(-name=>'order1',
        -values=>['ASC','DESC'],
        -default=>'DESC',
        -labels=>\%radio_labels),
    $q->end_td, $q->end_Tr, $q->end_table,

    $q->p('Then by:'),
    $q->start_table, $q->start_Tr, $q->start_td,
    $q->popup_menu(-name=>'sort2',
        -values=>['','count','datetime','firewall','username','sourceip','domain','url'],
        -labels=>\%column_labels,
        -default=>''),
    $q->end_td, $q->start_td,
    $q->radio_group(-name=>'order2',
        -values=>['ASC','DESC'],
        -default=>'ASC',
        -labels=>\%radio_labels),
    $q->end_td, $q->end_Tr, $q->end_table,

    $q->p('Then by:'),
    $q->start_table, $q->start_Tr, $q->start_td,
    $q->popup_menu(-name=>'sort3',
        -values=>['','count','datetime','firewall','username','sourceip','domain','url'],
        -labels=>\%column_labels,
        -default=>''),
    $q->end_td, $q->start_td,
    $q->radio_group(-name=>'order3',
        -values=>['ASC','DESC'],
        -default=>'ASC',
        -labels=>\%radio_labels),
    $q->end_td, $q->end_Tr, $q->end_table,

    # End the right column
    $q->end_td,
    $q->end_Tr,
    $q->end_table,

    # End the page
    $q->end_form;
    end_page;