AccountInfo.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. namespace App\Models\Login;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use App\Helpers\Functions;
  6. use App\Models\Login\GameVersion;
  7. class AccountInfo extends Model
  8. {
  9. protected $connection = "Login";
  10. protected $table = "AccountInfo";
  11. protected $primaryKey = "AccountDBID";
  12. protected $dates = [];
  13. protected $fillable = ["Username", "Password", "UUID","RegisterTime", "RegisterIP",
  14. "LastLoginTime","LastLoginIP","IsBlocked","Real_Balance","Bonus_Balance",
  15. "Permission","UserAge","MakeCodeNo","Email","Real_CERPass"
  16. ];
  17. protected $hidden = [
  18. 'Password',
  19. 'UUID',
  20. 'Permission',
  21. 'MakeCodeNo'
  22. ];
  23. public $timestamps = false;
  24. public function antihacklogcontrol(){
  25. return $this->hasMany('App\Models\Web\AntihackLogControl','AccountDBID');
  26. }
  27. public static function LoginAccount($params)
  28. {
  29. $AccountData = self::where('Username', $params['Username'])->first();
  30. if(!$AccountData){
  31. return ['code' => -1, 'msg' => 'Ez a fiók nem létezik!' ];
  32. }else if($AccountData->Username == $params['Username'] && $AccountData->Password != md5($params['Password'])){
  33. return ['code' => -2, 'msg' => 'Hibás jelszó!' ];
  34. }
  35. if($AccountData->IsBlocked == 1)
  36. return ['code' => -3, 'msg' => 'Letiltott fiók!' ];
  37. //if($AccountData->IsActivated == 0)
  38. //return ['code' => -4, 'msg' => 'Conta não ativada!' ];
  39. //$GameVersion = GameVersion::first();
  40. //if($GameVersion->IsMaintenance == 1 && $AccountData->Permission == 0)
  41. //return ['code' => -5, 'msg' => 'Servidor em manutenção!' ];
  42. $UUID = vsprintf('%s%s-%s-4000-8%.3s-%s%s%s0',str_split(dechex( microtime(true) * 1000 ) . bin2hex( random_bytes(8) ),4));
  43. $AccountData->UUID = $UUID;
  44. $AccountData->LastLoginIP = Functions::getIp();
  45. $AccountData->LastLoginTime = now();
  46. $AccountData->save();
  47. //$AccountData->Version = $GameVersion->Version;
  48. return [
  49. 'code' => 0,
  50. 'msg' => 'Siker!',
  51. 'token' => $UUID,
  52. 'accountinfo' => $AccountData
  53. ];
  54. }
  55. public static function UpdateUUID($UUID)
  56. {
  57. $AccountData = self::where('UUID', $UUID)->first();
  58. $AccountData->UUID = "";
  59. $AccountData->save();
  60. }
  61. public static function GetBalance($Username)
  62. {
  63. $totalBalance = 0;
  64. $AccountBalance = self::where('Username', $Username)->first();
  65. if($AccountBalance){
  66. $totalBalance = $AccountBalance->Real_Balance + $AccountBalance->Bonus_Balance;
  67. }
  68. return $totalBalance;
  69. }
  70. public static function UpdateBalance($Username, $totalBalance)
  71. {
  72. $AccountBalance = self::where('Username', $Username)->first();
  73. if($AccountBalance)
  74. $AccountBalance->Real_Balance = $totalBalance;
  75. $AccountBalance->Bonus_Balance = 0;
  76. $AccountBalance->save();
  77. }
  78. public static function GETACCOUNTSPECIALCHARINNAME()
  79. {
  80. $accounts = self::get();
  81. $Data[] = [];
  82. foreach ($accounts as $key => $account) {
  83. if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $account->Username))
  84. {
  85. $Data[$key] = [
  86. 'Username' => $account->Username
  87. ];
  88. }
  89. }
  90. return $Data;
  91. }
  92. public static function CreateAccount($params)
  93. {
  94. $Account = new AccountInfo;
  95. $Account->Username = $params['Username'];
  96. $Account->Password = md5($params['Password']);
  97. $Account->UUID = $params['UUID'];
  98. $Account->RegisterIP = '127.0.0.1';
  99. $Account->RegisterTime = now();
  100. $Account->IsBlocked = 0;
  101. $Account->Real_Balance = 200000;
  102. $Account->Bonus_Balance = 0;
  103. //$Account->BirthDate = now();
  104. $Account->Email = 'teste@teste.com.br';
  105. //$Account->AccountType = 0;
  106. //$Account->AccountRecoverCode = '123456';
  107. //$Account->IsActivated = 0;
  108. //$Account->RegFont = 'quenio';
  109. $Account->Permission = 0;
  110. $Account->save();
  111. }
  112. }