<?php
// connection.php

define("MT5_SERVER_IP", "access.tgshost.org");
define("MT5_SERVER_PORT", 26043);
define("MT5_SERVER_WEB_LOGIN", "7020");
define("MT5_SERVER_WEB_PASSWORD", "Aa@123456");
define("MT5_TIMEOUT", 10); // seconds

include_once __DIR__ . "/mt5_api/mt5_api.php";  // MTWebAPI class

class MT5Connection {
    public $api;

    public function __construct() {
        $this->api = new MTWebAPI("WebAPI", "./logs", true);
    }

    public function connect(): bool {
        $ret = $this->api->Connect(
            MT5_SERVER_IP,
            MT5_SERVER_PORT,
            MT5_TIMEOUT,
            MT5_SERVER_WEB_LOGIN,
            MT5_SERVER_WEB_PASSWORD
        );
        return $ret === MTRetCode::MT_RET_OK;
    }

    public function lastError(): int {
        return $this->api->LastError();
    }
}
?>
