<?php session_start();
error_reporting(E_ALL ^ E_WARNING); 
?>
<!DOCTYPE html>
<html lang="en">
   <head>
      <title>Theme Activate Panel</title>
      <meta charset="utf-8">
      <!-- Viewport configuration, scaling options -->
      <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
      <!---Canonical-Tage--->
      <link rel="canonical" href="theme-activate-panel.html">
      <link href="assets/css/bootstrap.min.css" rel="stylesheet">
      <!-- Roboto font  -->
      <link rel="preconnect" href="https://fonts.googleapis.com">
      <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
      <link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&display=swap" rel="stylesheet">
      <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
      <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
      <![endif]-->
   </head>
   <body>
   <!--Unique id Begin-->
   <div id="s_mm">
      <!--TopBar Begin-->
      <div class="bg-primary p-3">
         <div class="container-fluid">
            <div class="row">
               <h5 class="text-center text-white p-0 m-0">Enter your purchase code here, to activate the item and get unlock full features.</h5>
            </div>
         </div>
      </div>
      <!--TopBar End-->
      <section class="py-5">
         <div class="container">
            <div class="row">
               <div class="col-md-8 mx-auto">
                  <div class="alert alert-secondary mb-4" role="alert">
                     <div class="text-center">
                        <h5 class="m-0">Activate purchase code</h5>
                     </div>
                  </div>
                  <div class="alert alert-secondary mb-4" role="alert">
                     <!--form Begin-->
                     <form action="./forms/verify.php" method="post" id="verify-envato-purchase">
                        <div class="mb-3">
                           <label for="licence" class="form-label">Item Purchase Code:</label>
                           <input type="text"  name="purchase_code" class="form-control" id="input-purchase-code" maxlength="60" placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" maxlength="40" required>
                        </div>
                         <button type="submit" value="Verify Purchase" class="btn btn-primary">Continue</button>
                        <!-- <a href="sql-connection.html" class="btn btn-primary">Continue</a> -->
                        <a href="sql-connection.html" target="_blank" class="float-end text-dark mt-2">Where is my purchase code?</a>
                     </form>
                     <!--form End-->
                  </div>
               </div>
            </div>
         </div>
         <div id="show-result">
            <?php if($_SESSION['status'] !=""){?>
               <span style='color: red'>Sorry, This is not a valid purchase code or this user have not purchased any of your items.</span>
               <?php unset($_SESSION['status']);  } ?>
               <?php if($_SESSION['notactive'] !=""){?>
               <span style='color: red'>THIS CODE ALREADY RUN IN OTHER DOMAIN, PLEASE DEACTIVATE YOUR SIDE</span>
               <?php unset($_SESSION['notactive']);  } ?>
         </div>
      </section>
     </div>
	 <!--Unique id End-->
    <script src="assets/js/bootstrap.bundle.min.js"></script>
    <script src="assets/js/jquery-3.4.1.min.js"></script>
    <script type="text/javascript">
      $(document).ready( function() {
        var form = $('#verify-envato-purchase');

        $('#verify-envato-purchase').submit(function(e){
          e.preventDefault();

          $.ajax( {
            type: "POST",
            url: form.attr( 'action' ),
            data: form.serialize(),
            success: function( response ) {
               //console.log(response);
              //alert(response)
               if(response=="<span style='color: red'>Sorry, This is not a valid purchase code or this user have not purchased any of your items.</span>"){
               window.location.replace("theme-activate-panel.php");
              // $("#show-result").html(response);
               }else if(response==""){
                  window.location.replace("theme-activate-panel.php");
               }
               else{
                  window.location.replace("sql-connection.php");
               }
            }
          } );
        } );
      } );
</script>
   </body>
</html>