<?php

$jsondata = file_get_contents("./api/json/slc_xcdata.json");
$data = json_decode($jsondata, true);
$json = $data["app"];
$admob_banner_id = $json["admob_banner_id"];
$admob_interstitial_id = $json["admob_interstitial_id"];
$message = "<div class=\"alert alert-primary\" id=\"flash-msg\"><h4><i class=\"icon fa fa-check\"></i>Items Updated!</h4></div>";
if (isset($_POST["submit"])) {
    $jsonData = file_get_contents("./api/json/slc_xcdata.json");
    $arrayData = json_decode($jsonData, true);
    $replacementData = ["app" => ["admob_banner_id" => $_POST["admob_banner_id"], "admob_interstitial_id" => $_POST["admob_interstitial_id"]]];
    $newArrayData = array_replace_recursive($arrayData, $replacementData);
    $newJsonData = json_encode($newArrayData, JSON_UNESCAPED_UNICODE);
    file_put_contents("./api/json/slc_xcdata.json", $newJsonData);
    header("Location: appads.php?message=" . $message);
}
include "includes/header.php";
echo " <!-- Begin Page Content -->\n        <div class=\"container-fluid\">\n\n";
if (isset($_GET["message"])) {
    echo $_GET["message"];
}
echo "          <!-- Content Row -->\n          <div class=\"row\">\n\n            <!-- First Column -->\n            <div class=\"col-lg-12\">\n\n              <!-- Custom codes -->\n                <div class=\"card text-text-primary\">\n                <div class=\"card-header bg-primary py-3\">\n                <center><h4 align=\"center\" class=\"m-0 text-white\"><i class=\"fa fa-rocket\"\n                                    style=\"font-size:20px\">&nbsp;&nbsp;</i> Ad Customisation</h4>\n                        \n\t\t\t\t\t\t</center>\n\n            </div>\n                <div class=\"card-body\">\n                            <form method=\"post\">\n\t\t\t\t\t\t\t<div class=\"form-group \">\n                            <label class=\"text-primary control-label requiredField\"  for=\"admob_banner_id\">\n                            <strong> Admob Banner Id</strong>\n                            </label>\n                            <div class=\"input-group\">\n";
echo "                            <input class=\"form-control text-primary\" id=\"description\" name=\"admob_banner_id\" value=\"" . $admob_banner_id . "\" type=\"text\"/>" . "\n";
echo "                            </div>\n                            </div>\n                            <div class=\"form-group \">\n                            <label class=\"control-label  text-primary\" for=\"admob_interstitial_id\">\n                            <strong> Admob Interstitial Id</strong>\n                            </label>\n                            <div class=\"input-group\">\n";
echo "                            <input type=\"text\" class=\"form-control text-primary\" name=\"admob_interstitial_id\" id=\"date\" value=\"" . $admob_interstitial_id . "\">" . "\n";
echo "                            </div>\n                            </div>\n                            <div class=\"form-group\">\n                            <div>\n                        <button class=\"btn btn-success btn-icon-split\" name=\"submit\" type=\"submit\">\n                        <span class=\"icon text-white-50\"><i class=\"fas fa-check\"></i></span><span class=\"text\">Submit</span>\n                        </button>\n                            </div>\n                            </div>\n                            </form>\n                </div>\n              </div>\n            </div>\n            </div>\n\n    <br><br><br>";
include "includes/footer.php";
require "includes/slc.php";
echo "      </body>\n";

?>