Posted on: 12/20/03 09:47am
By: daveshorts
/** * * Check quota() * * Php function to tell you if you are going overquota * Will probably only work on unix systems **/ function phpblock_checkQuota(){ // The hard disk you are interested in $hd='hda10'; // when the free space should be in red $worry=1000; // when the free space should be in red and large $panic=10; $string=exec('quota'); preg_match("/$hds*(d*)s*(d*)s*(d*)s{1,7}(d*)/",$string,$matches); $freespace=$matches[2]-$matches[1]; $return.= "<tr><td>used</td><td align=right>$matches[1] kB</td></tr> <tr><td>quota</td><td align=right>$matches[2] kB</td></td>"; if($freespace<$panic){ $return.= "<tr><td><b>Free</></td><td align=right><b><font color=red size=6>$freespace</font></b> kB</td></tr>";} elseif($freespace<$worry){ $return.= "<tr><td><b>Free</b></td><td align=right><font color=red>$freespace kB</font></td></tr>";} elseif($freespace<0){ $return.= "<tr><td><b>Free</b></td><td align=right><font color=red>$freespace kB</font></td></tr> <tr><b>Grace</b></td><td align=right><font color=red>$matches[4]</font></td></tr>"; } else{ $return.= "<tr><td><b>Free</b></td><td align=right>$freespace kB</td></tr>"; } return $return; }