index.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. $endpointsAllowedHostsRaw = $ubillingConfig->getAlterParam('ENDPOINTS_HOSTS');
  3. if (!empty($endpointsAllowedHostsRaw)) {
  4. $endpointsAllowedHostsRaw = explode(',', $endpointsAllowedHostsRaw);
  5. $endpointsAllowedHosts = array();
  6. foreach ($endpointsAllowedHostsRaw as $io => $each) {
  7. $ip = trim($each);
  8. $endpointsAllowedHosts[$ip] = $io;
  9. }
  10. if (!isset($endpointsAllowedHosts[$_SERVER['REMOTE_ADDR']])) {
  11. die('GRAPH:DENIED');
  12. }
  13. }
  14. set_time_limit(60);
  15. $graph = new OphanimGraph();
  16. $ip = ubRouting::get('ip', 'fi', FILTER_VALIDATE_IP);
  17. $direction = (ubRouting::get('dir', 'vf') == 'S') ? 'S' : 'R';
  18. $w = (ubRouting::get('w', 'int')) ? ubRouting::get('w', 'int') : 1540;
  19. $h = (ubRouting::get('h', 'int')) ? ubRouting::get('h', 'int') : 400;
  20. $customTitle = '';
  21. if ($ubillingConfig->getAlterParam('CHARTS_NETDESC')) {
  22. $netLib = new OphanimNetLib();
  23. $netDesc = $netLib->getIpNetDescription($ip);
  24. if ($netDesc) {
  25. $customTitle .= ' (' . $netDesc . ')';
  26. }
  27. }
  28. //day by default
  29. $dateFrom = date("Y-m-d 00:00:00");
  30. $dateTo = date("Y-m-d H:i:s");
  31. if (ubRouting::checkGet('period')) {
  32. $period = ubRouting::get('period');
  33. switch ($period) {
  34. case '24h':
  35. $dateFrom = date("Y-m-d H:i:s", strtotime("-24 hour", time()));
  36. $dateTo = date("Y-m-d H:i:s");
  37. break;
  38. case '48h':
  39. $dateFrom = date("Y-m-d H:i:s", strtotime("-48 hour", time()));
  40. $dateTo = date("Y-m-d H:i:s");
  41. break;
  42. case 'hour':
  43. $dateFrom = date("Y-m-d H:i:s", strtotime("-1 hour", time()));
  44. $dateTo = date("Y-m-d H:i:s");
  45. break;
  46. case 'day':
  47. $dateFrom = date("Y-m-d 00:00:00");
  48. $dateTo = date("Y-m-d H:i:s");
  49. break;
  50. case 'week':
  51. $dateFrom = date("Y-m-d H:i:s", strtotime("-7 day", time()));
  52. $dateTo = date("Y-m-d H:i:s");
  53. break;
  54. case 'month':
  55. $dateFrom = date("Y-m-d H:i:s", strtotime("-1 month", time()));
  56. $dateTo = date("Y-m-d H:i:s");
  57. break;
  58. case 'year':
  59. $dateFrom = date("Y-m-d H:i:s", strtotime("-1 year", time()));
  60. $dateTo = date("Y-m-d H:i:s");
  61. break;
  62. case 'explict':
  63. if (ubRouting::checkGet(array('from', 'to'))) {
  64. $timeStampFrom = ubRouting::get('from');
  65. $timeStampTo = ubRouting::get('to');
  66. if ($timeStampFrom < $timeStampTo) {
  67. $dateFrom = date("Y-m-d H:i:s", $timeStampFrom);
  68. $dateTo = date("Y-m-d H:i:s", $timeStampTo);
  69. }
  70. }
  71. break;
  72. }
  73. }
  74. $graph->renderGraph($ip, $direction, $dateFrom, $dateTo, $w, $h, $customTitle);