• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Tibia 11 Webservice

Milice

Nutjob
Joined
Oct 4, 2008
Messages
954
Solutions
2
Reaction score
157
Location
Sverige ;D
Due to the fact that a bunch of people seem to want to get their Tibia 11 client to work, i am now releasing a fully functioning login webservice.

http://pastebin.com/uf2frXMf

This script is made to be put at the very top of your index.php, before EVERYTHING else.
This is to make it a lot easier for players who wish to connect.

To connect to said webservice use Jo3bingham's Tibia 11 IP Changer
https://otland.net/threads/tibia-11-ip-changer.246255/
 
Does tibia client 11 do an http request to ip/services/login.php by default?
I guess I should add it to Znote AAC. I have never used that client so not sure how it works.
 
Does tibia client 11 do an http request to ip/services/login.php by default?
I guess I should add it to Znote AAC. I have never used that client so not sure how it works.
If you use Jo3binghams IPChanger ) which is linked in the thread ) you set the path yourself.
The reason i made it so that you can put it in the index.php (it checks for Mozilla/5.0 useragent which is used by Tibia11) is because then you will simply set your path to "http://example.ot" and it will connect.
 
@Milice
No bro, im sure that i have all good, i try with login.php and index.php, with custom client 11 and with the new ip changer for Tibia 11, and nothing, what i have wrong? check:

Config for Tibia 11 Ip Changer:

Client Path:
C:\Users\Darkjav\Desktop\bk\Me\Tibia\Tibia1100\packages\Tibia\bin\client.exe

Login Web Service:


index.php
Code:
<?php
    if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0") {
        @error_reporting(0);
        @ini_set('display_errors', 'Off');
        header("Content-Type: application/json");
 
        $loginInfo = json_decode(file_get_contents("php://input"));
        $accountName = $loginInfo->{"accountname"};
        $password = $loginInfo->{"password"};
 
        if($accountName == "" || password == "") {
            die('{"errorCode":3,"errorMessage":"Account name or password is incorrect."}');
        }
 
        $MySQL_Host = "127.0.0.1";
        $MySQL_User = "root";
        $MySQL_Password = "tested87";
        $MySQL_DB = "test1100";
 
        $SQL = new mysqli($MySQL_Host, $MySQL_User, $MySQL_Password, $MySQL_DB);
 
        if(mysqli_connect_error()) {
            die('{"errorCode":3,"errorMessage":"Internal error. Please try again later or contact customer support if the problem persists."}');
        }
 
        $AccountQuery = $SQL->query("SELECT * FROM `accounts` WHERE `name` = '".$SQL->real_escape_string($accountName)."' AND `password` = '".SHA1($SQL->real_escape_string($password))."'")->fetch_array(MYSQLI_ASSOC);
        if($AccountQuery["name"] != $accountName) {
            die('{"errorCode":3,"errorMessage":"Account name or password is incorrect."}');
        }
 
        $AccountID = $AccountQuery["id"];
        $Secret = $AccountQuery["secret"];
        $Premdays = $AccountQuery["premdays"];
 
        $CharacterQuery = $SQL->query("SELECT `name` FROM `players` WHERE `account_id` = '".$AccountID."'")->fetch_all(MYSQLI_ASSOC);
 
        $worldID = 0;
        $worldName = "OTSERVERTEST Full Rl 10.94 - 11.0";
        $serverAddress = $_SERVER["SERVER_ADDR"];
        $serverPort = 7172;
        $freePremium = false;
 
        echo '{"session":{"sessionkey":"'.$accountName.'\n'.$password.'\n'.$secret.'\n'.(floor(time() / 30)).'","lastlogintime":0,"ispremium":'.($Premdays > 0 || $freePremium ? "true" : "false").',"premiumuntil":'.($freePremium ? "0" : time() + ($Premdays * 86400)).',"status":"active"},"playdata":{"worlds":[{"id":'.$worldID.',"name":"'.$worldName.'","externaladdress":"'.$serverAddress.'","externalport":'.$serverPort.',"previewstate":0}],"characters":[';
        foreach($CharacterQuery as $Character) {
            if($Character != $CharacterQuery[0]) {
                echo ',';
            }
            echo '{"worldid":'.$worldID.',"name":"'.$Character["name"].'"}';
        }
        echo ']}}';
    return;
    }
?>
<?php
// comment to show E_NOTICE [undefinied variable etc.], comment if you want make script and see all errors
error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE);

// true = show sent queries and SQL queries status/status code/error message
//define('DEBUG_DATABASE', true);
define('DEBUG_DATABASE', false);

define('INITIALIZED', true);

date_default_timezone_set('America/New_York');

