diff --git a/RELEASE b/RELEASE index 25eaeeaa5..691307546 100644 --- a/RELEASE +++ b/RELEASE @@ -1 +1 @@ -0.8.2 rev 5427 +0.8.2 rev 5428 diff --git a/config/taskbar.d/widgets/traffic.ini b/config/taskbar.d/widgets/traffic.ini new file mode 100644 index 000000000..de9e2814d --- /dev/null +++ b/config/taskbar.d/widgets/traffic.ini @@ -0,0 +1,6 @@ +ID="widget_traffic" +CODEFILE="widget_traffic.php" +NEED_RIGHT="" +NEED_OPTION="WIDGET_TRAFFIC" +UNIMPORTANT=1 +TYPE="widget" \ No newline at end of file diff --git a/config/taskbar.d/widgets/widget_traffic.php b/config/taskbar.d/widgets/widget_traffic.php new file mode 100644 index 000000000..d4101aae0 --- /dev/null +++ b/config/taskbar.d/widgets/widget_traffic.php @@ -0,0 +1,65 @@ +cache = new UbillingCache(); + } + + /** + * Render traffic data + * + * @return string + */ + public function getTraffic() { + $queryDown = "SELECT SUM(D0+D1+D2+D3+D4+D5+D6+D7+D8+D9) as `downloaded` from `users`"; + $dataDown = simple_query($queryDown); + $queryUp = "SELECT SUM(U0+U1+U2+U3+U4+U5+U6+U7+U8+U9) as `uploaded` from `users`"; + $dataUp = simple_query($queryUp); + $result = __('Traffic') . ': ' . __('Downloaded') . ' - ' . stg_convert_size($dataDown['downloaded']) . ', ' . __('Uploaded') . ' - ' . stg_convert_size($dataUp['uploaded']); + $result = $this->widgetContainer($result); + return ($result); + } + + /** + * Widget data with caching + * + * @return string + */ + public function render() { + $result = ''; + $this->initCache(); + $obj = $this; + $result = $this->cache->getCallback('WIDGET_TRAFFIC', function() use ($obj) { + return ($obj->getTraffic()); + }, $this->timeout); + + return ($result); + } + +} + +?> \ No newline at end of file