<?php
// AdzMedia Publisher Install Code
// Language: PHP (curl)
// Version: 20130112
// Copyright AdzMedia Pvt Ltd, All rights reserved


$publisher_id = '2262'; // Publisher unique Site ID

$rq_page = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

$adzmedia_url = 'http://ad.adzmedia.mobi/index.php?';


$adzmedia_headers = array();
    foreach ($_SERVER as $adz_name => $adz_value) {
        $adzmedia_headers[] = "ADZ-$adz_name: $adz_value";
    }
$adz_ip="";
if (isset($_SERVER)) {
if (isset($_SERVER["HTTP_CLIENT_IP"])) {
$adz_ip=$_SERVER["HTTP_CLIENT_IP"];
} else {
$adz_ip=$_SERVER["REMOTE_ADDR"];
}
} else {
if (getenv('HTTP_CLIENT_IP')) {
$adz_ip=getenv('HTTP_CLIENT_IP');
} else {
$adz_ip=getenv('REMOTE_ADDR');
}
}
$keyname_ua_arr = array('HTTP_X_DEVICE_USER_AGENT', 'HTTP_X_OPERAMINI_PHONE_UA','HTTP_X_BOLT_PHONE_UA', 'HTTP_X_MOBILE_UA', 'HTTP_USER_AGENT');
                    foreach ($keyname_ua_arr as $keyname_ua) {
                        if (!empty($_SERVER[$keyname_ua])) {
                            $adz_ua = $_SERVER[$keyname_ua];
                        break;
                    }
                }
	
$fields = array(
            'publisher_id'=>urlencode($publisher_id),
            'ip'=>urlencode($adz_ip),
            'user_agent'=>urlencode($adz_ua),
            'rq_page'=>urlencode($rq_page),
            'v'=>urlencode("PHP-20130112"),
            'ref'=>urlencode($_SERVER["HTTP_REFERER"])
        );

foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&';
                       
                                }
$final_post = rtrim($fields_string,'&');
$time_out = 5;

 
        $adzmedia_url .= $final_post;
        $adzmedia_curl_post = array (
        CURLOPT_URL             => $adzmedia_url,
        CURLOPT_RETURNTRANSFER  => true,
        CURLOPT_HEADER          => 0,
        CURLOPT_USERAGENT       => $adz_ua,
        CURLOPT_RETURNTRANSFER  => 1,
        CURLOPT_FOLLOWLOCATION  => 1,
        CURLOPT_HTTPPROXYTUNNEL => true,
        CURLOPT_POST            => true,
        CURLOPT_POSTFIELDS      => $final_post,
        CURLOPT_TIMEOUT         => $time_out,
        CURLOPT_HTTPHEADER      => $adzmedia_headers
        );
        $adzmedia_init = curl_init();
        curl_setopt_array( $adzmedia_init, $adzmedia_curl_post );
        $adzmedia_responce = curl_exec($adzmedia_init);
		
        if (curl_getinfo($adzmedia_init,CURLINFO_HTTP_CODE) == 200)
        {
        echo $adzmedia_responce;
        }
        curl_close($adzmedia_init);
?>
