<?php
//===================初期設定=====================
//時間の取得
$now = date("Y/m/d H:i:s");
$data_file = "./g_bbs.log"; //データファイル名
$data_max = 100; //データ最大記録数
$page_view = 10; //1ページの記事表示件数
$homegif = "./home.gif"; //ホームページへのリンク用画像
$passwd = "777"; //管理者用パスワード
$up_dir = '/img/';
$w_max = 200; //画像の横幅の最大値(ピクセル)
$h_max = 200; //画像の縦幅の最大値(ピクセル)
$hensin_order = 1; //返信記事の表示順序。昇順なら1、降順なら0。
//================================================

//スーパーグローバル変数対策
if(!isset($PATH_TRANSLATED)){
    
$path = dirname($_SERVER["PATH_TRANSLATED"]).$up_dir;
}else{
    
$path = dirname($PATH_TRANSLATED).$up_dir;
}
if(!isset(
$PHP_SELF)){ $PHP_SELF = $_SERVER["PHP_SELF"]; }
if(!isset(
$flags)){ $flags = $_POST['flags']; }
if(!isset(
$re_sub)){ $re_sub = $_POST['re_sub']; }
if(!isset(
$code)){ $code = $_POST['code']; }
if(!isset(
$action)){ $action = $_POST['action']; }
if(!isset(
$delcode)){ $delcode = $_POST['delcode']; }
if(!isset(
$password)){ $password = $_POST['password']; }
if(!isset(
$ress)){ $ress = $_POST['ress']; }
if(!isset(
$name)){ $name = $_POST['name']; }
if(!isset(
$email)){ $email = $_POST['email']; }
if(!isset(
$hp)){ $hp = $_POST['hp']; }
if(!isset(
$subject)){ $subject = $_POST['subject']; }
if(!isset(
$scolor)){ $scolor = $_POST['scolor']; }
if(!isset(
$comment)){ $comment = $_POST['comment']; }
if(!isset(
$tag)){ $tag = $_POST['tag']; }
if(!isset(
$pass)){ $pass = $_POST['pass']; }
if(!isset(
$upfile)){ $upfile = $_FILES['upfile']['tmp_name']; }
if(!isset(
$upfile_name)){ $upfile_name = $_FILES['upfile']['name']; }
if(!isset(
$upfile2)){ $upfile2 = $_FILES['upfile2']['tmp_name']; }
if(!isset(
$upfile2_name)){ $upfile2_name = $_FILES['upfile2']['name']; }
if(!isset(
$upfile3)){ $upfile3 = $_FILES['upfile3']['tmp_name']; }
if(!isset(
$upfile3_name)){ $upfile3_name = $_FILES['upfile3']['name']; }
if(!isset(
$pline)){ $pline = $_POST['pline']; }
//エスケープ記号対策
$name = stripslashes($name);
$subject = stripslashes($subject);
$comment = stripslashes($comment);
?>

<HTML>
<HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=x-sjis">
    <TITLE>画像掲示板</TITLE>
    <STYLE TYPE="text/css">
    <!--
    :link     {
            Color : blue ;
            Text-Decoration : None
        }
    :active     {
            Color : blue ;
            Text-Decoration : None
        }
    :visited     {
            Color : blue ;
            Text-Decoration : None
        }
    A:hover     {
            Color : blue ;
            Text-Decoration : Underline
        }
    -->
    </STYLE>
