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

require 'includes/check.php';
$ifofuser_check = $_SESSION['id'];
$jsondata_admin = file_get_contents('./includes/brbox.json');
$data_admin = json_decode($jsondata_admin, true);
$json_admin = $data_admin['info'];
$col_admin = $json_admin['kk'];
$col_thm = $json_admin['ll'];
$col_thm1 = $json_admin['nn'];
$col_thm2 = $json_admin['pp'];
$col_thm3 = $json_admin['rr'];
$col_thm4 = $json_admin['tt'];
$col_thm5 = $json_admin['vv'];
$col_thm6 = $json_admin['xx'];
$col_thm7 = $json_admin['zz'];

if ($col_admin == '0') {
	header('Location: app.php');
}

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$jsondata_check = file_get_contents('./includes/brbox.json');
$json_check = json_decode($jsondata_check, true);
$col1_check = $json_check['info'];
$col4_check = $col1_check['mm'];
$jsondata = file_get_contents('./api/json/brbox_xcdata.json');
$data = json_decode($jsondata, true);
$json = $data['app'];
$theme_d = $json["theme"] == "d" ? "selected" : "";
$theme_1 = $json["theme"] == "1" ? "selected" : "";
$theme_2 = $json["theme"] == "2" ? "selected" : "";
$theme_3 = $json["theme"] == "3" ? "selected" : "";
$theme_4 = $json["theme"] == "4" ? "selected" : "";
$theme_5 = $json["theme"] == "5" ? "selected" : "";
$theme_6 = $json["theme"] == "6" ? "selected" : "";
$theme_7 = $json["theme"] == "7" ? "selected" : "";
$active_d = $json["theme"] == "d" ? "success" : "primary";
$active_1 = $json["theme"] == "1" ? "success" : "primary";
$active_2 = $json["theme"] == "2" ? "success" : "primary";
$active_3 = $json["theme"] == "3" ? "success" : "primary";
$active_4 = $json["theme"] == "4" ? "success" : "primary";
$active_5 = $json["theme"] == "5" ? "success" : "primary";
$active_6 = $json["theme"] == "6" ? "success" : "primary";
$active_7 = $json["theme"] == "7" ? "success" : "primary";
$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/brbox_xcdata.json');
	$arrayData = json_decode($jsonData, true);
	$replacementData = [
		'app' => ['theme' => $_POST['theme']]
	];
	$newArrayData = array_replace_recursive($arrayData, $replacementData);
	$newJsonData = json_encode($newArrayData, JSON_UNESCAPED_UNICODE);
	file_put_contents('./api/json/brbox_xcdata.json', $newJsonData);
	header('Location: theme.php?message=' . $message);
}

include 'includes/header.php';
echo ' <!-- Begin Page Content -->' . "\n";
echo '        <div class="container-fluid">' . "\n";
echo "\n";

if (isset($_GET['message'])) {
	echo $_GET['message'];
}

echo '          <!-- Page Heading -->' . "\n";
echo '          <h1 class="h3 mb-1 text-gray-800">Theme Changes</h1>' . "\n";
echo '         ' . "\n";
echo '          <!-- Content Row -->' . "\n";
echo '          <div class="row">' . "\n";
echo "\n";
echo '            <!-- First Column -->' . "\n";
echo '            <div class="col-lg-12">' . "\n";
echo "\n";
echo '              <!-- Custom codes -->' . "\n";
echo '                <div class="card border-left-primary shadow card shadow mb-4">' . "\n";
echo '                <div class="card-header py-3">' . "\n";
echo '                <h6 class="m-0 font-weight-bold text-primary"><i class="fa fa-paint-brush"></i> Choose Your Theme</h6>' . "\n";
echo '                </div>' . "\n";
echo '                <div class="card-body">' . "\n";
echo '                            <form method="post">' . "\n";
echo '                            <div class="form-group ">' . "\n";
echo '                            <label class="control-label requiredField" for="theme" >' . "\n";
echo '                            </label>' . "\n";
echo '                            <select class="select form-control text-primary" id="select" name="theme">' . "\n";

if ($col_thm == '1') {
	echo "\t\t\t\t\t\t\t\t" . '<option value="d"' . $theme_d . '>Standard</span></option>' . "\n";
}

if ($col_thm1 == '1') {
	echo '                     <option value="1"' . $theme_1 . '>Theme 1</option>' . "\n";
}

if ($col_thm2 == '1') {
	echo "\t\t\t\t\t\t\t\t" . '<option value="2"' . $theme_2 . '>Theme 2</option>' . "\n";
}

if ($col_thm3 == '1') {
	echo "\t\t\t\t\t\t\t\t" . '<option value="3"' . $theme_3 . '>Theme 3</option>' . "\n";
}

if ($col_thm4 == '1') {
	echo "\t\t\t\t\t\t\t\t" . '<option value="4"' . $theme_4 . '>Theme 4</option>' . "\n";
}

