3 // Deprecated. Node Manager manages the node bandwidth limit.
5 // Mark Huang <mlhuang@cs.princeton.edu>
6 // Copyright (C) 2006 The Trustees of Princeton University
11 // Get admin API handle
12 require_once 'plc_api.php';
16 // backwards compatibility with the old 4.2 API
17 global $__PLC_API_VERSION;
18 if ( ! method_exists ($adm,"GetInterfaces"))
19 $__PLC_API_VERSION = 4.2;
21 $__PLC_API_VERSION = 4.3;
23 if ($__PLC_API_VERSION==4.2)
24 $interfaces = $adm->GetNodeNetworks(array('ip' => $_SERVER['REMOTE_ADDR']));
26 $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
28 if (!empty($interfaces)) {
29 if ($interfaces[0]['bwlimit'] !== NULL) {
30 $rate = $interfaces[0]['bwlimit'];
31 if ($rate >= 1000000000 && ($rate % 1000000000) == 0) {
32 printf("%.0fgbit", ($rate / 1000000000.));
33 } elseif ($rate >= 1000000 && ($rate % 1000000) == 0) {
34 printf("%.0fmbit", ($rate / 1000000.));
35 } elseif ($rate >= 1000) {
36 printf("%.0fkbit", ($rate / 1000.));
38 printf("%.0fbit", $rate);