<?php
/**
 * @package		Ad Platform
 * @author		Uta Marian - Alexandru ( -uMarian- )
 * @license		http://codecanyon.net/licenses
 * @link		http://www.uta-marian.com
 * @version		Version 1.0
 */

require_once(dirname(__FILE__).'/../../config.php');

$GET_IP			=	$prepare->get_client_ip();
$geolocation	=	ip2c_geolocation($GET_IP);
$ip['ADDRESS']	=	$GET_IP;

//*** GEOLOCATION ***//
$ip['CONTINENT_CODE']		=	$geolocation['continentCode'];
$ip['CONTINENT_NAME']		=	$geolocation['continentName'];
$ip['COUNTRY_CODE_2']		=	$geolocation['countryCode2'];
$ip['COUNTRY_CODE_3']		=	$geolocation['countryCode3'];
$ip['COUNTRY_NAME']			=	$geolocation['countryName'];
$ip['COUNTRY_LAT']			=	$geolocation['countryLatitude'];
$ip['COUNTRY_LONG']			=	$geolocation['countryLongitude'];

$ip['REGION_NAME']			=	$geolocation['regionName'];
$ip['CITY_NAME']			=	$geolocation['cityName'];
$ip['CITY_LAT']				=	$geolocation['cityLatitude'];
$ip['CITY_LONG']			=	$geolocation['cityLongitude'];

//*** GET ALL VARIABLES ***//
$FULL_URL	=	$prepare->sanitize( $_GET['r'], 'input' );
$URL		=	base64_decode( $FULL_URL );
$DECODE		=	explode( '&', $URL );

$USER_ID	=	str_replace( 'user=', '', $DECODE['0'] );//*** ADVERTISER USER ID ***//
$AD_ID		=	str_replace( 'ad_id=', '', $DECODE['1'] );//*** ADVERTISER AD ID ***//
$KEYWORD	=	str_replace( 'keyword=', '', $DECODE['2'] );//*** ADVERTISER AD KEYWORD ***//
$PRICE		=	str_replace( 'keyword_price=', '', $DECODE['3'] );//*** ADVERTISER AD KEYWORD PRICE ***//
$TARGET		=	str_replace( 'url_target=', '', $DECODE['4'] );//*** ADVERTISER AD KEYWORD PRICE ***//
$SLOT		=	str_replace( 'slot=', '', $DECODE['5'] );//*** PUBLISHER AD SLOT ***//
$CHANNEL_ID	=	str_replace( 'channel_id=', '', $DECODE['6'] );//*** PUBLISHER CHANNEL ID ***//
$PUB_ID		=	str_replace( array('client=','ca-pub-'), array('',''), $DECODE['7'] );//*** PUBLISHER CHANNEL ID ***//

$REFERER	=	str_replace( 'referer=', '', $DECODE['8'] );//*** REFERER DOMAIN ***//
$DOMAIN		=	str_replace( 'domain=', '', $DECODE['9'] );//*** WEBSITE DOMAIN ***//
$CAMPAIGN	=	str_replace( 'campaign=', '', $DECODE['10'] );//*** ADV CAMPAIGN ***//



$validate = $db->Query("SELECT `ra_id` FROM reported_ads where ra_ad_id=?","i",$AD_ID);



if ( empty ( $validate ) && $AD_ID > 0 ) {

$ra_ad_id	=	$AD_ID;
$ra_ip		=	$GET_IP;
$ra_country	=	$geolocation['countryName'];
$ra_date	=	strtotime( "now" );

	$insert = $db->NoQuery("INSERT INTO reported_ads VALUES(NULL,?,?,?,?)","ssss",$ra_ad_id,$ra_ip,$ra_country,$ra_date);
}







/* set page title */
$view->title = $LANG["WBS_AD_REPORT"];
$view->description = $LANG["WBS_AD_REPORT"];
$view->keywords = $LANG["WBS_AD_REPORT"];

$view->header = $view->render(DIR_TEMPLATE.WEBSITE_TEMPLATE.'/header.php');
$view->footer = $view->render(DIR_TEMPLATE.WEBSITE_TEMPLATE.'/footer.php');

echo $view->render(DIR_TEMPLATE.WEBSITE_TEMPLATE.'/report.php');
?>