<?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");
}
require_once __DIR__ . "/../../models/is_user.php";
if(isset($_GET["id"])) {
    $id = check_string($_GET["id"]);
    if(!($cron = $CMSNT->get_row("SELECT * FROM `cron_jobs` WHERE `trans_id` = '" . $id . "' AND `user_id` = '" . $getUser["id"] . "'  "))) {
        redirect(base_url("cron-jobs"));
    }
} else {
    redirect(base_url("cron-jobs"));
}
$body = ["title" => __("Chỉnh sửa link CRON JOB") . " | " . $CMSNT->site("title"), "desc" => $CMSNT->site("description"), "keyword" => $CMSNT->site("keywords")];
$body["header"] = "\n<link rel=\"stylesheet\" href=\"" . BASE_URL("public/client/") . "css/wallet.css\">\n<link rel=\"stylesheet\" href=\"" . BASE_URL("mod/css/cronjob.css") . "\">\n";
$body["footer"] = "\n\n";
require_once __DIR__ . "/header.php";
require_once __DIR__ . "/nav.php";
echo "\n\n<section class=\"py-5 inner-section profile-part\">\n    <div class=\"container\">\n        <div class=\"row\">\n            <div class=\"col-lg-7\">\n                <div class=\"home-heading mb-3\">\n                    <h3><i class=\"fa-solid fa-pen-to-square m-2\"></i>";
echo mb_strtoupper(__("Chỉnh sửa link CRON"));
echo "                        <span style=\"float: right;\">\n                            <a class=\"btn btn-danger btn-sm\" href=\"";
echo base_url("cron-jobs");
echo "\"><i\n                                    class=\"fa-solid fa-arrow-left me-1\"></i>";
echo mb_strtoupper(__("Quay lại"));
echo "</a>\n                        </span>\n                    </h3>\n                </div>\n                <div class=\"account-card pt-3\">\n                    <fieldset>\n                        <legend>";
echo __("Cấu hình");
echo "</legend>\n                        <div class=\"form-group row\">\n                            <div class=\"col-lg-3 col-form-label required fw-bold fs-6\">\n                                <label class=\"form-label\">";
echo __("Liên kết cần CRON");
echo " (<span\n                                        class=\"text-danger\">*</span>)</label>\n                            </div>\n                            <div class=\"col-xl-9 fv-row\">\n                                <input type=\"hidden\" id=\"token\" class=\"form-control\" value=\"";
echo $getUser["token"];
echo "\" />\n                                <input type=\"text\" class=\"form-control\" id=\"link_cron\" value=\"";
echo $cron["link_cron"];
echo "\" required>\n                                <small id=\"link-error\" class=\"text-danger\" style=\"display: none;\">\n                                    ";
echo __("Vui lòng nhập liên kết hợp lệ.");
echo "                                </small>\n                            </div>\n                        </div>\n                        <script>\n                        function isValidURL(url) {\n                            // Biểu thức chính quy để kiểm tra URL hợp lệ\n                            const pattern = new RegExp('^(https?:\\\\/\\\\/)?' + // protocol\n                                '((([a-zA-Z0-9\\\\-]+\\\\.)+[a-zA-Z]{2,})|' + // domain name\n                                '((\\\\d{1,3}\\\\.){3}\\\\d{1,3}))' + // OR ip (v4) address\n                                '(\\\\:\\\\d+)?(\\\\/[-a-zA-Z0-9@:%_\\\\+.~#?&//=]*)?\$', 'i'); // port and path\n                            return !!pattern.test(url);\n                        }\n\n                        document.getElementById('link_cron').addEventListener('input', function() {\n                            const linkValue = this.value;\n                            const errorElement = document.getElementById('link-error');\n\n                            if (!isValidURL(linkValue)) {\n                                errorElement.style.display = 'block'; // Hiển thị lỗi\n                            } else {\n                                errorElement.style.display = 'none'; // Ẩn lỗi\n                            }\n                        });\n                        </script>\n                        <div class=\"form-group row\">\n                            <div class=\"col-lg-8 col-form-label required fw-bold fs-6\">\n                                <label class=\"form-label\">";
echo __("Vòng lặp");
echo " (<span\n                                        class=\"text-danger\">*</span>)</label>\n                            </div>\n                            <div class=\"col-xl-4 fv-row\">\n                                <div class=\"input-group mb-3\">\n                                    <input type=\"number\" class=\"form-control\" id=\"timeloop\" value=\"";
echo $cron["timeloop"];
echo "\" value=\"60\">\n                                    <span class=\"input-group-text\">";
echo __("giây");
echo "</span>\n                                </div>\n                                <small id=\"timeloop-error\" class=\"text-danger\" style=\"display: none;\">";
echo __("Vòng lặp phải lớn\n                                    hơn hoặc bằng " . $CMSNT->site("cronjob_timeloop") . " giây.");
echo "</small>\n                            </div>\n                        </div>\n\n                        <script>\n                        document.getElementById('timeloop').addEventListener('input', function() {\n                            const timeloopValue = parseInt(this.value);\n                            const errorElement = document.getElementById('timeloop-error');\n\n                            if (timeloopValue < ";
echo (int) $CMSNT->site("cronjob_timeloop");
echo ") {\n                                errorElement.style.display = 'block'; // Hiển thị lỗi\n                            } else {\n                                errorElement.style.display = 'none'; // Ẩn lỗi\n                            }\n                        });\n                        </script>\n\n                        <div class=\"form-group row\">\n                            <div class=\"col-lg-8 col-form-label required fw-bold fs-6\">\n                                <label class=\"form-label\">";
echo __("Phương thức");
echo " (<span\n                                        class=\"text-danger\">*</span>)</label>\n                            </div>\n                            <div class=\"col-xl-4 fv-row\">\n                                <select class=\"form-control\" id=\"method\">\n                                    <option ";
echo $cron["method"] == "GET" ? "selected" : "";
echo " value=\"GET\">GET</option>\n                                    <option ";
echo $cron["method"] == "POST" ? "selected" : "";
echo " value=\"POST\">POST</option>\n                                </select>\n                            </div>\n                        </div>\n                    </fieldset>\n                \n                     \n\n                    <button class=\"btn-buy\" id=\"btnSave\" onclick=\"processbtnSave()\">\n                        <i class=\"fa-solid fa-save\"></i>\n                        <span>";
echo __("LƯU LẠI");
echo "</span>\n                    </button>\n\n                </div>\n            </div>\n            <div class=\"col-lg-5\">\n                <div class=\"home-heading mb-3\">\n                    <h3><i class=\"fa-solid fa-triangle-exclamation m-2\"></i>";
echo mb_strtoupper(__("Lưu ý"));
echo "                    </h3>\n                </div>\n                <div class=\"account-card pt-3\">\n                    ";
echo $CMSNT->site("cronjob_note");
echo "                </div>\n            </div>\n        </div>\n    </div>\n\n</section>\n\n\n\n<script type=\"text/javascript\">\n\nfunction processbtnSave() {\n    const btnSave = document.getElementById('btnSave');\n    const btnContent = btnSave.innerHTML;\n    \$('#btnSave').html('<i class=\"fa fa-spinner fa-spin\"></i>')\n        .prop('disabled',\n            true);\n    \$.ajax({\n        url: \"";
echo base_url("ajaxs/client/cronjob.php");
echo "\",\n        method: \"POST\",\n        dataType: \"JSON\",\n        data: {\n            action: 'saveCronJob',\n            token: \$(\"#token\").val(),\n            link_cron: \$(\"#link_cron\").val(),\n            timeloop: \$(\"#timeloop\").val(),\n            method: \$(\"#method\").val(),\n            id: '";
echo $id;
echo "'\n        },\n        success: function(response) {\n            if (response.status == 'success') {\n                Swal.fire('";
echo __("Successful!");
echo "', response.msg, 'success');\n            } else {\n                Swal.fire('";
echo __("Failure!");
echo "', response.msg, 'error');\n            }\n            \$('#btnSave').html(btnContent).prop('disabled', false);\n        },\n        error: function() {\n            showMessage('";
echo __("Không thể xử lý");
echo "', 'error');\n            \$('#btnSave').html(\n                btnContent\n            ).prop('disabled',\n                false);\n        }\n    });\n}\n</script>\n\n\n\n";
require_once __DIR__ . "/footer.php";

?>