<?php 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$jsondata = file_get_contents("./api/zyx.json");
$data = json_decode($jsondata, true);
$json = $data['app_dns'];
if(isset($_POST['submit'])){
$message = '<div class="alert alert-primary" id="flash-msg"><h4><i class="icon fa fa-check"></i>Items Updated!</h4></div>';
$json = $data['app_dns'];
$jsonData = file_get_contents("./api/zyx.json");
$arrayData = json_decode($jsonData, true);

$newData['app_dns'] = array('app_dns' =>  array(

   'dns_title'              => $_POST["dns_title"],
   'url'                => $_POST["url"],
   'live_dns'           => $_POST["live_dns"],
   'epg_dns'            => $_POST["epg_dns"],
   'movie_dns'          => $_POST["movie_dns"],
   'series_dns'         => $_POST["series_dns"],
   'catchup_dns'        => $_POST["catchup_dns"]
     ));
     if(isset($newdata)){
     $newdata = json_encode($newdata);};
     if(isset($key)){
     $index = array_search( $key, $keys, $strict = true );};
   $newdata = array_merge_recursive($arrayData, $newData);
  //$newArrayData = array_merge_recursive($arrayData, $json);
  $newdata['app_dns'] = array_values($newdata['app_dns']);
  
$newJsonData = json_encode($newdata, JSON_PRETTY_PRINT);
file_put_contents("./api/zyx.json", $newJsonData);
header("Location: dns.php");
		}
include ('includes/header.php');


echo "            <div class=\"col-md-8 px-4\">\n";
echo "              <div class=\"card bg text-primay alert-primary\">\n";
echo "                <div class=\"card-header card-header-warning\">\n";
echo "                  <h4 class=\"card-title\">Add DNS</h4>\n";
echo "                </div>\n";
echo "                <div class=\"card-body\">\n";
echo "                  <form  method=\"post\">\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Title</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"dns_title\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Main DNS</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"url\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Live</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"live_dns\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Epg</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"epg_dns\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Movie</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"movie_dns\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Series</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"series_dns\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Catch-Up</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"catchup_dns\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "					<br><button type=\"submit\" name=\"submit\" class=\"btn btn-primary pull-right\">Submit</button>\n";
echo "				</form>\n";
echo "				</div>\n";
echo "              </div>\n";
echo "            </div>\n";
echo "		   </div>\n";
echo "    <br><br><br>\n";
include ('includes/footer.php');
echo "</body>\n";
echo "\n";
echo "</html>\n";
?>