<?php
session_start();

if (isset($_SESSION["user_id"]) and isset($_SESSION["password"])) {
	$dbhost=$_SESSION["dbhost"];
	$dbuser=$_SESSION["dbuser"];
	$dbpass=$_SESSION["dbpass"];
	
	$id=$_SESSION["user_id"];
	$password=$_SESSION["password"];
	$name=$_SESSION["name"];
	$fullname=$_SESSION["fullname"];
	$email=$_SESSION["email"];
	$birthday=$_SESSION["birthday"];
	$phone=$_SESSION["phone"];
	$address=$_SESSION["address"];
	$country=$_SESSION["country"];
	$image=$_SESSION["image"];

	//echo '<script>alert(" User ID : '.$_SESSION["user_id"].'")</script>';
	//echo '<script>alert(" Password : '.$_SESSION["password"].'")</script>';
	?>
	<!DOCTYPE html>
	<html lang="zxx">
	<head>
		<title>SuperCryptEX | Main</title>
		<meta charset="UTF-8">
		<meta name="description" content="SolMusic HTML Template">
		<meta name="keywords" content="music, html">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">

		<!-- Favicon -->
		<link href="img/favicon.ico" rel="shortcut icon"/>

		<!-- Google font -->
		<link href="https://fonts.googleapis.com/css?family=Montserrat:300,300i,400,400i,500,500i,600,600i,700,700i&display=swap" rel="stylesheet">

		<!-- Stylesheets -->
		<link rel="stylesheet" href="css/bootstrap.min.css"/>
		<link rel="stylesheet" href="css/font-awesome.min.css"/>
		<link rel="stylesheet" href="css/owl.carousel.min.css"/>
		<link rel="stylesheet" href="css/slicknav.min.css"/>

		<!-- Main Stylesheets -->
		<link rel="stylesheet" href="css/style.css"/>

		<!--JQuery-->
		<script src="https://code.jquery.com/jquery-3.3.1.min.js" type="text/javascript"></script>
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

	<!--[if lt IE 9]>
		<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
		<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
	<![endif]-->

	<!--- Load User Data --->
	<script type="text/javascript">
		$(document).ready(function(){
			$.getJSON('./fetch_userdata.php', function(data){
				for (var i in data.objectz) {
					$("#retrieve").append(
						'<li><h5 style="color: #fff;"><div class="fa fa-user" style="margin-right: 15px;margin-bottom: 15px;"></div>Name</h5><div class="form-group"><h4 class="text-uppercase" style="color: #5bc0de;">'+data.objectz[i].fullname+'</h4></div></li>'+
						'<li><h5 style="color: #fff;"><div class="fa fa-envelope" style="margin-right: 15px;margin-bottom: 15px;"></div>E-Mail</h5><div class="form-group"><h4 class="text-uppercase" style="color: #5bc0de;">'+data.objectz[i].email+'</h4></div></li>'+
						'<li><h5 style="color: #fff;"><div class="fa fa-home" style="margin-right: 15px;margin-bottom: 15px;"></div>Address</h5><div class="form-group"><h4 class="text-uppercase" style="color: #5bc0de;">'+data.objectz[i].address+', '+data.objectz[i].country+'</h4></div></li>'+
						'<li><h5 style="color: #fff;"><div class="fa fa-phone" style="margin-right: 15px;margin-bottom: 15px;"></div>Phone</h5><div class="form-group"><h4 class="text-uppercase" style="color: #5bc0de;">'+data.objectz[i].phone+'</h4></div></li>'+
						'<li><h5 style="color: #fff;"><div class="fa fa-calendar" style="margin-right: 15px;margin-bottom: 15px;"></div>Name</h5><div class="form-group"><h4 class="text-uppercase" style="color: #5bc0de;">'+data.objectz[i].birthday+'</h4></div></li>');
				}
				window.console && console.log(data);
			})
		});
	</script>

	<!--- Edit Button Toggle--->
	<script type="text/javascript">
		var edit=true;
		function toggle(){

			if(edit==false){
				edit=true;
				document.getElementById("editmode").style.display = 'none';
				document.getElementById("viewmode").style.display = 'block';
				document.getElementById("edit_button").innerHTML = "Edit";
			}
			else{
				edit=false;
				document.getElementById("editmode").style.display = 'block';
				document.getElementById("viewmode").style.display = 'none';
				document.getElementById("edit_button").innerHTML = "View";
			}
		};
	</script>

	<!--- GENERATE ELGAMAL KEYPAIR --->
	<script type="text/javascript">

		var var_Q = 0;
		var var_PrimitiveRootOfP = 0;
		var var_p = 0
		var var_x = 0;
		var var_g = 0;
		var var_y = 0;
		var var_k = 0;
		var var_a = 0;

	// Function - Random Range
	function getRandomRange(min, max) {
		return Math.floor(Math.random() * (max - min) + min);
	};

	// Function - Cek Bilangan Prima
	function TestPrimeElement(element) {
		var isPrime = true;

		if (element == 2 || element == 3)
		{
			return isPrime;
		}
		else
		{
			if (element == 1 || element % 2 == 0 || element % 3 == 0)
			{
				isPrime = false;
			}
			else
			{
				for (var i = 5; i <= Math.floor(Math.sqrt(element)); i = i + 6)
					if (element % i == 0 || element % (i + 2) == 0)
					{
						isPrime = false;
						break;
					}
				}
			}

			return isPrime;
		};

    // Function - Cek Apakah 2 Bilangan Saling Prima atau Tidak (Co-Prime)
    function TestCoPrime(a, b) {
        // Euclidean Algorithm / GCD (Menentukan FPB dari 2 Bilangan)
        var temp;
        while (b != 0)
        {
        	temp = a % b;
        	a = b;
        	b = temp;
        }

        // 2 atau Lebih Bilangan Bisa Dikatakan Ko-Prima Jika GDC-nya = 1
        if (a == 1)
        {
        	return true;
        }
        else
        {
        	return false;
        }
    };

    // Function - Kalkulasikan Pangkat dan Modulo ((number ^ power) % modulo)
    function PowerAndModulo(number, power, modulo) {
        // Menggunakan "Square Multiplication Algorithm" Karena Memproses Bilangan yang Sangat Besar

        // Pembulatan (Jadikan Integer)
        number = Math.floor(number);
        power = Math.floor(power);
        modulo = Math.floor(modulo);

        // Convert ke Binary
        var a = [];
        var k = 0;

        do
        {
        	a[k] = power % 2;
        	power = power / 2;
        	power = Math.floor(power);
        	k++;
        }
        while (power != 0);

        // Kalkulasikan Hasil Pangkat dan Modulo
        var result = 1;

        for (var i = k - 1; i >= 0; i--)
        {
        	result = (result * result) % modulo;
        	if (a[i] == 1)
        	{
        		result = (result * number) % modulo;
        	}
        }

        return Math.floor(result);
    };

    function BackupPowerAndModulo(a, b, n) {
    	a = a % n;
    	var result = 1;
    	var x = a;

    	while(b > 0){
    		var leastSignificantBit = b % 2;
    		b = Math.floor(b / 2);

    		if (leastSignificantBit == 1) {
    			result = result * x;
    			result = result % n;
    		}

    		x = x * x;
    		x = x % n;
    	}
    	return result;
    };

	// Function - Cek Apakah (p - 1) mod Q = 0 atau Tidak
	function TestTheEstimateOfThePNumber(est_p, est_Q) {
		if ((est_p - 1) % est_Q == 0)
		{
			return true;
		}
		else
		{
			return false;
		}
	};

	// Function - Cek Apakah Sebuah Bilangan Merupakan Primitive Root dari Bilangan Prima atau Bukan
	function TestPrimitiveElement(pe_input, pe_prime, pe_Q) {
            /* Primitive Root :
             * Misal Bilangan p = 7, Bilangan a = 3
             * Elemennya Yaitu : 1, 2, 3, 4, 5, 6
             * 
             * Cek Sebuah Bilangan Apakah Primitive Root atau Tidak dengan Cara :
             * Proot = a ^ (1 ... (p -1)) mod p
             * Proot = 3 ^ (1 ... 6) mod 7
             * 3 ^ 1 % 7 = [3], 3 ^ 2 % 7 = [2], 3 ^ 3 % 7 = [6], 3 ^ 4 % 7 = [4], 3 ^ 5 % 7 = [5], 3 ^ 6 % 7 = [1]
             * 
             * Dari 3 ^ 1 Hingga 3 ^ 6 Menghasilkan Output 1, 2, 3, 4, 5, 6  yang Mengandung Elemen dari p
             * Jadi 3 Adalah Primitive Root dari 7.
             */

             var pe_check = true;
             var pe_power = pe_prime - Math.floor(1 / pe_Q);
             var pe_test = PowerAndModulo(pe_input, pe_power, pe_prime);

             if (pe_test != 1)
             {
             	pe_check = true;
             }
             else
             {
             	if (pe_test == 1)
             	{
             		pe_check = false;
             	}
             }

             return pe_check;
         };

	// CORE Function - Generate Private / Public Key
	function generateKeyElGamal() {

		//console.log("Coba Fungsi Pangkat Modulo (988 ^ 1443) mod 1709 : " + PowerAndModulo(988, 1443, 1709));
		var output = [];

		console.log("Before : \n" +
			"Var Q = "+var_Q+"\n" +
			"Var PRoP = "+var_PrimitiveRootOfP+"\n" +
			"Var p = "+var_p+"\n" +
			"Var x = "+var_x+"\n" +
			"Var g = "+var_g+"\n" +
			"Var y = "+var_y+"\n" +
			"Var k = "+var_k+"\n" +
			"Var a = "+var_a+"\n"
			);

		var_Q = var_PrimitiveRootOfP = var_g = var_x = var_y = var_k = 0;

		// 1. Menentukan Bilangan Prima Acak Antara [1000 - 3000]
		console.log("Check 1");
		do
		{
			var_p = getRandomRange(1000, 3000);
		}
		while (TestPrimeElement(var_p) == false);

		// 2. Menentukan Bilangan Acak Q Sehingga Q Merupakan Divisor dari p-1 (GCD)
		console.log("Check 2");
		do
		{
            // Menentukan Bilangan Random Q dengan Min = 2 & Max = p-1
            var_Q = getRandomRange(2, var_p - 1);
        }
        // Bilangan Q Harus Prima dan (p - 1) mod Q Harus = 0
        while (TestPrimeElement(var_p) == false || TestTheEstimateOfThePNumber(var_p, var_Q) == false);

        // 3. Menentukan Sebuah Bilangan yang Merupakan Primitive Root dari p
        console.log("Check 3");
        do
        {
        	var_PrimitiveRootOfP = getRandomRange(2, var_p - 1);
        }
        while (TestPrimitiveElement(var_PrimitiveRootOfP, var_p, var_Q) == false);

        // 4. Generate - Variabel "g", Dimana g < p
        console.log("Check 4");
        var_g = PowerAndModulo(var_PrimitiveRootOfP, var_p - Math.floor(1 / var_Q), var_p);

		// 5. Generate - Variabel "x"
		console.log("Check 5");
		do
		{
            // Menentukan Bilangan Random x dengan Min = 2 & Max = p-2
            var_x = getRandomRange(2, var_p - 2);
        }
        while (var_x == var_Q || var_x == var_PrimitiveRootOfP);

		// 6. Generate - Variabel "y", Dimana y = (g ^ x) mod p
		console.log("Check 6");
		var_y = PowerAndModulo(var_g, var_x, var_p);
		
		// 7. Generate - Variabel "k"
		do
		{
			var_k = getRandomRange(2, var_p - 2);
		}
		while (var_k == var_x || var_k == var_g || var_k == var_Q || var_k == var_PrimitiveRootOfP || TestCoPrime(var_k, var_p - 1) == false);

		// 8. Generate - Variabel "a" (Kalkukasi -> a = g ^ k mod p)
		var_a = PowerAndModulo(var_g, var_k, var_p);

		console.log("After : \n" +
			"Var p = "+var_p+"\n" +
			"Var Q = "+var_Q+" -> Prime, (p - 1) mod Q = 0, Min = 2, Max = (p - 1)\n" +
			"Var PRoP = "+var_PrimitiveRootOfP+" -> Primitive Root of P\n" +
			"Var x = "+var_x+" -> Min = 2, Max = (p - 1)\n" +
			"Var g = "+var_g+" -> g < p\n" +
			"Var y = "+var_y+" -> (g ^ x) mod p\n" +
			"Var k = "+var_k+"\n" +
			"Var a = "+var_a+" -> (g ^ k) mod p\n"
			);

		// Private Key
		output[0] = var_p + "|" + var_x + "|" + var_a;

        // Public Key
        output[1] = var_p + "|" + var_g + "|" + var_y + "|" + var_k;

        return output;
    };

    // MAIN Function - Generate Host/Client Key
    function generateKeyPair(mode) {
    	/* [#] ElGamal Key Details :
         * 
         * [A] Client :
         * Client - Public Key  = p, g, y, k    (For Encryption)
         * Client - Private Key = p, x, a       (For Decryption)
         * 
         * [B] Host :
         * Host - Private Key   = p, g, y, k    (For Encryption) -> Inverted, Basically Public Key
         * Host - Public Key    = p, x, a       (For Decryption) -> Inverted, Basically Private Key
         */

    	// Mode :
    	// Host 	= 0
    	// Client 	= 1
    	var kp = generateKeyElGamal();
    	var privateKey;
    	var publicKey;

    	if (mode == 0) {
    		privateKey = kp[1];
    		publicKey = kp[0];

    		alert(
    			"Host Private Key : " + privateKey + "\n" +
    			"Host Public Key : " + publicKey
    			);
    	}
    	else {
    		privateKey = kp[0];
    		publicKey = kp[1];

    		alert(
    			"Client Private Key : " + privateKey + "\n" +
    			"Client Public Key : " + publicKey
    			);
    	}
    };

</script>

 <!--- ALL DOWNLOAD FUNCTIONS --->
 <script type="text/javascript">
   function download(filename, text) {
    var element = document.createElement('a');
    element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
    element.setAttribute('download', filename);

    element.style.display = 'none';
    document.body.appendChild(element);

    element.click();

    document.body.removeChild(element);
  }
</script>

<!--- Smooth Scrolling --->
<style>html { scroll-behavior: smooth; }</style>
</head>
<body>
	<!-- Page Preloder -->
	<div id="preloder">
		<div class="loader"></div>
	</div>

	<!-- Header section -->
	<header class="header-section clearfix" id="home">
		<a href="#" class="site-logo">
			<h4 style="color: #fc0254;">SuperCrypt <span style="color: white;">EX</span></h4>
			<!---<img src="img/logo.png" alt="">--->
		</a>
		<div class="header-right">
			<a href="#" class="hr-btn">Help</a>
			<span>|</span>
			<div class="user-panel">
				<a href="./destroy_session.php" class="login">Logout</a>
				<a href="" class="register"><?= $_SESSION["fullname"]; ?></a>
			</div> 
		</div>
		<ul class="main-menu">
			<li><a href="./main.php#home">Home</a></li>
			<li><a href="./todo.php#">To-Do</a></li>
			<li><a href="./sendfile.php#">File Transfer</a></li>
			<li><a href="./inbox.php#">Inbox</a></li>
			<li><a href="./contact.php#">Contact Us</a></li>
		</ul>
	</header>
	<!-- Header section end -->

	<!-- Hero section -->
	<section class="hero-section">
		<div class="hero-slider owl-carousel">
			<div class="hs-item">
				<div class="container">
					<div class="row">
						<div class="col-lg-6">
							<div class="hs-text">
								<h2><span>Hello, <br></span> <?= $_SESSION["fullname"]; ?></h2>
								<p>What will you do today? <br>Keep relax and Have a great day :D </p>
								<a href="./inbox.php#" class="site-btn">File Inbox</a>
								<a href="#profile" class="site-btn sb-c2">Edit Your Profile</a>
							</div>
						</div>
						<div class="col-lg-6">
							<div class="hr-img">
								<img src="img/hero-bg.png" alt="">
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="hs-item">
				<div class="container">
					<div class="row">
						<div class="col-lg-6">
							<div class="hs-text">

								<h2><span>SuperCrypt</span> EX</h2>
								<p>The all in one solution for your needs. <br>We provide many features that we think you’ll love it.</p>
								<a href="./sendfile.php#" class="site-btn">Send a File</a>
								<a href="./todo.php#" class="site-btn sb-c2">Create To-Do List</a>
							</div>
						</div>
						<div class="col-lg-6">
							<div class="hr-img">
								<img src="img/hero-bg.png" alt="">
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
	<!-- Hero section end -->

						<!-- Premium section end -->
						<section class="premium-section spad">
							<div class="container">
								<div class="row">
									<div class="col-lg-6">
										<div class="section-title">
											<h2>Why Go Premium</h2>
										</div>
									</div>
									<div class="col-lg-6">
										<p>Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quis ipsum suspendisse ultrices gravida. Risus commodo viverra maecenas accumsan lacus vel facilisis. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
									</div>
								</div>
								<div class="row">
									<div class="col-lg-3 col-sm-6">
										<div class="premium-item">
											<img src="img/premium/1.jpg" alt="">
											<h4>No Ad Interruptions</h4>
											<p>Consectetur adipiscing elit</p>
										</div>
									</div>
									<div class="col-lg-3 col-sm-6">
										<div class="premium-item">
											<img src="img/premium/2.jpg" alt="">
											<h4>Colorful To-Do List Design</h4>
											<p>Ectetur adipiscing elit</p>
										</div>
									</div>
									<div class="col-lg-3 col-sm-6">
										<div class="premium-item">
											<img src="img/premium/3.jpg" alt="">
											<h4>Transfer File Securely</h4>
											<p>Sed do eiusmod tempor </p>
										</div>
									</div>
									<div class="col-lg-3 col-sm-6">
										<div class="premium-item">
											<img src="img/premium/4.jpg" alt="">
											<h4>Rich Feature</h4>
											<p>Adipiscing elit</p>
										</div>
									</div>
								</div>
							</div>
						</section>
						<!-- Premium section end -->

	<!-- Subscription section -->
	<section class="subscription-section spad" id="profile">
		<div class="container">
			<div class="row">
				<div class="col-lg-6">
					<div class="sub-text">
						<h2>USER PROFILE</h2>
						<h3>Basic Account</h3>

						<p>Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quis ipsum suspendisse ultrices gravida. Risus commodo viverra maecenas accumsan lacus vel facilisis. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
						<button class="site-btn" onclick="toggle()" id="edit_button">Edit</button>
						<button class="site-btn" onclick="generateKeyPair(0)" id="generate_key">Generate Key</button>

					</div>

				</div>

				<!--- View Mode --->
				<div class="col-lg-6" id="viewmode">

					<ul class="sub-list">
						<div id="retrieve"></div>

						<div id="success_fail"></div>
					</ul>
				</div>

				<!--- Edit Mode --->
				<div class="col-lg-6" id="editmode"style="display: none;">
					<ul class="sub-list">
						<form class="contact-form" method="post">
							<!--- Name --->
							<li><h5 style="color: white;"><div class="fa fa-user" style="margin-right: 15px;margin-bottom: 15px;"></div>Name</h5>
								<div class="form-group">
									<input type="text" class="form-control form-control-user" value='<?= $_SESSION["fullname"]; ?>' name="e_fullname" id="e_fullname" placeholder="Full Name">
								</div></li>
								<!--- E-Mail --->
								<li><h5 style="color: white;"><div class="fa fa-envelope" style="margin-right: 15px;margin-bottom: 15px;"></div>E-Mail</h5>
									<div class="form-group">
										<input type="email" class="form-control form-control-user" value='<?= $_SESSION["email"]; ?>' name="e_email" id="e_email" placeholder="Email">
									</div></li>
									<!--- Address --->
									<li><h5 style="color: white;"><div class="fa fa-home" style="margin-right: 15px;margin-bottom: 15px;"></div>Address</h5>
										<div class="form-group row">
											<div class="col-sm-6 mb-3 mb-sm-0">
												<input type="text" class="form-control form-control-user" value='<?= $_SESSION["address"]; ?>' name="e_address" id="e_address" placeholder="Address">
											</div>
											<div class="col-sm-6">
												<select id="e_country" name="e_country" class="form-control">
													<option value='<?= $_SESSION["country"]; ?>' selected disabled hidden><?= $_SESSION["country"]; ?></option>
													<option value="Afghanistan">Afghanistan</option>
													<option value="Åland Islands">Åland Islands</option>
													<option value="Albania">Albania</option>
													<option value="Algeria">Algeria</option>
													<option value="American Samoa">American Samoa</option>
													<option value="Andorra">Andorra</option>
													<option value="Angola">Angola</option>
													<option value="Anguilla">Anguilla</option>
													<option value="Antarctica">Antarctica</option>
													<option value="Antigua and Barbuda">Antigua and Barbuda</option>
													<option value="Argentina">Argentina</option>
													<option value="Armenia">Armenia</option>
													<option value="Aruba">Aruba</option>
													<option value="Australia">Australia</option>
													<option value="Austria">Austria</option>
													<option value="Azerbaijan">Azerbaijan</option>
													<option value="Bahamas">Bahamas</option>
													<option value="Bahrain">Bahrain</option>
													<option value="Bangladesh">Bangladesh</option>
													<option value="Barbados">Barbados</option>
													<option value="Belarus">Belarus</option>
													<option value="Belgium">Belgium</option>
													<option value="Belize">Belize</option>
													<option value="Benin">Benin</option>
													<option value="Bermuda">Bermuda</option>
													<option value="Bhutan">Bhutan</option>
													<option value="Bolivia">Bolivia</option>
													<option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option>
													<option value="Botswana">Botswana</option>
													<option value="Bouvet Island">Bouvet Island</option>
													<option value="Brazil">Brazil</option>
													<option value="British Indian Ocean Territory">British Indian Ocean Territory</option>
													<option value="Brunei Darussalam">Brunei Darussalam</option>
													<option value="Bulgaria">Bulgaria</option>
													<option value="Burkina Faso">Burkina Faso</option>
													<option value="Burundi">Burundi</option>
													<option value="Cambodia">Cambodia</option>
													<option value="Cameroon">Cameroon</option>
													<option value="Canada">Canada</option>
													<option value="Cape Verde">Cape Verde</option>
													<option value="Cayman Islands">Cayman Islands</option>
													<option value="Central African Republic">Central African Republic</option>
													<option value="Chad">Chad</option>
													<option value="Chile">Chile</option>
													<option value="China">China</option>
													<option value="Christmas Island">Christmas Island</option>
													<option value="Cocos (Keeling) Islands">Cocos (Keeling) Islands</option>
													<option value="Colombia">Colombia</option>
													<option value="Comoros">Comoros</option>
													<option value="Congo">Congo</option>
													<option value="Congo, The Democratic Republic of The">Congo, The Democratic Republic of The</option>
													<option value="Cook Islands">Cook Islands</option>
													<option value="Costa Rica">Costa Rica</option>
													<option value="Cote D'ivoire">Cote D'ivoire</option>
													<option value="Croatia">Croatia</option>
													<option value="Cuba">Cuba</option>
													<option value="Cyprus">Cyprus</option>
													<option value="Czech Republic">Czech Republic</option>
													<option value="Denmark">Denmark</option>
													<option value="Djibouti">Djibouti</option>
													<option value="Dominica">Dominica</option>
													<option value="Dominican Republic">Dominican Republic</option>
													<option value="Ecuador">Ecuador</option>
													<option value="Egypt">Egypt</option>
													<option value="El Salvador">El Salvador</option>
													<option value="Equatorial Guinea">Equatorial Guinea</option>
													<option value="Eritrea">Eritrea</option>
													<option value="Estonia">Estonia</option>
													<option value="Ethiopia">Ethiopia</option>
													<option value="Falkland Islands (Malvinas)">Falkland Islands (Malvinas)</option>
													<option value="Faroe Islands">Faroe Islands</option>
													<option value="Fiji">Fiji</option>
													<option value="Finland">Finland</option>
													<option value="France">France</option>
													<option value="French Guiana">French Guiana</option>
													<option value="French Polynesia">French Polynesia</option>
													<option value="French Southern Territories">French Southern Territories</option>
													<option value="Gabon">Gabon</option>
													<option value="Gambia">Gambia</option>
													<option value="Georgia">Georgia</option>
													<option value="Germany">Germany</option>
													<option value="Ghana">Ghana</option>
													<option value="Gibraltar">Gibraltar</option>
													<option value="Greece">Greece</option>
													<option value="Greenland">Greenland</option>
													<option value="Grenada">Grenada</option>
													<option value="Guadeloupe">Guadeloupe</option>
													<option value="Guam">Guam</option>
													<option value="Guatemala">Guatemala</option>
													<option value="Guernsey">Guernsey</option>
													<option value="Guinea">Guinea</option>
													<option value="Guinea-bissau">Guinea-bissau</option>
													<option value="Guyana">Guyana</option>
													<option value="Haiti">Haiti</option>
													<option value="Heard Island and Mcdonald Islands">Heard Island and Mcdonald Islands</option>
													<option value="Holy See (Vatican City State)">Holy See (Vatican City State)</option>
													<option value="Honduras">Honduras</option>
													<option value="Hong Kong">Hong Kong</option>
													<option value="Hungary">Hungary</option>
													<option value="Iceland">Iceland</option>
													<option value="India">India</option>
													<option value="Indonesia">Indonesia</option>
													<option value="Iran, Islamic Republic of">Iran, Islamic Republic of</option>
													<option value="Iraq">Iraq</option>
													<option value="Ireland">Ireland</option>
													<option value="Isle of Man">Isle of Man</option>
													<option value="Israel">Israel</option>
													<option value="Italy">Italy</option>
													<option value="Jamaica">Jamaica</option>
													<option value="Japan">Japan</option>
													<option value="Jersey">Jersey</option>
													<option value="Jordan">Jordan</option>
													<option value="Kazakhstan">Kazakhstan</option>
													<option value="Kenya">Kenya</option>
													<option value="Kiribati">Kiribati</option>
													<option value="Korea, Democratic People's Republic of">Korea, Democratic People's Republic of</option>
													<option value="Korea, Republic of">Korea, Republic of</option>
													<option value="Kuwait">Kuwait</option>
													<option value="Kyrgyzstan">Kyrgyzstan</option>
													<option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option>
													<option value="Latvia">Latvia</option>
													<option value="Lebanon">Lebanon</option>
													<option value="Lesotho">Lesotho</option>
													<option value="Liberia">Liberia</option>
													<option value="Libyan Arab Jamahiriya">Libyan Arab Jamahiriya</option>
													<option value="Liechtenstein">Liechtenstein</option>
													<option value="Lithuania">Lithuania</option>
													<option value="Luxembourg">Luxembourg</option>
													<option value="Macao">Macao</option>
													<option value="Macedonia, The Former Yugoslav Republic of">Macedonia, The Former Yugoslav Republic of</option>
													<option value="Madagascar">Madagascar</option>
													<option value="Malawi">Malawi</option>
													<option value="Malaysia">Malaysia</option>
													<option value="Maldives">Maldives</option>
													<option value="Mali">Mali</option>
													<option value="Malta">Malta</option>
													<option value="Marshall Islands">Marshall Islands</option>
													<option value="Martinique">Martinique</option>
													<option value="Mauritania">Mauritania</option>
													<option value="Mauritius">Mauritius</option>
													<option value="Mayotte">Mayotte</option>
													<option value="Mexico">Mexico</option>
													<option value="Micronesia, Federated States of">Micronesia, Federated States of</option>
													<option value="Moldova, Republic of">Moldova, Republic of</option>
													<option value="Monaco">Monaco</option>
													<option value="Mongolia">Mongolia</option>
													<option value="Montenegro">Montenegro</option>
													<option value="Montserrat">Montserrat</option>
													<option value="Morocco">Morocco</option>
													<option value="Mozambique">Mozambique</option>
													<option value="Myanmar">Myanmar</option>
													<option value="Namibia">Namibia</option>
													<option value="Nauru">Nauru</option>
													<option value="Nepal">Nepal</option>
													<option value="Netherlands">Netherlands</option>
													<option value="Netherlands Antilles">Netherlands Antilles</option>
													<option value="New Caledonia">New Caledonia</option>
													<option value="New Zealand">New Zealand</option>
													<option value="Nicaragua">Nicaragua</option>
													<option value="Niger">Niger</option>
													<option value="Nigeria">Nigeria</option>
													<option value="Niue">Niue</option>
													<option value="Norfolk Island">Norfolk Island</option>
													<option value="Northern Mariana Islands">Northern Mariana Islands</option>
													<option value="Norway">Norway</option>
													<option value="Oman">Oman</option>
													<option value="Pakistan">Pakistan</option>
													<option value="Palau">Palau</option>
													<option value="Palestinian Territory, Occupied">Palestinian Territory, Occupied</option>
													<option value="Panama">Panama</option>
													<option value="Papua New Guinea">Papua New Guinea</option>
													<option value="Paraguay">Paraguay</option>
													<option value="Peru">Peru</option>
													<option value="Philippines">Philippines</option>
													<option value="Pitcairn">Pitcairn</option>
													<option value="Poland">Poland</option>
													<option value="Portugal">Portugal</option>
													<option value="Puerto Rico">Puerto Rico</option>
													<option value="Qatar">Qatar</option>
													<option value="Reunion">Reunion</option>
													<option value="Romania">Romania</option>
													<option value="Russian Federation">Russian Federation</option>
													<option value="Rwanda">Rwanda</option>
													<option value="Saint Helena">Saint Helena</option>
													<option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option>
													<option value="Saint Lucia">Saint Lucia</option>
													<option value="Saint Pierre and Miquelon">Saint Pierre and Miquelon</option>
													<option value="Saint Vincent and The Grenadines">Saint Vincent and The Grenadines</option>
													<option value="Samoa">Samoa</option>
													<option value="San Marino">San Marino</option>
													<option value="Sao Tome and Principe">Sao Tome and Principe</option>
													<option value="Saudi Arabia">Saudi Arabia</option>
													<option value="Senegal">Senegal</option>
													<option value="Serbia">Serbia</option>
													<option value="Seychelles">Seychelles</option>
													<option value="Sierra Leone">Sierra Leone</option>
													<option value="Singapore">Singapore</option>
													<option value="Slovakia">Slovakia</option>
													<option value="Slovenia">Slovenia</option>
													<option value="Solomon Islands">Solomon Islands</option>
													<option value="Somalia">Somalia</option>
													<option value="South Africa">South Africa</option>
													<option value="South Georgia and The South Sandwich Islands">South Georgia and The South Sandwich Islands</option>
													<option value="Spain">Spain</option>
													<option value="Sri Lanka">Sri Lanka</option>
													<option value="Sudan">Sudan</option>
													<option value="Suriname">Suriname</option>
													<option value="Svalbard and Jan Mayen">Svalbard and Jan Mayen</option>
													<option value="Swaziland">Swaziland</option>
													<option value="Sweden">Sweden</option>
													<option value="Switzerland">Switzerland</option>
													<option value="Syrian Arab Republic">Syrian Arab Republic</option>
													<option value="Taiwan, Province of China">Taiwan, Province of China</option>
													<option value="Tajikistan">Tajikistan</option>
													<option value="Tanzania, United Republic of">Tanzania, United Republic of</option>
													<option value="Thailand">Thailand</option>
													<option value="Timor-leste">Timor-leste</option>
													<option value="Togo">Togo</option>
													<option value="Tokelau">Tokelau</option>
													<option value="Tonga">Tonga</option>
													<option value="Trinidad and Tobago">Trinidad and Tobago</option>
													<option value="Tunisia">Tunisia</option>
													<option value="Turkey">Turkey</option>
													<option value="Turkmenistan">Turkmenistan</option>
													<option value="Turks and Caicos Islands">Turks and Caicos Islands</option>
													<option value="Tuvalu">Tuvalu</option>
													<option value="Uganda">Uganda</option>
													<option value="Ukraine">Ukraine</option>
													<option value="United Arab Emirates">United Arab Emirates</option>
													<option value="United Kingdom">United Kingdom</option>
													<option value="United States">United States</option>
													<option value="United States Minor Outlying Islands">United States Minor Outlying Islands</option>
													<option value="Uruguay">Uruguay</option>
													<option value="Uzbekistan">Uzbekistan</option>
													<option value="Vanuatu">Vanuatu</option>
													<option value="Venezuela">Venezuela</option>
													<option value="Viet Nam">Viet Nam</option>
													<option value="Virgin Islands, British">Virgin Islands, British</option>
													<option value="Virgin Islands, U.S.">Virgin Islands, U.S.</option>
													<option value="Wallis and Futuna">Wallis and Futuna</option>
													<option value="Western Sahara">Western Sahara</option>
													<option value="Yemen">Yemen</option>
													<option value="Zambia">Zambia</option>
													<option value="Zimbabwe">Zimbabwe</option>
												</select>
											</div>
										</div></li>
										<!--- Phone and Birthday --->
										<li><h5 style="color: white;"><div class="fa fa-server" style="margin-right: 15px;margin-bottom: 15px;"></div>Phone & Birthday</h5>
											<div class="form-group row">
												<div class="col-sm-6 mb-3 mb-sm-0">
													<input type="tel" onfocus="(this.type='number')" maxlength="12" class="form-control form-control-user" value='<?= $_SESSION["phone"]; ?>' name="e_phone" id="e_phone" placeholder="Phone" onkeydown="return isNumberKey(event)">
												</div>
												<div class="col-sm-6">
													<input type="text" onfocus="(this.type='date')" class="form-control form-control-user" value='<?= $_SESSION["birthday"]; ?>' name="e_birthday" id="e_birthday" placeholder="Birthday">
												</div>
											</div></li>
											<!--- Confirm Password --->
											<li><h5 style="color: white;"><div class="fa fa-unlock-alt" style="margin-right: 15px;margin-bottom: 15px;"></div>Confirm Password</h5>
												<div class="form-group">
													<input type="password" class="form-control form-control-user" name="e_confpass" id="e_confpass" placeholder="Confirm Password" required>
												</div></li>
												<div id="reg_form">
													<button type="submit" class="site-btn" style="background-color: #5bc0de;">Update Profile</button>
												</div>
											</form>
										</ul>

										<?php
										if (isset($_POST["e_confpass"])) {
											$verify=$_POST["e_confpass"];
											$pdo=new PDO($dbhost, $dbuser, $dbpass);
											$stmt = $pdo->prepare("SELECT * FROM users WHERE user_id=:id and password=PASSWORD(:pw)");
											$stmt->execute(array(':id' => $id, ':pw' => $verify));
											$result = $stmt->fetch();
											$pass_result=$result["password"];

											if($_SESSION["password"]==$pass_result)
											{
												$e_fullname=strip_tags($_POST['e_fullname']);
												$e_email=strip_tags($_POST['e_email']);
												$e_address=strip_tags($_POST['e_address']);
												$e_country=strip_tags($_POST['e_country']);
												$e_birthday=strip_tags($_POST['e_birthday']);
												$e_phone=strip_tags($_POST['e_phone']);
												$e_confpass=strip_tags($_POST['e_confpass']);

												if ($e_fullname) {
													$sql = "UPDATE users SET fullname=:fullname WHERE user_id=:uid";
													$stmt = $pdo->prepare($sql);
													$stmt->execute(array(
														':fullname' => $e_fullname,
														':uid' => $_SESSION["user_id"]));
												}
												if ($e_email) {
													$sql = "UPDATE users SET email=:email WHERE user_id=:uid";
													$stmt = $pdo->prepare($sql);
													$stmt->execute(array(
														':email' => $e_email,
														':uid' => $_SESSION["user_id"]));
												}
												if ($e_address) {
													$sql = "UPDATE users SET address=:address WHERE user_id=:uid";
													$stmt = $pdo->prepare($sql);
													$stmt->execute(array(
														':address' => $e_address,
														':uid' => $_SESSION["user_id"]));
												}
												if ($e_country) {
													$sql = "UPDATE users SET country=:country WHERE user_id=:uid";
													$stmt = $pdo->prepare($sql);
													$stmt->execute(array(
														':country' => $e_country,
														':uid' => $_SESSION["user_id"]));
												}
												if ($e_birthday) {
													$sql = "UPDATE users SET birthday=:birthday WHERE user_id=:uid";
													$stmt = $pdo->prepare($sql);
													$stmt->execute(array(
														':birthday' => $e_birthday,
														':uid' => $_SESSION["user_id"]));
													$_SESSION["birthday"] = $e_birthday;
												}
												if ($e_phone) {
													$sql = "UPDATE users SET phone=:phone WHERE user_id=:uid";
													$stmt = $pdo->prepare($sql);
													$stmt->execute(array(
														':phone' => $e_phone,
														':uid' => $_SESSION["user_id"]));
													$_SESSION["phone"] = $e_phone;
												}
												/*if ($newpass) {
													$sql = "UPDATE users SET password=PASSWORD(:pass) WHERE user_id=:uid";
													$stmt = $pdo->prepare($sql);
													$stmt->execute(array(
														':pass' => $newpass,
														':uid' => $_SESSION["user_id"]));
													$password=$newpass;
												}*/

												$_SESSION["fullname"] = $e_fullname;
												$_SESSION["email"] = $e_email;
												$_SESSION["birthday"] = $e_birthday;
												$_SESSION["phone"] = $e_phone;
												$_SESSION["address"] = $e_address;
												$_SESSION["country"] = $e_country;

												echo '<script>$("#success_fail").append(\'<div class="text-center"><p style="color: green;">Data Successfully Updated!</p></div>\');</script>';
												echo '<script>alert("Data Successfully Updated!")</script>';

											}
											else{
												echo '<script>$("#success_fail").append(\'<div class="text-center"><p style="color: gold;">Data Update Failed!</p></div>\');</script>';
												echo '<script>alert("Data Update Failed!")</script>';
											}
											$_POST["e_confpass"]="";
											unset($_POST);
											echo '<script type="text/javascript">window.location.href= "./main.php"</script>';
										}
										else{
											echo '<script>$("#success_fail").append(\'<div class="text-center"><p style="color: gold;"></p></div>\');</script>';
										}
										
										?>

									</div>
								</div>
							</div>
						</section>
						<!-- Subscription section end -->

	<!-- Concept section -->
	<section class="concept-section spad">
		<div class="container">
			<div class="row">
				<div class="col-lg-6">
					<div class="section-title">
						<h2>Our Server & Services</h2>
					</div>
				</div>
				<div class="col-lg-6">
					<p>We’re committed to provide the best service possible. In order to meet this promise, we vow to maintain the server as best as possible such as user-friendly UI, fast server connection, guaranteed privacy (for sure), and many more... below are some of the services we have : </p>
				</div>
			</div>
			<div class="row">
				<div class="col-lg-3 col-sm-6">
					<div class="concept-item">
						<img src="img/concept/1.jpg" alt="">
						<h5>To-Do List</h5>
					</div>
				</div>
				<div class="col-lg-3 col-sm-6">
					<div class="concept-item">
						<img src="img/concept/2.jpg" alt="">
						<h5>Secure File Transfer</h5>
					</div>
				</div>
				<div class="col-lg-3 col-sm-6">
					<div class="concept-item">
						<img src="img/concept/3.jpg" alt="">
						<h5>Game Server</h5>
					</div>
				</div>
				<div class="col-lg-3 col-sm-6">
					<div class="concept-item">
						<img src="img/concept/4.jpg" alt="">
						<h5>VPN Server</h5>
					</div>
				</div>
			</div>
		</div>
	</section>
	<!-- Concept section end -->

	<!-- How section -->
	<section class="how-section spad set-bg" data-setbg="img/how-to-bg.jpg">
		<div class="container text-white">
			<div class="section-title">
				<h2>How It Works</h2>
			</div>
			<div class="row">
				<div class="col-md-4">
					<div class="how-item">
						<div class="hi-icon">
							<img src="img/icons/brain.png" alt="">
						</div>
						<h4>Create an Account</h4>
						<p>Lorem ipsum dolor sit amet, consectetur adipi-scing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quis ipsum sus-pendisse ultrices gravida. </p>
					</div>
				</div>
				<div class="col-md-4">
					<div class="how-item">
						<div class="hi-icon">
							<img src="img/icons/pointer.png" alt="">
						</div>
						<h4>Choose What Do You Want To Do</h4>
						<p>Donec in sodales dui, a blandit nunc. Pellen-tesque id eros venenatis, sollicitudin neque sodales, vehicula nibh. Nam massa odio, portti-tor vitae efficitur non. </p>
					</div>
				</div>
				<div class="col-md-4">
					<div class="how-item">
						<div class="hi-icon">
							<img src="img/icons/smartphone.png" alt="">
						</div>
						<h4>Enjoy!</h4>
						<p>Ablandit nunc. Pellentesque id eros venenatis, sollicitudin neque sodales, vehicula nibh. Nam massa odio, porttitor vitae efficitur non, ultric-ies volutpat tellus. </p>
					</div>
				</div>
			</div>
		</div>
	</section>
	<!-- How section end -->

	<!-- Intro section -->
	<section class="intro-section spad">
		<div class="container">
			<div class="row">
				<div class="col-lg-6">
					<div class="section-title">
						<h2>Unlimited Access to 100K tracks</h2>
					</div>
				</div>
				<div class="col-lg-6">
					<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quis ipsum sus-pendisse ultrices gravida. Risus commodo viverra maecenas accumsan lacus vel facilisis. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quis ipsum suspendisse ultrices gravida.</p>
					<a href="#" class="site-btn">Try it now</a>
				</div>
			</div>
		</div>
	</section>
	<!-- Intro section end -->

						<!-- Footer section -->
						<footer class="footer-section">
							<div class="container">
								<div class="row">
									<div class="col-xl-6 col-lg-7 order-lg-2">
										<div class="row">
											<div class="col-sm-4">
												<div class="footer-widget">
													<h2>Services</h2>
													<ul>
														<li><a href="./todo.php#">To-Do List</a></li>
														<li><a href="./sendfile.php#">File Transfer</a></li>
														<li><a href="./inbox.php#">Inbox</a></li>
													</ul>
												</div>
											</div>
											<div class="col-sm-4">
												<div class="footer-widget">
													<h2>About us</h2>
													<ul>
														<li><a href="./admins.php#">IPFlare OP's</a></li>
														<li><a href="./contact.php#">Support</a></li>
													</ul>
												</div>
											</div>

										</div>
									</div>
									<div class="col-xl-6 col-lg-5 order-lg-1">
										<a href="#" class="">
											<h4 style="color: #fc0254;">SuperCrypt <span style="color: white;">EX</span></h4>
											<!---<img src="img/logo.png" alt="">--->
										</a>
										<div class="copyright">
											&copy;<script>document.write(new Date().getFullYear());</script> | SuperCryptEX - Secure Server
										</div>

										<div class="social-links">
											<a href="https://www.instagram.com/"><i class="fa fa-instagram"></i></a>
											<a href="https://www.pinterest.com/"><i class="fa fa-pinterest"></i></a>
											<a href="https://www.facebook.com/"><i class="fa fa-facebook"></i></a>
											<a href="https://twitter.com/"><i class="fa fa-twitter"></i></a>
											<a href="https://www.youtube.com/"><i class="fa fa-youtube"></i></a>
										</div>

										<div class="copyright"><strong>Design by <br>[</strong>
											<!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
											Copyright &copy;<script>document.write(new Date().getFullYear());</script> All rights reserved | This template is made with <i class="fa fa-heart-o" aria-hidden="true"></i> by <a href="https://colorlib.com" target="_blank">Colorlib</a>
											<!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
											<strong> ]</strong></div>

										</div>
									</div>
								</div>
							</footer>
							<!-- Footer section end -->

							<!--====== Javascripts & Jquery ======-->
							<script src="js/jquery-3.2.1.min.js"></script>
							<script src="js/bootstrap.min.js"></script>
							<script src="js/jquery.slicknav.min.js"></script>
							<script src="js/owl.carousel.min.js"></script>
							<script src="js/mixitup.min.js"></script>
							<script src="js/main.js"></script>

						</body>
						</html>
						<?php
					}
					else {
						header("Location: ./login.php");
					}
					?>