# Ir-i-BBS   -  interface for ezWeb
# ---------------------------------
#   Copyright (c) 1999 by Irao Computer System, All rights reserved.
#

my $copyright_ez = "<IMG ICON=\"copyright\">1999 by Irao.";
#ここまで変更厳禁

$ezMail1 = 'DEST="device:home/goto?svc=Email&SUB=sendMsg" VARS="TO=';
$ezMail2 = 'DEST="mailto:';

$ezMail = ($ENV{'HTTP_X_UP_SUBNO'} =~ /[a-z][a-z]\.ezweb/)? $ezMail2 : $ezMail1;

$sendRef = ($send_referer_ez)? ' SENDREFERER="TRUE"' : '';

$d_markable =~ tr/a-z/A-Z/;
$d_public =~ tr/a-z/A-Z/;
my $next_ez = 0;
my $end_mes = 0;

sub ez_mail_encode {
    my ($m) = @_;
    $m =~ s/([^-0-9a-zA-Z@._])/'%'.unpack 'H2',$1/eg;
    return $m;
}

sub about_ez {
    $about_data_ez = &load_about;
    $buffer =<<"EOB";
<HDML VERSION="3.0" TTL="64800"><DISPLAY NAME="TOP">
<ACTION TYPE="ACCEPT" LABEL="戻る" TASK="PREV">
<CENTER><IMG ICON="pushpin">$ezweb_title<IMG ICON="pushpin"><BR>
<CENTER>$version<BR><BR>
$about_data_ez<BR>
$copyright_ez<BR>
All rights reserved.</DISPLAY>
EOB
    &$output_buffer;
    exit;
}

sub top_ez {
    my($attribute, $d_ispublic, $returl, $top_data_ez);
    local ($topez);
    
    $d_ispublic = "$d_markable $d_public";
    $attribute .= ' MARKABLE="' . $d_markable . '"'
        if ($d_markable =~ /(TRUE|FALSE)/);
    $attribute .= ' PUBLIC="' . $d_public . '"'
        if ($d_public =~ /(TRUE|FALSE)/);
    $attribute .= ' ACCESSDOMAIN="' . $d_accessdomain . '"'
        if (($d_accessdomain ne "") && ($d_ispublic =~ /FALSE/));
    $attribute .= ' ACCESSPATH="' . $d_accesspath . '"'
        if (($d_accesspath ne "") && ($d_ispublic =~ /FALSE/));
    $returl = (($ret_ez) && ($ret_ez !~ /^\s*$/))? $ret_ez : '';

    $topez = "true";
    $top_data_ez = &load_about;

    $returl =<<"EOR" if ($returl);
<ACTION TYPE="SOFT1" LABEL="戻る" TASK="GO" DEST="$returl">
EOR
    my ($addition);
    $addition = "<BR><CENTER>$version" if ($print_version);

    my $counterStr = '<CENTER>' . $mobile_counter_front_str . $a_count . $mobile_counter_back_str
    if ($mobile_counter_mode and $enable_counter);

	my $anounce;
	my $ezlast = (exists $COOKIE{'EzLAx'})? $COOKIE{'EzLAx'} : undef;
	if (not defined $ezlast or (stat($bbs_data_file))[9] > $ezlast) {
		my $expDate = &get_gmt(86400*$cookDaysEz);
		my $now = time;
		$cook = "Set-Cookie: EzLAx=$now; expires=$expDate\n";
		undef $ezlast;
		$anounce = '<LINE>更新されました. 再読込します<WRAP>';
		print <<"EOB";
Content-Type: multipart/mixed;boundary="--EZweb"
$cook


----EZweb
Content-Type: application/x-up-cacheop

OpCode=InvalidateSVC&Operand=$ENV{'SCRIPT_NAME'}%3Fstart

----EZweb
EOB
	}

    $buffer =<<"EOB";
<HDML VERSION="3.0" TTL="0"$attribute><DISPLAY NAME="TOP">
<ACTION TYPE="ACCEPT" LABEL="入る" REL="NEXT" TASK="GO" DEST="?start=0">
$returl
<CENTER><IMG ICON="pushpin">$ezweb_title<IMG ICON="pushpin">$addition
$counterStr<BR>$anounce<BR>$top_data_ez
$copyright_ez<BR>All rights reserved.</DISPLAY>
EOB
    &$output_buffer;
	if (not defined $ezlast) {
		print "----EZweb--\n\n";
	}
    exit;
}

