⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datalib.pl

📁 系统重定向方面的资料
💻 PL
字号:
#!/usr/bin/perl

# 例如帐号是否重复,过滤或保留字段
sub firstcheck
  {
    @res = split(/\,/,$reserved);
      
    foreach $r(@res) 
      {
        $r = "\L$r\E";
        if ($input{"username"} eq $r) 
        {   $ehint.="你不能使用此帐号!<br>";  } 
      }
      
    if ($ehint eq "")
      {
        $db = "$datapath/$userdb";
        tie(%cat, 'AnyDBM_File', $db , $flags, 0666) || &error("不能打开数据库-- 用户数据库");
        if ($cat{$input{"username"}}) 
          {
            $ehint.="此用户帐号已经有人申请了<br>";
          }
        untie(%cat);
      }
      
  }

# 用于检测邮件是否唯一,或者网址是否唯一 : 不和非本用户的相同
sub secondcheck
{
	
}

#检测字段长度,合法性,是否唯一
sub checkfield
  {
    
    for ($i=0;$i<$field_count;$i++)
      {
        $curtext = $input{"$field_list[$i]"};
          
        @myattr=split(/,/,$field_attr{$i});
        $mytype = $myattr[2];
        $myminl = $myattr[0];
        $mymaxl = $myattr[1];
        $mytexttype =$myattr[3];
        $myonly = $myattr[4];
          
        # text,textarea,radio,checkbox,select,password
        if ( $mytype eq "text")
          {
            #长度检测
            if (( length($curtext)<$myminl) or (length($curtext)>$mymaxl) ) 
              { 
                if ($curtext eq "")
                 { $ehint.="$field_name[$i]没有填写!<br>"; }
                else
                 { $ehint.="$field_name[$i]的长度范围是$myminl\-$mymaxl<br>"; }
              }
            else
              {
                #是否为邮件,网址  
                if ($mytexttype eq "1"  )
                {
                    if ($curtext!~ /\w+\@\w+\.\w+/) {$ehint.="输入了一个错误的电子邮件<br>";}
                }
                elsif ($mytexttype eq "2"   )
                {
                  if (!($curtext  =~ /http:\/\/.*\..*/))
                    {      $ehint.="输入了一个错误的网址!<br>";      }
                }
                elsif ($mytexttype eq "3" )
                {
                  if ($curtext!~ /\w/) {$ehint.="$field_name[$i]只能为字母,数字或\_<br>";}
                }
                else {}
              }
          }
        elsif ($mytype eq "hidden")
        {}
        elsif ($mytype eq "none") 
        {}
        elsif ($mytype eq "textarea")
          {
            if (( length($curtext)<$myminl) or (length($curtext)>$mymaxl) ) 
              { 
                if ($curtext eq "")
                 { $ehint.="$field_name[$i] 没有填写!<br>"; }
              else
               { $ehint.="$field_name[$i]的长度范围是$myminl\-$mymaxl<br>"; }
          }
        }
        elsif ($mytype eq "radio")
          {
            %mysel = eval("%".$field_list[$i]."_sel");
            @myallvalue =values(%mysel);
            $nsel =0;
            while(($myvalue,$mydisplay)= each(%mysel))
              {
                if ( $myvalue eq $curtext) {$nsel=1;}
            }
          if ($nsel=0) {$curtext=$myallvalue[0]}
        }
        elsif ($mytype eq "checkbox")
          {
            $myvalue=$myattr[5];
            if ($curtext ne $myvalue) {$curtext="";}
        }
        elsif ($mytype eq "select")
          {
            %mysel = eval("%".$field_list[$i]."_sel");
            @myallvalue =values(%mysel);
            $nsel =0;
            while(($myvalue,$mydisplay)= each(%mysel))
              {
                if ( $myvalue eq $curtext) {$nsel=1;}
            }
          if ($nsel=0) {$curtext=$myallvalue[0]}
        }
        elsif  ( ($mytype eq "password") or ($mytype eq "password1") )
          {
            if (( length($curtext)<$myminl) or (length($curtext)>$mymaxl) ) 
              { 
                if ($curtext eq "")
                 { $ehint.="$field_name[$i]没有填写!<br>"; }
              else
               { $ehint.="$field_name[$i]的长度范围是$myminl\-$mymaxl<br>"; }
          }
        }
        else 
        {};
        }
  
}

#你可以添加更多的检测:重复密码
sub morecheck
{
    if ( $input{"pwd1"} ne $input{"pwd"} )
    { $ehint.="两次密码输入不相同!<br>";}
    
    if ( $input{"redirect"} =~ /go\.coolwww\.net/i )
    { $ehint.="目标网址不得含有go\.coolwww\.net!<br>"; }
}

#过滤不合适,不安全因素
sub myfilter
  {
    $input{'site_des'} =~ s/>//g;
    $input{'site_des'} =~ s/<//g;
    $input{'site_keywords'} =~ s/>//g;
    $input{'site_keywords'} =~ s/<//g;
      
  }

1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -