
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        function checkStatus() {
            $.ajax({
                url: 'check_status.php',
                method: 'GET',
                success: function(response) {
                    if (response.trim() === "Not Running") {
                        window.location.href = "logout.php";
                    }
                },
                error: function() {
                    console.error("Failed to check status.");
                }
            });
        }

        // Run checkStatus every second
        setInterval(checkStatus, 1000);
    </script>


<?php



                                                    $sql = "SELECT * FROM tbl_manager";
                                                    $query = $dbh->prepare($sql);
                                                    $query->execute();
                                                    $results = $query->fetchAll(PDO::FETCH_OBJ);
                                                    $cnt = 1;
                                                    if ($query->rowCount() > 0) {}
                                                        foreach ($results as $result) {}
                                                        
                                                        
                                                        $logined = htmlentities($result->login);
                                                        $server = htmlentities($result->server);
                                                        $mainpass = htmlentities($result->mainpass);
                                                        $apipass = htmlentities($result->apipass);
                                                        
                                                        list($host, $port) = explode(':', $server);
                                                    

define("PATH_TO_SCRIPTS", "mt5_api/");
include PATH_TO_SCRIPTS . "mt5_api.php";

define("MT5_SERVER_IP", $host);
define("MT5_SERVER_PORT", $port);
define("MT5_SERVER_WEB_LOGIN", $logined);
define("MT5_SERVER_WEB_PASSWORD", $apipass);

define("MT5_CRYPT_PROTOCOL", true);
define("IS_WRITE_DEBUG_LOG", true);
define("MT5_CONNECTION_TIMEOUT", 3);
define("PATH_TO_LOGS", "./logs");
define("AGENT", "WebAPITesterArt");

$api = new MTWebAPI(AGENT, PATH_TO_LOGS, MT5_CRYPT_PROTOCOL);
$api->SetLoggerWriteDebug(IS_WRITE_DEBUG_LOG);

?>