<?php
function wpfresh5_gdpr_all_pages( $gdprtype )
{
	$pref='wpf5gdpr-';
// Set up the objects needed
$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query(array('post_type' =>get_post_types('', 'names')));
// Filter through all pages and find Portfolio's children
$all_children = get_page_children( get_the_ID(), $all_wp_pages );
$all_children=get_pages();
// echo what we get back from WP to the browser
$count=0;
if(!empty($all_children)){
	if($gdprtype !='cookie')
	{
		$class="";
	}
	else
	{
		$class="";
	}
	if($gdprtype =='cookie')
	{
		$class="selectcontrol";
	}

	echo '<select  class="'.$class.'" name="'.$gdprtype.'">';

		if($gdprtype=='cookie')
		{//for type cookie
	         if(get_option($pref.'show')=='y')
			 {
			 echo '<option Value="y" selected>All Pages</option>';
			 echo '<option Value="n">Don\'t Display</option>';
			 echo '<option Value="h">Home</option>';
			 }
			 else if(get_option($pref.'show')=='n')
			 {
				echo '<option Value="y">All Pages</option>';
			 echo '<option Value="n" selected>Don\'t Display</option>';
			 echo '<option Value="h">Home</option>';
			 }
			 else if(get_option($pref.'show')=='h')
			 {
				echo '<option Value="y">All Pages</option>';
			 echo '<option Value="n" selected>Don\'t Display</option>';
			 echo '<option Value="h" selected>Home</option>';
			 }
			 else
			 {
				 echo '<option Value="y">All Pages</option>';
			 echo '<option Value="n">Don\'t Display</option>';
			 echo '<option Value="h">Home</option>';
			 }
		}
		if($gdprtype=='afttandc')
		{
			//for terms and conditions after accept page redirect
			if(get_option($pref.'tandc-aft')=='l')
			 {
				 echo '<option Value="h" >Home</option>';
			 echo '<option Value="l" selected>Last Visited page</option>';
			echo '<option Value="n">Don\'t Redirect</option>';
			 }
			 else if(get_option($pref.'tandc-aft')=='n')
			 {
				  echo '<option Value="h" >Home</option>';
				  echo '<option Value="l">Last Visited page</option>';
				  echo '<option Value="n" selected>Don\'t Redirect</option>';
			 }
			 else if(get_option($pref.'tandc-aft')=='h')
			 {     echo '<option Value="h" selected>Home</option>';
				  echo '<option Value="l">Last Visited page</option>';
				  echo '<option Value="n">Don\'t Redirect</option>';
			 }
			 else
			 {
				  echo '<option Value="h" >Home</option>';
				 echo '<option Value="l">Last Visited page</option>';
				  echo '<option Value="n">Don\'t Redirect</option>';
			 }
		}
		if($gdprtype=='beftandc')
		{
			//for terms and conditions page
			if(get_option($pref.'tandc-bef')=='0')
			 {
			 echo '<option Value="0" selected></option>';

			 }
			 else
			 {
				echo '<option Value="0"></option>';
			 }
		}

		if($gdprtype=='aftpp')
		{
			//for privacy policy after accept page redirect
			if(get_option($pref.'pp-aft')=='l')
			 {
				 echo '<option Value="h">Home</option>';
			 echo '<option Value="l" selected>Last Visited page</option>';
			echo '<option Value="n">Don\'t Redirect</option>';
			 }
			 else if(get_option($pref.'pp-aft')=='n')
			 {     echo '<option Value="h">Home</option>';
				  echo '<option Value="l">Last Visited page</option>';
				  echo '<option Value="n" selected>Don\'t Redirect</option>';
			 }
			 else if(get_option($pref.'pp-aft')=='h')
			 {     echo '<option Value="h" selected>Home</option>';
				  echo '<option Value="l">Last Visited page</option>';
				  echo '<option Value="n">Don\'t Redirect</option>';
			 }
			 else
			 {
				 echo '<option Value="h">Home</option>';
				 echo '<option Value="l">Last Visited page</option>';
				  echo '<option Value="n">Don\'t Redirect</option>';
			 }
		}
		if($gdprtype=='befpp')
		{
			//for privacy policy  page
			if(get_option($pref.'pp-bef')=='0')
			 {
			 echo '<option Value="0" selected></option>';

			 }
			 else
			 {
				echo '<option Value="0"></option>';
			 }
		}

    foreach($all_children as $child){
		$count++;
		if(strlen($child->post_title)<1)
		{
			$title="No Title";
		}
		else
		{
			$title=$child->post_title;
		}
		$selected="";
		if($gdprtype=='cookie')
			{//option selection for cookie
		if(get_option($pref.'show')==$child->ID)
		{
			$selected="selected";
		}

			}
		if($gdprtype=='beftandc')
			{//option selection for page tandc
		if(get_option($pref.'tandc-bef')==$child->ID)
		{
			$selected="selected";
		}
			}
        if($gdprtype=='afttandc')
			{//option selection for page redicet after accepttandc
		if(get_option($pref.'tandc-aft')==$child->ID)
		{
			$selected="selected";
		}
			}

         if($gdprtype=='befpp')
			{//option selection for page privacy policy
		if(get_option($pref.'pp-bef')==$child->ID)
		{
			$selected="selected";
		}
			}
        if($gdprtype=='aftpp')
			{//option selection for page redicet after accept privacy policy
		if(get_option($pref.'pp-aft')==$child->ID)
		{
			$selected="selected";
		}
			}

         echo '<option Value="'.$child->ID.'" '.$selected.'>'.$title.'</option>';

    }
    echo '</select>';
}
}

function  wpfresh5_rmhttpurlandmatch($url)
{//cookie match url and show alert
if(get_the_ID()==$url)
{
	return 1;
}
else
{
	return 0;
}
/*$hurl='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$surl='https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if(strpos($hurl,$url)!==false)
{
	return 1;
}
else if(strpos($surl,$url)!==false)
{
	return 1 ;
}
*/
}

//-----For Terms and Conditions

