//ADTWIRL INSTALL CODE
function adtwirl_request($ads_number = 1, $use_array = true)
{
// PHP Install Code Version: 6.3.2011 v 2.00.00 BETA
// Unique id code of your site
$site_code = '9c70dc4f-d947-491c-b3e8-f43c800abdfa';
// Enable image ads (true = enable ; false = disable )
$image_ads = true;
// Enable adult ads (true = enable ; false = disable )
$adult_ads = true;
/* Enable free ads (true = enable ; false = disable ) you will get points instead of Money for this ads which you can use to advertise your site, if this ads are disabled your site will show only cash ads */
$free_ads = true;
$request_timeout = 3; /* request timeout in seconds (recomended is to keep this value under 5 seconds) */
$request_method = 1; /* You can chose here the request method for ads, but the best value is 1 which stands for curl, 2 - file_get_contents request method. */
// Do not edit from this line
// Lets block bots and pc users from ad requests
$bot_list = array("teoma", "yahoo", "majestic", "bot", "crawl", "spider", "seek", "alexa", "froogle", "inktomi", "looksmart", "firefly", "directory", "jeeves", "www.galaxy.com", "scooter", "slurp", "appie", "fast", "webbug", "spade", "zyborg", "rabaz", "fetcher", "partners", "t9space", "phonif"); foreach($bot_list as $bot) { if( stristr($_SERVER['HTTP_USER_AGENT'],$bot) ) { return ''; break; } }
$regex_match="/(nokia|iphone|ipod|ipad|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|"; $regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|ios|meego|webos|techfaith|palmsource|"; $regex_match.="blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|"; $regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|"; $regex_match.="jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220"; $regex_match.=")/i"; if(isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE']) || preg_match($regex_match, strtolower($_SERVER['HTTP_USER_AGENT']))){}else return '';
// Generating POST parameters
$params[] = 'site_code=' . $site_code; $params[] = 'adult=' . $adult_ads; $params[] = 'free=' . $free_ads; $params[] = 'image=' . $image_ads; $params[] = 'ads=' . $ads_number; $params[] = 'code=6-13-11'; $headers_arr = array('HTTP_ACCEPT_LANGUAGE', 'HTTP_USER_AGENT', 'HTTP_HOST', 'REQUEST_URI', 'HTTP_ACCEPT', 'HTTP_REFERER', 'HTTP_CLIENT_IP','REMOTE_ADDR'); foreach ($headers_arr as $k) { if (isset($_SERVER[$k])) { $header_key = str_replace('_','-', $k); $params[] = strtolower($header_key).'='.urlencode($_SERVER[$k]); } } foreach($_SERVER as $k => $v ) { if(stristr($k, 'HTTP_X')) { $header_key = str_replace(array('HTTP_X_', '_'),array('x-', '-'), $k); $params[] = strtolower($header_key).'='.urlencode($v); } elseif(stristr($k, 'GEOIP_')) { $header_key = str_replace('_','-', $k); $params[] = strtolower($header_key).'='.urlencode($v); } } $IP = ""; if (isset($_SERVER)) { if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { $IP = $_SERVER["HTTP_X_FORWARDED_FOR"]; $proxy = $_SERVER["REMOTE_ADDR"]; } elseif (isset($_SERVER["HTTP_CLIENT_IP"])) { $IP = $_SERVER["HTTP_CLIENT_IP"]; } elseif (isset($_SERVER["HTTP_X_REAL_IP"])) { $IP = $_SERVER["HTTP_X_REAL_IP"]; } else { $IP = $_SERVER["REMOTE_ADDR"]; } } else { if (getenv('HTTP_X_FORWARDED_FOR')) { $IP = getenv('HTTP_X_FORWARDED_FOR');} elseif (getenv('HTTP_CLIENT_IP')) { $IP = getenv('HTTP_CLIENT_IP'); } else { $IP = getenv('REMOTE_ADDR'); } } if (strstr($IP, ',')) { $ips = explode(',', $IP); $IP = $ips[0]; } if (empty($IP)) $IP = $_SERVER["REMOTE_ADDR"]; elseif (strtolower(trim($IP)) == 'unknown') $IP = $_SERVER["REMOTE_ADDR"]; $keyname_ua_arr = array('HTTP_X_DEVICE_USER_AGENT', 'HTTP_X_OPERAMINI_PHONE_UA', 'HTTP_USER_AGENT'); foreach ($keyname_ua_arr as $keyname_ua) { if (!empty($_SERVER[$keyname_ua])) { $UA = urlencode($_SERVER[$keyname_ua]); break; } } $params[] = 'ip='.$IP; $params[] = 'ua='.$UA; $post = implode('&', $params);
// Sending request to adtwirl server
if($request_method==1)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://a.adtwirl.com/ad_source.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, $request_timeout);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $request_timeout);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Connection: Close'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$contents = curl_exec($ch);
curl_close($ch);
}
elseif($request_method==2)
{
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'timeout' => $request_timeout,
'content' => $post
)
);
$context = stream_context_create($opts);
$contents = file_get_contents('http://a.adtwirl.com/ad_source.php', false, $context);
}
// Preparing ads for output
if ($use_array == true && $ads_number > 1)
{
$arr = explode("
", $contents);
$ads = array();
for($i=0;$i<$ads_number;$i++)
{
if(preg_match('/^\<.*\>$/', $arr[$i])) $ads[] = $arr[$i];
}
if(count($ads)>0)
return $ads;
}
elseif(preg_match('/^\<.*\>$/', $contents))
return $contents;
}
//END OF THE ADTWIRL INSTALL CODE
// USAGE EXAMPLE
echo adtwirl_request();
/* Or if you want to use 2 ads request and place ads separate on your site use this example:
$_ads = adtwirl_request(2);
$first_ad = $_ads[0];
$second_ad = $_ads[1];
And now to place the first and second ad eg. at the top and at the bottom of your site put.
top of the site
echo $first_ad;
Here is your site content
bottom of your site
echo $second_ad;
this example will save your server ressources because you will get two ads with one request */
?>