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


sub transright 
{ 
	&get_form_data; 
	        if($formdata{'message'} eq "") 
        { 
	    &chatshowmsg; 
            exit 0; 
        } 
        $lowmaster = $formdata{'message'}; 
 
        MyDo $do_chatcheckmaster; 
        if ((&checkmaster($UserData{'User'},$UserData{'Room'}) ne 0)&&($UserData{'Group'} ne 99)) 
        {#See wether the quest is come from the right user 
	    &chatshowmsg; 
            exit 0; 
        } 
 
        MyDo $do_finduser; 
        
        $insertsite = 0; 
        if(open(USERLIST,"<$chatdatadir/$UserData{'Room'}$DATA")) 
        { 
            @userlines=; 
	    close(USERLIST); 
            $usernum = @userlines; 
            $insertsite = &finduser($lowmaster,$usernum); 
        } 
         
        if(($insertsite ne -1)&&($UserData{'Group'} ne 99)) 
        { 
	    &chatshowmsg; 
            exit 0; 
        } 
 
        &lock("$ChatRoomListFile"); 
        if(open(ROOMLIST, "<$ChatRoomListFile")) 
        {#Change the master  
	      @roomlines=;  
              close ROOMLIST; 
              if(open(ROOMLIST, ">$ChatRoomListFile")) 
              { 
                 foreach $roomline(@roomlines) 
                 { 
               	     ($roomname,$usernum,$master,$tails)=split(/:/,$roomline,4); 
               	     if($roomname eq $UserData{'Room'}) 
               	     { 
               	   	$roomline = "$roomname:$usernum:$lowmaster:$tails"; 
               	     } 
               	     print ROOMLIST $roomline; 
               	} 
               	close ROOMLIST; 
              } 
        } 
        &unlock("$ChatRoomListFile"); 
                
        $message = "这个聊天室的室主是:$formdata{'message'}!!"; 
        &UpdateChatData(0, $UserData{'User'},$UserData{'Room'},$UserData{'Nick'},$message); 
        &chatshowmsg; 
} 
1; #return true