#! /usr/local/bin/perl ############################################## #BooGuestBook,v1.04 / This program for Admin.# #(C) BooBooClub 2000-2006 # ############################################## #set data $bgb = './bgb.cgi'; $admin = './bgbad.cgi'; $dat = './bgbdata.dat'; $id = 'id'; $pwd = 'pass'; $head = '管理ページ'; $back = 'bgcolor="#ffffff" background="./bgb_b.gif"'; $linkc = 'text="#555555" link="#0000ff" vlink="#880088"'; $margin = '100'; #read lib require 'jcode.pl'; #read if($ENV{'REQUEST_METHOD'} eq "POST"){ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else{ $buffer = $ENV{'QUERY_STRING'}; } @pairs = split(/&/,$buffer); 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/\r\n|[\r\n]//ig; $value =~ s/,//g; $value =~ s//>/ig; #prevent chr error &jcode'convert(*value,'sjis'); if($name eq 'remove'){ $FORM{$name} .= ','.$value; } else{ $FORM{$name} = $value; } } @remove = split(/,/,$FORM{'remove'}); #file_lock &lock; sub lock{ $lockfile = './lock/lockfile'; $retry = 1; until(symlink("$dat", "$lockfile")){ if(++$retry >= 30){ unlink("$lockfile"); exit 0; } sleep(1); } } #branch if(!$FORM{'submit'}){ &html; } else{ ✓ &html; } sub check{ if($FORM{'id'} eq $id && $FORM{'pwd'} eq $pwd){ &remove; } else{ &error; } } sub remove{ open(DAT,"$dat"); @bdats = ; close(DAT); foreach $odat(@bdats){ ($time,$name,$mail,$txt,$count) = split(/,/,$odat); chomp $count; $oc = $count; $i = 0; foreach $rc(@remove){ if($oc eq $rc){ $i++; } } if($i == 0){ push(@ndat,$odat); } } open(DAT,">$dat"); print DAT @ndat; close(DAT); } sub error{ print "Content-type: text/html\n\n"; print "password error\n"; print "\n"; if($margin != 0){ print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "\n"; } print "

Password Error!

\n"; print "IDかパスワードが間違っています。

\n"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; if($margin != 0){ print "
\n"; } #print "\n"; $z = "1"; } sub html{ open(DAT,"$dat"); @rdats = ; close(DAT); if($z ne "1"){ print "Content-type: text/html\n\n"; print "管理ページ\n"; print "\n"; } if($margin != 0){ print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "\n"; } print "

$head

\n"; print "
\n"; print "\n"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; print "ID: \n"; print "    Password:

\n"; print "\n"; print "\n"; print "
\n"; foreach $rdat(@rdats){ ($time,$name,$mail,$txt,$count) = split(/,/,$rdat); chomp $count; print "
\n"; print " \n"; print "Name\=$name\   No.$count\
$otime\n"; } print "

\n"; print "
\n"; if($margin != 0){ print "
\n"; } print "\n"; unlink("$lockfile"); exit 0; }