<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if (session_status() === PHP_SESSION_NONE){session_start();}

 $str_data = file_get_contents("api/zyx.json");
$data = json_decode($str_data, true);
$json = $data;
$json2 = $data['in_app_purchase'];
$json3 = $data['endpoint'];
$json4 = $data['language'];
//$data2 = json_decode($str_data, true);
$json5 = $data['app_conf']['default_device_select'];
$i="";
$i = (int)$i;

if(isset($_POST['submit_1c'])){;
$jsonData = file_get_contents("api/zyx.json");
$arrayData = json_decode($jsonData, true);
$newData = array(
   "app_mode"=> $_POST["app_mode"],
    "code_login"=> $_POST["code_login"],
    "app_mode_universal"=> $_POST["app_mode_universal"]);
    $newdata = array_replace($arrayData, $newData);
    $nextdata = array('in_app_purchase' =>array(
        "in_app_purchase_id"=>$_POST["in_app_purchase_id"], 
        "lic_key"=>$_POST["lic_key"], 
        "in_app_status"=>$_POST["in_app_status"],
        ));
        $nextnew = array_replace_recursive($newdata, $nextdata);
   $newjsonData= json_encode($nextnew, JSON_PRETTY_PRINT);
    file_put_contents("./api/zyx.json", $newjsonData);
    
header("Location: purple3.php");
}
if (isset($_POST['submit_2c'])){
    $json3 = $data['app_conf'];
    $jsonData3 = file_get_contents("./api/zyx.json");
    $arrayData3 = json_decode($jsonData3, true);
    $replacementData3 = array('endpoint' => array(
            "m3u_parse"=>$_POST["m3u_parse"], 
            "login"=>$_POST["login"], 
            "register"=>$_POST["register"], 
            "list_get"=>$_POST["list_get"],
            "list_xstream_update"=>$_POST["list_xstream_update"],
            "deleteurl"=>$_POST["deleteurl"], 
            "list_m3u_update"=>$_POST["list_m3u_update"],
            "list_update_epg"=>$_POST["list_update_epg"],
            ));
    $newArrayData3 = array_replace_recursive($arrayData3, $replacementData3);
    $newJsonData3 = json_encode($newArrayData3, JSON_PRETTY_PRINT);
    file_put_contents("./api/zyx.json", $newJsonData3);
    header("Location: purple3.php?");
}
if (isset($_POST['submit_3c']))
{
    $jsonData4 = file_get_contents("./api/zyx.json");
    $arrayData4 = json_decode($jsonData4, true);
    $replacementData4 = array('language' => array(
        "defult_language"=>$_POST["defult_language"],
        "firstime_select_language"=>$_POST["firstime_select_language"],
            ));
            $newarrayData4 = array_replace_recursive($arrayData4, $replacementData4);
            $newJsonData4 = json_encode($newarrayData4,     JSON_PRETTY_PRINT);
         //   file_put_contents(",/api/zyx.json",$newJsonData4);
            $arrayData5 = json_decode($newJsonData4, true);
       $anotherarray = array('app_conf'=> array('default_device_select' => array(
         "detect"=>$_POST["detect"],
         "device"=>$_POST["device"] ,
        )));
        $anothernew = array_replace_recursive($arrayData5, $anotherarray);
    $newJsonData5 = json_encode($anothernew, JSON_PRETTY_PRINT);
    
    file_put_contents("./api/zyx.json", $newJsonData5);
    header("Location: purple3.php?");
}
include("includes/header.php");
?>
<!-- Begin Page Content -->
        <div class="container-fluid">

          <!-- Page Heading -->
          <h1 class="h3 mb-1 text-gray-800"> Purple Settings   Three Submenus        
          <!-- Content Row -->
          <div class="row">
            <!-- First Column -->
            <div class="col-lg-4">
<div class="wrapper">
              <!-- Custom codes -->
                <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-mobile"></i> App Mode-In App purchase </h6>
                </div>
                <div class="card-body">
                        <form method="post">
<div class="form-group">
                            <h6 class="form-text"><strong>app_mode Xstream Full M3u Universal</strong></h6>
                           <input type="text" class="form-control" placeholder="app_mode" name="app_mode" value="<?= $json['app_mode'];?>"> 
                         </div><div class="form-group">
                            <h6 class="form-text"><strong>code_login</strong></h6>
                           <input type="text" class="form-control" placeholder="code_login" name="code_login" value="<?= $json['code_login'];?>"> 
                         </div><div class="form-group">
                            <h6 class="form-text"><strong>app_mode_universal</strong></h6>
                           <input type="text" class="form-control" placeholder="app_mode_universal" name="app_mode_universal" value="<?= $json['app_mode_universal'];?>"> 
                         </div>
                         <div class="form=group">
                            <h6 class="form-text"><strong>in_app_purchase_id</strong></h6>
                           <input type="text" class="form-control" placeholder="in_app_purchase_id" name="in_app_purchase_id" value="<?= $json['in_app_purchase']['in_app_purchase_id'];?>"> 
                         </div>
                         <div class="form-group">
                            <h6 class="form-text"><strong>lic_key</strong></h6>
                           <input type="text" class="form-control" placeholder="lic_key" name="lic_key" value="<?= $json['in_app_purchase']['lic_key'];?>"> 
                         <br>
                          <div class="form-group">
                        <button class="btn btn-primary btn-icon-split" name="submit_1c" type="submit">
                        <span class="icon text-white-50"><i class="fas fa-check"></i></span><span class="text">Submit</span>
                           </button>
                           </div></div>
                           </form>