// if not defined before, set 'false' to load all normal
if(!defined('ONLY_PAGE'))
    define('ONLY_PAGE', false);
    
// check if site is disabled/requires installation
include_once('./system/load.loadCheck.php');

// fix user data, load config, enable class auto loader
include_once('./system/load.init.php');

// DATABASE
include_once('./system/load.database.php');
if(DEBUG_DATABASE)
    Website::getDBHandle()->setPrintQueries(true);
// DATABASE END

// LOGIN
if(!ONLY_PAGE)
    include_once('./system/load.login.php');
// LOGIN END

// COMPAT
// some parts in that file can be blocked because of ONLY_PAGE constant
include_once('./system/load.compat.php');
// COMPAT END

// LOAD PAGE
include_once('./system/load.page.php');
// LOAD PAGE END

// LAYOUT
// with ONLY_PAGE we return only page text, not layout
if(!ONLY_PAGE)
    include_once('./system/load.layout.php');
else
    echo $main_content;
// LAYOUT END


/services/login.php
Code:
<?php
    if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0") {
        @error_reporting(0);
        @ini_set('display_errors', 'Off');
        header("Content-Type: application/json");
 
        $loginInfo = json_decode(file_get_contents("php://input"));
        $accountName = $loginInfo->{"accountname"};
        $password = $loginInfo->{"password"};
 
        if($accountName == "" || password == "") {
            die('{"errorCode":3,"errorMessage":"Account name or password is incorrect."}');
        }
 
        $MySQL_Host = "127.0.0.1";
        $MySQL_User = "root";
        $MySQL_Password = "tested87";
        $MySQL_DB = "test1100";
 
        $SQL = new mysqli($MySQL_Host, $MySQL_User, $MySQL_Password, $MySQL_DB);
 
        if(mysqli_connect_error()) {
            die('{"errorCode":3,"errorMessage":"Internal error. Please try again later or contact customer support if the problem persists."}');
        }
 
        $AccountQuery = $SQL->query("SELECT * FROM `accounts` WHERE `name` = '".$SQL->real_escape_string($accountName)."' AND `password` = '".SHA1($SQL->real_escape_string($password))."'")->fetch_array(MYSQLI_ASSOC);
        if($AccountQuery["name"] != $accountName) {
            die('{"errorCode":3,"errorMessage":"Account name or password is incorrect."}');
        }
 
        $AccountID = $AccountQuery["id"];
        $Secret = $AccountQuery["secret"];
        $Premdays = $AccountQuery["premdays"];
 
        $CharacterQuery = $SQL->query("SELECT `name` FROM `players` WHERE `account_id` = '".$AccountID."'")->fetch_all(MYSQLI_ASSOC);
 
        $worldID = 0;
        $worldName = "OTSERVERTEST Full Rl 10.94 - 11.0";
        $serverAddress = $_SERVER["SERVER_ADDR"];
        $serverPort = 7172;
        $freePremium = false;
 
        echo '{"session":{"sessionkey":"'.$accountName.'\n'.$password.'\n'.$secret.'\n'.(floor(time() / 30)).'","lastlogintime":0,"ispremium":'.($Premdays > 0 || $freePremium ? "true" : "false").',"premiumuntil":'.($freePremium ? "0" : time() + ($Premdays * 86400)).',"status":"active"},"playdata":{"worlds":[{"id":'.$worldID.',"name":"'.$worldName.'","externaladdress":"'.$serverAddress.'","externalport":'.$serverPort.',"previewstate":0}],"characters":[';
        foreach($CharacterQuery as $Character) {
            if($Character != $CharacterQuery[0]) {
                echo ',';
            }
            echo '{"worldid":'.$worldID.',"name":"'.$Character["name"].'"}';
        }
        echo ']}}';
    return;
    }
?>


(only work with my old login.php using custom client 11)
 
@Milice
No bro, im sure that i have all good, i try with login.php and index.php, with custom client 11 and with the new ip changer for Tibia 11, and nothing, what i have wrong? check:

Config for Tibia 11 Ip Changer:

Client Path:

Login Web Service:


