function update_traffic_requests() { global $maindb; /*Build Request*/ // Include the Http Class require_once MAD_PATH . '/modules/http/class.http.php'; // Instantiate it $http = new Http(); $http->addParam('last', getconfig_var('last_tafficrequest_id')); $http->addParam('uid', getconfig_var('mobfox_uid')); $campred = mysql_query("SELECT * FROM md_networks WHERE network_auto_approve='1'", $maindb); while ($network_detail = mysql_fetch_array($campred)) { $http->addParam('' . $network_detail['network_identifier'] . '_autoapprove', '1'); if ($network_detail['network_aa_min'] == 1) { $http->addParam('' . $network_detail['network_identifier'] . '_autoapprove_min_cpc', $network_detail['network_aa_min_cpc']); $http->addParam('' . $network_detail['network_identifier'] . '_autoapprove_min_cpm', $network_detail['network_aa_min_cpm']); } } $http->execute('http://network.madserve.org/api_request.php'); if ($http->error) { return false; } $xml_trafficrequest = new SimpleXmlElement($http->result, LIBXML_NOCDATA); foreach ($xml_trafficrequest->request as $traffic_request) { $trafficrequest_id = $traffic_request['id']; $trafficrequest_network = $traffic_request['network']; $trafficrequest_rate_type = $traffic_request['rate_type']; $trafficrequest_rate = $traffic_request['rate_content']; $trafficrequest_priority = $traffic_request['priority']; $trafficrequest_campaign_start = $traffic_request['campaign_start']; $trafficrequest_campaign_end = $traffic_request['campaign_end']; $trafficrequest_autoapprove = $traffic_request->autoapprove; $trafficrequest_targeting_maindevice = $traffic_request->targeting['main_device']; $trafficrequest_targeting_iphone = $traffic_request->targeting['iphone']; $trafficrequest_targeting_ipod = $traffic_request->targeting['ipod']; $trafficrequest_targeting_ipad = $traffic_request->targeting['ipad']; $trafficrequest_targeting_android = $traffic_request->targeting['android']; $trafficrequest_targeting_other = $traffic_request->targeting['other']; $trafficrequest_targeting_ios_version_min = $traffic_request->targeting['ios_version_min']; $trafficrequest_targeting_ios_version_max = $traffic_request->targeting['ios_version_max']; $trafficrequest_targeting_android_version_min = $traffic_request->targeting['android_version_min']; $trafficrequest_targeting_android_version_max = $traffic_request->targeting['android_version_max']; if (check_network_installed($trafficrequest_network)) { // START INSERT TRAFFIC REQUEST $received_ts = time(); // Insert Campaign into DB mysql_query("INSERT INTO md_trafficrequests (request_id, network_id, network_identifier, request_status, request_pricing_type, request_pricing, request_priority, request_received_timestamp, request_sent_timestamp, request_expiration, request_autoapproved, campaign_name, campaign_desc, campaign_start, campaign_end, target_iphone, target_ipod, target_ipad, target_android, target_other, ios_version_min, ios_version_max, android_version_min, android_version_max, device_target)\nVALUES ('{$trafficrequest_id}', '', '{$trafficrequest_network}', '0', '{$trafficrequest_rate_type}', '{$trafficrequest_rate}', '{$trafficrequest_priority}', '{$received_ts}', '', '{$trafficrequest_campaign_end}', '{$trafficrequest_autoapprove}', '', '', '{$trafficrequest_campaign_start}', '{$trafficrequest_campaign_end}', '{$trafficrequest_targeting_iphone}', '{$trafficrequest_targeting_ipod}', '{$trafficrequest_targeting_ipad}', '{$trafficrequest_targeting_android}', '{$trafficrequest_targeting_other}', '{$trafficrequest_targeting_ios_version_min}', '{$trafficrequest_targeting_ios_version_max}', '{$trafficrequest_targeting_android_version_min}', '{$trafficrequest_targeting_android_version_max}', '{$trafficrequest_targeting_maindevice}')", $maindb); global $created_request_id; $created_request_id = mysql_insert_id($maindb); foreach ($traffic_request->targeting->geo_targeting->value as $geo_targeting_code) { /*Add GEO Targeting*/ add_trafficrequest_targeting($created_request_id, 'geo', $geo_targeting_code); } foreach ($traffic_request->targeting->channel_targeting->value as $channel_targeting_code) { /*Add Channel Targeting*/ add_trafficrequest_targeting($created_request_id, 'channel', $channel_targeting_code); } if ($trafficrequest_autoapprove == 1) { approve_trafficrequest($created_request_id); } } // END INSERT TRAFFIC REQUEST update_configvar('last_tafficrequest_id', $trafficrequest_id); } update_configvar('last_trafficrequest_update', time()); }
global $current_section; $current_section = 'trafficrequests'; require_once '../../init.php'; // Required files require_once MAD_PATH . '/www/cp/auth.php'; require_once MAD_PATH . '/functions/adminredirect.php'; require_once MAD_PATH . '/www/cp/restricted.php'; require_once MAD_PATH . '/www/cp/admin_functions.php'; require_once MAD_PATH . '/www/cp/templates/header.tpl.php'; if (!check_permission('trafficrequests', $user_detail['user_id'])) { exit; } if (isset($_GET['action'])) { if ($_GET['action'] == 'approve' && is_numeric($_GET['id'])) { approve_trafficrequest($_GET['id']); } if ($_GET['action'] == 'decline' && is_numeric($_GET['id'])) { decline_trafficrequest($_GET['id']); } } ?> <div id="content"> <div id="contentHeader"> <h1>Traffic Request Management</h1> </div> <!-- #contentHeader --> <div class="container"> <div class="grid-24">