<?php
session_start();
require("../../mainconfig.php");
$msg_type = "nothing";

if (isset($_SESSION['user'])) {
	header("Location: ".$cfg_baseurl);
} else {
	if (isset($_POST['verif'])) {
		$post_code = mysqli_real_escape_string($db, trim($_POST['code']));
		$check_code = mysqli_query($db, "SELECT * FROM users WHERE verif_code = '$post_code'");
	    $data_user = mysqli_fetch_assoc($check_code);
			
		if (empty($post_code)) {
			$msg_type = "error";
			$msg_content = "<script>swal('Error!', 'Mohon mengisi input.', 'error');</script><b>Gagal:</b> Mohon mengisi input.";
		} else if (mysqli_num_rows($check_code) == 0) {
			$msg_type = "error";
			$msg_content = "<script>swal('Error!', 'Kode verifikasi tidak ditemukan.', 'error');</script><b>Gagal:</b> Kode verifikasi tidak ditemukan.";
		} else {

    $update_user = mysqli_query($db, "UPDATE users SET status = 'Active' WHERE verif_code = '$post_code'");
    if ($update_user == TRUE) {
           $msg_type = "success";
		   $msg_content = "<b>Berhasil:</b> Akun berhasil diaktivasi. Anda akan dialihkan ke halaman login.<META HTTP-EQUIV=Refresh CONTENT=\"2; URL=login\">"; 
    } else {
           $msg_type = "error";
		   $msg_content = "<b>Gagal:</b> ERROR.";        
        }	   
		}
	}
}

?>
                        <!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="SMM Panel Indonesia yang menyediakan Followers, Likes, Views, Subscriber, untuk beragam social media: Instagram, Youtube, Facebook, Twitter dengan harga Termurah." name="description"/>
    <title>Borneo Media - SMM</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="keywords" content="SMM Panel Indonesia, Followers, Likes, Views, Subscriber, untuk beragam social media: Instagram, Youtube, Facebook, Twitter, harga Termurah">
    <meta name="author" content="</CODINGINAN>">
    <link rel="icon" href="<?= $cfg_baseurl ?>assets/images/favicon.png" type="image/x-icon">
    <link rel="shortcut icon" href="<?= $cfg_baseurl ?>assets/images/favicon.png" type="image/x-icon">
    <!-- Google font-->
    <link href="https://fonts.googleapis.com/css?family=Rubik:400,400i,500,500i,700,700i&amp;display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i,900&amp;display=swap" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="../../assets/css/font-awesome.css">
    <!-- ico-font-->
    <link rel="stylesheet" type="text/css" href="../../assets/css/vendors/icofont.css">
    <!-- Themify icon-->
    <link rel="stylesheet" type="text/css" href="../../assets/css/vendors/themify.css">
    <!-- Flag icon-->
    <link rel="stylesheet" type="text/css" href="../../assets/css/vendors/flag-icon.css">
    <!-- Feather icon-->
    <link rel="stylesheet" type="text/css" href="../../assets/css/vendors/feather-icon.css">
    <!-- Plugins css start-->
    <!-- Plugins css Ends-->
    <!-- Bootstrap css-->
    <link rel="stylesheet" type="text/css" href="../../assets/css/vendors/bootstrap.css">
    <!-- App css-->
    <link rel="stylesheet" type="text/css" href="../../assets/css/style.css">
    <link id="color" rel="stylesheet" href="../../assets/css/color-1.css" media="screen">
    <!-- Responsive css-->
    <link rel="stylesheet" type="text/css" href="../../assets/css/responsive.css">
  </head>
  <body>
    <!-- login page start-->
    <div class="container-fluid p-0">
      <div class="row m-0">
        <div class="col-12 p-0">    
          <div class="login-card login-dark">
            <div>
              <div><a class="logo" href="index.html"><img class="img-fluid for-light" src="../../assets/images/logo/logo.png" alt="looginpage"><img class="img-fluid for-dark" src="../../assets/images/logo/logo_dark.png" alt="looginpage"></a></div>
              <div class="login-main"> 
                <?php 
											if ($msg_type == "success") {
											?>
											<div class="alert alert-success dark" role="alert">
                      <p><?php echo $msg_content; ?></p>
                    </div>
											<?php
											} else if ($msg_type == "error") {
											?>
											<div class="alert alert-secondary dark" role="alert">
                          <p><?php echo $msg_content; ?></p>
                        </div>
											<?php
											}
											?>
                <form class="theme-form" method="POST">
                  <h4>Verify your account</h4>
                  <p>Enter your verification code</p>
                  <div class="form-group">
                    <label class="col-form-label">Verification Code</label>
                    <input class="form-control" type="number" name="code" required placeholder="Kode Verifikasi">
                  </div>
                  <div class="form-group mb-0">
                    <div class="text-end mt-3">
                      <button class="btn btn-primary btn-block w-100" type="submit" name="verif">Verif Sekarang!</button>
                    </div>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- latest jquery-->
      <script src="../../assets/js/jquery.min.js"></script>
      <!-- Bootstrap js-->
      <script src="../../assets/js/bootstrap/bootstrap.bundle.min.js"></script>
      <!-- feather icon js-->
      <script src="../../assets/js/icons/feather-icon/feather.min.js"></script>
      <script src="../../assets/js/icons/feather-icon/feather-icon.js"></script>
      <!-- scrollbar js-->
      <!-- Sidebar jquery-->
      <script src="../../assets/js/config.js"></script>
      <!-- Plugins JS start-->
      <!-- Plugins JS Ends-->
      <!-- Theme js-->
      <script src="../../assets/js/script.js"></script>
      <!-- Plugin used-->
      <script>
    function myFunction() {
      var x = document.getElementById("myInput");
      if (x.type === "password") {
        x.type = "text";
      } else {
        x.type = "password";
      }
    }
    
    function myFunction2() {
      var x = document.getElementById("myInput2");
      if (x.type === "password") {
        x.type = "text";
      } else {
        x.type = "password";
      }
    }
    </script>
    </div>
  </body>
</html>
<script src='https://www.google.com/recaptcha/api.js'></script>