public function getMobileData() { if (!bt_mobile_enabled()) { error404(); } $groups = array(); if (BTAuth::user()->getPref("user_mobile_breakdown_1")) { $groups[] = BTAuth::user()->getPref("user_mobile_breakdown_1"); if (BTAuth::user()->getPref("user_mobile_breakdown_2")) { $groups[] = BTAuth::user()->getPref("user_mobile_breakdown_2"); if (BTAuth::user()->getPref("user_mobile_breakdown_3")) { $groups[] = BTAuth::user()->getPref("user_mobile_breakdown_3"); if (BTAuth::user()->getPref("user_mobile_breakdown_4")) { $groups[] = BTAuth::user()->getPref("user_mobile_breakdown_4"); } } } } if (!$groups) { $groups = array('devices.type'); } $breakdown_cols = array("devices.brand" => "Brand", "devices.type" => "Device Type", "devices.os" => "OS", "devices.os_version" => "OS Version", "devices.browser" => "Browser", "devices.browser_version" => "Browser Version", "orgs.name" => "Carrier/ISP"); foreach ($groups as $group) { if (!isset($breakdown_cols[$group])) { $groups = array('devices.type'); break; } } $group = " "; $group .= implode(',', $groups); //$cols = array('browser_name', 'clicks', 'leads', 'conv', 'payout', 'epc', 'avg_cpc', 'income', 'cost', 'net', 'roi'); $cols = array('label', 'clicks', 'click_throughs', 'click_through_rates', 'leads', 'conv', 'payout', 'epc', 'income'); $sql = 'select ' . $group . ', '; $sql .= getReportGeneralSelects() . 'from '; $sql .= getReportFilters('platforms/mobile', 'left join bt_s_clicks_advanced as adv on (click.click_id=adv.click_id) LEFT JOIN bt_s_device_data AS devices on adv.device_id=devices.device_id left join bt_g_organizations as orgs on adv.org_id=orgs.org_id '); $sql .= " and adv.device_id>0 and devices.hash<>'d41d8cd98f00b204e9800998ecf8427e' group by " . $group; $sql .= ' order by ' . $group . ' '; $click_results = DB::getRows($sql); for ($i = 0; $i < count($groups); $i++) { if ($pos = strpos($groups[$i], '.')) { $groups[$i] = substr($groups[$i], $pos + 1); } } $final_rows = array(); $tree = makeHierarchical($click_results, $groups); unset($click_results); //no longer needed foreach ($tree as $node) { getRowsFromTreeNode($node, 0, $final_rows); } return array('data' => $final_rows, 'cols' => $cols, 'cnt' => count($final_rows)); }
<?php $organization_id = 0; $geo_block_id = 0; $ip = DB::quote(ip2long($_SERVER['REMOTE_ADDR'])); /***BEGIN GEO TRACKING****/ if (bt_geo_enabled()) { require BT_ROOT . '/private/includes/traffic/geolookup.php'; $geo_block_id = runGeoLookup(); } /***END GEO TRACKING****/ /***BEGIN MOBILE TRACKING****/ if (bt_mobile_enabled()) { require BT_ROOT . '/private/includes/traffic/organization.php'; $organization_id = runOrganizationLookup(); //Track Devices: require_once BT_ROOT . '/private/libs/wurfl/TeraWurfl.php'; $wurflObj = new TeraWurfl(); $wurflObj->getDeviceCapabilitiesFromAgent(); //dont run for desktop OSes. $is_wireless = $wurflObj->getDeviceCapability('is_wireless_device'); $is_tablet = $wurflObj->getDeviceCapability('is_tablet'); $is_phone = $wurflObj->getDeviceCapability('can_assign_phone_number'); $is_desktop = true; if ($is_wireless == 'true') { $is_desktop = false; } else { if ($is_tablet == 'true') { $is_desktop = false; } else { if ($is_phone == 'true') {