Files
Gazou-Channel-PHP-Archives/gazou-v2.3/gazou.php
T
2022-07-22 04:22:16 -07:00

571 lines
20 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?
/*
* �摜BBS by ToR
* http://php.s3.to
*
* �摜�n���R�f���‚ł��BJPG�AGIF�APNG�̂ݱ���۰�މ”\
*
* �ۑ��p�f�B���N�g���uimg�v���쐬���ď������ݑ����i717���j��ݒ肵�Ă�������
* �ŋ߂̖����T�[�o��SAFE MODE���ݒ肳��Ă��鏊���������ߎg����ꏊ�͌����܂��B
* OK->http://www.coolfreehost.com http://www.saxen.net
*
*2000/10/26 v1.0 �Ƃ肠��������
*2000/10/18 v1.1 URL�A���[����\���A��
*2000/11/28 v1.2 �폜�@�\
*2000/11/30 v2.0 �Ǘ��@�\�A�摜�`�F�b�N�i���O���ڒlj��j��
*2001/03/17 v2.1 �����Ĉ�‚ɁA�摜�ۑ��������ԁ����[�J����
*2001/06/30 v2.2 Win�t�@�C��������p�X\\������
*2001/07/17 v2.3 �Ǘ��p�X���޸ޏC���A��
*/
//-------------�ݒ肱������-------------
# �f���‚̃^�C�g��
$title = '�摜BBS�`��';
# �Ǘ��җp�p�X���[�h�B�K���ύX���ĉ������B
$admin_pass = 'asdfg';
# �t�@�C�����A�b�v���[�h����f�B���N�g��
# �Ō�� / �ɂ��ĉ������B
$up_dir = '/img/';
# �A�b�v���[�h����f�B���N�g���̐�΃p�X
$path = dirname($PATH_TRANSLATED).$up_dir;
# ���O�ۑ��t�@�C��
$logfile = 'imglog.log';
# html�ɏ����o�����ǂ���
$HTML = 0;
# �ÓIHTML�������o���ꍇ��HTML�t�@�C��
$html_file = '';
# ��y�[�W������̕\���L����
$page_def = 7;
# �ő�L�^���� ������z����ƌÂ������珇�ɍ폜����܂��B
$max = 200;
# �摜�t�@�C���� <IMG> �^�O�Œ��ڕ\�����邩�ǂ��� 1 �ŕ\�� 0 �ŕ\�����Ȃ�
$show_img = 1;
# ����z�X�g����̘A�����e�𐧌�
# --> �b�����L�q����Ƃ��̎��Ԉȏ���o�߂��Ȃ��ƘA�����e�ł��Ȃ�
$w_regist = 0;
# �Ǘ��҂����‚����摜�̂ݕ\���i�`�F�b�N���Ă���F1,���ׂĕ\���F0�j
$ImageCheck = 0;
# ���1�̏ꍇ�A�`�F�b�N����ĂȂ��摜�̑�։摜
$IconSoon = './soon.gif';
# �摜�t�@�C���̍ő�\���̑傫���i�P�ʁF�s�N�Z���j
# --> ����𒴂���摜�͏k���\�����܂�
$MaxW = 300; # ����
$MaxH = 300; # �c��
# �A�b�v���[�h�”\�ȍő�T�C�Y�i�P�� : KB�j
# -->php.ini�܂���php_upload_max_filesize�ɂ��܂����A
# �f�t�H���g�l�ł���Q���K�ȏ�͐ݒ�ł��܂���B
$maxbyte = 150;
// ������HP�i�����N�j
$HOME = "http://php.s3.to/";
//---------�ݒ肱���܂�--------------
$maxsize = $maxbyte * 1024; //�o�C�g�ɕϊ�
function head(&$dat){ //�w�b�_�[�\����
global $mode,$no,$PHP_SELF,$logfile,$maxsize,$maxbyte,$MaxW,$MaxH,$title,$HOME;
if($mode == "resmsg"){ //���X�̏ꍇ
$res = file($logfile);
$flag = 0;
while (list($key, $value) = each ($res)) {
list($rno,$date,$name,$mail,$sub,$com,$url) = explode("<>", $value);
if ($no == "$rno"){ $flag=1; break; }
}
if ($flag == 0) error("�Y���L�������‚���܂���");
$r_sub = "Re:$sub";
$r_com = "&gt;$com";
$r_com = eregi_replace("<br />","\r&gt;",$r_com);
}
$dat='<html><head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=Shift_JIS">
<STYLE TYPE="text/css">
<!--
body,tr,td,th { font-size:10pt }
a:hover { color:#DD0000; }
span { font-size:20pt }
small { font-size:8pt }
-->
</STYLE>
<title>'.$title.'</title></head>
<body bgcolor="#FFFFEE" text="#800000" link="#0000EE" vlink="#0000EE">
<p align=right>
[<a href="'.$HOME.'" target="_top">�g�b�v�ɖ߂�</a>]
[<a href="'.$PHP_SELF.'?mode=admin">�Ǘ��p</a>]
</p>
<center><!--�㕔�o�i�[--><P>
<font color="#800000" face="�l�r �o�S�V�b�N" size=5><b><SPAN>'.$title.'</SPAN></b></font>
<hr width="90%" size=1>
<form action="'.$PHP_SELF.'" method="POST" enctype="multipart/form-data">
<input type=hidden name=mode value="regist">
<input type="hidden" name="MAX_FILE_SIZE" value="'.$maxsize.'">
<table cellpadding=1 cellspacing=1>
<tr>
<td bgcolor=#eeaa88><b>���Ȃ܂�</b></td>
<td><input type=text name=name size="28" value=""></td>
</tr>
<tr>
<td bgcolor=#eeaa88><b>�d���[��</b></td>
<td><input type=text name=email size="28" value=""></td>
</tr>
<tr>
<td bgcolor=#eeaa88><b>��@�@��</b></td>
<td>
<input type=text name=sub size="35" value="'.$r_sub.'">
<input type=submit value="���M����"><input type=reset value="���Z�b�g">
</td>
</tr>
<tr>
<td bgcolor=#eeaa88><b>�R�����g</b></td>
<td><textarea name=com cols="48" rows="4" wrap=soft>'.$r_com.'</textarea>
</td>
</tr>
<tr>
<td bgcolor=#eeaa88><b>�t�q�k</b></td>
<td><input type=text name=url size="63" value="http://"></td>
</tr>
<tr>
<td bgcolor=#eeaa88><b>�Y�tFile</b></td>
<td><input type=file name=upfile size="35"></td>
</tr>
<tr>
<td bgcolor=#eeaa88><b>�폜�L�[</b></td>
<td>
<input type=password name=pwd size=8 maxlength=8 value="">
<small>(�L���̍폜�p�B�p������8�����ȓ�)</small>
</td>
</tr>
<tr><td colspan=2>
<small>
<LI>�Y�t�”\�t�@�C�� �F GIF, JPG, PNG<br>
<LI>�u���E�U�ɂ���Ă͐���ɓY�t�ł��Ȃ����Ƃ�����܂��B<br>
<LI>�ő哊�e�f�[�^�ʂ� '.$maxbyte.'KB �܂łł��B<br>
<LI>�摜�͉� '.$MaxW.'�s�N�Z���A�c '.$MaxH.'�s�N�Z���𒴂���Ək���\������܂��B</small>
</td></tr></table></form></center>
<hr>';
}
function foot(&$dat){ //�t�b�^�[�\����
global $PHP_SELF;
$dat.='<table align=right><tr>
<td nowrap align=center><form action="'.$PHP_SELF.'" method="POST">
<input type=hidden name=mode value="usrdel">
�y�L���폜�z<br>
�L��No<input type=text name=no size=3>
�폜�L�[<input type=password name=pwd size=4 maxlength=8>
<input type=submit value="�폜">
</form></td>
</tr></table><br clear=all>
<center><!--�����o�i�[--><P><small><!-- GazouBBS v2.0 -->
- <a href="http://php.s3.to" target="_top">GazouBBS</a> -
</small></center>
</body></html>';
}
function Main(&$dat){ //�L���\����
global $logfile,$page_def,$up_dir,$page,$PHP_SELF,
$path,$IconSoon,$ImageCheck;
$view = file($logfile);
$logsize = sizeof($view);
if(isset($page)) $start = $page;
else $start = $logsize - 1;
$end = $start - $page_def + 1;
if($end < 0) $end = 0;
for($s = $start;$s >= $end;$s--){
list($no,$date,$name,$mail,$sub,$com,$url,
$host,$pw,$imgfile,$W,$H,$time2,$chk) = explode("<>", $view[$s]);
if($url) { $url = "<a href=\"http://$url\" target=\"_blank\">HOME</a>"; }
if($mail){ $name = "<a href=\"mailto:$mail\">$name</a>"; }
$com = eregi_replace("(^|/>)(&gt;[^<]*)", "\\1<font color=789922>\\2</font>", $com);
if ($imgfile && file_exists("$path$imgfile")) {
if ($ImageCheck && $chk != 1) {
$dat.="<P><img src=\"$IconSoon\">";
} elseif ($W && $H) {
$dat.="<P><a href=\".$up_dir$imgfile\" target='_blank'><img src=\".$up_dir$imgfile\" width=$W height=$H border=0 align=left hspace=20></a>";
} else {
$dat.= "<P><a href=\".$up_dir$imgfile\" target='_blank'><img src=\".$up_dir$imgfile\" border=0 align=left hspace=20></a>";
}
}
$dat.="No.$no <font color=\"#cc1105\" size=+1><b>$sub</b></font><br> ";
$dat.="Name <font color=\"#117743\"><b>$name</b></font> Date $date ";
$dat.="[<a href=\"$PHP_SELF?mode=resmsg&no=$no\">RES</a>] &nbsp; $url <p>";
$dat.="<blockquote>\n";
$dat.="$com</blockquote><br clear=left><hr>\n";
$p++;
} //end for
if(($logsize > $page_def) && ($p >= $page_def)){
$dat.="<table align=left><tr>\n";
$dat.="<td><form action=$PHP_SELF?page=$end method=POST>";
$dat.="<input type=submit value=\"���̃y�[�W\" name=submit>\n";
$dat.="</form></td>\n</tr></table>\n";
}
}
function regist(){ //���O��������
global $name,$email,$sub,$com,$url,$MaxW,$MaxH,$source_name;
global $pwd,$upfile,$html_url,$logfile,$jisa,$max,$w_regist,$path;
// �t�H�[�����e���`�F�b�N
if(empty($com)){ error("�{�����������܂�Ă��܂���"); }
if(empty($name)){ error("���O���L������Ă��܂���"); }
if(empty($sub)){ $sub="�i����j"; }
$check = file($logfile);
$tail = sizeof($check);
$last = $tail - 1;
list($tno,$tdate,$tname,$tmail,$tsub,$tcom,
$turl,$thost,$tpw,$ttail,$tw,$th,$ttime) = explode("<>", $check[$last]);
if($name == $tname && $com == $tcom) error("��d���e�͋֎~�ł�");
if ($w_regist && $times - $ttime < $w_regist)
error("�A�����e�͂������΂炭���Ԃ�u���Ă��炨�肢�v���܂�");
// �L��No���̔�
$no = $tno + 1;
// �z�X�g�����擾
$host = getenv("REMOTE_HOST");
$addr = getenv("REMOTE_ADDR");
if($host == "" || $host == $addr) $host=@gethostbyaddr($addr);
// �폜�L�[���Í���
if ($pwd) { $PW = crypt(($pwd),aa); }
// URL���������N
if ($autolink) { auto_link($com); }
// �ő�L��������
if ($max < $tail) {
$del = file($logfile);
$top = $tail - $max;
for($j=$top; $j<=$tail; $j++){
list($no,$date,$name,$mail,$sub,$com,
$url,$host,$pw,$ex,$w,$h,$tim)= explode("<>", $del[$j]);
if (file_exists("$path$tim$ex")){ unlink("$path$tim$ex"); }
$dp = fopen ($logfile,"w");flock($dp,2);
fputs($dp, $del[$j]);flock($dp,3);
fclose($dp);
}
}
$now = gmdate( "Y/m/d(D) H:i",time()+9*60*60);
$url = ereg_replace( "^http://", "",$url);
$sub = htmlspecialchars($sub);
$sub = stripslashes($sub);
$name = htmlspecialchars($name);
$name = stripslashes($name);
$com = htmlspecialchars($com);
$com = stripslashes($com);
$com = str_replace( "\r\n", "\r", $com); //���s�����̓���B
$com = str_replace( "\r", "\n", $com);
$com = ereg_replace("\n((�@| |\t)*\n){3,}","\n",$com);//�A�������s����s
$com = nl2br($com); //���s�����̑O��<br>��������B
$com = ereg_replace( "\n", "", $com); //\n�𕶎��񂩂�����B
$times = time();
if ($upfile) {
$fname=UpFile();
$size = @getimagesize("$path$fname");
$W=$size[0];$H=$size[1];
// �摜�\���k��
if ($W > $MaxW || $H > $MaxH) {
$W2 = $MaxW / $W;
$H2 = $MaxH / $H;
($W2 < $H2) ? $key = $W2 : $key = $H2;
$W = (int) $W * $key;
$H = (int) $H * $key;
}
}
$new_msg="$no<>$now<>$name<>$email<>$sub<>$com<>$url<>$host<>$PW<>$fname<>$W<>$H<>$times<><>\n";
$fp = fopen($logfile,"a");
flock($fp,2);
fputs($fp, $new_msg);
flock($fp,3);
fclose($fp);
// ���[���ʒm����
// if ($mailing == 1) { mail_to(); }
}
function UpFile(){ //�A�b�v���[�h����
global $up_dir,$upfile,$upfile_name,$path;
$source = $upfile;
$source_name = $upfile_name;
//6/30
$source_name = ereg_replace("^(.:.*\\\\)?(.*)", "\\2", $source_name);
if(($source != "none")&&($source != "")){
$dest = $path.$source_name;
if(copy($source,$dest)){
echo "����";
$imagesize = getimagesize($dest);
switch($imagesize[2]) {
case 0:
error("�摜�ȊO�̓A�b�v���[�h�ł��܂���");
unlink($dest);
exit;
case 1:
echo " $imagesize[0] x $imagesize[1]<br>";
echo "GIF�摜 �A�b�v���� �| $dest";
break;
case 2:
echo " $imagesize[0] x $imagesize[1]<br>";
echo "JPG�摜 �A�b�v���� �| $dest";
break;
case 3:
echo " $imagesize[0] x $imagesize[1]<br>";
echo "PNG�摜 �A�b�v���� �| $dest";
break;
}
} else {
error("Upload �f�B���N�g���ɏ������ݎ��s\n");
}
unlink($source);
}
return $source_name;
}
function usrdel(){ //���[�U�[�폜
global $pwd,$no,$logfile,$path;
if ($no == "" || $pwd == "")
{ error("�폜No�܂��͍폜�L�[�����̓����ł�"); }
$logall = file($logfile);
$flag=0;
while(list(,$lines)=each($logall)){
list($o_no,$date,$name,$mail,$sub,$com,$url,$host,$pw,$tail,$w,$h,$o_tim) = explode("<>",$lines);
if ($no == "$o_no") { $flag=1; $PWD=$pw; $upfile="$tail"; }
else { $pushlog[]=$lines; }
}
if ($flag == 0) { error("�Y���L������������܂���"); }
if ($PWD == "") { error("�Y���L���ɂ͍폜�L�[���ݒ肳��Ă��܂���"); }
// �폜�L�[���ƍ�
$match = crypt(($pwd),aa);
if ($match != $PWD) { error("�폜�L�[���Ⴂ�܂�"); }
// ���O���X�V
$fp = fopen($logfile,"w");
flock($fp,2);
while(list(,$val)=each($pushlog)){
fputs($fp,$val);
}
flock($fp,3);
fclose($fp);
if(file_exists("$path$upfile")){ unlink("$path$upfile"); }
}
function admin(){ //�Ǘ��@�\
global $admin_pass,$PHP_SELF,$logfile,$path,$ImageCheck;
global $del,$pass,$chk;
if ($pass && $admin_pass != "$pass")
{ error("�p�X���[�h���Ⴂ�܂�"); }
?>
<html><head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=Shift_JIS">
<STYLE TYPE="text/css">
<!--
body,tr,td,th { font-size:9pt; }
a:hover { color:#DD0000; }
span { font-size:20pt; }
small { font-size:9pt }
-->
</STYLE>
<?
echo "<title>$title</title></head>";
echo "<body bgcolor=\"#FFFFEE\" text=\"#800000\">";
echo "[<a href=\"$PHP_SELF\">�f���‚ɖ߂�</a>]\n";
echo "<table width='100%'><tr><th bgcolor=\"#A08000\">\n";
echo "<font color=\"#FFFFFF\">�Ǘ����[�h</font>\n";
echo "</th></tr></table>\n";
if (!$pass) {
echo "<P><center><h4>�p�X���[�h����͂��ĉ�����</h4>\n";
echo "<form action=\"$PHP_SELF\" method=\"POST\">\n";
echo "<input type=hidden name=mode value=\"admin\">\n";
echo "<input type=password name=pass size=8>";
echo "<input type=submit value=\" �F�� \"></form>\n";
}else {
// �摜����
if ($chk) {
// �摜�����}�b�`���O���X�V
$logall = file($logfile);
while(list(,$lines)=each($logall)){
list($no,$date,$name,$mail,$sub,$com,$url,$host,$pw,$tail,$w,$h,$o_tim,$check) = explode("<>",$lines);
if ($chk == "$no") { $lines="$no<>$date<>$name<>$mail<>$sub<>$com<>$url<>$host<>$pw<>$tail<>$w<>$h<>$o_tim<>1<>"; }
$pushlog[]=$lines;
}
// ���O���X�V
$fp = fopen($logfile,"w");
flock($fp,2);
while(list(,$val)=each($pushlog)){
fputs($fp,$val);
}
flock($fp,3);
fclose($fp);
}
// �폜����
if ($del) {
// �폜�����}�b�`���O���X�V
$delall = file($logfile);
$flag = 0;
while(list(,$delline)=each($delall)){
list($no,$date,$name,$mail,$sub,$com,$url,$host,$pw,$tail,$w,$h,$time) = explode("<>",$delline);
if ($del == "$no") {
$flag = 1;
if (file_exists("$path$tail")){
unlink("$path$tail"); }
continue;
}
if($flag == 0){ $dellog[]=$delline; }
}
// ���O���X�V
$fp = fopen($logfile,"w");
flock($fp,2);
while(list(,$val)=each($dellog)){
fputs($fp,$val);
}
flock($fp,3);
fclose($fp);
}
// �폜��ʂ�\��
echo "<form action=\"$PHP_SELF\" method=\"POST\">\n";
echo "<input type=hidden name=mode value=\"admin\">\n";
echo "<input type=hidden name=pass value=\"$pass\">\n";
echo "<center><P>�폜�������L���̃`�F�b�N�{�b�N�X�Ƀ`�F�b�N�����A�폜�{�^���������ĉ������B\n";
echo "<P><table border=1 cellspacing=0>\n";
echo "<tr><th>�폜</th><th>�L��No</th><th>���e��</th><th>�薼</th>";
echo "<th>���e��</th><th>�R�����g</th><th>�z�X�g��</th><th>�Y�t<br>(Bytes)</th>";
if ($ImageCheck) { echo "<th>�摜<br>����</th>"; }
echo "</tr>\n";
$delmode = file($logfile);
while (list(,$val)=each($delmode)){
$img_flag=0;
list($no,$date,$name,$mail,$sub,$com,$url,
$host,$pw,$tail,$w,$h,$time,$chk) = explode("<>",$val);
list($date,$dmy) = split("\(", $date);
if ($mail) { $name="<a href=\"mailto:$mail\">$name</a>"; }
$com = str_replace("<br>","",$com);
$com = htmlspecialchars($com);
if(strlen($com) > 40){ $com = substr($com,0,38) . " ..."; }
if (file_exists("$path$tail")) {
$img_flag = 1;
$clip = "<a href=\"$path$tail\" target='_blank'>$File</a>";
$size = filesize("$path$tail");
$all += $size;
} else {
$clip = "";
$size = 0;
}
echo "<tr><th><input type=checkbox name=del value=\"$no\"></th>";
echo "<th>$no</th><td><small>$date</small></td><td>$sub</td>";
echo "<td><b>$name</b></td><td><small>$com</small></td>";
echo "<td>$host</td><td align=center>$clip<br>($size)</td>\n";
// �摜����
if ($ImageCheck) {
if ($img_flag == 1 && $chk == 1) {
echo "<th><font color=red>OK</font></th>";
} elseif ($img_flag == 1 && $chk != 1) {
echo "<th><input type=checkbox name=chk value=$no></th>";
} else {
echo "<td><br></td>";
}
}
echo "</tr>\n";
}
echo "</table>\n";
echo "<P><input type=submit value=\"�폜����\">";
echo "<input type=reset value=\"���Z�b�g\"></form>\n";
$all = (int)($all / 1024);
echo "�y�Y�t�f�[�^���� �F <b>$all</b> KB�z\n";
}
echo "</center>\n";
die ("</body></html>");
}
function MakeHtml(){ //HTML����
global $html_file;
head($buf);
Main($buf);
foot($buf);
$hp = fopen ($html_file,"w");
flock($hp,2);
fputs($hp, $buf);
fclose($hp);
include("$html_file");
exit;
}
function error($mes){ //�G���[�t�H�[�}�b�g
?>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=x-sjis"></head>
<body bgcolor="#f9f9ce" text="#1A1A1A">
<br><br><hr size=1><br><br>
<center><font color=red size=5><b><? echo $mes; ?></b></font></center>
<br><br><hr size=1></body></html>
<?
exit;
}
/*======Main======*/
switch($mode):
case 'regist':
regist();
if($HTML) MakeHtml();
echo '<META HTTP-EQUIV="refresh" CONTENT="0; URL='.$PHP_SELF.'">';
break;
case 'admin':
admin();
break;
case 'usrdel':
usrdel();
if($HTML) MakeHtml();
break;
default:
head($buf);
Main($buf);
foot($buf);
echo $buf;
break;
endswitch;
?>