<?php 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$db = new SQLite3('./api/vpn_config.db');

if(isset($_POST['submit'])){
$db->exec("INSERT INTO vpn(userid, vpn_appid, vpn_country, vpn_state, vpn_config, vpn_status, auth_type, auth_embedded, username, password, date) VALUES('".$_POST['userid']."', '".$_POST['vpn_appid']."', '".$_POST['vpn_country']."', '".$_POST['vpn_state']."', '".$_POST['vpn_config']."', '".$_POST['vpn_status']."', '".$_POST['auth_type']."', '".$_POST['auth_embedded']."', '".$_POST['username']."', '".$_POST['password']."', '".$_POST['date']."')");
$db->close();
header("Location: vpn.php");
}
include ('includes/header.php');
echo "        <div class=\"card-body\">\n";
echo "        <div class=\"card bg-black text-white\">\n";
echo "          <center><h2 class=\"card-header card-header-warning\">New VPN</h2></center>\n";
echo "                <div class=\"card-body\">\n";
echo "                <div class=\"alert alert-black\" role=\"alert\">\n";
echo "                <div class=\"row\">\n";
echo "                <div class=\"col-12\">\n";
echo "                  <form  method=\"post\">\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Country Code</label>\n";
echo "                          <input type=\"hidden\" class=\"form-control\" name=\"userid\" value=\"VD399\">\n";
echo "                          <input type=\"hidden\" class=\"form-control\" name=\"vpn_appid\" value=\"10\">\n";
echo "                            <input type=\"text\" class=\"form-control\" name=\"vpn_country\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">State / Region</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"vpn_state\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">URL</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"vpn_config\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Status</label>\n";
echo "                           <select class=\"select form-control text-primary\" id=\"select\" name=\"vpn_status\">\n";
echo " 									    <option value=\"ACTIVE\">Enable</option>\n";
echo " 									    <option value=\"INACTIVE\">Disable</option>\n";
echo "                                     </select>\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Username</label>\n";
echo "                          <input type=\"hidden\" class=\"form-control\" name=\"auth_type\" value=\"up\">\n";
echo "                          <input type=\"hidden\" class=\"form-control\" name=\"auth_embedded\" value=\"YES\">\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"username\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Password</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"password\">\n";
echo "                          <input type=\"hidden\" class=\"form-control\" name=\"date\"   value=\"".date("Y-m-d h:i:s")."\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "					<br><center><button type=\"submit\" name=\"submit\" class=\"btn btn-primary\">Submit</button></center>\n";
echo "				</form>\n";
echo "				</div>\n";
echo "              </div>\n";
echo "            </div>\n";
echo "		   </div>\n";
echo "              </div>\n";
include ('includes/footer.php');
echo "</body>\n";
echo "\n";
echo "</html>\n";
?>