sub reload_ez {
	print <<"EOB";
Content-Type: multipart/mixed;boundary="--EZweb"


----EZweb
Content-Type: application/x-up-cacheop

OpCode=InvalidateSVC&Operand=$ENV{'SCRIPT_NAME'}

----EZweb
Content-Type: text/x-hdml;charset=Shift_JIS

<HDML VERSION="3.0" TTL=0><NODISPLAY NAME=RELOAD>
<ACTION TYPE=ACCEPT TASK=GO DEST="?start=0">
</NODISPLAY></HDML>

----EZweb--
EOB
	exit;
}

sub write_ez_body {
    my ($cname, $cmail, $cseed);
    $cname = $COOKIE{'name'};
    $cmail = $COOKIE{'email'};
    $cseed = $COOKIE{'seed'};
    my $postdata = 'action=regist&name=$(nm)&email=$(ma)&subject=$(sb)';
    $postdata .= '&message=$(ms)&pass=$(pw)';

    &wri_mod_body($cname, $cmail, "", "", $cseed, '記入', $postdata);
    exit;
}

sub change_ez_body {
    my ($contact, $rettop);
    
    if (($contact_admin) && 
            ($email_admin =~ /^[a-zA-Z0-9\.\-]+\@[a-zA-Z0-9\.\-]+$/)) {
        my $emad = $email_admin;
        $emad =~ s/^\s+//;
        $emad =~ s/\s+$//;
        my $emad2 = &ez_mail_encode($emad);
        $contact =<<"EOC";
<CE LABEL="メール" TASK="GOSUB" ${ezMail}$emad2">管理人に連絡する
EOC
    }
    $rettop = (($ret_local) && ($ret_local !~ /^\s*$/))? $ret_local : '';
    $rettop =<<"EOR" if ($rettop);
<CE LABEL="戻る" TASK="GO" DEST="$rettop">トップに戻る
EOR
    my ($logmode);
    if (($save_log) && (-e $bbs_log_file)) {
        $logmode = '<CE LABEL="表示" TASK="GO" METHOD="GET" DEST="?mode=log&start=0">掲示板の過去ログ';
    }
    $buffer = <<"EOB";
<HDML VERSION="3.0"><ACTION LABEL="戻る" TYPE="SOFT1" TASK="RETURN">
<CHOICE NAME="CHANGE">次から動作を選んでください<BR>
<CE LABEL="開始" TASK="GO" METHOD="GET" DEST="?action=write">掲示板に書込む
<CE LABEL="実行" TASK="GO" METHOD="GET" DEST="?action=reload">再読込する
<CE LABEL="実行" TASK="GO" METHOD="GET" DEST="?action=find">記事を検索
<CE LABEL="行う" TASK="GO" METHOD="GET" DEST="?action=select">記事の修正
<CE LABEL="開始" TASK="GO" METHOD="GET" DEST="?action=delete">記事を削除
<CE LABEL="見る" TASK="GO" METHOD="GET" DEST="?action=about">掲示板の概要
${rettop}${logmode}${contact}<CE LABEL="設定" TASK="GO" METHOD="GET" DEST="?action=ch_init">掲示板の設定
<CE LABEL="設定" TASK="GO" METHOD="GET" DEST="?action=ch_master">管理パス変更
</CHOICE>
EOB
    &$output_buffer;
    exit;
}