if ($col_thm5 == '1') {
	echo "\t\t\t\t\t\t\t\t" . '<option value="5"' . $theme_5 . '>Theme 5</option>' . "\n";
}

if ($col_thm6 == '1') {
	echo "\t\t\t\t\t\t\t\t" . '<option value="6"' . $theme_6 . '>Theme 6</option>' . "\n";
}

if ($col_thm7 == '1') {
	echo "\t\t\t\t\t\t\t\t" . '<option value="7"' . $theme_7 . '>New Layout</option>' . "\n";
}

echo '                            </select>' . "\n";
echo "\t\t\t\t\t\t\t" . '</div>' . "\n";
echo '                            <div class="form-group">' . "\n";
echo '                            <div class="card-body">' . "\n";
echo '                        <button class="btn btn-success btn-icon-split" name="submit" type="submit">' . "\n";
echo '                        <span class="icon text-white-50"><i class="fas fa-check"></i></span><span class="text">Submit</span>' . "\n";
echo '                        </button>' . "\n";
echo '                            </div>' . "\n";
echo '                            </div>' . "\n";
echo '                            </form>' . "\n";
echo '                </div>' . "\n";
echo '              </div>' . "\n";
echo '            </div>' . "\n";
echo "\n";

if ($col_thm == '1') {
	echo '            <!-- Theme -->' . "\n";
	echo '            <div class="col-xl-3 col-md-6 mb-4">' . "\n";
	echo '              <div class="card border-left-' . $active_d . ' shadow py-2">' . "\n";
	echo '                <div class="card-body">' . "\n";
	echo '                  <div class="row no-gutters align-items-center">' . "\n";
	echo '                    <div class="col mr-2">' . "\n";
	echo '                      <div class="text-xs font-weight-bold text-' . $active_d . ' text-uppercase mb-1">Standard</div>' . "\n";
	echo '                      <div class="h5 mb-0 font-weight-bold text-gray-800"><img class="card-img-bottom" src="./img/themes/d.jpg" alt="Card image" style="width:100%"></div>' . "\n";
	echo '                    </div>' . "\n";
	echo '                  </div>' . "\n";
	echo '                </div>' . "\n";
	echo '              </div>' . "\n";
	echo '            </div>' . "\n";
}

if ($col_thm1 == '1') {
	echo '            <!-- Theme -->' . "\n";
	echo '            <div class="col-xl-3 col-md-6 mb-4">' . "\n";
	echo '              <div class="card border-left-' . $active_1 . ' shadow py-2">' . "\n";
	echo '                <div class="card-body">' . "\n";
	echo '                  <div class="row no-gutters align-items-center">' . "\n";
	echo '                    <div class="col mr-2">' . "\n";
	echo '                      <div class="text-xs font-weight-bold text-' . $active_1 . ' text-uppercase mb-1">Theme 1</div>' . "\n";
	echo '                      <div class="h5 mb-0 font-weight-bold text-gray-800"><img class="card-img-bottom" src="./img/themes/1.jpg" alt="Card image" style="width:100%"></div>' . "\n";
	echo '                    </div>' . "\n";
	echo '                  </div>' . "\n";
	echo '                </div>' . "\n";
	echo '              </div>' . "\n";
	echo '            </div>' . "\n";
}

echo '            ' . "\n";

if ($col_thm2 == '1') {
	echo '            <!-- Theme -->' . "\n";
	echo '            <div class="col-xl-3 col-md-6 mb-4">' . "\n";
	echo '              <div class="card border-left-' . $active_2 . ' shadow py-2">' . "\n";
	echo '                <div class="card-body">' . "\n";
	echo '                  <div class="row no-gutters align-items-center">' . "\n";
	echo '                    <div class="col mr-2">' . "\n";
	echo '                      <div class="text-xs font-weight-bold text-' . $active_2 . ' text-uppercase mb-1">Theme 2</div>' . "\n";
	echo '                      <div class="h5 mb-0 font-weight-bold text-gray-800"><img class="card-img-bottom" src="./img/themes/2.jpg" alt="Card image" style="width:100%"></div>' . "\n";
	echo '                    </div>' . "\n";
	echo '                  </div>' . "\n";
	echo '                </div>' . "\n";
	echo '              </div>' . "\n";
	echo '            </div>' . "\n";
	echo '            ' . "\n";
}

