#####################################################
#  LEO SuperCool BBS / LeoBBS X / 雷傲極酷超級論壇  #
#####################################################
# 基於山鷹(糊)、花無缺製作的 LB5000 XP 2.30 免費版  #
#   新版程式製作 & 版權所有: 雷傲科技 (C)(R)2004    #
#####################################################
#      主頁地址： http://www.LeoBBS.com/            #
#      論壇地址： http://bbs.LeoBBS.com/            #
#####################################################

      unlink ("${lbdir}cache/id/$infilemembername.cgi");
      if (($inmembername ne "")&&($inmembername ne "訪客")) {
	if (open(FILE,"${lbdir}data/idbans.cgi")) {
           $term_idbannedmembers = <FILE>;  
           close(FILE);
           $term_idbannedmembers =~ s/\t/\_/isg;
           $term_idbannedmembers = "\_$term_idbannedmembers\_";
           $term_idbannedmembers =~ s/\_\_/\_/isg;
	   $term_idbannedmembers =~ s/(\.|\*|\(|\)|\||\\|\/|\?|\+|\[|\])//ig;
           $tempinmembername = "\_$inmembername\_";
	   $tempinmembername =~ s/(\.|\*|\(|\)|\||\\|\/|\?|\+|\[|\])//ig;
           if ($term_idbannedmembers =~ /$tempinmembername/i) { &error(" ID 被禁止&由於你沒遵守本站規定！你的 ID ($inmembername) 被禁止！如有疑問，請聯絡管理員。"); }
	}
      }

      if ($arrowformwhere ne "") {
	$arrowwhere = "no";
	use testinfo qw(ipwhere);
	$fromwhere = &ipwhere("$trueipaddress");
	if ($fromwhere ne "") {
	  $arrowformwhere =~ s/ ,/,/isg;
	  $arrowformwhere =~ s/, /,/isg;
	  my @arrowformwhere = split(/\,/,$arrowformwhere);
	  foreach (@arrowformwhere) {
	    next if ($_ eq "");
	    if (($fromwhere =~ m/$_/)||($_ =~ m/$fromwhere/)) { #准許\此地區
	    	$arrowwhere = "yes";
	    	last;
	    }
	  }
	}
	
      }

      if (open(FILE, "${lbdir}data/ipbans.cgi")) {
            my @term_bannedmembers = <FILE>;
            close(FILE);
            my @term_vipmembers = grep(/^[0-9]/, @term_bannedmembers);
            @term_bannedmembers = grep(/^\-/, @term_bannedmembers);
            my $ipallow = "yes";

            foreach (@term_bannedmembers) {
                s/\r//sg;
                s/^\-//sg;
                chomp;
                next if ($_ eq "");
                if ($trueipaddress =~ /^$_/ || $ipaddress =~ /^$_/) {
                    $ipallow = $_;
                    last;
                }
            }
            foreach (@term_vipmembers) {
                s/\r//sg;
                chomp;
                next if ($_ eq "");
                if ($trueipaddress =~ /^$_/ || $ipaddress =~ /^$_/) {
                    $ipallow = "yes";
                    $arrowwhere = "yes";
                    last;
                }
            }
            &error("地區被禁止&由於壇主規定，你的來自地區 ( $fromwhere) 被禁止瀏覽本論壇！如有疑問，請聯絡管理員。") if ($arrowwhere eq "no");
#            if ($arrowwhere eq "no") { print header(-charset=>big5 , -expires=>"$EXP_MODE" , -cache=>"$CACHE_MODES"); exit; }
            &error(" IP 被禁止&由於你沒遵守本站規定！你的 IP ($ipallow) 被禁止！如有疑問，請聯絡管理員。") if ($ipallow ne "yes");
      }

      #寫入快取標誌
      open (FILE, ">${lbdir}cache/id/$infilemembername.cgi");
      close(FILE);
1;
