<?php
    // define('SHORTINIT', true);
    define( 'WP_USE_THEMES', false );
    require_once(dirname(__FILE__) . '/../../../wp-load.php');
    $agents = get_option( 'okewa_agents' );
    $agent_num = count($agents['btns']);
    $rotation = $_GET['id'];
    if( $agent_num > $rotation ) {
        $rotation++;
    } else {
        $rotation = 1;
    }
    $settings = get_option( 'okewa_settings' );
    $settings['rotation'] = $rotation;
    update_option('okewa_settings', $settings);
    $number = $_GET['no'];
    $message = $_GET['msg'];
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">  
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <style>
		html, body {
		  height: 100%;
		  margin: 0;
		  padding: 0;
		}

		#startup {
		  width: 100%;
		  height: 100%;
		  position: fixed;
		  background-color: #eeeeee;

		  -moz-user-select: none;
		  -webkit-user-select: none;

		  display: flex;
		  align-items: center;
		  justify-content: center;
		  display: -webkit-box;
		  display: -webkit-flex;
		  -webkit-align-items: center;
		  -webkit-justify-content: center;
		}

		.spinner-container {
		  -webkit-animation: rotate 2s linear infinite;
		  animation: rotate 2s linear infinite;
		}

		.spinner-container .path {
		  stroke-dasharray: 1,150; /* 1%, 101% circumference */
		  stroke-dashoffset: 0;
		  stroke: rgba(27, 154, 89, 0.7);
		  stroke-linecap: round;
		  -webkit-animation: dash 1.5s ease-in-out infinite;
		  animation: dash 1.5s ease-in-out infinite;
		}

		@keyframes rotate {
		  100% { transform: rotate(360deg); }
		}
		@-webkit-keyframes rotate{
		  100% { -webkit-transform: rotate(360deg); }
		}

		@keyframes dash {
		  0% {
			stroke-dasharray: 1,150;  /* 1%, 101% circumference */
			stroke-dashoffset: 0;
		  }
		  50% {
			stroke-dasharray: 90,150; /* 70%, 101% circumference */
			stroke-dashoffset: -35;   /* 25% circumference */
		  }
		  100% {
			stroke-dasharray: 90,150; /* 70%, 101% circumference */
			stroke-dashoffset: -124;  /* -99% circumference */
		  }
		}
		@-webkit-keyframes dash {
		  0% {
			stroke-dasharray: 1,150;  /* 1%, 101% circumference */
			stroke-dashoffset: 0;
		  }
		  50% {
			stroke-dasharray: 90,150; /* 70%, 101% circumference */
			stroke-dashoffset: -35;   /* 25% circumference */
		  }
		  100% {
			stroke-dasharray: 90,150; /* 70%, 101% circumference */
			stroke-dashoffset: -124;  /* -99% circumference */
		  }
		}
    </style>
  </head>
<body>    
<div id="startup">
  <svg class="spinner-container" width="65px" height="65px" viewBox="0 0 52 52">
    <circle class="path" cx="26px" cy="26px" r="20px" fill="none" stroke-width="4px" />
  </svg>
</div>
<?php echo $settings['fb_pixel']; ?>
<script>
var width = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
if (width > 767) {
    setTimeout(function(){
      window.location.href = "https://web.whatsapp.com/send?phone=<?php echo $number; ?>&text=<?php echo $message; ?>";
    }, 500);
}
else {
    setTimeout(function(){
      window.location.href = "whatsapp://send/?phone=<?php echo $number; ?>&text=<?php echo $message; ?>";
    }, 500);
}
</script>
</body>
</html>