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

📄 wwwadmin.pl

📁 java开发的聊天室
💻 PL
📖 第 1 页 / 共 2 页
字号:
###########################################################################

elsif ($FORM{'action'} eq 'remove') {

   &check_passwd;

   for ($i = $FORM{'min'}; $i <= $FORM{'max'}; $i++) {
      if ($FORM{$i} eq 'all') {
         push(@ALL,$i);
      }
      elsif ($FORM{$i} eq 'single') {
         push(@SINGLE,$i);
      }
   }

   open(MSGS,"$basedir/$mesgfile");
   @lines = <MSGS>;
   close(MSGS);

   foreach $single (@SINGLE) {
      foreach ($j = 0;$j <= @lines;$j++) {
         if ($lines[$j] =~ /<!--top: $single-->/) {
            splice(@lines, $j, 3);
            $j -= 3;
         }
         elsif ($lines[$j] =~ /<!--end: $single-->/) {
            splice(@lines, $j, 1);
            $j--;
         }
      }
      $filename = "$basedir/$mesgdir/$single\.$ext";
      if (-e $filename) {
         unlink("$filename") || push(@NOT_REMOVED,$single);
      }
      else {
         push(@NO_FILE,$single);
      }
      push(@ATTEMPTED,$single);
   }

   foreach $all (@ALL) {
      undef($top); undef($bottom);
      foreach ($j = 0;$j <= @lines;$j++) {
         if ($lines[$j] =~ /<!--top: $all-->/) {
            $top = $j;
         }
         elsif ($lines[$j] =~ /<!--end: $all-->/) {
            $bottom = $j;
         }
      }
      if ($top && $bottom) {
         $diff = ($bottom - $top);
         $diff++;
         for ($k = $top;$k <= $bottom;$k++) {
            if ($lines[$k] =~ /<!--top: (.*)-->/) {
               push(@DELETE,$1);
            }
         }
         splice(@lines, $top, $diff);
         foreach $delete (@DELETE) {
            $filename = "$basedir/$mesgdir/$delete\.$ext";
            if (-e $filename) {
               unlink($filename) || push(@NOT_REMOVED,$delete);
            }
            else {
               push(@NO_FILE,$delete);
            }
            push(@ATTEMPTED,$delete);
         }
      }
      else {
         push(@TOP_BOT,$all);
      }
   }

   open(WWWBOARD,">$basedir/$mesgfile");
   print WWWBOARD @lines;
   close(WWWBOARD);      

   &return_html($FORM{'type'});

}

###########################################################################
# Remove Action by Date or Author                                         #
#       This portion is used by the method remove_by_date or 		  #
#   remove_by_author.     		  				  #
###########################################################################

elsif ($FORM{'action'} eq 'remove_by_date_or_author') {

   &check_passwd;

   @used_values = split(/\s/,$FORM{'used_values'});
   foreach $used_value (@used_values) {
      @misc_values = split(/\s/,$FORM{$used_value});
      foreach $misc_value (@misc_values) {
         push(@SINGLE,$misc_value);
      }
   }

   open(MSGS,"$basedir/$mesgfile");
   @lines = <MSGS>;
   close(MSGS);

   foreach $single (@SINGLE) {
      foreach ($j = 0;$j <= @lines;$j++) {
         if ($lines[$j] =~ /<!--top: $single-->/) {
            splice(@lines, $j, 3);
            $j -= 3;
         }
         elsif ($lines[$j] =~ /<!--end: $single-->/) {
            splice(@lines, $j, 1);
            $j--;
         }
      }
      $filename = "$basedir/$mesgdir/$single\.$ext";
      if (-e $filename) {
         unlink("$filename") || push(@NOT_REMOVED,$single);
      }
      else {
         push(@NO_FILE,$single);
      }
      push(@ATTEMPTED,$single);
   }

   open(WWWBOARD,">$basedir/$mesgfile");
   print WWWBOARD @lines;
   close(WWWBOARD);

   &return_html($FORM{'type'});

}

