/*
* �摜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����
�^�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 = ">$com";
$r_com = eregi_replace("
","\r>",$r_com);
}
$dat='
'.$title.'
[�g�b�v�ɖ߂�]
[�Ǘ��p]
'.$title.'
';
}
function foot(&$dat){ //�t�b�^�[�\����
global $PHP_SELF;
$dat.='
- GazouBBS -
';
}
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 = "HOME"; }
if($mail){ $name = "$name"; }
$com = eregi_replace("(^|/>)(>[^<]*)", "\\1\\2", $com);
if ($imgfile && file_exists("$path$imgfile")) {
if ($ImageCheck && $chk != 1) {
$dat.="
";
} elseif ($W && $H) {
$dat.="
";
} else {
$dat.= "
";
}
}
$dat.="No.$no $sub
";
$dat.="Name $name Date $date ";
$dat.="[RES] $url
";
$dat.="
\n";
$dat.="$com
\n";
$p++;
} //end for
if(($logsize > $page_def) && ($p >= $page_def)){
$dat.="\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��
��������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]
";
echo "GIF�摜 �A�b�v���� �| $dest";
break;
case 2:
echo " $imagesize[0] x $imagesize[1]
";
echo "JPG�摜 �A�b�v���� �| $dest";
break;
case 3:
echo " $imagesize[0] x $imagesize[1]
";
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���Ⴂ�܂�"); }
?>
echo "$title";
echo "";
echo "[�f���ɖ߂�]\n";
echo "| \n";
echo "�Ǘ����[�h\n";
echo " |
|---|
\n";
if (!$pass) {
echo "�p�X���[�h����͂��ĉ�����
\n";
echo "\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 "\n";
$all = (int)($all / 1024);
echo "�y�Y�t�f�[�^���� �F $all KB�z\n";
}
echo "\n";
die ("");
}
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
?>
echo $mes; ?>
exit;
}
/*======Main======*/
switch($mode):
case 'regist':
regist();
if($HTML) MakeHtml();
echo '';
break;
case 'admin':
admin();
break;
case 'usrdel':
usrdel();
if($HTML) MakeHtml();
break;
default:
head($buf);
Main($buf);
foot($buf);
echo $buf;
break;
endswitch;
?>