sub view_ez_head {
    my ($arg) = @_;
    require $ir_i_def_pl if ($imchr_title);
    
    $end_mes = 0;
    if ($arg) {
        $next_ez = $start + $page_max;
        if ($arg <= $page_max + $start) {
            $next_ez = $arg - 1;
            $end_mes = 1;
        }
    } else {
        $next_ez = 0;
    }
    $buffer =<<"EOB";
<HDML VERSION="3.0"><ACTION LABEL="メニュー" TASK="GOSUB" TYPE="SOFT1" METHOD="GET" DEST="?action=change">
EOB

    $ecclen = length($buffer) if ($ez_auto);

}

sub view_ez_body {
    my ($line) = @_;
    my $line_number = $i;
    unless ($line) {
        $buffer .= <<'EOB';
<DISPLAY NAME="TOP"><CENTER>投稿はありません<BR></DISPLAY>
EOB
        return;
    }
    my ($subject, $name, $mail, $web, $message, $date, $host,
                    $addr, $agent, $pass, $unkey) = split("\t", $line);
    chomp $unkey;
    $date = &conv_date_imode($date);
    
    $message = &conv_imchr($message);
    $subject = &conv_imchr($subject);
    $name = &conv_imchr($name);

    $message = &conv_jschr($message);
    $subject = &conv_jschr($subject);
    $name = &conv_jschr($name);

    if ($mail ne "") {
        my $ml = $mail;
        $ml =~ s/^\s+//;
        $ml =~ s/\s+$//;
        my $ml2 = &ez_mail_encode($ml);
        $name = <<"EON";
<A LABEL="メール" TASK="GOSUB" ${ezMail}$ml2">$name</A>
EON
    }

    $sc = '[\x00-\x7F]';
    $wc = '[\x81-\x9F\xE0-\xFA][\x40-\x7E\x80-\xFB]';

    $name =~ s/^(($sc|$wc)*)?\$/$1\&#x24;/g;
    $subject =~ s/^(($sc|$wc)*)?\$/$1\&#x24;/g;
    $message =~ s/^(($sc|$wc)*)?\$/$1\&#x24;/g;

    my $template =<<"EOT";
$date<BR>$subject<BR>
<CENTER>$name<BR>
$message<BR><BR>
</DISPLAY>
EOT

    my $mlog = '&mode=log' if ($FORM{'mode'} =~ /^log$/i);
    my $next_action = "";
    my $smode = ($FORM{'q'})? '&q=$(str)&l=$(lgc)' : '';
    my ($tlen, $maxlen);
    $tlen = length($template);
    $maxlen = $ez_auto_size * 1024;
    if (($ez_auto) && ($ecclen + $tlen > $maxlen) && !($force)) {
        $buffer =~ s/<(ACTION TYPE="ACCEPT" LABEL="次)へ(" TASK="GO" DEST=)"#NUM${line_number}">/<${1}${2}"?start=$line_number$mlog$smode">/;
        return 1;
    }

    if (($next_ez) && ($line_number < ($next_ez - 1))) {
        my $next_ln = $line_number + 1;
        $next_action = <<"EON";
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#NUM$next_ln">
EON
    } elsif (($next_ez) && (!($end_mes))) {
        $next_action = <<"EON";
<ACTION TYPE="ACCEPT" LABEL="次" TASK="GO" METHOD="GET" DEST="?start=$next_ez$mlog$smode">
EON
    } else {
        if ($line_number == ($next_ez - 1)) {
            my $next_ln = $line_number + 1;
            $next_action = <<"EON";
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#NUM$next_ln">
EON
        } else {
            $next_action = <<'EON';
<ACTION TYPE="ACCEPT" LABEL="戻る" TASK="GO" METHOD="GET" DEST="?start=0$mlog">
EON
        }
    }

    $buffer .=<<"EOB";
<DISPLAY NAME="NUM$line_number">$next_action
$template
EOB
    if ($ez_auto) {
        $ecclen += $tlen;
        $ecclen += length(qq/<DISPLAY NAME="NUM$line_number">$next_action/);
    }
    return 0;
}

sub view_ez_foot {
    &$output_buffer;
}

sub view_ez_nums {
# Does nothing
}

