<%
# Returns a list of the applications installed on the machine
#
sub apps_installed
{
my $dir = $ENV{DOCUMENT_ROOT}."/apps";
my @list = ();
local *DIR;
opendir( DIR, "$dir" ) or return undef;
@list = grep { ( -d "$dir/$_" or -l "$dir/$_" ) && !/^\.\.?/ } readdir DIR;
closedir DIR;
return @list;
}
# Given a list of applications installed, alters the display order so
# they are sorted, with the admin server last
#
sub order
{
my @list = @_;
# sort putting anything numerically prefixed names first
my @numlist = sort { <=> } grep /^\d/, @list ;
my @alphalist = sort grep !/^\d/, @list;
my @newlist = ( @numlist, @alphalist );
# move admin to the end
LIST:
for ( my $i=0; $i<@newlist; $i++ )
{
if ( $newlist[$i] eq 'admin' )
{
push( @newlist, splice( @newlist, $i, 1 ));
last LIST;
}
}
return @newlist;
}
# Adds the hypertext links for the installed applications in the adminserver
#
sub display ()
{
my @apps = &order( &apps_installed );
if ( scalar @apps == 0 )
{
# No applications installed
Z::write("No applications are installed!, please reinstall \
the admin server.");
return;
}
foreach $item ( @apps )
{
Z::write( "\n");
}
}
## Go do it!
&display;
%>
© Copyright Zeus Technology Limited 1997-2000. All rights reserved.