function wpfresh5_tandcacceptbutton()
{//terms and condition shortcode accept button and add user meta or cookie for it
$pref='wpf5gdpr-';
	if(isset($_POST['gdpraccept']))
	{
		if(is_user_logged_in())
		{//if user logged in add or update user meta
          $user =get_current_user_id();

          $havemeta = get_user_meta($user,$pref.'tandc', false);
		  if( $havemeta)
		  {
			 if(get_user_meta($user,$pref.'tandc', true)!=get_option($pref.'tandc-version'))
			 {
				 update_user_meta($user,$pref.'tandc',get_option($pref.'tandc-version'));
			 }
		  }
		  else
		  {
			  add_user_meta($user,$pref.'tandc',get_option($pref.'tandc-version'));}
        }


		if(get_option($pref.'tandc-aft')=='l')
		{

			$link=$_SESSION['tandclvpage'];
			echo "<script>window.location='".$link."';</script>";
		}
		else if(get_option($pref.'tandc-aft')=='h')
		{

			$link=$_SESSION['tandclvpage'];
			echo "<script>window.location='".get_home_url()."';</script>";
		}
		else if(get_option($pref.'tandc-aft')=='n')
		{

		}
		else
		{
			$link=get_permalink(get_option($pref.'tandc-aft'));
			echo "<script>window.location='".$link."';</script>";
		}
	}
	$nlg="";
	if(!is_user_logged_in())
	{
		$nlg="<input type='hidden' value='1' name='gdprnlgtandc'>";
	}
	$form="<p><form action='' method='post'>".$nlg."
	<label>
	I accept the terms and conditions as laid out in this Terms & Conditions page.
	<input type='checkbox' required=''>
	</label>
	<br/>
	<input type='submit' value='Accept' name='gdpraccept'></form></p>";
	// require_once("gdprstyle.php");
	// $form .=gdprstyle();
	return $form;
}
function wpfresh5_gdprsettandccookie()
{//adding a cookie for terms and conditions
	$pref='wpf5gdpr-';
	$tandcookie=$pref.'tandc';
	if(isset($_COOKIE[$tandcookie]))
	{
	if($_COOKIE[$tandcookie]!=get_option($pref.'tandc-version'))
	setcookie($tandcookie,get_option($pref.'tandc-version'),time()+(480000*365),COOKIEPATH, COOKIE_DOMAIN);
    }
	else
	{setcookie($tandcookie,get_option($pref.'tandc-version'),time()+(480000*365),COOKIEPATH, COOKIE_DOMAIN);}

}
function wpfresh5_gdpr_check_tandc_cookie_or_usermeta()
{//check cookie or user meta set or not
$pref='wpf5gdpr-';

$https = ((!empty($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] != 'off')) ? true : false;

if(wpfresh5_rmhttpurlandmatch(get_option($pref.'tandc-bef'))==1 || wpfresh5_rmhttpurlandmatch(get_option($pref.'pp-bef'))==1)
{}
else{
if($https) {
    $_SESSION['tandclvpage']= "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
} else {
   $_SESSION['tandclvpage']= "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
}
    }
	$tandcookie=$pref.'tandc';
	$link=get_permalink(get_option($pref.'tandc-bef'));
	$link = add_query_arg( 'force_accept', '1', $link );
if(is_user_logged_in()&&(get_option($pref.'tandc-bef')!='0'))
{
	$user =get_current_user_id();
	$havemeta = get_user_meta($user,$pref.'tandc', false);
	if(get_option($pref.'tandc-lusr')=='1'){
		    if($havemeta){
				if(get_user_meta($user,$pref.'tandc', true)!=get_option($pref.'tandc-version'))
			echo "<script>window.location='".$link."';</script>";
			             }
             else
			 {
				echo "<script>window.location='".$link."';</script>";
			 }
			                           }
}
else if(get_option($pref.'tandc-bef')!='0' && get_option($pref.'tandc-nlusr')=='1')
{
	if(get_option($pref.'tandc-nlusr')=='1')
	{
		if(isset($_COOKIE[$tandcookie]))
		{
			if($_COOKIE[$tandcookie]!=get_option($pref.'tandc-version'))
			echo "<script>window.location='".$link."';</script>";
		}
		else
		{
			echo "<script>window.location='".$link."';</script>";
		}
	}
	else
	{
		echo "<script>window.location='".$link."';</script>";
	}
}

}
//----For Privacy Policy------



function wpfresh5_ppacceptbutton()
{//privacy policy shortcode accept button and add user meta or cookie for it
$pref='wpf5gdpr-';
	if(isset($_POST['gdpracceptpp']))
	{
		if(is_user_logged_in())
		{//if user logged in add or update user meta
          $user =get_current_user_id();

          $havemeta = get_user_meta($user,$pref.'pp', false);
		  if( $havemeta)
		  {
			 if(get_user_meta($user,$pref.'pp', true)!=get_option($pref.'pp-version'))
			 {
				 update_user_meta($user,$pref.'pp',get_option($pref.'pp-version'));
			 }
		  }
		  else
		  {
			  add_user_meta($user,$pref.'pp',get_option($pref.'pp-version'));}
        }


		if(get_option($pref.'pp-aft')=='l')
		{

			$link=$_SESSION['pplvpage'];
			echo "<script>window.location='".$link."';</script>";
		}
		else if(get_option($pref.'pp-aft')=='h')
		{

			$link=$_SESSION['pplvpage'];
			echo "<script>window.location='".get_home_url()."';</script>";
		}
		else if(get_option($pref.'pp-aft')=='n')
		{

		}
		else
		{
			$link=get_permalink(get_option($pref.'pp-aft'));
			echo "<script>window.location='".$link."';</script>";
		}
	}
	$nlg="";
	if(!is_user_logged_in())
	{
		$nlg="<input type='hidden' value='1' name='gdprnlgpp'>";
	}
	$form="<p><form action='' method='post'>".$nlg."
	<label class='containerr'>
	I agree to the Privacy Policy and I give my consent to the terms laid out.
	<input type='checkbox' required='' >
	<br/>
	<br/>
	<input type='submit' class='gdpracceptbutton' value='Accept and Continue' name='gdpracceptpp' ></form></p>";

	// require_once("gdprstyle.php");
	// $form .=gdprstyle();
	return $form;
}

