<?php
/**
*
* @ This file is created by http://DeZender.Net
* @ deZender (PHP7 Decoder for SourceGuardian Encoder)
*
* @ Version			:	5.0.1.0
* @ Author			:	DeZender
* @ Release on		:	22.04.2022
* @ Official site	:	http://DeZender.Net
*
*/

$jsondata = file_get_contents("./api/json/r3alm_xcdata.json");
$data = json_decode($jsondata, true);
$json = $data["app"];
$message = "<div class=\"alert alert-primary\" id=\"flash-msg\"><h4><i class=\"icon fa fa-check\"></i>Items Updated!</h4></div>";
$apkautono = $json["apkautoupdate"] == "no" ? "selected" : "";
$apkautoyes = $json["apkautoupdate"] == "yes" ? "selected" : "";
$apkurl = $json["apkurl"];
$version_code = $json["version_code"];
if (isset($_POST["submit"])) {
    $jsonData = file_get_contents("./api/json/r3alm_xcdata.json");
    $arrayData = json_decode($jsonData, true);
    $replacementData = ["app" => ["apkurl" => $_POST["apkurl"], "version_code" => $_POST["version_code"], "apkautoupdate" => $_POST["apkautoupdate"]]];
    $newArrayData = array_replace_recursive($arrayData, $replacementData);
    $newJsonData = json_encode($newArrayData, JSON_UNESCAPED_UNICODE);
    file_put_contents("./api/json/r3alm_xcdata.json", $newJsonData);
    header("Location: update.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=\"fas fa-upload\"\n                                    style=\"font-size:20px\">&nbsp;&nbsp;</i>APK Push Update</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\" for=\"apkautoupdate\" >\n                              <strong>  Auto Update Apk: </strong>\n                            </label>\n                            <select class=\"select form-control text-primary\" id=\"select\" name=\"apkautoupdate\">\n";
echo "\t\t\t\t\t\t\t<option value=\"yes\"" . $apkautoyes . ">Enabled</option>" . "\n";
echo "                            <option value=\"no\"" . $apkautono . ">Disabled</option>" . "\n";
echo "                            </select>\n                            </div>\n                            <div class=\"form-group \">\n                            <label class=\" text-primary control-label\" for=\"apkurl\">\n                              <strong>  Apk Url: </strong>\n                            </label>\n                            <div class=\"input-group\">\n";
echo "                            <input type=\"text\" class=\"form-control text-primary\" name=\"apkurl\" id=\"apkurl\" value=\"" . $apkurl . "\">" . "\n";
echo "                            </div>\n                            </div>\n                            <div class=\"form-group \">\n                            <label class=\" text-primary control-label\" for=\"version_code\">\n                              <strong>   Version Code: </strong>\n                            </label>\n                            <div class=\"input-group\">\n";
echo "                            <input type=\"text\" class=\"form-control text-primary\" name=\"version_code\" id=\"version_code\" value=\"" . $version_code . "\">" . "\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\n    <br><br><br>";
include "includes/footer.php";
require "includes/r3alm.php";
echo "</body>\n";

?>