<?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/brbox_ann.json");
$json = json_decode($jsondata, true);
$message = "<div class=\"alert alert-primary\" id=\"flash-msg\"><h4><i class=\"icon fa fa-check\"></i>Items Updated!</h4></div>";
$announcement = $json["announcement"];
$status = $json["ann_status"];
$channel = $json["channel"];
$expire = $json["ann_expire"];
$interval = $json["ann_interval"];
$disappear = $json["ann_disappear"];
if (isset($_POST["submit"])) {
    $jsonData = file_get_contents("./api/json/brbox_ann.json");
    if ($_POST["status"] == "ACTIVE") {
        $success = "1";
    } else {
        $success = "0";
    }
    $arrayData = json_decode($jsonData, true);
    $replacementData = ["success" => $success, "announcement" => $_POST["announcement"], "ann_status" => $_POST["status"], "channel" => $_POST["channel"], "ann_expire" => $_POST["expire"], "ann_interval" => $_POST["interval"], "ann_disappear" => $_POST["disappear"]];
    $newArrayData = array_replace_recursive($arrayData, $replacementData);
    $newJsonData = json_encode($newArrayData, JSON_UNESCAPED_UNICODE);
    file_put_contents("./api/json/brbox_ann.json", $newJsonData);
    header("Location: announcement.php?message=" . $message);
}
include "includes/header.php";
$statusINACTIVE = $json["ann_status"] == "INACTIVE" ? "selected" : "";
$statusACTIVE = $json["ann_status"] == "ACTIVE" ? "selected" : "";
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-bullhorn\"\r\n                                    style=\"font-size:20px\">&nbsp;&nbsp;</i> Edit Announcement</h4>\r\n                        \r\n\t\t\t\t\t\t</center>\r\n\n                </div>\n                <div class=\"card-body\">\n                        <form method=\"post\">\n                        <div class=\"form-group \">\n                        <label class=\"control-label requiredField text-primary\" for=\"announcement\">\n                        <strong>Announcement:</strong> \n                        </label>\n                        <div class=\"input-group\">\n";
echo "<input class=\"form-control text-primary\" id=\"announcement\" name=\"announcement\" value=\"" . $announcement . "\" type=\"text\"/>" . "\n";
echo "                        </div>\n                        </div>\n                       <div class=\"form-group \">\n                        <label class=\"control-label requiredField text-primary\" for=\"select\">\n                        <strong> Status:</strong>\n                        </label>\n                        <select class=\"select form-control text-primary text-primary\" id=\"select\" name=\"status\">\n";
echo "\t\t\t\t\t\t<option value=\"INACTIVE\" " . $statusINACTIVE . ">INACTIVE</option>" . "\n";
echo "                        <option value=\"ACTIVE\" " . $statusACTIVE . ">ACTIVE</option>" . "\n";
echo "                        </select>\n                        </div>\n                        <div class=\"form-group\">\n                        <label class=\"control-label requiredField text-primary\" for=\"channel\">\n                        <strong>Channel: </strong>(All or Channel Name)</label>\n                        <div class=\"input-group\">\n";
echo "                        <input class=\"form-control text-primary\" id=\"channel\" name=\"channel\" value=\"" . $channel . "\" type=\"text\"/>" . "\n";
echo "                        </div>\n                        </div>\n                        <div class=\"form-group \">\n                        <label class=\"control-label  text-primary\" for=\"date\">\n                        <strong>Expiration:</strong> \n                        </label>\n                        <div class=\"input-group\">\n";
echo "                        <input type=\"text\" class=\"form-control text-primary\" name=\"expire\" placeholder=\"YYYY-MM-DD\" id=\"datetimepicker\" value=\"" . $expire . "\">" . "\n";
echo "                        </div>\n                        </div>\n                        <div class=\"form-group \">\n                        <label class=\"control-label requiredField text-primary\" for=\"interval\">\n                        <strong>Display Interval:</strong> (Minute)</label>\n                        <div class=\"input-group\">\n";
echo "                        <input class=\"form-control text-primary\" id=\"interval\" name=\"interval\" placeholder=\"0 min\" value=\"" . $interval . "\" type=\"text\"/>" . "\n";
echo "                        </div>\n                        </div>\n                        <div class=\"form-group \">\n                        <label class=\"control-label requiredField text-primary\" for=\"disappear\">\n                        <strong>Disappear: </strong>(Minute)<div class=\"input-group\">\n";
echo "                        <input class=\"form-control text-primary\" id=\"disappear\" name=\"disappear\" placeholder=\"0 min\" value=\"" . $disappear . "\" type=\"text\"/>" . "\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            </div>\n    <br><br><br>\n";
include "includes/footer.php";
echo " <script>\n\$(document).ready(function () {\$('#flash-msg').delay(3000).fadeOut('slow');\n});\n  </script>\n</body>\n</html>\n";

?>