X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=web%2Fmachines.cgi;h=e0ee813c8766f72c04ea2b5eca066e1295bb1ad3;hb=fa5376db2dfc333147d1b672a954742cf98733c5;hp=973b43294ba338f44fa390b573eb1113a22fb53c;hpb=17450b68dfef531fd21a59bc615f24426f080d6f;p=mirror%2Fuserdir-ldap.git diff --git a/web/machines.cgi b/web/machines.cgi index 973b432..e0ee813 100755 --- a/web/machines.cgi +++ b/web/machines.cgi @@ -1,5 +1,6 @@ #!/usr/bin/perl -#$Id: machines.cgi,v 1.2 1999/09/30 05:38:29 tausq Exp $ +# $Id: machines.cgi,v 1.8 2000/08/20 02:32:46 tausq Exp $ + # (c) 1999 Randolph Chung. Licensed under the GPL. use lib '.'; @@ -18,14 +19,15 @@ my (%attrs, @attrorder, %summaryattrs, @summaryorder); 'distribution' => 'Distribution', 'access' => 'Access', 'sponsor' => 'Sponsor', - 'sponsorurl' => 'Sponsor URL', 'sponsor-admin' => 'Sponsor admin', 'location' => 'Location', 'machine' => 'Processor', 'memory' => 'Memory', 'disk' => 'Disk space', 'bandwidth' => 'Bandwidth', + 'status' => 'Status', 'notes' => 'Notes', + 'description' => 'Description', 'createtimestamp' => 'Entry created', 'modifytimestamp' => 'Entry modified' ); @@ -33,15 +35,18 @@ my (%attrs, @attrorder, %summaryattrs, @summaryorder); # This defines what fields are displayed, and in what order @attrorder = ('hostname', 'admin', 'architecture', 'distribution', 'access', 'sponsor', 'sponsor-admin', 'location', 'machine', 'memory', - 'disk', 'bandwidth', 'notes', 'createtimestamp', 'modifytimestamp'); + 'disk', 'bandwidth', 'status', 'notes', 'description', + 'createtimestamp', 'modifytimestamp'); # ditto for summary %summaryattrs = ('hostname' => 'Host name', 'host' => 'just for a link', 'architecture' => 'Architecture', + 'distribution' => 'Distribution', + 'status' => 'Status', 'access' => 'Access'); -@summaryorder = ('hostname', 'architecture', 'access'); +@summaryorder = ('hostname', 'architecture', 'distribution', 'status', 'access'); # Global settings... my %config = &Util::ReadConfigFile; @@ -65,7 +70,7 @@ $mesg = $ldap->search(base => $config{hostbasedn}, filter => 'host=*'); $mesg->code && &Util::HTMLError($mesg->error); $entries = $mesg->as_struct; -foreach $dn (sort {$entries->{$a}->{host}->[0] <=> $entries->{$b}->{host}->[0]} keys(%$entries)) { +foreach $dn (sort {$entries->{$a}->{host}->[0] cmp $entries->{$b}->{host}->[0]} keys(%$entries)) { $data = $entries->{$dn}; my $thishost = $data->{host}->[0]; @@ -77,6 +82,11 @@ foreach $dn (sort {$entries->{$a}->{host}->[0] <=> $entries->{$b}->{host}->[0]} foreach $key (keys(%attrs)) { $output{$key} = $data->{$key}->[0]; } + + $output{hostname} = undef; + foreach my $hostname (@{$data->{hostname}}) { + $output{hostname} .= sprintf("%s%s", ($output{hostname} ? ', ' : ''), $hostname); + } # Modified/created time. TODO: maybe add is the name of the creator/modifier $output{modifytimestamp} = &Util::FormatTimestamp($output{modifytimestamp}); @@ -87,7 +97,19 @@ foreach $dn (sort {$entries->{$a}->{host}->[0] <=> $entries->{$b}->{host}->[0]} $output{'sponsor-admin'} = sprintf("%s", $output{'sponsor-admin'}, $output{'sponsor-admin'}); # URL - $output{sponsor} = sprintf("%s", $output{sponsorurl}, $output{sponsor}); + my ($sponsor, $url) = undef; + $output{sponsor} = undef; + foreach $sponsor (@{$data->{sponsor}}) { + $sponsor =~ m#((http|ftp)://\S+)#i; + $url = $1; + $sponsor =~ s/$url//; + $output{sponsor} .= "
" if ($output{sponsor}); + if ($url) { + $output{sponsor} .= sprintf("%s", $url, $sponsor); + } else { + $output{sponsor} .= $sponsor; + } + } $selected = " selected "; } @@ -99,8 +121,10 @@ foreach $dn (sort {$entries->{$a}->{host}->[0] <=> $entries->{$b}->{host}->[0]} $summary{$thishost}{$key} = $data->{$key}->[0]; } - $summary{$thishost}{hostname} = sprintf("%s", - $summary{$thishost}{host}, $summary{$thishost}{hostname}); + $summary{$thishost}{hostname} = undef; + foreach my $hostname (@{$data->{hostname}}) { + $summary{$thishost}{hostname} .= sprintf("%s%s", ($summary{$thishost}{hostname} ? '
' : ''), $summary{$thishost}{host}, $hostname); + } } $ldap->unbind; @@ -109,18 +133,18 @@ if ($output{havehostdata}) { $hostdetails .= "\n"; } else { # display summary info $hostdetails = "

Summary

\n"; - $hostdetails .= "\n
"; + $hostdetails .= "\n"; foreach $key (@summaryorder) { - $hostdetails .= ""; + $hostdetails .= ""; } - $hostdetails .= "\n"; + $hostdetails .= "\n"; foreach $host (sort(keys(%summary))) { $hostdetails .= "";
$summaryattrs{$key}$summaryattrs{$key}