www.pudn.com > coolchat.zip > checkforbidipid.pl


sub checkforbididip 
{ 
            my($id,$room) = @_; 
             
            my $lowid = lc($id); 
            my ($theusername,$thetime) = (); 
 
            #First, check forbid ID 
            my $forbidfile = "$ChaTempFilePath$room.out"; 
            if(open(FORBID, "$forbidfile")) 
            { 
                my @lines=; 
                close(FORBID); 
                foreach $line(@lines) 
                {   	 
                     ($theusername,$thetime)=split(/:/,$line); 
                     return 1 if($theusername eq $lowid); 
                } 
            } 
 
            #Second, check forbid IP 
            $forbidfile = "$ChaTempFilePath$room.ip"; 
            if(open(FORBID, "<$forbidfile")) 
            { 
                my @lines=; 
                close(FORBID); 
                foreach $line(@lines) 
                {   	 
                    chomp($line); 
                    return 2 if($line eq $ENV{'REMOTE_ADDR'}); 
                } 
            } 
            return 0; 
} 
 
sub checkforbidroom 
{ 
	my $roomname = shift; 
	local($fbroom,$forbidfile,$line) = (); 
	$roomname = lc($roomname); 
 
        $forbidfile = $ChaTempFilePath."forbidroom.dat"; 
        if(open(FORBID, "$forbidfile")) 
        { 
                my @lines=; 
                close(FORBID); 
                foreach $line(@lines) 
                {   	 
                     ($fbroom)=split(/:/,$line,1); 
                     if(lc($fbroom) eq $roomname) 
                     { 
                         return 1; 
               	     } 
                } 
        } 
        return 0; 
} 
1;