index.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. if (cfr('SWITCHSONIC')) {
  3. if ($ubillingConfig->getAlterParam('SWITCHSONIC_ENABLED')) {
  4. if (ubRouting::checkGet(array('swip', 'swcomm'))) {
  5. $swId = ubRouting::get('swid');
  6. $swIp = ubRouting::get('swip');
  7. $swComm = ubRouting::get('swcomm');
  8. $displayMode = ubRouting::get('mode');
  9. $baseUrl = '?module=switchsonic';
  10. $baseUrl .= '&swid=' . $swId;
  11. $baseUrl .= '&swip=' . $swIp;
  12. $baseUrl .= '&swcomm=' . $swComm;
  13. $sonicTimeout = $ubillingConfig->getAlterParam('SWITCHSONIC_TIMEOUT');
  14. if (!$sonicTimeout) {
  15. $sonicTimeout = 5; //default if not set obviously
  16. }
  17. $sonicTimeout = ubRouting::filters($sonicTimeout, 'int') * 1000; //in ms.
  18. $controls = '';
  19. if (!empty($swId)) {
  20. $controls .= wf_BackLink('?module=switchpoller&switchid=' . $swId);
  21. }
  22. $controls .= wf_Link($baseUrl, wf_img('skins/sonic_icon.png') . ' ' . __('Realtime traffic'), false, 'ubButton');
  23. $controls .= wf_Link($baseUrl . '&mode=charts', wf_img('skins/realtime_icon.png') . ' ' . __('Realtime charts'), false, 'ubButton');
  24. $controls .= wf_Link($baseUrl . '&mode=freeze', wf_img('skins/icon_lock.png') . ' ' . __('Freeze dont move'), false, 'ubButton');
  25. show_window('', $controls);
  26. $sonic = new SwitchSonic($swIp, $swComm);
  27. if ($sonic->checkAuth()) {
  28. if (empty($displayMode)) {
  29. $zenFlow = new ZenFlow('ajswsonic', $sonic->renderSpeeds(), $sonicTimeout);
  30. show_window(__('Realtime bandwidth monitor'), $zenFlow->render());
  31. } else {
  32. if ($displayMode == 'charts') {
  33. $zenFlow = new ZenFlow('ajswsonic', $sonic->renderCharts(), ($sonicTimeout + 1000));
  34. show_window(__('Realtime charts'), $zenFlow->render());
  35. }
  36. if ($displayMode == 'freeze') {
  37. show_window(__('Traffic'), $sonic->renderSpeeds());
  38. show_window(__('Graphs'), $sonic->renderCharts());
  39. }
  40. }
  41. zb_BillingStats(true);
  42. } else {
  43. show_error(__('Something went wrong') . ': ' . __('Authorization failed'));
  44. }
  45. } else {
  46. show_error(__('Something went wrong'));
  47. }
  48. } else {
  49. show_error(__('This module is disabled'));
  50. }
  51. } else {
  52. show_error(__('Access denied'));
  53. }