#!/bin/perl # �@�@�������̏ꍇ���̂܂܂ł����ł����A # ���perl�̃p�X�̓T�[�o�[�ɂ���ĈႤ���Ƃ�����̂ŁA # �v���o�C�_�[��CGI�ݒu�ē����Q�Ƃ��ĉ������B # =================================================================== # EASY ���[�A���P�[�g�iEASY Tohyo Ver2.2�j # File name: eztohyo.cgi # Copyright; Hiroshi Ishikawa (e-mail; laut@net-easy.com) # (URL; http://www.net-easy.com) # Last Update: 2000/01/14 # # EASY Tohyo Ver2.2�͌l�g�p�Ɍ���t���[�E�F�A�ł��B # �ۋ��̔������鏤�p���p�Ȃǂ͂��₢���킹�������B # �܂��A�����͎��R�ł����A���̗��͍폜���Ȃ��ʼn������B # =================================================================== require 'cgi-lib.pl'; #���̏ꏊ�ɂ���Ƃ��͑��΃p�X�Ŏw�� require 'jcode.pl'; #���̏ꏊ�ɂ���Ƃ��͑��΃p�X�Ŏw�� &ReadParse; # �^�C�g�� $title = '�������v��'; # �߂�y�[�W��URL $back = 'http://manpuku.mom/'; #���΃p�X�ł��� # �T���N�X�y�[�W $thanks = 'en_thanks.html'; #���΃p�X�ł��� # ���̓��[�̐����� $kaisetsu = '���Ȃ��̍D���ȏē��͉��ł����H
�R�����g������Ƃ����Ȑl�̖��킢�����������āA�ӊO�Ȃ��������������ł��邩���H
���[���Ă������������ɂ͖����X���Ŏg����T�������`�P�b�g���v���[���g�I'; # �O���t�p��GIF�t�@�C���̐ݒu�ꏊ $gif = "img/bar1.gif"; #���͓����f�B���N�g���̏ꍇ�B�ʂ̏ꏊ�ɒu�����̓p�X���L���B # �L�^�ۑ��t�@�C�� $file = 'enquete.txt'; # �p�X���[�h�i���e�L���̍폜�̍ەK�v�E�K�X�ύX���ĉ������j $psw = 'R3A2rxkw'; # �e�R�����g�̍ő�ۑ����A������z����ƌÂ����̂���폜����� $max = 10; # �e���ڂ̍ő啶�����i���{��̏ꍇ�̕������j $length_max = '20'; # cookie���g�p���邩���Ȃ��� # �P��I�Ԃ�,�P��̖K��ɂ‚��P�񂾂��̓��[�ɂȂ�܂��B $cook = '0'; #�g�p��1�A�g�p���Ȃ���0 # cookie�̏����ݒ� # ��̍��ڂŁu1�v��I�񂾏ꍇ�̂ݕK�v,�u0�v��I�񂾂Ƃ��͂��̂܂܁B $cookie = 'easytohyo'; #�ύX���Ă����Ȃ��Ă��� # ���ڂ̒lj���F�߂邩 $koumoku_add = 'no'; #�F�߂Ȃ�����'no'�ɕύX # ===================================================================== # �����ݒ肪�K�v�Ȃ̂͂����܂łł� # --------------------------------------------------------------------- # ����ȉ��͕ύX�̕K�v�͂���܂��񂪁ABODY�^�O�Ȃǂ�ύX���邾���Ȃ� # �ύX�”\�ł��B�������A$xxxx�̂悤�ɕϐ����g���Ă���Ƃ����ύX����� # �G���[�̌����ƂȂ�̂Œ��ӂ��ĉ������B # ===================================================================== # cookie�p�Ɏ��Ԃ��擾 $time = time; $time_last = $time - (60 * 10); # cookie�̗L���𒲂ׁA����Ύ擾�T�u���[�`���� if($cook eq '1'){ if ($ENV{'HTTP_COOKIE'} =~ /$cookie/){ &CookieCutter; } } # ���Ԃ̎擾 ($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime; $mon++; @week = ('��','��','��','��','��','��','�y'); $wday = $week[$wday]; $mon = sprintf("%.2d",$mon); $mday = sprintf("%.2d",$mday); $hour = sprintf("%.2d",$hour); $min = sprintf("%.2d",$min); $sec = sprintf("%.2d",$sec); $year = substr($year,1,2); $jikan = "$year/$mon/$mday($wday) $hour:$min:$sec"; # CGI���Ăяo���ꂽ�ꍇ�����ɉ����ď������� if($in{'forked'} eq 'tohyo'){ &tohyo; &html; print "

���[���肪�Ƃ��������܂����B
���[���Ă�������������ɁA�����̓X���Ŏg���邨�H���T�[�r�X���������グ�܂��B
�����ł��H���̍ۂ́A�������N���b�N�����o�Ă���T�[�r�X����������Ă������������B
����Ƃ���������낵�����肢\�\\���グ�܂��B\n"; }elsif($in{'forked'} eq 'add'){ &add; &html; }elsif($in{'forked'} eq 'add_admin'){ &add_admin; &delete_html; }elsif($in{'forked'} eq 'link'){ &comment_link_html; }elsif(($in{'forked'} eq 'admin') && ($in{'psw'} eq "$psw")){ &delete_html; }elsif(($in{'forked'} eq 'delete') && ($in{'psw'} eq "$psw")){ &delete; &delete_html; }elsif($in{'action'} eq 'add_com'){ &add_com; }else{ &html; } # �ŏ��ɌĂяo���ꂽ�Ƃ��̃T�u���[�`�� sub html{ if(!open(TXT,"$file")){&error(err_fail);} flock(TXT,2); @DATA = ; flock(TXT,8); close(TXT); if($DATA[0] eq ''){ if(!open(TXT,"$file")){&error(err_fail);} flock(TXT,2); print TXT "0,$jikan\n"; flock(TXT,8); close(TXT); $DATA[0] = "0,$jikan\n"; } @line1 = split(/\,/,$DATA[0]); $total = $line1[0]; $last_time = $line1[1]; print "Content-type: text/html\n"; &SetCookie; print "\n"; print < �ē����v[�L����Ђ܂�Ղ��J���p�j]
���R�؁@�ړ��Ž��̐V���o�؍��������@�吨�Ŋy���߂�R�[�X��������t�@�\���t���I


�ē�����������ē��G���^�[�e�C�����g�@�X���b�g�A���݂����A�X�܏Љ�[�r�[�Ȃǐ����R

�g�b�v�y�[�W�� �T�C�g�}�b�v��

�����@����v


$kaisetsu

$last_time�@�@���݁A���[����$total�ł��B
���̍��ڂP�‚Ƀ`�F�b�N���āA���[�{�^���������Ă��������B
EOM if($koumoku_add eq 'yes'){ print "
���T���̍��ڂ��Ȃ����͈�ԉ��̃t�H�[���ō��ڂ�lj����ĉ������B\n"; } if($cook eq '1'){ print "
�P��̂��K��łP�񂾂����[�i�܂��͍��ڂ̒lj��j���ł��܂��B\n"; } print < EOM $count = @DATA; $count--; $i = 1; $j = 0; $juni = 1; $gr_check = 'yes'; while($count > 0){ @line = split(/\,/,$DATA[$i]); if($line[1] == 0){$per = 0;} if($line[1] != 0){ $per = int(1000 * ($line[1] / $total)) / 10; if($line[1] != $tokuten){ $juni = $i; $tokuten = $line[1]; }else{ $tokuten = $line[1]; } } $rank = $juni; if($line[1] == 0){$rank = 0;} print "\n"; $convert_url = $line[2]; $convert_url =~ s/./sprintf("%%%2X",ord($&))/eg; $koumoku = "$line[2]\n"; print "\n"; print "\n"; #�p�[�Z���g�\���������_�ȉ����ʂ��\������Ă��܂����͉��̍s����#���Ƃ��ĉ����� #$per = substr($per,0,4); #���̏ꍇ�S���܂łɂȂ�܂� print "\n"; if($gr_check eq 'yes'){ if($per < 40){ $m = 15; }elsif($per >= 40){ if($per > 60){ $m = 2; }else{ $m = 4; } } $gr_check = 'no'; } $r = int($per * $m); if($per != 0){ print "\n"; }else{ print "\n"; } print "\n"; $i++; $j--; $count--; } print <
���ڂ�*�󂪂‚��Ă�����̂̓R�����g������܂�
���������[�������O���t
$rank$koumoku\n"; if($line[3] ne ''){ print "*\n"; } print "$line[1]$per\%
EOM if($koumoku_add eq 'yes'){ print <
�lj����鍀�ڂ�������[���ڂ̒lj�]�{�^���������ĉ�����

�lj����鍀�ڂɃR�����g�����������ꍇ�͂���ɉ��ɏ����Ă�������
�����O�i�n���h���l�[���j�F
�R�����g�F
�@
EOM } # �ȉ�13�s�͍폜���Ȃ��ʼn������B(Copyright�ł�) print <
EasyTohyo Ver2.1
������E�ē��@�����i�܂�Ղ��j
�؍��n�싏�����@���R�؁i�炳�񂩂�j
�Y�₮��@���āi�͂����j
����ŏĂ����@�I�����C���̔�
�������떞������@�Q�[���@�肢�@�M�������[
���⍇��
���y�[�WTOP���@   Copyright(C) 2008 manpukuCompany. All Rights Reserved.
EOM } # ���[������Ƃ��̉��Z�T�u���[�`�� sub tohyo{ if($in{'choice'} eq ''){ &error(bad_choice); } if(($cook eq '1') && ($check_time > $time_last)){ &html; exit; } if(!open(TXT,"$file")){&error(err_fail);} flock(TXT,2); @DATA = ; flock(TXT,8); close(TXT); @log = split(/\,/,$DATA[0]); $total = $log[0] + 1; $line1 = "$total,$jikan\n"; $choice = $in{'choice'}; &jcode'convert(*choice,"sjis"); $i = 1; $count = @DATA; $count--; while($count > 0){ @line = split(/\,/,$DATA[$i]); if($line[2] eq $choice){ $tokuten = $line[1] + 1; $tokuten_5keta = sprintf("%.5d",$tokuten); $DATA[$i] = "$tokuten_5keta,$tokuten,$line[2],$line[3],$line[4],$line[5],$line[6]\="; }else{ $DATA[$i] = "$DATA[$i]\="; } $data_new = "$data_new$DATA[$i]"; $i ++; $count--; } @DATA_new = split(/\=/,$data_new); @DATA_new = sort(@DATA_new); @DATA_new = reverse(@DATA_new); @DATA = ($line1,@DATA_new); if(!open(TXT,">$file")){&error(err_fail);} flock(TXT,2); print TXT @DATA; flock(TXT,8); close(TXT); } # �V���ɍ��ڂ�lj������Ƃ��̃T�u���[�`�� sub add{ if($in{'touroku'} eq ''){ &error(bad_touroku); } if(($cook eq '1') && ($check_time > $time_last)){ &html; exit; } $length_check = length($in{'touroku'}); $length_max = int($length_max * 2); if($length_check > $length_max){ &error(bad_length); } $touroku = $in{'touroku'}; $name = $in{'name'}; $comment = $in{'comment'}; &jcode'convert(*touroku,"sjis"); &jcode'convert(*name,"sjis"); &jcode'convert(*comment,"sjis"); $touroku =~ s/&/��/g; $touroku =~ s//>/g; $touroku =~ s/,/./g; $touroku =~ s/ /�@/g; $name =~ s/&/&/g; $name =~ s//>/g; $name =~ s/,/./g; $name =~ s/ /�@/g; $comment =~ s/&/&/g; $comment =~ s//>/g; $comment =~ s/,/./g; $comment =~ s/ /�@/g; if(!open(TXT,"$file")){&error(err_fail);} flock(TXT,2); @DATA = ; flock(TXT,8); close(TXT); $count = @DATA; $count--; $i = 1; $check = 'no'; while($count > 0){ @line = split(/\,/,$DATA[$i]); if($line[2] eq $touroku){ &error(bad_touroku_check); }else{ $check = 'yes'; } $i++; $count--; } if($DATA[1] eq ''){$check = 'yes';} if($check eq 'yes'){ @line1 = split(/\,/,$DATA[0]); $total = $line1[0] + 1; $DATA[0] = "$total,$jikan\n"; if(($comment eq '') && ($name ne '')){ &error(bad_comment); } if(($comment ne '') && ($name eq '')){ $name ='����'; } $remote_addr = $ENV{'REMOTE_ADDR'}; $remote_host = ((gethostbyaddr(pack('C4',split(/\./,$remote_addr)),2))[0]); $value = "00001,1,$touroku,$name,$comment,$remote_host,$remote_addr\n"; push(@DATA,$value); $i = 2; $count = @DATA; $count = $count-2; $data_new = $DATA[1]; while($count > 0){ $data_new = "$data_new\=$DATA[$i]"; $i ++; $count--; } @DATA_new = split(/\=/,$data_new); @DATA_new = sort(@DATA_new); @DATA_new = reverse(@DATA_new); @DATA_new = ($DATA[0],@DATA_new); if(!open(TXT,">$file")){&error(err_fail);} flock(TXT,2); print TXT @DATA_new; flock(TXT,8); close(TXT); } } # �폜����s��I��HTML��ʂ��o�͂���T�u���[�`�� sub delete_html{ print "Content-type: text/html\n\n"; print < �Ǘ��҉��

�Ǘ��҉��

�߂�

�lj����鍀�ڂ�������[���ڂ̒lj�]�{�^���������ĉ�����
�����ł̒lj��͓��[�ɂȂ�܂���

�lj����鍀�ڂɃR�����g�����������ꍇ�͂���ɉ��ɏ����Ă�������
�����O�i�n���h���l�[���j�F
�R�����g�F
�@

�폜����L�����`�F�b�N���đ��M���ĉ�����
���ڂ�������l�́A�����[�g�z�X�g���e�s�Ōォ��Q�Ԗڂ̍��ځA�Ōオ�����[�g�A�h���X�ɂȂ��Ă��܂��B


EOM if(!open(OUT,"$file")){&error(err_fail);} flock(OUT,2); @DATA = ; flock(OUT,8); close(OUT); $count = @DATA; $count--; $i = 1; while($count > 0){ @line = split(/\,/,$DATA[$i]); print "$line[1]�[ $line[2] $line[3] \- $line[4] $line[5] $line[6]
\n"; $i ++; $count --; } print < EOM } # �폜�T�u���[�`�� sub delete{ if(!open(OUT,"$file")){&error(err_fail);} flock(OUT,2); @DATA = ; flock(OUT,8); close(OUT); @line1 = split(/\,/,$DATA[0]); $total_old = $line1[0]; $count = @DATA; @code = split(/\0/,$in{'delete'}); $countcode = @code; $i = 0; $j = 0; while(($count > 0) || ($countcode > $j)){ @line = split(/\,/,$DATA[$i]); if($line[2] eq $code[$j]){ @data_line = split(/\,/,$DATA[$i]); $tokuten = $data_line[1]; $delete_tokuten = $delete_tokuten + $tokuten; $DATA[$i] = ''; $j ++; } $i ++; $count --; } $total_new = $total_old - $delete_tokuten; $DATA[0] = "$total_new,$jikan\n"; $line = $DATA[0]; shift(@DATA); @DATA = sort(@DATA); @DATA = reverse(@DATA); @DATA = ($line,@DATA); if(!open(TXT,">$file")){&error(err_fail);} flock(TXT,2); print TXT @DATA; flock(TXT,8); close(TXT); } # ���ڂɑ΂���R�����g��\������T�u���[�`�� sub comment_link_html{ if(!open(OUT,"$file")){&error(err_fail);} flock(OUT,2); @DATA = ; flock(OUT,8); close(OUT); $count = @DATA; $count--; $i = 1; while($count > 0){ @line = split(/\,/,$DATA[$i]); if($in{'link'} eq "$line[2]"){ print "Content-type: text/html\n\n"; print < $line[2]�̃R�����g EOM if(($line[3] ne '') && ($line[4] ne '')){ @NAME = split(/\//,$line[3]); @COMMENT = split(/\//,$line[4]); $count = @NAME; print <


$line[2]�̃R�����g
�ŐV��$max���܂ł��\\������܂��i���݃R�����g�ۑ�����$count���j EOM $j = 0; while($count > 0){ print "
\n\n"; print "\n"; print "\n"; print "
$NAME[$j]����
$COMMENT[$j]
\n
\n
\n"; $j++; $count--; } }else{ print "


\n"; print "
�R�����g�͌��݂���܂���
\n
\n"; } print <���̃E�B���h�E��‚��� �@�@
�R�����g�̒lj������鎞�͉��ɂ�������������
�����O�i�n���h���l�[���j�F

�R�����g�F


EOM } $i++; $count--; } } # cookie�̎擾�T�u���[�`�� sub CookieCutter { foreach(split(/; /,$ENV{'HTTP_COOKIE'})){ ($key,$value) = split(/=/); if ($key eq $cookie){ $cookieJar{$cookie} = $value; } } $check_time = $cookieJar{$cookie}; } # cookie�Z�b�g�T�u���[�`�� sub SetCookie{ if($cook eq '1'){ if(($in{'forked'} eq 'tohyo') || ($in{'forked'} eq 'add')){ print "Set-Cookie: "; print "$cookie=$time;\n"; } } } # �R�����g�lj��T�u���[�`�� sub add_com{ if($in{'comment'} eq ''){ &error(bad_touroku); } $koumoku = $in{'koumoku'}; $comment = $in{'comment'}; $name = $in{'name'}; &jcode'convert(*comment,"sjis"); &jcode'convert(*name,"sjis"); $name =~ s/&/&/g; $name =~ s//>/g; $name =~ s/,/./g; $comment =~ s/&/&/g; $comment =~ s//>/g; $comment =~ s/,/./g; $comment =~ s/\//\-/g; if(!open(TXT,"$file")){&error(err_fail);} flock(TXT,2); @DATA = ; flock(TXT,8); close(TXT); $count = @DATA; $count--; $i = 1; @NEW_DATA = "$DATA[0]"; while($count > 0){ @line = split(/\,/,$DATA[$i]); if($line[2] eq $koumoku){ if($name eq ''){$name = '����';} if($line[3] eq ''){ $line[3] = "$name"; }else{ $line[3] = "$line[3]\/$name"; @check_name = split(/\//,$line[3]); $check_n = @check_name; if($check_n > $max){ shift(@check_name); foreach $write(@check_name){ if($new_line3 eq ""){ $new_line3 = $write; }else{ $new_line3 = "$new_line3\/$write"; } } $line[3] = $new_line3; $flag = 'yes'; } } if($line[4] eq ''){ $line[4] = "$comment"; }else{ $line[4] = "$line[4]\/$comment"; if($flag eq "yes"){ @check_comment = split(/\//,$line[4]); shift(@check_comment); foreach $write_c(@check_comment){ if($new_line4 eq ""){ $new_line4 = $write_c; }else{ $new_line4 = "$new_line4\/$write_c"; } } $line[4] = $new_line4; } } } $value = "$line[0],$line[1],$line[2],$line[3],$line[4],$line[5],$line[6]"; push(@NEW_DATA,$value); $i++; $count--; } if(!open(TXT,">$file")){&error(err_fail);} flock(TXT,2); print TXT @NEW_DATA; flock(TXT,8); close(TXT); &comment_link_html; } # �Ǘ��җp���ڒlj��T�u���[�`�� # �Ǘ��҂����ڂ�lj�����Ƃ��͓��[�����[���ō��ڒlj������ sub add_admin{ if($in{'touroku'} eq ''){ &error(bad_touroku); } $touroku = $in{'touroku'}; $name = $in{'name'}; $comment = $in{'comment'}; &jcode'convert(*touroku,"sjis"); &jcode'convert(*name,"sjis"); &jcode'convert(*comment,"sjis"); $touroku =~ s/&/��/g; $touroku =~ s//>/g; $touroku =~ s/,/./g; $name =~ s/&/&/g; $name =~ s//>/g; $name =~ s/,/./g; $comment =~ s/&/&/g; $comment =~ s//>/g; $comment =~ s/,/./g; if(!open(TXT,"$file")){&error(err_fail);} flock(TXT,2); @DATA = ; flock(TXT,8); close(TXT); $count = @DATA; $count--; $i = 1; $check = 'no'; while($count > 0){ @line = split(/\,/,$DATA[$i]); if($line[2] eq $touroku){ &error(bad_touroku_check); }else{ $check = 'yes'; } $i++; $count--; } if($DATA[1] eq ''){$check = 'yes';} if($check eq 'yes'){ if($DATA[0] == ''){ @line1 = split(/\,/,$DATA[0]); $total = 0; $DATA[0] = "$total,$jikan\n"; } if(($comment eq '') && ($name ne '')){ &error(bad_comment); } if(($comment ne '') && ($name eq '')){ $name ='����'; } $value = "00000,0,$touroku,$name,$comment,$remote_host,$remote_addr\n"; push(@DATA,$value); if(!open(TXT,">$file")){&error(err_fail);} flock(TXT,2); print TXT @DATA; flock(TXT,8); close(TXT); } } # �G���[�T�u���[�`�� sub error{ $error = $_[0]; if ($error eq "bad_choice"){ $msge = '���ڂ����P�‘I����u���[�{�^���v�����Ă�������'; }elsif($error eq "bad_touroku"){ $msge = '���ڂ��L������Ă��܂���'; }elsif($error eq "bad_comment"){ $msge = '�R�����g�������Ă��������B
�����Ȃ��ꍇ�͖��O���R�����g���󗓂ɂ��ĉ������B'; }elsif($error eq "bad_touroku_check"){ $msge = '�o�^���悤�Ƃ��Ă��鍀�ڂ͊��ɂ���܂�'; }elsif($error eq "err_fail"){ $msge = '�t�@�C���I�[�v���ł��܂���'; }elsif($error eq "bad_length"){ $bad_max_length = int($length_max / 2); $msge = "�lj����鍀�ڂ̕�������$bad_max_length�����ȓ��ɂ��Ă�������"; }else{ $msge = '���炩�̃G���[�ł�'; } print "Content-type: text/html\n\n"; print "ERROR\n"; print "\n"; print "

$msge


\n"; print "BACK\n"; exit; }