Advertisement
Guest User

fdfsd

a guest
May 1st, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.21 KB | None | 0 0
  1. <?php
  2. /**
  3. * Created by Notepad++.
  4. * User: Malucooo - Erick Nunes
  5. * Remaked of login.php by JLCVP and parts of login.php by Monteiro. Thanks for both!
  6. * Date: 18/09/17
  7. * Time: 03:01
  8. */
  9.  
  10. require 'config/config.php';
  11.  
  12. // comment to show E_NOTICE [undefinied variable etc.], comment if you want make script and see all errors
  13. error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE);
  14.  
  15. // true = show sent queries and SQL queries status/status code/error message
  16. define('DEBUG_DATABASE', false);
  17. define('INITIALIZED', true);
  18.  
  19. if (!defined('ONLY_PAGE'))
  20. define('ONLY_PAGE', true);
  21.  
  22. // check if site is disabled/requires installation
  23. include_once('./system/load.loadCheck.php');
  24.  
  25. // fix user data, load config, enable class auto loader
  26. include_once('./system/load.init.php');
  27.  
  28. // DATABASE
  29. include_once('./system/load.database.php');
  30. if (DEBUG_DATABASE)
  31. Website::getDBHandle()->setPrintQueries(true);
  32.  
  33. // DATABASE END
  34. /*error example:
  35. {
  36. "errorCode":3,
  37. "errorMessage":"Account name or password is not correct."
  38. }*/
  39.  
  40. # Declare variables with array structure
  41. $characters = array();
  42. $playerData = array();
  43. $data = array();
  44. $isCasting = false;
  45.  
  46. # error function
  47. function sendError($msg){
  48. $ret = array();
  49. $ret["errorCode"] = 3;
  50. $ret["errorMessage"] = $msg;
  51.  
  52. die(json_encode($ret));
  53. }
  54.  
  55. # getting infos
  56. $request = file_get_contents('php://input');
  57. $result = json_decode($request, true);
  58.  
  59. # account infos
  60. $accountName = $result["accountname"];
  61. $password = $result["password"];
  62. # game port
  63. $port = 7172;
  64.  
  65. # check if player wanna see cast list
  66. if (strtolower($accountName) == "cast")
  67. $isCasting = true;
  68. if ($isCasting) {
  69. $casts = $SQL->query("SELECT `player_id` FROM `live_casts`")->fetchAll();
  70. if (count($casts[0]) == 0)
  71. sendError("There is no live casts right now!");
  72. foreach($casts as $cast) {
  73. $character = new Player();
  74. $character->load($cast['player_id']);
  75.  
  76. if ($character->isLoaded()) {
  77. $char = array("worldid" => 0, "name" => $character->getName(), "ismale" => (($character->getSex() == 1) ? true : false), "tutorial" => false);
  78. $characters[] = $char;
  79. }
  80. }
  81. $port = 7173;
  82. $lastLogin = 0;
  83. $premiumAccount = true;
  84. $timePremium = 0;
  85. } else {
  86. $account = new Account();
  87. $account->find($accountName);
  88.  
  89. if (!$account->isLoaded())
  90. sendError("Failed to get account. Try again!");
  91. if ($account->getPassword() != Website::encryptPassword($password))
  92. sendError("The password for this account is wrong. Try again!");
  93.  
  94. foreach($account->getPlayersList() as $character) {
  95. $char = array("worldid" => 0, "name" => $character->getName(), "ismale" => (($character->getSex() == 1) ? true : false), "tutorial" => false);
  96. $characters[] = $char;
  97. }
  98.  
  99. $lastLogin = $account->getLastLogin();
  100. $premiumAccount = ($account->isPremium()) ? true : false;
  101. $timePremium = time() + ($account->getPremDays() * 86400);
  102. }
  103. $session = array(
  104. "fpstracking" => false,
  105. "isreturner" => true,
  106. "returnernotification" => false,
  107. "showrewardnews" => false,
  108. "sessionkey" => $accountName . "\n" . $password,
  109. "lastlogintime" => $lastLogin,
  110. "ispremium" => $premiumAccount,
  111. "premiumuntil" => $timePremium,
  112. "status" => "active"
  113. );
  114. $world = array(
  115. "id" => 0,
  116. "name" => $config['server']['serverName'],
  117. "externaladdress" => $config['server']['ip'],
  118. "externalport" => $port,
  119. "previewstate" => 0,
  120. "location" => "BRA",
  121. "anticheatprotection" => false
  122. );
  123.  
  124. //Survey by: Cjaker
  125. $survey = array(
  126. "id" => rand(0, 999999),
  127. "invitationtext" => "Querido tibiano, obrigado por usar OTX, a base mais atualizada do Tibia Global.\n'Mensagem dita por Cjaker'.",
  128. "invitationtoken" => "1751f1beddf001e1d36dee78ace974",
  129. "endtimestamp" => 1510614000
  130. );
  131.  
  132. // https://limesurvey.cipsoft.com/index.php/survey/index/sid/527875/lang-en?token=1751f1beddf001e1d36dee78ace974
  133. // token=invitationtoken
  134. // o endtimestamp acima é o tempo convertido em unix timestamp, onde o mesmo é o prazo que irá acabar o survey!
  135.  
  136. $worlds = array($world);
  137. $data["session"] = $session;
  138. $playerData["worlds"] = $worlds;
  139. $playerData["characters"] = $characters;
  140. $data["playdata"] = $playerData;
  141. $data["survey"] = $survey;
  142.  
  143. echo json_encode($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement