急!!(菜鸟在线等)判断输出的问题!

zuoshoubingliang 2008-12-08 02:01:30
<?php
session_start();
include "config/config_inc.php";
include "include/fun_inc.php";
include "language/$CFG_LANGUAGE"."_inc.php";
if ($G_USERNAME == "")
{
header("Location: login.php");
}
function getdiskspaces($disk)
{
$i=1;
$tok = strtok($disk," ");
while($tok)
{
$xi=$tok;
if ($i == 1)
{
$a1=$xi;
}
if ($i == 2)
{
$a2=$xi;
}
if ($i == 3)
{
$a3=$xi;
}
if ($i == 4)
{
$a4=$xi;
}

$i++;
$tok = strtok(" ");
}
$sum1=$a1;
$use1=$a2;
$last=$a3;
$perc=$a4;
$msg= array("all"=>$sum1,"used"=>$use1,"percent"=>$perc);
//$msg="<img src='image/icons_disk.png' width='16' height='16' />磁盘可用总空间 :".$sum1."    <img src='image/icons_disk01.png' width='16' height='16' />已占用空间 :".$use1."  已用百分比:".$perc;
return $msg;
}
function count_spac($sumspace1)
{
$sum_len=strlen($sumspace1);
if ($sum_len >= 4)
{
if ($sum_len >= 7)
{
$sumspace3=$sumspace1/1048576;
// $sumspace2=round($sumspace3);
$yesorno=strstr($sumspace3,".");
if ($yesorno != "")
{
$datt=explode(".",$sumspace3);
$sum_a=$datt[0];
$sum_b=substr($datt[1],0,2);
$sumspace3="$sum_a.$sum_b";
}
$sumspaces="$sumspace3 G";
}else{
$sumspace3=$sumspace1/1024;
$sumspace2=round($sumspace3);
$sumspaces="$sumspace2 M";
}
}else{
$sumspaces="$sumspace1 K";
}
return $sumspaces;
}

//return k
function getdirsize($thepath)
{
$totalsize = "0";
if(!is_dir("$thepath")) return $totalsize;
$result = exec("du -sk $thepath");
$date1=explode("/",$result);
$totalsize=trim($date1[0]);
return $totalsize;
}


$udisk_space=getdirsize("$G_HOME/Maildir/share");
$udisk = count_spac($udisk_space); ///////// udisk占的空间