elsif ($FORM{'action'} eq 'change_passwd') {

   open(PASSWD,"$passwd_file") || &error(passwd_file);
   $passwd_line = <PASSWD>;
   chop($passwd_line) if $passwd_line =~ /\n$/;
   close(PASSWD);

   ($username,$passwd) = split(/:/,$passwd_line);

   if (!($FORM{'passwd_1'} eq $FORM{'passwd_2'})) {
      &error(not_same);
   }

   $test_passwd = crypt($FORM{'password'}, substr($passwd, 0, 2));
   if ($test_passwd eq $passwd && $FORM{'username'} eq $username) {
      open(PASSWD,">$passwd_file") || &error(no_change);
      $new_password = crypt($FORM{'passwd_1'}, substr($passwd, 0, 2));
      if ($FORM{'new_username'}) {
         $new_username = $FORM{'new_username'};
      }
      else {
         $new_username = $username;
      }
      print PASSWD "$new_username:$new_password";
      close(PASSWD);
   }
   else {
      &error(bad_combo);
   }

   &return_html(change_passwd);
}

else {
   print "<html><head><title>收集资料管理处</title><BASEFONT FACE=Arial></head>\n";
   print "<body bgcolor=#FFFFFF text=#000000><center><h1>收集资料管理处</h1></center>\n";
   print "选择以下几种方法删除资料<p>\n";
   print "<hr size=7 width=95% color=red><br>\n";
   print "<ul>\n";
   print "<li>资料删除\n";
   print "<ul>\n";
   print "<li><a href=\"$cgi_url\?remove\">删除资料</a>\n";
   print "<li><a href=\"$cgi_url\?remove_by_num\">按文件号删除资料</a>\n";
   print "<li><a href=\"$cgi_url\?remove_by_date\">按发表时间删除资料</a>\n";
   print "<li><a href=\"$cgi_url\?remove_by_author\">按作者删除资料</a>\n";
   print "</ul><br>\n";
   print "<li>口令\n";
   print "<ul>\n";
   print "<li><a href=\"$cgi_url\?change_passwd\">修改管理口令</a>\n";
   print "</ul>\n";
   print "</ul>\n";
   print "<hr size=7 width=95% color=red><br>\n";
   print "</body></html>";
}

#######################
# Parse Form Subroutine

sub parse_form {

   # Get the input
   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

   # Split the name-value pairs
   @pairs = split(/&/, $buffer);

   foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);

      # Un-Webify plus signs and %-encoding
      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

      $FORM{$name} = $value;
   }
}

sub return_html {
   $type = $_[0];
   if ($type eq 'remove') {
      print "<html><head><title>删除资料结果</title><BASEFONT FACE=Arial></head>\n";
      print "<body><center><h1>删除资料结果</h1></center>\n";
   }
   elsif ($type eq 'remove_by_num') {
      print "<html><head><title>按标号删除资料结果</title><BASEFONT FACE=Arial></head>\n";
      print "<body><center><h1>按标号删除资料结果</h1></center>\n";
   }
   elsif ($type eq 'remove_by_date') {
      print "<html><head><title>按时间删除资料结果</title><BASEFONT FACE=Arial></head>\n";
      print "<body><center><h1>按时间删除资料结果</h1></center>\n";
   }
   elsif ($type eq 'remove_by_author') {
      print "<html><head><title>按作者删除资料结果</title><BASEFONT FACE=Arial></head>\n";
      print "<body><center><h1>按作者删除资料结果</h1></center>\n";
   }
   elsif ($type eq 'change_passwd') {
      print "<html><head><title>管理口令被修改</title><BASEFONT FACE=Arial></head>\n";
      print "<body><center><h1>管理口令被修改</h1></center>\n";
      print "管理口令被修改为:<p><hr size=7 width=95% color=red><p>\n";
      print "<b>用户名: $new_username<p>\n";
      print "口&nbsp;&nbsp;令: $FORM{'passwd_1'}</b><p>\n";
      print "<hr size=7 width=95% color=red><p>\n";
      print "请记住您修改的密码!\n";
      print "</body></html>\n";
   }
   if ($type =~ /^remove/) {
      print "Below is a short summary of what messages were removed from $mesgpage and the\n";
      print "$mesgdir directory.  All files that the script attempted to remove, were removed,\n";
      print "unless there is an error message stating otherwise.<p><hr size=7 width=95% color=red><p>\n";
 
      print "<b>试图删除资料:</b> @ATTEMPTED<p>\n";
      if (@NOT_REMOVED) {
         print "<b>资料不能被删除:</b> @NOT_REMOVED<p>\n";
      }
      if (@NO_FILE) {
         print "<b>文件找不到:</b> @NO_FILE<p>\n";
      }
      print "<hr size=7 width=95% color=red><center><font size=-1>\n";
   print "[ <a href=\"$cgi_url\?remove\">删除资料</a> ] [ <a href=\"$cgi_url\?remove_by_date\">按时间删除</a> ] [ <a href=\"$cgi_url\?remove_by_author\">按作者删除</a> ] [ <a href=\"$cgi_url\?remove_by_num\">按编号删除</a> ] [ <a href=\"$baseurl/$mesgpage\">$title</a> ]\n";
#      print "[ <a href=\"$cgi_url\?remove\">Remove</a> ] [ <a href=\"$cgi_url\?remove_by_date\">Remove by Date</a> ] [ <a href=\"$cgi_url\?remove_by_author\">Remove by Author</a> ] [ <a href=\"$cgi_url\?remove_by_num\">Remove by Message Number</a> ] [ <a href=\"$baseurl/$mesgpage\">$title</a> ]\n";
      print "</font></center><hr size=7 width=95% color=red>\n";
      print "</body></html>\n";
   }
}

sub error {
   $error = $_[0];
   if ($error eq 'bad_combo') {
      print "<html><head><title>Bad Username - Password Combination</title><BASEFONT FACE=Arial></head>\n";
      print "<body><center><h1>Bad Username - Password Combination</h1></center>\n";
      print "You entered and invalid username password pair.  Please try again.<p>\n";
      &passwd_trailer
   }
   elsif ($error eq 'passwd_file') {
      print "<html><head><title>Could Not Open Password File For Reading</title><BASEFONT FACE=Arial></head>\n";
      print "<body><center><h1>Could Not Open Password File For Reading</h1></center>\n";
      print "Could not open the password file for reading!  Check permissions and try again.<p>\n";
      &passwd_trailer
   }
   elsif ($error eq 'not_same') {
      print "<html><head><title>Incorrect Password Type-In</title><BASEFONT FACE=Arial></head>\n";
      print "<body><center><h1>Incorrect Password Type-In</h1></center>\n";
      print "The passwords you typed in for your new password were not the same.\n";
      print "You may have mistyped, please try again.<p>\n";
      &passwd_trailer
   }
   elsif ($error eq 'no_change') {
      print "<html><head><title>Could Not Open Password File For Writing</title><BASEFONT FACE=Arial></head>\n";
      print "<body><center><h1>Could Not Open Password File For Writing</h1></center>\n";
      print "Could not open the password file for writing!  Password not changed!<p>\n";
      &passwd_trailer
   }

   exit;
}

sub passwd_trailer {
   print "<hr size=7 width=95% color=red><center><font size=-1>\n";
   print "[ <a href=\"$cgi_url\">WWWAdmin</a> ] [ <a href=\"$baseurl/$mesgpage\">$title</a> ]\n";
   print "</font></center><hr size=7 width=95% color=red>\n";
   print "</body></html>\n";
}

sub check_passwd {
   open(PASSWD,"$passwd_file") || &error(passwd_file);
   $passwd_line = <PASSWD>;
   chop($passwd_line) if $passwd_line =~ /\n$/;
   close(PASSWD);

   ($username,$passwd) = split(/:/,$passwd_line);

   $test_passwd = crypt($FORM{'password'}, substr($passwd, 0, 2));
   if (!($test_passwd eq $passwd && $FORM{'username'} eq $username)) {
      &error(bad_combo);
   }
}

⌨️ 快捷键说明

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