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.

196 lines
5.1 KiB

#!/usr/bin/perl
#
# $Id: adminclient.pl,v 1.6 2006/01/23 21:39:30 ddoughty Exp $
#
# Source File: adminclient.pl
# Get config
require 'sitecfg.pl';
&app_initialize;
print "Content-Type: text/html\n\n";
if (&get_session($FORM{'tid'})) {
if ($FORM{'lang'} ne $SESSION{'lang'}) { &set_session($FORM{'tid'},'lang',$FORM{'lang'});}
&get_client_configuration($FORM{'clid'});
$SYSTEM{'supportedlanguagesreg'} = &GetSupportedLanguages($SYSTEM{'DEFAULTLANG'},'N','N','N');
$SYSTEM{'supportedlanguagesmult'} = &GetSupportedLanguages($SYSTEM{'ALLOWEDLANGS'},'N','N','Y');
&get_client_configuration();
$SESSION{'lang'} = ($SYSTEM{'DEFAULTLANG'} eq '') ? "enu" : $SYSTEM{'DEFAULTLANG'};
$SESSION{'lang'} = ($FORM{'lang'} eq '') ? $SESSION{'lang'} : $FORM{'lang'};
&LoadLanguage($SESSION{'lang'});
if ($FORM{'dbop'} eq 'cnew') {
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "New Client");
$FORM{'newclient'} = "Y";
@lines = &get_template("cdef");
&print_response;
} elsif ($FORM{'dbop'} eq 'cdel') {
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "Delete Client $FORM{'clid'}");
&open_results;
&client_delete_response;
&close_results;
} elsif ($FORM{'dbop'} eq 'cupd') {
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "Edit Client $FORM{'clid'}");
&get_client_profile($FORM{'clid'});
@lines = &get_template("cdef");
&print_response;
} else {
&show_illegal_access_warning;
}
}
sub print_response {
foreach $line (@lines) {
$srch = "<%=CLIENT.REPORTING%>";
if ( $line =~ /$srch/i) {
&client_reporting_options($CLIENT{'clid'});
} else {
$line = &xlatline($line);
}
}
}
sub client_reporting_options {
# @rrecs = &get_test_list($_[0]);
}
sub client_delete_response {
&get_client_profile($FORM{'clid'});
print "Deleting $FORM{'clid'} $CLIENT{'clnmc'} ...<BR>\n";
# open preservation file
$archivefile = join($pathsep, $dataroot, "$FORM{'clid'}.dat");
$archivefile =~ s/$docroot/$archiveroot/g;
open (ARCHFILE, ">$archivefile");
# delete client profile
@crecs = &get_data("clients.dat");
$trash = join($pathsep, $dataroot, "clients.dat");
open (TMPFILE, ">$trash");
foreach $crec (@crecs) {
chop ($crec);
($id, $trash) = split(/&/, $crec);
if ($id eq $CLIENT{'clid'}) {
print ARCHFILE "$crec\n";
print "client profile $id archived $! ...<BR>\n";
} else {
print TMPFILE "$crec\n";
}
}
close TMPFILE;
# delete administrative logins
@crecs = &get_data("admin.dat");
$trash = join($pathsep, $dataroot, "admin.dat");
open (TMPFILE, ">$trash");
foreach $crec (@crecs) {
chop ($crec);
($id, $pwd, $pv, $clid) = split(/&/, $crec);
if ($clid eq $CLIENT{'clid'}) {
print ARCHFILE "$crec\n";
print "admin login $id archived $! ...<BR>\n";
} else {
print TMPFILE "$crec\n";
}
}
close TMPFILE;
close ARCHFILE;
$chmodok = chmod 0666, $archivefile;
# delete logos
$ulinkdir = join($pathsep, $pubroot, "graphic");
opendir (GDIR, $ulinkdir);
@dots = readdir(GDIR);
closedir GDIR;
$rmmask = "$CLIENT{'clid'}.";
foreach $rmfile (@dots) {
if ($rmfile =~ /$rmmask/ ) {
$ulinkfile = join($pathsep, $pubroot, "graphic", $rmfile);
$archivefile = $ulinkfile;
$archivefile =~ s/$docroot/$archiveroot/g;
rename $ulinkfile, $archivefile;
print "$ulinkfile archived $! ...<BR>\n";
}
}
@dots = ();
# delete cnd file
$tofile = join($pathsep, $dataroot, "cnd.$CLIENT{'clid'}");
$archivefile = $tofile;
$archivefile =~ s/$docroot/$archiveroot/g;
rename $tofile, $archivefile;
print "$tofile archived $! ...<BR>\n";
# delete reports file
$tofile = join($pathsep, $dataroot, "reports.$CLIENT{'clid'}");
$archivefile = $tofile;
$archivefile =~ s/$docroot/$archiveroot/g;
rename $tofile, $archivefile;
print "$tofile archived $! ...<BR>\n";
# delete tests file
$tofile = join($pathsep, $dataroot, "tests.$CLIENT{'clid'}");
$archivefile = $tofile;
$archivefile =~ s/$docroot/$archiveroot/g;
rename $tofile, $archivefile;
print "$tofile archived $! ...<BR>\n";
# delete test graphic files
opendir (GDIR, $testgraphic);
@dots = readdir(GDIR);
closedir GDIR;
$rmmask = "$CLIENT{'clid'}.";
foreach $rmfile (@dots) {
if ($rmfile =~ /$rmmask/ ) {
$ulinkfile = join($pathsep, $testgraphic, $rmfile);
$archivefile = $ulinkfile;
$archivefile =~ s/$docroot/$archiveroot/g;
rename $ulinkfile, $archivefile;
print "$ulinkfile archived $! ...<BR>\n";
}
}
@dots = ();
# delete test questions files
opendir (GDIR, $questionroot);
@dots = readdir(GDIR);
closedir GDIR;
$rmmask = ".$CLIENT{'clid'}";
foreach $rmfile (@dots) {
if ($rmfile =~ /$rmmask/ ) {
$ulinkfile = join($pathsep, $questionroot, $rmfile);
$archivefile = $ulinkfile;
$archivefile =~ s/$docroot/$archiveroot/g;
rename $ulinkfile, $archivefile;
print "$ulinkfile archived $! ...<BR>\n";
}
}
@dots = ();
# delete index page
$tofile = join($pathsep, $pubroot, "$CLIENT{'clid'}", "index.htm");
$cnt = unlink $tofile;
print "$tofile deleted $! ...<BR>\n";
}
sub open_results {
print "<HTML>
<BODY>
";
}
sub close_results {
print "
<P><CENTER>
<FORM>
<INPUT TYPE=SUBMIT VALUE=\"Close\" onClick='window.close()'>
</FORM>
</CENTER></P>
</BODY>
</HTML>
";
}