⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 weight.php

📁 FTB安装版 v1.3(虚拟形象)FTB安装版 v1.3(虚拟形象)
💻 PHP
字号:
<?php
$forumid=121;
//此程序的BMI计算原理来自中国中医减肥网,我可不懂其中的算法啊 :)
require("userdata/style.php");
require("global.php");
require("header.php");echo"$headertp";
headguide("您现在正处在 <?=$bbs_title?><br>娱乐园中心","<a href='club.php'>娱乐园</a>","<a href='weight.php'>我的身材够标准么?</a>");
	$admin_ofstar['write_ofstar'] = '1';	//			是记录测试结果(1,打开;0,关闭)
	$admin_ofstar['counter'] = '1';		//			是否计数(1,打开;0,关闭)
if ($login_status==0) {
    msg_box('自我体重检验','<br>状态:发生错误,您还没有登录论坛<br><ul><li><a href="javascript:history.back(1)">返回前页</a></li><br><li><a href="login.php">现在登录</li><br><li><a href="register.php">现在注册</li></ul>');
    exit;
    }
if($step!=2){
	print_input();
require("footer.php");echo"$footertp";
	exit();
}
if($step==2)
{
if ($name==""){
	$err="请输入姓名或昵称。\\n";
}

if($mail==""){
	$err.="信箱不能为空,请输入你的信箱。\\n\\n";
}
if($flag!=1)//检查体重是否有效
{if ($weight>500 or $weight<2){
	$err.="您的体重输入有误,请重新输入。\\n";
	$err.="本测试体重范围在2-500公斤。\\n\\n";
}
//检查身高是否有效
if ($high>250 or $high<30){
	$err.="您的身高输入有误,请重新输入。\\n";
	$err.="本测试体重范围在30-250厘米。\\n\\n";
}
}
if ($month>0 and ($born_weight<2 or $born_weight>6)){
	$err.="您的出生体重输入有误,请重新输入。\\n";
	$err.="本测试出生体重范围在2-6公斤。\\n\\n";
}
//检查年龄是否有效
if ($year>120 or ($year<=0 and $month<=0) or ($month)>24){
	$err.="您的年龄输入有误,请重新输入。\\n";
	$err.="本测试体重范围在5个月-100岁。\\n\\n";
}

if ($err){
	print "<script>alert(\"$err\");</script>";
	print_input();
}
if (!$err)
	{
$userin=explode("|",readfromfile("$userpath/$username.php"));
if ($userin[24]<=0){
	msg_box('您负债太多!金钱不为正','<br>状态:发生错误,请多发好帖子,不要浪费金钱,不要赌博,还要努力打工。<br><ul><li><a href="javascript:history.back(1)">返回前页</a></li><br><li><a href="index.php">回到主页</li><br><li><a href="club.php">娱乐园中心</li></ul>');
    exit;
    }
dtchange($username,'0','0',"-$post_ofstar");
	}
// ***************** 显示标题 *********************
?><table width=80% border=0 bgcolor=<?=$bordercolor?> align="center" cellspacing=1 cellpadding=1>
<tr bgcolor=<?=$categorycolor?>>
<td colspan=3 bgcolor=<?=$forumcolorone?>>
<table cellpadding=0 cellspacing=0 border=0>
<tr height=22><td align=center width=800 bgcolor=<?=$forumcolorone?>>测验结果如下!</td>
</tr></table>
</td>
</tr></table><br><br>
<div align=center>
  <table width=80% border=0 cellspacing=0 cellpadding=0 bgcolor=<?=$bordercolor?>>
    <tr> 
      <td> 
        <table width=100% border=0 cellspacing=1 cellpadding=0>
          <tr> 
            <form name=form method=post>
              <td bgcolor=<?=$forumcolortwo?>>
			  <BR>
<?
// ***************** 错误判断结束 *********************

$s=($sex=="男")?"先生":"女士";
echo "&nbsp;&nbsp;&nbsp;&nbsp;<b>$name</b>.$s.您好:(您支付了{$post_ofstar}{$bbs_money})<br><br>";

//以下开始计算
//*****************年龄小于2岁的婴幼儿
$month=$year*12+$month;				
if ($month<25){	
	if(($month)<7){	
		$weight_nor=$month*.6+$born_weight;
		$weight_hig=$weight-$weight_nor;
	}
	else{								//6个月以上
		$weight_nor=$month*.6+$born_weight+($month-6)*.5;
		$weight_hig=$weight-$weight_nor;
	}
	$chenghu="您的宝宝";
	echo "  您的宝宝现在体重是:$weight2 公斤<br>";
	echo "  您的宝宝出生时体重:$born_weight 公斤<br>";
	echo "  您的宝宝月龄是:$month 月<br>";
	echo "  您的宝宝标准体重是:$weight_nor 公斤 <br>";
	bztj_pd($weight_hig,$chenghu);
	echo "  您的宝宝肥胖度是:";
	weight_jb($weight_hig/$weight_nor);
	echo "<br>";
}

//****************2岁以上,且身高小于150
if ($year>=2 and $year<15 and $high<150){
	$weight_nor=$year*2+8;
	$weight_hig=$weight-$weight_nor;
	$chenghu="您";
	echo "  您的身高是:$high 厘米<br>";
	echo "  您的体重是:$weight 公斤<br>";
	echo "  您的标准体重是:$weight_nor 公斤<br>";
	bztj_pd($weight_hig,$chenghu);
	echo "  您的肥胖度是:";
	weight_jb($weight_hig/$weight_nor);
	echo "<br>";
}

//*******************成年人
if ($year>=2 and $year<=50){
	$weight_nor=($high-100)*.9;
	$weight_hig=$weight-$weight_nor;
	$bmi=10000*$weight/$high/$high;//BMI
	$chenghu="您";
	settype($bmi,integer);
	echo "  您的身高是:$high 厘米 <br>";
	echo "  您的体重是:$weight 公斤 <br>";
	echo "  您的标准体重是:$weight_nor 公斤 <br>";
	bztj_pd($weight_hig,$chenghu);
	echo "  您的BMI是:$bmi <br>";
	echo "  您的肥胖度是:";
	weight_jb($weight_hig/$weight_nor);
	echo '<br>';
}

//*****************************老年人
if ($year>50){
	if ($sex=="男"){
		$weight_nor=.6465*$high-48.68;
	}
	else{
		$weight_nor=.559*$high-33.41;
	}
	$chenghu="您";
	$weight_hig=$weight-$weight_nor;
	echo "  您的身高是:$high 厘米<br>";
	echo "  您的体重是:$weight 公斤<br>";
	echo "  您的标准体重是:$weight_nor 公斤<br>";
	bztj_pd($weight_hig,$chenghu);
	echo "  您的BMI是:$bmi <br>";
	echo "  您的肥胖度是:";
	weight_jb($weight_hig/$weight_nor);
	echo "<br>";
}

//********************显示统计信息******************
if ($admin_ofstar['counter']){
	$counter=counter();

		?><p align=center>您是第<?=$counter?>位测试者<br> <input type="button" value="返 回" onClick="location.href='weight.php'" style="height:20px; background-color:#f3f3f3; border:1 solid black;" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'">  <input type=hidden value=1 name=step></p>
		<?
}
echo "</td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
";
if ($admin_ofstar['write_ofstar']) write_ofstar($counter);
echo "</body></html>";
		require("footer.php");echo"$footertp";
	exit();
}
//*****************函数定义*******************
function weight_jb($weight_jb){			// 利用超过正常的肥胖度来判断肥胖标准
	$weight_jb=$weight_jb*100;
	$jb=round($weight_jb,1)."%<br><br>";
	$j=$jb;
	if ($weight_jb<-20){
		$j.="  太瘦了,不能因为追求美丽,而不注意健康!";
	}
	elseif ($weight_jb<-10){
		$j.="  现在有些瘦,注意身体健康。";
	}
	elseif ($weight_jb<10){
		$j.="  恭喜,现在的体重正处于最佳状态,请注意保持。";
	}
	elseif ($weight_jb<20){
		$j.="  很遗憾,现在超重了,请注意吧。";
	}
	elseif ($weight_jb<30){
		$j.="  请注意,现在是轻度肥胖。";
	}
	elseif ($weight_jb<50){
		$j.="  请注意!现在是中度肥胖,已受到肥胖的危胁,请马上减肥!";
	}
	else{
		$j.="<font color='red'>  警告!</font>现在是重度肥胖,健康正在受着肥胖的严重损害。";
	}
	echo $j;
}

