<?php 
if (session_status() === PHP_SESSION_NONE){session_start();}
$jsondata = file_get_contents("./api/zyx.json");
$data = json_decode($jsondata, true);
if(isset($_POST['submit_support'])){
$json = $data['api_key'];
$jsonData = file_get_contents("./api/zyx.json");
$arrayData = json_decode($jsonData, true);
$replacementData = array('api_key' =>  array(
	"vpn_url"		            => $_POST["vpn_url"],
	"vpn_username"		        => $_POST["vpn_username"],
	"vpn_password"		        => $_POST["vpn_password"]));
$newArrayData = array_replace_recursive($arrayData, $replacementData);
$newJsonData = json_encode($newArrayData, JSON_PRETTY_PRINT);
file_put_contents("./api/zyx.json", $newJsonData);
header("Location: vpn1.php");
}
$jsondata = file_get_contents("./api/zyx.json");
$data = json_decode($jsondata, true);
$json = $data['api_key'];
include ('includes/header.php');
?>
<!-- Begin Page Content -->
        <div class="container-fluid">

            <!-- First Column -->
<div class="wrapper">
<div class="card border-left-primary alert-primary shadow h-100 card shadow mb-4">
                <div class="card-header py-3">
                <h6 class="m-0 font-weight-bold text-primary "><i class="fas fa-user-shield"></i> VPN Details</h6>
                </div>
                <div class="card-body">
                        <form method="post">
                        <div class="form-group">
                        <label class="control-label requiredField" for="vpn_url">
                        <strong> VPN URL</strong>
                        </label>
                        <div class="input-group">
                        <input class="form-control" id="vpn_url" name="vpn_url" value="<?=$json['vpn_url']?>" type="text"/>
                        </div>
                        </div>
                        <div class="form-group">
                        <label class="control-label " for="vpn_username">
                        <strong> VPN Username</strong> 
                        </label>
                        <div class="input-group">
                        <input class="form-control" name="vpn_username"  id="vpn_username" value="<?=$json['vpn_username']?>"  type="text" />
                        </div>
                        </div>
                        <div class="form-group">
                        <label class="control-label requiredField" for="vpn_password">
                        <strong> VPN Passsword</strong>
                        </label>
                        <div class="input-group">
                        <input class="form-control" id="vpn_password" name="vpn_password" value="<?=$json['vpn_password']?>"type="text"/>
                        </div>
                        </div>
                        <div class="form-group">
                        <button class="btn btn-primary btn-icon-split" name="submit_support" type="submit">
                        <span class="icon text-white-50"><i class="fas fa-check"></i></span><span class="text">Submit</span>
                        </button>
<? include ('includes/footer.php');?>