136 lines
3.4 KiB
Perl
136 lines
3.4 KiB
Perl
#!/usr/bin/perl -wT
|
|
|
|
#----------------------------------------------------------------------
|
|
# user manager functions: initial
|
|
#
|
|
# Copyright (c) 2001 Daniel van Raay <danielvr@caa.org.au>
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
#----------------------------------------------------------------------
|
|
|
|
package esmith;
|
|
|
|
use strict;
|
|
use CGI ':all';
|
|
use CGI::Carp qw(fatalsToBrowser);
|
|
|
|
use esmith::cgi;
|
|
use esmith::config;
|
|
use esmith::util;
|
|
use esmith::db;
|
|
|
|
BEGIN
|
|
{
|
|
# Clear PATH and related environment variables so that calls to
|
|
# external programs do not cause results to be tainted. See
|
|
# "perlsec" manual page for details.
|
|
|
|
$ENV {'PATH'} = '';
|
|
$ENV {'SHELL'} = '/bin/bash';
|
|
delete $ENV {'ENV'};
|
|
}
|
|
|
|
esmith::util::setRealToEffective ();
|
|
|
|
$CGI::POST_MAX=1024 * 100; # max 100K posts
|
|
$CGI::DISABLE_UPLOADS = 1; # no uploads
|
|
|
|
my %conf;
|
|
tie %conf, 'esmith::config';
|
|
|
|
my %accounts;
|
|
tie %accounts, 'esmith::config', '/home/e-smith/db/accounts';
|
|
|
|
my $q = new CGI;
|
|
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf, 'Smeserver User Manager');
|
|
|
|
print <<EOF;
|
|
|
|
<P>To perform a user administration function, click one of the
|
|
links in the menu on the left of your screen. If your admin allows it,
|
|
you can:
|
|
|
|
<ul>
|
|
EOF
|
|
|
|
my $user = $ENV{'REMOTE_USER'};
|
|
|
|
my $userAdminPanels = db_get_prop(\%accounts, $user, 'AdminPanels');
|
|
$userAdminPanels = '' if ! defined ($userAdminPanels);
|
|
|
|
my $globalAdminPanels = db_get_prop(\%accounts, 'globalUP', 'AdminPanels');
|
|
$globalAdminPanels = '' if ! defined ($globalAdminPanels);
|
|
|
|
my @adminpanels;
|
|
if ( defined ($userAdminPanels) )
|
|
{
|
|
@adminpanels = grep (/^userpanel-/, ((split (/,/, $userAdminPanels, -1)),(split (/,/, $globalAdminPanels, -1))));
|
|
}
|
|
|
|
my $panel;
|
|
my %panelhash = ();
|
|
my $desc;
|
|
my $longdesc;
|
|
foreach $panel (@adminpanels)
|
|
{
|
|
unless (open (RD, "/etc/e-smith/web/panels/user/cgi-bin/$panel"))
|
|
{
|
|
warn "Can't open file /etc/e-smith/web/panels/user/cgi-bin/$panel: $!\n";
|
|
next;
|
|
}
|
|
|
|
$desc = "";
|
|
$longdesc = "";
|
|
while (<RD>)
|
|
{
|
|
if (/^\s*#\s*description\s*:\s*(.+?)\s*$/)
|
|
{
|
|
$desc = $1;
|
|
}
|
|
if (/^\s*#\s*longdesc\s*:\s*(.+?)\s*$/)
|
|
{
|
|
$longdesc = $1;
|
|
}
|
|
|
|
last if ( $desc && $longdesc );
|
|
}
|
|
close RD;
|
|
|
|
if ($desc && $longdesc)
|
|
{
|
|
$panelhash{$desc} = $longdesc;
|
|
}
|
|
}
|
|
|
|
foreach $panel (sort keys %panelhash)
|
|
{
|
|
print "<li><b>$panel</b> - <i>$panelhash{$panel}</i></li>\n";
|
|
}
|
|
|
|
print <<EOF;
|
|
</ul>
|
|
|
|
<P>This software comes with ABSOLUTELY NO WARRANTY. As part of our
|
|
commitment to open-source software, you are welcome to copy and
|
|
redistribute this software.
|
|
|
|
EOF
|
|
|
|
print $q->endform;
|
|
|
|
esmith::cgi::genFooter ($q);
|
|
|