default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / edit / process / addr_range.html
1 <& elements/process.html,
2   'table'           => 'addr_range',
3   'popup_reload'    => 'Address range changed',
4   'precheck_callback' => sub {
5     my ($cgi) = @_;
6     my $start = NetAddr::IP->new($cgi->param('start'), 0)
7       or return 'Illegal or empty (IP address) start: '.$cgi->param('start');
8     if ( length($cgi->param('end')) ) {
9       my $end = NetAddr::IP->new($cgi->param('end'), 0)
10         or return 'Illegal or empty (IP address) end: '.$cgi->param('end');
11       if ( $end < $start ) {
12         ($start, $end) = ($end, $start);
13         $cgi->param('end', $end->addr);
14         $cgi->param('start', $start->addr);
15       }
16       # detect addr ranges that are too big
17       my ($one) = split('\.', $start->addr);
18       if ( $one < 128 and $start + 0x7FFFFFFF <= $end ) {
19         # then this is going to overflow
20         return "Address ranges must be < 2^31 - 1 addresses long.";
21       } # if the first octet is >= 128, then it's in the top half of 
22         # address space and it CAN'T be too big
23
24       $cgi->param('length', $end - $start + 1);
25     } else {
26       $cgi->param('length', 1);
27     }
28     '';
29   },
30 &>