function pullData($userData) { require_once 'lib/helpers/visits-setup.inc.php'; $BrowsersToPull = new BrowserTableGateway($dbAdapter); $ContinentsToPull = new ContinentsTableGateway($dbAdapter); $CountriesToPull = new CountriesTableGateway($dbAdapter); $DeviceBrandToPull = new DeviceBrandTableGateway($dbAdapter); $DeviceTypeToPull = new DeviceTypesTableGateway($dbAdapter); $OperatingSystemsToPull = new OperatingSystemsTableGateway($dbAdapter); $ReferrersToPull = new ReferrersTableGateway($dbAdapter); $VisitsToPull = new VisitsTableGateway($dbAdapter); $dataSets = array("Browsers", "Continents", "Countries", "Devicebrand", "Devicetype", "Operatingsystems", "Referrers", "Visits"); if (in_array($userData, $dataSets)) { switch ($userData) { case "Browsers": $array = $BrowsersToPull->findAll(); echo json_encode($array); break; case "Continents": $array = $ContinentsToPull->findAll(); echo json_encode($array); break; case "Countries": $array = $CountriesToPull->findAll(); echo json_encode($array); break; case "Devicebrand": $array = $DeviceBrandToPull->findAll(); echo json_encode($array); break; case "Devicetype": $array = $DeviceTypeToPull->findAll(); echo json_encode($array); break; case "Operatingsystems": $array = $OperatingSystemsToPull->findAll(); echo json_encode($array); break; case "Referrers": $array = $ReferrersToPull->findAll(); echo json_encode($array); break; case "Visits": $array = $VisitsToPull->findAll(); echo json_encode($array); break; } } }
} foreach ($browserVisits as $key => $value) { $browserVisits[$key] = round($value / $totalVisits * 100, 2) . "%"; } $browserHeaders = array("Browser", "Visits"); /* * Retrieves all visit information for a specific brand */ $brandsGateway = new DeviceBrandTableGateway($dbAdapter); $brandList = $brandsGateway->findAll(); if (isset($_GET["brandId"]) && $_GET["brandId"] != "") { $brandId = $_GET["brandId"]; $brand = $brandsGateway->findById($brandId); $brandResults = array($brand->name => $visitsGateway->countByDeviceBrand($brandId)); $brandHeaders = array("Brand", "Visits"); } /* * Retrieves all visit information for a specific continent */ $continentsGateway = new ContinentsTableGateway($dbAdapter); $continentList = $continentsGateway->findAll(); if (isset($_GET["continentCode"]) && $_GET["continentCode"] != "") { $continentCode = $_GET["continentCode"]; $countriesGateway = new CountriesTableGateway($dbAdapter); $countries = $countriesGateway->filterByContinentCode($continentCode); $countryResults = array(); foreach ($countries as $result) { $countryResults[$result->CountryName] = $visitsGateway->countByCountryCode($result->ISO); } $countryHeaders = array("Country", "Visits"); }