function wpfresh5_gdprsetppcookie()
{//adding a cookie for privacy policy
	$pref='wpf5gdpr-';
	$ppcookie=$pref.'pp';
	if(isset($_COOKIE[$ppcookie]))
	{
	if($_COOKIE[$ppcookie]!=get_option($pref.'pp-version'))
	setcookie($ppcookie,get_option($pref.'pp-version'),time()+(480000*365),COOKIEPATH, COOKIE_DOMAIN);
    }
	else
	{setcookie($ppcookie,get_option($pref.'pp-version'),time()+(480000*365),COOKIEPATH, COOKIE_DOMAIN);}

}
function wpfresh5_gdpr_check_pp_cookie_or_usermeta()
{//check cookie or user meta set or not for privacy policy
$pref='wpf5gdpr-';

$https = ((!empty($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] != 'off')) ? true : false;
if(wpfresh5_rmhttpurlandmatch(get_option($pref.'tandc-bef'))==1 || wpfresh5_rmhttpurlandmatch(get_option($pref.'pp-bef'))==1)
{}
else{
if($https) {
    $_SESSION['pplvpage']= "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
} else {
   $_SESSION['pplvpage']= "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
}
    }
	$ppcookie=$pref.'pp';
	$link=get_permalink(get_option($pref.'pp-bef'));
	$link = add_query_arg( 'force_accept', '1', $link );

if(is_user_logged_in()&&(get_option($pref.'pp-bef')!='0'))
{
	$user =get_current_user_id();
	$havemeta = get_user_meta($user,$pref.'pp', false);
	if(get_option($pref.'pp-lusr')=='1'){
		    if($havemeta){
				if(get_user_meta($user,$pref.'pp', true)!=get_option($pref.'pp-version'))
			echo "<script>window.location='".$link."';</script>";
			             }
             else
			 {
				echo "<script>window.location='".$link."';</script>";
			 }
			                           }
}
else if(get_option($pref.'pp-bef')!='0'&& get_option($pref.'pp-nlusr')=='1')
{
	if(get_option($pref.'pp-nlusr')=='1')
	{
		if(isset($_COOKIE[$ppcookie]))
		{
			if($_COOKIE[$ppcookie]!=get_option($pref.'pp-version'))
			echo "<script>window.location='".$link."';</script>";
		}
		else
		{
			echo "<script>window.location='".$link."';</script>";
		}
	}
	else
	{
		echo "<script>window.location='".$link."';</script>";
	}
}

}
//---------Right to be forgotten request table----------------------
function wpfresh5_showRequestToForget()
{
	echo '<script>

			</script>';

	global $wpdb;
	$table=$wpdb->prefix.'wpfresh5_gdpr_requests';

	 if(isset($_GET['wpcrpagecount']))
	  {
		  $wpcridin=$_GET['wpcrpagecount'];
		  $sql="select * from ".$table." where type='fm' and id <".$wpcridin." order by id desc";

	  }
	  else
	  {
	  $sql="select * from ".$table." where type='fm' order by id desc";
	  }
	$records=$wpdb->get_results($sql);
	$wpcrcount=0;
	$last=0;
	foreach($records as $data)
	{
		$wpcrcount++;

		if($data->login=='1')
		{
			$login="<font color='green'>Logged In </font>";
		}
		else if($data->login=='2')
		{
			$login="<font color='green'>Confirmed with verification Link .</font>";
		}
		else
		{
			$login="<font color='red'>Confirmation Link Sent.</font>";
		}
		if($data->action=='0')
		{
			$action='<table><tr><td><button type="submit" class="btn btn-primary" value="Forget" name="gdprfmtakeaction" data-toggle="tooltip" title="Forget Requested Data and Send a Confirmation Email">
			<span class="glyphicon glyphicon-ok-sign"></span>
            </button></td><td>
			<button type="submit" class="btn btn-info" value="Forget" name="gdprfmview" data-toggle="tooltip" title="View Requested Data">
			<span class="glyphicon glyphicon-eye-open"></span>
            </button></td><td>
			<button type="submit" name="gdprfmremove" class="btn btn-danger" value="remove" onclick="return gdprfmActionDel()" data-toggle="tooltip" title="Remove Request">
			<span class="glyphicon glyphicon-trash"></span>
            </button></td></tr></table>
			';
		}
		else
		{
			$action='<span style="margin-left:84px;"><button type="submit" name="gdprfmremove" class="btn btn-danger" value="remove" onclick="return gdprfmActionDel()" data-toggle="tooltip" title="Remove Request">
			<span class="glyphicon glyphicon-trash"></span>
            </button>';
		}
		if($data->value=='c'){$type="Comments";}if($data->value=='p'){$type="Posts";}if($data->value=='u'){$type="User Meta";}
		echo
		'
		<form action="" method="post">
		<input type="hidden" value="'.$data->value.'" name="afmvalue">
		<input type="hidden" value='.$data->id.' name="afmreqid">
		<input type="hidden" value='.$data->user.' name="afmuser">
		<input type="hidden" value='.$data->email.' name="afmemail">
		<tr>
		<td>'.$data->id.'</td><td>'.$data->email.'</td><td>'.$login.'</td><td>'.$type.'</td><td>'.$data->recorded.'</td><td>'.$data->actiontime.'</td><td>'.$action.'</td>
		</tr>
		</form>
		';
		if($wpcrcount==10)
		   {

			   break;
		   }
	}
	if( isset( $_SERVER['HTTP_HOST'] ) && isset( $data ) )
		$gdprfmnxtpage = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&wpcrpagecount='.$data->id;
	else
		$gdprfmnxtpage = $_SERVER['REQUEST_URI'].'&wpcrpagecount=1';
	// $gdprfmnxtpage=$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&wpcrpagecount='.$data->id;
	echo
	'
	<tfoot>
		<tr>
			<td colspan="8">
			<ul class="pager">';
		if(isset($_GET['wpcrpagecount']))
		{
             echo '
			 <script type="text/javascript">
            function goBack() {
              window.history.back();
                  }
                </script>
				<li class="previous" onclick="goBack()"><a style="cursor:pointer">Previous</a></li>';
		}

      if($wpcrcount==10)
	  {
	echo '<li class="next"><a href="'.$gdprfmnxtpage.'">Next</a></li>';
	  }


	echo '</ul>
			</td>
		</tr>
	</tfoot>

	';
}
//---------Data access request table----------------------

