356
[1] => Hand-Guns
[2] => 3582
[3] => Para-1911-Expert-45acp-2-12-9.html
*/
$bzone = $extract_bzone[0];
}
elseif ((!is_numeric($extract_bzone[1])) && (is_numeric($extract_bzone[2]))) {
/*
[0] => Italy-regional-travel-tourist-resources
[1] => tip
[2] => 251
[3] => Weather-condition-forecast-in-Tuscany-and-Italy.html
*/
$bzone = $extract_bzone[2];
}
elseif ((!is_numeric($extract_bzone[1])) && (is_numeric(preg_replace('/[^0-9]/i','', $extract_bzone[2])))) {
/*
[0] => trip
[1] => incoming-Italy
[2] => 206.htm
*/
$bzone = preg_replace('/[^0-9]/i','', $extract_bzone[2]);
}
}
}
if (empty($bzone)) { $bzone = "default"; }
$gborder = (empty($gborder)) ? "1px" : "$gborder" . "px";
$gpos = (empty($gpos)) ? "center" : "$gpos";
if (($bf == "showad") || ($bfunction == "showad")) { searchads($db_link,$uid,$bzone,$bzone2,$bsize,$btype,$bpos,$btarget,$bborder,$brefresh,$dayofweek,$today,$ipaddress,$bmode,$bstyle,$gwidth,$gheight,$tborder,$cpadding,$bocolor,$bocolorlight,$bocolordark,$gborder,$gpos,$brows,$bcolumns,$gspacing,$colheight,$bexclusive,$btotal,$bsortcolumn,$banner_url_lb); }
elseif (($bf == "fetchad") || ($bfunction == "fetchad")) { fetchad($db_link,$uid,$cid,$aid,$bsize,$bzone,$atype); }
elseif (($bfunction == "clickad") || ($bf == "go")) { clickbanner($db_link,$uid,$bzone,$bsize,$btype,$bpos,$cid,$aid,$today,$ipaddress,$transferurl); }
elseif (($bf == "trackformad") || ($bfunction == "trackformad")) { click_rm_banner($db_link,$uid,$bzone,$bsize,$btype,$bpos,$campaignid,$adno,$ipaddress); }
exit(0);
function searchads($db_link,$uid,$bzone,$bzone2,$bsize,$btype,$bpos,$btarget,$bborder,$brefresh,$dayofweek,$today,$ipaddress,$bmode,$bstyle,$gwidth,$gheight,$tborder,$cpadding,$bocolor,$bocolorlight,$bocolordark,$gborder,$gpos,$brows,$bcolumns,$gspacing,$colheight,$bexclusive,$btotal,$bsortcolumn,$banner_url_lb) {
global $timestamp, $hour, $HTTP_USER_AGENT;
$ssl_enabled = detectssl();
$load_ad = false;
$format_zone = preg_replace('/[^A-Za-z0-9\-]/', '', $bzone);
$session_index_name = "adpool-$uid-$format_zone-$bsize";
$session_index_seq = "seq-$uid-$format_zone-$bsize";
$session_index_nextad = "nextad-$uid-$format_zone-$bsize";
$session_companion_ad = "companion-$uid";
if (($bmode == "order") && (!$_SESSION[$session_index_name]) && (!$_SESSION[$session_index_seq]) && (!$_SESSION[$session_index_nextad])) {
$preload_array = explode('|', preload_ads($db_link,$uid,$bsize,$bzone,$today,$dayofweek,$ipaddress,$bmode,$btotal));
list($load_ad['cid'],$load_ad['aid']) = explode(':', $preload_array[1]);
$_SESSION[$session_index_seq] = "$preload_array[0]";
$_SESSION[$session_index_nextad] = "2";
} elseif (($bmode == "order") && ($_SESSION[$session_index_name]) && ($_SESSION[$session_index_seq]) && ($_SESSION[$session_index_nextad])) {
$linearray = explode('-', $_SESSION[$session_index_name]);
$sess_seq = $_SESSION[$session_index_nextad];
foreach ($linearray as $value) {
list($seqno,$campaignid,$adno) = explode(':', $value);
if ($seqno == "$sess_seq") { $load_ad['cid'] = "$campaignid"; $load_ad['aid'] = "$adno"; }
}
$_SESSION[$session_index_nextad] = ($sess_seq >= $_SESSION[$session_index_seq]) ? "1" : $_SESSION[$session_index_nextad] + 1;
}
$cid_load = (isset($load_ad['cid'])) ? $load_ad['cid'] : false;
$aid_load = (isset($load_ad['aid'])) ? $load_ad['aid'] : false;
$result = mysqli_query($db_link,construct_query($db_link,$uid,$bsize,$bzone,$btype,$today,$dayofweek,1,$btotal,$cid_load,$aid_load)) or die(mysqli_error($db_link).__LINE__);
$matches = (mysqli_num_rows($result) > 0) ? mysqli_num_rows($result) : "0";
// if preloaded ad not available, clear session
if (($matches == "0") && (!empty($load_ad['cid'])) && (!empty($load_ad['aid']))) {
unset($_SESSION[$session_index_nextad]);
unset($_SESSION[$session_index_seq]);
unset($_SESSION[$session_index_name]);
}
if ($matches == "0") {
$ad_base_query = ($bsize != "text") ? "SELECT SQL_NO_CACHE a.accno, a.campaignid, a.adno, a.ad_size, a.ad_title, a.ad_linkunder, a.ad_mouseover, a.ad_playsound, a.ad_weight, a.ad_autoweight, a.ad_banner, a.ad_type, a.remote_banner, a.ad_bannertext, a.ad_url, a.impressions, a.clicks, settings.banner_url, c.record_id ip_record_id, d.record_id stats_record_id" : "SELECT SQL_NO_CACHE a.accno, a.campaignid, a.adno, a.ad_title, a.ad_txtfont, a.ad_txtsize, a.ad_txtsetting, a.ad_mouseover, a.ad_playsound, a.ad_weight, a.ad_autoweight, a.ad_bannertext, a.ad_url, a.ad_keywords, a.impressions, a.clicks, settings.banner_url, c.record_id ip_record_id, d.record_id stats_record_id";
$ad_base_query .= (" FROM `adpeeps_ads` a LEFT JOIN `adpeeps_settings` AS settings ON a.accno=settings.accno");
$ad_base_query .= (" LEFT JOIN `adpeeps_statisticsiplog` AS c ON a.accno=c.accno AND a.campaignid=c.campaignid AND a.adno=c.adno AND c.showdate='$today' AND c.type = 'i' AND c.ipaddress='$ipaddress'");
$ad_base_query .= (" LEFT JOIN `adpeeps_statistics` AS d ON d.accno=a.accno AND d.campaignid=a.campaignid AND d.adno=a.adno AND d.index_date=a.index_date AND d.index_date = '$today' AND d.showdate BETWEEN '$today $hour:00:00' AND '$today $hour:59:59'");
$ad_base_query .= (" WHERE a.accno = '$uid' AND a.ad_default = '1' AND a.adstatus = '1' AND a.campaignstatus = '1'");
$ad_base_query .= ($bsize == "all") ? "AND a.ad_size != 'text'" : "AND a.ad_size='$bsize'";
$result = mysqli_query($db_link, "$ad_base_query") or die(mysqli_error($db_link).__LINE__);
$matches = (mysqli_num_rows($result) > 0) ? mysqli_num_rows($result) : "0";
if ($btype == "1" && $matches == "0") {
echo chr(0x47).chr(0x49).chr(0x46).chr(0x38).chr(0x39).chr(0x61).chr(0x01).chr(0x00).
chr(0x01).chr(0x00).chr(0x80).chr(0x00).chr(0x00).chr(0x04).chr(0x02).chr(0x04).
chr(0x00).chr(0x00).chr(0x00).chr(0x21).chr(0xF9).chr(0x04).chr(0x01).chr(0x00).
chr(0x00).chr(0x00).chr(0x00).chr(0x2C).chr(0x00).chr(0x00).chr(0x00).chr(0x00).
chr(0x01).chr(0x00).chr(0x01).chr(0x00).chr(0x00).chr(0x02).chr(0x02).chr(0x44).
chr(0x01).chr(0x00).chr(0x3B);
}
}
if ((!empty($brows)) && ($brows > 0) && (!empty($bcolumns)) && ($bcolumns > 0)) {
$btotal = (($brows * $bcolumns) >= $matches) ? "$matches" : ($brows * $bcolumns);
$brefresh = false;
}
elseif ((empty($btotal)) && ($brefresh >= 1) && ($btype != "4")) { $btotal = "$matches"; }
elseif ((empty($btotal)) && ($brefresh >= 1) && ($btype == "4")) { $btotal = "1"; }
elseif (empty($btotal)) { $btotal = "1"; }
/// fetch all eligible ads, randomly place in order, select all up to btotal limit
if ($matches > 0) {
$weight_array = "";
$weightlist = array();
$multiplier = array('200' => "5",'100' => "4",'50' => "3",'10' => "2",'1' => "1");
srand((double)microtime() * 1000000);
$rand_num = rand() % 1000000 . "$btotal" . "$bsize";
while($row = mysqli_fetch_assoc($result)) {
$banner_url = (empty($banner_url_lb)) ? "$row[banner_url]" : "$banner_url_lb";
$banner_url = ($ssl_enabled) ? preg_replace('/http:/i', 'https:', "$banner_url") : "$banner_url";
$aid = "$row[accno]";
$campaignid = "$row[campaignid]";
$adno = "$row[adno]";
$adsize = ($bsize != "text") ? "$row[ad_size]" : "text";
$ad_title = (isset($row['ad_title'])) ? htmlspecialchars(stripslashes($row['ad_title']), ENT_QUOTES) : false;
$ad_linkunder = (isset($row['ad_linkunder'])) ? $row['ad_linkunder'] : false;
$ad_banner = (isset($row['ad_banner'])) ? $row['ad_banner'] : false;
$ad_type = (isset($row['ad_type'])) ? $row['ad_type'] : false;
$remote_banner = ((!empty($row['remote_banner'])) && ($ssl_enabled) && (preg_match('/uploaded_banners\//', $row['remote_banner']))) ? preg_replace('/http:/i', 'https:', $row['remote_banner']) : "$row[remote_banner]";
$ad_bannertext = (isset($row['ad_bannertext'])) ? stripslashes($row['ad_bannertext']) : false;
if ($bsize == "text") {
$ad_bannertext = htmlspecialchars(str_replace("\n", "", $ad_bannertext), ENT_QUOTES);
$ad_bannertext = str_replace("\r", "
", $ad_bannertext);
}
$ad_txtfont = (isset($row['ad_txtfont'])) ? $row['ad_txtfont'] : false;
$ad_txtsize = (isset($row['ad_txtsize'])) ? $row['ad_txtsize'] : false;
$ad_txtsetting = (isset($row['ad_txtsetting'])) ? $row['ad_txtsetting'] : false;
$ad_displayurl = (isset($row['ad_keywords'])) ? $row['ad_keywords'] : false;
$ad_mouseover = (isset($row['ad_mouseover'])) ? addslashes($row['ad_mouseover']) : false;
$ad_playsound = (isset($row['ad_playsound'])) ? $row['ad_playsound'] : false;
$ad_autoweight = (isset($row['ad_autoweight'])) ? $row['ad_autoweight'] : false;
$aux_flexfield = (isset($row['aux_flexfield'])) ? $row['aux_flexfield'] : false;
$ad_weight = "$row[ad_weight]";
$ad_url = (isset($row['ad_url'])) ? $row['ad_url'] : false;
$impressions = "$row[impressions]";
$clicks = "$row[clicks]";
$ad_transparent = "$row[ad_transparent]";
$ad_companion = "$row[ad_companion]";
$lastdateshown = "$row[index_date]";
$ip_stats_record_id = "$row[ip_record_id]";
$stats_record_id = "$row[stats_record_id]";
$filter_spider_robot = "$row[filter_spider_robot]";
$country_code = "$row[country_code2]";
$country_name = "$row[country_name]";
$city = "$row[city]";
$state = "$row[state]";
$zone_order = "$row[zone_order]";
$campanion_sort = "$row[campanion_sort]";
if (($bmode !="noweight") && (!in_array("$ad_weight", $weightlist))) {
$weightlist[] = "$ad_weight";
$weight_array .= str_repeat("$ad_weight ", $multiplier[$ad_weight]);
}
// place all returned ads inside an array
$adlist[] = array('campanion_sort' => "$campanion_sort",'zone_sort' => "$zone_order",'ad_title' => "$ad_title",'aid' => "$aid",'campaignid' => "$campaignid",'adno' => "$adno",'adsize' => "$adsize", 'ad_linkunder' => "$ad_linkunder", 'ad_banner' => "$ad_banner", 'ad_type' => "$ad_type", 'remote_banner' => "$remote_banner",'ad_bannertext' => "$ad_bannertext",'ad_txtfont' => "$ad_txtfont",'ad_txtsize' => "$ad_txtsize",'ad_displayurl' => "$ad_displayurl",'ad_mouseover' => "$ad_mouseover",'ad_playsound' => "$ad_playsound",'ad_weight' => "$ad_weight",'ad_autoweight' => "$ad_autoweight",'aux_flexfield' => "$aux_flexfield",'ad_url' => "$ad_url",'impressions' => "$impressions", 'clicks' => "$clicks", 'ad_transparent' => "$ad_transparent", 'ad_companion' => "$ad_companion", 'lastdateshown' => "$lastdateshown", 'country_code' => "$country_code", 'country_name' => "$country_name", 'city' => "$city", 'state' => "$state", 'ip_stats_record_id' => "$ip_stats_record_id", 'stats_record_id' => "$stats_record_id");
// place all eligible ads inside an array
} // end mysql while statement
mysqli_free_result($result);
// more than one possible weight, start weighting functions
if (count($weightlist) > 1) {
unset($weightlist);
$array = explode(" ", trim($weight_array));
$pickweight = array_rand($array, 1);
sortBySubkey($adlist, false, $array[$pickweight]);
}
// more than one possible weight, start weighting functions
shuffle($adlist); // shuffle all eligible ads fecthed from database
// check for spider/rebot
if (($filter_spider_robot == "1") && (!empty($HTTP_USER_AGENT)) && (!isset($_SESSION['scheck']))) {
$robot_spider_check = mysqli_query($db_link, "SELECT ref_id FROM `adpeeps_excluded_robots` WHERE LOCATE(search_string,'$HTTP_USER_AGENT') > 0") or die(mysqli_error($db_link).__LINE__);
if (mysqli_num_rows($robot_spider_check) > 0) {
$norecord = 1;
$_SESSION['scheck'] = "1";
while($spider_row = mysqli_fetch_assoc($robot_spider_check)) {
mysqli_query($db_link, "UPDATE adpeeps_excluded_robots SET access_count = access_count+1, last_update_date = '$timestamp' WHERE ref_id = '$spider_row[ref_id]'") or die(mysqli_error($db_link).__LINE__);
}
} else {
$_SESSION['scheck'] = "0";
}
} elseif (($filter_spider_robot == "1") && (isset($_SESSION['scheck']))) {
$norecord = "$_SESSION[scheck]";
}
// check for spider/rebot
if ($bexclusive == "1") {
$array_count = count($adlist);
for($y=0; $y<$array_count; $y++) {
extract($adlist[$y], EXTR_OVERWRITE);
// place all eligible ads inside an array
$adlist_group[$campaignid] = array('ad_title' => "$ad_title",'aid' => "$aid",'campaignid' => "$campaignid",'adno' => "$adno",'adsize' => "$adsize", 'ad_linkunder' => "$ad_linkunder", 'ad_banner' => "$ad_banner", 'ad_type' => "$ad_type", 'remote_banner' => "$remote_banner",'ad_bannertext' => "$ad_bannertext",'ad_txtfont' => "$ad_txtfont",'ad_txtsize' => "$ad_txtsize",'ad_displayurl' => "$ad_displayurl",'ad_mouseover' => "$ad_mouseover",'ad_playsound' => "$ad_playsound",'ad_weight' => "$ad_weight",'ad_autoweight' => "$ad_autoweight",'ad_autoweight' => "$ad_autoweight",'ad_url' => "$ad_url",'impressions' => "$impressions", 'clicks' => "$clicks", 'ad_transparent' => "$ad_transparent", 'ad_companion' => "$ad_companion", 'lastdateshown' => "$lastdateshown", 'country_code' => "$country_code", 'country_name' => "$country_name", 'city' => "$city", 'state' => "$state", 'ip_stats_record_id' => "$ip_stats_record_id", 'stats_record_id' => "$stats_record_id");
// place all eligible ads inside an array
}
unset($adlist); // delete orginial ad list array
$adlist = $adlist_group; // rename grouped array to name of original array
shuffle($adlist); // reshuffle array one last time
}
// sort text links A-Z if enabled or by zone order if using autodetect
if (!empty($bsortcolumn)) {
sortBySubkey($adlist, "$bsortcolumn", false);
} elseif (!empty($bzone2)) {
sortBySubkey($adlist, 'zone_sort', false);
} elseif (isset($_SESSION[$session_companion_ad])) {
sortBySubkey($adlist, 'campanion_sort', false);
}
$matches = (count($adlist) >= $btotal) ? "$btotal" : count($adlist);
static $print_once = false;
$order = 0;
for ($i = 0; $i < $matches && $i < $btotal; ++$i) {
extract($adlist[$i], EXTR_OVERWRITE);
++$order;
if ((!isset($_SESSION[$session_companion_ad])) && ($ad_companion == "Y")) {
$_SESSION[$session_companion_ad] = array('campaignid' => "$campaignid", 'expires' => time()+5);
}
$ads[$order] = showbanner($db_link,$uid,$bzone,$adsize,$btype,$bpos,$btarget,$bborder,$brefresh,$dayofweek,$today,$banner_url,$ipaddress,$bmode,$bstyle,$gwidth,$gheight,$gborder,$gpos,$campaignid,$adno,$ad_title,$ad_linkunder,$ad_banner,$ad_type,$remote_banner,$ad_bannertext,$ad_url,$ad_txtfont,$ad_txtsize,$ad_txtsetting,$ad_displayurl,$ad_mouseover,$ad_playsound,$ad_transparent,$order,$matches,$rand_num,$country_code,$country_name,$city,$state);
if ($norecord != "1") { record_data($db_link,$uid,$ipaddress,$bzone,$bsize,$btype,$bpos,$campaignid,$adno,$ad_url,'impression',$ad_weight,$ad_autoweight,$impressions,$clicks,$lastdateshown,$ip_stats_record_id,$stats_record_id,$country_code,$country_name,$city,$state,$order,$matches); }
} # Close FOR Loops
unset($adlist);
$ini_adcount = 0;
// If showing ads in columns/rows this code will create the table template and store value in $html_out
if ((!empty($brows)) && ($brows > 0) && (!empty($bcolumns)) && ($bcolumns > 0)) {
$html_out .= "
1
} # Close Function
function showbanner($db_link,$uid,$bzone,$bsize,$btype,$bpos,$btarget,$bborder,$brefresh,$dayofweek,$today,$banner_url,$ipaddress,$bmode,$bstyle,$gwidth,$gheight,$gborder,$gpos,$campaignid,$adno,$ad_title,$ad_linkunder,$ad_banner,$ad_type,$remote_banner,$ad_bannertext,$ad_url,$ad_txtfont,$ad_txtsize,$ad_txtsetting,$ad_displayurl,$ad_mouseover,$ad_playsound,$ad_transparent,$order,$matches,$rand_num,$country_code,$country_name,$city,$state) {
global $theme_border, $theme_borderstyle, $theme_background, $theme_color, $tagline, $tagline_bgcolor, $tagline_fontcolor, $tagline_font, $tcolor, $textcolor, $lcolor, $colwidth, $colheight, $print_once;
if ($order == "1") {
$html_out = false;
}
// pick random theme
if (empty($theme_border) || empty($theme_borderstyle) || empty($theme_background)) {
$theme_border = array("#ffcc33","#b4b0dc","#a8dda0","#8d8d8d");
$theme_borderstyle = array("solid","solid","solid","dotted");
$theme_background = array("#fcf9d7","#ecf8ff","#FFFF66","#eeeee5");
$theme_color = array("#616161","#616161","#616161","#000000");
$theme_count = count($theme_border);
}
$themeset = rand(0,$theme_count - 1);
$google_border = $theme_border[$themeset];
$google_background = $theme_background[$themeset];
$google_color = $theme_color[$themeset];
$google_style = $theme_borderstyle[$themeset];
// pick random theme
$transparent = ($ad_transparent == "1") ? "transparent" : false;
if ($bsize != "text") {
// ini flash link
$movie_url = (!empty($remote_banner)) ? "$remote_banner" : "$banner_url" . "/adpeeps.php?bf=fetchad&uid=$uid&cid=$campaignid&aid=$adno&atype=1&bzone=$bzone&bsize=$bsize";
$movie_url .= (strrchr(strtolower($movie_url),'.') == ".swf") ? "?" : "&";
if ((!empty($ad_url)) && (substr(strtolower("$ad_url"), 0, 9) == "clicktag=")) {
$movie_url .= substr("$ad_url", 0, 9) . "$banner_url" . "/adpeeps.php" . "%3F" . "bf=go%26uid=$uid%26bzone=$bzone%26bsize=$bsize%26btype=$btype%26bpos=$bpos%26cid=$campaignid%26aid=$adno";
} elseif (!empty($ad_url)) {
$movie_url .= "clickTAG=" . "$banner_url" . "/adpeeps.php" . "%3F" . "bf=go%26uid=$uid%26bzone=$bzone%26bsize=$bsize%26btype=$btype%26bpos=$bpos%26cid=$campaignid%26aid=$adno";
}
// ini flash link
list($w,$h) = explode('x',$bsize);
}
/////////////////////// display actual ad ///////////////
// 1 = regular banner via standard image tags
// 2 = php/ssi tags
// 3 = javascript
// 4 = iframe
# Standard Image
if ($btype == "1") {
if (empty($remote_banner)) {
header("Content-type: image/gif");
header("Content-Disposition: inline; filename=".md5(microtime()).";");
echo "$ad_banner";
} else {
$remote_banner = (preg_match('/uploaded_banners\//', $remote_banner)) ? "uploaded_banners/" . substr($remote_banner, strrpos($remote_banner,'/')+1,strlen($remote_banner)-strrpos($remote_banner,'/')) : "$remote_banner";
readfile("$remote_banner");
}
}
# All Other Types (SSI,PHP,JAVA,IFRAME)
else {
if ($btype == "4") {
$refresh_seconds = $brefresh * 1000;
$randnum = rand() % 1000000;
echo ("\n
\n |