function bztj_pd($weight_hig,$chenghu){
	if ($weight_hig<0){
		$w=-$weight_hig;
		echo "  ".$chenghu." 低于标准体重:".$w." 公斤<br>";
	}
	elseif ($weight_hig==0){
		echo "  ".$chenghu." 的体重太棒了,正好是标准体重!<BR>";
	}
	else{
		echo "  ".$chenghu." 超过标准体重:".$weight_hig." 公斤<br>";
	}
}


function counter(){
	if(!@is_file("count.txt")){
		$fp = fopen("count.txt","w");
		fclose($fp);
	}
	$fp = fopen("count.txt","r+");
	$counter =0+fgets($fp,10);
	$counter++;
	rewind($fp);
	fputs($fp,$counter,10);
	fclose($fp);
	return $counter;
}

function write_ofstar($counter){
	if(!@is_file("write_ofstar.txt")){
		$fp = fopen("write_ofstar.txt","w");
		fclose($fp);
	}
	global $weight_nor,$weight_hig,$weight_nor,$name,$mail,$username;//声明全局变量
	global $sex,$year,$high,$weight,$month,$born_weight,$weight_jb,$bmi;
	$weight_jb=round(100*$weight_hig/$weight_nor,1);
	$date_ip=date_ip();
	//信箱,计数,姓名,性别,年龄,身高,体重,正常体重,超重,肥胖度,BMI,(婴儿)月龄和出生体重,测试时间,IP地址
	$com=$mail.",".$counter.",".$name;
	$com.=",".$sex.",".$year.",".$high.",".$weight;
	$com.=",".$weight_nor.",".$weight_hig.",".$weight_jb.",".$bmi;
	$com.=",".$month.",".$born_weight;//婴儿加上月龄和出生体重
	$com.=",".$username.",".$date_ip."\n";
	//echo $com;
	$f=fopen("write_ofstar.txt","a+");
	fputs($f,$com);
	fclose;
}