function wpfresh5_showRequestToDataAccess()
{
	echo '<script>

			</script>';

	global $wpdb;
	$table=$wpdb->prefix.'wpfresh5_gdpr_requests';

	 if(isset($_GET['wpcrpagecount']))
	  {
		  $wpcridin=$_GET['wpcrpagecount'];
		  $sql="select * from ".$table." where type='da' and id <".$wpcridin." order by id desc";

	  }
	  else
	  {
	  $sql="select * from ".$table." where type='da' order by id desc";
	  }
	$records=$wpdb->get_results($sql);
	$wpcrcount=0;
	$last=0;
	foreach($records as $data)
	{
		$wpcrcount++;

		if($data->login=='1')
		{
			$login="<font color='green'>Logged In</font>";
		}
		else if($data->login=='2')
		{
			$login="<font color='green'>Confirmed with verification Link .</font>";
		}
		else
		{
			$login="<font color='red'>Confirmation Link Sent.</font>";
		}
		/*else if($data->login=='2')
		{
			$login="<font color='orange'></p>Email is not registered with this id .</p></font>";
		}
		else if($data->login=='0')
		{
			$login="<font color='red'></p>Did not login.</p></font>";
		}*/

		if($data->action=='0')
		{
			$action='<table><tr><td><button type="submit" class="btn btn-primary" value="Forget" name="gdprdatakeaction" data-toggle="tooltip" title="Send Requested Data">
			<span class="glyphicon glyphicon-ok-sign"></span>
            </button></td><td>
			<button type="submit" class="btn btn-info" value="Forget" name="gdprdaview" data-toggle="tooltip" title="View Requested Data">
			<span class="glyphicon glyphicon-eye-open"></span>
            </button></td><td>
			<button type="submit" name="gdprdaremove" class="btn btn-danger" value="remove" onclick="return gdprdaAction()" data-toggle="tooltip" title="Remove Request">
			<span class="glyphicon glyphicon-trash"></span>
            </button></td></tr></table>
			';
		}
		else
		{
			$action='<span style="margin-left:84px"><button type="submit" name="gdprdaremove" class="btn btn-danger" value="remove" onclick="return gdprdaAction()" data-toggle="tooltip" title="Remove Request">
			<span class="glyphicon glyphicon-trash"></span>
            </button></span>';
		}
		echo
		'
		<form action="" method="post">
		<input type="hidden" value='.$data->id.' name="dareqid">
		<input type="hidden" value='.$data->user.' name="dauser">
		<input type="hidden" value='.$data->email.' name="daemail">
		<tr>
		<td>'.$data->id.'</td><td>'.$data->email.'</td><td>'.$login.'</td><td>'.$data->recorded.'</td><td>'.$data->actiontime.'</td><td>'.$action.'</td>
		</tr>
		</form>
		';
		if($wpcrcount==10)
		   {

			   break;
		   }
	}
	if( isset( $_SERVER['HTTP_HOST'] ) && isset( $data ) )
		$gdprfmnxtpage = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&wpcrpagecount='.$data->id;
	else
		$gdprfmnxtpage = $_SERVER['REQUEST_URI'].'&wpcrpagecount=1';
	// $gdprfmnxtpage=$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&wpcrpagecount='.$data->id;
	echo
	'
	<tfoot>
		<tr>
			<td colspan="7">
			<ul class="pager">';
		if(isset($_GET['wpcrpagecount']))
		{
             echo '
			 <script type="text/javascript">
            function goBack() {
              window.history.back();
                  }
                </script>
				<li class="previous" onclick="goBack()"><a style="cursor:pointer">Previous</a></li>';
		}

      if($wpcrcount==10)
	  {
	echo '<li class="next"><a href="'.$gdprfmnxtpage.'">Next</a></li>';
	  }


	echo '</ul>
			</td>
		</tr>
	</tfoot>

	';
}
//----------data rectification request table-------------


function wpfresh5_showRequestToDataRectification()
{
	echo '<script>

			</script>';

	global $wpdb;
	$table=$wpdb->prefix.'wpfresh5_gdpr_requests';

	 if(isset($_GET['wpcrpagecount']))
	  {
		  $wpcridin=$_GET['wpcrpagecount'];
		  $sql="select * from ".$table." where type='dr' and id <".$wpcridin." order by id desc";

	  }
	  else
	  {
	  $sql="select * from ".$table." where type='dr' order by id desc";
	  }
	$records=$wpdb->get_results($sql);
	$wpcrcount=0;
	$last=0;
	foreach($records as $data)
	{
		$wpcrcount++;

		if($data->login=='1')
		{
			$login="<font color='green'>Logged In</font>";
		}
		else if($data->login=='2')
		{
			$login="<font color='green'>Confirmed with verification Link .</font>";
		}
		else
		{
			$login="<font color='red'>Confirmation Link Sent.</font>";
		}
		/*else if($data->login=='2')
		{
			$login="<font color='orange'></p>Email is not registered with this id .</p></font>";
		}
		else if($data->login=='0')
		{
			$login="<font color='red'></p>Did not login.</p></font>";
		}*/
		if($data->value=='c'){$type="Comments";}if($data->value=='p'){$type="Posts";}if($data->value=='u'){$type="User Data";}
		if($data->action=='0')
		{
			$action='<table><tr><td><button type="submit" class="btn btn-primary" value="Forget" name="gdprdrtakeaction" data-toggle="tooltip" title="Send Requested Data">
			<span class="glyphicon glyphicon-ok-sign"></span>
            </button></td><td>
			<button type="submit" class="btn btn-info" value="Forget" name="gdprdrview" data-toggle="tooltip" title="View Requested Data">
			<span class="glyphicon glyphicon-eye-open"></span>
            </button></td><td>
			<button type="submit" name="gdprdrremove" class="btn btn-danger" value="remove" onclick="return gdprdrAction()" data-toggle="tooltip" title="Remove Request">
			<span class="glyphicon glyphicon-trash"></span>
            </button></td></tr></table>
			';
		}
		else
		{
			$action='<span style="margin-left:84px"><button type="submit" name="gdprdrremove" class="btn btn-danger" value="remove" onclick="return gdprdrAction()" data-toggle="tooltip" title="Remove Request">
			<span class="glyphicon glyphicon-trash"></span>
            </button></span>';
		}
		echo
		'
		<form action="" method="post">
		<input type="hidden" value='.$data->value.' name="drrtype">
		<input type="hidden" value='.$data->id.' name="drreqid">
		<input type="hidden" value='.$data->user.' name="druser">
		<input type="hidden" value='.$data->email.' name="dremail">
		<tr>
		<td>'.$data->id.'</td><td>'.$data->email.'</td><td>'.$login.'</td><td>'.$type.'</td><td>'.$data->recorded.'</td><td>'.$data->actiontime.'</td><td>'.$action.'</td>
		</tr>
		</form>
		';
		if($wpcrcount==10)
		   {

			   break;
		   }
	}
	if( isset( $_SERVER['HTTP_HOST'] ) && isset( $data ) )
		$gdprfmnxtpage = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&wpcrpagecount='.$data->id;
	else
		$gdprfmnxtpage = $_SERVER['REQUEST_URI'].'&wpcrpagecount=1';
	// $gdprfmnxtpage=$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&wpcrpagecount='.$data->id;
	echo
	'
	<tfoot>
		<tr>
			<td colspan="7">
			<ul class="pager">';
		if(isset($_GET['wpcrpagecount']))
		{
             echo '
			 <script type="text/javascript">
            function goBack() {
              window.history.back();
                  }
                </script>
				<li class="previous" onclick="goBack()"><a style="cursor:pointer">Previous</a></li>';
		}

      if($wpcrcount==10)
	  {
	echo '<li class="next"><a href="'.$gdprfmnxtpage.'">Next</a></li>';
	  }


	echo '</ul>
			</td>
		</tr>
	</tfoot>

	';
}
//--------gdpr unsubscription request table----------

