<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Adwards extends CI_Controller {
	public function __construct()
	{
		parent::__construct();
		$this->load->model('common_model');
	}
	function google()
	{
		print_r($_SERVER['HTTP_REFERER']);
		//$_SERVER['HTTP_REFERER'] = 'https://adwords.google.com/aw/keywords?campaignId=812020710&ocid=219991364&tableState=%7B%221%22%5B';
		if(preg_match('/gclid/i', $_SERVER['HTTP_REFERER']) or preg_match('/gclid/i', $_SERVER['REQUEST_URI'])) {

		echo "Google adwords visitor content";

		}

		else {

		echo "regular visitor content";

		}
		$campId = 0;
		$campdata = explode('campaignId=', $_SERVER['HTTP_REFERER']);
		if(count($campdata)>0)
		{
			$camp = explode('&', $campdata[1]);
			if(count($camp)>0)
			{
				$campId = $camp[0];
			}
			$this->session->set_userdata('google',$campId);
		}
		//echo $this->session->userdata('google'); die;
		redirect(base_url());
	}
	function facebook()
	{
		print_r($_SERVER['HTTP_USER_AGENT']);

		if(preg_match('/facebook.com/i', $_SERVER['HTTP_USER_AGENT']) or preg_match('/facebook.com/i', $_SERVER['REQUEST_URI'])) {

		echo "Facebook adwords visitor content";

		}

		else {

		echo "regular visitor content";

		}
		$this->session->set_userdata('facebook',1);
		redirect(base_url());
	}
}
	