function date_ip(){
	$dates = date(y).'年';
	$dates .= date(m).'月';
	$dates .= date(d).'日';
	$dates .= date(H).'时';
	$dates .= date(i).'分';
	$dates .= date(s).'秒';
	global $REMOTE_ADDR;
	$IP=$REMOTE_ADDR;
	$dates.=",".$IP;
	return $dates;
}

function print_input(){
	global $weight_nor,$weight_hig,$weight_nor,$name,$mail;//声明全局变量
	global $sex,$year,$high,$weight,$month,$site_url,$bbs_title,$born_weight,$titlecolor,$forumcolorone,$bordercolor,$weight_jb,$bmi;
	 if(!$born_weight) $born_weight="";
	 print <<<EOT
	<body>
	<div align="center"> 
	  <table width="775" border="0" cellspacing="0" cellpadding="0" bgcolor="$bordercolor">
		<tr> 
		  <td> 
			<table width="100%" border="0" cellspacing="1" cellpadding="0">
			  <tr> 
				<form name="form" method="post">
				  <td bgcolor="#FFFFFF">
				  <table width="100%" border="1" bordercolorlight="$bordercolor" bordercolordark="$bordercolor">
                  <tr> 
                    <td bgcolor=$titlecolor colspan="2" align=center height=26><b class=title>{$bbs_title}体型测试程式(要<font color="red">钱</font>的哦^_^)!</b>
                    </td>
                  </tr>
	 <tr> 
                    <td width="50%"> 姓 名: 
                      <input type="text" name="name" maxlength="6" size="7" value="$name"> 
                    </td>
                    <td>&nbsp; </td>
                  </tr>
                  <tr> 
                    <td> 性 别: 
                      <select name="sex">
                        <option selected>男</option>
                        <option>女</option>
                      </select> </td>
                    <td> </td>
                  </tr>
                  <tr>
                    <td>E_mail: 
                      <input type="text" name="mail" size="30" value="$mail"> 
                    </td>
                    <td><font color="#FF0000"><input type=radio name=flag value=1>注:</font>2岁以下婴幼儿在下面填写</td>
                  </tr>
                  <tr>
                    <td>年 龄: 
                      <input type="text" name="year" size="7" maxlength="4"  value="$year">
                      周岁</td>
                    <td> 婴 幼 儿: 
                      <input type="text" name="month" size="7" maxlength="2"  value="$month">
                      月</td>
                  </tr>
                  <tr>
                    <td>身 高: 
                      <input type="text" name="high" size="7" maxlength="4"  value="$high">
                      厘米 </td>
                    <td><font color="#FF0000"> </font>出生体重: 
                      <input type="text" name="born_weight" size="7" maxlength="2" value="$born_weight">
                      公斤</td>
                  </tr>
                  <tr>
                    <td>体 重: 
                      <input type="text" name="weight" size="7" value="$weight">
                      公斤</td>
                    <td> 现 体 重: 
                      <input type="text" name="weight2" size="7" value="$weight2">
                      公斤</td>
                  </tr>
                  <tr> 
                    <td><font color="#999999">如果是婴儿以上3项不要填写</font></td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr> 
                    <td colspan="2" align=center><input type=submit value="确认提交" style="height:20px;background-color:#f3f3f3;border:1 solid black" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'">
                     <input type=reset value="清除重写" style="height:20px;background-color:#f3f3f3;border:1 solid black" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'" name="reset">
		 <input type="button" value="论坛首页" onClick="location.href='index.php'" style="height:20px; background-color:#f3f3f3; border:1 solid black;" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'">  
		 <input type=hidden value="2" name="step"> </td>
                  </tr>
                </table>
				  </td>
				</form>
			  </tr>
			  <tr> 
				<td bgcolor=$forumcolorone> <p><br>
					  体重指数(BMI)计算方法为:<br>
					    BMI=体重(公斤)/(身高(米)×身高(米))<br>
					  根据体重指数,胖瘦就一目了然,指数越小则人越瘦,越大则人越胖。男女性的最佳体重指数为22,此时健康状况最佳,也最不容易患病。男性指数大于24,女性指数大于26就可以确诊为肥胖。</p>
				  <p>   肥胖度也是一个常用来衡量人胖瘦的指数,计算方法为:<br>
					    肥胖度=(实际体重-标准体重)×100%<br>
					  正常体重在标准体重的±10%范围内,高于10%为肥胖,低于10%为消瘦。</p><br></p>
				</td>
			  </tr>
			</table>
		  </td>
		</tr>
	  </table>
	</div>
</body></html>
EOT;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -