1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#!/usr/bin/perl
require ("./cgi-lib.pl") || die "can\'t require cgi-lib.pl: $!";;
require ("./common.pl") || die "can\'t require common.pl: $!";;
@days=(0,31,28,31,30,31,30,31,31,30,31,30,31 );
#--------------------------------------------------------------------------
# Header Routine
#--------------------------------------------------------------------------
sub header {
local($mo,$yr)=@_;
print "Content-type: text/html
<HTML>
<HEAD>
<TITLE>WebPlan User Administration</TITLE>
</HEAD>
<BODY>
<CENTER><P ALIGN=\"CENTER\"> <IMG SRC=\"rtsban.jpg\"></P></CENTER>
";
} # header
#--------------------------------------------------------------------------
# Print the content of the FORM
#--------------------------------------------------------------------------
sub form {
print "<FORM method=post action=admin.cgi>\n";
print "User: <INPUT TYPE=TEXT NAME=\"user\" SIZE=\"12\" \n>";
print "Server: <INPUT TYPE=TEXT NAME=\"server\" SIZE=\"36\" \n>";
print "<INPUT TYPE=SUBMIT NAME=action VALUE=\"Add\"> \n" ;
print "<INPUT TYPE=SUBMIT NAME=action VALUE=\"Delete\"> \n" ;
print "</FORM>\n" ;
print "<br>\n";
print "<B><U>Instructions</B></U><br>\n";
print "<U>Add</U> require to enter User AND server name (please include domain name)<br>\n";
print ". If user \"Team\" do not exist please create it. This one is a general-purpose user for everyone.<br>\n";
print "<U>Delete</U> require to enter only the username.<br>\n";
print ". User is removed from the list<br>\n";
print ". If the server = WebServer : user data is <B><font color=\"#ff0000\">deleted</font></B><br>\n";
print ". Else : data is <U>not</U> deleted on remote server<br>\n";
} # form
#--------------------------------------------------------------------------
# Print the Footer
#--------------------------------------------------------------------------
sub footer {
print <<"END";
END
print "</BODY>";
print "</HTML>";
} # footer
#--------------------------------------------------------------------------
# Main Function
#--------------------------------------------------------------------------
@PlanData=&obtain_user;
&header;
&ReadParse;
# print "User=$in{user} Server=$in{server} Action=$in{action}<br>\n";
$err="";
if ( ! ($in{action} eq "" || $in{user} eq "" ) ) {
print "<hr>";
if ( $in{action} eq Add ) {
if ( $in{server} eq "" ) {
$err="Please specify server when adding a user\n";
}
else {
$dup=0;
foreach $line ( @PlanData ) {
@info=split(/;/,$line);
if ( $info[0] eq $in{user} ) {
$dup=1;
last;
}
}
if ( $dup == 1 ) {
$err="User $in{user} already exist \!\!\n";
}
else {
system("touch /usr/local/lib/netplan.dir/$in{user}");
system("echo $in{server} > /usr/local/lib/netplan.dir/.$in{user}");
}
}
}
elsif ( $in{action} eq Delete ) {
$found=0;
foreach $line ( @PlanData ) {
@info=split(/;/,$line);
if ( $info[0] eq $in{user} ) {
$found=1;
last;
}
}
if ( $found == 1 ) {
unlink "/usr/local/lib/netplan.dir/.$in{user}";
unlink "/usr/local/lib/netplan.dir/$in{user}";
} else {
$err="User $in{user} does not exist \!\n";
}
}
else {
#err="Invalid action \"$in{action}\". Please report to WebPlan administrator.";
}
@PlanData=&obtain_user;
}
&listUser;
&form;
print "<FONT COLOR=\"#ff0000\">$err</FONT><br>";
&footer;
|