TEST

Age:
Human
Dog
Cat
Horse

©Okibi Lab.

(元記事はこのへん:id:owl:20060701;呼び出している script は http://hum.uah.jp/age.php


ソースはこれなんで、もし上掲サイト消失してたらどこか PHP の使えるサイトに貼って試してください。

<HTML>
<HEAD>
<META name="GENERATOR" content="WZ EDITOR Version 4.00E">
<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<META http-equiv="Content-Style-Type" content="text/css">
<TITLE>「猫で言うと○歳!」</TITLE>
</HEAD>
<BODY bgcolor="#ccbbc0">
<H2>どうぶつ年齢換算</H2>
<P><font color="#cc3399">PHP版(携帯対応)</font><BR>
<FONT color="#cc0000" size="-1">※注:諸説あるうちの一例です</FONT>
</P>

<?php

$x = true;
$s = "<font color='#0099cc'>";
$xh = "";  $sh = "<font>";
$xi = "";  $si = "<font>";
$xn = "";  $sn = "<font>";
$xu = "";  $su = "<font>";
$xr = "";  $sr = "<font>";

    $age = (float) $_GET['age'];
    if ($age <= 0) {
        $age = $_POST['age'];
        if ($_POST['age'] <= 0) {
            $age = 18; 
            $x = false;
        }
    }

    if       (($_POST['base'] == "i") || ($_GET['inu']) || ($_GET['dog'])) {
        $i = $age;
        $xi = "checked";
        $si = $s; 
        if     ($i < 1) { $h = 17 * $i; }
        else            { $h = 5 * $i + 12; }
    } elseif (($_POST['base'] == "n") || ($_GET['neko']) || ($_GET['cat'])) {
        $n = $age;
        $xn = "checked";
        $sn = $s; 
        if     ($n < 1) { $h = 18 * $n; }
        elseif ($n < 2) { $h = 6 * $n + 12; }
        else            { $h = 4 * $n + 16; }
    } elseif (($_POST['base'] == "u")  || ($_GET['uma']) || ($_GET['horse'])) {
        $u = $age;
        $xu = "checked";
        $su = $s; 
        if     ($u < 2) { $h = 6 * $u;}
        elseif ($u < 3) { $h = 5 * $u + 2; }
    } elseif (($_POST['base'] == "r")  || ($_GET['usagi']) || ($_GET['rabit'])) {
        $r = $age;
        $xr = "checked";
        $sr = $s; 
        if     ($r < 2 / 3 ) { $h = 27 * $r;}
        elseif ($r < 4 / 3 ) { $h = 9 * $r + 12; }
        else                 { $h = 6 * $r + 16; }
    } else {
        $h = $age;
        $xh = "checked";
        $sh = $s; 
    }

    if     ($h < 18) { $i = $h / 17; }
        else         { $i = ($h - 12) / 5; }

    if     ($h < 18) { $n = $h / 18; }
    elseif ($h < 24) { $n = ($h - 12) / 6; }
        else         { $n = ($h - 16) / 4; }

    if     ($h < 12) { $u = $h / 6; }
    elseif ($h < 17) { $u = ($h - 2) / 5; }
        else         { $u = ($h - 8) / 3; }

    if     ($h < 18) { $r = $h / 27; }
    elseif ($h < 24) { $r = ($h - 12) / 9; }
        else         { $r = ($h - 16) / 6; }



    if ($x) {
        print  ($sh);
        printf ("ひと:%1.1f歳 (%d歳%d月)<br>" , $h , $h , ($h - floor($h)) * 12 );
        print  ("</font>" . $si);
        printf ("いぬ:%1.1f歳 (%d歳%d月)<br>" , $i , $i , ($i - floor($i)) * 12 );
        print  ("</font>" . $sn);
        printf ("ねこ:%1.1f歳 (%d歳%d月)<br>" , $n , $n , ($n - floor($n)) * 12 );
        print  ("</font>" . $su);
        printf ("うま:%1.1f歳 (%d歳%d月)<br>" , $u , $u , ($u - floor($u)) * 12 );
        print  ("</font>" . $sr);
        printf ("うさ:%1.1f歳 (%d歳%d月)<br>" , $r , $r , ($r - floor($r)) * 12 );
        print  ("</font><HR>");
    }

?>

<FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
年齢:<INPUT size="5" type="text" name="age" tabindex="1" style="text-align : right;" istyle="4" mode="numeric" value="<?php echo $age; ?>"><BR>
  <input type="radio" name="base" value="h" accesskey="1" <?php echo $xh; ?> /> ひと<br>
  <input type="radio" name="base" value="i" accesskey="2" <?php echo $xi; ?> /> いぬ<br>
  <input type="radio" name="base" value="n" accesskey="3" <?php echo $xn; ?> /> ねこ<br>
  <input type="radio" name="base" value="u" accesskey="4" <?php echo $xu; ?> /> うま<br>
  <input type="radio" name="base" value="r" accesskey="5" <?php echo $xr; ?> /> うさぎ<br>
<INPUT type="submit" accesskey="#" tabindex="2" name="btn_calc" value=" CALC "> 
<INPUT type="reset" accesskey="*" name="btn_clr" value=" C ">
<BR>
</FORM>

<hr>
<P><IMG src="BBY_icn4.gif" width="32" height="32" border="0"> <A href="http://d.hatena.ne.jp/owl/20060701#age">
熾火研究所</A>謹製 <br>2006/07/09
</P>

<P><A href="http://hum.uah.jp/age.php"><IMG src="qr_age_php_uah.gif" height="87" width="87" border="0"></A>
 携帯でもOK
</P>
</BODY>
</HTML>


ついでに bmi.php も貼っておく。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 12.0.4.0 for Windows">
<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<META http-equiv="Content-Style-Type" content="text/css">
<TITLE>BMI CALCULATOR on PHP</TITLE>

<?php

//         2009/09/22 ver.1.0
//         2009/09/23 ver.1.1 こまごまと修正
//         2009/09/26 ver.2.0β -> 改良して 2.0 リリース(表生成)
//         2009/10/16 ver.2.1 Default で BMI表を表示
//         2009/10/18 ver.2.11 表記抜け修正


$cl00 = "#99ff99";
$cl0  = "#ccccff";
$cl1  = "#ccff99";
$cl2  = "#ffffcc";
$cl3  = "#ffcccc";

$ready_w = true;
$ready_h = true;

    function wt($bm,$ht)
    {
        $ww = $bm * $ht * $ht / 10000;
        return $ww;
    }


    $w = (float) $_GET['w'] + (float) $_GET['weight'];
    if ($w <= 0) {
        $w = $_POST['form_weight'];
        if ($w <= 0) {
            $w = 60.0; 
            $ready_w = false;
        }
    }

    $h = (float) $_GET['h'] + (float) $_GET['height'];
    if ($h <= 0) {
        $h = $_POST['form_height'];
        if ($h <= 0) {
            $h = 165.0; 
            $ready_h = false;
        }
    }

    $b = (float) $_GET['b'] +  (float) $_GET['bmi'] +  (float) $_GET['BMI'];
    if ($b <= 0) {
        $b = $_POST['form_BMI'];
        if ($b <= 0) {
            $b = 22.0; 
        }
    }

    if           (($ready_h) && ($ready_w)) { $b = round($w / $h / $h * 10000 , 1); 
        } elseif  ($ready_h)                { $w = round($b * $h * $h / 10000 , 1);
        } elseif                ($ready_w)  { $h = round(sqrt($w / $b) * 100  , 1);
    }

    $xw = sprintf("%4.1f" , htmlspecialchars((string) $w));
    $xh = sprintf("%4.1f" , htmlspecialchars((string) $h));
    $xb = sprintf("%4.1f" , htmlspecialchars((string) $b));

    if           ($b < 18.5) { $c = "underweight"; $cc = $cl0;
        } elseif ($b < 25.0) { $c = "normal";      $cc = $cl1;
        } elseif ($b < 30.0) { $c = "overweight";  $cc = $cl2;
        } else               { $c = "obese";       $cc = $cl3;

    }

?>

</HEAD>
<BODY bgcolor="#ccffcc" text="#003300" link="#993300" vlink="#336600" alink="#ffff99"><P></P>
<H1>BMI CALC</H1>

<FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Weight <INPUT size="6" type="text" maxlength="6" name="form_weight"  tabindex="1" istyle="4" mode="numeric" style="text-align : right;" value="<?php echo $xw; ?>"> kg<BR>
Height <INPUT size="6" type="text" maxlength="6" name="form_height" tabindex="2" istyle="4" mode="numeric" style="text-align : right;" value="<?php echo $xh; ?>"> cm<BR>
BMI <INPUT size="5" type="text" maxlength="5" name="form_BMI" tabindex="3" istyle="4" mode="numeric" style="text-align : right;" value="<?php echo $xb; ?>">
<INPUT size="12" type="text" maxlength="12" name="form_comme" readonly value="<?php echo $c; ?>" style="background-color : <?php echo $cc; ?>;text-align : center;"><BR>
<BR>
<INPUT type="submit" accesskey="#" tabindex="4" name="btn_calc" value=" CALC "></FORM>

<?php
    if ($ready_h) {
        $w3  = round(wt(30.0 , $h),1);
        $w2  = round(wt(25.0 , $h),1);
        $w1  = round(wt(18.5 , $h),1);
        $w00 = round(wt(22.0 , $h),1);
    }
?>
<TABLE border="1" cellpadding="2"><TBODY>
<TR>
    <TD colspan="2" align="center" bgcolor="#99ff99">
        <?php
            if ($ready_h) {
                echo 'Wgt for <b>';
                printf("%3.1fcm" , $xh);
                echo '</b>';
            } else {
                echo 'Reference (WHO)';
            }
        ?>
    </TD>
</TR>
<TR>
    <TD align="center" bgcolor="#99ff99"><B>BEST</B></TD>
    <TD align="center" bgcolor="#99ff99">
        <?php
            if ($ready_h) {
                echo '<b>';
                printf("<b>%3.1fkg</b>" , $w00);
                echo '</b>';
            } else {
                echo '<b>BMI=22.0</b>';
            }
        ?>
    </TD>
</TR>
<TR>
    <TD align="center" bgcolor="#ffcccc">obese</TD>
    <TD bgcolor="#ffcccc">
        <?php
            if ($ready_h) {
                printf("%3.1f〜" , $w3);
            } else {
                echo '30.0〜';
            }
        ?>
    </TD>
</TR>
<TR>
    <TD align="center" bgcolor="#ffffcc">overWgt</TD>
    <TD bgcolor="#ffffcc">
        <?php
            if ($ready_h) {
                printf("%3.1f〜%3.1f" , $w2 , $w3 - 0.1);
            } else {
                echo '25.0〜30.0';
            }
        ?>
    </TD>
</TR>
<TR>
    <TD align="center" bgcolor="#ccff99">normal</TD>
    <TD bgcolor="#ccff99">
        <?php
            if ($ready_h) {
                printf("%3.1f〜%3.1f" , $w1 , $w2 - 0.1);
            } else {
                echo '18.5〜25.0';
            }
        ?>
    </TD>
</TR>
<TR>
    <TD align="center" bgcolor="#ccccff">underWgt</TD>
    <TD align="right" bgcolor="#ccccff">
        <?php
            if ($ready_h) {
                printf("〜%3.1f" , $w1 - 0.1);
            } else {
                echo '〜18.5';
            }
        ?>
    </TD>
</TR>
</TBODY>
</TABLE>
<P><IMG src="qrcode_uah_bmi.gif" border="0" width="99" height="99"></P>
<P><FONT size="-1"><A href="http://d.hatena.ne.jp/owl/">&copy;Okibi Labo.</A><BR>
2009/10/18 v2.11</FONT></P>
</BODY>
</HTML>