| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- namespace App\Models\Login;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- use App\Helpers\Functions;
- use App\Models\Login\GameVersion;
- class AccountInfo extends Model
- {
- protected $connection = "Login";
- protected $table = "AccountInfo";
- protected $primaryKey = "AccountDBID";
- protected $dates = [];
- protected $fillable = ["Username", "Password", "UUID","RegisterTime", "RegisterIP",
- "LastLoginTime","LastLoginIP","IsBlocked","Real_Balance","Bonus_Balance",
- "Permission","UserAge","MakeCodeNo","Email","Real_CERPass"
-
- ];
- protected $hidden = [
- 'Password',
- 'UUID',
- 'Permission',
- 'MakeCodeNo'
- ];
- public $timestamps = false;
- public function antihacklogcontrol(){
- return $this->hasMany('App\Models\Web\AntihackLogControl','AccountDBID');
- }
- public static function LoginAccount($params)
- {
- $AccountData = self::where('Username', $params['Username'])->first();
- if(!$AccountData){
- return ['code' => -1, 'msg' => 'Ez a fiók nem létezik!' ];
- }else if($AccountData->Username == $params['Username'] && $AccountData->Password != md5($params['Password'])){
- return ['code' => -2, 'msg' => 'Hibás jelszó!' ];
- }
- if($AccountData->IsBlocked == 1)
- return ['code' => -3, 'msg' => 'Letiltott fiók!' ];
- //if($AccountData->IsActivated == 0)
- //return ['code' => -4, 'msg' => 'Conta não ativada!' ];
- //$GameVersion = GameVersion::first();
- //if($GameVersion->IsMaintenance == 1 && $AccountData->Permission == 0)
- //return ['code' => -5, 'msg' => 'Servidor em manutenção!' ];
- $UUID = vsprintf('%s%s-%s-4000-8%.3s-%s%s%s0',str_split(dechex( microtime(true) * 1000 ) . bin2hex( random_bytes(8) ),4));
- $AccountData->UUID = $UUID;
- $AccountData->LastLoginIP = Functions::getIp();
- $AccountData->LastLoginTime = now();
- $AccountData->save();
- //$AccountData->Version = $GameVersion->Version;
- return [
- 'code' => 0,
- 'msg' => 'Siker!',
- 'token' => $UUID,
- 'accountinfo' => $AccountData
- ];
- }
- public static function UpdateUUID($UUID)
- {
- $AccountData = self::where('UUID', $UUID)->first();
- $AccountData->UUID = "";
- $AccountData->save();
- }
- public static function GetBalance($Username)
- {
- $totalBalance = 0;
- $AccountBalance = self::where('Username', $Username)->first();
- if($AccountBalance){
- $totalBalance = $AccountBalance->Real_Balance + $AccountBalance->Bonus_Balance;
- }
- return $totalBalance;
- }
- public static function UpdateBalance($Username, $totalBalance)
- {
- $AccountBalance = self::where('Username', $Username)->first();
- if($AccountBalance)
- $AccountBalance->Real_Balance = $totalBalance;
- $AccountBalance->Bonus_Balance = 0;
- $AccountBalance->save();
- }
- public static function GETACCOUNTSPECIALCHARINNAME()
- {
- $accounts = self::get();
- $Data[] = [];
- foreach ($accounts as $key => $account) {
- if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $account->Username))
- {
- $Data[$key] = [
- 'Username' => $account->Username
- ];
- }
- }
- return $Data;
- }
- public static function CreateAccount($params)
- {
- $Account = new AccountInfo;
- $Account->Username = $params['Username'];
- $Account->Password = md5($params['Password']);
- $Account->UUID = $params['UUID'];
- $Account->RegisterIP = '127.0.0.1';
- $Account->RegisterTime = now();
- $Account->IsBlocked = 0;
- $Account->Real_Balance = 200000;
- $Account->Bonus_Balance = 0;
- //$Account->BirthDate = now();
- $Account->Email = 'teste@teste.com.br';
- //$Account->AccountType = 0;
- //$Account->AccountRecoverCode = '123456';
- //$Account->IsActivated = 0;
- //$Account->RegFont = 'quenio';
- $Account->Permission = 0;
- $Account->save();
- }
- }
|