Example #1
0
function ad_request($data)
{
    global $request_settings;
    prepare_r_hash();
    if (!isset($data['rt'])) {
        $data['rt'] = '';
    }
    if (isset($data['p'])) {
        $request_settings['referer'] = $data['p'];
    } else {
        $request_settings['referer'] = '';
    }
    if (isset($data['longitude'])) {
        $request_settings['longitude'] = $data['longitude'];
    } else {
        $request_settings['longitude'] = '';
    }
    if (isset($data['latitude'])) {
        $request_settings['latitude'] = $data['latitude'];
    } else {
        $request_settings['latitude'] = '';
    }
    if (isset($data['iphone_osversion'])) {
        $request_settings['iphone_osversion'] = $data['iphone_osversion'];
    }
    if (!isset($data['sdk']) or $data['sdk'] != 'banner' && $data['sdk'] != 'vad') {
        $request_settings['sdk'] = 'banner';
    } else {
        $request_settings['sdk'] = $data['sdk'];
    }
    /*Identify Response Type*/
    switch ($data['rt']) {
        case 'javascript':
            $request_settings['response_type'] = 'json';
            $request_settings['ip_origin'] = 'fetch';
            break;
        case 'json':
            $request_settings['response_type'] = 'json';
            $request_settings['ip_origin'] = 'fetch';
            break;
        case 'iphone_app':
            $request_settings['response_type'] = 'xml';
            $request_settings['ip_origin'] = 'fetch';
            break;
        case 'android_app':
            $request_settings['response_type'] = 'xml';
            $request_settings['ip_origin'] = 'fetch';
            break;
        case 'ios_app':
            $request_settings['response_type'] = 'xml';
            $request_settings['ip_origin'] = 'fetch';
            break;
        case 'ipad_app':
            $request_settings['response_type'] = 'xml';
            $request_settings['ip_origin'] = 'fetch';
            break;
        case 'xml':
            $request_settings['response_type'] = 'xml';
            $request_settings['ip_origin'] = 'request';
            break;
        case 'api':
            $request_settings['response_type'] = 'xml';
            $request_settings['ip_origin'] = 'request';
            break;
        case 'api-fetchip':
            $request_settings['response_type'] = 'xml';
            $request_settings['ip_origin'] = 'fetch';
            break;
        default:
            $request_settings['response_type'] = 'html';
            $request_settings['ip_origin'] = 'request';
            break;
    }
    if (MAD_MAINTENANCE) {
        noad();
    }
    if (!check_input($data)) {
        global $errormessage;
        print_error(1, $errormessage, $request_settings['sdk'], 1);
        return false;
    }
    global $zone_detail;
    $zone_detail = get_placement($data);
    if (!$zone_detail) {
        global $errormessage;
        print_error(1, $errormessage, $request_settings['sdk'], 1);
        return false;
    }
    $request_settings['adspace_width'] = $zone_detail['zone_width'];
    $request_settings['adspace_height'] = $zone_detail['zone_height'];
    $request_settings['channel'] = getchannel();
    update_last_request();
    set_geo($request_settings['ip_address']);
    set_device($request_settings['user_agent']);
    build_query();
    if ($campaign_query_result = launch_campaign_query($request_settings['campaign_query'])) {
        if (!process_campaignquery_result($campaign_query_result)) {
            launch_backfill();
        }
    } else {
        launch_backfill();
    }
    global $display_ad;
    if (isset($display_ad['available']) && $display_ad['available'] == 1) {
        track_request(1);
        display_ad();
    } else {
        track_request(0);
        noad();
    }
}
Example #2
0
 function request($key = '', $required = false, $default = NULL)
 {
     if (ENVIRONMENT == 'development' && !is_array($key)) {
         track_request($key, $required, $default);
     }
     if (is_array($key) && $key) {
         foreach ($key as $key_name) {
             $data[$key_name] = isset($_REQUEST[$key_name]) ? $_REQUEST[$key_name] : false;
             track_request($key_name, $required, $default);
         }
         return $data;
     }
     if ($required && (!isset($_REQUEST[$key]) || empty($_REQUEST[$key]))) {
         _die("{$key} field is required field.");
     }
     if (!is_null($default) && !isset($_REQUEST[$key])) {
         $_REQUEST[$key] = $default;
     }
     return isset($_REQUEST[$key]) ? $_REQUEST[$key] : false;
 }