function wpfresh5_gdpr_unsubscription_request_table()
{
	echo '<script>

			</script>';

	global $wpdb;
	$table=$wpdb->prefix.'wpfresh5_gdpr_requests';

	 if(isset($_GET['wpcrpagecount']))
	  {
		  $wpcridin=$_GET['wpcrpagecount'];
		  $sql="select * from ".$table." where type='uns' and (login='1' or login='2') and id <".$wpcridin." order by id desc";

	  }
	  else
	  {
	  $sql="select * from ".$table." where type='uns' and (login='1' or login='2') order by id desc";
	  }
	$records=$wpdb->get_results($sql);
	$wpcrcount=0;
	$last=0;
	foreach($records as $data)
	{
		$wpcrcount++;

		if($data->login=='1')
		{
			$login="<font color='green'>Logged In</font>";
		}
		else if($data->login=='2')
		{
			$login="<font color='green'>Confirmed with verification Link .</font>";
		}
		else
		{
			$login="<font color='red'>Confirmation Link Sent.</font>";
		}


		if($data->value=='c'){$type="Comments";}if($data->value=='p'){$type="Posts";}if($data->value=='u'){$type="User Data";}
		if($data->action=='0')
		{
			$action='<table><tr><td><button type="submit" class="btn btn-primary" value="Forget" name="gdprunstakeaction" data-toggle="tooltip" title="Send Requested Data">
			<span class="glyphicon glyphicon-ok-sign"></span>
            </button></td>
			<td>
			<button type="submit" name="gdprunsremove" class="btn btn-danger" value="remove" onclick="return gdprunsAction()" data-toggle="tooltip" title="Remove Request">
			<span class="glyphicon glyphicon-trash"></span>
            </button></td></tr></table>
			';
			$status="Pending";
		}
		else
		{
			$action='<span style="margin-left:41px"><button type="submit" name="gdprunsremove" class="btn btn-danger" value="remove" onclick="return gdprunsAction()" data-toggle="tooltip" title="Remove Request">
			<span class="glyphicon glyphicon-trash"></span>
            </button></span>';
			$status="";
			$status="Unsubscribed";
		}
		echo
		'
		<form action="" method="post">
		<input type="hidden" value='.$data->value.' name="unstype">
		<input type="hidden" value='.$data->id.' name="unsreqid">
		<input type="hidden" value='.$data->user.' name="unsuser">
		<input type="hidden" value='.$data->email.' name="unsemail">
		<tr>
		<td><input type="checkbox" id="id'.$data->id.'" name="unschk[]" class="containerr" value="'.$data->id.'" onclick="collectID(this.value)"></td><td>'.$data->email.'</td><td>'.$data->value.'</td><td>'.$data->recorded.'</td><td>'.$status.'</td><td>'.$action.'</td>
		</tr>
		</form>
		';
		if($wpcrcount==10)
		   {

			   break;
		   }
	}
	if( isset( $_SERVER['HTTP_HOST'] ) && isset( $data ) )
		$gdprfmnxtpage = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&wpcrpagecount='.$data->id;
	else
		$gdprfmnxtpage = $_SERVER['REQUEST_URI'].'&wpcrpagecount=1';
	// $gdprfmnxtpage=$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&wpcrpagecount='.$data->id;
	echo
	'
	<tfoot>
		<tr>
			<td colspan="7">
			<ul class="pager">';
		if(isset($_GET['wpcrpagecount']))
		{
             echo '
			 <script type="text/javascript">
            function goBack() {
              window.history.back();
                  }
                </script>
				<li class="previous" onclick="goBack()"><a style="cursor:pointer">Previous</a></li>';
		}

      if($wpcrcount==10)
	  {
	echo '<li class="next"><a href="'.$gdprfmnxtpage.'">Next</a></li>';
	  }


	echo '</ul>
			</td>
		</tr>
	</tfoot>

	';

}
//-----wp gdpr fix cookie consent table

function wpfresh5_showRequestToCookieConsent()
{

	global $wpdb;
	$table=$wpdb->prefix.'wpfresh5_gdpr_requests';

	 if(isset($_GET['wpcrpagecount']))
	  {
		  $wpcridin=$_GET['wpcrpagecount'];
		  $sql="select * from ".$table." where type='cookie' and id <".$wpcridin." order by id desc";

	  }
	  else
	  {
	  $sql="select * from ".$table." where type='cookie' order by id desc";
	  }
	$records=$wpdb->get_results($sql);
	$wpcrcount=0;
	$last=0;
	foreach($records as $data)
	{
		$wpcrcount++;

		if($data->value=='1')
		{
			$accept="<font color='green'>Accepted</font>";
		}
		else
		{
			$accept="<font color='red'>Did not Accept</font>";
		}

			$action='<button type="submit" name="cookieconsentremove" class="btn btn-danger" value="remove" onclick="return gdprdrAction()" data-toggle="tooltip" title="Remove Request">
			<span class="glyphicon glyphicon-trash"></span>
            </button>';

		echo
		'
		<form action="" method="post">
		<input type="hidden" value='.$data->id.' name="cookieconsentid">
		<tr>
		<td>'.$data->id.'</td><td>'.$data->ip.'</td><td>'.$accept.'</td><td>'.$data->recorded.'</td><td>'.$action.'</td>
		</tr>
		</form>
		';
		if($wpcrcount==10)
		   {

			   break;
		   }
	}

	if( isset( $_SERVER['HTTP_HOST'] ) && isset( $data ) )
		$gdprfmnxtpage = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&wpcrpagecount='.$data->id;
	else
		$gdprfmnxtpage = $_SERVER['REQUEST_URI'].'&wpcrpagecount=1';

	// $gdprfmnxtpage=$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&wpcrpagecount='.$data->id;
	echo
	'
	<tfoot>
		<tr>
			<td colspan="7">
			<ul class="pager">';
		if(isset($_GET['wpcrpagecount']))
		{
             echo '
			 <script type="text/javascript">
            function goBack() {
              window.history.back();
                  }
                </script>
				<li class="previous" onclick="goBack()"><a style="cursor:pointer">Previous</a></li>';
		}

      if($wpcrcount==10)
	  {
	echo '<li class="next"><a href="'.$gdprfmnxtpage.'">Next</a></li>';
	  }


	echo '</ul>
			</td>
		</tr>
	</tfoot>

	';
}



