X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=machines.cgi;h=5cdbbcd021449508136426ab902403e44e9a4d55;hb=f9609dae4f7fce6ca978c830f8e6311b7a94723c;hp=166c2cae566f51f7061860871e3d419e0c8a7f70;hpb=295f9baecdce2ac043eaf41833094b0435d932aa;p=mirror%2Fuserdir-ldap-cgi.git diff --git a/machines.cgi b/machines.cgi index 166c2ca..5cdbbcd 100755 --- a/machines.cgi +++ b/machines.cgi @@ -17,7 +17,7 @@ use POSIX; use MIME::Base64; use Digest::MD5 qw(md5_hex); -my (%attrs, @attrorder, %summaryattrs, @summaryorder); +my (%attrs, @attrorder, %summaryattrs, @summaryorder, %summarylistitems); # This defines the description of the fields, and which fields are retrieved %attrs = ('hostname' => 'Host name', @@ -50,13 +50,14 @@ my (%attrs, @attrorder, %summaryattrs, @summaryorder); # ditto for summary %summaryattrs = ('hostname' => 'Host name', - 'host' => 'just for a link', - 'architecture' => 'Architecture', - 'distribution' => 'Distribution', + 'host' => 'just for a link', + 'architecture' => 'Architecture', 'status' => 'Status', - 'access' => 'Access'); - -@summaryorder = ('hostname', 'architecture', 'distribution', 'status', 'access'); + 'access' => 'Access', + 'sponsor' => 'Sponsor', + 'purpose' => 'Purpose'); +@summaryorder = qw{hostname architecture sponsor purpose status access}; +%summarylistitems = map {$_=>1} qw{purpose sponsor}; # Global settings... my %config = &Util::ReadConfigFile; @@ -83,6 +84,28 @@ sub sshfingerprint { return $hrfpr; } +sub wiki_link($) { + my ($in) = @_; + $in =~ s#\[\[(.*?)\|(.*?)\]\]#$2#g; + $in =~ s#\[\[(.*?)\]\]#$1#g; + return $in; +} + +sub item_uplist($) { + my ($items) = @_; + my $out = undef; + + if (scalar @$items >= 1) { + $out = ""; + } + return $out; +} + $SIG{__DIE__} = \&DieHandler; my $query = new CGI; @@ -92,6 +115,7 @@ my $sortorder = lc($query->param('sortorder')) || "asc"; &Util::HTMLSendHeader; $ldap = Net::LDAP->new($config{ldaphost}) || &Util::HTMLError($!); +&Util::UpgradeConnection($ldap) unless $config{usessl} eq 'False'; $mesg; $ldap->bind; @@ -134,34 +158,26 @@ foreach $dn (sort {$entries->{$a}->{host}->[0] cmp $entries->{$b}->{host}->[0]} $output{sshrsahostfprint} .= sshfingerprint($key) . "
"; } - # URL - my ($sponsor, $url) = undef; - $output{sponsor} = undef; - foreach $sponsor (@{$data->{sponsor}}) { - $sponsor =~ m#((http|ftp)://\S+)#i; - $url = $1; - $sponsor =~ s/\s*$url\s*//; - $output{sponsor} .= "
" if ($output{sponsor}); - if ($url) { - $output{sponsor} .= sprintf("%s", $url, $sponsor); - } else { - $output{sponsor} .= $sponsor; - } - } + my $sponsor = item_uplist($data->{sponsor}); + $output{sponsor} = $sponsor if defined $sponsor; + my $purpose = item_uplist($data->{purpose}); + $output{purpose} = $purpose if defined $purpose; - #Reformat purposes to be pleasing for the human eye: - $output{purpose} = join(",", @{$data->{purpose}}); - - $selected = " selected "; + $selected = " selected "; } - - $hostlist .= "