<?php

if( isset( $_POST['wpfs5_gpdr_cookies_save'] ) ) {
  wpfresh5_save_legal_cookies();
}
$pref='wpf5gdpr-';
//---------all new

if(get_option($pref.'dont-accept-cookie-url'))
{

}
else
{
  add_option($pref.'dont-accept-cookie-url','');
}
//-------cooki record remove

if(isset($_POST['cookieconsentremove']))
{
  global $wpdb;
  $table=$wpdb->prefix."wpfresh5_gdpr_requests";
  $wpdb->query($wpdb->prepare("delete from ".$table." where id=%d ",array($_POST['cookieconsentid'])));
}

//------
if(isset($_POST['defctext']))
{
  update_option($pref.'notice',wpfresh5_gdprEditorText('cookie'));
}
if(isset($_POST['savegdprcookie']))
{
update_option($pref.'notice',stripslashes($_POST['gdprnotice']));
update_option($pref.'show',$_POST['cookie']);
update_option($pref.'cookie-style',$_POST['gdprcustomstyle']);
update_option($pref.'cookie-text-color',$_POST['gdprtxtcolor']);
update_option($pref.'cookie-bg-color',$_POST['gdprbgcolor']);
update_option($pref.'cookie-position',$_POST['gdprcookieposition']);
update_option($pref.'cookie-distance',$_POST['wpgdrdistance']);
update_option($pref.'cookie-accept-button',$_POST['wpgdracceptbuttontext']);

if(isset($_POST['wpgdprcookieeu']))
{
  update_option($pref.'cookie-eu','1');
}
else
{
  update_option($pref.'cookie-eu','0');
}
if(filter_var($_POST['wpgdrdntacceptbuttonurl'],FILTER_VALIDATE_URL))
{
  update_option($pref.'dont-accept-cookie-url',$_POST['wpgdrdntacceptbuttonurl']);
}
else
{
  echo "<script>alert('Please enter a valid url where to redirect if user does not accept cookie');</script>";
}

}

$chkd="";
if(get_option($pref.'show')=='1')
{
  $chkd="checked";
}
//wp editor style
$settings = array(
    'textarea_rows' => 8,
);
?>

   <?php
    $settings = wpfresh5_get_plugin_settings();
    wpfresh5_settings_legal_tab_cookies( $settings );
    ?>
    <h4 class="m0">Cookie Log</h4>

    <table class="table widefat gdprrqtable">
      <thead>
        <tr>
        <th>#</th>
        <th>IP</th>
        <th>Status</th>
        <th>Time</th>
        <th>Options</th>
          </tr>
      </thead>
      <tbody>
      <?php wpfresh5_showRequestToCookieConsent(); ?>
      </tbody>
     </table>
<input type="hidden" name="wpfs5_gpdr_cookies_save" value="1">