<?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.
if(!defined("IN_SITE")) {
    exit("The Request Not Found");
}
$body = ["title" => "Chỉnh sửa Link Cron Job", "desc" => "CMSNT Panel", "keyword" => "cmsnt, CMSNT, cmsnt.co,"];
$body["header"] = "\n\n";
$body["footer"] = "\n<!-- bs-custom-file-input -->\n<script src=\"" . BASE_URL("public/AdminLTE3/") . "plugins/bs-custom-file-input/bs-custom-file-input.min.js\"></script>\n<!-- Page specific script -->\n<script>\n\$(function () {\n  bsCustomFileInput.init();\n});\n</script> \n";
require_once __DIR__ . "/../../models/is_admin.php";
if(isset($_GET["id"])) {
    $id = check_string($_GET["id"]);
    $row = $CMSNT->get_row("SELECT * FROM `cron_jobs` WHERE `id` = '" . $id . "' ");
    if(!$row) {
        redirect(base_url("admin/cron-jobs"));
    }
} else {
    redirect(base_url("admin/cron-jobs"));
}
require_once __DIR__ . "/header.php";
require_once __DIR__ . "/sidebar.php";
require_once __DIR__ . "/nav.php";
if(!checkPermission($getUser["admin"], "edit_cron")) {
    exit("<script type=\"text/javascript\">if(!alert(\"Bạn không có quyền sử dụng tính năng này\")){window.history.back();}</script>");
}
if(isset($_POST["saveCron"])) {
    if($CMSNT->site("status_demo") != 0) {
        exit("<script type=\"text/javascript\">if(!alert(\"" . __("This function cannot be used because this is a demo site") . "\")){window.history.back().location.reload();}</script>");
    }
    if(empty($_POST["server_id"])) {
        exit("<script type=\"text/javascript\">if(!alert(\"Vui lòng chọn Server\")){window.history.back().location.reload();}</script>");
    }
    $server_id = check_string($_POST["server_id"]);
    if(empty($_POST["link_cron"])) {
        exit("<script type=\"text/javascript\">if(!alert(\"Vui lòng nhập Link cần CRON\")){window.history.back().location.reload();}</script>");
    }
    $link_cron = check_string($_POST["link_cron"]);
    if(empty($_POST["method"])) {
        exit("<script type=\"text/javascript\">if(!alert(\"Vui lòng nhập method\")){window.history.back().location.reload();}</script>");
    }
    $method = check_string($_POST["method"]);
    if(empty($_POST["timeloop"])) {
        exit("<script type=\"text/javascript\">if(!alert(\"Vui lòng nhập vòng lặp\")){window.history.back().location.reload();}</script>");
    }
    $timeloop = (int) check_string($_POST["timeloop"]);
    if($timeloop <= 0) {
        exit("<script type=\"text/javascript\">if(!alert(\"Vòng lặp không hợp lệ\")){window.history.back().location.reload();}</script>");
    }
    $isUpdate = $CMSNT->update("cron_jobs", ["server_id" => $server_id, "link_cron" => $link_cron, "method" => $method, "timeloop" => $timeloop, "status" => check_string($_POST["status"]), "expires_at" => check_string($_POST["expires_at"]), "updated_at" => gettime()], " `id` = '" . $id . "' ");
    if($isUpdate) {
        $Mobile_Detect = new Mobile_Detect();
        $CMSNT->insert("logs", ["user_id" => $getUser["id"], "ip" => myip(), "device" => $Mobile_Detect->getUserAgent(), "createdate" => gettime(), "action" => "Edit Cron (" . $link_cron . ")."]);
        $my_text = $CMSNT->site("noti_action");
        $my_text = str_replace("{domain}", $_SERVER["SERVER_NAME"], $my_text);
        $my_text = str_replace("{username}", $getUser["username"], $my_text);
        $my_text = str_replace("{action}", "Edit Cron (" . $link_cron . ").", $my_text);
        $my_text = str_replace("{ip}", myip(), $my_text);
        $my_text = str_replace("{time}", gettime(), $my_text);
        sendMessAdmin($my_text);
        exit("<script type=\"text/javascript\">if(!alert(\"Lưu thành công !\")){window.history.back().location.reload();}</script>");
    }
    exit("<script type=\"text/javascript\">if(!alert(\"Lưu thất bại !\")){window.history.back().location.reload();}</script>");
}
echo "\n\n<div class=\"main-content app-content\">\n    <div class=\"container-fluid\">\n        <div class=\"d-md-flex d-block align-items-center justify-content-between my-4 page-header-breadcrumb\">\n            <h1 class=\"page-title fw-semibold fs-18 mb-0\"><i class=\"fa-solid fa-server\"></i> Chỉnh sửa Link Cron Job\n                '<b style=\"color:red;\">";
echo $row["trans_id"];
echo "</b>'</h1>\n            <div class=\"ms-md-1 ms-0\">\n            </div>\n        </div>\n        <div class=\"row\">\n            <div class=\"col-xl-12\">\n                <div class=\"card custom-card\">\n                    <div class=\"card-header justify-content-between\">\n                        <div class=\"card-title\">\n                            CHỈNH SỬA SERVER CRON\n                        </div>\n                    </div>\n                    <div class=\"card-body\">\n                        <form action=\"\" method=\"POST\" enctype=\"multipart/form-data\">\n                            <div class=\"row mb-4\">\n                                <label class=\"col-sm-4 col-form-label\"\n                                    for=\"example-hf-email\">";
echo __("Liên kết cần CRON");
echo "                                    (<span class=\"text-danger\">*</span>)</label>\n                                <div class=\"col-sm-8\">\n                                    <input type=\"text\" class=\"form-control\" value=\"";
echo $row["link_cron"];
echo "\"\n                                        name=\"link_cron\" required>\n                                </div>\n                            </div>\n                            <div class=\"row mb-4\">\n                                <label class=\"col-sm-4 col-form-label\" for=\"example-hf-email\">";
echo __("Vòng lặp");
echo "                                    (<span class=\"text-danger\">*</span>)</label>\n                                <div class=\"col-sm-8\">\n                                    <input type=\"text\" class=\"form-control\" value=\"";
echo $row["timeloop"];
echo "\"\n                                        name=\"timeloop\" required>\n                                </div>\n                            </div>\n                            <div class=\"row mb-4\">\n                                <label class=\"col-sm-4 col-form-label\" for=\"example-hf-email\">Method</label>\n                                <div class=\"col-sm-8\">\n                                    <select class=\"form-control\" name=\"method\" required>\n                                        <option ";
echo $row["method"] == "GET" ? "selected" : "";
echo " value=\"GET\">GET</option>\n                                        <option ";
echo $row["method"] == "POST" ? "selected" : "";
echo " value=\"POST\">POST\n                                        </option>\n                                    </select>\n                                </div>\n                            </div>\n                            <div class=\"row mb-4\">\n                                <label class=\"col-sm-4 col-form-label\" for=\"example-hf-email\">Máy chủ</label>\n                                <div class=\"col-sm-8\">\n                                    <select class=\"form-control\" name=\"server_id\" required>\n                                        ";
foreach ($CMSNT->get_list(" SELECT * FROM `cron_server` WHERE `status` = 1 ") as $server) {
    echo "                                        <option ";
    echo $server["id"] == $row["server_id"] ? "selected" : "";
    echo "                                            value=\"";
    echo $server["id"];
    echo "\" data-price=\"";
    echo $server["price"];
    echo "\">\n                                            ";
    echo $server["name"];
    echo " - ";
    echo format_currency($server["price"]);
    echo "</option>\n                                        ";
}
echo "                                    </select>\n                                </div>\n                            </div>\n                            <div class=\"row mb-4\">\n                                <label class=\"col-sm-4 col-form-label\"\n                                    for=\"example-hf-email\">";
echo __("Thời gian hết hạn");
echo " (<span\n                                        class=\"text-danger\">*</span>)</label>\n                                <div class=\"col-sm-8\">\n                                    <div class=\"input-group\">\n                                        <div class=\"input-group-text text-muted\"> <i class=\"ri-time-line\"></i>\n                                        </div>\n                                        <input type=\"text\" class=\"form-control\" id=\"limitdatetime\" name=\"expires_at\"\n                                            value=\"";
echo $row["expires_at"];
echo "\" required>\n                                    </div>\n                                </div>\n                            </div>\n                            <div class=\"row mb-4\">\n                                <label class=\"col-sm-4 col-form-label\" for=\"example-hf-email\">Trạng thái</label>\n                                <div class=\"col-sm-8\">\n                                    <select class=\"form-control\" name=\"status\" required>\n                                        <option ";
echo $row["status"] == "active" ? "selected" : "";
echo " value=\"active\">Hoạt\n                                            động</option>\n                                        <option ";
echo $row["status"] == "pause" ? "selected" : "";
echo " value=\"pause\">Tạm dừng\n                                        </option>\n                                        <option ";
echo $row["status"] == "expired" ? "selected" : "";
echo " value=\"expired\">Hết\n                                            hạn</option>\n                                    </select>\n                                </div>\n                            </div>\n                            <div class=\"row mb-4\">\n                                <label class=\"col-sm-4 col-form-label\"\n                                    for=\"example-hf-email\">";
echo __("Tổng số tiền đã thanh toán");
echo "                                    (<span class=\"text-danger\">*</span>)</label>\n                                <div class=\"col-sm-8\">\n                                    <input type=\"text\" class=\"form-control\" value=\"";
echo format_currency($row["pay"]);
echo "\"\n                                        readonly>\n                                </div>\n                            </div>\n                            <a type=\"button\" class=\"btn btn-danger shadow-danger btn-wave\"\n                                href=\"";
echo base_url_admin("cron-jobs");
echo "\"><i class=\"fa fa-fw fa-undo me-1\"></i>\n                                ";
echo __("Back");
echo "</a>\n                            <button type=\"submit\" name=\"saveCron\" class=\"btn btn-primary shadow-primary btn-wave\"><i\n                                    class=\"fa fa-fw fa-save me-1\"></i> ";
echo __("Save");
echo "</button>\n                        </form>\n                    </div>\n                </div>\n            </div>\n        </div>\n    </div>\n</div>\n\n\n\n\n\n";
require_once __DIR__ . "/footer.php";

?>