addServer("192.168.30.51", self::$port); self::$instance->addServer("127.0.0.1", self::$port); } return self::$instance; } } $block_spotx = "0"; $show_companion = 0; if(isset($_GET['vsl']) && $_GET['vsl'] == "1"){ //called from vslider. show companion banner $show_companion = "1"; $apnx_placement_id = "1419620"; //default if affiliate doesnot have appnexus mapping } // Replace injection_ with ac_ $affId = str_replace("injection_", "ac_", $affId); if(stripos($affId, "44147") !== false){ $fbo_vertical = ",fbov"; } /* //do not load liverail for injection and exe if(stripos($affId, "injection") !== false || stripos($affId, "ac_") !== false || stripos($affId, "exe") !== false){ $load_liverail = "0"; } */ //05/20/2013: Always load liverail as primary source and backfill to adap, for everything (injection too!) $load_liverail = "1"; //disable liverail on https $ssl = "http"; if(trim($_SERVER['HTTPS']) != '' && $_SERVER['SERVER_PORT'] == 443){ $ssl = "https"; } $mute = 0; if($_GET['novol'] == "1") $mute = 1; //pass LR_URL to prevent picking up usadserver as referrer /* if(trim($_GET['wrd'])){ // if(stripos($_GET['wrd'], "%3A%2F%2F") !== false) //double encoded // $lr_url = urldecode($_GET['wrd']); // else // $lr_url = $_GET['wrd']; //this is always encrypted and double encoding issue is prevented by adding www. to iframe call $lr_url = decrypt_mcrypt(trim($_GET['wrd'])); } else $lr_url = "http://www.cheapstuff.com/"; */ //do not use wrd anymore since we are load balancing on usadserver level and wrd has the original domain if( isset($_SERVER['HTTPS'] ) ) { $lr_url = "https://".$_SERVER['HTTP_HOST']; } else{ $lr_url = "http://".$_SERVER['HTTP_HOST']; } //some domains have trailing . $lr_url = rtrim($lr_url, "."); $rand = rand(1,10); $ref = ''; if(true || $rand <= 2) //pass actual referer upstram always for spotxchange { if(isset($_GET['ref']) && trim($_GET['ref']) != ''){ //decoded Get['ref'] still has encoded :// if(stripos($_GET['ref'], "%3A%2F%2F") !== false) $ref = urldecode($_GET['ref']); else $ref = $_GET['ref']; } else if(isset($_GET['enr']) && trim($_GET['enr']) != ''){ //encrypted referrer and double encoding issue is prevented by adding www. to iframe call $ref = decrypt_mcrypt(trim($_GET['enr'])); } else{ $block_spotx = "1"; $ref = $_SERVER['HTTP_REFERER']; } if(stristr($ref, "dailymotion.com") || stristr($ref, "vimeo.com") || stristr($ref, "craigslist") || stristr($ref, "wikipedia.org")) die(); include_once 'lib/php/api/adsafe/api.php'; $ad_safe = new _AdSafe(); $url = parse_url($ref, PHP_URL_HOST); if(!$ad_safe->isSafe($url)){ die(); } } else { $ref = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; if(isset($_GET['ref']) && trim($_GET['ref']) != '') $actualRef = $_GET['ref']; else $actualRef = urlencode($_SERVER['HTTP_REFERER']); if(stristr($actualRef, "dailymotion.com") || stristr($actualRef, "vimeo.com")) die(); } //echo $ref; //block spotx if sxch=1 if(isset($_GET['sxch'])) $block_spotx = "1"; //For showing content after preroll for Yashi and Spotx $content_target = "0"; if(isset($_GET['vid']) && $_GET['vid'] == "1"){ $content_target = "1"; } //Called from image advantage wrapper. Do spotx check on referrer if(isset($_GET['iad']) && $_GET['iad'] == "1" && $ref){ //if adsafe approved for preroll, check for spotxchage blacklist //host check $dom = parse_url($ref, PHP_URL_HOST); if(!$dom) $dom = $ref; $dom_mod = str_ireplace("www.", "", $dom); $sql = "SELECT * FROM `rep_spotx_blocked` where url like '$dom%' OR url like '$dom_mod%' OR INSTR('$dom', url)>0 limit 1"; $mkey = md5("spotx1_{$sql}"); if(!$spotx_blocked = mCachedb::mGet()->get($mkey)){ $db = ConnectToRead(); $sRes = mysql_query($sql, $db); if(mysql_num_rows($sRes)>0){ $spotx_blocked = "TRUE"; } else{ $spotx_blocked = "FALSE"; } mCachedb::mGet()->set($mkey, $spotx_blocked, 0, 24*60*60*2); mysql_close($db); } if($spotx_blocked == "TRUE") $block_spotx = "1"; } $prodType = 'overlay'; $affNum = ''; /*if(strpos($affId, "_")) { $affId_ex = explode("_", $affId); $prodType = trim($affId_ex[0]); $affNum = trim($affId_ex[1]); } else $affNum = $affId;*/ if(stripos($affId, "_") !== false){ $affId_ex = explode("_", $affId); $p = trim($affId_ex[0]); if($p == 'overlay') $product = 'o'; else if($p == 'inline') $product = 'i'; else if($p == 'footerroll') $product = 'f'; else if($p == 'serp') $product = 's'; else if($p == 'vslider') $product = 'v'; else if($p == 'videosense' || $p == 'vsense') $product = 'd'; else if($p == 'ac' || $p == 'injection') $product = 'a'; else $product = $p; } else{ $product="unknown-$affId"; } $anyclipEn = 1; $adapCutoff = 15; $preAff = ""; if(strpos($affId, "_")) { $affId_ex = explode("_", $affId); $affNum = trim($affId_ex[1]); $preAff = trim($affId_ex[0]); if($affNum != '' && is_numeric($affNum)) { class mCache extends Memcache { static private $instance = null; static private $port = 11211; static function mGet() { if(self::$instance == null) { self::$instance = new Memcache; self::$instance->addServer('192.168.30.51', self::$port); } return self::$instance; } } $mkey_new = "anyClipData_".md5($affNum); $expire = 900; if(!$anyClipArr = mCache::mGet()->get($mkey_new)) { include_once("lib/php/include/db.php"); $db = ConnectToRead(); $aSql = "select a.anyclip, a.adap_cutoff from Affiliate a right join AffiliateIDs aid on (a.name = aid.Affiliate) where aid.id = {$affNum}"; $aRes = mysql_query($aSql, $db); if($aRes) { $aRow = mysql_fetch_assoc($aRes); if($aRow && $aRow['anyclip'] != '') { $anyclipEn = $aRow['anyclip']; $adapCutoff = $aRow['adap_cutoff']; } } $anyClipArr = array($anyclipEn, $adapCutoff); mCache::mGet()->set($mkey_new, $anyClipArr, 0, $expire); mysql_close($db); } else { $anyclipEn = $anyClipArr[0]; $adapCutoff = $anyClipArr[1]; } //get appnexus id from companion banner if($show_companion){ $sql = "SELECT r.Placements from AffiliateIDs ai, rep_publisher_placement r where ai.appnexus_id=r.id and ai.id=$affNum"; $key = md5($sql); if(!$apnxsTagId = mCache::mGet()->get($key)){ $db = ConnectToRead(); $res = mysql_query($sql, $db); while($row = mysql_fetch_array($res)){ $apnxsTagId = $row['Placements']; } mysql_close($db); mCache::mGet()->set($key, $apnxsTagId, 0, 900); } if($apnxsTagId != '') { if(stristr($apnxsTagId,",")){ $apnxsTagId_array = explode(",",$apnxsTagId); if(is_array($apnxsTagId_array) && count($apnxsTagId_array)>0){ shuffle($apnxsTagId_array); $apnxsTagId = $apnxsTagId_array[0]; } } $apnx_placement_id = $apnxsTagId; } } //check if injection or exe affiliate $sql = "SELECT * from AffiliateIDs where id=".addslashes($aid); $vkey = md5($sql); if(!$is_inj = mCache::mGet()->get($vkey)){ $db = ConnectToRead(); $res = mysql_query($sql, $db); mysql_close($db); $is_inj = "FALSE"; if($res) { while ($row = mysql_fetch_assoc($res)) { if(stripos($row['Affiliate'], "injection") || stripos($row['Affiliate'], "exe")){ $is_inj = "TRUE"; } } } mCache::mGet()->set($vkey, $is_inj, 0, 24*60*60*3); } } } $adapCutoff = intval($adapCutoff * 1000); $adSafePubId = "preroll_".$affNum; $adSafeCmpId = $preAff; // double check spotx blocked ref - $ref if($block_spotx == "0"){ $blockedVal = 0; $ref_dom = parse_url($ref, PHP_URL_HOST); if(!$ref_dom) $ref_dom = $ref; $ref_dom_mod = str_ireplace("www.", "", $ref_dom); $sql = "SELECT * FROM rep_spotx_blocked where url like '%$ref%' OR url like %$ref_dom%' OR url like '%$ref_dom_mod%' OR INSTR('$ref', url)>0 limit 1"; $mkey = md5("spotx_vs_{$sql}"); $expire = 900; if(!$blockedArr = mCachedb::mGet()->get($mkey)) { $db = ConnectToRead(); $res = mysql_query($sql, $db); if($res) { $row = mysql_fetch_assoc($res); if($row && trim($row['url']) != '') $blockedVal = 1; } $blockedArr = array($blockedVal); mCachedb::mGet()->set($mkey, $blockedArr, 0, $expire); mysql_close($db); } else $blockedVal = $blockedArr[0]; if($blockedVal == 1) $block_spotx = "1"; } //Block search.yahoo.com, bing.com and google.com from spotxchange if(stripos($ref, "yahoo.com")!==false || stripos($ref, "bing.com")!==false || stripos($ref, "google.com")!==false) $block_spotx = "1"; if($block_spotx == "1" || $_GET['yt'] == "1" || $ref == ""){ $lr_tags = "blockspot,wrad"; } else $lr_tags = "wrad"; if($content_target == "1") $lr_tags .= ",playvid"; if($_GET['yt'] == "1") $lr_tags .= ",yt"; if($is_inj == "TRUE") $lr_tags .= ",nolrc"; if($ssl == "http") $liverail_url = "http://cdn-static.liverail.com"; else $liverail_url = "https://cdn-static-secure.liverail.com"; //get video function getVideo(){ //get video $sql = "select * from rep_videos"; $vkey = md5($sql."1"); if(!$vids = mCachedb::mGet()->get($vkey)){ $db = ConnectToRead(); $res = mysql_query($sql, $db); mysql_close($db); $vids = array(); if($res) { while ($row = mysql_fetch_assoc($res)) { if($row['id'] < 10) $row['id'] = "00".$row['id']; else if($row['id'] >= 10 && $row['id'] < 100) $row['id'] = "0".$row['id']; else $row['id'] = $row['id']; $vids[] = array("id"=>$row['id'], "title"=>$row['title'], "description"=>$row['description'], "category"=>$row['keywords']); } if(!empty($vids)) mCachedb::mGet()->set($vkey, $vids, 0, 24*60*60); } } if(count($vids)>0){ $rand_key = array_rand($vids); $video = $vids[$rand_key]; //$video_url = "http://s.colo.com/$vid.mp4"; } return $video; } $video = getVideo(); $vid = $video['id']; $video_url = $ssl."://s.colo.com/$vid.mp4"; $video_title = $video['title']; $video_desc = $video['description']; $video_category = str_ireplace("gadx", "", $video['category']); //coull tags require video category. function getLRID($aid){ $aid = addslashes($aid); $aSql = "select lr_id from AffiliateIDs where id = {$aid} limit 1"; $mkey = 'aff_lrid_'.md5($aid); $expire = 60*20; if(!$aff_lrid = mCachedb::mGet()->get($mkey)){ $db = ConnectToRead(); $aRes = mysql_query($aSql, $db); if($aRes){ $aRow = mysql_fetch_assoc($aRes); if($aRow && $aRow['lr_id'] != ''){ $aff_lrid = $aRow['lr_id']; if($aff_lrid > 0) mCachedb::mGet()->set($mkey, $aff_lrid, 0, $expire); else mCachedb::mGet()->set($mkey, "NONE000", 0, $expire); } } mysql_close($db); } if(!is_numeric($aff_lrid)){ $aff_lrid = 0; } return intval($aff_lrid); } $liverail_publisher_id = getLRID($affNum); if(!$liverail_publisher_id){ $liverail_publisher_id = 109659; } if($_GET['lr_test'] == "1") $liverail_publisher_id = "1331"; $video_subdomain = "video.".str_ireplace("www.", "", $_SERVER['HTTP_HOST']); ?>
/js/LiveRail.Interstitial-1.0.js?LR_PUBLISHER_ID=&width=&height=&LR_URL=&align=vertical&LR_VERTICALS=wrad&LR_AUTOPLAY=1&LR_VIDEO_AMID=&LR_LAYOUT_SKIN_ID=2&volume=0&LR_CUSTOM1=&target=flowplayer_preroll&LR_COMPANIONS=300:250:modal_videoAd_wrapper&LR_TAGS=&LR_VIDEO_ID=&LR_VIDEO_URL=&LR_TITLE=&LR_DESCRIPTION=&LR_CUSTOM2="> */ ?> &pubId="> */ ?> &pubId="> */ ?>