Location: PHPKode > projects > phpBandwidth > phpbandwidth/index.php
<?
// phpbandwidth by Alexander Wigen
include("db_config.php");
include("db_$db[type].php");
include("user_functions.php");
$conn = db_connect();
if ($conn === FALSE)
{
	echo "Cant connect to the database, have you connfigured it at <a href=\"db_install.php\">db_install.php</a> ?";
	exit;
}
include("header.php");

$users = db_get_users($conn);
if (count($users) == 0)
{
	?>
	No users defined!<br>
	<a href="user_add.php">Add user here</a>
	<?
	exit;
}

reset($users);
while (list ($uid, $val) = each ($users)) {
	$bw = fill_bandwidth_array($conn, $uid);
	$total_limit +=  $bw[limit];
	$total_used += $bw[total];
}
$day_today = date("d");
$days_in_month = date("t");
$days_left = $days_in_month - $day_today;
$prosent = $total_used/$total_limit *100 . "%";

echo "Status for <b>" . date("F") . "</b>:";
echo html_bar_month(250, $prosent, "50");
echo"<br>
Total bandwidth used is <b>" . round($total_used) . " Mb</b> of $total_limit Mb<br>";

if ($prosent < 100)
	echo "That's ". round($prosent) ."%";
else
	echo "That's ". round($prosent - 100) ."% over!";

?>
<br>
<br>
<b>
Users:</b>
<table border=0 cellpadding="3" cellspacing="15">
 <tr>
<?
reset($users);
while (list ($uid, $val) = each ($users)) {
	$bandwidth = fill_bandwidth_array($conn, $uid);
	$days_left = date("t") - date("d") + 1;
	$avr_day = number_format($bandwidth[left] / $days_left, 1,'.','');
	$prosent = ($bandwidth[total]/$bandwidth[limit]) * 100 . "%";
	echo "<td bgcolor=\"#cccccc\"><center><a href=\"userstats.php?uid=$uid\"><b>$val</b></a><br></center>";
	echo "Month:<table border=0><tr><td align=right>".round($bandwidth[total]) ."</td><td>Mb</td></tr>";
	echo "<tr><td>";
	if ($bandwidth[left] > 0)
		echo round($bandwidth[left]). "</td><td align=right>Left</td></tr>";
		else
		echo round(-$bandwidth[left]). "</td><td align=right>Over</td></tr>";
	echo "</table>\n";
		// If not in current month display progress bar as 100%
	if ($current_month == date('m') && $current_year == date('Y'))
		echo html_bar_month(100, $prosent . "%", 28);
	else	
		echo html_double_bar(100, $prosent . "%", 28, 100 . "%", 10);	

	if ($avr_day < 0)
		$prosent = "100%";
	else
		$prosent = ($bandwidth[today_total]/$avr_day) * 100 . "%";
	echo round($bandwidth[today_total]). " Mb<br>";
	echo html_bar(100, $prosent,10);
	echo "</td>\n";
}
?>
 </tr>
</table>
Click username for detailed info<br>
<?if (array_search($REMOTE_ADDR, $phpbandwidth[trusted_ips]) !== FALSE)
	echo "<a href=\"user_configure.php\">Configure users here</a><br>\n";
?>
<br>
<br>Generated by phpBandwidth<br>
Get it at <a href="http://www.wigen.net/phpbandwidth">www.wigen.net/phpbandwidth</a>
<?include ("footer.php");?>
Return current item: phpBandwidth