<?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['plugin_list'];
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['plugin_list'];
$jsonData = file_get_contents("./api/zyx.json");
$arrayData = json_decode($jsonData, true);

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

   'name'              => $_POST["name"],
   'version'                => $_POST["version"],
   'playstore_url'           => $_POST["playstore_url"],
   'apk_url'            => $_POST["apk_url"],
   'status'          => $_POST["status"],
   'pkg_name'         => $_POST["pkg_name"]
   
     ));
     $newdata = json_encode($newdata);
     $index = array_search( $key, $keys, $strict = true );
   $newdata = array_merge_recursive($arrayData, $newData);
  //$newArrayData = array_merge_recursive($arrayData, $json);
  $newdata['plugin_list'] = array_values($newdata['plugin_list']);
  
$newJsonData = json_encode($newdata, JSON_PRETTY_PRINT);
file_put_contents("./api/zyx.json", $newJsonData);
header("Location: plugin.php");
		}
include ('includes/header.php');


echo "            <div class=\"col-md-8 px-4\">\n";
echo "              <div class=\"card bg text-primay\">\n";
echo "                <div class=\"card-header card-header-warning\">\n";
echo "                  <h4 class=\"card-title\">Add Plugin</h4>\n";
echo "                </div>\n";
echo "                <div class=\"card-body alert-primary\">\n";
echo "                  <form  method=\"post\">\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Name</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"name\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">version</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"version\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">playstore_url</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"playstore_url\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">apk_url</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"apk_url\">\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 "                          <input type=\"text\" class=\"form-control\" name=\"status\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">pkg_name</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 "					<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";
?>