index.php
Code:
<?php
    if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0") {
        @error_reporting(0);
        @ini_set('display_errors', 'Off');
        header("Content-Type: application/json");
 
        $loginInfo = json_decode(file_get_contents("php://input"));
        $accountName = $loginInfo->{"accountname"};
        $password = $loginInfo->{"password"};
 
        if($accountName == "" || password == "") {
            die('{"errorCode":3,"errorMessage":"Account name or password is incorrect."}');
        }
 
        $MySQL_Host = "127.0.0.1";
        $MySQL_User = "root";
        $MySQL_Password = "tested87";
        $MySQL_DB = "test1100";
 
        $SQL = new mysqli($MySQL_Host, $MySQL_User, $MySQL_Password, $MySQL_DB);
 
        if(mysqli_connect_error()) {
            die('{"errorCode":3,"errorMessage":"Internal error. Please try again later or contact customer support if the problem persists."}');
        }
 
        $AccountQuery = $SQL->query("SELECT * FROM `accounts` WHERE `name` = '".$SQL->real_escape_string($accountName)."' AND `password` = '".SHA1($SQL->real_escape_string($password))."'")->fetch_array(MYSQLI_ASSOC);
        if($AccountQuery["name"] != $accountName) {
            die('{"errorCode":3,"errorMessage":"Account name or password is incorrect."}');
        }
 
        $AccountID = $AccountQuery["id"];
        $Secret = $AccountQuery["secret"];
        $Premdays = $AccountQuery["premdays"];
 
        $CharacterQuery = $SQL->query("SELECT `name` FROM `players` WHERE `account_id` = '".$AccountID."'")->fetch_all(MYSQLI_ASSOC);
 
        $worldID = 0;
        $worldName = "OTSERVERTEST Full Rl 10.94 - 11.0";
        $serverAddress = $_SERVER["SERVER_ADDR"];
        $serverPort = 7172;
        $freePremium = false;
 
        echo '{"session":{"sessionkey":"'.$accountName.'\n'.$password.'\n'.$secret.'\n'.(floor(time() / 30)).'","lastlogintime":0,"ispremium":'.($Premdays > 0 || $freePremium ? "true" : "false").',"premiumuntil":'.($freePremium ? "0" : time() + ($Premdays * 86400)).',"status":"active"},"playdata":{"worlds":[{"id":'.$worldID.',"name":"'.$worldName.'","externaladdress":"'.$serverAddress.'","externalport":'.$serverPort.',"previewstate":0}],"characters":[';
        foreach($CharacterQuery as $Character) {
            if($Character != $CharacterQuery[0]) {
                echo ',';
            }
            echo '{"worldid":'.$worldID.',"name":"'.$Character["name"].'"}';
        }
        echo ']}}';
    return;
    }
?>
<?php
// comment to show E_NOTICE [undefinied variable etc.], comment if you want make script and see all errors
error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE);

// true = show sent queries and SQL queries status/status code/error message
//define('DEBUG_DATABASE', true);
define('DEBUG_DATABASE', false);

define('INITIALIZED', true);

date_default_timezone_set('America/New_York');

// if not defined before, set 'false' to load all normal
if(!defined('ONLY_PAGE'))
    define('ONLY_PAGE', false);
   
// check if site is disabled/requires installation
include_once('./system/load.loadCheck.php');

// fix user data, load config, enable class auto loader
include_once('./system/load.init.php');

// DATABASE
include_once('./system/load.database.php');
if(DEBUG_DATABASE)
    Website::getDBHandle()->setPrintQueries(true);
// DATABASE END

// LOGIN
if(!ONLY_PAGE)
    include_once('./system/load.login.php');
// LOGIN END

// COMPAT
// some parts in that file can be blocked because of ONLY_PAGE constant
include_once('./system/load.compat.php');
// COMPAT END

// LOAD PAGE
include_once('./system/load.page.php');
// LOAD PAGE END

// LAYOUT
// with ONLY_PAGE we return only page text, not layout
if(!ONLY_PAGE)
    include_once('./system/load.layout.php');
else
    echo $main_content;
// LAYOUT END


