コード例 #1
0
ファイル: r_f.php プロジェクト: aiurlano/mAdserve-Fork
function select_adunit_query($campaign_id)
{
    global $zone_detail;
    switch ($zone_detail['zone_type']) {
        case 'banner':
            $query_part['size'] = "AND adv_width<=" . $zone_detail['zone_width'] . " AND adv_height<=" . $zone_detail['zone_height'] . "";
            break;
        case 'interstitial':
            if (MAD_INTERSTITIALS_EXACTMATCH) {
                $query_part['size'] = "AND adv_width=320 AND adv_height=480";
            } else {
                $query_part['size'] = "AND adv_width<=320 AND adv_height<=480";
            }
            break;
    }
    $query = "SELECT adv_id, adv_height, adv_width FROM md_ad_units WHERE campaign_id='" . $campaign_id . "' AND adv_status=1 " . $query_part['size'] . " ORDER BY adv_width DESC, adv_height DESC";
    $cache_result = get_cache($query);
    if ($cache_result) {
        return $cache_result;
    }
    global $maindb;
    $adarray = array();
    $usrres = mysql_query($query, $maindb);
    while ($ad_detail = mysql_fetch_array($usrres)) {
        $add = array('ad_id' => $ad_detail['adv_id'], 'width' => $ad_detail['adv_width'], 'height' => $ad_detail['adv_height']);
        array_push($adarray, $add);
    }
    if ($total_ads_inarray = count($adarray) < 1) {
        return false;
    }
    /*foreach ($adarray as $key => $row) {
          $ad_id[$key]  = $row['ad_id'];
          $width[$key] = $row['width'];
          $height[$key] = $row['height'];
      }*/
    // Sort the data with volume descending, edition ascending
    // Add $data as the last parameter, to sort by the common key
    //array_multisort($width, SORT_DESC, $adarray);
    $highest_height = $adarray[0]['height'];
    $highest_width = $adarray[0]['width'];
    $val = removeElementWithValue2($adarray, "height", $highest_height, "width", $highest_width);
    set_cache($query, $val, 100);
    return $val;
}
コード例 #2
0
ファイル: r_f.php プロジェクト: liulingfu/madserve
function select_adunit_query($campaign_id)
{
    global $zone_detail;
    global $request_settings;
    switch ($zone_detail['zone_type']) {
        case 'banner':
            $query_part['size'] = "AND adv_width<=" . $zone_detail['zone_width'] . " AND adv_height<=" . $zone_detail['zone_height'] . "";
            break;
        case 'interstitial':
            if (MAD_INTERSTITIALS_EXACTMATCH) {
                $query_part['size'] = "AND adv_width=320 AND adv_height=480";
            } else {
                $query_part['size'] = "AND adv_width<=320 AND adv_height<=480";
            }
            break;
    }
    error_reporting(E_ALL);
    // if latitude and longitude are there in request, join locations table also
    if (is_numeric($request_settings['cLat']) && is_numeric($request_settings['cLog'])) {
        $lat = $request_settings['cLat'];
        $lon = $request_settings['cLog'];
        $query = "SELECT DISTINCT ad_unit.adv_id, ad_unit.adv_height, ad_unit.adv_width FROM md_ad_units ad_unit LEFT JOIN md_ad_unit_to_locations location ON (ad_unit.adv_id = location.adv_id) WHERE campaign_id='" . $campaign_id . "' AND adv_status=1 " . $query_part['size'] . " AND adv_location_bound_lat_min <= {$lat} AND adv_location_bound_lat_max >= {$lat} AND adv_location_bound_lon_min <= {$lon} AND adv_location_bound_lon_max >= {$lon} ORDER BY adv_width DESC, adv_height DESC";
    } else {
        $query = "SELECT adv_id, adv_height, adv_width FROM md_ad_units WHERE campaign_id='" . $campaign_id . "' AND adv_status=1 " . $query_part['size'] . " ORDER BY adv_width DESC, adv_height DESC";
    }
    $cache_result = get_cache($query);
    if ($cache_result) {
        return $cache_result;
    }
    global $maindb;
    $adarray = array();
    $usrres = mysql_query($query, $maindb);
    while ($ad_detail = mysql_fetch_array($usrres)) {
        $add = array('ad_id' => $ad_detail['adv_id'], 'width' => $ad_detail['adv_width'], 'height' => $ad_detail['adv_height']);
        array_push($adarray, $add);
    }
    if ($total_ads_inarray = count($adarray) < 1) {
        return false;
    }
    /*foreach ($adarray as $key => $row) {
        $ad_id[$key]  = $row['ad_id'];
        $width[$key] = $row['width'];
        $height[$key] = $row['height'];
    }*/
    // Sort the data with volume descending, edition ascending
    // Add $data as the last parameter, to sort by the common key
    //array_multisort($width, SORT_DESC, $adarray);
    $highest_height = $adarray[0]['height'];
    $highest_width = $adarray[0]['width'];
    $val = removeElementWithValue2($adarray, "height", $highest_height, "width", $highest_width);
    set_cache($query, $val, 100);
    return $val;
}