You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

85 lines
2.1 KiB

#!/usr/bin/perl
#
# $Id: addadmin.pl,v 1.5 2006/01/23 21:39:30 ddoughty Exp $
#
# Source File: addadmin.pl
# Get config
require 'sitecfg.pl';
require 'testlib.pl';
&app_initialize;
print "Content-Type: text/html\n\n";
if (&get_session($FORM{'tid'})) {
&LanguageSupportInit();
if ($FORM{'dbop'} eq 'adel') {
&remove_adminid();
$SYSTEM{'message'} = "Administrator ID $FORM{'admid'} has been removed.";
} elsif ($FORM{'dbop'} eq 'anew') {
&upd_adminid();
$SYSTEM{'message'} = "Administrator ID $FORM{'admid'} has been added.";
} elsif ($FORM{'dbop'} eq 'aupd') {
&upd_adminid();
$SYSTEM{'message'} = "Administrator password for ID $FORM{'admid'} has been changed.";
} else {
$SYSTEM{'message'} = "";
}
$FORM{dbop} = "cupd";
&get_client_profile($FORM{'clid'});
&show_template("cdef");
}
sub get_admin_dbdef {
@admrecs = &get_data("admin.dat");
$admrec = $admrecs[0];
chop ($admrec);
@flds = split(/&/, $admrec);
for (0 .. $#flds) { $RECFLD{$flds[$_]} = $_;}
}
sub remove_adminid {
&get_admin_dbdef();
$outfile = join($pathsep, $dataroot, "admin.dat");
open (OUTFILE, ">$outfile");
print OUTFILE "$admrec\n";
for (1 .. $#admrecs) {
$admrec = $admrecs[$_];
chop ($admrec);
@dataitems = split(/&/, $admrec);
if ($dataitems[$RECFLD{'uid'}] ne $FORM{'admid'} ) {
print OUTFILE "$admrec\n";
}
}
close OUTFILE;
}
sub upd_adminid {
&get_admin_dbdef();
if ($FORM{'mclid'} ne "") {
$clid = $FORM{'mclid'};
} else {
$clid = $FORM{'clid'};
}
$clid =~ s/\+/ /g;
$outfile = join($pathsep, $dataroot, "admin.dat");
$!="";
open (OUTFILE, ">$outfile");
print OUTFILE "$admrec\n";
for (1 .. $#admrecs) {
$admrec = $admrecs[$_];
chop ($admrec);
@dataitems = split(/&/, $admrec);
if ($dataitems[$RECFLD{'uid'}] eq $FORM{'admid'} ) {
if ($FORM{'admpwd'} eq "") { $FORM{'admpwd'} = $dataitems[$RECFLD{'pwd'}]; }
$newadmrec = join('&', $FORM{'admid'}, $FORM{'admpwd'}, $FORM{'admtyp'}, $clid);
$admrec = $newadmrec;
$newadmrec = "";
}
print OUTFILE "$admrec\n";
}
unless ($newadmrec eq '') {print OUTFILE "$newadmrec\n";}
close OUTFILE;
}