sub logmenu_ez_body {
    my ($contact, $rettop);
    
    if (($contact_admin) && 
            ($email_admin =~ /^[a-zA-Z0-9\.\-]+\@[a-zA-Z0-9\.\-]+$/)) {
        my $emad = $email_admin;
        $emad =~ s/^\s+//;
        $emad =~ s/\s+$//;
        my $emad2 = &ez_mail_encode($emad);
        $contact =<<"EOC";
<CE LABEL="メール" TASK="GOSUB" ${ezMail}$emad2">管理人に連絡する
EOC
    }
    $rettop = (($ret_local) && ($ret_local !~ /^\s*$/))? $ret_local : '';
    $rettop =<<"EOR" if ($rettop);
<CE LABEL="戻る" TASK="GO" DEST="$rettop">トップに戻る
EOR
    $buffer = <<"EOB";
<HDML VERSION="3.0"><ACTION LABEL="戻る" TYPE="SOFT1" TASK="RETURN">
<CHOICE NAME="CHANGE">次から動作を選んでください<BR>
<CE LABEL="実行" TASK="GO" METHOD="GET" DEST="?start=0">通常モード
<CE LABEL="実行" TASK="GO" METHOD="GET" DEST="?action=find&mode=log">記事を検索
<CE LABEL="見る" TASK="GO" METHOD="GET" DEST="?action=about">掲示板の概要
$rettop
$contact
<CE LABEL="設定" TASK="GO" METHOD="GET" DEST="?action=ch_init">掲示板の設定
<CE LABEL="設定" TASK="GO" METHOD="GET" DEST="?action=ch_master">管理パス変更
</CHOICE>
EOB
    &$output_buffer;
    exit;
}

sub view_log_ez_head {
    my ($arg) = @_;
    require $ir_i_def_pl if ($imchr_title);
    
    $end_mes = 0;
    if ($arg) {
        $next_ez = $start + $page_max;
        if ($arg <= $page_max + $start) {
            $next_ez = $arg - 1;
            $end_mes = 1;
        }
    } else {
        $next_ez = 0;
    }
    $buffer =<<"EOB";
<HDML VERSION="3.0"><ACTION LABEL="メニュー" TASK="GOSUB" TYPE="SOFT1" METHOD="GET" DEST="?action=logmenu">
EOB

    $ecclen = length($buffer) if ($ez_auto);
}

sub view_log_ez {
    $view_head = 'view_log_ez_head';
    $view_body = 'view_ez_body';
    $view_foot = 'view_ez_foot';
}

sub delete_ez_head {
    my ($arg) = @_;
    require $ir_i_def_pl if ($imchr_title);
    $end_mes = 0;
    if ($arg) {
        $next_ez = $start + $page_max;
        if ($arg <= $page_max + $start) {
            $next_ez = $arg - 1;
            $end_mes = 1;
        }
    } else {
        $next_ez = 0;
    }
    $next_dele = "";
    unless ($end_mes) {
        $next_dele = <<"EON";
<CE LABEL="次" TASK="GO" METHOD="GET" DEST="?start=$next_ez&action=delete#DEL">
次の $page_max 件の記事
EON
    }
    $next_dele .= <<'EON';
<CE LABEL="戻る" TASK="GO" DEST="?start=0">記事一覧に戻る
EON

    $buffer = <<"EOB";
<HDML VERSION="3.0" TTL="30">
<ACTION LABEL="中止" TYPE="SOFT1" TASK="PREV">
<ENTRY NAME="PASS" KEY="p" FORMAT="M*M" DEFAULT="" NOECHO="TRUE">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#DEL">
削除パス:<BR></ENTRY>
<CHOICE NAME="DEL">
次から削除する記事を選んでください<BR>
EOB
}

sub delete_ez_body {
    my ($line) = @_;
    my $line_number = $_;

    unless ($line) {
        $buffer .= <<'EOB';
<CENTER>削除する投稿はありません<BR>
<CE TASK="GO" DEST="?start=0" LABEL="戻る">記事一覧に戻る
EOB
        return;
    }

    my ($subject, $name, $mail, $web, $message, $date, $host,
                    $addr, $agent, $pass, $unkey) = split("\t", $line);
    chomp $unkey;
    $date = &conv_date_imode($date);
    
    $message = &conv_imchr($message);
    $subject = &conv_imchr($subject);
    $name = &conv_imchr($name);

    $message = &conv_jschr($message);
    $subject = &conv_jschr($subject);
    $name = &conv_jschr($name);

    $buffer .= <<"EOB";
<CE LABEL="削除確認" TASK="GO" DEST="?action=certify&key=$unkey&pass=\$p">
$date $subject $name
EOB
}

sub delete_ez_foot {
    $buffer .= <<"EOB";
$next_dele</CHOICE>
EOB
    &$output_buffer;
}

sub delete_ez {
    $view_head = 'delete_ez_head';
    $view_body = 'delete_ez_body';
    $view_foot = 'delete_ez_foot';
    &view;
}

sub certify_ez_body {
    require $ir_i_def_pl if ($imchr_title);
    &file_lock("$bbs_data_file");
    &make_new() unless (-e "$bbs_data_file");
    open FHI, "$bbs_data_file" || &bdf_error("ファイルが開けません");
    @mes = <FHI>;
    close FHI;
    &file_unlock("$bbs_data_file");
    $data = "";
    unless ($#mes < 0) {
        foreach (@mes) {
            my ($num, $pass) = &get_delete_key_pass($_);
            if ($num eq $FORM{'key'}) {
                $data = $_;
                last;
            }
        }
    }
    &error("記事が見つかりませんでした") if ($data eq "");
    my ($subject, $name, $mail, $web, $message, $date, $host,
                    $addr, $agent, $pass, $unkey) = split("\t", $data);
    $pass = $FORM{'pass'};
    chomp $unkey;
    $date = &conv_date_imode($date);
    
    $message = &conv_imchr($message);
    $subject = &conv_imchr($subject);
    $name = &conv_imchr($name);

    $message = &conv_jschr($message);
    $subject = &conv_jschr($subject);
    $name = &conv_jschr($name);

    $buffer = <<"EOB";
<HDML VERSION="3.0" TTL="0">
<DISPLAY NAME="CERTIFY">
<ACTION LABEL="中止" TYPE="SOFT1" TASK="PREV">
<ACTION LABEL="了解" TYPE="ACCEPT" TASK="GO" DEST="$bbs_local" METHOD="POST" POSTDATA="action=remove&remove=$unkey&pass=$pass">
次の投稿記事を削除しますがよろしいですか？<BR>
$date<BR>
$subject<BR>
<CENTER>$name<BR>
$message<BR><BR>
</DISPLAY>
EOB
    &$output_buffer;
    exit;
}

sub select_ez_head {
    my ($arg) = @_;
    require $ir_i_def_pl if ($imchr_title);
    $end_mes = 0;
    if ($arg) {
        $next_ez = $start + $page_max;
        if ($arg <= $page_max + $start) {
            $next_ez = $arg - 1;
            $end_mes = 1;
        }
    } else {
        $next_ez = 0;
    }
    $next_dele = "";
    unless ($end_mes) {
        $next_dele = <<"EON";
<CE LABEL="次" TASK="GO" METHOD="GET" DEST="?start=$next_ez&action=select#SEL">
次の $page_max 件の記事
EON
    }
    $next_dele .= <<'EON';
<CE LABEL="戻る" TASK="GO" DEST="?start=0">記事一覧に戻る
EON

    $buffer = <<"EOB";
<HDML VERSION="3.0" TTL="30">
<ACTION LABEL="中止" TYPE="SOFT1" TASK="PREV">
<ENTRY NAME="PASS" KEY="p" FORMAT="M*M" DEFAULT="" NOECHO="TRUE">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#SEL">
削除パス:<BR></ENTRY>
<CHOICE NAME="SEL">
次から修正する記事を選んでください<BR>
EOB
}

sub select_ez_body {
    my ($line) = @_;
    my $line_number = $_;

    unless ($line) {
        $buffer .= <<'EOB';
<CENTER>修正する投稿はありません<BR>
<CE TASK="GO" DEST="?start=0" LABEL="戻る">記事一覧に戻る
EOB
        return;
    }

    my ($subject, $name, $mail, $web, $message, $date, $host,
                    $addr, $agent, $pass, $unkey) = split("\t", $line);
    chomp $unkey;
    $date = &conv_date_imode($date);
    
    $message = &conv_imchr($message);
    $subject = &conv_imchr($subject);
    $name = &conv_imchr($name);

    $message = &conv_jschr($message);
    $subject = &conv_jschr($subject);
    $name = &conv_jschr($name);

    $buffer .= <<"EOB";
<CE LABEL="修正開始" TASK="GO" DEST="?action=modify&mod=$unkey&pass=\$p">
$date $subject $name
EOB
}

sub select_ez_foot {
    &delete_ez_foot();
}

sub select_ez {
    $view_head = 'select_ez_head';
    $view_body = 'select_ez_body';
    $view_foot = 'select_ez_foot';
    &view;
}

sub modify_ez {
    my ($subject, $name, $email, $web, $message, $pass, $num) = &modify();
    $message =~ s/<br>/\n/gi;
    map {
        s/\&/\&amp;/g;
        s/\"/\&quot;/g; # "
        s/>/\&gt;/g;
        s/</\&lt;/g;
    } ($subject, $name, $message);
    my $postdata = 'action=modify&name=$(nm)&email=$(ma)&subject=$(sb)';
    $postdata .= '&message=$(ms)&pnew=$(pw)&mod=' . $num . '&pass=' . $pass;
    &wri_mod_body($name, $email, $subject, $message, $pass, '修正', $postdata);
    exit;
}

sub wri_mod_body {
    my($name, $email, $subject, $message, $pass, $word, $post) = @_;

    $buffer = <<"EOB";
<HDML VERSION="3.0"><ACTION LABEL="中止" TYPE="SOFT1" TASK="PREV">
<DISPLAY NAME="WRITE">
<ACTION TYPE="ACCEPT" LABEL="開始" TASK="GO" DEST="#NAME">
$wordを開始します。よろしければ「開始」を選んで下さい。<BR>
いったん回線を切っても結構\です。</DISPLAY>
<ENTRY NAME="NAME" KEY="nm" FORMAT="M*M" DEFAULT="$name">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#MAIL">
名前:<BR></ENTRY>
<ENTRY NAME="MAIL" KEY="ma" FORMAT="*x" DEFAULT="$email">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#SUBJ">
E-mail:<BR></ENTRY>
<ENTRY NAME="SUBJ" KEY="sb" FORMAT="*M" DEFAULT="$subject">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#MESG">
題名:<BR></ENTRY>
<ENTRY NAME="MESG" KEY="ms" FORMAT="M*M" DEFAULT="$message">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#PASS">
本文:<BR></ENTRY>
<ENTRY NAME="PASS" KEY="pw" FORMAT="mmmm*m" DEFAULT="$pass" NOECHO="TRUE">
<ACTION TYPE="ACCEPT" LABEL="記入" TASK="GO" METHOD="POST" POSTDATA="$post" DEST="$bbs_local"$sendRef ACCEPT-CHARSET="shift-jis">
削除パス(削除する時に使います):<BR></ENTRY>
EOB
    &$output_buffer;
}

sub error_ez {
    my ($s) = @_;
    
    $buffer = <<"EOB";
<HDML VERSION="3.0" TTL="64800"><DISPLAY NAME="TOP">
<ACTION TYPE="ACCEPT" LABEL="戻る" TASK="PREV">
<CENTER><IMG ICON="pushpin">$ezweb_title<IMG ICON="pushpin"><BR>
<CENTER>$version<BR><BR>
<IMG ICON="stopsign">$s<BR>
</DISPLAY>
EOB
    &$output_buffer;
}

sub search_body_ez {
    my ($mlog, $mlogic, $next_deck);
    $mlog = '&mode=log' if ($FORM{'mode'} =~ /^log$/i);

    if ($term_logic_enabled) {
        $mlogic =<<'EOM';
<CHOICE NAME="CLGC" KEY="lgc" IDEFAULT="1">
<ACTION TYPE="ACCEPT" TASK="GO" DEST="#SEND">
<CE VALUE="and">AND
<CE VALUE="or">OR
</CHOICE>
EOM
    }
    $next_deck = ($term_logic_enabled)? '#CLGC' : '#SEND';
    $buffer = <<"EOB";
<HDML VERSION="3.0"><DISPLAY NAME="SETMKEY">
<ACTION TYPE="SOFT1" LABEL="戻る" TASK="PREV">
<ACTION TYPE="ACCEPT" LABEL="記入" TASK="GO" DEST="#ENT">
<CENTER><IMG ICON="pushpin">$ezweb_title<IMG ICON="pushpin"><BR>
<CENTER>$version<BR><BR><IMG ICON="magnifyglass">記事の検索<BR>
検索語句を記入します。「記入」を選んで下さい。<BR></DISPLAY>
<ENTRY NAME="ENT" KEY="str" FORMAT="M*M" DEFAULT="">
<ACTION LABEL="開始" TYPE="ACCEPT" TASK="GO" VARS="lgc=and" DEST="$next_deck">
検索語句:<BR></ENTRY>
$mlogic<NODISPLAY NAME="SEND">
<ACTION TYPE="ACCEPT" TASK="GO" DEST="$bbs_local" METHOD="POST" POSTDATA="q=\$(str)&l=\$(lgc)&start=0$mlog">
</NODISPLAY>
EOB
    &$output_buffer;
    exit;
}

sub search_ez_head {
    my ($arg, $data) = @_;
    &$view_head($arg);
#    &view_ez_head($arg);
}

sub search_ez_foot {
    &$output_buffer;
}


sub set_master_mode_ez {
    $buffer = <<"EOB";
<HDML VERSION="3.0" TTL="0"><DISPLAY NAME="SETMKEY">
<ACTION TYPE="SOFT1" LABEL="戻る" TASK="PREV">
<ACTION TYPE="ACCEPT" LABEL="開始" TASK="GO" DEST="#NEW1">
<CENTER><IMG ICON="pushpin">$ezweb_title<IMG ICON="pushpin"><BR>
<CENTER>$version<BR><BR><IMG ICON="lockkey">マスターキー設定<BR>
マスターキーの設定を開始します。「開始」を選んで下さい。<BR></DISPLAY>
<ENTRY NAME="NEW1" KEY="p1" FORMAT="mmmm*m" DEFAULT="" NOECHO="TRUE">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#NEW2">
新パスワード:<BR></ENTRY>
<ENTRY NAME="NEW2" KEY="p2" FORMAT="mmmm*m" DEFAULT="" NOECHO="TRUE">
<ACTION LABEL="設定" TYPE="ACCEPT" TASK="GO" DEST="$bbs_local" METHOD="POST" POSTDATA="action=set_master&authorize=$COOKIE{'authorize'}&new1=\$(p1)&new2=\$(p2)">
新パスワード:<BR>(確認のためもう一度入力してください)<BR></ENTRY>
EOB
    &$output_buffer;
    exit;
}