//--------gdpr send mail function----
function wpfresh5_gdprSendWPMail($to,$subject,$body)
{
	$wpcrmailheaders = "MIME-Version: 1.0" . "\r\n";
                $wpcrmailheaders .= "Content-type:text/html;charset=UTF-8" . "\r\n";

				$wpcrmailbody='
				<html><head></head><body>
				<p style="font-size:18px;padding:2px;margin-top:8px;margin-bottom:6px;color:white;background-color:#003366;">'.$subject.'</p><br>
				<p>'.$body.'</p>
				</body></html>
				';

				wp_mail($to,$subject,$body,$wpcrmailheaders);
}
//--------gdpr short code frgt me request function----
function wpfresh5_gdprRequestForgetMe()
{
	$head="Hello,<br>A request to forget was created on your blog. It's logged in the admin section of ".get_bloginfo('name').". <br>";
	$foot="<br>Please review it when convenient.<br>Thanks";

	$pref='wpf5gdpr-';
	global $wpdb;
	$table=$wpdb->prefix."wpfresh5_gdpr_requests";
	$login='0';
if(is_user_logged_in())
{
	if(email_exists($_POST['gdprEmail'])==get_current_user_id())
	{$login='1';}
}
if($_POST['gdprfmchkboxc']=='c')
{
	if($login=='0')
   {
	   $vlogin=wpfresh5_gdprMailConfirmationLink($_POST['gdprEmail'],'Request to Forget Comments Confirmation','fm');
	   $clogin=$vlogin;
   }
	else
	{$clogin=$login;}
	$in=$wpdb->query($wpdb->prepare("insert into ".$table."(id,user,email,login, type,ip,value,updatedvalue,recorded,action, actiontime)values(%d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",array('',get_current_user_id(),$_POST['gdprEmail'],$clogin,'fm',$_SERVER['REMOTE_ADDR'],'c','',date('d-M-Y h:iA'),'0',' ')));

	$body=$head."The requesting email : ".$_POST['gdprEmail'].$foot;
	wpfresh5_gdprSendWPMail(get_option($pref.'rtbf-email'),'Request to forget created',$body);

}
if(isset( $_POST['gdprfmchkboxp'] ) && ( $_POST['gdprfmchkboxp']=='p' ) )
{
	if($login=='0')
   {
	   $vlogin=wpfresh5_gdprMailConfirmationLink($_POST['gdprEmail'],'Request to Forget Posts Confirmation','fm');
	   $plogin=$vlogin;
   }
	else {$plogin=$login;}
	$in=$wpdb->query($wpdb->prepare("insert into ".$table."(id,user,email,login, type,ip,value,updatedvalue,recorded,action, actiontime)values(%d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",array('',get_current_user_id(),$_POST['gdprEmail'],$plogin,'fm',$_SERVER['REMOTE_ADDR'],'p','',date('d-M-Y h:iA'),'0',' ')));

	$body=$head."The requesting email : ".$_POST['gdprEmail'].$foot;
	wpfresh5_gdprSendWPMail(get_option($pref.'rtbf-email'),'Request to forget created.',$body);
}
if(isset( $_POST['gdprfmchkboxu'] ) && ( $_POST['gdprfmchkboxu']=='u' ) )
{
	if($login=='0')
   {
	   $vlogin=wpfresh5_gdprMailConfirmationLink($_POST['gdprEmail'],'Request to Forget User Meta Confirmation','fm');
	   $ulogin=$vlogin;
   }
	else {$ulogin=$login;}
	$in=$wpdb->query($wpdb->prepare("insert into ".$table."(id,user,email,login, type,ip,value,updatedvalue,recorded,action, actiontime)values(%d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",array('',get_current_user_id(),$_POST['gdprEmail'],$ulogin,'fm',$_SERVER['REMOTE_ADDR'],'u','',date('d-M-Y h:iA'),'0',' ')));

	$body=$head."The requesting email : ".$_POST['gdprEmail'].$foot;
	wpfresh5_gdprSendWPMail(get_option($pref.'rtbf-email'),'Request to forget created .',$body);
}
/*if($login=='1')
{echo "<script>alert('Request Received');</script>";}
else
{echo "<script>alert('Confirmation mail sent');</script>";}*/
}
//-------------gdpr short code data access request submission------------
function wpfresh5_gdprRequestDataAccess()
{
	$pref='wpf5gdpr-';
	global $wpdb;
	$table=$wpdb->prefix."wpfresh5_gdpr_requests";
	$login='0';
if(is_user_logged_in())
{
	if(email_exists($_POST['gdprEmail'])==get_current_user_id())
	{
		$login='1';
		$in=$wpdb->query($wpdb->prepare("insert into ".$table."(id,user,email,login, type,ip,value,updatedvalue,recorded,action, actiontime)values(%d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",array('',get_current_user_id(),$_POST['gdprEmail'],$login,'da',$_SERVER['REMOTE_ADDR'],'','',date('d-M-Y h:iA'),'0',' ')));

	}

}
if($login=='0')
{
	$login=wpfresh5_gdprMailConfirmationLink($_POST['gdprEmail'],'Data Access Confirmation','da');
	$in=$wpdb->query($wpdb->prepare("insert into ".$table."(id,user,email,login, type,ip,value,updatedvalue,recorded,action, actiontime)values(%d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",array('',get_current_user_id(),$_POST['gdprEmail'],$login,'da',$_SERVER['REMOTE_ADDR'],'','',date('d-M-Y h:iA'),'0',' ')));
	// echo "<script>alert('Confirmation Link Sent')</script>";
}



	$body="Hello,<br>A data access report was filed by ".$_POST['gdprEmail']." The report has been logged in the admin of ".get_bloginfo('name').".<br>Please review at your convenience.<br>Thanks";
	wpfresh5_gdprSendWPMail(get_option($pref.'da-email'),'Data report requested',$body);
	// if($login=='1')
	// {echo "<script>alert('Request Received');</script>";}
}