</HEAD>
<BODY BGCOLOR="#ffffee">
<FORM ACTION="<?php echo $PHP_SELF; ?>" METHOD="POST" ENCTYPE="multipart/form-data">
<P><INPUT TYPE="HIDDEN" NAME="action" SIZE="-1" VALUE="regist"></P>
<P ALIGN="CENTER"><IMG SRC="title.gif" WIDTH="300" HEIGHT="60" ALIGN="BOTTOM" BORDER="0"></P>
<P ALIGN="CENTER"><FONT SIZE="2" COLOR="red">お名前とコメントは必ず書き込んで下さい。エラーになります。記事の最大記録数は<?php echo $data_max; ?>件です。</FONT></P>
<BLOCKQUOTE>
    <P>
    <TABLE BORDER="0" WIDTH="88%">
        <TR>
            <TD WIDTH="12%" ALIGN="RIGHT">
                <P ALIGN="RIGHT">お名前:
            </TD>
            <TD><INPUT TYPE="TEXT" NAME="name" SIZE="15"></TD>
        </TR>
        <TR>
            <TD WIDTH="12%" ALIGN="RIGHT">
                <P ALIGN="RIGHT">E-mail:
            </TD>
            <TD COLSPAN="3"><INPUT TYPE="TEXT" NAME="email" SIZE="25"></TD>
        </TR>
        <TR>
            <TD WIDTH="12%" ALIGN="RIGHT">
                <P ALIGN="RIGHT">HomePage:
            </TD>
            <TD><INPUT TYPE="TEXT" NAME="hp" SIZE="40"></TD>
        </TR>
        <TR>
            <TD WIDTH="12%">
                <P ALIGN="RIGHT">削除キー:
            </TD>
            <TD><INPUT TYPE="PASSWORD" NAME="pass" SIZE="7"><FONT SIZE="2" COLOR="#CC0000"> *半角英数4文字以上推奨。削除キーを設定すると、いつでもご自分の記事を削除できます。</FONT></TD>
        </TR>
        <TR>
            <TD WIDTH="12%" ALIGN="RIGHT">
                <P ALIGN="RIGHT">題目:
            </TD>
            <TD><INPUT TYPE="TEXT" NAME="subject" SIZE="40"> 題目色:<INPUT TYPE="RADIO" NAME="scolor" VALUE="blue" checked><B><FONT COLOR="blue">青</FONT></B> <INPUT
                TYPE="RADIO" NAME="scolor" VALUE="red"><B><FONT COLOR="red">赤</FONT></B> <INPUT TYPE="RADIO" NAME="scolor" VALUE="green"><B><FONT
                COLOR="green">緑</FONT></B> <INPUT TYPE="RADIO" NAME="scolor" VALUE="#996600"><B><FONT COLOR="#996600">茶</FONT></B> <INPUT
                TYPE="RADIO" NAME="scolor" VALUE="#660099"><B><FONT COLOR="#660099">紫</FONT></B></TD>
        </TR>
        <TR>
            <TD WIDTH="12%" ALIGN="RIGHT">
                <P ALIGN="RIGHT">コメント:
            </TD>
            <TD><TEXTAREA NAME="comment" ROWS="4" COLS="60"></TEXTAREA> <INPUT TYPE="CHECKBOX" NAME="tag" VALUE="1">タグ有効</TD>
        </TR>
        <TR>
            <TD WIDTH="12%" ALIGN="RIGHT">
                <P ALIGN="RIGHT">添付画像:
            </TD>
            <TD>1.<INPUT TYPE="file" NAME="upfile" SIZE="35"><FONT SIZE="2" COLOR="#CC0000"> *GIF、JPG、PNG画像のみ有効。H画像はもちろん禁止!</FONT><BR>2.<INPUT TYPE="file" NAME="upfile2" SIZE="35"><BR>3.<INPUT TYPE="file" NAME="upfile3" SIZE="35"></TD>
        </TR>
        <TR>
            <TD WIDTH="12%">&nbsp;</TD>
            <TD>
<?php
if ($flags == 'return') {
    print
"<input type=submit value=[" . $re_sub . "]に返信>\n";
    print
"<input type=hidden name=ress value=$code>\n";
} else {
    print
"<INPUT TYPE=SUBMIT VALUE=書き込み/更新> <INPUT TYPE=RESET VALUE=リセット>\n";
}
?>
</TD>
        </TR></TABLE>
</FORM>

