• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

I have the problem: Login failed. Tbia might currently be down for maintenance.

eduardogrammer

New Member
Joined
Apr 29, 2020
Messages
2
Reaction score
0
I believe that my error is in login.php that I didn't edit at all because I don't know what I need to edit. I'm trying some things but I still can't do it. I am using theforgottenserver. Would it be an option to switch to MyACC because I find more content about?
Im using the current version from tibia: 12.31

my login.php:
PHP:
<?php
/**
 * Created by PhpStorm.
 * User: jlcvp - leu
 * Date: 07/06/17
 * Time: 21:22
 */

require 'config/config.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', false);

define('INITIALIZED', true);

if (!defined('ONLY_PAGE'))
    define('ONLY_PAGE', true);

// 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

/*error example:
{
    "errorCode":3,
    "errorMessage":"Account name or password is not correct."
}*/

//error function
function sendError($error_msg,$code=3){
    $retError = array();
    $retError["errorCode"] = $code;
    $retError["errorMessage"] = $error_msg;
    die(json_encode($retError));
}


$request_body = file_get_contents('php://input');
$result = json_decode($request_body, true);

$acc = $result["accountname"];
$password = $result["password"];

$query = $SQL->prepare("SELECT `id`,`premdays` FROM `accounts` WHERE `name` = :acc AND `password` = SHA1(:pass) LIMIT 1");

$query->bindValue(":acc", $acc);
$query->bindValue(":pass", $password);

$dbResource = $query->execute();

if (!$dbResource) {
    sendError("failed to get account.");
}

$dbRet = $query->fetch();
if (!dbRet) {
    sendError("failed to fetch account data");
}

$accId = $dbRet["id"];
$premdays = $dbRet["premdays"];

if (!$accId) {
    sendError("Account name or password is not correct.");
}

$dbResource = $SQL->query("SELECT `name`,`sex`,`lastlogin` FROM `players` WHERE `account_id` = $accId");

if (!$dbResource) {
    sendError("failed to get characters.");
}

$accArray = array();

$lastlogin=0;

while ($dbRet = $dbResource->fetch()) {
    $dict = array(
        "worldid" => 0,
        "name" => $dbRet["name"],
        "ismale" => (($dbRet["sex"]==1)?true:false),
        "tutorial" => (($dbRet["lastlogin"]>0) ? false:true)
    );
    $accArray[] = $dict;
    if($lastlogin<$dbRet["lastlogin"]){
        $lastlogin = $dbRet["lastlogin"];
    }
}

$data = array();

//TODO: Melhorar estrutura de dado aqui e preencher com os dados reais da account
$session = array(
    "sessionkey" => $acc . "\n" . $password,
    "lastlogintime" => $lastlogin,
    "ispremium" => ($premdays > 0 || $config["server"]["freePremium"]) ? true : false,
    "premiumuntil" => ($freePremium) ? (time() + 365 * 86400) : (time() + $premdays * 86400),
    "status" => "active"
);

$data["session"] = $session;

$playerData = array();

//TODO: melhorar estrutura de dado aqui para permitir multiple worlds
$world = array(
    "id" => 0,
    "name" => $config["server"]["serverName"],
    "externaladdress" => $config["server"]["ip"],
    "externalport" => $config["server"]["gameProtocolPort"],
    "previewstate" => 0,
    "location" => "BRA",
    "externaladdressunprotected" => $config["server"]["ip"],
    "externaladdressprotected" => $config["server"]["ip"]
);

$worlds = array($world);
$playerData["worlds"] = $worlds;
$playerData["characters"] = $accArray;


$data["playdata"] = $playerData;

echo json_encode($data);

my config.lua
LUA:
-- Combat settings
-- NOTE: valid values for worldType are: "pvp", "no-pvp" and "pvp-enforced"
worldType = "pvp"
hotkeyAimbotEnabled = true
protectionLevel = 1
killsToRedSkull = 3
killsToBlackSkull = 6
pzLocked = 60000
removeChargesFromRunes = true
removeChargesFromPotions = true
removeWeaponAmmunition = true
removeWeaponCharges = true
timeToDecreaseFrags = 24 * 60 * 60
whiteSkullTime = 15 * 60
stairJumpExhaustion = 2000
experienceByKillingPlayers = false
expFromPlayersLevelRange = 75

-- Connection Config
-- NOTE: maxPlayers set to 0 means no limit
ip = "127.0.0.1"
bindOnlyGlobalAddress = false
loginProtocolPort = 7171
gameProtocolPort = 7172
statusProtocolPort = 7171
maxPlayers = 0
motd = "Welcome to The Forgotten Server!"
onePlayerOnlinePerAccount = true
allowClones = false
serverName = "Forgotten"
statusTimeout = 5000
replaceKickOnLogin = true
maxPacketsPerSecond = 25

-- Deaths
-- NOTE: Leave deathLosePercent as -1 if you want to use the default
-- death penalty formula. For the old formula, set it to 10. For
-- no skill/experience loss, set it to 0.
deathLosePercent = -1

-- Houses
-- NOTE: set housePriceEachSQM to -1 to disable the ingame buy house functionality
housePriceEachSQM = 1000
houseRentPeriod = "never"
houseOwnedByAccount = false

-- Item Usage
timeBetweenActions = 200
timeBetweenExActions = 1000

-- Map
-- NOTE: set mapName WITHOUT .otbm at the end
mapName = "forgotten"
mapAuthor = "Komic"

-- Market
marketOfferDuration = 30 * 24 * 60 * 60
premiumToCreateMarketOffer = true
checkExpiredMarketOffersEachMinutes = 60
maxMarketOffersAtATimePerPlayer = 100

-- MySQL
mysqlHost = "127.0.0.1"
mysqlUser = "forgottenserver"
mysqlPass = "xxxxx"
mysqlDatabase = "forgottenserver"
mysqlPort = 3306
mysqlSock = ""

-- Misc.
-- NOTE: classicAttackSpeed set to true makes players constantly attack at regular
-- intervals regardless of other actions such as item (potion) use. This setting
-- may cause high CPU usage with many players and potentially affect performance!
-- forceMonsterTypesOnLoad server loads all monster types on startup for debugging purposes, you can change to false if all of your monster files don't throw errors to save up memory.
allowChangeOutfit = true
freePremium = false
kickIdlePlayerAfterMinutes = 15
maxMessageBuffer = 4
emoteSpells = false
classicEquipmentSlots = false
classicAttackSpeed = false
showScriptsLogInConsole = true
showOnlineStatusInCharlist = false
yellMinimumLevel = 2
yellAlwaysAllowPremium = false
forceMonsterTypesOnLoad = true

-- Server Save
-- NOTE: serverSaveNotifyDuration in minutes
serverSaveNotifyMessage = true
serverSaveNotifyDuration = 5
serverSaveCleanMap = false
serverSaveClose = false
serverSaveShutdown = true

-- Rates
-- NOTE: rateExp is not used if you have enabled stages in data/XML/stages.xml
rateExp = 5
rateSkill = 3
rateLoot = 2
rateMagic = 3
rateSpawn = 1

-- Monsters
deSpawnRange = 2
deSpawnRadius = 50

-- Stamina
staminaSystem = true

-- Scripts
warnUnsafeScripts = true
convertUnsafeScripts = true

-- Startup
-- NOTE: defaultPriority only works on Windows and sets process
-- priority, valid values are: "normal", "above-normal", "high"
defaultPriority = "high"
startupDatabaseOptimization = false

-- Status server information
ownerName = ""
ownerEmail = ""
url = "https://otland.net/"
location = "Sweden"
 

Similar threads

Back
Top