if ($col_thm3 == '1') {
	echo '            <!-- Theme -->' . "\n";
	echo '            <div class="col-xl-3 col-md-6 mb-4">' . "\n";
	echo '              <div class="card border-left-' . $active_3 . ' shadow py-2">' . "\n";
	echo '                <div class="card-body">' . "\n";
	echo '                  <div class="row no-gutters align-items-center">' . "\n";
	echo '                    <div class="col mr-2">' . "\n";
	echo '                      <div class="text-xs font-weight-bold text-' . $active_3 . ' text-uppercase mb-1">Theme 3</div>' . "\n";
	echo '                      <div class="h5 mb-0 font-weight-bold text-gray-800"><img class="card-img-bottom" src="./img/themes/3.jpg" alt="Card image" style="width:100%"></div>' . "\n";
	echo '                    </div>' . "\n";
	echo '                  </div>' . "\n";
	echo '                </div>' . "\n";
	echo '              </div>' . "\n";
	echo '            </div>' . "\n";
	echo '            ' . "\n";
}

if ($col_thm4 == '1') {
	echo '            <!-- Theme -->' . "\n";
	echo '            <div class="col-xl-3 col-md-6 mb-4">' . "\n";
	echo '              <div class="card border-left-' . $active_4 . ' shadow py-2">' . "\n";
	echo '                <div class="card-body">' . "\n";
	echo '                  <div class="row no-gutters align-items-center">' . "\n";
	echo '                    <div class="col mr-2">' . "\n";
	echo '                      <div class="text-xs font-weight-bold text-' . $active_4 . ' text-uppercase mb-1">Theme 4</div>' . "\n";
	echo '                      <div class="h5 mb-0 font-weight-bold text-gray-800"><img class="card-img-bottom" src="./img/themes/4.jpg" alt="Card image" style="width:100%"></div>' . "\n";
	echo '                    </div>' . "\n";
	echo '                  </div>' . "\n";
	echo '                </div>' . "\n";
	echo '              </div>' . "\n";
	echo '            </div>' . "\n";
	echo '            ' . "\n";
}

if ($col_thm5 == '1') {
	echo '            <!-- Theme -->' . "\n";
	echo '            <div class="col-xl-3 col-md-6 mb-4">' . "\n";
	echo '              <div class="card border-left-' . $active_5 . ' shadow py-2">' . "\n";
	echo '                <div class="card-body">' . "\n";
	echo '                  <div class="row no-gutters align-items-center">' . "\n";
	echo '                    <div class="col mr-2">' . "\n";
	echo '                      <div class="text-xs font-weight-bold text-' . $active_5 . ' text-uppercase mb-1">Theme 5</div>' . "\n";
	echo '                      <div class="h5 mb-0 font-weight-bold text-gray-800"><img class="card-img-bottom" src="./img/themes/5.jpg" alt="Card image" style="width:100%"></div>' . "\n";
	echo '                    </div>' . "\n";
	echo '                  </div>' . "\n";
	echo '                </div>' . "\n";
	echo '              </div>' . "\n";
	echo '            </div>' . "\n";
	echo '            ' . "\n";
}

if ($col_thm6 == '1') {
	echo '            <!-- Theme -->' . "\n";
	echo '            <div class="col-xl-3 col-md-6 mb-4">' . "\n";
	echo '              <div class="card border-left-' . $active_6 . ' shadow py-2">' . "\n";
	echo '                <div class="card-body">' . "\n";
	echo '                  <div class="row no-gutters align-items-center">' . "\n";
	echo '                    <div class="col mr-2">' . "\n";
	echo '                      <div class="text-xs font-weight-bold text-' . $active_6 . ' text-uppercase mb-1">Theme 6</div>' . "\n";
	echo '                      <div class="h5 mb-0 font-weight-bold text-gray-800"><img class="card-img-bottom" src="./img/themes/6.jpg" alt="Card image" style="width:100%"></div>' . "\n";
	echo '                    </div>' . "\n";
	echo '                  </div>' . "\n";
	echo '                </div>' . "\n";
	echo '              </div>' . "\n";
	echo '            </div>' . "\n";
	echo '            ' . "\n";
}

if ($col_thm7 == '1') {
	echo '            <!-- Theme -->' . "\n";
	echo '            <div class="col-xl-3 col-md-6 mb-4">' . "\n";
	echo '              <div class="card border-left-' . $active_7 . ' shadow py-2">' . "\n";
	echo '                <div class="card-body">' . "\n";
	echo '                  <div class="row no-gutters align-items-center">' . "\n";
	echo '                    <div class="col mr-2">' . "\n";
	echo '                      <div class="text-xs font-weight-bold text-' . $active_7 . ' text-uppercase mb-1">New Layout</div>' . "\n";
	echo '                      <div class="h5 mb-0 font-weight-bold text-gray-800"><img class="card-img-bottom" src="./img/themes/0_new.jpg" alt="Card image" style="width:100%"></div>' . "\n";
	echo '                    </div>' . "\n";
	echo '                  </div>' . "\n";
	echo '                </div>' . "\n";
	echo '              </div>' . "\n";
	echo '            </div>' . "\n";
	echo '            ' . "\n";
}

echo '            </div>' . "\n";
echo '            </div>' . "\n";
echo "\n";
include 'includes/footer.php';
require 'includes/brbox.php';
echo '</body>' . "\n";

?>