<?php
//===============データの削除==================
if ($action == "delete") {
    if((
$delcode != "") && ($password != "")){
        
$delfile = file($data_file);
        
$fp = fopen($data_file, "w");
        for(
$i=0; $i<sizeof($delfile); $i++){
            list(
$dcode,$dress,$dname,$demail,$dhp,$dsubject,$dscolor,$dcomment,$dfname,$dfname2,$dfname3,$dpass,$dnow,$dhost,$dagent) = split( ",", $delfile[$i]);
            if ((
$password == $dpass) || ($password == $passwd)) {
                if (
$delcode == $dcode) {
                    
$delfile[$i] = "";
                    if(
$dfname){ unlink(".".$up_dir.$dfname); }
                    if(
$dfname2){ unlink(".".$up_dir.$dfname2); }
                    if(
$dfname3){ unlink(".".$up_dir.$dfname3); }
                }
            }
            
fputs($fp,$delfile[$i]);
        }
        
fclose($fp);
        unset(
$delfile);
    }
}
//===============インライン関数===================
function inline_link($link){
    
$link = ereg_replace("(https?|ftp|news)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)","<a href=\"\\1\\2\" target=\"_blank\">\\1\\2</a>",$link);
    return
$link;
}
//===============データの書き込み=================
if($action == "regist"){
    if((
$name != "") && ($comment != "")){
        
$code = time(); //アクセス時の秒数
        //ホスト名を取得
        
$host = getenv("REMOTE_HOST");
        
$addr = getenv("REMOTE_ADDR");
        if(
$host == "" || $host == $addr){
            
$host = gethostbyaddr($addr);
        }
        
//訪問者のブラウザを取得
        
$agent = getenv("HTTP_USER_AGENT");
        
//ここから書き込みデータの調整
        
$name = htmlspecialchars($name); //特殊文字のHTMLエントリへの変換
        
$email = htmlspecialchars($email);
        
$hp = htmlspecialchars($hp);
        
$subject = htmlspecialchars($subject);
        if(!
$tag){
            
$comment = htmlspecialchars($comment);
        }
        
$comment = nl2br($comment); //HTML改行文字の挿入
        
$comment = str_replace("\r", "", $comment); //文字列の置換
        
$comment = str_replace("\n", "", $comment);
        
//ログファイルの区切文字(",")と区別するために文字コード(&#44)に書き換える。
        
$ress = str_replace(",", "&#44;",$ress);
        
$name = str_replace(",", "&#44;",$name);
        
$email = str_replace(",", "&#44",$email);
        
$hp = str_replace(",", "&#44",$hp);
        
$subject = str_replace(",", "&#44;",$subject);
        
$comment = str_replace(",", "&#44;",$comment);
        
//インラインリンクを実現(URLのみ)
        
$comment = inline_link($comment);
        
$message = file($data_file);
        
//画像のアップロード処理
        
if(is_uploaded_file($upfile)){
            
$imagesize = getimagesize($upfile); //画像の属性を取得
            
switch($imagesize[2]){
                case
1:
                    
$out = $code . ".gif";
                    break;
                case
2:
                    
$out = $code . ".jpg";
                    break;
                case
3:
                    
$out = $code . ".png";
                    break;
                default:
                    
unlink($upfile);
            }
            if(
$out){
                
$sendpath = $path.$out;
                if(
move_uploaded_file($upfile, $sendpath)){
                    
chmod($sendpath,0666);
                    
$fname = $out;
                }
            }
        }
        if(
is_uploaded_file($upfile2)){
            
$imagesize = getimagesize($upfile2); //画像の属性を取得
            
switch($imagesize[2]){
                case
1:
                    
$out = $code . "_2.gif";
                    break;
                case
2:
                    
$out = $code . "_2.jpg";
                    break;
                case
3:
                    
$out = $code . "_2.png";
                    break;
                default:
                    
unlink($upfile2);
            }
            if(
$out){
                
$sendpath = $path.$out;
                if(
move_uploaded_file($upfile2, $sendpath)){
                    
chmod($sendpath,0666);
                    
$fname2 = $out;
                }
            }
        }
        if(
is_uploaded_file($upfile3)){
            
$imagesize = getimagesize($upfile3); //画像の属性を取得
            
switch($imagesize[2]){
                case
1:
                    
$out = $code . "_3.gif";
                    break;
                case
2:
                    
$out = $code . "_3.jpg";
                    break;
                case
3:
                    
$out = $code . "_3.png";
                    break;
                default:
                    
unlink($upfile3);
            }
            if(
$out){
                
$sendpath = $path.$out;
                if(
move_uploaded_file($upfile3, $sendpath)){
                    
chmod($sendpath,0666);
                    
$fname3 = $out;
                }
            }
        }
        
//ログファイルの区切文字(",")と区別するために文字コード(&#44)に書き換え。
        
$fname = str_replace(",", "&#44;",$fname);
        
$fname2 = str_replace(",", "&#44;",$fname2);
        
$fname3 = str_replace(",", "&#44;",$fname3);
        
//配列要素を文字列により連結
        
$input_msg = implode(",", array($code,$ress,$name,$email,$hp,$subject,$scolor,$comment,$fname,$fname2,$fname3,$pass,$now,$host,$agent));
        
$fp = fopen($data_file, "w");
        
rewind($fp);
        
fputs($fp, "$input_msg\n");
        
//最大記録数の調整
        
if(($data_max * 1.2) < sizeof($message)){
            
$msg_num = $data_max - 1;
        }else{
            
$msg_num = sizeof($message);
        }
        for(
$i = 0; $i < $msg_num; $i++){
            
fputs($fp, $message[$i]);
        }
        
fclose($fp);
        unset(
$message);
        echo
"<META HTTP-EQUIV=refresh CONTENT=0;URL=$PHP_SELF>\n";
    }
}
//親記事だけを配列に抜き出す
$message = file($data_file);
for(
$i=0; $i<sizeof($message); $i++){
    list(
$rcode,$rress,$rname,$remail,$rhp,$rsubject,$rscolor,$rcomment,$rfname,$rfname2,$rfname3,$rpass,$rnow,$rhost,$ragent) = split( ",", $message[$i]);
    if(
$rress == ""){
        
$PARENT[] = $message[$i];
    }
}
//==================HTML表示======================
//1ページ当たりの表示件数の調整
$msg_count = count($PARENT); //親記事の行数をカウント
if($pline == "")
    
