1 # Routines for actually displaying (parts of) database in CGI output.
3 # Copyright (C) 1999 Ian Jackson <ijackson@chiark.greenend.org.uk>
5 # This is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 2,
8 # or (at your option) any later version.
10 # This is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public
16 # License along with this file; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 sub list_database ($) {
22 print DEBUG "ldb 0 $instyle\n";
23 $instyle =~ m/^all|area|viewoverlap|overlap/ or die "$instyle ?";
25 &{"dblist_prep_$listing"}();
27 print DEBUG "ldb 1 $v @kl\n";
28 foreach $k (keys %db) {
29 print DEBUG "ldb q $k\n";
31 $dblt_network= $ent->{'network'};
32 $dblt_prefix= $ent->{'prefix'};
33 next unless &{"dblist_cond_$listing"};
36 print DEBUG "ldb 2 @kl\n";
38 $x= $db{$a}->{'network'} cmp $db{$b}->{'network'}; return $x if $x;
39 $x= $db{$a}->{'prefix'} <=> $db{$b}->{'prefix'}; return $x if $x;
40 return -1 if $a eq 'picked' && $b ne 'picked';
41 return +1 if $b eq 'picked' && $a ne 'picked';;
42 $x= $db{$a}->{'name'} cmp $db{$b}->{'name'}; return $x if $x;
43 $x= $db{$a}->{'contact'} cmp $db{$b}->{'contact'}; return $x if $x;
46 print DEBUG "ldb 3 @kl\n";
47 $listingnonefound= @kl ? 0 : 1;
48 print DEBUG "ldb end $listingnonefound\n";
49 $v= "listing$listing"; $$v= 1;
53 sub dblist_prep_all { }
54 sub dblist_cond_all { 1; }
56 sub dblist_prep_area {
57 $dblo_network= $area_networks[$list_areai];
58 $dblo_prefix= $area_prefixes[$list_areai];
59 $listarea= display_net($dblo_network,$dblo_prefix);
61 sub dblist_cond_area { dblist_cond_overlap(); }
63 sub dblist_prep_overlap {
64 ($dblo_network,$dblo_prefix) = parse_netrange($in{'with'});
65 $listoverlap= display_net($dblo_network,$dblo_prefix);
67 sub dblist_cond_overlap {
68 return net_overlap($dblt_network,$dblt_prefix, $dblo_network,$dblo_prefix);
71 sub dblist_prep_viewoverlap {
72 ($dblo_network,$dblo_prefix) = ($network,$prefix);
73 $listoverlap= display_net($network,$prefix);
75 sub dblist_cond_viewoverlap { dblist_cond_overlap(); }
77 sub foreach_start_db { $db_i=0; }
78 sub foreach_cond_db { return $db_i < @kl; }
79 sub foreach_incr_db { $db_i++; }
80 sub foreach_setvars_db {
84 $dblt_network= $ent->{'network'};
85 $dblt_prefix= $ent->{'prefix'};
86 $db_picked= $k eq 'picked';
92 $db_net= display_net($dblt_network,$dblt_prefix);
93 if (exists $db{'picked'}) {
94 $db_pickedoverlap= net_overlap($dblt_network, $dblt_prefix,
95 $pick_network, $pick_prefix);
100 $db_viewing= ($k eq $id);
104 $db_name= html_sani($ent->{'name'});
105 $db_contact= html_sani($ent->{'contact'});
106 $db_hiddenemail= !!$ent->{'hiddenemail'};
107 $db_email= $db_hiddenemail ? "" : html_sani($ent->{'email'});
108 $db_confirmed= !!$ent->{'changed'};