<?php

include "includes/header.php";
echo " <!-- Begin Page Content -->\n        <div class=\"container-fluid\">\n\n";
if (isset($_POST["message"])) {
    echo $_POST["message"];
}
$lurl = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] !== "off" ? "https" : "http") . "://" . $_SERVER["HTTP_HOST"] . dirname($_SERVER["PHP_SELF"]) . "/api/";
$jsondata = file_get_contents("./api/json/slc_xcdata.json");
$data = json_decode($jsondata, true);
$json = $data["app"];
$security_key64 = $json["security_key"];
$security_id64 = $json["security_id"];
$security_key = base64_decode(base64_decode($security_key64));
$security_id = base64_decode(base64_decode($security_id64));
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 fa-code\"\n                                    style=\"font-size:20px\">&nbsp;&nbsp;</i> URL AES Convert</h4>\n                        \n\t\t\t\t\t\t</center>\n\n            </div>\n                <div class=\"card-body\">\n                            <form method=\"post\">\n                            <div class=\"form-group \">\n                            <label class=\" text-primary control-label requiredField\" for=\"aa\" >\n                            <strong> Enter your string in the textarea below.</strong>\n                            </label>\n                            <div class=\"input-group\">\n<textarea class=\"form-control text-primary\" name=\"txtCode\" cols=\"50\" rows=\"3\" id=\"inny\">";
echo isset($_POST["txtCode"]) ? $_POST["txtCode"] : $lurl;
echo "</textarea>\n<br>\n                            </div>\n                            </div>\n                            <div class=\"form-group \">\n                            <label class=\" text-primary control-label requiredField\" for=\"aa\" >\n                            <strong> Converted string output</strong>\n                            </label>\n                            <div class=\"input-group\">\n<textarea class=\"form-control text-primary\"  name=\"txtResult\" cols=\"50\" rows=\"3\" id=\"output\">";
if (isset($_POST["cmdEncode"])) {
    $txtCode = $_POST["txtCode"];
    $str = bin2hex(openssl_encrypt($txtCode, "AES-128-CBC", $security_key, OPENSSL_RAW_DATA, $security_id));
    $new_str = str_replace(" ", "", $str);
    echo $new_str;
} else {
    $text = isset($_POST["txtCode"]);
    $str = bin2hex(openssl_encrypt($text, "AES-128-CBC", $security_key, OPENSSL_RAW_DATA, $security_id));
    $new_str = str_replace(" ", "", $str);
    echo $new_str;
}
echo "</textarea><br>\n                            </div>\n                            </div>\n                            <div class=\"form-group\">\n                            <div>\n   \n<center>\n<button class=\"btn btn-success btn-icon-split submit_button\" name=\"cmdEncode\" value=\"Encode\"  /><span class=\"icon text-white-50\"><i class=\"fas fa-check\"></i></span><span class=\"text\"> Encoder </span></button>\n\n        <button class=\"btn btn-warning btn-icon-split submit_button\" name=\"cmdDecode\" value=\"Decode\"  /><span class=\"icon text-white-50\"><i class=\"fas fa-check\"></i></span><span class=\"text\"> Decoder </span></button>\n        \n        <button class=\"btn btn-danger btn-icon-split submit_button\" type=\"button\" value=\"Clear All\" onClick=\"clearContents()\"><span class=\"icon text-white-50\"><i class=\"fas  fa-eraser\"></i></span><span class=\"text\"> Clear </span></button>\n        <button class=\"btn btn-info btn-icon-split submit_button\" type=\"button\" onClick=\"changeText('copy', ' Copied Output', ' Copy Output')\" ><span class=\"icon text-white-50\"><i class=\"fas fa-copy\"></i></span><span  id=\"copy\"        class=\"text\"> Copy Output</span></button><br>\n  </center>\n\n                            </form>\n                </div>\n              </div>\n            </div>\n\n    <br><br><br>";
include "includes/footer.php";
require "includes/slc.php";
echo "      </body>\n";