$p_line = 0;
else
    
$p_line = $pline;
$end_data = $msg_count - 1;
$page_end = $p_line + ($page_view - 1);
if(
$page_end >= $end_data)
    
$page_end = $end_data;
for(
$i=$p_line; $i<=$page_end; $i++){
    list(
$code2,$ress2,$name2,$email2,$hp2,$subject2,$scolor2,$comment2,$fname2,$fname2_2,$fname2_3,$pass2,$now2,$host2,$agent2) = split(",", $PARENT[$i]);
    
//親記事の表示
    
echo "<table border=1 bordercolor='green' width=88%>\n";
    echo
"<tr><td>\n";
    echo
"<form method=POST action=$PHP_SELF>\n";
    echo
"<input type=checkbox name=delcode value=$code2>\n";
    echo
"<font size=4 color=$scolor2><b>$subject2</b></font>\n";
    if(
$email2 != ""){
        echo
" <a href=mailto:$email2 onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='blue'\"><b>$name2</b></a>\n";
    }else{
        echo
" <b>$name2</b>\n";
    }
    if(
$hp2 != ""){
        echo
" <a href=$hp2 target=_top><img src=$homegif border=0></a>\n";
    }
    echo
" <font size=2 color='green'>$now2</font>\n";
    echo
"<input type=hidden name=action value=delete>\n";
    echo
"<font size=2>削除キー:</font><input type=password size=7 name=password>\n";
    echo
"<input type=submit value=削除><br>\n";
    echo
"</form><blockquote>\n";
    echo
"<table border=0>\n";
    echo
"<tr><td>\n";
    if(
$fname2 && file_exists("$path$fname2")){
        
$size = getimagesize("$path$fname2");
        
$img_w=$size[0];
        
$img_h=$size[1];
        if(
$img_w > $w_max || $img_h > $h_max){
            
$w_ritu = $w_max / $img_w;
            
$h_ritu = $h_max / $img_h;
            (
$w_ritu < $h_ritu) ? $key = $w_ritu : $key = $h_ritu;
            
$width = (int) $img_w * $key;
            
$height = (int) $img_h * $key;
            echo
"<A HREF=.$up_dir$fname2 TARGET=_blank><img src=.$up_dir$fname2 WIDTH=" . $width . " HEIGHT=" . $height . "></A>";
        }else{
            echo
"<img src=.$up_dir$fname2>";
        }
    }
    if(
$fname2_2 && file_exists("$path$fname2_2")){
        
$size = getimagesize("$path$fname2_2");
        
$img_w=$size[0];
        
$img_h=$size[1];
        if(
$img_w > $w_max || $img_h > $h_max){
            
$w_ritu = $w_max / $img_w;
            
$h_ritu = $h_max / $img_h;
            (
$w_ritu < $h_ritu) ? $key = $w_ritu : $key = $h_ritu;
            
$width = (int) $img_w * $key;
            
$height = (int) $img_h * $key;
            echo
" <A HREF=.$up_dir$fname2_2 TARGET=_blank><img src=.$up_dir$fname2_2 WIDTH=" . $width . " HEIGHT=" . $height . "></A>";
        }else{
            echo
" <img src=.$up_dir$fname2_2>";
        }
    }
    if(
$fname2_3 && file_exists("$path$fname2_3")){
        
$size = getimagesize("$path$fname2_3");
        
$img_w=$size[0];
        
$img_h=$size[1];
        if(
$img_w > $w_max || $img_h > $h_max){
            
$w_ritu = $w_max / $img_w;
            
$h_ritu = $h_max / $img_h;
            (
$w_ritu < $h_ritu) ? $key = $w_ritu : $key = $h_ritu;
            
$width = (int) $img_w * $key;
            
$height = (int) $img_h * $key;
            echo
" <A HREF=.$up_dir$fname2_3 TARGET=_blank><img src=.$up_dir$fname2_3 WIDTH=" . $width . " HEIGHT=" . $height . "></A>";
        }else{
            echo
" <img src=.$up_dir$fname2_3>";
        }
    }
    echo
"<P>$comment2\n";
    echo
"</td></tr></table>\n";
    echo
"<form method=POST action=$PHP_SELF>\n";
    echo
"<input type=submit value=返信>\n";
    echo
"<input type=hidden name=code value=" . $code2 . ">\n";
    echo
"<input type=hidden name=re_sub value=" . $subject2 . ">\n";
    echo
"<input type=hidden name=flags value=return>\n";
    echo
"<font size=2>[$host2] $agent2</font>\n";
    echo
"</form></blockquote>\n";
    
//返信記事の表示
    
if($hensin_order){
            
$max_data = count($message) - 1;
            for(
$j=$max_data; $j>=0; $j--){
            list(
$code3,$ress3,$name3,$email3,$hp3,$subject3,$scolor3,$comment3,$fname3,$fname3_2,$fname3_3,$pass3,$now3,$host3,$agent3) = split(",", $message[$j]);
            if (
$code2 == $ress3) {
                echo
"<blockquote>\n";
                echo
"<form method=POST action=$PHP_SELF>\n";
                echo
"<input type=checkbox name=delcode value=$code3>\n";
                echo
"RE:<font color=$scolor3><b>$subject3</b></font>\n";
                if (
$email3 != "") {
                    echo
" <a href=mailto:$email3 onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='blue'\"><strong>$name3</strong></a>\n";
                }else{
                    echo
" <strong>$name3</strong>\n";
                }
                if(
$hp3 != ""){
                    echo
" <a href=$hp3 target=_top><img src=$homegif border=0></a>\n";
                }
                echo
" <font size=2 color='green'>$now3</font>\n";
                echo
"<input type=hidden name=action value=delete>\n";
                echo
"<font size=2>削除キー:</font><input type=password size=7 name=password>\n";
                echo
"<input type=submit value=削除><blockquote>\n";
                echo
"<table border=0>\n";
                echo
"<tr><td>\n";
                if(
$fname3 && file_exists("$path$fname3")){
                    
$size = getimagesize("$path$fname3");
                    
$img_w=$size[0];
                    
$img_h=$size[1];
                    if(
$img_w > $w_max || $img_h > $h_max){
                        
$w_ritu = $w_max / $img_w;
                        
$h_ritu = $h_max / $img_h;
                        (
$w_ritu < $h_ritu) ? $key = $w_ritu : $key = $h_ritu;
                        
$width = (int) $img_w * $key;
                        
$height = (int) $img_h * $key;
                        echo
"<A HREF=.$up_dir$fname3 TARGET=_blank><img src=.$up_dir$fname3 WIDTH=" . $width . " HEIGHT=" . $height . "></A>";
                    }else{
                        echo
"<img src=.$up_dir$fname3>";
                    }
                }
                if(
$fname3_2 && file_exists("$path$fname3_2")){
                    
$size = getimagesize("$path$fname3_2");
                    
$img_w=$size[0];
                    
$img_h=$size[1];
                    if(
$img_w > $w_max || $img_h > $h_max){
                        
$w_ritu = $w_max / $img_w;
                        
$h_ritu = $h_max / $img_h;
                        (
$w_ritu < $h_ritu) ? $key = $w_ritu : $key = $h_ritu;
                        
$width = (int) $img_w * $key;
                        
$height = (int) $img_h * $key;
                        echo
" <A HREF=.$up_dir$fname3_2 TARGET=_blank><img src=.$up_dir$fname3_2 WIDTH=" . $width . " HEIGHT=" . $height . "></A>";
                    }else{
                        echo
" <img src=.$up_dir$fname3_2>";
                    }
                }
                if(
$fname3_3 && file_exists("$path$fname3_3")){
                    
$size = getimagesize("$path$fname3_3");
                    
$img_w=$size[0];
                    
$img_h=$size[1];
                    if(
$img_w > $w_max || $img_h > $h_max){
                        
$w_ritu = $w_max / $img_w;
                        
$h_ritu = $h_max / $img_h;
                        (
$w_ritu < $h_ritu) ? $key = $w_ritu : $key = $h_ritu;
                        
$width = (int) $img_w * $key;
                        
$height = (int) $img_h * $key;
                        echo
" <A HREF=.$up_dir$fname3_3 TARGET=_blank><img src=.$up_dir$fname3_3 WIDTH=" . $width . " HEIGHT=" . $height . "></A>";
                    }else{
                        echo
" <img src=.$up_dir$fname3_3>";
                    }
                }
                echo
"<P>$comment3\n";
                echo
"</td></tr></table>\n";
                echo
"<font size=2>[$host3] $agent3</font></blockquote>\n";
                echo
"</form></blockquote>\n";
            }
        }
    }else{
        for(
$j=0; $j<sizeof($message); $j++){
            list(
$code3,$ress3,$name3,$email3,$hp3,$subject3,$scolor3,$comment3,$fname3,$fname3_2,$fname3_3,$pass3,$now3,$host3,$agent3) = split(",", $message[$j]);
            if (
$code2 == $ress3) {
                echo
"<blockquote>\n";
                echo
"<form method=POST action=$PHP_SELF>\n";
                echo
"<input type=checkbox name=delcode value=$code3>\n";
                echo
"RE:<font color=$scolor3><b>$subject3</b></font>\n";
                if (
$email3 != "") {
                    echo
" <a href=mailto:$email3 onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='blue'\"><strong>$name3</strong></a>\n";
                }else{
                    echo
" <strong>$name3</strong>\n";
                }
                if(
$hp3 != ""){
                    echo
" <a href=$hp3 target=_top><img src=$homegif border=0></a>\n";
                }
                echo
" <font size=2 color='green'>$now3</font>\n";
                echo
"<input type=hidden name=action value=delete>\n";
                echo
"<font size=2>削除キー:</font><input type=password size=7 name=password>\n";
                echo
"<input type=submit value=削除><blockquote>\n";
                echo
"<table border=0>\n";
                echo
"<tr><td>\n";
                if(
$fname3 && file_exists("$path$fname3")){
                    
$size = getimagesize("$path$fname3");
                    
$img_w=$size[0];
                    
$img_h=$size[1];
                    if(
$img_w > $w_max || $img_h > $h_max){
                        
$w_ritu = $w_max / $img_w;
                        
$h_ritu = $h_max / $img_h;
                        (
$w_ritu < $h_ritu) ? $key = $w_ritu : $key = $h_ritu;
                        
$width = (int) $img_w * $key;
                        
$height = (int) $img_h * $key;
                        echo
"<A HREF=.$up_dir$fname3 TARGET=_blank><img src=.$up_dir$fname3 WIDTH=" . $width . " HEIGHT=" . $height . "></A>";
                    }else{
                        echo
"<img src=.$up_dir$fname3>";
                    }
                }
                if(
$fname3_2 && file_exists("$path$fname3_2")){
                    
$size = getimagesize("$path$fname3_2");
                    
$img_w=$size[0];
                    
$img_h=$size[1];
                    if(
$img_w > $w_max || $img_h > $h_max){
                        
$w_ritu = $w_max / $img_w;
                        
$h_ritu = $h_max / $img_h;
                        (
$w_ritu < $h_ritu) ? $key = $w_ritu : $key = $h_ritu;
                        
$width = (int) $img_w * $key;
                        
$height = (int) $img_h * $key;
                        echo
" <A HREF=.$up_dir$fname3_2 TARGET=_blank><img src=.$up_dir$fname3_2 WIDTH=" . $width . " HEIGHT=" . $height . "></A>";
                    }else{
                        echo
" <img src=.$up_dir$fname3_2>";
                    }
                }
                if(
$fname3_3 && file_exists("$path$fname3_3")){
                    
$size = getimagesize("$path$fname3_3");
                    
$img_w=$size[0];
                    
$img_h=$size[1];
                    if(
$img_w > $w_max || $img_h > $h_max){
                        
$w_ritu = $w_max / $img_w;
                        
$h_ritu = $h_max / $img_h;
                        (
$w_ritu < $h_ritu) ? $key = $w_ritu : $key = $h_ritu;
                        
$width = (int) $img_w * $key;
                        
$height = (int) $img_h * $key;
                        echo
" <A HREF=.$up_dir$fname3_3 TARGET=_blank><img src=.$up_dir$fname3_3 WIDTH=" . $width . " HEIGHT=" . $height . "></A>";
                    }else{
                        echo
" <img src=.$up_dir$fname3_3>";
                    }
                }
                echo
"<P>$comment3\n";
                echo
"</td></tr></table>\n";
                echo
"<font size=2>[$host3] $agent3</font></blockquote>\n";
                echo
"</form></blockquote>\n";
            }
        }
    }
    echo
"</td></tr></table><br>\n";
}
unset(
$message);
?>