sub set_init_mode_ez {
    local ($title, $email_admin, $envimgpath, $email_send);
    local ($sendmail, $email_to, $email_from, $email_subj);
    local ($bbs_url);
    
    my ($def_pass) = $FORM{'new1'} if ($FORM{'action'} eq 'set_master');

    $init_exist = &load_init($init_file);
    my ($email_send_on, $email_send_off);

    $email_send_on = ($email_send == 1)? 'checked' : '';
    $email_send_off = ($email_send == 0)? 'checked' : '';

    my $bbs_admin = $bbs_local . '?action=ch_master' .
                    '&authorize=' . $COOKIE{'authorize'};
    my $scr_path = 'http://' . $ENV{'SERVER_NAME'} . $ENV{'SCRIPT_NAME'};
    $bbs_url = $scr_path
        if ($bbs_url =~ /^\s*$/);

    my $postdata = 'action=set_init&authorize=' . $COOKIE{'authorize'} . '&title=$(bt)&email_admin=$(am)&bbs_url=$(bu)&env_img_path=$(ip)&email_send=$(pn)&sendmail=$(sm)&email_from=$(fm)&email_to=$(tm)&email_subj=$(sj)';

    $buffer = <<"EOB";
<HDML VERSION="3.0"><ACTION LABEL="中止" TYPE="SOFT1" TASK="PREV">
<DISPLAY NAME="INIT">
<ACTION TYPE="ACCEPT" LABEL="開始" TASK="GO" DEST="#TITLE">
設定を開始します。よろしければ「開始」を選んで下さい。<BR>
いったん回線を切っても結構\です。</DISPLAY>
<ENTRY NAME="TITLE" KEY="bt" FORMAT="M*M" DEFAULT="$title">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#MAIL">
掲示板タイトル:<BR></ENTRY>
<ENTRY NAME="MAIL" KEY="am" FORMAT="*x" DEFAULT="$email_admin">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#URL">
管理者メールアドレス:<BR></ENTRY>
<ENTRY NAME="URL" KEY="bu" FORMAT="*x" DEFAULT="$bbs_url">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#PATH">
掲示板URL(絶対パス):<BR></ENTRY>
<ENTRY NAME="PATH" KEY="ip" FORMAT="*M" DEFAULT="$envimgpath">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#NOTIFY">
画像へのパス:<BR></ENTRY>
<CHOICE NAME="NOTIFY" KEY="pn" DEFAULT="$email_send">
投稿通知:
<CE VALUE="1" LABEL="選択" TASK="GO" DEST="#SENDMAIL">する
<CE VALUE="0" LABEL="選択" TASK="GO" DEST="#SET">しない
</CHOICE>
<ENTRY NAME="SENDMAIL" KEY="sm" FORMAT="*M" DEFAULT="$sendmail">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#FROM">
sendmail:<BR></ENTRY>
<ENTRY NAME="FROM" KEY="fm" FORMAT="*x" DEFAULT="$email_from">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#TO">
宛先:<BR></ENTRY>
<ENTRY NAME="TO" KEY="tm" FORMAT="*x" DEFAULT="$email_to">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#SUBJECT">
送信者:<BR></ENTRY>
<ENTRY NAME="SUBJECT" KEY="sj" FORMAT="M*M" DEFAULT="$email_subj">
<ACTION TYPE="ACCEPT" LABEL="次へ" TASK="GO" DEST="#SET">
題名:<BR></ENTRY>
<DISPLAY NAME="SET">
<ACTION TYPE="ACCEPT" LABEL="設定" TASK="GO" METHOD="POST" POSTDATA="$postdata" DEST="$bbs_local"$sendRef ACCEPT-CHARSET="shift-jis">
設定を書き込みます。よろしければ「設定」を選んで下さい。</DISPLAY>
EOB
    &$output_buffer;
    exit;
}

sub authorize_ez {
    my ($msg) = @_;
    $buffer = <<"EOB";
<HDML VERSION="3.0" TTL="0"><ACTION LABEL="中止" TYPE="SOFT1" TASK="PREV">
<ENTRY NAME="AUTHORIZE" KEY="at" FORMAT="mmmm*m" DEFAULT="" NOECHO="TRUE">
<ACTION TYPE="ACCEPT" LABEL="実行" TASK="GO" METHOD="POST" POSTDATA="action=authorize&next_act=$FORM{'next_act'}&next_start=$FORM{'next_start'}&pass=\$(at)" DEST="$bbs_local"$sendRef ACCEPT-CHARSET="shift-jis">
$msg<BR>
パスワード認証<BR>
パスワード:<BR></ENTRY>
EOB
    &$output_buffer;
    exit;
}

sub output_buffer_ez {
    my ($header, $footer);
    $header =<<"EOH";
Content-Type: text/x-hdml;charset=Shift_JIS

EOH

    $footer =<<"EOF";
</HDML>
EOF
    &subst_secure if ($limit_mode);

    print "$header";
    print "$buffer";
    print "$footer";

}

1;
