#!/usr/bin/perl
# =========================================================================
#
# /////CLEVER BBS Ver.4.21 (Shift_JIS)/////
#
# Copyright (C) 2003-2006 solo.design
# All rights reserved
# Script written by Junichiro Kondo
# web site : http://solodesign.jp/
# mail : support@solodesign.jp
#
# =========================================================================
# 必要なファイルのパス指定 ------------------------------------------------
require './jcode.pl';
require './cgi-lib.pl';
require './bbsini.cgi';
# 設定終了 ----------------------------------------------------------------
# -------------------------------------------------------------------------
# メイン処理
# -------------------------------------------------------------------------
&decode;
&axs_check;
if ($mode eq "usr_del") { &usr_del; }
elsif ($mode eq "regist") { ®ist; }
elsif ($mode eq "res") { &res_form; }
elsif ($mode eq "admin") { &admin; }
elsif ($mode eq "check") { ✓ }
elsif ($mode eq "find") { &find; }
&html_log;
# -------------------------------------------------------------------------
# アクセス制限
# -------------------------------------------------------------------------
sub axs_check {
&get_host;
local($flag)=0;
foreach (@deny) {
if (!$_) { next; }
$_ =~ s/\*/\.\*/g;
if ($host =~ /$_/i) { $flag=1; last; }
}
if ($flag) { &error("アクセスを許可されていません"); }
}
# -------------------------------------------------------------------------
# 画面に表示する前の設定
# -------------------------------------------------------------------------
# HTMLのヘッダー ------------------------------------------------
sub adminheader {
print "Content-type: text/html\n\n";
print <<"EOM";
$title
EOM
}
# 記事表示部のヘッダ --------------------------------------------
sub header {
if (!$htm_renew) {
print "Content-type: text/html; charset=Shift_JIS\n\n";
}
open(SKIN, $cleverskin_html);
$cleverskin = join('',);
close(SKIN);
($head_html,$write_html,$mainhtml,$reshtml,$mafot_html,$fot_html) = split(//, $cleverskin);
if ($htm_renew) {
print OUT $head_html;
} else {
print $head_html;
}
}
# 記事表示部の投稿欄 --------------------------------------------
sub write {
if (!$htm_renew) {
&get_cookie;
$write_html =~ s/(name="name")/$1 value="$c_name"/i;
$write_html =~ s/(name="email")/$1 value="$c_email"/i;
$write_html =~ s/(name="url")/$1 value="http:\/\/$c_url"/i;
$write_html =~ s/(name="pwd")/$1 value="$c_pwd"/i;
}
if ($mode eq "find") {
$write_html =~ s/(name="word")/$1 value="$in{'word'}"/i;
}
if ($in{'cond'} eq 'or') {
$write_html =~ s/(value="or")/$1 checked/i;
} else {
$write_html =~ s/(value="and")/$1 checked/i;
}
if ($htm_renew) {
print OUT $write_html;
} else {
print $write_html;
}
}
# 記事表示部のメイン --------------------------------------------
sub main {
if (!$reno && $flag) {
$flag=1;
if ($htm_renew) {
print OUT $mafot_html;
} else {
print $mafot_html;
}
}
if (!$reno) {
&auto_link($comment);
$maintmp = $mainhtml;
$maintmp =~ s/no/$no/i;
$maintmp =~ s/name/$name/i;
$maintmp =~ s/url/$url/i;
$maintmp =~ s/sub/$sub/i;
$maintmp =~ s/comment/$comment/i;
$maintmp =~ s/date/$dat_tmp/i;
$maintmp =~ s/mail/$mail/i;
$maintmp =~ s/color/$color/i;
if (-e "$ImgDir$no$tail") {
$maintmp =~ s/img/$img/i;
} else {
$maintmp =~ s/img//i;
}
$maintmp =~ s/(a href="resinput")/a href="$script?mode=res&no=$no"/i;
$flag=1;
if ($htm_renew) {
print OUT $maintmp;
} else {
print $maintmp;
}
}
if ($reno) {
&auto_link($comment);
$restmp = $reshtml;
$restmp =~ s/resno/$no/i;
$restmp =~ s/resname/$name/i;
$restmp =~ s/resurl/$url/i;
$restmp =~ s/ressub/$sub/i;
$restmp =~ s/rescomment/$comment/i;
$restmp =~ s/resdate/$dat_tmp/i;
$restmp =~ s/resmail/$mail/i;
$restmp =~ s/rescolor/$color/i;
if (-e "$ImgDir$no$tail") {
$restmp =~ s/resimg/$img/i;
} else {
$restmp =~ s/resimg//i;
}
if ($htm_renew) {
print OUT $restmp;
} else {
print $restmp;
}
}
}
# 記事表示部のフッタ --------------------------------------------
sub footer {
$fottmp = $fot_html;
$next = $page + $p_log;
$back = $page - $p_log;
$p_flag=0;
if ($page_icon) {
$page_back = "
";
$page_next = "
";
} else {
$page_back = $back_text;
$page_next = $next_text;
}
if ($mode eq "find") {
if ($in{'word'} ne "") {
if ($count >= 1) {
$fottmp =~ s/footmsg/「$in{'word'}」を検索した結果ヒット数は$count件ありました。/i;
} else {
$fottmp =~ s/footmsg/「$in{'word'}」を検索した結果マッチする書き込みはありませんでした。/i;
}
if ($back_line >= 0) {
$fottmp =~ s/back/$page_back<\/a>/i;
} else {
$fottmp =~ s/back//i;
}
if ($page_end ne "$end_data") {
$fottmp =~ s/next/$page_next<\/a>/i;
} else {
$fottmp =~ s/next//i;
}
} else {
$fottmp =~ s/footmsg/検索キーワードを入力してください。/i;
$fottmp =~ s/back//i;
$fottmp =~ s/next//i;
}
} else {
$fottmp =~ s/footmsg//i;
if ($back >= 0) {
$p_flag=1;
$fottmp =~ s/back/$page_back<\/a>/i;
} else {
$fottmp =~ s/back//i;
}
if ($next < $i) {
$p_flag=1;
$fottmp =~ s/next/$page_next<\/a>/i;
} else {
$fottmp =~ s/next//i;
}
}
if ($htm_renew) {
print OUT $fottmp;
} else {
print $fottmp;
}
}
# レス記事部のヘッダ --------------------------------------------
sub resheader {
print "Content-type: text/html; charset=Shift_JIS\n\n";
open(RES, $resskin_html);
$resskin = join('',);
close(RES);
($reshead_html,$reswrite_html,$resmainhtml,$resreshtml,$resmafot_html,$resfot_html) = split(//, $resskin);
print $reshead_html;
}
# レス記事部の投稿欄 -------------------------------------------
sub reswrite {
&get_cookie;
if ($res_clip) {
$reswrite_html =~ s/(method="POST")/$1 enctype="multipart\/form-data"/i;
} else {
$reswrite_html =~ s/(method="POST")/$1/i;
}
$reswrite_html =~ s/(name="name")/$1 value="$c_name"/i;
$reswrite_html =~ s/(name="email")/$1 value="$c_email"/i;
$reswrite_html =~ s/(name="url")/$1 value="http:\/\/$c_url"/i;
$reswrite_html =~ s/(name="pwd")/$1 value="$c_pwd"/i;
$reswrite_html =~ s/(name="reno")/$1 value="$in{'no'}"/i;
print $reswrite_html;
}
# レス記事部のメイン --------------------------------------------
sub resmain {
if ($in{'no'} eq "$no" || $in{'no'} eq "$reno") {
$dat_tmp = $dateline;
($d_year,$d_mon,$d_day,$d_weekstr,$d_hour,$d_min,$d_sec) = split(/&/,$date);
$dat_tmp =~ s/year/$d_year/i;
$dat_tmp =~ s/month/$d_mon/i;
$dat_tmp =~ s/day/$d_day/i;
$dat_tmp =~ s/week/$d_weekstr/i;
$dat_tmp =~ s/hour/$d_hour/i;
$dat_tmp =~ s/minute/$d_min/i;
$dat_tmp =~ s/second/$d_sec/i;
if (!$reno) {
&auto_link($comment);
$resmaintmp = $resmainhtml;
$resmaintmp =~ s/no/$no/i;
$resmaintmp =~ s/name/$name/i;
$resmaintmp =~ s/url/$url/i;
$resmaintmp =~ s/sub/$sub/i;
$resmaintmp =~ s/comment/$comment/i;
$resmaintmp =~ s/date/$dat_tmp/i;
$resmaintmp =~ s/mail/$mail/i;
$resmaintmp =~ s/color/$color/i;
if (-e "$ImgDir$no$tail") {
$resmaintmp =~ s/img/$img/i;
} else {
$resmaintmp =~ s/img//i;
}
print $resmaintmp;
}
if ($reno) {
&auto_link($comment);
$resrestmp = $resreshtml;
$resrestmp =~ s/resno/$no/i;
$resrestmp =~ s/resname/$name/i;
$resrestmp =~ s/resurl/$url/i;
$resrestmp =~ s/ressub/$sub/i;
$resrestmp =~ s/rescomment/$comment/i;
$resrestmp =~ s/resdate/$dat_tmp/i;
$resrestmp =~ s/resmail/$mail/i;
$resrestmp =~ s/rescolor/$color/i;
if (-e "$ImgDir$no$tail") {
$resrestmp =~ s/resimg/$img/i;
} else {
$resrestmp =~ s/resimg//i;
}
print $resrestmp;
if ($reno && !$flag) { $flag=1; }
}
}
}
# レス記事部のフッタ --------------------------------------------
sub resfooter {
print $resfot_html;
}
# 検索記事表示部のメイン ----------------------------------------
sub findmain {
&auto_link($comment);
$findmaintmp = $mainhtml;
$findmaintmp =~ s/no/$findno/i;
$findmaintmp =~ s/name/$name/i;
$findmaintmp =~ s/url/$url/i;
$findmaintmp =~ s/sub/$sub/i;
$findmaintmp =~ s/comment/$comment/i;
$findmaintmp =~ s/date/$dat_tmp/i;
$findmaintmp =~ s/mail/$mail/i;
$findmaintmp =~ s/color/$color/i;
if (-e "$ImgDir$no$tail") {
$findmaintmp =~ s/img/$img/i;
} else {
$findmaintmp =~ s/img//i;
}
$findmaintmp =~ s/(a href="resinput")/a href="$script?mode=res&no=$resno"/i;
print $findmaintmp;
print $mafot_html;
}
# -------------------------------------------------------------------------
# HTML更新処理
# -------------------------------------------------------------------------
sub html_renew {
if ($htmfile ne "") {
open(OUT,">$htmfile") || &error("Write Error: $htmfile");
$htm_renew = 1;
&header;
&write;
$start = $page + 1;
$end = $page + $p_log;
open(IN,"$logfile") || &error("Open Error : $logfile");
$top = ;
$i=0;
$flag=0;
while () {
($no,$reno,$date,$name,$mail,$sub,$comment,
$url,$host,$pw,$color,$tail,$w,$h,$chk) = split(/<>/);
if ($reno eq "") { $i++; }
if ($i < $start) { next; }
if ($i > $end) { next; }
$dat_tmp = $dateline;
($d_year,$d_mon,$d_day,$d_weekstr,$d_hour,$d_min,$d_sec) = split(/&/,$date);
$dat_tmp =~ s/year/$d_year/i;
$dat_tmp =~ s/month/$d_mon/i;
$dat_tmp =~ s/day/$d_day/i;
$dat_tmp =~ s/week/$d_weekstr/i;
$dat_tmp =~ s/hour/$d_hour/i;
$dat_tmp =~ s/minute/$d_min/i;
$dat_tmp =~ s/second/$d_sec/i;
if ($mail_icon && $mail) { $mail = "
"; }
elsif (!$mail_icon && $mail) {
if ($name_link) { $name = "$name"; }
else { $mail = "$mail_text"; }
}
if ($home_img) { $link_img = ""; }
if ($home_icon && $url) { $url = "
"; }
elsif (!$home_icon && $url) { $url = "$home_text"; }
&imgview;
&main;
}
close(IN);
print OUT $mafot_html;
&footer;
close(OUT);
$htm_renew = 0;
}
}
# -------------------------------------------------------------------------
# 記事表示部
# -------------------------------------------------------------------------
sub html_log {
&header;
&write;
$start = $page + 1;
$end = $page + $p_log;
open(IN,"$logfile") || &error("Open Error : $logfile");
$top = ;
$i=0;
$flag=0;
while () {
($no,$reno,$date,$name,$mail,$sub,$comment,
$url,$host,$pw,$color,$tail,$w,$h,$chk) = split(/<>/);
if ($reno eq "") { $i++; }
if ($i < $start) { next; }
if ($i > $end) { next; }
$dat_tmp = $dateline;
($d_year,$d_mon,$d_day,$d_weekstr,$d_hour,$d_min,$d_sec) = split(/&/,$date);
$dat_tmp =~ s/year/$d_year/i;
$dat_tmp =~ s/month/$d_mon/i;
$dat_tmp =~ s/day/$d_day/i;
$dat_tmp =~ s/week/$d_weekstr/i;
$dat_tmp =~ s/hour/$d_hour/i;
$dat_tmp =~ s/minute/$d_min/i;
$dat_tmp =~ s/second/$d_sec/i;
if ($mail_icon && $mail) { $mail = "
"; }
elsif (!$mail_icon && $mail) {
if ($name_link) { $name = "$name"; }
else { $mail = "$mail_text"; }
}
if ($home_img) { $link_img = ""; }
if ($home_icon && $url) { $url = "
"; }
elsif (!$home_icon && $url) { $url = "$home_text"; }
&imgview;
&main;
}
close(IN);
print $mafot_html;
&footer;
}
# -------------------------------------------------------------------------
# 返信フォーム
# -------------------------------------------------------------------------
sub res_form {
open(IN,"$logfile") || &error("Open Error : $logfile");
$top = ;
&resheader;
&reswrite;
$flag=0;
while () {
($no,$reno,$date,$name,$mail,$sub,$comment,
$url,$host,$pw,$color,$tail,$w,$h,$chk) = split(/<>/);
if ($mail_icon && $mail) { $mail = "
"; }
elsif (!$mail_icon && $mail) {
if ($name_link) { $name = "$name"; }
else { $mail = "$mail_text"; }
}
if ($home_icon && $url) { $url = "
"; }
elsif (!$home_icon && $url) { $url = "$home_text"; }
&imgview
&resmain
}
close(IN);
print $resmafot_html;
&resfooter;
exit;
}
# -------------------------------------------------------------------------
# エラー処理
# -------------------------------------------------------------------------
sub error {
&unlock if ($lockflag);
&adminheader;
print <<"EOM";
EOM
exit;
}
# -------------------------------------------------------------------------
# 管理モード
# -------------------------------------------------------------------------
sub admin {
if ($in{'pass'} eq "") {
&adminheader;
print <<"EOM";