<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.4
 * @ Decoder version: 1.0.2
 * @ Release: 10/08/2022
 */

// Decoded file for php version 74.
echo "<!-- Developer By CMSNT.CO | FB.COM/CMSNT.CO | ZALO.ME/0947838128 | MMO Solution -->\n";
define("IN_SITE", true);
require_once __DIR__ . "/libs/db.php";
require_once __DIR__ . "/config.php";
require_once __DIR__ . "/libs/lang.php";
require_once __DIR__ . "/libs/helper.php";
require_once __DIR__ . "/libs/database/users.php";
$CMSNT = new DB();
if($CMSNT->site("status") != 1 && !isSecureCookie("admin_login")) {
    require_once __DIR__ . "/views/common/maintenance.php";
    exit;
}
$rateLimitWindow = 10;
$maxRequests = 15;
$userIP = myip();
$currentTime = time();
if(!isset($_SESSION["rate_limit"])) {
    $_SESSION["rate_limit"] = [];
}
if(!isset($_SESSION["rate_limit"][$userIP])) {
    $_SESSION["rate_limit"][$userIP] = ["start_time" => $currentTime, "request_count" => 1];
} else {
    $userData =& $_SESSION["rate_limit"][$userIP];
    if($rateLimitWindow < $currentTime - $userData["start_time"]) {
        $userData["start_time"] = $currentTime;
        $userData["request_count"] = 1;
    } else {
        $userData["request_count"]++;
    }
    if($maxRequests < $userData["request_count"]) {
        header("HTTP/1.1 429 Too Many Requests");
        exit("Bạn đã gửi quá nhiều yêu cầu. Vui lòng thử lại sau.");
    }
}
if(isset($_GET["utm_source"])) {
    $utm_source = check_string($_GET["utm_source"]);
    setcookie("utm_source", $utm_source, time() + 2592000, "/");
}
if(isset($_GET["aff"])) {
    $aff = check_string($_GET["aff"]);
    setcookie("aff", $aff, time() + 2592000, "/");
    if($user_ref = $CMSNT->get_row("SELECT * FROM `users` WHERE `id` = '" . $aff . "' ")) {
        $CMSNT->cong("users", "ref_click", 1, " `id` = '" . $user_ref["id"] . "' ");
    }
}
$module = !empty($_GET["module"]) ? check_path($_GET["module"]) : "client";
$home = $module == "client" ? $CMSNT->site("home_page") : "home";
$action = !empty($_GET["action"]) ? check_path($_GET["action"]) : $home;
if($module == "admin") {
    require_once __DIR__ . "/models/is_admin.php";
}
if($action == "footer" || $action == "header" || $action == "sidebar" || $action == "nav" || $action == "widget-cron") {
    require_once __DIR__ . "/views/common/404.php";
    exit;
}
$path = "views/" . $module . "/" . $action . ".php";
if(file_exists($path)) {
    require_once __DIR__ . "/" . $path;
    exit;
}
require_once __DIR__ . "/views/common/404.php";
exit;

?>