<?php
if((isset($_GET['gdpremail']))&&(isset($_GET['gdprtype']))&&(isset($_GET['gdprotp'])))
{

	global $wpdb;
	$utable=$wpdb->prefix."wpfresh5_gdpr_requests";
	$uupdate=$wpdb->query($wpdb->prepare("update ".$utable." set login=%s where email=%s and type=%s and login=%s ",array('2',$_GET['gdpremail'],$_GET['gdprtype'],$_GET['gdprotp'])));
	/*if($uupdate)
	{
		echo "<script>alert('Request Confirmed');</script>";
	}*/
}
?>

<?php
if(isset($_POST['gdprpdasubmit']))
{

     if(filter_var($_POST['gdprEmail'],FILTER_VALIDATE_EMAIL))
	{wpfresh5_gdprRequestDataAccess();	}


}
if(isset($_POST['gdprfmsubmit']))
{
	if(filter_var($_POST['gdprEmail'], FILTER_VALIDATE_EMAIL))
	{wpfresh5_gdprRequestForgetMe();	}

}
if(isset($_POST['gdprdrsubmit']))
{
	if(filter_var($_POST['gdprEmail'],FILTER_VALIDATE_EMAIL))
	{wpfresh5_gdprRequestDataRectification();	}
}
if(isset($_POST['gdprunssubmit']))
{
	if ( filter_var($_POST['gdprEmail'],FILTER_VALIDATE_EMAIL)/*(preg_match("/^[a-zA-Z'. -]+$/", $_POST['unsname']))&&(filter_var($_POST['unsemail'],FILTER_VALIDATE_EMAIL))*/)
	{
        wpfresh5_gdprUnsubscriptionRequestSubmit();
    }
}
?>


<?php
function wpfresh5_gdpr_user_req_form()
{
	$pref='wpf5gdpr-';
	if( isset( $_POST['wpfs5gpdrf'] ) && ( $_POST['wpfs5gpdrf'] ) ) {
		return '<p>Thank you for your message.</p><p>Your request has been sent to our Data Protection Officer. We will attend to it as soon as possible</p>';
	}
	$formstruct='
<h3>Exercise your rights under GDPR</h3>

<p>Send your GDPR request via the form below.</p>

<p>Your request will be sent to the Data Protection Officer.</p>
<form action="" method="POST">
<label class="gpdrlabel">What\'s your name</label>
<input type="text" name="gdprName" class="gpdrfield" required="required" />
<label class="gpdrlabel">What\'s your email</label>
<input type="text" name="gdprEmail" class="gpdrfield" required="required" />

<label class="gpdrlabel">What do you want to get done?</label>
<select id="gdpraction" name="gdpraction" class="gpdrfield">
  <option value="gdprPDA">I want to access all my data</option>
  <option value="gdprFM">I want to delete my personal data ("Right to be forgotten")</option>
  <option value="gdprDR">I want to rectify my personal data</option>
  <option value="gdprUR">I want to request to be unsubscribed</option>
</select>

<div id="gdprpda" class="wpgdprpanel" style="display:block">
<br/>

<p>
<b>Request a copy of the data we have about you. An email will be sent to you with the data after it\'s generated.</b></p>

<!--<label for="gdprEmail">Email:</label>
<input type="email" id="gdprEmail" name="gdprEmail" value="" required="">-->
<br>

 <button type="submit" name="gdprpdasubmit" class="gdprsubmitbtn" value="1">Submit Request</button>

<!--</form>-->
</div>

<div id="gdprfm" class="wpgdprpanel" style="display:none">
<!--<form action="" method="post">-->
<br/>
<p>
<b>
Select what data you would like to get deleted. You’ll be notified by email once it’s done.
</b></p>
<label class="containerr">
<input type="checkbox" name="gdprfmchkboxc" value="c">
WordPress Comments (Your comments on posts/pages)
</label>
<br>
<label class="containerr">
<input type="checkbox" name="gdprfmchkboxp" value="p">
WordPress Posts (any posts created by you)
</label>
<br>
<label class="containerr">
<input type="checkbox" name="gdprfmchkboxu" value="u">
WordPress User Data (your user details on this site)
</label>
 <br>
 <br>
<!--//  <br><label for="">Email:</label><br>
// <input type="email" class="form-control" name="gdprEmail" value="" required="">
// <br>-->
<label class="containerr">
I consent to my email being collected in order to process this request. See Privacy Policy page for more information.
 <input type="checkbox" name="gdprchkbox" value="1" >
</label>
<br/>
<br/>
 <button type="submit" name="gdprfmsubmit" class="btn btn-primary gdprsubmitbtn" value="1">Submit Request</button>
<!--</form>-->
</div>

<div id="gdprdr" class="wpgdprpanel" style="display:none">
<br/>
<!--<form action="" method="post">-->

<label class="containerr">
<input type="checkbox" name="gdprdrchkboxc" value="c">
WordPress Comments (Your comments on posts/pages)
</label>
<br>
<label class="containerr">
<input type="checkbox" name="gdprdrchkboxp" value="p">
WordPress Posts (any posts created by you)
</label>
<br>
<label class="containerr">
<input type="checkbox" name="gdprdrchkboxu" value="u">
WordPress User Data (your user details on this site)
</label>
<br/>

<label class="gpdrlabel">What data would you like to be rectified?</label>
<textarea name="gdprrectification" class="gpdrfield" rows="5" ></textarea><br>

<!--<label for="">Email:</label><br>
<input type="email" class="form-control" name="gdprEmail" value="" required="">
-->
<br>

<button type="submit" name="gdprdrsubmit" class="btn btn-primary gdprsubmitbtn" value="1">Submit Request</button>

<!--</form>-->
     </div>

   <div id="gdprur" class="wpgdprpanel" style="display:none">
   <br/>
   <br/>
   <div class="alert alert-warning">'.get_option($pref.'uns-notification').'</div>
<!--<form action="" method="post">
<label for="">Name:</label>
<input type="text" id="" class="form-control" name="unsname" value="" required="">
<br>
<label for="">Email:</label>
<input type="email" id="" class="form-control" name="unsemail" value="" required="">
<br>-->
 <button type="submit" name="gdprunssubmit" class="gdprsubmitbtn" value="1">Submit Request</button>
<!--</form>-->
</div>
<input type="hidden" name="wpfs5gpdrf" value="1" />
</form>
<br/>

<style>
</style>';

return $formstruct;
}
?>