index.php 945 B

123456789101112131415161718192021222324252627
  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('GETTRAFF:DENIED');
  12. }
  13. }
  14. $year = (ubRouting::get('year', 'int')) ? ubRouting::get('year', 'int') : curyear();
  15. $month = (ubRouting::get('month', 'int')) ? ubRouting::get('month', 'int') : date("n");
  16. $ip = (ubRouting::get('ip', 'fi', FILTER_VALIDATE_IP)) ? ubRouting::get('ip', 'fi', FILTER_VALIDATE_IP) : '';
  17. $harvester = new OphanimHarvester();
  18. $trafCounters = $harvester->getTraffCounters($year, $month, $ip);
  19. header('Content-type: application/json');
  20. die(json_encode($trafCounters));