<P>
<TABLE BORDER="0" WIDTH="88%">
    <TR>
        <TD WIDTH="50%">

<?php
if($page_end >= $page_view){
    
$page_count = floor($page_end / $page_view);
    
$prev_line = ($page_count - 1) * $page_view;
    echo
"<form method=Post action=$PHP_SELF>\n";
    echo
"<input type=hidden name=pline value=$prev_line>\n";
    echo
"<input type=submit value=前のページ>\n";
    echo
"</form>\n";
}else{
    echo
"&nbsp;\n";
}
?>

        </TD>
        <TD WIDTH="50%"><P ALIGN="RIGHT">

<?php
$next_line
= $page_end + 1;
if(
$page_end != $end_data){
    echo
"<form method=Post action=$PHP_SELF>\n";
    echo
"<input type=hidden name=pline value=$next_line>\n";
    echo
"<input type=submit value=次のページ>\n";
    echo
"</form>\n";
}else{
    echo
"&nbsp;\n";
}
?>

        </TD>
    </TR>
</TABLE>
</BLOCKQUOTE>
<div align=right><font size=-1>Powered by <a href="http://www.komonet.ne.jp/" onMouseOver="this.style.color='red'" onMouseOut="this.style.color='blue'">KOMONET</a></font></div>
</BODY>
</HTML>