";
#This next if statement checks to make sure the user inputted a valid code from a form
if (($Form{'code'} eq "XXXXXXXXXXXXXX") || ($Form{'code'} eq "XXXXXXXXX") || ($Form{'code'} eq "XXXXXXX")){
open(kick, "$Form{'han'}.txt"); #This opens a file with the members handle
@kick = ; #this reads it
close(kick); #closes it
foreach (@kick){
chomp; #chomps it
}
$kick = @kick[0];
#This checks to see if the file is blank specificaly doesn't have a first line
if($kick eq ""){
$kick = 1; #makes the kickvote total 1
print "The new kick vote total is $kick","/","3"; #prints total
@kick = ($kick, $Form{'code'}, "-", "-"); #stores the kickvote total, code used to vote, and the two place holder for the other required codes to kick a member
} else {
$codeok = 1; #place holder
#this checks to see if the inputed code has been used before
foreach $line (@kick){
if ($line eq "$Form{'code'}"){
$codeok = 0; #if the code has been used, this is set to 0
print "That code has already been used";
}
}
#runs this if code has not been used
if ($codeok == 1){
$kick++; #adds 1 to the total
@kick[0] = "$kick"; #stores $kick to the aray
$kicks = join('#', @kick); $joins all the keys in @kick together for editing
$kicks =~ s/-/$Form{'code'}/; #replacing the first encountered "-" with the code inputted
@kick = split(/#/, $kicks); #splits it back up
print "The new kick vote total is $kick","/","3";
}
}
#this checks to see if all the codes have voted to kick the member
if ($kick == 3){
open(memb, "membs.txt"); #opens membs.txt for reading
@membs = ; #reads .txt file
close(memb); #closes
foreach (@membs){
chomp; #chomps the \n off
}
@search = grep(!/&$Form{'han'}&/, @membs); #searches for every user in the @membs (contents of ) and puts into @search. So it virtualy takes the user out of the text file
open(memb, ">membs.txt"); #opens it for writing
foreach $line (@search){
print memb "$line\n"; #prints the contents off the last membs, but without the kicked member
}
close(memb);
open(THING, "$Form{'han'}.txt");
close(THING);
$ext = ".txt"; #stores the extension
$filename = "$Form{'han'}$ext"; #defines file to be deleted
unlink "$Form{'han'}.txt" or die "Couldn't delete $filename: $!"; #should delete the file that stored the kickvote total and used codes
print " Member Kicked Out of Clan";
}
#this next bit just stores the kick info into the file
open(kick, ">$Form{'han'}.txt");
foreach $line (@kick){
print kick "$line\n";
}
close(kick);
print "";
} else {
print "That is not a valid code.";
}