//---------gdpr shortcode data rectification request submission--------
function wpfresh5_gdprRequestDataRectification()
{
	$head="Hello,<br>A data rectification request was logged by <br>";
	$foot="<br>It's recorded in the admin of ".get_bloginfo('name').".<br>Please review when convenient.<br>Thanks";

	$pref='wpf5gdpr-';
	global $wpdb;
	$table=$wpdb->prefix."wpfresh5_gdpr_requests";
	$login='0';
if(is_user_logged_in())
{
	if(email_exists($_POST['gdprEmail'])==get_current_user_id())
	{$login='1';}
}
if( isset( $_POST['gdprdrchkboxc'] ) && ( $_POST['gdprdrchkboxc']=='c' ) )
{
	if($login=='0')
   {
	   $vlogin=wpfresh5_gdprMailConfirmationLink($_POST['gdprEmail'],'Request to rectify Comments confirmation','dr');
	   $clogin=$vlogin;
   }
	else
	{$clogin=$login;}
	$in=$wpdb->query($wpdb->prepare("insert into ".$table."(id,user,email,login, type,ip,value,updatedvalue,recorded,action, actiontime)values(%d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",array('',get_current_user_id(),$_POST['gdprEmail'],$clogin,'dr',$_SERVER['REMOTE_ADDR'],'c',$_POST['gdprrectification'],date('d-M-Y h:iA'),'0',' ')));

	$body=$head.$_POST['gdprEmail'].$foot;
	wpfresh5_gdprSendWPMail(get_option($pref.'drr-email'),'Data rectification request logged',$body);

}
if( isset( $_POST['gdprdrchkboxp'] ) && ( $_POST['gdprdrchkboxp']=='p' ) )
{
	if($login=='0')
   {
	   $vlogin=wpfresh5_gdprMailConfirmationLink($_POST['gdprEmail'],'Request to forget Posts confirmation','dr');
	   $plogin=$vlogin;
   }
	else {$plogin=$login;}
	$in=$wpdb->query($wpdb->prepare("insert into ".$table."(id,user,email,login, type,ip,value,updatedvalue,recorded,action, actiontime)values(%d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",array('',get_current_user_id(),$_POST['gdprEmail'],$plogin,'dr',$_SERVER['REMOTE_ADDR'],'p',$_POST['gdprrectification'],date('d-M-Y h:iA'),'0',' ')));

	$body=$head.$_POST['gdprEmail'].$foot;

	wpfresh5_gdprSendWPMail(get_option($pref.'drr-email'),'Data rectification request logged',$body);
}
if( isset( $_POST['gdprdrchkboxu'] ) && ( $_POST['gdprdrchkboxu']=='u' ) )
{
	if($login=='0')
   {
	   $vlogin=wpfresh5_gdprMailConfirmationLink($_POST['gdprEmail'],'Request to rectify User data Confirmation','dr');
	   $ulogin=$vlogin;
   }
	else {$ulogin=$login;}
	$in=$wpdb->query($wpdb->prepare("insert into ".$table."(id,user,email,login, type,ip,value,updatedvalue,recorded,action, actiontime)values(%d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",array('',get_current_user_id(),$_POST['gdprEmail'],$ulogin,'dr',$_SERVER['REMOTE_ADDR'],'u',$_POST['gdprrectification'],date('d-M-Y h:iA'),'0',' ')));

	$body=$head.$_POST['gdprEmail'].$foot;
	wpfresh5_gdprSendWPMail(get_option($pref.'drr-email'),'Data rectification request logged',$body);
}
/*if($login=='1')
{echo "<script>alert('Request Received');</script>";}
else
{echo "<script>alert('Confirmation mail sent');</script>";}*/
}

//----gdpr shortcode unsubscription function-----

function wpfresh5_gdprUnsubscriptionRequestSubmit()
{
	$pref='wpf5gdpr-';
	global $wpdb;
	$table=$wpdb->prefix."wpfresh5_gdpr_requests";
	$login='0';
if(is_user_logged_in())
{
	if(email_exists($_POST['gdprEmail'])==get_current_user_id())
	{
		$login='1';
		$in=$wpdb->query($wpdb->prepare("insert into ".$table."(id,user,email,login, type,ip,value,updatedvalue,recorded,action, actiontime)values(%d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",array('',get_current_user_id(),$_POST['gdprEmail'],$login,'uns',$_SERVER['REMOTE_ADDR'],$_POST['gdprName'],'',date('d-M-Y h:iA'),'0',' ')));

	}

}
if($login=='0')
{
	$login=wpfresh5_gdprMailConfirmationLink($_POST['gdprEmail'],'Unsubscription Confirmation','uns');
	$in=$wpdb->query($wpdb->prepare("insert into ".$table."(id,user,email,login, type,ip,value,updatedvalue,recorded,action, actiontime)values(%d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",array('',get_current_user_id(),$_POST['gdprEmail'],$login,'uns',$_SERVER['REMOTE_ADDR'],$_POST['gdprName'],'',date('d-M-Y h:iA'),'0',' ')));
	// echo "<script>alert('Confirmation Link Sent')</script>";
}



	//$body="<b>From : ".$_POST['gdprEmail']."</b>";
	//wpfresh5_gdprSendWPMail(get_option($pref.'da-email'),'Unsubscription Request Received',$body);
	// if($login=='1')
	// {echo "<script>alert('Request Received');</script>";}
}