$width = 450; //显示的进度条长度,单位 px
if($shellbbb!='nolimit')
{
$total=$shellbbb*1073741824; //总共需要操作的记录数
$now=$udisk_space*1024;
$pix = $width / $total; //每条记录的操作所占的进度条单位长度
$progress = $pix*$now;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="main.css" rel="stylesheet" type="text/css">
<link href="tab.css" rel="stylesheet" type="text/css">
<script language="javascript" type="text/javascript">
function show_time()
{
var today,hour,second,minute,year,month,date,time;

today=new Date();

year = today.getFullYear();
month = today.getMonth()+1;
date = today.getDate();
hour = today.getHours();
minute =today.getMinutes();
second = today.getSeconds();
if(second < 10)
{
time ="<font color='red'>"+year + " </font>年<font color='red'>" + month + " </font>月<font color='red'>" + date +" </font>日<font color='red'>" + hour + " </font>时<font color='red'>" + minute + " </font>分<font color='red'>0" + second+" </font>秒";
}
else
{
time ="<font color='red'>"+year + " </font>年<font color='red'>" + month + " </font>月<font color='red'>" + date +" </font>日<font color='red'>" + hour + " </font>时<font color='red'>" + minute + " </font>分<font color='red'>" + second+" </font>秒";
}
document.getElementById("time").innerHTML = time;
}
setInterval(show_time,1000);
</script>
</head>

<body onload="show_time();">
<div class="nav"><img src="images/place.jpg" width="20" height="19" />
<div class="navname">当前位置:登录 >> 系统信息</div>
</div>

<table width="94%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="3" background="images/xian.jpg"></td>
</tr>
</table>

<br />
<table width="94%" height="163" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><fieldset>
<legend> 信息详情 </legend>
<br />
<table width="96%" height="120" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="120" valign="middle" bgcolor="#F8FBFE"><table width="94%" height="37" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td width="41%" height="25" align="right">当前时间: </td>
<td width="59%" align="left"><div id="time"></div></td>
</tr>
</table>
<?php if ($G_USERNAME == "postmaster")
{
$disk1=$disk2=$disk3=$disk4="";
$disk1=exec("/bin/df -h /home/vpopmail/");
$msg1=getdiskspaces($disk1);
$disk2=exec("/bin/df -h /disk2/");
$msg2=getdiskspaces($disk2);
$disk3=exec("/bin/df -h /disk3/");
$msg3=getdiskspaces($disk3);
$disk4=exec("/bin/df -h /disk4/");
$msg4=getdiskspaces($disk4);
?>
<table width="94%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#598ACD">
<tr>
<th width="12%" height="27" align="center" >磁盘编号</th>
<th width="9%" height="27" align="center" >可用空间</th>
<th width="13%" height="27" align="center" >已用空间</th>
<th width="18%" height="27" align="center" >已用比例</th>
</tr>
<tr>
<td height="25" align="center" bgcolor="#FFFFFF">disk1</td>
<td align="center" bgcolor="#FFFFFF" ><?php echo $msg1[used];?></td>
<td align="center" bgcolor="#FFFFFF"><?php echo $msg1[percent];?></td>
<td align="center" bgcolor="#FFFFFF"><?php echo $msg1[all];?></td>
</tr>
<?php if(is_dir("/disk2/"))
{
?>
<tr>
<td height="25" align="center" bgcolor="#F1F5FA">disk2</td>
<td align="center" bgcolor="#F1F5FA"><?php echo $msg2[used];?></td>
<td align="center" bgcolor="#F1F5FA"><?php echo $msg2[percent];?></td>
<td align="center" bgcolor="#F1F5FA"><?php echo $msg2[all];?></td>
</tr>
<?php
}if(is_dir("/disk3/"))
{
?>
<tr>
<td height="25" align="center" bgcolor="#F1F5FA">disk3</td>
<td align="center" bgcolor="#F1F5FA"><?php echo $msg3[used];?></td>
<td align="center" bgcolor="#F1F5FA"><?php echo $msg3[percent];?></td>
<td align="center" bgcolor="#F1F5FA"><?php echo $msg3[all];?></td>
</tr>
<?php
}if(is_dir("/disk4/"))
{
?>
<tr>
<td height="25" align="center" bgcolor="#F1F5FA">disk4</td>
<td align="center" bgcolor="#F1F5FA"><?php echo $msg4[used];?></td>
<td align="center" bgcolor="#F1F5FA"><?php echo $msg4[percent];?></td>
<td align="center" bgcolor="#F1F5FA"><?php echo $msg4[all];?></td>
</tr>
<?php
}?>
</table>
<?php

}else
{
?>
小弟想让如果$msg[all]等于“/dev/sda1”这个字符串的话就不输出disk比如:$msg4[all]等于“/dev/sda1”的话就不输出disk4 应该怎么写呀
那位高手帮小弟写一下来指点一下小弟 谢谢了
...全文
34 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
phpboy 2008-12-08

//是不是这样?

<?php if(is_dir("/disk2/") && $msg2[all]!='/dev/sda1') //这
{
?>
<tr>
<td height="25" align="center" bgcolor="#F1F5FA">disk2 </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg2[used];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg2[percent];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg2[all];?> </td>
</tr>
<?php
}if(is_dir("/disk3/") && $msg3[all]!='/dev/sda1') //这
{
?>
<tr>
<td height="25" align="center" bgcolor="#F1F5FA">disk3 </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg3[used];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg3[percent];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg3[all];?> </td>
</tr>
<?php
}if(is_dir("/disk4/") && $msg4[all]!='/dev/sda1') //这
{
?>
<tr>
<td height="25" align="center" bgcolor="#F1F5FA">disk4 </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg4[used];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg4[percent];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg4[all];?> </td>
</tr>
<?php
}?>
</table>
<?php

}else
{
?>
回复
penglewen 2008-12-08
<?php if(is_dir("/disk1/")&&$msg1['all']!='/dev/sda1')
{
?>
<tr>
<td height="25" align="center" bgcolor="#FFFFFF">disk1 </td>
<td align="center" bgcolor="#FFFFFF" > <?php echo $msg1[used];?> </td>
<td align="center" bgcolor="#FFFFFF"> <?php echo $msg1[percent];?> </td>
<td align="center" bgcolor="#FFFFFF"> <?php echo $msg1[all];?> </td>
</tr>
<?php
}if(is_dir("/disk2/")&&$msg2['all']!='/dev/sda1')
{
?>
<tr>
<td height="25" align="center" bgcolor="#F1F5FA">disk2 </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg2[used];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg2[percent];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg2[all];?> </td>
</tr>
<?php
}if(is_dir("/disk3/")&&$msg3['all']!='/dev/sda1')
{
?>
<tr>
<td height="25" align="center" bgcolor="#F1F5FA">disk3 </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg3[used];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg3[percent];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg3[all];?> </td>
</tr>
<?php
}if(is_dir("/disk4/")&&$msg4['all']!='/dev/sda1')
{
?>
<tr>
<td height="25" align="center" bgcolor="#F1F5FA">disk4 </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg4[used];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg4[percent];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg4[all];?> </td>
</tr>
<?php
}?>
</table>
<?php

}else
{
?>
回复
testoktest 2008-12-08
是不是这样

if(is_dir("/disk4/") && $msg4[all]=='/dev/sda1')
{
?>
<tr>
<td height="25" align="center" bgcolor="#F1F5FA">disk4 </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg4[used];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg4[percent];?> </td>
<td align="center" bgcolor="#F1F5FA"> <?php echo $msg4[all];?> </td>
</tr>
<?php
}?>
</table>
<?php

}else
{
?>
回复
程序猿之殇 2008-12-08
if($msg['all'] == "/dev/sda1")
{
}
else
{
}
实话没太明白你的意思,代码又乱又长.其实只要if else语句就可以了.
回复
相关推荐
发帖
基础编程
创建于2007-09-28

2.1w+

社区成员

从PHP安装配置,PHP入门,PHP基础到PHP应用
申请成为版主
帖子事件
创建了帖子
2008-12-08 02:01
社区公告
暂无公告