#!/usr/bin/perl if ($ENV{'QUERY_STRING'}) {$namevalues = $ENV{'QUERY_STRING'};} else {read(STDIN, $namevalues, $ENV{'CONTENT_LENGTH'});} @pairs = split(/&/, $namevalues); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; $value =~ s/<([^>]|\n)*>//g; $form{$name} = $value;} print "Content-Type: text/html; charset=gb2312 \n\n"; #--------~~~~~VARIABLES~~~~~~~-------# #header of every page $header = "header.htm"; #footer of every page $footer = "footer.htm"; # Url to admin script $scripturl = "admin.pl"; # path to base where info stored $base = "base.txt"; # pic for table creation $pixel = "pixel.gif"; # this picture split visitor post and admin reply $line = "dots.gif"; # Your admin password, change it!! $pass = "admin"; #now run script www.example.com/cgi-bin/guest/admin.pl?action=login #end of editing ! &header; $action = $form{'action'}; if ($action eq 'main') {&main;} if ($action eq 'login') {&login;} if ($action eq 'last_mess') {&last_mess;} if ($action eq 'by_date') {&by_date;} if ($action eq 'delete') {&delete;} if ($action eq 'reply') {&reply;} if ($action eq 'reply1') {&reply1;} if ($action eq 'viewmail') {&viewmail;} $cp = $form{'cpassword'}; $action = $form{'action'}; $pass = "admin"; #ADMIN LOGIN sub login { print qq~

留言板 : 管理页面
口 令 :

  

 

~; exit; } sub check_pass { $cp = $form{'cpassword'}; if ($cp ne $pass){ $serror = 1 ; } if ($serror) { print "密码错误.\n";exit; } } ####MAIN ADMIN PAGE sub main { &check_pass; print qq~
留言板 : 管理页面

根据时间查看留言板
From :  to:



或者
查看最后 
条记录



查看使用过该留言板人员的 E-mail

~; exit; } sub last_mess { &check_pass; $cp = $form{'cpassword'}; $form_last = $form{'last_mess'}; open (FE, "$base")|| die "not found"; @lines = ; foreach $lines (@lines){$howmanylines++;} @lines = reverse(@lines); @kat = (0..$form_last-1); foreach (@lines[@kat]){ ($id,$month,$day,$year,$date,$name,$mail,$url,$country,$ip,$desc,$reply) = split('[|]',$_); if($name ne ""){ print qq~
  $desc
姓名 : $name   mail : $mail   网址 : $url     地区 : $country      发布日期 : $date   IP : $ip
~; } if($reply ne ""){ @temo=split(/\|/,$_); $cnt=grep(/|/,@temo); $cnin=1; for($in=11;$in<$cnt-1;$in++){ print qq~

$temo[$in] 回复 :

单位 :$temo[$in+2]

$temo[$in+3]

删除

~; $in=$in+3; $cnin++; } } print qq~
~; } print "<< 返回到管理页面" ; } sub by_date { &check_pass; $from_month = $form{'from_month'}; $from_day = $form{'from_day'}; $from_year = $form{'from_year'}; $to_month = $form{'to_month'}; $to_day = $form{'to_day'}; $to_year = $form{'to_year'}; open (FE, "$base")|| die "not found"; @lines = ; print "
显示留言 : $from_month/$from_day/$from_year - $to_month/$to_day/$to_year
"; foreach $lines (@lines){$howmanylines++;} foreach (@lines){ ($id,$month,$day,$year,$date,$name,$mail,$url,$country,$ip,$desc,$reply) = split('[|]',$_); $from_dig = "$from_year$from_month$from_day"; $to_dig = "$to_year$to_month$to_day"; $dig = "$year$month$day"; if ($from_dig le $dig & $to_dig ge $dig){ print qq~
  $desc
姓名 : $name   mail : $mail   网址 : $url   地区 : $country   发布日期 : $date   IP : $ip
~; } if($reply ne ""){ @temo=split(/\|/,$_); $cnt=grep(/|/,@temo); $cnin=1; for($in=11;$in<$cnt-1;$in++){ print qq~

$temo[$in] 回复 :

单位 :$temo[$in+2]

$temo[$in+3]

删除

~; $in=$in+3; $cnin++; } } print qq~
~; } print "<< 返回到管理页面" ; } sub reply { &check_pass; $id2 = $form{'id'}; open(FILE, "$base"); @lines = ; foreach (@lines){($id,$month,$day,$year,$date,$name,$mail,$url,$country,$ip,$desc,$reply) = split(/\|/,$_); if ($id eq "$id2"){ print qq~

 

  $desc
name : $name   mail : $mail   url : $url   country : $country   post date : $date   IP : $ip

~; if ($reply ne ""){print "该流言已经被回复 , 你可以再次回复.
$reply
";} print qq~

请回复该留言 :



~; } } } sub reply1 { &check_pass; $cp = $form{'cpassword'}; $reply2 = $form{'reply2'}; $id2 = $form{'id'}; $reply2 =~ s//>/g;$reply2 =~ s/\cM//g;$reply2 =~ s/\n\n/

/g; $reply2 =~ s/\n/
/g; open(FILE, "$base"); @indata = ; close(FILE); open(FILE, ">$base"); foreach $temp (@indata) { ($id,$month,$day,$year,$date,$name,$mail,$url,$country,$ip,$desc,$reply) = split(/\|/, $temp); if ($id eq "$id2") { print FILE "$id|$month|$day|$year|$date|$name|$mail|$url|$country|$ip|$desc|$reply2|\n"; } else { print FILE "$id|$month|$day|$year|$date|$name|$mail|$url|$country|$ip|$desc|$reply|\n"; } } close(FILE); print "

"; print "留言已经成功 回复.

"; print "<< 返回到管理页面" ; } sub header { open(FILE,"$header"); while() { print $_; } } sub footer { open(FILE,"$footer"); while() { print $_; } } sub delete { &check_pass; $cp = $form{'cpassword'}; $action = $form{'action'}; $id_del = $form{'id'}; $cnin1 = $form{'cnin'}; open (FILE, "$base"); while () { @temo1=split(/\|/,$_); $cnt1=grep(/|/,@temo1); #print "\n$cnt1"; ($id,$month,$day,$year,$date,$name,$mail,$url,$country,$ip,$desc,$reply) = split(/\|/, $_); if ($cnin1 eq ""){ $row = $_; chop $row; #print "$row"; ($id,$month,$day,$year,$date,$name,$mail,$url,$country,$ip,$desc,$reply) = split(/\|/, $row); } else{ $row=""; $yu=10+($cnin1-1)*4; if($id_del == $id){ for($ain=0;$ain<$cnt1-1;$ain++){ #print "temo1[$ain]=$temo1[$ain]"; if($ain<$yu){ $row .= $temo1[$ain].'|'; } if($ain==$yu){ $row .= $temo1[$ain].'|'; $ain=11+$cnin1*4; } if($ain>$yu){ $row .= $temo1[$ain].'|'; } } } else{ for($ain=0;$ain<$cnt1-1;$ain++){ $row .= $temo1[$ain].'|'; } } } if (($id_del ne $id) or ($cnin1 ne "")){$new_row .= "$row\n";} } #print "$new_row
"; close (FILE); #print "$new_row"; open (FILE, ">$base"); print FILE "$new_row"; close (FILE); print "
"; print "消息已经被成功 删除.

"; print "<< 返回到管理页面" ; } sub viewmail { &check_pass; $cp = $form{'cpassword'}; print "

E-mail 列表 :

"; open(FILE, "$base"); @lines = ; foreach (@lines){($id,$month,$day,$year,$date,$name,$mail,$url,$ip,$desc,$reply) = split(/\|/,$_); print "

$mail

"; } print "<< 返回到管理页面" ; } &footer;