/services/login.php
Code:
<?php
    if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0") {
        @error_reporting(0);
        @ini_set('display_errors', 'Off');
        header("Content-Type: application/json");
 
        $loginInfo = json_decode(file_get_contents("php://input"));
        $accountName = $loginInfo->{"accountname"};
        $password = $loginInfo->{"password"};
 
        if($accountName == "" || password == "") {
            die('{"errorCode":3,"errorMessage":"Account name or password is incorrect."}');
        }
 
        $MySQL_Host = "127.0.0.1";
        $MySQL_User = "root";
        $MySQL_Password = "tested87";
        $MySQL_DB = "test1100";
 
        $SQL = new mysqli($MySQL_Host, $MySQL_User, $MySQL_Password, $MySQL_DB);
 
        if(mysqli_connect_error()) {
            die('{"errorCode":3,"errorMessage":"Internal error. Please try again later or contact customer support if the problem persists."}');
        }
 
        $AccountQuery = $SQL->query("SELECT * FROM `accounts` WHERE `name` = '".$SQL->real_escape_string($accountName)."' AND `password` = '".SHA1($SQL->real_escape_string($password))."'")->fetch_array(MYSQLI_ASSOC);
        if($AccountQuery["name"] != $accountName) {
            die('{"errorCode":3,"errorMessage":"Account name or password is incorrect."}');
        }
 
        $AccountID = $AccountQuery["id"];
        $Secret = $AccountQuery["secret"];
        $Premdays = $AccountQuery["premdays"];
 
        $CharacterQuery = $SQL->query("SELECT `name` FROM `players` WHERE `account_id` = '".$AccountID."'")->fetch_all(MYSQLI_ASSOC);
 
        $worldID = 0;
        $worldName = "OTSERVERTEST Full Rl 10.94 - 11.0";
        $serverAddress = $_SERVER["SERVER_ADDR"];
        $serverPort = 7172;
        $freePremium = false;
 
        echo '{"session":{"sessionkey":"'.$accountName.'\n'.$password.'\n'.$secret.'\n'.(floor(time() / 30)).'","lastlogintime":0,"ispremium":'.($Premdays > 0 || $freePremium ? "true" : "false").',"premiumuntil":'.($freePremium ? "0" : time() + ($Premdays * 86400)).',"status":"active"},"playdata":{"worlds":[{"id":'.$worldID.',"name":"'.$worldName.'","externaladdress":"'.$serverAddress.'","externalport":'.$serverPort.',"previewstate":0}],"characters":[';
        foreach($CharacterQuery as $Character) {
            if($Character != $CharacterQuery[0]) {
                echo ',';
            }
            echo '{"worldid":'.$worldID.',"name":"'.$Character["name"].'"}';
        }
        echo ']}}';
    return;
    }
?>


(only work with my old login.php using custom client 11)
It should work, from here atleast http://otservertest.sytes.net/ is unreachable and that ofcourse the client will have to be able to connect to the webservice. Try doing it locally and see if it works. If not, PM me with some more information about the issue.
 
You missed some of it millice, authenticator is not allowed currently by this.

The authenticator code is "6" by the way. And nice, finally someone got it after us(Fortissimum).

This are all errorcodes I used
PHP:
/* Error Codes :
        1: technical errors
        2: 
        3: Login errorCode
        4:
        5:
        6: Authenticator error
    */

//edit last post next time
 
Last edited by a moderator:
I am able to enter my information and get the character select screen to load up properly, but as soon as I click a character to login, it says Account and Password is incorrect. Do you have any idea what is causing it?

I set the RSA Key myself, and the webservice is located at http://127.0.0.1/index.php
 
I am able to enter my information and get the character select screen to load up properly, but as soon as I click a character to login, it says Account and Password is incorrect. Do you have any idea what is causing it?

I set the RSA Key myself, and the webservice is located at http://127.0.0.1/index.php
It may have to do with an outdated php configuration, update your php to the latest version and it should work.
 
I thought I was doing great with
  • PHP version: 7.0.13
Lol, but there is a version 7.1.0 so I will try that.
 
Sorry for the double post, but here's an update.

I actually went down to PHP version: 5.6.28 to test it, and it instantly said illegal value no matter what I input (I tried going backwards to see what would be different)
Then by upgrading to the latest PHP 7.1.0 it still would allow me to login to character select and just wouldn't go past that point.
 
Last time, really sorry about triple posting, I miss editing.

Code:
[ 17:16:11,859 ] QObject::connect: Cannot connect (null)::stateChanged(QNetworkSession::State) to QNetworkReplyHttpImpl::_q_networkSessionStateChanged(QNetworkSession::State)
[ 17:16:19,955 ] QObject::connect: Cannot connect (null)::stateChanged(QNetworkSession::State) to QNetworkReplyHttpImpl::_q_networkSessionStateChanged(QNetworkSession::State)
[ 17:16:20,770 ] Connection to gameserver  QUrl("tcp://127.0.0.1:7172")  requested (Charakter "Nadega Sample" )
[ 17:16:20,770 ] Socket state changed  QAbstractSocket::HostLookupState
[ 17:16:20,770 ] Socket state changed  QAbstractSocket::ConnectingState
[ 17:16:20,775 ] Socket state changed  QAbstractSocket::ConnectedState
[ 17:16:20,775 ] Connected to Gameserver  "127.0.0.1" "Tibia11 Server"
[ 17:16:20,783 ] QObject::connect: Cannot connect (null)::stateChanged(QNetworkSession::State) to QNetworkReplyHttpImpl::_q_networkSessionStateChanged(QNetworkSession::State)
[ 17:16:20,784 ] Socket state changed  QAbstractSocket::ClosingState
[ 17:16:20,784 ] Socket state changed  QAbstractSocket::UnconnectedState
[ 17:16:20,784 ] Disconnected from Gameserver

Here is a logfile of the client.exe as it is trying to connect.
 
Back
Top