#!/usr/bin/perl use CGI qw(:standard); $bbslist = "/opt/BBSacct/bbslist.txt"; $bbs = "/opt/BBSacct/bbsacct.exe"; @bbspop = ("ALL"); $BBSPass = "!BBS4acct"; $| = 1; open(BBSL,$bbslist); @lines = ; close(BBSL); foreach $line (@lines) { chomp($line); @s = split(/ /,$line); push(@bbspop,$s[0]); } print header; print "

BBS User Account Management

\n"; print start_html('BBS Account Management'), start_form, "User Name: ",textfield(-name=>'Uname',-size=>15), p, radio_group(-name=>'ad',-values=>['Add Account','Delete Account','Change Password'],-default=>'Add Account'), p, "BBS Hostname: ",popup_menu(-name=>'Host',-values=>[@bbspop],-default=>'ALL'), p, "New Password: ",textfield(-name=>'Npass',-size=>15)," (Minimum 8 characters containing 1 upper, 1 lower, 1 number, and 1 special)", p, "Execute Password: ",password_field(-name=>'Epass',-size=>8)," ",submit(-name=>'Execute'), end_form, hr; if (param()) { $Epass = param(Epass); $Uname = param(Uname); $ad = param(ad); $Host = param(Host); $Npass = param(Npass); if ($Epass ne BBS) { print "Invalid Execute Password\n"; exit; } else { print "Processing\n"; print "
\n"; } stringcheck($Uname,"User Name"); if ($Host ne "ALL") { $pc = `ping $Host`; if ($pc =~ /alive/) { } else { print "Could not connect to $Host\n"; print "
\n"; exit; } open(BBSF,$bbslist); @lines = ; close(BBSF); foreach $line (@lines) { chomp($line); @s = split(/ /,$line); $hc = $s[0]; if ($Host =~ /$hc/) { $Pass = $s[1]; } } if ($ad eq "Add Account") { stringcheck($Npass,"New Password"); runexp($Host,$Pass,$Uname,$Npass,"a"); } if ($ad eq "Delete Account") { runexp($Host,$Pass,$Uname,$Npass,"d"); } if ($ad eq "Change Password") { stringcheck($Npass,"New Password"); runexp($Host,$Pass,$Uname,$Npass,"d"); runexp($Host,$Pass,$Uname,$Npass,"a"); } } else { open(BBSL,$bbslist); @lines = ; close(BBSL); foreach $line (@lines) { chomp($line); @s = split(/ /,$line); $Host = $s[0]; $Pass = $s[1]; $pc = `ping $Host`; if ($pc =~ /alive/) { } else { print "Could not connect to $Host\n"; print "
\n"; next; } if ($ad eq "Add Account") { stringcheck($Npass,"New Password"); runexp($Host,$Pass,$Uname,$Npass,"a"); } if ($ad eq "Delete Account") { runexp($Host,$Pass,$Uname,$Npass,"d"); } if ($ad eq "Change Password") { stringcheck($Npass,"New Password"); runexp($Host,$Pass,$Uname,$Npass,"d"); runexp($Host,$Pass,$Uname,$Npass,"a"); } } } } sub stringcheck { my($nc,$em) = @_; if (length($nc) == 0) { print "ERROR - Must input $em\n"; exit; } } sub runexp { my($Ho,$Pa,$Us,$Na,$Wh) = @_; @f = `$bbs $Ho $Pa $Us $Wh $Na`; foreach $line (@f) { chomp($line); if ($line =~ /COMPLETE/) { @s = split(/Z/,$line); $em = $s[1]; print "$em Complete\n"; print "
\n"; } if ($line =~ /^ERROR/) { @s = split(/Z/,$line); $em = $s[1]; print "$em\n"; print "
\n"; } } }