</div></div></div></div>
<!-- 2nd Column -->
            <div class="col-lg-4">
             <div class="wrapper">
              <!-- Custom codes -->
                <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> M3u App Endpoints  </h6>
                </div>
                <div class="card-body">
                <form method="post">	
                <div class="form-group">
                            <h6 class="form-text"><strong>m3u_parse</strong></h6>
                           <input type="text" class="form-control" placeholder="m3u_parse" name="m3u_parse" value="<?= $json3['m3u_parse'];?>"> 
                         </div><div class="form-group">
                            <h6 class="form-text"><strong>login</strong></h6>
                           <input type="text" class="form-control" placeholder="login" name="login" value="<?= $json3['login'];?>"> 
                         </div><div class="form-group">
                            <h6 class="form-text"><strong>register</strong></h6>
                           <input type="text" class="form-control" placeholder="register" name="register" value="<?= $json3['register'];?>"> 
                         </div>
                         <div class="form=group">
                            <h6 class="form-text"><strong>list_get</strong></h6>
                           <input type="text" class="form-control" placeholder="list_get" name="list_get" value="<?= $json3['list_get'];?>"> 
                         </div>
                         <div class="form-group">
                            <h6 class="form-text"><strong>list_xstream_update</strong></h6>
                           <input type="text" class="form-control" placeholder="list_xstream_update" name="list_xstream_update" value="<?= $json3['list_xstream_update'];?>"> 
                         </div>
<div class="form-group">
                            <h6 class="form-text"><strong>deleteurl</strong></h6>
                           <input type="text" class="form-control" placeholder="deleteurl" name="deleteurl" value="<?= $json3['deleteurl'];?>"> 
                           </div>
 <div class="form-group">
                             <h6 class="form-text"><strong>list_m3u_update</strong></h6>
                           <input type="text" class="form-control" placeholder="list_m3u_update" name="list_m3u_update" value="<?= $json3['list_m3u_update'];?>"> 
                         </div>
<div class="form-group">
                            <h6 class="form-text"><strong>list_update_epg</strong></h6>
                           <input type="text" class="form-control" placeholder="list_update_epg" name="list_update_epg" value="<?= $json3['list_update_epg'];?>"> 
                         </div>
<div class="form-group">
                        <button class="btn btn-primary btn-icon-split" name="submit_2c" type="submit">
                        <span class="icon text-white-50"><i class="fas fa-check"></i></span><span class="text">Submit</span>
                           </button>
                             </div>
                               </form>
                                </body>
		                          </div></div>
		                          </div></div>
		                          <!-- Third Column -->
            <div class="col-lg-4">
<div class="wrapper">
              <!-- Custom codes -->
                <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> Language-Device Select </h6>
                </div>
                <div class="card-body">
                    <form method="post">
                                        <div class="card-body">
                        <form method="post">
<div class="form-group">
                            <h6 class="form-text"><strong>defult_language</strong></h6>
                           <input type="text" class="form-control" placeholder="defult_language" name="defult_language" value="<?= $json4['defult_language'];?>"> 
                         </div></div>
                         <div class="form-group ">
                        <label class="control-label requiredField" for="firstime_select_language">
                       <h6><strong>firstime_select_language =<? echo $json4['firstime_select_language']?></strong></h6> </label>
                        		<p><label>True</label>
							<input type="radio" name="firstime_select_language" value="true"  							 
							 <? if($json4['firstime_select_language'] == 'true' ){ echo 'checked="checked"'; } ?> />							
							<label>False</label>
							<input type="radio" name="firstime_select_language" value="false" 
							<?  if($json4['firstime_select_language'] == 'false' ){ echo 'checked="checked"'; } ?>	/>
							</label></div>
							
							<div class="form-group ">
                        <label class="control-label requiredField" for="detect">
                        <h6><strong>Detect Type Of Device =<? echo $json5['detect']?></strong></h6> </label>
                        		<p><label>True</label>
							<input type="radio" name="detect" value="true"  							 
							 <? if($json5['detect'] == 'true' ){ echo 'checked="checked"'; } ?> />							
							<label>False</label>
							<input type="radio" name="detect" value="false" 
							<?  if($json5['detect'] == 'false' ){ echo 'checked="checked"'; } ?>	/>
							</label></div>
<div class="form-group">
                            <h6 class="form-text"><strong>Device Tv Or Mobile</strong></h6>
                           <input type="text" class="form-control" placeholder="device" name="device" value="<?= $json5['device'];?>"> 
                         </div><div>
<div class="form-group">
                        <button class="btn btn-primary btn-icon-split" name="submit_3c"
type="submit">
                        <span class="icon text-white-50"><i class="fas fa-check"></i></span><span class="text">Submit</span>
                           </button>
                              </div>
                                 </div>
                                   </form>
                                     </div>
                                       </div>
                                         </div>
</div></div></div></div>
