<?php

$jsondata = file_get_contents("./includes/slc.json");
$data = json_decode($jsondata, true);
$json = $data["info"];
$col = $json["aa"];
$lang = $json["aa"] == "1" ? "selected" : "";
$lang1 = $json["aa"] == "2" ? "selected" : "";
$lang2 = $json["aa"] == "3" ? "selected" : "";
$lang3 = $json["aa"] == "4" ? "selected" : "";
$lang4 = $json["aa"] == "5" ? "selected" : "";
$lang5 = $json["aa"] == "6" ? "selected" : "";
$lang6 = $json["aa"] == "7" ? "selected" : "";
$lang7 = $json["aa"] == "8" ? "selected" : "";
$lang8 = $json["aa"] == "9" ? "selected" : "";
$lang9 = $json["aa"] == "11" ? "selected" : "";
$lang10 = $json["aa"] == "12" ? "selected" : "";
$lang11 = $json["aa"] == "13" ? "selected" : "";
$lang12 = $json["aa"] == "14" ? "selected" : "";
$message = "<div class=\"alert alert-primary\" id=\"flash-msg\"><h4><i class=\"icon fa fa-check\"></i>Theme Updated!</h4></div>";
if (isset($_POST["submit"])) {
    $jsonData = file_get_contents("./includes/slc.json");
    $date = date("d-m-Y H:i:s");
    $time = time();
    $slc = base64_encode($date);
    $slc1 = sha1($slc);
    $slc2 = $json["ii"] + 1;
    $arrayData = json_decode($jsonData, true);
    $replacementData = ["info" => ["aa" => $_POST["aa"], "bb" => $date, "cc" => $time, "dd" => $slc, "ff" => $slc2, "gg" => $slc1]];
    $newArrayData = array_replace_recursive($arrayData, $replacementData);
    $newJsonData = json_encode($newArrayData, JSON_UNESCAPED_UNICODE);
    file_put_contents("./includes/slc.json", $newJsonData);
    header("Location: colour.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-play-circle\"\r\n                                    style=\"font-size:20px\">&nbsp;&nbsp;</i>Colour Changes</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\t\t\t\t\t\t\t<div class=\"form-group \">\n                            <label class=\" text-primary control-label requiredField\" for=\"aa\" >\n                            <strong> Pick Your Colour</strong>\n                            </label>\n                            <select class=\"select form-control text-primary\" id=\"select\" name=\"aa\">\n";
echo "\t\t\t\t\t\t\t\t<option value=\"1\"" . $lang . ">Blue</option>" . "\n";
echo "\t\t\t\t\t\t\t\t<option value=\"2\"" . $lang1 . ">Dark-Blue</option>" . "\n";
echo "\t\t\t\t\t\t\t\t<option value=\"3\"" . $lang2 . ">Red</option>" . "\n";
echo "\t\t\t\t\t\t\t\t<option value=\"4\"" . $lang3 . ">Orange</option>" . "\n";
echo "\t\t\t\t\t\t\t\t<option value=\"5\" " . $lang4 . ">Green</option>" . "\n";
echo "\t\t\t\t\t\t\t\t<option value=\"6\"" . $lang5 . ">Teal</option>" . "\n";
echo "\t\t\t\t\t\t\t\t<option value=\"7\"" . $lang6 . ">Cyan</option>" . "\n";
echo "\t\t\t\t\t\t\t\t<option value=\"8\"" . $lang7 . ">Silver</option>" . "\n";
echo "\t\t\t\t\t\t\t\t<option value=\"9\"" . $lang8 . ">Gray</option>" . "\n";
echo "\t\t\t\t\t\t\t\t<option value=\"11\"" . $lang9 . ">Black</option>" . "\n";
echo "\t\t\t\t\t\t\t\t<option value=\"12\"" . $lang10 . ">Purple</option>" . "\n";
echo "\t\t\t\t\t\t\t\t<option value=\"13\"" . $lang11 . ">Yellow</option>" . "\n";
echo "\t\t\t\t\t\t\t\t<option value=\"14\"" . $lang12 . ">Dark Black</option>" . "\n";
echo "                            </select>\n\t\t\t\t\t\t\t</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            </div>\n            </div>\n            </div>\n\n    <br><br><br>";
include "includes/footer.php";
require "includes/slc.php";
echo "</body>\n";

?>