//-------mail confirmation link-------
function wpfresh5_gdprMailConfirmationLink($to,$subject,$type)
{
	if($type=='da')
	{
		$subject="Please confirm your data request";
		$cnfheader="Hello,<br>You've made a request to report all the data we have on you with us.<br>Plese confirm that you have indeed made this request by clicking the link below.<br>";
        $cnffooter="<br>Your data will be sent to you on confirmation.<br>Thanks";
	}
	if($type=='fm')
	{
		$subject="Request to Forget";
		$cnfheader="Hello,<br>You've made a request to forget with us. Please click on the link below to confirm that the request is valid. Your request will be processed after you click the confirmation.<br>";
        $cnffooter="<br>Thanks";
	}
	if($type=='dr')
	{
		$subject="Your request to rectify data";
		$cnfheader="Hello,<br>You've made a request to rectify your data with us. Please click on the link below to confirm the request.<br>";
        $cnffooter="<br>Your data will be rectified by the admin on confirmation.<br>Thanks";
	}
	if($type=='uns')
	{
		$subject="Your unsubscribe request";
		$cnfheader="Hello,
<br>
This is in reference to the unsubscribe request that you submitted with us.
<br>
Please click on the link below to confirm unsubscrition.<br>";
        $cnffooter="<br>The blog administrator will be notified and you will be unsubscribed as soon as possible.<br>Thanks";
	}
	$wpcrmailheaders = "MIME-Version: 1.0" . "\r\n";
    $wpcrmailheaders .= "Content-type:text/html;charset=UTF-8" . "\r\n";
	$otp=substr(str_shuffle('123456789abscfghijklmnopqrstuvwxyz@ABCDFGHJ'),0,5);
	$msg=get_permalink().'?gdpremail='.$to.'&gdprtype='.$type.'&gdprotp='.$otp;
	$msg=$cnfheader.$msg.$cnffooter;
	wp_mail($to,$subject,$msg,$wpcrmailheaders);
	return $otp;
}

//-------terms and conditions set or not--
function wpfresh5_isSetTandC()
{$pref='wpf5gdpr-';
	if(get_option($pref.'tandc-bef')!='0')

		{
			return 1;
		}
		else
		{
			return 0;
		}
}
//-------privacy policy set or not--
function wpfresh5_isSetPP()
{$pref='wpf5gdpr-';
	if(get_option($pref.'pp-bef')!='0')

		{
			return 1;
		}
		else
		{
			return 0;
		}
}
//--------did the user form published or not----------
function wpfresh5_isUserFormPublished()
{
	$count=0;
	$pref='wpf5gdpr-';
$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query(array('post_type' =>get_post_types('', 'names')));
$all_children = get_page_children( get_the_ID(), $all_wp_pages );
foreach($all_children as $child)
{
	if(has_shortcode( $child->post_content, 'GDPR_UserRequestForm'))
	{

		$count=1;
		break;
	}
}
return $count;
}
function wpfresh5_complianceStatus()
{//compliance status
	$pref='wpf5gdpr-';
		$count=0;
		$settings = wpfresh5_get_plugin_settings();
		if( isset( $settings['legal'] ) && isset( $settings['legal']['cookies'] )  && ( $settings['legal']['cookies']['cookiew_enabled'] ) )
		  $count++;
	 // if(strlen(get_option($pref.'notice'))>0){$count++;}
	 if(wpfresh5_isSetTandC()==1){$count++;}
	 if(wpfresh5_isSetPP()==1){$count++;}
	 if(strlen(get_option($pref.'rtbf-message'))>0){$count++;}
	 if(strlen(get_option($pref.'da-message'))>0){$count++;}
	 if(strlen(get_option($pref.'dbr-message'))>0){$count++;}
	 if(strlen(get_option($pref.'drr-message'))>0){$count++;}
	 //if(get_option($pref.'eu-active')=='0'){$count++;}
	 return $count;
}

//-----------EU country or not---------
function wpfresh5_is_eu_visitor()
{
  $ip = $_SERVER['REMOTE_ADDR']; // the IP address to query
  $query = @unserialize(file_get_contents('http://ip-api.com/php/'.$ip));
  // var_dump($query);die();
  if($query && $query['status'] == 'success')
  {
	  $my_countrieseuro = array('BE','BG','CZ','DK','DE','EE','IE','EL','ES','FR','HR','IT','CY','LV','LT','LU','HU','MT','NL','AT','PL','PT','RO','SI','SK','FI','SE','UK','GB');
    if (in_array($query['countryCode'], $my_countrieseuro)) {
    	return 1;
    }
    else{
    	return 0;
    }

  }
}

//----GDPR Visual Editor Text---------
function wpfresh5_gdprEditorText($type)
{
	if($type=='cookie')
	{
		$text="Important<br>
This site makes use of cookies which may contain tracking information about visitors. By continuing to browse this site you agree to our use of cookies.
";
	}
	if($type=='rightforget')
	{
		$text="Hello,<br>

Please refer to your request to forget your data on our blog. <br>

This is to report that action has been taken and your data has been forgotten as requested.<br>

If you have any queries, please let us know.<br>

Thanks
";
	}
	if($type=='dataaccess')
	{
		$text="Hello,<br>

Please refer to your request to report all the data that we have about you.<br>

Enclosed please find all the data that we have on you. <br>

If you need any more information, please let us know .<br>

Thanks
";
	}
	if($type=='databreach')
	{
		$text="Hello,<br>

We regret to inform you that there was a data breach on our site and your information or passwords may be compromised.<br>

We request you to change your password on our site asap, and also any other site where you may have used the same password.<br>

Please also review your information with us and ensure that you are adequately protected against any misuse.<br>

We are working to bridge the breach and you’ll be notified of further developments if any.<br>

Thanks
";
	}
	if($type=='datarectification')
	{

		$text="Hello,<br>

Please refer to your data rectification request with us. We are pleased to inform you that action was taken on your request and your data has been rectified.<br>

Please let us know if you need any other help.<br>

Thanks
";
	}
	return $text;
}

/* Add buttons to accept */

add_filter( 'the_content', 'wpfresh5_gdpr_add_accept_btn' );

function wpfresh5_gdpr_add_accept_btn( $content ) {
	if( !is_page() || !isset( $_GET['force_accept'] ) )
		return $content;
	$tandc_page = get_option( 'wpf5gdpr-tandc-bef');
	if( $tandc_page && is_page( $tandc_page ) ) {
		$prev_txt = '<h2 style="font-weight:bold">Please note: You need to accept our Terms and Conditions before you can browse our site</h2><br/>';
		return $prev_txt.$content.wpfresh5_tandcacceptbutton();
	}

	$pp_page = get_option( 'wpf5gdpr-pp-bef');
	if( $pp_page && is_page( $pp_page ) ) {
		$prev_txt = '<h2 style="font-weight:bold">Please note: You need to accept our Privacy Policy before you can browse our site</h2><br/>';
		return $prev_txt.$content.wpfresh5_ppacceptbutton();
	}
}
?>