<%args> $pua_id <%once> use DBI; Personal User Agent
  PUA Interface - Electronic Numbering System InternetNZ  
 

 
 
<& nav.html, pua_id => $pua_id, current_page => 'pua_rules.html' &>

Rules

<& _list_rules, pua_id => $pua_id &>


 
Powered by Catalyst IT
<%def _list_rules> <%args> $pua_id <%init> my $dbh = DBI->connect('dbi:Pg:dbname=pua', 'pua', 'pua') or die "Couldn't connect to database: " . DBI->errstr; my $sth = $dbh->prepare("SELECT * from rule WHERE pua_id=$pua_id;"); $sth->execute or die "Execute failed: " . $sth->errstr; my $rv = ""; my @current; while (@current = $sth->fetchrow_array()) { my @actions = split(/:::/, $current[5]); my $temp = ""; my $editstring = ""; my $criteriastring = ""; my $count = 0; foreach my $action (@actions) { if ($action =~ s/connect://) { $editstring .= "&action$count=connect&device$count=$action"; my $sh = $dbh->prepare("SELECT device_name from owner_device where device_id=$action;"); $sh->execute or die "Execute failed: " . $sh->errstr; my $device = $sh->fetchrow_array(); $temp .= "connect to $device, "; } elsif ($action =~ s/check://){ $editstring .= "&action$count=$action&device$count="; $temp .= "execute rule $action, "; } $count++; } if ($current[4] =~ /(hours:)(\d{4})(-)(\d{4})/) { $criteriastring = "and current time is between $2 and $4 "; $editstring .= "&starttime=$2&endtime=$4"; } print "$current[2] "; print "[edit] "; print "[delete]
"; my $contact = ''; if (!$current[3]) { $contact = "anybody"; } else { my $sh = $dbh->prepare("SELECT contact_name from pua_contact where contact_id=$current[3];"); $sh->execute or die "Execute failed: " . $sh->errstr; $contact = $sh->fetchrow_array(); } print "If caller is $contact "; print "$criteriastring "; chop($temp); chop($temp); print "$temp.

"; } print $rv;