├── .github └── FUNDING.yml ├── .poggit.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── ServerAuth ├── plugin.yml ├── resources │ ├── config.yml │ └── languages │ │ ├── CZ_cz.yml │ │ ├── EN_en.yml │ │ ├── ES_es.yml │ │ ├── IT_it.yml │ │ ├── NL_nl.yml │ │ ├── PT_br.yml │ │ ├── RU_ru.yml │ │ ├── TR_tr.yml │ │ └── ja_JP.yml └── src │ └── ServerAuth │ ├── Commands │ ├── ChangePassword.php │ ├── Commands.php │ ├── Login.php │ ├── Logout.php │ ├── Register.php │ ├── ServerAuthCommand.php │ ├── ServerAuthCommandHandler.php │ └── Unregister.php │ ├── EventListener.php │ ├── Events │ ├── ServerAuthAuthenticateEvent.php │ ├── ServerAuthChangePasswordEvent.php │ ├── ServerAuthDeauthenticateEvent.php │ ├── ServerAuthEvent.php │ ├── ServerAuthLoadPluginEvent.php │ ├── ServerAuthRegisterEvent.php │ └── ServerAuthUnregisterEvent.php │ ├── HashAlgs │ ├── DefaultHash.php │ ├── DefaultHashSalted.php │ ├── HashAlg.php │ └── SimpleAuthHash.php │ ├── Importers │ ├── HereAuthJSONImporter.php │ ├── HereAuthMySQLImporter.php │ ├── Importer.php │ ├── ServerAuthMySQLImporter.php │ ├── ServerAuthSQLiteImporter.php │ ├── ServerAuthYAMLImporter.php │ ├── SimpleAuthMySQLImporter.php │ ├── SimpleAuthSQLiteImporter.php │ └── SimpleAuthYAMLImporter.php │ ├── Providers │ ├── MySQLProvider.php │ ├── Provider.php │ ├── SQLiteProvider.php │ └── YAMLProvider.php │ ├── ServerAuth.php │ └── Tasks │ ├── MessageTask.php │ └── MySQLTask.php ├── ServerAuthAccountManager ├── ServerAuthWebAPI.php ├── account.php ├── admin.php ├── config.php ├── css │ ├── font-awesome.css │ ├── font-awesome.min.css │ ├── xweb.css │ └── xweb.min.css ├── fonts │ ├── fontawesome-webfont.eot │ ├── fontawesome-webfont.svg │ ├── fontawesome-webfont.ttf │ └── fontawesome-webfont.woff ├── index.php ├── js │ ├── jquery.min.js │ ├── xweb.js │ └── xweb.min.js ├── login.php └── register.php └── ServerAuthWebAPI └── ServerAuthWebAPI.php /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: "https://paypal.me/Flavius12" 2 | -------------------------------------------------------------------------------- /.poggit.yml: -------------------------------------------------------------------------------- 1 | --- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/EvolSoft/ServerAuth 2 | branches: 3 | - master 4 | projects: 5 | ServerAuth: 6 | path: ServerAuth/ 7 | ... 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ![start2](https://cloud.githubusercontent.com/assets/10303538/6315586/9463fa5c-ba06-11e4-8f30-ce7d8219c27d.png) 2 | 3 | # Contributing to ServerAuth 4 | 5 | First of all thank you to contribute and help us to improve our projects. 6 | 7 | ## Issues 8 | 9 | If you want to report bugs or suggestions use the [Issue Tracker](https://github.com/EvolSoft/ServerAuth/issues) 10 | 11 | - Please **don't** duplicate issues. Do a small search on current issues before report yours 12 | - Please provide as more detailed informations as you can about the issue 13 | - Please **don't** post issues related to unofficial source code 14 | - Please **don't** post fake or support issues 15 | - Please write in English 16 | 17 | ## Code contributions 18 | 19 | If you want to contribute on code simply do a [Pull Request](https://github.com/EvolSoft/ServerAuth/pull/new). Before doing this **be sure** that: 20 | - The code is correct, clear and written in English 21 | - You provided a good and descriptive title 22 | - The Pull Request doesn't already exist 23 | 24 | ## Translation contributions 25 | 26 | If you want to contribute on translations make a [Pull Request](https://github.com/EvolSoft/ServerAuth/pull/new). 27 | 28 | Remember that your translation file **must** follow the default ServerAuth language file structure 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 EvolSoft 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![start2](https://cloud.githubusercontent.com/assets/10303538/6315586/9463fa5c-ba06-11e4-8f30-ce7d8219c27d.png) 2 | 3 | **THE PLUGIN IS NOT READY TO BE USED YET. IT HAS NOT BEEN TESTED CAREFULLY AND IT STILL CONTAINS LOTS OF BUGS! PLEASE WAIT THE OFFICIAL RELEASE ON POGGIT!** 4 | 5 | # ServerAuth 6 | 7 | [![Join the chat at https://gitter.im/EvolSoft/ServerAuth](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/EvolSoft/ServerAuth?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 8 | 9 | An advanced authentication plugin for PocketMine 10 | 11 | [![Download!](https://user-images.githubusercontent.com/10297075/101246002-cb046780-3710-11eb-950f-ba06934b8138.png)](http://gestyy.com/er3ftX) 12 | 13 | ## Category 14 | 15 | PocketMine-MP plugins, PHP Web scripts 16 | 17 | ## Requirements 18 | 19 | [PocketMine-MP](https://github.com/pmmp/PocketMine-MP) API 3.0.0-ALPHA7 - 3.0.0-ALPHA8
20 | PHP >= 5.4.0 *(for ServerAuthAccountManager)*
21 | PHP MySQLi extension
22 | 23 | ## Overview 24 | 25 | **ServerAuth** is the most advanced authentication system for PocketMine-MP. 26 | 27 | ***This Plugin uses the New API. You can't install it on old versions of PocketMine.*** 28 | 29 | ***To prevent bugs, delete all old plugin data if you are updating ServerAuth.*** 30 | 31 | ***WARNING: If you're updating from old versions of ServerAuth to ServerAuth v2.12 or newer you MAY NEED to delete the current language folder!!!*** 32 | 33 | ***Features:*** 34 | 35 | - MySQL support 36 | - Multi-language support 37 | - Web API 38 | - Online Account Manager 39 | - IP Sessions 40 | - /register, /unregister, /login, /logout and /changepassword commands 41 | 42 | And more... 43 | 44 | **What is included?** 45 | 46 | In the ZIP file you will find:
47 | *- ServerAuth_v2.13.phar : ServerAuth Plugin + API*
48 | *- ServerAuthAccountManager : An advanced online script to manage ServerAuth accounts*
49 | *- ServerAuthWebAPI : ServerAuth Web API to use on your own web scripts*
50 | 51 | **Commands:** 52 | 53 | ***/serverauth*** *- ServerAuth commands (aliases: [sa, sauth, auth])*
54 | ***/register*** *- Allows registering an account (aliases: [reg])*
55 | ***/login*** *- Allows logging into an account*
56 | ***/changepassword*** *- Allows changing account password (aliases: [ch, chp, chpass])*
57 | ***/unregister*** *- Allows unregistering an account*
58 | ***/logout*** *- Allows to do the log out* 59 | 60 | ***To-Do:*** 61 | 62 |
- Bug fix (if bugs will be found)
63 | 64 | ## Documentation 65 | 66 | Documentation available at [ServerAuth Wiki](https://github.com/EvolSoft/ServerAuth/wiki) 67 | 68 | ## Download 69 | 70 | You can download precompiled versions of ServerAuth on [ServerAuth Releases](https://github.com/EvolSoft/ServerAuth/releases) section 71 | 72 | ## Extensions 73 | 74 | [EvolSoft/ChatLogin](https://github.com/EvolSoft/ChatLogin): A ServerAuth extension to do login/register directly on chat 75 | 76 | [EvolSoft/InvisibleLogin](https://github.com/EvolSoft/InvisibleLogin): A ServerAuth extension to make players invisible when they are not authenticated 77 | 78 | [EvolSoft/EmailConfirm](https://github.com/EvolSoft/EmailConfirm): A ServerAuth extension which implements email confirmation when registering ServerAuth accounts 79 | 80 |
If you want to submit your own ServerAuth Extension PM us on Twitter @Flavius12_ or @_EvolSoft or ask in ServerAuth Gitter Channel
81 | 82 | ## Contributing 83 | 84 | If you want to contribute to this project please follow the [Contribution Guidelines](https://github.com/EvolSoft/ServerAuth/blob/master/CONTRIBUTING.md) 85 | -------------------------------------------------------------------------------- /ServerAuth/plugin.yml: -------------------------------------------------------------------------------- 1 | name: ServerAuth 2 | main: ServerAuth\ServerAuth 3 | version: 3.0 4 | api: [3.0.0, 4.0.0] 5 | load: STARTUP 6 | author: EvolSoft 7 | description: The most advanced authentication plugin for PocketMine-MP. 8 | website: https://www.evolsoft.tk 9 | commands: 10 | serverauth: 11 | aliases: [sa, sauth, auth] 12 | description: ServerAuth Commands. 13 | permission: serverauth 14 | register: 15 | aliases: [reg] 16 | description: Allows registering an account 17 | permission: serverauth.register 18 | login: 19 | description: Allows logging into an account 20 | permission: serverauth.login 21 | changepassword: 22 | aliases: [ch, chp, chpass] 23 | description: Allows changing account password 24 | permission: serverauth.changepassword 25 | unregister: 26 | description: Allows unregistering an account 27 | permission: serverauth.unregister 28 | logout: 29 | description: Allows to do the log out 30 | permission: serverauth.logout 31 | permissions: 32 | serverauth: 33 | default: op 34 | description: ServerAuth commands permissions. 35 | children: 36 | serverauth.help: 37 | default: true 38 | description: Allows player to show ServerAuth help. 39 | serverauth.info: 40 | default: op 41 | description: Allows player to read info about ServerAuth. 42 | serverauth.reload: 43 | default: op 44 | description: Allows player to reload ServerAuth. 45 | serverauth.register: 46 | default: true 47 | description: Allows registering an account. 48 | serverauth.login: 49 | default: true 50 | description: Allows logging into an account. 51 | serverauth.changepassword: 52 | default: true 53 | description: Allows changing account password. 54 | serverauth.unregister: 55 | default: true 56 | description: Allows unregistering an account. 57 | serverauth.logout: 58 | default: true 59 | description: Allows logging out an account. 60 | -------------------------------------------------------------------------------- /ServerAuth/resources/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Keep logged in by IP 3 | ip-login: false 4 | # Use UUID for authentication 5 | uuid-login: false 6 | # Force single authentication 7 | force-single-auth: true 8 | # Allow not authenticated users to move 9 | allow-move: false 10 | # Block chat for not authenticated users 11 | block-chat: true 12 | # Block commands for not authenticated users 13 | block-commands: true 14 | # Block all events 15 | block-all-events: true 16 | # Login/Register timeout 17 | timeout: 60 18 | # Minimum password length 19 | min-password: 6 20 | # Maximum password length 21 | max-password: 16 22 | # Password hash algorithm 23 | password-hash: 24 | # Password hash algorithm name 25 | # serverauth: basic ServerAuth hash algorithm 26 | # serverauth_salted: ServerAuth hash algorithm with salt 27 | # simpleauth: SimpleAuth default hash algorithm 28 | algorithm: "serverauth_salted" 29 | # Optional parameters for hash algorithm (may change according to the selected algorithm) 30 | # Default parameters are valid for both serverauth and serverauth_salted algorithms 31 | parameters: 32 | hash: "sha256" 33 | multi-hash: "md5" 34 | # ServerAuth language 35 | language: "EN_en" 36 | # ServerAuth message prefix 37 | prefix: "&1[ServerAuth] " 38 | # Show join message (defined on join-message in the current language file) 39 | show-join-message: true 40 | # Data provider 41 | data-provider: yaml 42 | # Data cache timeout (0 disables this feature) 43 | data-cache-timeout: 60 44 | # Max cached players (0 for unlimited) 45 | max-cached-players: 100 46 | #Login settings 47 | login: 48 | #Enable login on your server 49 | enabled: true 50 | #Enable failed logins kick 51 | enable-failed-logins-kick: true 52 | #Max number of attempts 53 | max-attempts: 5 54 | #Login message interval 55 | message-interval: 4 56 | #Register settings 57 | register: 58 | #Enable register on your server 59 | enabled: true 60 | #Require password confirmation 61 | confirm-required: false 62 | #Enable max registrations per IP 63 | enable-max-ip: false 64 | #Max registrations per IP (0 to disable this feature) 65 | max-ip: 3 66 | # Log multiple accounts to OPs 67 | log-multiple-accounts: true 68 | #Register message interval 69 | message-interval: 4 70 | #Change Password settings 71 | changepassword: 72 | #Enable changepassword on your server 73 | enabled: true 74 | #Require password confirmation 75 | confirm-required: true 76 | #Logout settings 77 | logout: 78 | #Enable logout on your server 79 | enabled: true 80 | #Unregister settings 81 | unregister: 82 | #Enable unregister on your server 83 | enabled: true 84 | #Require password confirmation 85 | require-password: true 86 | ... -------------------------------------------------------------------------------- /ServerAuth/resources/languages/CZ_cz.yml: -------------------------------------------------------------------------------- 1 | #ServerAuth plugin Czech language file 2 | #Translation by PikyCZ 3 | --- 4 | join-message: "&bPrihlasovaci system &aServerAuth" 5 | single-auth: "&cHrac s toutou prezdivkou je jiz prihlasen!" 6 | mysql-success: "&aServerAuth se uspesne pripojil k databazi MySQL!" 7 | mysql-restored: "&aMySQL spojeni obnoveno!" 8 | mysql-fail: "&cServerAuth se nemuze pripojit k databazi MySQL. Data budou ulozeny lokalne. Error: {MYSQL_ERROR}" 9 | config-reloaded: "&aKonfigurace resetovana!" 10 | operation-cancelled: "&cOperace byla zrusena" 11 | login: 12 | message: "&cProsim prihlas se /login " 13 | disabled: "&cPrihlaseni je zakazana na tomto serveru" 14 | command: "&cPouzij: /login " 15 | ip-login: "&9Prihlasils se pomoci IP" 16 | login-success: "&aJsi prihlasen!" 17 | login-timeout: "&cPlatnost prihlaseni vyprsela" 18 | already-login: "&aUz jste prihlasen" 19 | too-many-attempts: "&cPrilis mnoho pokusu o prihlaseni!" 20 | register: 21 | message: "&cZaregistruj se /register " 22 | message-conf: "&cProsim registruj se /register " 23 | disabled: "&cRegistrace je zakazana na tomto serveru" 24 | command: "&cPouzij: /register " 25 | command-conf: "&cPouzij: /register " 26 | register-success: "&aUspesne jsi zaregistrovany!" 27 | register-timeout: "&cVyprsel cas na registraci!" 28 | already-registered: "&aUz jsi zaregistrovany!" 29 | changepassword: 30 | disabled: "&cZmena hesla je zakazana na tomto serveru" 31 | login-required: "&cMusis byt prihlasen ke zmene hesla" 32 | command: "&cPouzij: /changepassword " 33 | command-conf: "&cPouzij: /changepassword " 34 | command-cons: "&cPouzij: /changepassword " 35 | changepassword-success: "&aHeslo zmeneno!" 36 | changepassword-cons-success: "&aHeslo pro &b{PLAYER} &abylo zmeneno na &b{PASSWORD}" 37 | logout: 38 | disabled: "&cOdhlaseny je zakazano na tomto serveru!" 39 | logout-success: "&aUz jsi odhlasen!" 40 | unregister: 41 | disabled: "&cZruseni registrace je zakazana na tomto serveru!" 42 | login-required: "&cMusite byt prihlasen k zruseni registrace" 43 | command: "&cPouzij: /unregister " 44 | command-cons: "&cPouzij: /unregister " 45 | unregister-success: "&aNyni jiz nemas ucet!" 46 | unregister-success-3rd: "&aHrac jiz nini nema ucet!" 47 | help: 48 | 1: "&b=> &aDostupne prikazy &b<=" 49 | 2: "&a/changepassword &b=>&a Zmeni heslo uctu" 50 | 3: "&a/login &b=>&a prihlaseni" 51 | 4: "&a/logout &b=>&a odhlaseni" 52 | 5: "&a/register &b=>&a Registrace uctu" 53 | 6: "&a/serverauth help &b=>&a Ukaze napovedu pro tento plugin" 54 | 7: "&a/serverauth info &b=>&a Ukaze info o tomto pluginu" 55 | 8: "&a/serverauth reload &b=>&a Resetuje config" 56 | 9: "&a/unregister &b=>&a Smaze ucet" 57 | error: "&cSubcommand &a{SUBCMD} &cnebylo nalezeno. Pouzij &a/serverauth help &cukaze dostupne prikazy" 58 | errors: 59 | generic: "&cDoslo k chybe" 60 | wrong-password: "&cSpatne heslo" 61 | password-no-match: "&cHeslo se neshoduje s potvrzenim" 62 | password-too-short: "&cHeslo je prilis kratke" 63 | password-too-long: "&cHeslo je prilis dlouhe" 64 | user-not-registered: "&cNejsi zaregistrovany" 65 | user-not-registered-3rd: "&cHrac neni registrovan" 66 | user-not-authenticated: "&cNejsi prihlasen!" 67 | max-ip-reached: "&cDosahl jsi maximalniho poctu registraci na jednu IP" 68 | no-permissions: "&cNemas oprávneni k pouziti tohoto ptikazu" 69 | player-only: "&cMuzete provest tento prikaz jako hrac" 70 | ... 71 | -------------------------------------------------------------------------------- /ServerAuth/resources/languages/EN_en.yml: -------------------------------------------------------------------------------- 1 | #ServerAuth plugin English language file 2 | #Translation by Flavius12 3 | --- 4 | join-message: "&bAuthentication system provided by &aServerAuth &bplugin." 5 | single-auth: "&cA player with this username is already authenticated!" 6 | mysql-success: "&aServerAuth successfully connected to the MySQL database!" 7 | mysql-restored: "&aMySQL connection restored!" 8 | config-reloaded: "&aConfiguration reloaded!" 9 | operation-cancelled: "&cOperation cancelled." 10 | login: 11 | message: "&cPlease login with /login " 12 | disabled: "&cLogin is disabled on this server." 13 | command: "&cUsage: /login " 14 | ip-login: "&9You have been authenticated by IP." 15 | uuid-login: "&9You have been authenticated by UUID." 16 | login-success: "&aYou have been authenticated!" 17 | login-timeout: "&cLogin timeout." 18 | already-login: "&aYou are already logged in." 19 | too-many-attempts: "&cToo many login attempts!" 20 | register: 21 | message: "&cPlease register with /register " 22 | message-conf: "&cPlease register with /register " 23 | disabled: "&cRegister disabled on this server." 24 | command: "&cUsage: /register " 25 | command-conf: "&cUsage: /register " 26 | register-success: "&aYour account has been registered!" 27 | register-timeout: "&cRegister timeout." 28 | already-registered: "&aYou are already registered." 29 | changepassword: 30 | disabled: "&cChange password disabled on this server." 31 | login-required: "&cYou must be authenticated to change your password." 32 | command: "&cUsage: /changepassword " 33 | command-conf: "&cUsage: /changepassword " 34 | command-cons: "&cUsage: /changepassword " 35 | changepassword-success: "&aPassword changed!" 36 | changepassword-cons-success: "&aPassword for user &b{PLAYER} &achanged to &b{PASSWORD}" 37 | logout: 38 | disabled: "&cLogout disabled on this server." 39 | logout-success: "&bYou have been logged out." 40 | unregister: 41 | disabled: "&cUnregister disabled on this server." 42 | login-required: "&cYou must be authenticated to unregister." 43 | command: "&cUsage: /unregister " 44 | command-cons: "&cUsage: /unregister " 45 | unregister-success: "&bYour account has been unregistered." 46 | unregister-success-3rd: "&aThe player's account has been unregistered!" 47 | importers: 48 | same-provider: "&cYou can't import data from the same provider" 49 | init-import: "&aImporting data..." 50 | data-not-found: "&cAccount data of {PLUGIN} plugin not found!" 51 | data-invalid: "&cInvalid {PLUGIN} account data." 52 | db-usage-basic: "&cUsage: /serverauth import {ID} [password] [port]" 53 | db-usage-advanced: "&cUsage: /serverauth import {ID} [password] [table_prefix] [port]" 54 | yaml: "&aSuccessfully imported {COUNT} profiles from {PLUGIN} yaml files to {PROVIDER}!" 55 | json: "&aSuccessfully imported {COUNT} profiles from {PLUGIN} json files to {PROVIDER}!" 56 | mysql: "&aSuccessfully imported {COUNT} profiles from {PLUGIN} mysql database to {PROVIDER}!" 57 | sqlite: "&aSuccessfully imported {COUNT} profiles from {PLUGIN} sqlite database to {PROVIDER}!" 58 | help: 59 | 1: "&b=> &aAvailable Commands &b<=" 60 | 2: "&a/changepassword &b=>&a Change the account password" 61 | 3: "&a/login &b=>&a Do login" 62 | 4: "&a/logout &b=>&a Do logout" 63 | 5: "&a/register &b=>&a Register an account" 64 | 6: "&a/serverauth help &b=>&a Show help about this plugin" 65 | 7: "&a/serverauth info &b=>&a Show info about this plugin" 66 | 8: "&a/serverauth import &b=>&a Import account data from other ServerAuth data providers or from other auth plugins" 67 | 9: "&a/serverauth reload &b=>&a Reload the config" 68 | 10: "&a/unregister &b=>&a Unregister your account" 69 | invalid: "&cSubcommand &a{SUBCMD} &cnot found. Use &a/serverauth help &cto show available commands" 70 | errors: 71 | generic: "&cAn error has occurred." 72 | provider-error: "&eAn error has occurred while initializing the specified data provider. YAML default data provider set." 73 | mysql-connect-error: "&cFailed to connect to MySQL database: {ERROR}" 74 | mysql-database-error: "&cFailed to create ServerAuth database into MySQL database!" 75 | mysql-query-error: "&cMySQL query failed." 76 | mysql-tables-error: "&cFailed to create ServerAuth tables into MySQL database!" 77 | sqlite-open-error: "&cFailed to open SQLite3 database: {ERROR}" 78 | sqlite-query-error: "&cSQLite3 query failed." 79 | sqlite-tables-error: "&cFailed to create ServerAuth tables into SQLite3 database!" 80 | invalid-hash-algorithm: "&eInvalid hash algorithm specified! ServerAuth salted algorithm set." 81 | invalid-provider: "&eInvalid data provider specified! YAML default data provider set." 82 | invalid-uuid: "&cYour UUID is invalid!" 83 | wrong-password: "&cWrong Password." 84 | password-no-match: "&cPassword doesn't match confirmation." 85 | password-too-short: "&cPassword too short." 86 | password-too-long: "&cPassword too long." 87 | user-not-registered: "&cYou are not registered." 88 | user-not-registered-3rd: "&cThe player isn't registered." 89 | user-not-authenticated: "&cYou are not authenticated." 90 | max-ip-reached: "&cYou reached the maximum number of registrations per IP address." 91 | no-permissions: "&cYou don't have permissions to use this command." 92 | player-only: "&cYou can only perform this command as a player." 93 | ... 94 | -------------------------------------------------------------------------------- /ServerAuth/resources/languages/ES_es.yml: -------------------------------------------------------------------------------- 1 | #ServerAuth plugin Spanish language file 2 | #Translation by TonyDroidd 3 | --- 4 | join-message: "&bSistema de autenticación proporcionado por &aServerAuth &bplugin" 5 | single-auth: "&cA player with this nickname is already authenticated!" 6 | mysql-success: "&aServerAuth successfully connected to the MySQL database!" 7 | mysql-restored: "&aMySQL connection restored!" 8 | mysql-fail: "&cServerAuth can't connect to the MySQL database. Data will be saved locally. Error: {MYSQL_ERROR}" 9 | config-reloaded: "&aConfiguration reloaded!" 10 | operation-cancelled: "&cOperation cancelled" 11 | login: 12 | message: "&cPor favor, inicia sesion usando /login " 13 | disabled: "&cAutenticacion esta desactivada en este servidor" 14 | command: "&cIntenta usando: /login " 15 | ip-login: "&9Haz iniciado sesion con tu IP." 16 | login-success: "&aHaz iniciado sesion!" 17 | login-timeout: "&cEl tiempo de autenticacion ha expirado!" 18 | already-login: "&aYa haz iniciado sesión!" 19 | too-many-attempts: "&cDemasiados intentos de acceso!" 20 | register: 21 | message: "&cPor favor, registrate usando /register " 22 | message-conf: "&cPor favor, registrate con /register " 23 | disabled: "&cLa registracion esta desactivada en este servidor!" 24 | command: "&cIntenta usandoe: /register " 25 | command-conf: "&cUsa: /register " 26 | register-success: "&aTe haz registrado correctamente!!" 27 | register-timeout: "&cHaz excedido el limite de tiempo!" 28 | already-registered: "&aYa estás registrado!" 29 | changepassword: 30 | disabled: "&cCambio de contraseña está desactivado en este servidor" 31 | login-required: "&cNecesitas iniciar sesion para cambiar tu contraseña" 32 | command: "&cUsa el comando: /changepassword " 33 | command-conf: "&cUsa: /changepassword " 34 | command-cons: "&cUsage: /changepassword " 35 | changepassword-success: "&aContraseña cambiada correctamente!" 36 | changepassword-cons-success: "&aPassword for user &b{PLAYER} &achanged to &b{PASSWORD}" 37 | logout: 38 | disabled: "&cCerrar sesion esta desactivado en este servidor!" 39 | logout-success: "&aYa haz cerrado sesion" 40 | unregister: 41 | disabled: "&cNo tienes permisos de desregistrarte" 42 | login-required: "&cNecesitas iniciar sesion para desregistrarte" 43 | command: "&cUsa: /unregister " 44 | command-cons: "&cUsage: /unregister " 45 | unregister-success: "&aTe haz desregistrado!" 46 | unregister-success-3rd: "&aThe player is now unregistered!" 47 | help: 48 | 1: "&b=> &aAvailable Commands &b<=" 49 | 2: "&a/changepassword &b=>&a Change the account password" 50 | 3: "&a/login &b=>&a Do login" 51 | 4: "&a/logout &b=>&a Do logout" 52 | 5: "&a/register &b=>&a Register an account" 53 | 6: "&a/serverauth help &b=>&a Show help about this plugin" 54 | 7: "&a/serverauth info &b=>&a Show info about this plugin" 55 | 8: "&a/serverauth reload &b=>&a Reload the config" 56 | 9: "&a/unregister &b=>&a Unregister your account" 57 | error: "&cSubcommand &a{SUBCMD} &cnot found. Use &a/serverauth help &cto show available commands" 58 | errors: 59 | generic: "&cHa ocurrido un error desconocido!" 60 | wrong-password: "&cLa contraseña incorrecta" 61 | password-no-match: "&cLas contraseñas no coinciden" 62 | password-too-short: "&cLa contraseña es muy corta" 63 | password-too-long: "&cLa contraseña es muy larga!" 64 | user-not-registered: "&cNo estas registrado en este servidor" 65 | user-not-registered-3rd: "&cThe player isn't registered" 66 | user-not-authenticated: "&cNo haz iniciado sesion!" 67 | max-ip-reached: "&cHas alcanzado el número máximo de inscripciones para ip" 68 | no-permissions: "&cYou don't have permissions to use this command" 69 | player-only: "&cYou can only perform this command as a player" 70 | ... -------------------------------------------------------------------------------- /ServerAuth/resources/languages/IT_it.yml: -------------------------------------------------------------------------------- 1 | #ServerAuth plugin Italian language file 2 | #Translation by Flavius12, EvolSoft 3 | --- 4 | join-message: "&bSistema di autenticazione fornito da &aServerAuth" 5 | single-auth: "&cUn player con questo nickname è già autenticato!" 6 | mysql-success: "&aServerAuth connesso al database MySQL con successo!" 7 | mysql-restored: "&aConnessione MySQL ripristinata!" 8 | mysql-fail: "&cServerAuth non è riuscito a connettersi al database MySQL. I dati verranno salvati localmente. Errore: {MYSQL_ERROR}" 9 | config-reloaded: "&aConfigurazione ricaricata!" 10 | operation-cancelled: "&cOperazione cancellata" 11 | login: 12 | message: "&cEsegui il login con /login " 13 | disabled: "&cIl login è disabilitato in questo server" 14 | command: "&cUso: /login " 15 | ip-login: "&9Sei autenticato per IP" 16 | login-success: "&aHai eseguito il login!" 17 | login-timeout: "&cTempo di login scaduto" 18 | already-login: "&aSei già autenticato" 19 | too-many-attempts: "&cTroppi tentativi di login!" 20 | register: 21 | message: "&cRegistrati con /register " 22 | message-conf: "&cRegistrati con /register " 23 | disabled: "&cLa registrazione è disabilitata in questo server" 24 | command: "&cUso: /register " 25 | command-conf: "&cUso: /register " 26 | register-success: "&aOra sei registrato!" 27 | register-timeout: "&cTempo di registrazione scaduto" 28 | already-registered: "&aSei già registrato" 29 | changepassword: 30 | disabled: "&cIl cambio password è disabilitato in questo server" 31 | login-required: "&cDevi essere autenticato per cambiare la password" 32 | command: "&cUso: /changepassword " 33 | command-conf: "&cUso: /changepassword " 34 | command-cons: "&cUso: /changepassword " 35 | changepassword-success: "&aPassword cambiata!" 36 | changepassword-console-success: "&aLa password per l'utente &b{PLAYER} &aé stata cambiata in &b{PASSWORD}" 37 | logout: 38 | disabled: "&cIl logout è disabilitato in questo server" 39 | logout-success: "&aHai eseguito il logout" 40 | unregister: 41 | disabled: "&cLa cancellazione dell'account è disabilitata in questo server" 42 | login-required: "&cDevi essere autenticato per cancellare l'account" 43 | command: "&cUso: /unregister " 44 | command-cons: "&cUso: /unregister " 45 | unregister-success: "&aIl tuo account è stato cancellato!" 46 | unregister-success-3rd: "&aL'account del player è stato cancellato!" 47 | help: 48 | 1: "&b=> &aComandi disponibili &b<=" 49 | 2: "&a/changepassword &b=>&a Cambia la password dell'account" 50 | 3: "&a/login &b=>&a Esegui il login" 51 | 4: "&a/logout &b=>&a Esegui il logout" 52 | 5: "&a/register &b=>&a Registra un account" 53 | 6: "&a/serverauth help &b=>&a Visualizza l'aiuto circa questo plugin" 54 | 7: "&a/serverauth info &b=>&a Visualizza le informazioni su questo plugin" 55 | 8: "&a/serverauth reload &b=>&a Ricarica la configurazione" 56 | 9: "&a/unregister &b=>&a Cancella il tuo account" 57 | error: "&cSottocomando &a{SUBCMD} &cnon trovato. Usa &a/serverauth help &per visualizzare i comandi disponibili" 58 | errors: 59 | generic: "&cSi è verificato un errore" 60 | wrong-password: "&cPassword errata" 61 | password-no-match: "&cLe password non corrispondono" 62 | password-too-short: "&cLa password è troppo corta" 63 | password-too-long: "&cLa password è troppo lunga" 64 | user-not-registered: "&cNon sei registrato" 65 | user-not-registered-3rd: "&cIl player non è registrato" 66 | user-not-authenticated: "&cNon sei autenticato" 67 | max-ip-reached: "&cHai raggiunto il numero massimo di registrazioni per IP" 68 | no-permissions: "&cNon hai i permessi per usare questo comando" 69 | player-only: "&cPuoi eseguire questo comando solo come player" 70 | ... -------------------------------------------------------------------------------- /ServerAuth/resources/languages/NL_nl.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EvolSoft/ServerAuth/7c07b43808727ec7fc7839f88c6413b0ed2a304c/ServerAuth/resources/languages/NL_nl.yml -------------------------------------------------------------------------------- /ServerAuth/resources/languages/PT_br.yml: -------------------------------------------------------------------------------- 1 | #ServerAuth plugin Portuguese language file 2 | #Translation by DeekInPlay 3 | --- 4 | join-message: "&bSistema de autenticação fornecido pelo plugin &aServerAuth&b." 5 | single-auth: "&cUm jogador com esse nome de usuário já está autenticado!" 6 | mysql-success: "&aServerAuth conectado com sucesso ao banco de dados MySQL!" 7 | mysql-restored: "&aConexão MySQL restaurada!" 8 | config-reloaded: "&aConfiguração recarregada!" 9 | operation-cancelled: "&cOperação cancelada." 10 | login: 11 | message: "&cPor favor, faça o login com /login " 12 | disabled: "&cO login está desativado neste servidor." 13 | command: "&cUso: /login " 14 | ip-login: "&9Você foi autenticado por IP." 15 | uuid-login: "&9Você foi autenticado pelo UUID." 16 | login-success: "&aVocê foi autenticado!" 17 | login-timeout: "&cTempo limite de login esgotado." 18 | already-login: "&aVocê já está logado." 19 | too-many-attempts: "&cMuitas tentativas de login!" 20 | register: 21 | message: "&cPor favor, registre-se com /register " 22 | message-conf: "&cPor favor, registre--se com /register " 23 | disabled: "&cRegistro desativado neste servidor." 24 | command: "&cUso: /register " 25 | command-conf: "&cUso: /register " 26 | register-success: "&aSua conta foi registrada!" 27 | register-timeout: "&cTempo limite de registro esgotado." 28 | already-registered: "&aVocê já está registrado." 29 | changepassword: 30 | disabled: "&cAlteração de senha desabilitada neste servidor." 31 | login-required: "&cVocê deve estar autenticado para alterar sua senha." 32 | command: "&cUso: /changepassword " 33 | command-conf: "&cUso: /changepassword " 34 | command-cons: "&cUso: /changepassword " 35 | changepassword-success: "&aSenha alterada!" 36 | changepassword-cons-success: "&aA senha de &b{PLAYER} &afoi alterada para &b{PASSWORD}" 37 | logout: 38 | disabled: "&cLogout desativado neste servidor." 39 | logout-success: "&bVocê foi desconectado." 40 | unregister: 41 | disabled: "&cCancelar registro desativado neste servidor." 42 | login-required: "&cVocê deve estar autenticado para cancelar o registro." 43 | command: "&cUso: /unregister " 44 | command-cons: "&cUso: /unregister " 45 | unregister-success: "&bSeu registro foi apagado." 46 | unregister-success-3rd: "&aO registro do jogador foi apagado." 47 | importers: 48 | same-provider: "&cVocê não pode importar dados do mesmo provedor" 49 | init-import: "&aImportando dados..." 50 | data-not-found: "&cOs dados da conta do plugin {PLUGIN} não foram encontrados!" 51 | data-invalid: "&cDados da conta {PLUGIN} inválidos." 52 | db-usage-basic: "&cUso: /serverauth import {ID} [senha] [porta]" 53 | db-usage-advanced: "&cUso: /serverauth import {ID} [senha] [prefixo_tabela] [porta]" 54 | yaml: "&aImportado com sucesso {COUNT} perfis dos arquivos yaml {PLUGIN} para {PROVIDER}!" 55 | json: "&aImportado com sucesso {COUNT} perfis dos arquivos json {PLUGIN} para {PROVIDER}!" 56 | mysql: "&aImportado com sucesso {COUNT} perfis do banco de dados mysql {PLUGIN} para {PROVIDER}!" 57 | sqlite: "&aImportado com sucesso {COUNT} perfis do banco de dados sqlite {PLUGIN} para {PROVIDER}!" 58 | help: 59 | 1: "&b=> &aComandos Disponíveis &b<=" 60 | 2: "&a/changepassword &b=>&a Alterar a senha da conta" 61 | 3: "&a/login &b=>&a Faça login" 62 | 4: "&a/logout &b=>&a Fazer logout" 63 | 5: "&a/register &b=>&a Registre uma conta" 64 | 6: "&a/serverauth help &b=>&a Mostrar ajuda sobre este plugin" 65 | 7: "&a/serverauth info &b=>&a Mostrar informações sobre este plugin" 66 | 8: "&a/serverauth import &b=>&a Importar dados da conta de outros provedores de dados ServerAuth ou de outros plugins de autenticação" 67 | 9: "&a/serverauth reload &b=>&a Recarregar a configuração" 68 | 10: "&a/unregister &b=>&a Cancelar o registro da sua conta" 69 | invalid: "&cSubcomando &a{SUBCMD} &cnão encontrando. Use &a/serverauth help &cpara mostrar os comandos disponíveis" 70 | errors: 71 | generic: "&cOcorreu um erro." 72 | provider-error: "&eOcorreu um erro ao inicializar o provedor de dados especificado. Conjunto de provedor de dados padrão YAML." 73 | mysql-connect-error: "&cFalha ao conectar ao banco de dados MySQL: {ERROR}" 74 | mysql-database-error: "&cFalha ao criar o banco de dados ServerAuth no banco de dados MySQL!" 75 | mysql-query-error: "&cFalha na consulta do MySQL." 76 | mysql-tables-error: "&cFalha ao criar tabelas ServerAuth no banco de dados MySQL!" 77 | sqlite-open-error: "&cFalha ao abrir o banco de dados SQLite3: {ERROR}" 78 | sqlite-query-error: "&cFalha na consulta SQLite3." 79 | sqlite-tables-error: "&cFalha ao criar tabelas ServerAuth no banco de dados SQLite3!" 80 | invalid-hash-algorithm: "&eAlgoritmo de hash inválido! Conjunto de algoritmos salted ServerAuth." 81 | invalid-provider: "&eFornecedor de dados inválido! Conjunto de provedor de dados padrão YAML." 82 | invalid-uuid: "&cSeu UUID é inválido!" 83 | wrong-password: "&cSenha incorreta." 84 | password-no-match: "&cA senha não corresponde à confirmação." 85 | password-too-short: "&cSenha muito curta." 86 | password-too-long: "&cSenha muito longa." 87 | user-not-registered: "&cVocê não está registrado." 88 | user-not-registered-3rd: "&cO jogador não está registrado." 89 | user-not-authenticated: "&cVocê não está autenticado." 90 | max-ip-reached: "&cVocê atingiu o número máximo de registros por endereço de IP." 91 | no-permissions: "&cVocê não tem permissões para usar este comando." 92 | player-only: "&cVocê só pode executar este comando em jogo." 93 | ... 94 | -------------------------------------------------------------------------------- /ServerAuth/resources/languages/RU_ru.yml: -------------------------------------------------------------------------------- 1 | #ServerAuth plugin Russian language file 2 | #Translation by Pub4Game 3 | --- 4 | join-message: "&bНа этом сервере используется авторизация &7- &aServerAuth" 5 | single-auth: "&cИгрок с таким ником уже играет на сервере!" 6 | mysql-success: "&aServerAuth успешно подключен к базе данных MySQL!" 7 | mysql-restored: "&aMySQL соединение восстановлено!" 8 | mysql-fail: "&cServerAuth не может подключиться к базе данных MySQL. Все данные будут сохранены локально. Ошибка: {MYSQL_ERROR}" 9 | config-reloaded: "&aКонфигурация плагина перезагружена!" 10 | operation-cancelled: "&cДействие отменено" 11 | login: 12 | message: "&cДля авторизации на сервере /login <пароль>" 13 | disabled: "&cАвторизация отключена на данном сервере" 14 | command: "&cИспользуйте: /login <пароль>" 15 | ip-login: "&9Вы уже вошли на сервер с данного IP" 16 | login-success: "&aВы успешно вошли в свой аккаунт!" 17 | login-timeout: "&cВремя ожидания авторизации закончилось" 18 | already-login: "&aВы уже вошли в свой аккаунт!" 19 | too-many-attempts: "&cВы делаете слишком много попыток входа!" 20 | register: 21 | message: "&cПожалуйста, зарегистрируйтесь на сервере /register <пароль>" 22 | message-conf: "&cПожалуйста, зарегистрируйтесь на сервере /register <пароль> <повтор пароля>" 23 | disabled: "&cРегистрация отключена на данном сервере" 24 | command: "&cИспользуйте: /register <пароль>" 25 | command-conf: "&cИспользуйте: /register <пароль> <повтор пароля>" 26 | register-success: "&aВы успешно зарегистрировались!" 27 | register-timeout: "&cВремя ожидания регистрации закончилось" 28 | already-registered: "&aВы уже зарегистрировали свой аккаунт!" 29 | changepassword: 30 | disabled: "&cИзменение пароля отключено на данном сервере" 31 | login-required: "&cПожалуйста, войдите в свой аккаунт, после чего смените пароль!" 32 | command: "&cИспользуйте: /changepassword <новый пароль>" 33 | command-conf: "&cИспользуйте: /changepassword <новый пароль> <повтор пароля>" 34 | command-cons: "&cИспользуйте: /changepassword <игрок> <новый пароль>" 35 | changepassword-success: "&aПароль был успешно изменен!" 36 | changepassword-cons-success: "&aПароль игрока &b{PLAYER} &aуспешно изменен на &b{PASSWORD}" 37 | logout: 38 | disabled: "&cВыход из аккаунта отключен на данном сервере" 39 | logout-success: "&aВы успешно вышли из своего аккаунта" 40 | unregister: 41 | disabled: "&cУдаление аккаунта отключено на сервере" 42 | login-required: "&cПожалуйста, войдите в свой аккаунт, после чего повторите попытку!" 43 | command: "&cИспользуйте: /unregister <пароль>" 44 | command-cons: "&cИспользуйте: /unregister <ник>" 45 | unregister-success: "&aВы успешно удалили свой аккаунт!" 46 | unregister-success-3rd: "&aВы успешно удалили аккаунт игрока!" 47 | help: 48 | 1: "&b=> &aДоступные команды &b<=" 49 | 2: "&a/changepassword &b=>&a Позволяет изменить пароль" 50 | 3: "&a/login &b=>&a Позволяет входить в аккаунт" 51 | 4: "&a/logout &b=>&a Позволяет выходить из аккаунта" 52 | 5: "&a/register &b=>&a Регистрирует аккаунт" 53 | 6: "&a/serverauth help &b=>&a Отображает помощь о плагине" 54 | 7: "&a/serverauth info &b=>&a Отображает информацию о плагине" 55 | 8: "&a/serverauth reload &b=>&a Перезагружает конфигурацию" 56 | 9: "&a/unregister &b=>&a Удаляет аккаунт" 57 | error: "&cСубкоманда &a{SUBCMD} &cне найдена. Используйте &a/serverauth help &cдля просмотра доступных команд." 58 | errors: 59 | generic: "&cПроизошла ошибка" 60 | wrong-password: "&cВы ввели неверный пароль!" 61 | password-no-match: "&cПароли не совпадают" 62 | password-too-short: "&cВаш пароль слишком короткий!" 63 | password-too-long: "&cВаш пароль слишком длинный!" 64 | user-not-registered: "&cВы не зарегистрированы!" 65 | user-not-registered-3rd: "&cИгрок с таким ником не зарегистрирован!" 66 | user-not-authenticated: "&cВы не авторизовались!" 67 | max-ip-reached: "&cВы достигли максимальное число регистраций с одного IP" 68 | no-permissions: "&cУ Вас нет прав для использования этой команды" 69 | player-only: "&cПожалуйста, используйте эту команду только в игре" 70 | ... 71 | -------------------------------------------------------------------------------- /ServerAuth/resources/languages/TR_tr.yml: -------------------------------------------------------------------------------- 1 | #ServerAuth plugin Turkish language file 2 | #Translation by NightRichTR (Old Nick: Gecekatili) 3 | #Bugs fixed by theilqer at 31.12.2021 4 | --- 5 | join-message: "&aServerAuth §atarafından sağlanan kimlik doğrulama eklentisi." 6 | single-auth: "&cBu isimle sunucuya zaten kayıt olunmuş!" 7 | mysql-success: "&aServerAuth ile MySQL bağlantısı başarıyla kuruldu!" 8 | mysql-restored: "&aMySQL bağlantısı restore ediliyor!" 9 | config-reloaded: "&aYapılandırma dosyası yeniden yüklendi!" 10 | operation-cancelled: "&cİşlem iptal edildi." 11 | login: 12 | message: "&cGiriş yapmak içim lütfen /login <şifre> komutunu kullanınız." 13 | disabled: "&cGiriş komutu bu sunucuda devre dışı bırakılmış." 14 | command: "&cKullanımı: /login <şifre>" 15 | ip-login: "&9IP Adresi ile otomatik giriş yapıldı." 16 | uuid-login: "&9UUID ile otomatik giriş yapıldı." 17 | login-success: "&aBaşarıyla giriş yapıldı!" 18 | login-timeout: "&cGiriş zaman aşımına uğradı." 19 | already-login: "&aZaten giriş yapıldı." 20 | too-many-attempts: "&cÇok fazla giriş yapmayı denedin!" 21 | register: 22 | message: "&cKayıt olmak için lütfen /register <şifre> komutunu kullanınız." 23 | message-conf: "&cKayıt olmak için lütfen /register <şifre> <şifreDoğrula>" 24 | disabled: "&cKayıt olma komutu bu sunucuda devre dışı bırakılmış." 25 | command: "&cKullanımı: /register <şifre>" 26 | command-conf: "&cKullanımı: /register <şifre> <şifreDoğrula>" 27 | register-success: "&aBaşarıyla kayıt olundu!" 28 | register-timeout: "&cKayıt olumu zaman aşımına uğradı." 29 | already-registered: "&aZaten kayıt olmuşsun." 30 | changepassword: 31 | disabled: "&cŞifre değistirme bu sunucuda devre dışı bırakılmış." 32 | login-required: "&cŞifre değiştirebilmek için ilk önce kayıt olmalısın." 33 | command: "&cKullanımı: /changepassword " 34 | command-conf: "&cKullanımı: /changepassword <şifreDoğrula>" 35 | command-cons: "&cKullanımı: /changepassword " 36 | changepassword-success: "&aŞifre değiştirildi!" 37 | changepassword-cons-success: "&b{PLAYER} &aiçin şifresi, &b{PASSWORD} &aolarak ayarlandı." 38 | logout: 39 | disabled: "&cÇıkış yapma bu sunucuda devre dışı bırakılmış." 40 | logout-success: "&aÇıkış yapıldı." 41 | unregister: 42 | disabled: "&cKayıt iptali bu sunucuda devre dışı bırakılmış." 43 | login-required: "&cKaydınızı silmek için ilk önce giriş yapmalısınız." 44 | command: "&cKullanımı: /unregister <şifre>" 45 | command-cons: "&cKullanımı: /unregister " 46 | unregister-success: "&aKaydınız silindi!" 47 | unregister-success-3rd: "&aOyuncunun kaydı silindi!" 48 | importers: 49 | same-provider: "&cAynı sağlayıcıdan, veriyi içeri aktaramazsınız." 50 | init-import: "&aVeri içe aktarılıyor..." 51 | data-not-found: "&c{PLUGIN} eklentisinin hesap verileri bulunamadı!" 52 | data-invalid: "&c{PLUGIN} eklentisinin hesap verileri, geçersiz durumda." 53 | db-usage-basic: "&cKullanımı: /serverauth import {ID} [şifre] [port]" 54 | db-usage-advanced: "&cKullanımı: /serverauth import {ID} [şifre] [tablo_öneki] [port]" 55 | yaml: "&a{PLUGIN} yaml dosyasından {PROVIDER} hesabına, {COUNT} adet profil başarıyla alındı!" 56 | json: "&a{PLUGIN} json dosyasından {PROVIDER} hesabına, {COUNT} adet profil başarıyla alındı!" 57 | mysql: "&a{PLUGIN} mysql veritabanından {PROVIDER} hesabına, {COUNT} adet profil başarıyla alındı!" 58 | sqlite: "&a{PLUGIN} sqlite veritabanından {PROVIDER} hesabına, {COUNT} adet profil başarıyla alındı!" 59 | help: 60 | 1: "&b=> &aKullanılabilir Komutlar &b<=" 61 | 2: "&a/changepassword &b=>&a Hesabınızın şifresini değiştirir" 62 | 3: "&a/login &b=>&a Hesabınıza giriş yapın" 63 | 4: "&a/logout &b=>&a Hesabınızdan çıkış yapın" 64 | 5: "&a/register &b=>&a Hesabınızla kayıt olun" 65 | 6: "&a/serverauth help &b=>&a Eklentinin yardım sayfasını görüntüle" 66 | 7: "&a/serverauth info &b=>&a Eklentinin infosunu görüntüle" 67 | 8: "&a/serverauth import &b=>&a Başka eklentilerin hesap verilerini, ServerAuth veri sağlayıcılarından veya diğer yetkili eklentilerden içe aktarır" 68 | 9: "&a/serverauth reload &b=>&a Yapılandırma dosyasını yenile" 69 | 10: "&a/unregister &b=>&a Hesabınızın kaydını silin" 70 | invalid: "&cSubcommand &a{SUBCMD} &cbulunamadı. Kullanabileceğiniz komutları görüntülemek için &a/serverauth help &ckomutunu kullanın" 71 | errors: 72 | generic: "&cBelirlenemeyen bir hata oluştu." 73 | provider-error: "&eBelirtilen veri sağlayıcısını başlatırken bir hata oluştu. YAML varsayılan veri sağlayıcısı ayarlandı." 74 | mysql-connect-error: "&cMySQL veritabanına bağlanılamadı. Hata: {ERROR}" 75 | mysql-database-error: "&cServerAuth veritabanı, MySQL veritabanına oluşturulamadı!" 76 | mysql-query-error: "&cMySQL sorgusu başarısız oldu." 77 | mysql-tables-error: "&cServerAuth tabloları MySQL veritabanında oluşturulamadı!" 78 | sqlite-open-error: "&cSQLite3 veritabanını açamadı. Hata: {ERROR}" 79 | sqlite-query-error: "&cSQLite3 sorgusu başarısız oldu.." 80 | sqlite-tables-error: "&cServerAuth tabloları SQLite3 veritabanında oluşturulamadı!" 81 | invalid-hash-algorithm: "&eGeçersiz karma şifreleme algoritması. ServerAuth stabil algoritmasına geçildi." 82 | invalid-provider: "&eGeçersiz veri sağlayıcısı belirlendi! YAML varsayılan veri sağlayıcısı ayarlandı." 83 | invalid-uuid: "&cUUID'niz geçersiz!" 84 | wrong-password: "&cKötü şifre." 85 | password-no-match: "&cŞifreniz doğrulanamadı." 86 | password-too-short: "&cŞifreniz çok kısa." 87 | password-too-long: "&cŞifreniz çok uzun." 88 | user-not-registered: "&cİlk önce sunucuya kayıt olun." 89 | user-not-registered-3rd: "&cBu oyuncu sunucuya hiç kayıt olmamış." 90 | user-not-authenticated: "&cİlk önce sunucuya giriş yapın." 91 | max-ip-reached: "&cBir IP'den maximum hesap hesap açma sayısına ulaştınız." 92 | no-permissions: "&cBu komutu kullanmak için yetkilendirilmediniz." 93 | player-only: "&cBu komutu yanlızca oyunda, oyuncu olarak kullanabilirsiniz." 94 | ... 95 | -------------------------------------------------------------------------------- /ServerAuth/resources/languages/ja_JP.yml: -------------------------------------------------------------------------------- 1 | #ServerAuth plugin Japanese language file 2 | #Translation by theilqer at 31.12.2021 3 | --- 4 | join-message: "&bによって提供される認証システム &aServerAuth &bプラグイン。." 5 | single-auth: "&cこのユーザー名のプレーヤーはすでに認証されています!" 6 | mysql-success: "&aServerAuth MySQLデータベースに正常に接続されました!" 7 | mysql-restored: "&aMySQL 接続が復元されました!" 8 | config-reloaded: "&a構成がリロードされました!" 9 | operation-cancelled: "&c操作はキャンセルされました。" 10 | login: 11 | message: "&cでログインしてください /login <パスワード>" 12 | disabled: "&cこのサーバーではログインが無効になっています。" 13 | command: "&c使用法: /login <パスワード>" 14 | ip-login: "&9IPによって認証されました。" 15 | uuid-login: "&9UUIDによって認証されました。" 16 | login-success: "&a認証されました!" 17 | login-timeout: "&cログインタイムアウト。" 18 | already-login: "&aすでにログインしています。" 19 | too-many-attempts: "&cログイン試行回数が多すぎます。" 20 | register: 21 | message: "&cに登録してください /register <パスワード>" 22 | message-conf: "&cに登録してください /register <パスワード> <パスワードを認証する>" 23 | disabled: "&cこのサーバーで登録が無効になっています。" 24 | command: "&c使用法: /register <パスワード>" 25 | command-conf: "&c使用法: /register <パスワード> <パスワードを認証する>" 26 | register-success: "&aアカウントが登録されました!" 27 | register-timeout: "&c登録タイムアウト。" 28 | already-registered: "&aあなたはすでに登録されています。" 29 | changepassword: 30 | disabled: "&cこのサーバーで無効になっているパスワードを変更します。" 31 | login-required: "&cパスワードを変更するには、認証を受ける必要があります。" 32 | command: "&c使用法: /changepassword <新しいパスワード>" 33 | command-conf: "&c使用法: /changepassword <新しいパスワード> <パスワードの確認>" 34 | command-cons: "&c使用法: /changepassword <プレーヤー> <新しいパスワード>" 35 | changepassword-success: "&aパスワード変更済み!" 36 | changepassword-cons-success: "&aユーザーのパスワード &b{PLAYER} &aに変更されました &b{PASSWORD}" 37 | logout: 38 | disabled: "&cこのサーバーではログアウトが無効になっています。" 39 | logout-success: "&bログアウトしました。" 40 | unregister: 41 | disabled: "&cこのサーバーで無効になっている登録を解除します。" 42 | login-required: "&c登録を解除するには、認証を受ける必要があります." 43 | command: "&c使用法: /unregister <パスワード>" 44 | command-cons: "&c使用法: /unregister <プレーヤー>" 45 | unregister-success: "&bアカウントの登録が解除されました。" 46 | unregister-success-3rd: "&aプレイヤーのアカウントは登録解除されました!" 47 | importers: 48 | same-provider: "&c同じプロバイダーからデータをインポートすることはできません" 49 | init-import: "&aデータのインポート..." 50 | data-not-found: "&cのアカウントデータ {PLUGIN} プラグインが見つかりません!" 51 | data-invalid: "&c無効 {PLUGIN} アカウントデータ。" 52 | db-usage-basic: "&c使用法: /serverauth import {ID} <ホスト> <ユーザー> <データベース> [パスワード] [ポート]" 53 | db-usage-advanced: "&c使用法: /serverauth import {ID} <ホスト> <ユーザー> <データベース> [パスワード] [テーブルプレフィックス] [ポート]" 54 | yaml: "&a正常にインポートされました {COUNT}からのプロファイル {PLUGIN} yamlファイルを {PROVIDER}!" 55 | json: "&a正常にインポートされました {COUNT} からのプロファイル {PLUGIN} json ファイルを {PROVIDER}!" 56 | mysql: "&a正常にインポートされました {COUNT} からのプロファイル {PLUGIN} mysql データベースから {PROVIDER}!" 57 | sqlite: "&a正常にインポートされました {COUNT} からのプロファイル {PLUGIN} sqlite データベースから {PROVIDER}!" 58 | help: 59 | 1: "&b=> &a使用可能なコマンド &b<=" 60 | 2: "&a/changepassword &b=>&a アカウントのパスワードを変更する" 61 | 3: "&a/login &b=>&a ログインしてください" 62 | 4: "&a/logout &b=>&a ログアウトする" 63 | 5: "&a/register &b=>&a アカウントを登録" 64 | 6: "&a/serverauth help &b=>&a このプラグインに関するヘルプを表示する" 65 | 7: "&a/serverauth info &b=>&a このプラグインに関する情報を表示する" 66 | 8: "&a/serverauth import &b=>&a 他のServerAuthデータプロバイダーまたは他の認証プラグインからアカウントデータをインポートします" 67 | 9: "&a/serverauth reload &b=>&a 設定をリロードします" 68 | 10: "&a/unregister &b=>&a アカウントの登録を解除します" 69 | invalid: "&cサブコマンド &a{SUBCMD} &c見つかりません。つかいます &a/serverauth help &c使用可能なコマンドを表示するには" 70 | errors: 71 | generic: "&cエラーが発生しました。" 72 | provider-error: "&e指定されたデータプロバイダーの初期化中にエラーが発生しました。 YAMLのデフォルトのデータプロバイダーセット." 73 | mysql-connect-error: "&cMySQLデータベースへの接続に失敗しました: {ERROR}" 74 | mysql-database-error: "&cServerAuthデータベースをMySQLデータベースに作成できませんでした!" 75 | mysql-query-error: "&cMySQLクエリが失敗しました。" 76 | mysql-tables-error: "&cServerAuthテーブルをMySQLデータベースに作成できませんでした!" 77 | sqlite-open-error: "&cSQLite3データベースを開くことができませんでした: {ERROR}" 78 | sqlite-query-error: "&cSQLite3クエリが失敗しました。" 79 | sqlite-tables-error: "&cServerAuthテーブルをSQLite3データベースに作成できませんでした!" 80 | invalid-hash-algorithm: "&e無効なハッシュアルゴリズムが指定されました! ServerAuthソルトアルゴリズムセット。" 81 | invalid-provider: "&e無効なデータプロバイダーが指定されました! YAMLのデフォルトのデータプロバイダーセット。" 82 | invalid-uuid: "&cUUIDが無効です!" 83 | wrong-password: "&c間違ったパスワード。" 84 | password-no-match: "&cパスワードが確認と一致しません." 85 | password-too-short: "&cパスワードが短すぎます。" 86 | password-too-long: "&cパスワードが長すぎます。" 87 | user-not-registered: "&cあなたは登録されていません。" 88 | user-not-registered-3rd: "&cプレイヤーは登録されていません。" 89 | user-not-authenticated: "&cあなたは認証されていません。" 90 | max-ip-reached: "&cIPアドレスごとの登録の最大数に達しました。" 91 | no-permissions: "&cこのコマンドを使用する権限がありません。" 92 | player-only: "&cこのコマンドはプレイヤーとしてのみ実行できます。" 93 | ... 94 | -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Commands/ChangePassword.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 23 | } 24 | 25 | public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args): bool { 26 | if($sender->hasPermission("serverauth.changepassword")){ 27 | if($sender instanceof Player){ 28 | if($this->plugin->isChangePasswordEnabled()){ 29 | if($this->plugin->isPlayerAuthenticated($sender)){ 30 | if($this->plugin->cfg["changepassword"]["confirm-required"]){ 31 | if(count($args) == 2){ 32 | if($args[0] == $args[1]){ 33 | goto chpassw; 34 | }else{ 35 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["password-no-match"])); 36 | } 37 | }else{ 38 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["changepassword"]["command-conf"])); 39 | } 40 | }else if(count($args) == 1){ 41 | chpassw: 42 | $cmessage = null; 43 | switch($this->plugin->changeAccountPassword($sender->getName(), $args[0], $cmessage)){ 44 | case ServerAuth::SUCCESS: 45 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["changepassword"]["changepassword-success"])); 46 | break; 47 | case ServerAuth::ERR_NOT_REG: 48 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["user-not-registered"])); 49 | break; 50 | case ServerAuth::ERR_PASS_SHORT: 51 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["password-too-short"])); 52 | break; 53 | case ServerAuth::ERR_PASS_LONG: 54 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["password-too-long"])); 55 | break; 56 | case ServerAuth::CANCELLED: 57 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $cmessage)); 58 | break; 59 | case ServerAuth::ERR_IO: 60 | break; 61 | default: 62 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["generic"])); 63 | break; 64 | } 65 | }else{ 66 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["changepassword"]["command"])); 67 | } 68 | }else{ 69 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["changepassword"]["login-required"])); 70 | } 71 | }else{ 72 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["changepassword"]["disabled"])); 73 | } 74 | }else if(count($args) == 2){ 75 | $cmessage = null; 76 | switch($this->plugin->changeAccountPassword($this->plugin->getServer()->getOfflinePlayer($args[0])->getName(), $args[1], $cmessage)){ 77 | case ServerAuth::SUCCESS: 78 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->replaceVars($this->plugin->chlang["changepassword"]["changepassword-cons-success"], array("PLAYER" => $args[0], "PASSWORD" => $args[1])))); 79 | break; 80 | case ServerAuth::ERR_NOT_REG: 81 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["user-not-registered-3rd"])); 82 | break; 83 | case ServerAuth::ERR_PASS_SHORT: 84 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["password-too-short"])); 85 | break; 86 | case ServerAuth::ERR_PASS_LONG: 87 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["password-too-long"])); 88 | break; 89 | case ServerAuth::CANCELLED: 90 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $cmessage)); 91 | break; 92 | case ServerAuth::ERR_IO: 93 | break; 94 | default: 95 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["generic"])); 96 | break; 97 | } 98 | }else{ 99 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["changepassword"]["command-cons"])); 100 | } 101 | }else{ 102 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["errors"]["no-permissions"])); 103 | } 104 | return true; 105 | } 106 | 107 | /** 108 | * {@inheritDoc} 109 | * @see \ServerAuth\Commands\ServerAuthCommand::getType() 110 | */ 111 | public function getType() : int { 112 | return ServerAuth::CMD_CHPASSW; 113 | } 114 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Commands/Commands.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 24 | } 25 | 26 | public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool { 27 | if(isset($args[0])){ 28 | $args[0] = strtolower($args[0]); 29 | switch($args[0]){ 30 | case "help": 31 | goto help; 32 | case "import": 33 | if($sender->hasPermission("serverauth.import")){ 34 | if(isset($args[1])){ 35 | $imp = $this->plugin->getImpoter($args[1]); 36 | if($imp){ 37 | $imp->export($sender, array_slice($args, 2)); 38 | break; 39 | } 40 | $sender->sendMessage($this->plugin->translateColors("&", "&cInvalid importer specified!")); 41 | break; 42 | } 43 | $sender->sendMessage($this->plugin->translateColors("&", "&cPlease specify an importer!")); 44 | break; 45 | } 46 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["errors"]["no-permissions"])); 47 | break; 48 | case "info": 49 | if($sender->hasPermission("serverauth.info")){ 50 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . "&bServerAuth &av" . $this->plugin->getDescription()->getVersion() . " &bdeveloped by &aEvolSoft")); 51 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . "&bWebsite &a" . $this->plugin->getDescription()->getWebsite())); 52 | break; 53 | } 54 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["errors"]["no-permissions"])); 55 | break; 56 | case "reload": 57 | if($sender->hasPermission("serverauth.reload")){ 58 | $this->plugin->reloadConfig(); 59 | $this->cfg = $this->plugin->getConfig()->getAll(); 60 | $this->plugin->chlang = ServerAuth::getAPI()->getConfigLanguage()->getAll(); 61 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["config-reloaded"])); 62 | break; 63 | } 64 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["errors"]["no-permissions"])); 65 | break; 66 | default: 67 | if($sender->hasPermission("serverauth")){ 68 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["help"]["invalid"], array("SUBCMD" => $args[0])))); 69 | break; 70 | } 71 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["errors"]["no-permissions"])); 72 | break; 73 | } 74 | return true; 75 | } 76 | help: 77 | if($sender->hasPermission("serverauth.help")){ 78 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["help"]["1"])); 79 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["help"]["2"])); 80 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["help"]["3"])); 81 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["help"]["4"])); 82 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["help"]["5"])); 83 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["help"]["6"])); 84 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["help"]["7"])); 85 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["help"]["8"])); 86 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["help"]["9"])); 87 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["help"]["10"])); 88 | }else{ 89 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["errors"]["no-permissions"])); 90 | } 91 | return true; 92 | } 93 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Commands/Login.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 23 | } 24 | 25 | public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool { 26 | if($sender->hasPermission("serverauth.login")){ 27 | if($sender instanceof Player){ 28 | if($this->plugin->isLoginEnabled()){ 29 | if(count($args) == 1){ 30 | $cmessage = null; 31 | /*if($this->plugin->cfg["log-multiple-accounts"]){ //TODO in future versions 32 | foreach($this->getServer()->getOnlinePlayers() as $pl){ 33 | if($pl->isOp()){ 34 | $pl->sendMessage($this->plugin->translateColors("&", $sender->getName() . " has (n) accounts: ")); 35 | } 36 | } 37 | }*/ 38 | switch($this->plugin->authenticatePlayer($sender, $args[0], false, $cmessage)){ 39 | case ServerAuth::SUCCESS: 40 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["login"]["login-success"])); 41 | break; 42 | case ServerAuth::ERR_WRONG_PASS: 43 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["wrong-password"])); 44 | break; 45 | case ServerAuth::ERR_ALREADY_AUTH: 46 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix(). $this->plugin->chlang["login"]["already-login"])); 47 | break; 48 | case ServerAuth::ERR_NOT_REG: 49 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["user-not-registered"])); 50 | break; 51 | case ServerAuth::ERR_TOO_MANY_ATTEMPTS: 52 | $sender->close("", $this->plugin->translateColors("&", $this->plugin->chlang["login"]["too-many-attempts"])); 53 | $this->plugin->resetAuthAttempts($sender); 54 | break; 55 | case ServerAuth::CANCELLED: 56 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $cmessage)); 57 | break; 58 | default: 59 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["generic"])); 60 | break; 61 | } 62 | }else{ 63 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["login"]["command"])); 64 | } 65 | }else{ 66 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["login"]["disabled"])); 67 | } 68 | }else{ 69 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["errors"]["player-only"])); 70 | } 71 | }else{ 72 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["errors"]["no-permissions"])); 73 | } 74 | return true; 75 | } 76 | 77 | /** 78 | * {@inheritDoc} 79 | * @see \ServerAuth\Commands\ServerAuthCommand::getType() 80 | */ 81 | public function getType() : int { 82 | return ServerAuth::CMD_LOGIN; 83 | } 84 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Commands/Logout.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 23 | } 24 | 25 | public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool { 26 | if($sender->hasPermission("serverauth.logout")){ 27 | if($sender instanceof Player){ 28 | $cmessage = null; 29 | if($this->plugin->isLogoutEnabled()){ 30 | switch($this->plugin->deauthenticatePlayer($sender, $cmessage)){ 31 | case ServerAuth::SUCCESS: 32 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["logout"]["logout-success"])); 33 | break; 34 | case ServerAuth::ERR_NOT_REG: 35 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["user-not-registered"])); 36 | break; 37 | case ServerAuth::ERR_NOT_AUTH: 38 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["user-not-authenticated"])); 39 | break; 40 | case ServerAuth::CANCELLED: 41 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $cmessage)); 42 | break; 43 | default: 44 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["generic"])); 45 | break; 46 | } 47 | }else{ 48 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["logout"]["disabled"])); 49 | } 50 | }else{ 51 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["errors"]["player-only"])); 52 | } 53 | }else{ 54 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["errors"]["no-permissions"])); 55 | } 56 | return true; 57 | } 58 | 59 | /** 60 | * {@inheritDoc} 61 | * @see \ServerAuth\Commands\ServerAuthCommand::getType() 62 | */ 63 | public function getType() : int { 64 | return ServerAuth::CMD_LOGOUT; 65 | } 66 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Commands/Register.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 23 | } 24 | 25 | public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool { 26 | if($sender->hasPermission("serverauth.register")){ 27 | if($sender instanceof Player){ 28 | if($this->plugin->isRegisterEnabled()){ 29 | if($this->plugin->cfg["register"]["confirm-required"]){ 30 | if(count($args) == 2){ 31 | if($args[0] == $args[1]){ 32 | goto register; 33 | }else{ 34 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["password-no-match"])); 35 | } 36 | }else{ 37 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["register"]["command-conf"])); 38 | } 39 | }else if(count($args) == 1){ 40 | register: 41 | $cmessage = null; 42 | switch($this->plugin->registerAccount($sender, $args[0], $cmessage)){ 43 | case ServerAuth::SUCCESS: 44 | ServerAuth::getAPI()->authenticatePlayer($sender, $args[0]); 45 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["register"]["register-success"])); 46 | break; 47 | case ServerAuth::ERR_ALREADY_REG: 48 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["register"]["already-registered"])); 49 | break; 50 | case ServerAuth::ERR_PASS_SHORT: 51 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["password-too-short"])); 52 | break; 53 | case ServerAuth::ERR_PASS_LONG: 54 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["password-too-long"])); 55 | break; 56 | case ServerAuth::ERR_MAX_IP: 57 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["max-ip-reached"])); 58 | break; 59 | case ServerAuth::ERR_IO: 60 | break; 61 | case ServerAuth::CANCELLED: 62 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $cmessage)); 63 | break; 64 | default: 65 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["generic"])); 66 | break; 67 | } 68 | }else{ 69 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["register"]["command"])); 70 | } 71 | }else{ 72 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["register"]["disabled"])); 73 | } 74 | }else{ 75 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["errors"]["player-only"])); 76 | } 77 | }else{ 78 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["errors"]["no-permissions"])); 79 | } 80 | return true; 81 | } 82 | 83 | /** 84 | * {@inheritDoc} 85 | * @see \ServerAuth\Commands\ServerAuthCommand::getType() 86 | */ 87 | public function getType() : int { 88 | return ServerAuth::CMD_REGISTER; 89 | } 90 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Commands/ServerAuthCommand.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 23 | } 24 | 25 | public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool { 26 | switch(strtolower($cmd->getName())){ 27 | case "register": 28 | return $this->plugin->getAuthCommand(ServerAuth::CMD_REGISTER)->onCommand($sender, $cmd, $label, $args); 29 | case "unregister": 30 | return $this->plugin->getAuthCommand(ServerAuth::CMD_UNREGISTER)->onCommand($sender, $cmd, $label, $args); 31 | case "login": 32 | return $this->plugin->getAuthCommand(ServerAuth::CMD_LOGIN)->onCommand($sender, $cmd, $label, $args); 33 | case "logout": 34 | return $this->plugin->getAuthCommand(ServerAuth::CMD_LOGOUT)->onCommand($sender, $cmd, $label, $args); 35 | case "changepassword": 36 | return $this->plugin->getAuthCommand(ServerAuth::CMD_CHPASSW)->onCommand($sender, $cmd, $label, $args); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Commands/Unregister.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 23 | } 24 | 25 | public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool { 26 | if($sender->hasPermission("serverauth.unregister")){ 27 | if($sender instanceof Player){ 28 | if($this->plugin->isUnregisterEnabled()){ 29 | if($this->plugin->isPlayerAuthenticated($sender)){ 30 | if($this->plugin->cfg["unregister"]["require-password"]){ 31 | if(count($args) == 1){ 32 | $pdata = $this->plugin->getPlayerData($sender->getName()); 33 | $hashalg = isset($pdata["hashalg"]) ? $this->plugin->getHashAlgById($pdata["hashalg"]) : $this->plugin->getHashAlg(); 34 | if(!$hashalg){ 35 | $hashalg = $this->plugin->getHashAlg(); 36 | } 37 | $params = isset($pdata["hashparams"]) ? $pdata["hashparams"] : $this->plugin->encodeParams($this->plugin->cfg["password-hash"]["parameters"]); 38 | if($this->plugin->hashPassword($args[0], $hashalg, $params . ",player:" . $sender->getName()) == $pdata["password"]){ 39 | goto unregister; 40 | }else{ 41 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["wrong-password"])); 42 | } 43 | }else{ 44 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["unregister"]["command"])); 45 | } 46 | }else{ 47 | unregister: 48 | $cmessage = null; 49 | switch($this->plugin->unregisterAccount($sender->getName(), $cmessage)){ 50 | case ServerAuth::SUCCESS: 51 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["unregister"]["unregister-success"])); 52 | break; 53 | case ServerAuth::ERR_NOT_REG: 54 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["user-not-registered"])); 55 | break; 56 | case ServerAuth::CANCELLED: 57 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $cmessage)); 58 | break; 59 | case ServerAuth::ERR_IO: 60 | break; 61 | default: 62 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["errors"]["generic"])); 63 | break; 64 | } 65 | } 66 | }else{ 67 | $sender->sendMessage($this->plugin->translateColors("&", $cfg["prefix"] . $this->plugin->chlang["unregister"]["login-required"])); 68 | } 69 | }else{ 70 | $sender->sendMessage($this->plugin->translateColors("&", $cfg["prefix"] . $this->plugin->chlang["unregister"]["disabled"])); 71 | } 72 | }else if(isset($args[0])){ 73 | $cmessage = null; 74 | switch($this->plugin->unregisterAccount($args[0], $cmessage)){ 75 | case ServerAuth::SUCCESS: 76 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["unregister"]["unregister-success-3rd"])); 77 | break; 78 | case ServerAuth::ERR_NOT_REG: 79 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["errors"]["user-not-registered-3rd"])); 80 | break; 81 | case ServerAuth::CANCELLED: 82 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $cmessage)); 83 | break; 84 | case ServerAuth::ERR_IO: 85 | break; 86 | default: 87 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["errors"]["generic"])); 88 | break; 89 | } 90 | }else{ 91 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["unregister"]["command-cons"])); 92 | } 93 | }else{ 94 | $sender->sendMessage($this->plugin->translateColors("&", $this->plugin->chlang["errors"]["no-permissions"])); 95 | } 96 | return true; 97 | } 98 | 99 | /** 100 | * {@inheritDoc} 101 | * @see \ServerAuth\Commands\ServerAuthCommand::getType() 102 | */ 103 | public function getType() : int { 104 | return ServerAuth::CMD_UNREGISTER; 105 | } 106 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/EventListener.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 33 | } 34 | 35 | /** 36 | * @param PlayerPreLoginEvent $event 37 | */ 38 | public function onPreLogin(PlayerPreLoginEvent $event){ 39 | $player = $event->getPlayer(); 40 | if($this->plugin->cfg["force-single-auth"]){ 41 | foreach($this->plugin->getServer()->getOnlinePlayers() as $pl){ 42 | if(strtolower($pl->getName()) == strtolower($player->getName())){ 43 | $player->close("", $this->plugin->translateColors("&", $this->plugin->chlang["single-auth"]), false); 44 | $event->setCancelled(true); 45 | return; 46 | } 47 | } 48 | if($this->plugin->cfg["uuid-login"] && $this->plugin->isAccountRegistered($player->getName())){ 49 | $pdata = $this->plugin->getPlayerData($player->getName()); 50 | if(isset($pdata["uuid"]) && $player->getUniqueId()->toString() == $pdata["uuid"]){ 51 | $this->plugin->authenticatePlayer($player, $pdata["password"], true); 52 | return; 53 | } 54 | $player->close("", $this->plugin->translateColors("&", $this->plugin->chlang["errors"]["invalid-uuid"])); 55 | $event->setCancelled(true); 56 | return; 57 | } 58 | if($this->plugin->isPlayerAuthenticated($player)){ 59 | if($this->plugin->cfg["ip-login"]){ 60 | $pdata = $this->plugin->getPlayerData($player->getName()); 61 | if(isset($pdata["ip"]) && $player->getAddress() == $pdata["ip"]){ 62 | $this->plugin->authenticatePlayer($player, $pdata["password"], true); 63 | }else{ 64 | $this->plugin->deauthenticatePlayer($player); 65 | } 66 | }else{ 67 | $this->plugin->deauthenticatePlayer($player); 68 | } 69 | } 70 | } 71 | } 72 | 73 | /** 74 | * @param PlayerJoinEvent $event 75 | */ 76 | public function onPlayerJoin(PlayerJoinEvent $event){ 77 | $player = $event->getPlayer(); 78 | if($this->plugin->cfg["show-join-message"]){ 79 | $player->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["join-message"])); 80 | } 81 | if($this->plugin->isPlayerAuthenticated($player)){ 82 | if($this->plugin->cfg["uuid-login"]){ 83 | $player->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["login"]["uuid-login"])); 84 | }else if($this->plugin->cfg["ip-login"]){ 85 | $player->sendMessage($this->plugin->translateColors("&", $this->plugin->getPrefix() . $this->plugin->chlang["login"]["ip-login"])); 86 | } 87 | } 88 | if(!$this->plugin->isAccountRegistered($player->getName()) && $this->plugin->isRegisterMessageEnabled()){ 89 | $this->plugin->callRegisterMessageHandler($this->plugin, $player); 90 | }else if(!$this->plugin->isPlayerAuthenticated($player) && $this->plugin->isLoginMessageEnabled()){ 91 | $this->plugin->callLoginMessageHandler($this->plugin, $player); 92 | } 93 | } 94 | 95 | /** 96 | * @param PlayerMoveEvent $event 97 | */ 98 | public function onPlayerMove(PlayerMoveEvent $event){ 99 | if(!$this->plugin->cfg["allow-move"] && !$this->plugin->isPlayerAuthenticated($event->getPlayer())){ 100 | $event->setCancelled(true); 101 | return; 102 | } 103 | } 104 | 105 | /** 106 | * @param PlayerChatEvent $event 107 | */ 108 | public function onPlayerChat(PlayerChatEvent $event){ 109 | if($this->plugin->getConfig()->getAll()["block-chat"]){ 110 | if(!$this->plugin->isPlayerAuthenticated($event->getPlayer())){ 111 | $event->setCancelled(true); 112 | } 113 | $recipients = $event->getRecipients(); 114 | foreach($recipients as $key => $recipient){ 115 | if($recipient instanceof Player){ 116 | if(!$this->plugin->isPlayerAuthenticated($recipient)){ 117 | unset($recipients[$key]); 118 | } 119 | } 120 | } 121 | $event->setRecipients($recipients); 122 | } 123 | } 124 | 125 | /** 126 | * @param PlayerCommandPreprocessEvent $event 127 | */ 128 | public function onPlayerCommand(PlayerCommandPreprocessEvent $event){ 129 | if($this->plugin->getConfig()->getAll()["block-commands"]){ 130 | if(!$this->plugin->isPlayerAuthenticated($event->getPlayer())){ 131 | $command = strtolower($event->getMessage()); 132 | if($command[0] == "/"){ 133 | $command = explode(" ", $command); 134 | /*if($this->plugin->getServer()->getCommandMap()->getCommand(ltrim($command[0], "/"))){ 135 | $cmdname = $this->plugin->getServer()->getCommandMap()->getCommand(ltrim($command[0], "/"))->getName(); 136 | if($cmdname != "register" && $cmdname != "login"){ 137 | $event->setCancelled(true); 138 | return; 139 | } 140 | }else{ 141 | $event->setCancelled(true); 142 | return; 143 | }*/ 144 | if($command[0] != "/login" && $command[0] != "/register" && $command[0] != "/reg"){ 145 | $event->setCancelled(true); 146 | return; 147 | } 148 | } 149 | } 150 | } 151 | } 152 | 153 | /** 154 | * @param PlayerInteractEvent $event 155 | */ 156 | public function onPlayerInteract(PlayerInteractEvent $event){ 157 | if(!$this->plugin->isPlayerAuthenticated($event->getPlayer())){ 158 | $event->setCancelled(true); 159 | return; 160 | } 161 | } 162 | 163 | /** 164 | * @param BlockBreakEvent $event 165 | */ 166 | public function onBlockBreak(BlockBreakEvent $event){ 167 | if(!$this->plugin->isPlayerAuthenticated($event->getPlayer())){ 168 | $event->setCancelled(true); 169 | return; 170 | } 171 | } 172 | 173 | /** 174 | * @param EntityDamageEvent $event 175 | */ 176 | public function onEntityDamage(EntityDamageEvent $event){ 177 | $player = $event->getEntity(); 178 | if($player instanceof Player){ 179 | if(!$this->plugin->isPlayerAuthenticated($player)){ 180 | $event->setCancelled(true); 181 | } 182 | } 183 | if($event instanceof EntityDamageByEntityEvent){ 184 | $damager = $event->getDamager(); 185 | if($damager instanceof Player){ 186 | if(!$this->plugin->isPlayerAuthenticated($damager)){ 187 | $event->setCancelled(true); 188 | } 189 | } 190 | } 191 | } 192 | 193 | /** 194 | * @param PlayerDropItemEvent $event 195 | */ 196 | public function onDropItem(PlayerDropItemEvent $event){ 197 | if($this->plugin->getConfig()->getAll()["block-all-events"] && !$this->plugin->isPlayerAuthenticated($event->getPlayer())){ 198 | $event->setCancelled(true); 199 | return; 200 | } 201 | } 202 | 203 | /** 204 | * @param PlayerItemConsumeEvent $event 205 | */ 206 | public function onItemConsume(PlayerItemConsumeEvent $event){ 207 | if($this->plugin->getConfig()->getAll()["block-all-events"] && !$this->plugin->isPlayerAuthenticated($event->getPlayer())){ 208 | $event->setCancelled(true); 209 | return; 210 | } 211 | } 212 | 213 | /** 214 | * @param CraftItemEvent $event 215 | */ 216 | public function onCraftItem(CraftItemEvent $event) { 217 | if($this->plugin->getConfig()->getAll()["block-all-events"] && !$this->plugin->isPlayerAuthenticated($event->getPlayer())){ 218 | $event->setCancelled(true); 219 | return; 220 | } 221 | } 222 | 223 | /** 224 | * @param PlayerAchievementAwardedEvent $event 225 | */ 226 | public function onAwardAchievement(PlayerAchievementAwardedEvent $event){ 227 | if($this->plugin->getConfig()->getAll()["block-all-events"] && !$this->plugin->isPlayerAuthenticated($event->getPlayer())){ 228 | $event->setCancelled(true); 229 | return; 230 | } 231 | } 232 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Events/ServerAuthAuthenticateEvent.php: -------------------------------------------------------------------------------- 1 | player = $player; 24 | } 25 | 26 | /** 27 | * Get player 28 | * 29 | * @return Player 30 | */ 31 | public function getPlayer() : Player { 32 | return $this->player; 33 | } 34 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Events/ServerAuthChangePasswordEvent.php: -------------------------------------------------------------------------------- 1 | player = $player; 25 | $this->password = $password; 26 | } 27 | 28 | /** 29 | * Get player 30 | * 31 | * @return string 32 | */ 33 | public function getPlayer(){ 34 | return $this->player; 35 | } 36 | 37 | /** 38 | * Get the new password 39 | * 40 | * @return $password 41 | */ 42 | public function getPassword(){ 43 | return $this->password; 44 | } 45 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Events/ServerAuthDeauthenticateEvent.php: -------------------------------------------------------------------------------- 1 | player = $player; 24 | } 25 | 26 | /** 27 | * Get player 28 | * 29 | * @return Player 30 | */ 31 | public function getPlayer() : Player { 32 | return $this->player; 33 | } 34 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Events/ServerAuthEvent.php: -------------------------------------------------------------------------------- 1 | cmessage; 28 | } 29 | 30 | /** 31 | * Set event cancelled message 32 | * 33 | * @param string $message 34 | */ 35 | public function setCancelledMessage($cmessage){ 36 | $this->cmessage = $cmessage; 37 | } 38 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Events/ServerAuthLoadPluginEvent.php: -------------------------------------------------------------------------------- 1 | player = $player; 27 | $this->password = $password; 28 | } 29 | 30 | /** 31 | * Get player 32 | * 33 | * @return Player 34 | */ 35 | public function getPlayer() : Player { 36 | return $this->player; 37 | } 38 | 39 | /** 40 | * Get password (it can be hashed or not) 41 | * 42 | * @return string 43 | */ 44 | public function getPassword(){ 45 | return $this->password; 46 | } 47 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Events/ServerAuthUnregisterEvent.php: -------------------------------------------------------------------------------- 1 | player = $player; 23 | } 24 | 25 | /** 26 | * Get player 27 | * 28 | * @return string 29 | */ 30 | public function getPlayer(){ 31 | return $this->player; 32 | } 33 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/HashAlgs/DefaultHash.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | * @see \ServerAuth\HashAlgs\HashAlg::getID() 24 | */ 25 | public function getId() : string { 26 | return "serverauth"; 27 | } 28 | 29 | /** 30 | * {@inheritDoc} 31 | * @see \ServerAuth\HashAlgs\HashAlg::hash() 32 | */ 33 | public function hash($password, $params = null){ 34 | $params = $this->plugin->decodeParams($params); 35 | $hash = isset($params["hash"]) ? $params["hash"] : "sha256"; 36 | $mhash = isset($params["multi-hash"]) ? $params["multi-hash"] : "md5"; 37 | $hashpwd = hash($hash, $password); 38 | if($mhash){ 39 | $hashpwd = hash($mhash, $hashpwd); 40 | } 41 | return $hashpwd; 42 | } 43 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/HashAlgs/DefaultHashSalted.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | * @see \ServerAuth\HashAlgs\HashAlg::getID() 24 | */ 25 | public function getId() : string { 26 | return "serverauth_salted"; 27 | } 28 | 29 | /** 30 | * {@inheritDoc} 31 | * @see \ServerAuth\HashAlgs\HashAlg::hash() 32 | */ 33 | public function hash($password, $params = null){ 34 | $params = $this->plugin->decodeParams($params); 35 | $hash = isset($params["hash"]) ? $params["hash"] : "sha256"; 36 | $mhash = isset($params["multi-hash"]) ? $params["multi-hash"] : "md5"; 37 | $salt = isset($params["player"]) ? strtolower($params["player"]) : ""; 38 | $hashpwd = hash($hash, $salt . $password); 39 | if($mhash){ 40 | $hashpwd = hash($mhash, $hashpwd . $salt); 41 | } 42 | return $hashpwd; 43 | } 44 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/HashAlgs/HashAlg.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | * @see \ServerAuth\HashAlgs\HashAlg::getID() 24 | */ 25 | public function getId(): string { 26 | return "simpleauth"; 27 | } 28 | 29 | /** 30 | * {@inheritDoc} 31 | * @see \ServerAuth\HashAlgs\HashAlg::hash() 32 | */ 33 | public function hash($password, $params = null){ 34 | $params = $this->plugin->decodeParams($params); 35 | $salt = isset($params["player"]) ? strtolower($params["player"]) : ""; 36 | return bin2hex(hash("sha512", $password . $salt, true) ^ hash("whirlpool", $salt . $password, true)); 37 | } 38 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Importers/HereAuthJSONImporter.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 22 | } 23 | 24 | /** 25 | * {@inheritDoc} 26 | * @see \ServerAuth\Importers\Importer::getID() 27 | */ 28 | public function getId() : string { 29 | return "hereauth-json"; 30 | } 31 | 32 | /** 33 | * {@inheritDoc} 34 | * @see \ServerAuth\Importers\Importer::export() 35 | */ 36 | public function export(CommandSender $sender, array $params = null){ 37 | $count = 0; 38 | $path = isset($params[0]) ? $params[0] : $this->plugin->getServer()->getPluginPath() . "HereAuth/accounts"; 39 | if(!is_dir($path)){ 40 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["data-not-found"], array("PLUGIN" => "HereAuth")))); 41 | return; 42 | } 43 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["importers"]["init-import"])); 44 | foreach(glob($path. "/*.json") as $usrfile){ 45 | $usrdata = json_decode(zlib_decode(file_get_contents($usrfile)), true); 46 | if($usrdata){ 47 | $cdata["password"] = bin2hex(base64_decode($usrdata["passwordHash"])); 48 | $cdata["hashed"] = true; 49 | $cdata["ip"] = $usrdata["lastIp"]; 50 | $cdata["uuid"] = UUID::fromBinary(base64_decode($usrdata["lastUuid"]))->toString(); 51 | $cdata["firstlogin"] = $usrdata["registerTime"]; 52 | $cdata["lastlogin"] = $usrdata["lastLogin"]; 53 | $cdata["hashalg"] = "simpleauth"; 54 | $cdata["hashparams"] = ""; 55 | $this->plugin->getDataProvider()->registerAccountRaw($usrdata["name"], $cdata); 56 | $count++; 57 | }else{ 58 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["data-invalid"], array("PLUGIN" => "HereAuth")))); 59 | } 60 | } 61 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["json"], array("COUNT" => $count, "PLUGIN" => "HereAuth", "PROVIDER" => $this->plugin->getDataProvider()->getId())))); 62 | } 63 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Importers/HereAuthMySQLImporter.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 22 | } 23 | 24 | /** 25 | * {@inheritDoc} 26 | * @see \ServerAuth\Importers\Importer::getID() 27 | */ 28 | public function getId() : string { 29 | return "hereauth-mysql"; 30 | } 31 | 32 | public function export(CommandSender $sender, array $params = null){ 33 | $count = 0; 34 | if(count($params) < 3){ 35 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["db-usage-advanced"], array("ID" => $this->getID())))); 36 | return; 37 | } 38 | $host = isset($params[0]) ? $params[0] : "localhost"; 39 | $user = isset($params[1]) ? $params[1] : "root"; 40 | $database = isset($params[2]) ? $params[2] : "hereauth"; 41 | $password = isset($params[3]) ? $params[3] : ""; 42 | $table_prefix = isset($params[4]) ? $params[4] : "ha"; 43 | $port = isset($params[5]) ? $params[5] : 3306; 44 | $db = @new \mysqli($host, $user, $password, $database, $port); 45 | if($db->connect_errno){ 46 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["errors"]["mysql-connect-error"], array("ERROR" => $db->connect_error)))); 47 | return; 48 | } 49 | $res = $db->query("SELECT name, hash, ip, uuid, register, login FROM " . $table_prefix . "accs"); 50 | if(!$res){ 51 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["data-invalid"], array("PLUGIN" => "HereAuth")))); 52 | return; 53 | } 54 | while($usrdata = $res->fetch_assoc()){ 55 | $cdata["password"] = bin2hex($usrdata["hash"]); 56 | $cdata["hashed"] = true; 57 | $cdata["ip"] = $usrdata["ip"]; 58 | $cdata["uuid"] = UUID::fromString(bin2hex($usrdata["uuid"]))->toString(); 59 | $cdata["firstlogin"] = $usrdata["register"]; 60 | $cdata["lastlogin"] = $usrdata["login"]; 61 | $cdata["hashalg"] = "simpleauth"; 62 | $cdata["hashparams"] = ""; 63 | $this->plugin->getDataProvider()->registerAccountRaw($usrdata["name"], $cdata); 64 | $count++; 65 | } 66 | $db->close(); 67 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["mysql"], array("COUNT" => $count, "PLUGIN" => "HereAuth", "PROVIDER" => $this->plugin->getDataProvider()->getId())))); 68 | } 69 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Importers/Importer.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 21 | } 22 | 23 | /** 24 | * {@inheritDoc} 25 | * @see \ServerAuth\Importers\Importer::getID() 26 | */ 27 | public function getId() : string { 28 | return "serverauth-mysql"; 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | * @see \ServerAuth\Importers\Importer::export() 34 | */ 35 | public function export(CommandSender $sender, array $params = null){ 36 | $count = 0; 37 | if(count($params) < 3){ 38 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["db-usage-advanced"], array("ID" => $this->getID())))); 39 | return; 40 | } 41 | $host = isset($params[0]) ? $params[0] : "localhost"; 42 | $user = isset($params[1]) ? $params[1] : "root"; 43 | $database = isset($params[2]) ? $params[2] : "serverauth"; 44 | $password = isset($params[3]) ? $params[3] : ""; 45 | $table_prefix = isset($params[4]) ? $params[4] : "srvauth_"; 46 | $port = isset($params[5]) ? $params[5] : 3306; 47 | if($this->plugin->getDataProvider()->getId() == "mysql"){ 48 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["importers"]["same-provider"])); 49 | return; 50 | } 51 | $db = @new \mysqli($host, $user, $password, $database, $port); 52 | if($db->connect_errno){ 53 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["errors"]["mysql-connect-error"], array("ERROR" => $db->connect_error)))); 54 | return; 55 | } 56 | $res = $db->query("SELECT user, password, ip, uuid, firstlogin, lastlogin, hashalg, hashparams FROM " . $table_prefix . "accounts"); 57 | if(!$res){ 58 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["data-invalid"], array("PLUGIN" => "ServerAuth")))); 59 | return; 60 | } 61 | while($usrdata = $res->fetch_assoc()){ 62 | $usrdata["hashed"] = true; 63 | $this->plugin->getDataProvider()->registerAccountRaw($usrdata["user"], $usrdata); 64 | $count++; 65 | } 66 | $db->close(); 67 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["mysql"], array("COUNT" => $count, "PLUGIN" => "ServerAuth", "PROVIDER" => $this->plugin->getDataProvider()->getId())))); 68 | } 69 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Importers/ServerAuthSQLiteImporter.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 21 | } 22 | 23 | /** 24 | * {@inheritDoc} 25 | * @see \ServerAuth\Importers\Importer::getID() 26 | */ 27 | public function getId() : string { 28 | return "serverauth-sqlite"; 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | * @see \ServerAuth\Importers\Importer::export() 34 | */ 35 | public function export(CommandSender $sender, array $params = null){ 36 | $count = 0; 37 | if($this->plugin->getDataProvider()->getId() == "sqlite"){ 38 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["importers"]["same-provider"])); 39 | return; 40 | } 41 | $db = @new \SQLite3($this->plugin->getDataFolder() . "data.db"); 42 | if(!$db){ 43 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["errors"]["sqlite-open-error"], array("ERROR" => $db->lastErrorMsg())))); 44 | return; 45 | } 46 | $res = $db->query("SELECT user, password, ip, uuid, firstlogin, lastlogin, hashalg, hashparams FROM accounts"); 47 | if(!$res){ 48 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["data-invalid"], array("PLUGIN" => "ServerAuth")))); 49 | return; 50 | } 51 | while($usrdata = $res->fetchArray()){ 52 | $usrdata["hashed"] = true; 53 | $this->plugin->getDataProvider()->registerAccountRaw($usrdata["user"], $usrdata); 54 | $count++; 55 | } 56 | $db->close(); 57 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["sqlite"], array("COUNT" => $count, "PLUGIN" => "ServerAuth", "PROVIDER" => $this->plugin->getDataProvider()->getId())))); 58 | } 59 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Importers/ServerAuthYAMLImporter.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 22 | } 23 | 24 | /** 25 | * {@inheritDoc} 26 | * @see \ServerAuth\Importers\Importer::getID() 27 | */ 28 | public function getId() : string { 29 | return "serverauth-yaml"; 30 | } 31 | 32 | /** 33 | * {@inheritDoc} 34 | * @see \ServerAuth\Importers\Importer::export() 35 | */ 36 | public function export(CommandSender $sender, array $params = null){ 37 | $count = 0; 38 | if($this->plugin->getDataProvider()->getId() == "yaml"){ 39 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["importers"]["same-provider"])); 40 | return; 41 | } 42 | foreach(glob($this->plugin->getDataFolder() . "users/*.yml") as $usrfile){ 43 | $usrdata = (new Config($usrfile, Config::YAML))->getAll(); 44 | $usrdata["hashed"] = true; 45 | $this->plugin->getDataProvider()->registerAccountRaw(strtolower(pathinfo($usrfile, PATHINFO_FILENAME)), $usrdata); 46 | $count++; 47 | } 48 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["yaml"], array("COUNT" => $count, "PLUGIN" => "ServerAuth", "PROVIDER" => $this->plugin->getDataProvider()->getId())))); 49 | } 50 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Importers/SimpleAuthMySQLImporter.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 21 | } 22 | 23 | /** 24 | * {@inheritDoc} 25 | * @see \ServerAuth\Importers\Importer::getID() 26 | */ 27 | public function getId() : string { 28 | return "simpleauth-mysql"; 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | * @see \ServerAuth\Importers\Importer::export() 34 | */ 35 | public function export(CommandSender $sender, array $params = null){ 36 | $count = 0; 37 | if(count($params) < 3){ 38 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["db-usage-basic"], array("ID" => $this->getId())))); 39 | return; 40 | } 41 | $host = isset($params[0]) ? $params[0] : "localhost"; 42 | $user = isset($params[1]) ? $params[1] : "root"; 43 | $database = isset($params[2]) ? $params[2] : "simpleauth"; 44 | $password = isset($params[3]) ? $params[3] : ""; 45 | $port = isset($params[5]) ? $params[5] : 3306; 46 | $db = @new \mysqli($host, $user, $password, $database, $port); 47 | if($db->connect_errno){ 48 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["errors"]["mysql-connect-error"], array("ERROR" => $db->connect_error)))); 49 | return; 50 | } 51 | $res = $db->query("SELECT name, hash, ip, registerdate, logindate FROM simpleauth_players"); 52 | if(!$res){ 53 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["data-invalid"], array("PLUGIN" => "SimpleAuth")))); 54 | return; 55 | } 56 | while($usrdata = $res->fetch_assoc()){ 57 | $cdata["password"] = $usrdata["hash"]; 58 | $cdata["hashed"] = true; 59 | $cdata["ip"] = $usrdata["ip"]; 60 | $cdata["firstlogin"] = $usrdata["registerdate"]; 61 | $cdata["lastlogin"] = $usrdata["logindate"]; 62 | $cdata["hashalg"] = "simpleauth"; 63 | $cdata["hashparams"] = ""; 64 | $this->plugin->getDataProvider()->registerAccountRaw($usrdata["name"], $cdata); 65 | $count++; 66 | } 67 | $db->close(); 68 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["mysql"], array("COUNT" => $count, "PLUGIN" => "SimpleAuth", "PROVIDER" => $this->plugin->getDataProvider()->getId())))); 69 | } 70 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Importers/SimpleAuthSQLiteImporter.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 21 | } 22 | 23 | /** 24 | * {@inheritDoc} 25 | * @see \ServerAuth\Importers\Importer::getID() 26 | */ 27 | public function getId() : string { 28 | return "simpleauth-sqlite"; 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | * @see \ServerAuth\Importers\Importer::export() 34 | */ 35 | public function export(CommandSender $sender, array $params = null){ 36 | $count = 0; 37 | if(!is_dir($this->plugin->getServer()->getPluginPath() . "SimpleAuth")){ 38 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["data-not-found"], array("PLUGIN" => "SimpleAuth")))); 39 | return; 40 | } 41 | $db = @new \SQLite3($this->plugin->getServer()->getPluginPath() . "SimpleAuth/players.db"); 42 | if(!$db){ 43 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["errors"]["sqlite-open-error"], array("ERROR" => $db->lastErrorMsg())))); 44 | return; 45 | } 46 | $res = $db->query("SELECT name, hash, ip, registerdate, logindate FROM players"); 47 | if(!$res){ 48 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["data-invalid"], array("PLUGIN" => "SimpleAuth")))); 49 | return; 50 | } 51 | while($usrdata = $res->fetchArray()){ 52 | $cdata["password"] = $usrdata["hash"]; 53 | $cdata["hashed"] = true; 54 | $cdata["ip"] = $usrdata["ip"]; 55 | $cdata["firstlogin"] = $usrdata["registerdate"]; 56 | $cdata["lastlogin"] = $usrdata["logindate"]; 57 | $cdata["hashalg"] = "simpleauth"; 58 | $cdata["hashparams"] = ""; 59 | $this->plugin->getDataProvider()->registerAccountRaw($usrdata["name"], $cdata); 60 | $count++; 61 | } 62 | $db->close(); 63 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["sqlite"], array("COUNT" => $count, "PLUGIN" => "SimpleAuth", "PROVIDER" => $this->plugin->getDataProvider()->getId())))); 64 | } 65 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Importers/SimpleAuthYAMLImporter.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 23 | } 24 | 25 | /** 26 | * {@inheritDoc} 27 | * @see \ServerAuth\Importers\Importer::getID() 28 | */ 29 | public function getId() : string { 30 | return "simpleauth-yaml"; 31 | } 32 | 33 | /** 34 | * {@inheritDoc} 35 | * @see \ServerAuth\Importers\Importer::export() 36 | */ 37 | public function export(CommandSender $sender, array $params = null){ 38 | $count = 0; 39 | if(!is_dir($this->plugin->getServer()->getPluginPath() . "SimpleAuth/players")){ 40 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["data-not-found"], array("PLUGIN" => "SimpleAuth")))); 41 | return; 42 | } 43 | foreach(glob($this->plugin->getServer()->getPluginPath() . "SimpleAuth/players/*") as $usrdir){ 44 | foreach(glob($usrdir . "/*.yml") as $usrfile){ 45 | $usrdata = (new Config($usrfile, Config::YAML))->getAll(); 46 | $cdata["password"] = $usrdata["hash"]; 47 | $cdata["hashed"] = true; 48 | $cdata["ip"] = $usrdata["ip"]; 49 | $cdata["firstlogin"] = $usrdata["registerdate"]; 50 | $cdata["lastlogin"] = $usrdata["logindate"]; 51 | $cdata["hashalg"] = "simpleauth"; 52 | $cdata["hashparams"] = ""; 53 | $this->plugin->getDataProvider()->registerAccountRaw(strtolower(pathinfo($usrfile, PATHINFO_FILENAME)), $cdata); 54 | $count++; 55 | } 56 | } 57 | $sender->sendMessage($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["importers"]["yaml"], array("COUNT" => $count, "PLUGIN" => "SimpleAuth", "PROVIDER" => $this->plugin->getDataProvider()->getId())))); 58 | } 59 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Providers/MySQLProvider.php: -------------------------------------------------------------------------------- 1 | "localhost", 35 | "port" => 3306, 36 | "user" => "root", 37 | "password" => "", 38 | "database" => "serverauth", 39 | "table-prefix" => "srvauth_" 40 | ); 41 | $this->plugin = $plugin; 42 | $this->cfg = new Config($this->plugin->getDataFolder() . "mysql.yml", Config::YAML, $c); 43 | } 44 | 45 | /** 46 | * {@inheritDoc} 47 | * @see \ServerAuth\Providers\Provider::init() 48 | */ 49 | public function init($params = null){ 50 | $this->db = @new \mysqli($this->cfg->get("host"), $this->cfg->get("user"), $this->cfg->get("password"), null, $this->cfg->get("port")); 51 | if($this->db->connect_errno){ 52 | $this->plugin->getServer()->getLogger()->error($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["errors"]["mysql-connect-error"], array("ERROR" => $this->db->connect_error)))); 53 | return false; 54 | } 55 | $this->plugin->getServer()->getLogger()->info($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["mysql-success"])); 56 | if(!$this->db->select_db($this->cfg->get("database"))){ 57 | if($this->db->query("CREATE DATABASE " . $this->cfg->get("database"))){ 58 | $this->plugin->getServer()->getLogger()->error($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["errors"]["mysql-database-error"])); 59 | return false; 60 | } 61 | } 62 | $this->db->select_db($this->cfg->get("database")); 63 | if(!$this->db->query("CREATE TABLE IF NOT EXISTS " . $this->cfg->get("table-prefix") . "info (version VARCHAR(10), data_version VARCHAR(10))")){ 64 | $this->plugin->getServer()->getLogger()->error($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["errors"]["mysql-tables-error"])); 65 | return false; 66 | } 67 | $res = $this->db->query("SELECT version, data_version FROM " . $this->cfg->get("table-prefix") . "info"); 68 | if(!$res){ 69 | $this->plugin->getServer()->getLogger()->error($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["errors"]["mysql-query-error"])); 70 | return; 71 | } 72 | if($res->num_rows == 0){ 73 | $this->db->query("INSERT INTO " . $this->cfg->get("table-prefix") . "info (version, data_version) VALUES (" . $this->plugin->getVersion() . ", " . self::DATA_VERSION . ")"); 74 | }else{ 75 | $this->db->query("UPDATE " . $this->cfg->get("table-prefix") . "info SET version='" . $this->plugin->getVersion() . "', data_version='" . self::DATA_VERSION . "' LIMIT 1"); 76 | } 77 | if(!$this->db->query("CREATE TABLE IF NOT EXISTS " . $this->cfg->get("table-prefix") . "accounts (user VARCHAR(50), password VARCHAR(200), ip VARCHAR(50), uuid VARCHAR(50), firstlogin BIGINT, lastlogin BIGINT, hashalg VARCHAR(20), hashparams VARCHAR(100))")){ 78 | $this->plugin->getServer()->getLogger()->error($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["errors"]["mysql-tables-error"])); 79 | return false; 80 | } 81 | $this->plugin->getServer()->getScheduler()->scheduleRepeatingTask(new MySQLTask($this->plugin, $this), 600); 82 | $this->status = true; 83 | return true; 84 | } 85 | 86 | /** 87 | * {@inheritDoc} 88 | * @see \ServerAuth\Providers\Provider::getID() 89 | */ 90 | public function getId() : string { 91 | return "mysql"; 92 | } 93 | 94 | /** 95 | * {@inheritDoc} 96 | * @see \ServerAuth\Providers\Provider::checkAuthentication() 97 | */ 98 | public function checkAuthentication(Player $player, $password, bool $hashed = false){ 99 | if(!$this->status) return ServerAuth::ERR_IO; 100 | $p = strtolower($player->getName()); 101 | $stmt = $this->db->prepare("SELECT password, hashalg, hashparams FROM " . $this->cfg->get("table-prefix") . "accounts WHERE user=?"); 102 | $stmt->bind_param("s", $p); 103 | if(!$stmt->execute()){ 104 | $stmt->close(); 105 | return ServerAuth::ERR_GENERIC; 106 | } 107 | $stmt->bind_result($stmt_password, $stmt_hashalg, $stmt_hashparams); 108 | $stmt->fetch(); 109 | $stmt->close(); 110 | if(!$hashed){ 111 | $hashalg = $this->plugin->getHashAlgById($stmt_hashalg); 112 | $params = $stmt_hashparams . ",player:" . $player->getName(); 113 | if(!$hashalg){ 114 | $hashalg = $this->plugin->getHashAlg(); 115 | } 116 | $password = $this->plugin->hashPassword($password, $hashalg, $params); 117 | } 118 | if(strcasecmp($stmt_password, $password) == 0){ 119 | $stmt = $this->db->prepare("UPDATE " . $this->cfg->get("table-prefix") . "accounts SET ip=?, lastlogin=? WHERE user=?"); 120 | $stmt_ip = $player->getAddress(); 121 | $stmt_lastplayed = $player->getLastPlayed(); 122 | $stmt->bind_param("sis", $stmt_ip, $stmt_lastplayed, $p); 123 | if(!$stmt->execute()){ 124 | $stmt->close(); 125 | return ServerAuth::ERR_GENERIC; 126 | } 127 | $stmt->close(); 128 | return ServerAuth::SUCCESS; 129 | } 130 | return ServerAuth::ERR_WRONG_PASS; 131 | } 132 | 133 | /** 134 | * {@inheritDoc} 135 | * @see \ServerAuth\Providers\Provider::registerAccountRaw() 136 | */ 137 | public function registerAccountRaw($player, array $data){ 138 | if(!$this->status) return ServerAuth::ERR_IO; 139 | $p = strtolower($player); 140 | $password = isset($data["password"]) ? $data["password"] : ""; 141 | $ip = isset($data["ip"]) ? $data["ip"] : ""; 142 | $uuid = isset($data["uuid"]) ? $data["uuid"] : ""; 143 | $firstlogin = isset($data["firstlogin"]) ? $data["firstlogin"] : 0; 144 | $lastlogin = isset($data["lastlogin"]) ? $data["lastlogin"] : 0; 145 | $hashalg = isset($data["hashalg"]) ? $this->plugin->getHashAlgById($data["hashalg"]) : $this->plugin->getHashAlg(); 146 | if(!$hashalg){ 147 | $hashalg = $this->plugin->getHashAlg(); 148 | } 149 | $hashalgid = $hashalg->getId(); 150 | $params = isset($data["hashparams"]) ? $data["hashparams"] : $this->plugin->encodeParams($this->plugin->cfg["password-hash"]["parameters"]); 151 | if(!isset($data["hashed"])){ 152 | $password = $this->plugin->hashPassword($password, $hashalg, $params . ",player:" . $player); 153 | } 154 | $stmt = $this->db->prepare("INSERT INTO " . $this->cfg->get("table-prefix") . "accounts (user, password, ip, uuid, firstlogin, lastlogin, hashalg, hashparams) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); 155 | $stmt->bind_param("ssssiiss", $p, $password, $ip, $uuid, $firstlogin, $lastlogin, $hashalgid, $params); 156 | if($stmt->execute()){ 157 | $stmt->close(); 158 | return ServerAuth::SUCCESS; 159 | } 160 | $stmt->close(); 161 | return ServerAuth::ERR_GENERIC; 162 | } 163 | 164 | /** 165 | * {@inheritDoc} 166 | * @see \ServerAuth\Providers\Provider::registerAccount() 167 | */ 168 | public function registerAccount(Player $player, $password){ 169 | if(!$this->status) return ServerAuth::ERR_IO; 170 | if($this->plugin->cfg["register"]["max-ip"] > 0){ 171 | if($this->countIP($player->getAddress()) + 1 > $this->plugin->cfg["register"]["max-ip"]){ 172 | return ServerAuth::ERR_MAX_IP; 173 | } 174 | } 175 | return $this->registerAccountRaw($player->getName(), array( 176 | "password" => $password, 177 | "ip" => $player->getAddress(), 178 | "uuid" => $player->getUniqueId()->toString(), 179 | "firstlogin" => $player->getFirstPlayed(), 180 | "lastlogin" => $player->getLastPlayed() 181 | )); 182 | } 183 | 184 | /** 185 | * {@inheritDoc} 186 | * @see \ServerAuth\Providers\Provider::changeAccountPassword() 187 | */ 188 | public function changeAccountPassword($player, $newpassword){ 189 | if(!$this->status) return ServerAuth::ERR_IO; 190 | $p = strtolower($player); 191 | $params = $this->plugin->encodeParams($this->plugin->cfg["password-hash"]["parameters"]); 192 | $hashalgid = $this->plugin->getHashAlg()->getId(); 193 | $stmt = $this->db->prepare("UPDATE " . $this->cfg->get("table-prefix") . "accounts SET password=?, hashalg=?, hashparams=? WHERE user=?"); 194 | $hashpwd = $this->plugin->hashPassword($newpassword, null, $params . ",player:" . $player); 195 | $stmt->bind_param("ssss", $hashpwd, $hashalgid, $params, $p); 196 | if(!$stmt->execute()){ 197 | $stmt->close(); 198 | return ServerAuth::ERR_GENERIC; 199 | } 200 | $stmt->close(); 201 | return ServerAuth::SUCCESS; 202 | } 203 | 204 | /** 205 | * {@inheritDoc} 206 | * @see \ServerAuth\Providers\Provider::isAccountRegistered() 207 | */ 208 | public function isAccountRegistered($player){ 209 | if(!$this->status) return ServerAuth::ERR_IO; 210 | $p = strtolower($player); 211 | $stmt = $this->db->prepare("SELECT user FROM " . $this->cfg->get("table-prefix") . "accounts WHERE user=?"); 212 | $stmt->bind_param("s", $p); 213 | $stmt->execute(); 214 | $stmt->store_result(); 215 | if($stmt->num_rows == 0){ 216 | $stmt->close(); 217 | return false; 218 | } 219 | $stmt->close(); 220 | return true; 221 | } 222 | 223 | /** 224 | * {@inheritDoc} 225 | * @see \ServerAuth\Providers\Provider::unregisterAccount() 226 | */ 227 | public function unregisterAccount($player){ 228 | if(!$this->status) return ServerAuth::ERR_IO; 229 | $p = strtolower($player); 230 | $stmt = $this->db->prepare("DELETE FROM " . $this->cfg->get("table-prefix") . "accounts WHERE user=?"); 231 | $stmt->bind_param("s", $p); 232 | if($stmt->execute()){ 233 | $stmt->close(); 234 | return ServerAuth::SUCCESS; 235 | } 236 | $stmt->close(); 237 | return ServerAuth::ERR_GENERIC; 238 | } 239 | 240 | /** 241 | * {@inheritDoc} 242 | * @see \ServerAuth\Providers\Provider::getAccountData() 243 | */ 244 | public function getAccountData($player){ 245 | if(!$this->status) return ServerAuth::ERR_IO; 246 | $p = strtolower($player); 247 | $data = array(); 248 | $stmt = $this->db->prepare("SELECT password, ip, uuid, firstlogin, lastlogin, hashalg, hashparams FROM " . $this->cfg->get("table-prefix") . "accounts WHERE user=?"); 249 | $stmt->bind_param("s", $p); 250 | if(!$stmt->execute()){ 251 | $stmt->close(); 252 | return ServerAuth::ERR_GENERIC; 253 | } 254 | $stmt->bind_result($data["password"], $data["ip"], $data["uuid"], $data["firstlogin"], $data["lastlogin"], $data["hashalg"], $data["hashparams"]); 255 | $stmt->fetch(); 256 | $stmt->close(); 257 | return $data; 258 | } 259 | 260 | /** 261 | * @internal 262 | * 263 | * Count accounts with the same IP address 264 | * 265 | * @param string $ip 266 | * 267 | * @return int 268 | */ 269 | private function countIP($ip) : int { 270 | $stmt = $this->db->prepare("SELECT * FROM " . $this->cfg->get("table-prefix") . "accounts WHERE ip=?"); 271 | $stmt->bind_param("s", $ip); 272 | $stmt->execute(); 273 | $stmt->store_result(); 274 | $n = $stmt->num_rows; 275 | $stmt->close(); 276 | return $n; 277 | } 278 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Providers/Provider.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 27 | } 28 | 29 | /** 30 | * {@inheritDoc} 31 | * @see \ServerAuth\Providers\Provider::init() 32 | */ 33 | public function init($params = null){ 34 | $this->db = @new \SQLite3($this->plugin->getDataFolder() . "data.db"); 35 | if(!$this->db){ 36 | $this->plugin->getServer()->getLogger()->error($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->replaceVars($this->plugin->chlang["errors"]["sqlite-open-error"], array("ERROR" => $db->lastErrorMsg())))); 37 | return false; 38 | } 39 | if(!$this->db->query("CREATE TABLE IF NOT EXISTS info (version TEXT, data_version TEXT)")){ 40 | $this->plugin->getServer()->getLogger()->error($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["errors"]["sqlite-tables-error"])); 41 | return false; 42 | } 43 | $res = $this->db->query("SELECT version, data_version FROM info"); 44 | if(!$res){ 45 | $this->plugin->getServer()->getLogger()->error($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["errors"]["sqlite-query-error"])); 46 | return false; 47 | } 48 | if(!$res->fetchArray(SQLITE3_NUM)){ 49 | $this->db->query("INSERT INTO info (version, data_version) VALUES (" . $this->plugin->getVersion() . ", " . self::DATA_VERSION . ")"); 50 | }else{ 51 | $this->db->query("UPDATE info SET version='" . $this->plugin->getVersion() . "', data_version='" . self::DATA_VERSION . "' LIMIT 1"); 52 | } 53 | if(!$this->db->query("CREATE TABLE IF NOT EXISTS accounts (user TEXT, password TEXT, ip TEXT, uuid TEXT, firstlogin INT, lastlogin INT, hashalg TEXT, hashparams TEXT)")){ 54 | $this->plugin->getServer()->getLogger()->error($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["errors"]["sqlite-tables-error"])); 55 | return false; 56 | } 57 | return true; 58 | } 59 | 60 | /** 61 | * {@inheritDoc} 62 | * @see \ServerAuth\Providers\Provider::getID() 63 | */ 64 | public function getId() : string { 65 | return "sqlite"; 66 | } 67 | 68 | /** 69 | * {@inheritDoc} 70 | * @see \ServerAuth\Providers\Provider::checkAuthentication() 71 | */ 72 | public function checkAuthentication(Player $player, $password, bool $hashed = false){ 73 | $p = strtolower($player->getName()); 74 | $stmt = $this->db->prepare("SELECT password, hashalg, hashparams FROM accounts WHERE user=:user"); 75 | $stmt->bindValue(":user", $p, SQLITE3_TEXT); 76 | $res = $stmt->execute(); 77 | if(!$res){ 78 | $stmt->close(); 79 | return ServerAuth::ERR_GENERIC; 80 | } 81 | $arr = $res->fetchArray(SQLITE3_NUM); 82 | $stmt->close(); 83 | $stmt_password = $arr[0]; 84 | $stmt_hashalg = $arr[1]; 85 | $stmt_hashparams = $arr[2]; 86 | if(!$hashed){ 87 | $hashalg = $this->plugin->getHashAlgById($stmt_hashalg); 88 | $params = $stmt_hashparams . ",player:" . $player->getName(); 89 | if(!$hashalg){ 90 | $hashalg = $this->plugin->getHashAlg(); 91 | } 92 | $password = $this->plugin->hashPassword($password, $hashalg, $params); 93 | } 94 | if(strcasecmp($stmt_password, $password) == 0){ 95 | $stmt = $this->db->prepare("UPDATE accounts SET ip=:ip, lastlogin=:lastlogin WHERE user=:user"); 96 | $stmt->bindValue(":user", $p, SQLITE3_TEXT); 97 | $stmt->bindValue(":ip", $player->getAddress(), SQLITE3_TEXT); 98 | $stmt->bindValue(":lastlogin", $player->getLastPlayed(), SQLITE3_INTEGER); 99 | if(!$stmt->execute()){ 100 | $stmt->close(); 101 | return ServerAuth::ERR_GENERIC; 102 | } 103 | $stmt->close(); 104 | return ServerAuth::SUCCESS; 105 | } 106 | return ServerAuth::ERR_WRONG_PASS; 107 | } 108 | 109 | /** 110 | * {@inheritDoc} 111 | * @see \ServerAuth\Providers\Provider::registerAccountRaw() 112 | */ 113 | public function registerAccountRaw($player, array $data){ 114 | $p = strtolower($player); 115 | $password = isset($data["password"]) ? $data["password"] : ""; 116 | $ip = isset($data["ip"]) ? $data["ip"] : ""; 117 | $uuid = isset($data["uuid"]) ? $data["uuid"] : ""; 118 | $firstlogin = isset($data["firstlogin"]) ? $data["firstlogin"] : 0; 119 | $lastlogin = isset($data["lastlogin"]) ? $data["lastlogin"] : 0; 120 | $hashalg = isset($data["hashalg"]) ? $this->plugin->getHashAlgById($data["hashalg"]) : $this->plugin->getHashAlg(); 121 | if(!$hashalg){ 122 | $hashalg = $this->plugin->getHashAlg(); 123 | } 124 | $params = isset($data["hashparams"]) ? $data["hashparams"] : $this->plugin->encodeParams($this->plugin->cfg["password-hash"]["parameters"]); 125 | if(!isset($data["hashed"])){ 126 | $password = $this->plugin->hashPassword($password, $hashalg, $params . ",player:" . $player); 127 | } 128 | $stmt = $this->db->prepare("INSERT INTO accounts (user, password, ip, uuid, firstlogin, lastlogin, hashalg, hashparams) VALUES (:user, :password, :ip, :uuid, :firstlogin, :lastlogin, :hashalg, :hashparams)"); 129 | $stmt->bindValue(":user", $p, SQLITE3_TEXT); 130 | $stmt->bindValue(":password", $password, SQLITE3_TEXT); 131 | $stmt->bindValue(":ip", $ip, SQLITE3_TEXT); 132 | $stmt->bindValue(":uuid", $uuid, SQLITE3_TEXT); 133 | $stmt->bindValue(":firstlogin", $firstlogin, SQLITE3_INTEGER); 134 | $stmt->bindValue(":lastlogin", $lastlogin, SQLITE3_INTEGER); 135 | $stmt->bindValue(":hashalg", $hashalg->getId(), SQLITE3_TEXT); 136 | $stmt->bindValue(":hashparams", $params, SQLITE3_TEXT); 137 | if($stmt->execute()){ 138 | $stmt->close(); 139 | return ServerAuth::SUCCESS; 140 | } 141 | $stmt->close(); 142 | return ServerAuth::ERR_GENERIC; 143 | } 144 | 145 | /** 146 | * {@inheritDoc} 147 | * @see \ServerAuth\Providers\Provider::registerAccount() 148 | */ 149 | public function registerAccount(Player $player, $password){ 150 | if($this->plugin->cfg["register"]["max-ip"] > 0){ 151 | if($this->countIP($player->getAddress()) + 1 > $this->plugin->cfg["register"]["max-ip"]){ 152 | return ServerAuth::ERR_MAX_IP; 153 | } 154 | } 155 | return $this->registerAccountRaw($player->getName(), array( 156 | "password" => $password, 157 | "ip" => $player->getAddress(), 158 | "uuid" => $player->getUniqueId()->toString(), 159 | "firstlogin" => $player->getFirstPlayed(), 160 | "lastlogin" => $player->getLastPlayed() 161 | )); 162 | } 163 | 164 | /** 165 | * {@inheritDoc} 166 | * @see \ServerAuth\Providers\Provider::changeAccountPassword() 167 | */ 168 | public function changeAccountPassword($player, $newpassword){ 169 | $p = strtolower($player); 170 | $params = $this->plugin->encodeParams($this->plugin->cfg["password-hash"]["parameters"]); 171 | $stmt = $this->db->prepare("UPDATE accounts SET password=:password, hashalg=:hashalg, hashparams=:hashparams WHERE user=:user"); 172 | $hashpwd = $this->plugin->hashPassword($newpassword, null, $params . ",player:" . $player); 173 | $stmt->bindValue(":user", $p, SQLITE3_TEXT); 174 | $stmt->bindValue(":password", $hashpwd, SQLITE3_TEXT); 175 | $stmt->bindValue(":hashalg", $this->plugin->getHashAlg()->getId(), SQLITE3_TEXT); 176 | $stmt->bindValue(":hashparams", $params, SQLITE3_TEXT); 177 | if(!$stmt->execute()){ 178 | $stmt->close(); 179 | return ServerAuth::ERR_GENERIC; 180 | } 181 | $stmt->close(); 182 | return ServerAuth::SUCCESS; 183 | } 184 | 185 | /** 186 | * {@inheritDoc} 187 | * @see \ServerAuth\Providers\Provider::isAccountRegistered() 188 | */ 189 | public function isAccountRegistered($player){ 190 | $p = strtolower($player); 191 | $stmt = $this->db->prepare("SELECT user FROM accounts WHERE user=:user"); 192 | $stmt->bindValue(":user", $p, SQLITE3_TEXT); 193 | $res = $stmt->execute(); 194 | if(!$res->fetchArray(SQLITE3_NUM)){ 195 | $stmt->close(); 196 | return false; 197 | } 198 | $stmt->close(); 199 | return true; 200 | } 201 | 202 | /** 203 | * {@inheritDoc} 204 | * @see \ServerAuth\Providers\Provider::unregisterAccount() 205 | */ 206 | public function unregisterAccount($player){ 207 | $p = strtolower($player); 208 | $stmt = $this->db->prepare("DELETE FROM accounts WHERE user=:user"); 209 | $stmt->bindValue(":user", $p, SQLITE3_TEXT); 210 | if($stmt->execute()){ 211 | $stmt->close(); 212 | return ServerAuth::SUCCESS; 213 | } 214 | $stmt->close(); 215 | return ServerAuth::ERR_GENERIC; 216 | } 217 | 218 | /** 219 | * {@inheritDoc} 220 | * @see \ServerAuth\Providers\Provider::getAccountData() 221 | */ 222 | public function getAccountData($player){ 223 | $p = strtolower($player); 224 | $data = array(); 225 | $stmt = $this->db->prepare("SELECT password, ip, uuid, firstlogin, lastlogin, hashalg, hashparams FROM accounts WHERE user=:user"); 226 | $stmt->bindValue(":user", $p, SQLITE3_TEXT); 227 | $res = $stmt->execute(); 228 | if(!$res){ 229 | $stmt->close(); 230 | return ServerAuth::ERR_GENERIC; 231 | } 232 | $data = $res->fetchArray(SQLITE3_ASSOC); 233 | $stmt->close(); 234 | return $data; 235 | } 236 | 237 | /** 238 | * @internal 239 | * 240 | * Count accounts with the same IP address 241 | * 242 | * @param string $ip 243 | * 244 | * @return int 245 | */ 246 | private function countIP($ip) : int { 247 | $stmt = $this->db->prepare("SELECT COUNT(*) AS count FROM accounts WHERE ip=:ip"); 248 | $stmt->bindValue(":ip", $ip, SQLITE3_TEXT); 249 | $res = $stmt->execute(); 250 | if(!$res){ 251 | $stmt->close(); 252 | return 0; 253 | } 254 | $row = $res->fetchArray(); 255 | $stmt->close(); 256 | return $row["count"]; 257 | } 258 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Providers/YAMLProvider.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 22 | } 23 | 24 | /** 25 | * {@inheritDoc} 26 | * @see \ServerAuth\Providers\Provider::init() 27 | */ 28 | public function init($params = null){ 29 | @mkdir($this->plugin->getDataFolder() . "users/"); 30 | } 31 | 32 | /** 33 | * {@inheritDoc} 34 | * @see \ServerAuth\Providers\Provider::getID() 35 | */ 36 | public function getId() : string { 37 | return "yaml"; 38 | } 39 | 40 | /** 41 | * {@inheritDoc} 42 | * @see \ServerAuth\Providers\Provider::checkAuthentication() 43 | */ 44 | public function checkAuthentication(Player $player, $password, bool $hashed = false){ 45 | $user = new Config($this->plugin->getDataFolder() . "users/" . strtolower($player->getName() . ".yml"), Config::YAML); 46 | if(!$hashed){ 47 | $hashalg = $this->plugin->getHashAlgById($user->get("hashalg")); 48 | $params = $user->get("hashparams") . ",player:" . $player->getName(); 49 | if(!$hashalg){ 50 | $hashalg = $this->plugin->getHashAlg(); 51 | } 52 | $password = $this->plugin->hashPassword($password, $hashalg, $params); 53 | } 54 | if(strcmp($user->get("password"), $password) == 0){ 55 | $user->set("ip", $player->getAddress()); 56 | $user->set("lastlogin", $player->getLastPlayed()); 57 | return ServerAuth::SUCCESS; 58 | } 59 | return ServerAuth::ERR_WRONG_PASS; 60 | } 61 | 62 | /** 63 | * {@inheritDoc} 64 | * @see \ServerAuth\Providers\Provider::registerAccountRaw() 65 | */ 66 | public function registerAccountRaw($player, array $data){ 67 | $password = isset($data["password"]) ? $data["password"] : ""; 68 | $ip = isset($data["ip"]) ? $data["ip"] : ""; 69 | $uuid = isset($data["uuid"]) ? $data["uuid"] : ""; 70 | $firstlogin = isset($data["firstlogin"]) ? $data["firstlogin"] : 0; 71 | $lastlogin = isset($data["lastlogin"]) ? $data["lastlogin"] : 0; 72 | $hashalg = isset($data["hashalg"]) ? $this->plugin->getHashAlgById($data["hashalg"]) : $this->plugin->getHashAlg(); 73 | if(!$hashalg){ 74 | $hashalg = $this->plugin->getHashAlg(); 75 | } 76 | $params = isset($data["hashparams"]) ? $data["hashparams"] : $this->plugin->encodeParams($this->plugin->cfg["password-hash"]["parameters"]); 77 | $user = new Config($this->plugin->getDataFolder() . "users/" . strtolower($player . ".yml"), Config::YAML); 78 | if(!isset($data["hashed"])){ 79 | $password = $this->plugin->hashPassword($password, $hashalg, $params . ",player:" . $player); 80 | } 81 | $user->set("password", $password); 82 | $user->set("ip", $ip); 83 | $user->set("uuid", $uuid); 84 | $user->set("firstlogin", $firstlogin); 85 | $user->set("lastlogin", $lastlogin); 86 | $user->set("hashalg", $hashalg->getId()); 87 | $user->set("hashparams", $params); 88 | $user->save(); 89 | return ServerAuth::SUCCESS; 90 | } 91 | 92 | /** 93 | * {@inheritDoc} 94 | * @see \ServerAuth\Providers\Provider::registerAccount() 95 | */ 96 | public function registerAccount(Player $player, $password){ 97 | if($this->plugin->cfg["register"]["max-ip"] > 0){ 98 | if($this->countIP($player->getAddress()) + 1 > $this->plugin->cfg["register"]["max-ip"]){ 99 | return ServerAuth::ERR_MAX_IP; 100 | } 101 | } 102 | return $this->registerAccountRaw($player->getName(), array( 103 | "password" => $password, 104 | "ip" => $player->getAddress(), 105 | "uuid" => $player->getUniqueId()->toString(), 106 | "firstlogin" => $player->getFirstPlayed(), 107 | "lastlogin" => $player->getLastPlayed() 108 | )); 109 | } 110 | 111 | /** 112 | * {@inheritDoc} 113 | * @see \ServerAuth\Providers\Provider::changeAccountPassword() 114 | */ 115 | public function changeAccountPassword($player, $newpassword){ 116 | $params = $this->plugin->encodeParams($this->plugin->cfg["password-hash"]["parameters"]); 117 | $user = new Config($this->plugin->getDataFolder() . "users/" . strtolower($player . ".yml"), Config::YAML); 118 | $user->set("hashalg", $this->plugin->getHashAlg()->getId()); 119 | $user->set("hashparams", $params); 120 | $user->set("password", $this->plugin->hashPassword($newpassword, null, $params . ",player:" . $player)); 121 | $user->save(); 122 | return ServerAuth::SUCCESS; 123 | } 124 | 125 | /** 126 | * {@inheritDoc} 127 | * @see \ServerAuth\Providers\Provider::isAccountRegistered() 128 | */ 129 | public function isAccountRegistered($player){ 130 | return file_exists($this->plugin->getDataFolder() . "users/" . strtolower($player . ".yml")); 131 | } 132 | 133 | /** 134 | * {@inheritDoc} 135 | * @see \ServerAuth\Providers\Provider::unregisterAccount() 136 | */ 137 | public function unregisterAccount($player){ 138 | if(@unlink($this->plugin->getDataFolder() . "users/" . strtolower($player . ".yml"))){ 139 | return ServerAuth::SUCCESS; 140 | } 141 | return ServerAuth::ERR_IO; 142 | } 143 | 144 | /** 145 | * {@inheritDoc} 146 | * @see \ServerAuth\Providers\Provider::getAccountData() 147 | */ 148 | public function getAccountData($player){ 149 | return (new Config($this->plugin->getDataFolder() . "users/" . strtolower($player . ".yml"), Config::YAML))->getAll(); 150 | } 151 | 152 | /** 153 | * @internal 154 | * 155 | * Count accounts with the same IP address 156 | * 157 | * @param string $ip 158 | * 159 | * @return int 160 | */ 161 | private function countIP($ip) : int { 162 | $count = 0; 163 | foreach(glob($this->plugin->getDataFolder() . "users/" . "*.yml") as $filename){ 164 | foreach(file($filename) as $fli=>$fl){ 165 | if(strpos($fl, $ip) !== false){ 166 | $count += 1; 167 | } 168 | } 169 | } 170 | return $count; 171 | } 172 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Tasks/MessageTask.php: -------------------------------------------------------------------------------- 1 | plugins = $plugins; 25 | } 26 | 27 | public function onRun(int $tick){ 28 | $plugin = $this->plugins; 29 | foreach($plugin->getServer()->getOnlinePlayers() as $player){ 30 | if(!$plugin->isPlayerAuthenticated($player)){ 31 | if(!isset($this->players[strtolower($player->getName())])){ 32 | $this->players[strtolower($player->getName())]["interval"] = 0; 33 | $this->players[strtolower($player->getName())]["kick"] = 0; 34 | }else{ 35 | $this->players[strtolower($player->getName())]["interval"]++; 36 | $this->players[strtolower($player->getName())]["kick"]++; 37 | } 38 | } 39 | if(!$plugin->isAccountRegistered($player->getName())){ 40 | if($this->players[strtolower($player->getName())]["interval"] >= $plugin->cfg["register"]["message-interval"]){ 41 | if($plugin->isRegisterMessageEnabled()){ 42 | $plugin->callRegisterMessageHandler($plugin, $player); 43 | } 44 | $this->players[strtolower($player->getName())]["interval"] = 0; 45 | } 46 | if($this->players[strtolower($player->getName())]["kick"] >= $plugin->cfg["timeout"]){ 47 | $player->close("", $plugin->translateColors("&", $plugin->chlang["register"]["register-timeout"])); 48 | unset($this->players[strtolower($player->getName())]); 49 | } 50 | }else if(!$plugin->isPlayerAuthenticated($player)){ 51 | if($this->players[strtolower($player->getName())]["interval"] >= $plugin->cfg["login"]["message-interval"]){ 52 | if($plugin->isLoginMessageEnabled()){ 53 | $plugin->callLoginMessageHandler($plugin, $player); 54 | } 55 | $this->players[strtolower($player->getName())]["interval"] = 0; 56 | } 57 | if($this->players[strtolower($player->getName())]["kick"] >= $plugin->cfg["timeout"]){ 58 | $player->close("", $plugin->translateColors("&", $plugin->chlang["login"]["login-timeout"])); 59 | unset($this->players[strtolower($player->getName())]); 60 | } 61 | }else if(isset($this->players[strtolower($player->getName())])){ 62 | unset($this->players[strtolower($player->getName())]); 63 | } 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /ServerAuth/src/ServerAuth/Tasks/MySQLTask.php: -------------------------------------------------------------------------------- 1 | mysqlp = $mysqlp; 30 | $this->plugin = $this->getOwner(); 31 | $this->cfg["host"] = $this->mysqlp->cfg->get("host"); 32 | $this->cfg["user"] = $this->mysqlp->cfg->get("user"); 33 | $this->cfg["password"] = $this->mysqlp->cfg->get("password"); 34 | $this->cfg["port"] = $this->mysqlp->cfg->get("port"); 35 | $this->cfg["database"] = $this->mysqlp->cfg->get("database"); 36 | } 37 | 38 | public function onRun(int $tick){ 39 | if($this->plugin->getDataProvider()->getId() == "mysql"){ 40 | if($this->mysqlp->db){ 41 | if(@!$this->mysqlp->db->ping()){ 42 | $this->mysqlp->db = @new \mysqli($this->cfg["host"], $this->cfg["user"], $this->cfg["password"], null, $this->cfg["port"]); 43 | if(!$this->mysqlp->db->connect_errno){ 44 | $this->mysqlp->db->select_db($this->cfg["database"]); 45 | Server::getInstance()->getLogger()->info($this->plugin->translateColors("&", ServerAuth::PREFIX . $this->plugin->chlang["mysql-restored"])); 46 | $this->mysqlp->status = true; 47 | }else{ 48 | $this->mysqlp->status = false; 49 | } 50 | } 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /ServerAuthAccountManager/ServerAuthWebAPI.php: -------------------------------------------------------------------------------- 1 | host = $host; 74 | $this->port = $port; 75 | $this->username = $username; 76 | $this->password = $password; 77 | $this->dbname = $database; 78 | $this->table_prefix = $table_prefix; 79 | $this->database = @new \mysqli($host, $username, $password, $database, $port); 80 | if($this->database->connect_error){ 81 | $this->status = ServerAuthWebAPI::ERR_MYSQL; 82 | }else{ 83 | $query = "SELECT api_version, version, password_hash FROM " . $table_prefix . "serverauth LIMIT 1"; 84 | if($this->database->query($query)){ 85 | $this->api_version = $this->getDatabase()->query($query)->fetch_assoc()["api_version"]; 86 | $this->version = $this->getDatabase()->query($query)->fetch_assoc()["version"]; 87 | $this->password_hash = $this->getDatabase()->query($query)->fetch_assoc()["password_hash"]; 88 | if($this->api_version > ServerAuthWebAPI::CURRENT_API){ 89 | $this->status = ServerAuthWebAPI::ERR_OUTDATED_WEBAPI; 90 | }elseif($this->api_version < ServerAuthWebAPI::CURRENT_API){ 91 | $this->status = ServerAuthWebAPI::ERR_OUTDATED_PLUGIN; 92 | }else{ 93 | $this->status = ServerAuthWebAPI::SUCCESS; 94 | } 95 | }else{ 96 | $this->status = ServerAuthWebAPI::ERR_MYSQL; 97 | } 98 | } 99 | } 100 | 101 | /** 102 | * Get the current ServerAuthWebAPI instance status 103 | * 104 | * @return int (SUCCESS|ERR_OUTDATED_WEBAPI|ERR_OUTDATED_PLUGIN|ERR_MYSQL) 105 | */ 106 | public function getStatus(){ 107 | return $this->status; 108 | } 109 | 110 | /** 111 | * Get ServerAuth plugin version 112 | * 113 | * @return string|int the current version string on SUCCESS, otherwise the current status 114 | */ 115 | public function getVersion(){ 116 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 117 | return $this->version; 118 | }else{ 119 | return $this->getStatus(); 120 | } 121 | } 122 | 123 | /** 124 | * Get ServerAuth plugin API version 125 | * 126 | * @return string|int the current API version string on SUCCESS, otherwise the current status 127 | */ 128 | public function getAPIVersion(){ 129 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 130 | return $this->api_version; 131 | }else{ 132 | return $this->getStatus(); 133 | } 134 | } 135 | 136 | /** 137 | * Get ServerAuthWebAPI version 138 | * 139 | * @return string 140 | */ 141 | public static function getWebAPIVersion(){ 142 | return ServerAuthWebAPI::WEBAPI_VERSION; 143 | } 144 | 145 | /** 146 | * Get ServerAuth password hash 147 | * 148 | * @return string 149 | */ 150 | public function getPasswordHash(){ 151 | return $this->password_hash; 152 | } 153 | 154 | /** 155 | * Get MySQL host 156 | * 157 | * @return string 158 | */ 159 | public function getHost(){ 160 | return $this->host; 161 | } 162 | 163 | /** 164 | * Get MySQL port 165 | * 166 | * @return int 167 | */ 168 | public function getPort(){ 169 | return $this->port; 170 | } 171 | 172 | /** 173 | * Get MySQL username 174 | * 175 | * @return string 176 | */ 177 | public function getUsername(){ 178 | return $this->username; 179 | } 180 | 181 | /** 182 | * Get MySQL password 183 | * 184 | * @return string 185 | */ 186 | public function getPassword(){ 187 | return $this->password; 188 | } 189 | 190 | /** 191 | * Get MySQL ServerAuth database name 192 | * 193 | * @return string 194 | */ 195 | public function getDatabaseName(){ 196 | return $this->dbname; 197 | } 198 | 199 | /** 200 | * Get ServerAuth MySQL table prefix 201 | * 202 | * @return string 203 | */ 204 | public function getTablePrefix(){ 205 | return $this->table_prefix; 206 | } 207 | 208 | /** 209 | * Get the current MySQL database instance 210 | * 211 | * @return mysqli|boolean 212 | */ 213 | public function getDatabase(){ 214 | if($this->database instanceof \mysqli){ 215 | return $this->database; 216 | }else{ 217 | return false; 218 | } 219 | } 220 | 221 | /** 222 | * Check if a player is registered to ServerAuth 223 | * 224 | * @param string $player 225 | * 226 | * @return boolean|int true or false on SUCCESS, otherwise the current status 227 | */ 228 | public function isPlayerRegistered($player){ 229 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 230 | //Check MySQL connection 231 | if($this->getDatabase() && $this->getDatabase()->ping()){ 232 | $stmt = $this->getDatabase()->prepare("SELECT user, password, ip, firstlogin, lastlogin FROM " . $this->getTablePrefix() . "serverauthdata WHERE user=?"); 233 | $stmt_player = strtolower($player); 234 | $stmt->bind_param("s", $stmt_player); 235 | $stmt->execute(); 236 | $stmt->store_result(); 237 | if($stmt->num_rows == 0){ 238 | $stmt->close(); 239 | return false; 240 | }else{ 241 | $stmt->close(); 242 | return true; 243 | } 244 | }else{ 245 | return ServerAuthWebAPI::ERR_MYSQL; 246 | } 247 | }else{ 248 | return $this->getStatus(); 249 | } 250 | } 251 | 252 | /** 253 | * Get player data 254 | * 255 | * @param string $player 256 | * 257 | * @return array|int the array of player data on SUCCESS, otherwise the current status 258 | */ 259 | public function getPlayerData($player){ 260 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 261 | if($this->isPlayerRegistered($player)){ 262 | //Check MySQL connection 263 | if($this->getDatabase() && $this->getDatabase()->ping()){ 264 | $stmt = $this->getDatabase()->prepare("SELECT user, password, ip, firstlogin, lastlogin FROM " . $this->getTablePrefix() . "serverauthdata WHERE user=?"); 265 | $stmt_player = strtolower($player); 266 | $stmt->bind_param("s", $stmt_player); 267 | if($stmt->execute()){ 268 | $stmt->bind_result($user, $password, $ip, $firstlogin, $lastlogin); 269 | $stmt->fetch(); 270 | $data = array( 271 | "password" => $password, 272 | "ip" => $ip, 273 | "firstlogin" => $firstlogin, 274 | "lastlogin" => $lastlogin 275 | ); 276 | $stmt->close(); 277 | return $data; 278 | }else{ 279 | $stmt->close(); 280 | return ServerAuthWebAPI::ERR_GENERIC; 281 | } 282 | }else{ 283 | return ServerAuthWebAPI::ERR_GENERIC; 284 | } 285 | }else{ 286 | return $this->isPlayerRegistered($player); 287 | } 288 | }else{ 289 | return $this->getStatus(); 290 | } 291 | } 292 | 293 | /** 294 | * Register a player to ServerAuth 295 | * 296 | * @param string $player 297 | * @param string $password 298 | * @param string $ip 299 | * @param int|double $firstlogin (UNIX timestamp) 300 | * @param int|double $lastlogin (UNIX timestamp) 301 | * 302 | * @return int|boolean true on SUCCESS or false if the player is already registered, otherwise the current status 303 | */ 304 | public function registerPlayer($player, $password, $ip, $firstlogin, $lastlogin){ 305 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 306 | if(!$this->isPlayerRegistered($player)){ 307 | //Check MySQL connection 308 | if($this->getDatabase() && $this->getDatabase()->ping()){ 309 | $stmt = $this->getDatabase()->prepare("INSERT INTO " . $this->getTablePrefix() . "serverauthdata (user, password, ip, firstlogin, lastlogin) VALUES (?, ?, ?, ?, ?)"); 310 | $password = hash($this->getPasswordHash(), $password); 311 | $stmt->bind_param("sssss", $player, $password, $ip, $firstlogin, $lastlogin); 312 | if($stmt->execute()){ 313 | $stmt->close(); 314 | return ServerAuthWebAPI::SUCCESS; 315 | }else{ 316 | $stmt->close(); 317 | return ServerAuthWebAPI::ERR_MYSQL; 318 | } 319 | }else{ 320 | return ServerAuthWebAPI::ERR_MYSQL; 321 | } 322 | }else{ 323 | return $this->isPlayerRegistered($player); 324 | } 325 | }else{ 326 | return $this->getStatus(); 327 | } 328 | } 329 | 330 | /** 331 | * Unregister a player 332 | * 333 | * @param string $player 334 | * 335 | * @return int|boolean true on SUCCESS or false if the player is not registered, otherwise the current status 336 | */ 337 | public function unregisterPlayer($player){ 338 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 339 | if($this->isPlayerRegistered($player)){ 340 | //Check MySQL connection 341 | if($this->getDatabase() && $this->getDatabase()->ping()){ 342 | $stmt = $this->getDatabase()->prepare("DELETE FROM " . $this->getTablePrefix() . "serverauthdata WHERE user=?"); 343 | $stmt_player = strtolower($player); 344 | $stmt->bind_param("s", $stmt_player); 345 | if($stmt->execute()){ 346 | $stmt->close(); 347 | return ServerAuthWebAPI::SUCCESS; 348 | }else{ 349 | $stmt->close(); 350 | return ServerAuthWebAPI::ERR_MYSQL; 351 | } 352 | }else{ 353 | return ServerAuthWebAPI::ERR_MYSQL; 354 | } 355 | }else{ 356 | return $this->isPlayerRegistered($player); 357 | } 358 | }else{ 359 | return $this->getStatus(); 360 | } 361 | } 362 | 363 | /** 364 | * Change player password 365 | * 366 | * @param string $player 367 | * @param string $new_password 368 | * 369 | * @return int|boolean true on SUCCESS or false if the player is not registered, otherwise the current status 370 | */ 371 | public function changePlayerPassword($player, $new_password){ 372 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 373 | if($this->isPlayerRegistered($player)){ 374 | //Check MySQL connection 375 | if($this->getDatabase() && $this->getDatabase()->ping()){ 376 | $stmt = $this->getDatabase()->prepare("UPDATE " . $this->getTablePrefix() . "serverauthdata SET password=? WHERE user=?"); 377 | $stmt_password = hash($this->getPasswordHash(), $new_password); 378 | $stmt_player = strtolower($player); 379 | $stmt->bind_param("ss", $stmt_password, $stmt_player); 380 | if($stmt->execute()){ 381 | $stmt->close(); 382 | return ServerAuthWebAPI::SUCCESS; 383 | }else{ 384 | $stmt->close(); 385 | return ServerAuthWebAPI::ERR_MYSQL; 386 | } 387 | } 388 | }else{ 389 | return $this->isPlayerRegistered($player); 390 | } 391 | }else{ 392 | return $this->getStatus(); 393 | } 394 | } 395 | } 396 | -------------------------------------------------------------------------------- /ServerAuthAccountManager/account.php: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | ServerAuth Account Manager 22 | 23 | getStatus(); 39 | } 40 | if(isset($_GET["action"]) && strtolower($_GET["action"]) == "logout"){ 41 | session_destroy(); 42 | header("Location: login.php"); 43 | } 44 | ?> 45 | 46 | 53 |
54 |
55 |
56 | 59 |
60 |
61 |
Warning
62 |
63 |
64 |
Registration disabled
65 |
66 |
67 | 71 |
72 |
73 |
MySQL Error
74 |
75 |
76 | MySQL Error: " . $api->getDatabase()->connect_error . "
"; 78 | ?> 79 |
80 |
81 | 84 |
85 |
86 |
Outdated Plugin Error
87 |
88 |
89 |
ServerAuth plugin is outdated. Please update it.
90 |
91 |
92 | 95 |
96 |
97 |
Outdated WebAPI Error
98 |
99 |
100 |
ServerAuth Web API is outdated. Please update it.
101 |
102 |
103 | isPlayerRegistered($_SESSION["login"])){ 106 | session_destroy(); 107 | header("Location: index.php"); 108 | } 109 | if($config["allow-show-info"]){ 110 | ?> 111 |
112 |
113 |
Account Info
114 |
115 |
116 | Username: " . $_SESSION["login"] . ""; 118 | echo "

IP Address: " . $api->getPlayerData($_SESSION["login"])["ip"] . "

"; 119 | echo "

Registration date: " . date("d/m/Y H:i:s", $api->getPlayerData($_SESSION["login"])["firstlogin"] / 1000) . "

"; 120 | echo "

Last login: " . date("d/m/Y H:i:s", $api->getPlayerData($_SESSION["login"])["lastlogin"] / 1000) . "

"; 121 | ?> 122 |
123 |
124 | 127 |
128 | getPlayerData($_SESSION["login"])["password"] == hash($api->getPasswordHash(), $_POST["old-password"])){ 131 | $old_password = true; 132 | if($_POST["new-password"] == $_POST["cnew-password"]){ 133 | if(preg_match('/\s/', $_POST["new-password"]) == 0){ 134 | if(strlen($_POST["new-password"]) <= $config["min-password-length"]){ 135 | $new_password = 2; 136 | }elseif(strlen($_POST["new-password"]) >= $config["max-password-length"]){ 137 | $new_password = 3; 138 | }else{ 139 | $new_password = 4; 140 | $api->changePlayerPassword($_SESSION["login"], $_POST["new-password"]); 141 | } 142 | }else{ 143 | $new_password = 1; 144 | } 145 | }else{ 146 | $new_password = 0; 147 | } 148 | }else{ 149 | $old_password = false; 150 | } 151 | } 152 | ?> 153 |
154 |
Change Password
155 |
156 |
157 |
158 |
159 |
160 | 161 |
162 |
163 | 164 | The password doesn't match the old password
"; 168 | } 169 | } 170 | ?> 171 |
172 |
173 |
174 |
175 |
176 |
177 | 178 |
179 |
180 | 181 |
182 |
183 |
184 |
185 | 186 |
187 |
188 | 189 | Password doesn't match confirmation
"; 193 | }elseif($new_password == 1){ 194 | echo "
Password can't contain spaces
"; 195 | }elseif($new_password == 2){ 196 | echo "
Password too short
"; 197 | }elseif($new_password == 3){ 198 | echo "
Password too long
"; 199 | }elseif($new_password == 4){ 200 | echo "
Password changed!
"; 201 | } 202 | } 203 | ?> 204 |
205 |
206 |
207 | 208 |
209 | 210 | 211 | 212 |
213 | unregisterPlayer($_SESSION["login"]); 216 | session_destroy(); 217 | header("Location: index.php"); 218 | } 219 | ?> 220 |
221 |
Delete Account
222 |
223 | 226 |
227 | 231 |
232 |

ServerAuth Account Manager v1.0.

233 |

© 2015 EvolSoft. Licensed under MIT.

234 |
235 | 236 | 237 | 238 | 239 | -------------------------------------------------------------------------------- /ServerAuthAccountManager/config.php: -------------------------------------------------------------------------------- 1 | ServerAuth Account Manager

ServerAuth Account Manager is a simple web script that let you to fully manage your ServerAuth accounts.
With ServerAuth Account Manager you can:


  • Manage all registered accounts (admin-only)
  • Show your ServerAuth account info
  • Change your account password
  • Delete your account
"; 20 | //MySQL host of ServerAuth plugin data 21 | $config["db_host"] = "host"; 22 | //MySQL port (default 3306) 23 | $config["db_port"] = 3306; 24 | //MySQL username 25 | $config["db_username"] = "username"; 26 | //MySQL password (you can leave it blank if your database doesn't need password) 27 | $config["db_password"] = ""; 28 | //MySQL ServerAuth database (it must be the one where you stored your ServerAuth plugin data) 29 | $config["db_database"] = "serverauth"; 30 | //ServerAuth table prefix (the same of your ServerAuth plugin config) 31 | $config["db_table_prefix"] = "srvauth_"; 32 | ?> -------------------------------------------------------------------------------- /ServerAuthAccountManager/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EvolSoft/ServerAuth/7c07b43808727ec7fc7839f88c6413b0ed2a304c/ServerAuthAccountManager/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /ServerAuthAccountManager/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EvolSoft/ServerAuth/7c07b43808727ec7fc7839f88c6413b0ed2a304c/ServerAuthAccountManager/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /ServerAuthAccountManager/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EvolSoft/ServerAuth/7c07b43808727ec7fc7839f88c6413b0ed2a304c/ServerAuthAccountManager/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /ServerAuthAccountManager/index.php: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | ServerAuth Account Manager 22 | 23 | 32 | 33 | 53 |
54 |
55 |
56 | You haven't set up admin data yet! It's recommended to do it immediately.

Click here to do this now.
"; 59 | } 60 | if(!$cfg_status){ 61 | echo "
ServerAuth Account Manager is not configured yet.

Please create a configuration file or rename the existing one.
"; 62 | //Default box 63 | echo "

ServerAuth Account Manager


ServerAuth Account Manager is a simple web script that let you to fully manage your ServerAuth accounts.
With ServerAuth Account Manager you can:


  • Manage all registered accounts (admin-only)
  • Show your ServerAuth account info
  • Change your account password
  • Delete your account
"; 64 | }else{ 65 | ?> 66 |
67 | 70 |
71 |

ServerAuth Account Manager v1.0. Register an account"; } ?>

72 |

© 2015 EvolSoft. Licensed under MIT.

73 |
74 |
75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /ServerAuthAccountManager/js/xweb.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * xWeb (v1.0) by EvolSoft 3 | * Developer: EvolSoft (Flavius12) 4 | * Website: http://www.evolsoft.tk 5 | * Date: 11/05/2015 06:15 PM (UTC) 6 | * Copyright & License: (C) 2015 EvolSoft 7 | * Licensed under MIT (https://github.com/EvolSoft/xWeb/blob/master/LICENSE) 8 | */ 9 | 10 | function changeTitle(e){checkElement("title")?$("title").text(e):$("head").append(""+e+"")}function checkElement(e){return $(e).length}function getVersion(){return XWEB_VERSION}function pxtoint(e){return parseInt(e.replace("px",""))}function initializeImageSlider(e){$(e).hasClass("image-slider")&&(ImageItem=$(e).find(".image-slider-images").children(".image-slider-item"),activeImageItem=$(e).find(".image-slider-images").children(".image-slider-item.active"),$(e).trigger("image-slider.initialize"),activeImageItem.length>0?(activeImageItem.css("margin-left","0%"),activeImageItem.prevAll().css("margin-left","-100%"),activeImageItem.nextAll().css("margin-left","100%"),$(e).find(".image-slider-navigation").find("[img-id='"+activeImageItem.attr("img-item")+"']").addClass("active")):(ImageItem.first().addClass("active"),ImageItem.nextAll().css("margin-left","100%"),$(e).find(".image-slider-navigation").find("[img-id='"+ImageItem.attr("img-item")+"']").addClass("active")))}function slideLeft(e){$(e).hasClass("image-slider")&&(parent=$(e).find(".image-slider-images").children(".image-slider-item"),activeParent=$(e).find(".image-slider-images").children(".image-slider-item.active"),$(e).trigger("image-slider.slide"),activeParent.prev().length>0?(parent.removeClass("active"),activeParent.prev().addClass("active"),activeParent.css("margin-left","0%"),activeParent.prev().css("margin-left","-100%"),activeParent.animate({"margin-left":"100%"},200),activeParent.prev().animate({"margin-left":"0%"},200),$(e).find(".image-slider-navigation").children("li").removeClass("active"),$(e).find(".image-slider-navigation").find("[img-id='"+activeParent.prev().attr("img-item")+"']").addClass("active")):(parent.removeClass("active"),parent.last().addClass("active"),activeParent.css("margin-left","0%"),parent.last().css("margin-left","-100%"),activeParent.animate({"margin-left":"100%"},200),parent.last().animate({"margin-left":"0%"},200),$(e).find(".image-slider-navigation").children("li").removeClass("active"),$(e).find(".image-slider-navigation").find("[img-id='"+parent.last().attr("img-item")+"']").addClass("active")))}function slideLeftPos(e,t){$(e).hasClass("image-slider")&&$(e).find(".image-slider-images").children("[img-item='"+t+"']")&&(parent=$(e).find(".image-slider-images").children(".image-slider-item"),parent.removeClass("active"),$(e).find(".image-slider-images").children("[img-item='"+t+"']").addClass("active"),initializeImageSlider(e),activeParent=$(e).find(".image-slider-images").children(".image-slider-item.active"),$(e).trigger("image-slider.slide"),activeParent.prev().length>0?(activeParent.prev().css("margin-left","0%"),activeParent.css("margin-left","100%"),activeParent.animate({"margin-left":"0%"},200),activeParent.prev().animate({"margin-left":"-100%"},200),$(e).find(".image-slider-navigation").children("li").removeClass("active"),$(e).find(".image-slider-navigation").find("[img-id='"+activeParent.attr("img-item")+"']").addClass("active")):(activeParent.css("margin-left","100%"),parent.last().css("margin-left","0%"),activeParent.animate({"margin-left":"0%"},200),parent.last().animate({"margin-left":"-100%"},200),$(e).find(".image-slider-navigation").children("li").removeClass("active"),$(e).find(".image-slider-navigation").find("[img-id='"+activeParent.attr("img-item")+"']").addClass("active")))}function slideRight(e){$(e).hasClass("image-slider")&&(parent=$(e).find(".image-slider-images").children(".image-slider-item"),activeParent=$(e).find(".image-slider-images").children(".image-slider-item.active"),$(e).trigger("image-slider.slide"),activeParent.next().length>0?(parent.removeClass("active"),activeParent.next().addClass("active"),activeParent.css("margin-left","0%"),activeParent.next().css("margin-left","100%"),activeParent.animate({"margin-left":"-100%"},200),activeParent.next().animate({"margin-left":"0%"},200),$(e).find(".image-slider-navigation").children("li").removeClass("active"),$(e).find(".image-slider-navigation").find("[img-id='"+activeParent.next().attr("img-item")+"']").addClass("active")):(parent.removeClass("active"),parent.first().addClass("active"),activeParent.css("margin-left","0%"),parent.first().css("margin-left","100%"),activeParent.animate({"margin-left":"-100%"},200),parent.first().animate({"margin-left":"0%"},200),$(e).find(".image-slider-navigation").children("li").removeClass("active"),$(e).find(".image-slider-navigation").find("[img-id='"+parent.first().attr("img-item")+"']").addClass("active")))}function slideRightPos(e,t){$(e).hasClass("image-slider")&&$(e).find(".image-slider-images").children("[img-item='"+t+"']")&&(parent=$(e).find(".image-slider-images").children(".image-slider-item"),parent.removeClass("active"),$(e).find(".image-slider-images").children("[img-item='"+t+"']").addClass("active"),initializeImageSlider(e),activeParent=$(e).find(".image-slider-images").children(".image-slider-item.active"),$(e).trigger("image-slider.slide"),activeParent.next().length>0?(activeParent.next().css("margin-left","0%"),activeParent.css("margin-left","-100%"),activeParent.animate({"margin-left":"0%"},200),activeParent.next().animate({"margin-left":"100%"},200),$(e).find(".image-slider-navigation").children("li").removeClass("active"),$(e).find(".image-slider-navigation").find("[img-id='"+activeParent.attr("img-item")+"']").addClass("active")):(activeParent.css("margin-left","-100%"),parent.first().css("margin-left","0%"),activeParent.animate({"margin-left":"0%"},200),parent.first().animate({"margin-left":"100%"},200),$(e).find(".image-slider-navigation").children("li").removeClass("active"),$(e).find(".image-slider-navigation").find("[img-id='"+activeParent.attr("img-item")+"']").addClass("active")))}function toggleModal(e){$(e).hasClass("modal")&&($(e).toggleClass("modal-open"),$(e).trigger($(e).hasClass("modal-open")?"modal.open":"modal.close"))}function closeModal(e){$(e).hasClass("modal")&&($(e).trigger("modal.close"),$(e).removeClass("modal-open"),$(e).addClass("closing"),$(e).on("transitionend",function(){$(this).removeClass("closing")}))}function getRSliderVal(e){return $(e).hasClass("slider")?(percentage=percent=Math.round(100*pxtoint($(e).find(".slider-handle").css("left"))/pxtoint($(e).css("width"))),percentage):null}var XWEB_VERSION="1.0";$(document).on("click",".close",function(){$(this).parent().hasClass("alert")&&($(this).parent().trigger("alert.close"),$(this).parent().remove())}),$(document).on("click","[alert-close]",function(){$(this).parent().hasClass("alert")&&($(this).parent().trigger("alert.close"),$(this).parent().remove())}),$(document).ready(function(){$(".image-slider").each(function(){initializeImageSlider(this)}),setInterval(function(){$("[auto-scroll]").each(function(){$(this).hasClass("image-slider")&&slideRight(this)})},4e3)}),$(document).on("click",".image-slider-control-left",function(){slideLeft($(event.target).parent())}),$(document).on("click",".image-slider-control-right",function(){slideRight($(event.target).parent())}),$(document).on("click",".image-slider > .image-slider-navigation > li",function(){$(event.target).hasClass("active")||($(event.target).nextAll().hasClass("active")?slideRightPos($(event.target).parent().parent(),$(this).attr("img-id")):slideLeftPos($(event.target).parent().parent(),$(this).attr("img-id")))}),$(document).on("click",function(){var e=event.target;$(e).parent().hasClass("open")&&$(e).parent().hasClass("menu-group")?($(".menu-group").removeClass("open"),$(e).parent().trigger("menu.close")):$(e).parent().hasClass("menu-group")&&""==$(e).attr("openmenu")?($(".menu-group").removeClass("open"),$(e).parent().toggleClass("open"),$(e).parent().trigger("menu.open")):($(".menu-group").each(function(){$(this).hasClass("open")&&$(this).trigger("menu.close")}),$(".menu-group").removeClass("open"))}),$(document).on("click",".close",function(){$(this).parent().parent().hasClass("modal")&&closeModal($(this).parent().parent())}),$(document).on("click",".modal-background",function(){$(this).parent().hasClass("modal")&&("false"==$(this).parent().attr("static")||"undefined"==typeof $(this).parent().attr("static"))&&closeModal($(this).parent())}),$(document).on("click",".navbar-toggle",function(){$(this).parent().hasClass("navbar")&&$(this).parent().find(".navbar-links").toggleClass("open")});var click=!1,current=null,pos=0;$(document).on("mousedown",function(){click=!0,current=event.target}),$(document).on("mouseup",function(){click=!1,current=null}),$(document).on("mousemove",function(e){click&&null!=current&&"slider-handle"==$(current).attr("class")&&(fixedpos=e.pageX-$(current).parent().offset().left,percent=Math.round(100*fixedpos/pxtoint($(current).parent().css("width"))),e.pageX>pos?fixedpos>=0&&fixedpos<=$(current).parent().width()&&($(current).css("left",+percent+"%"),$(current).parent().find(".slider-progress").css("width",percent+1+"%"),$(current).parent().trigger("slider.change")):fixedpos>=0&&fixedpos<=$(current).parent().width()&&($(current).css("left",+percent+"%"),$(current).parent().find(".slider-progress").css("width",percent+1+"%"),$(current).parent().trigger("slider.change"))),pos=e.pageX}),$(document).on("click","a",function(){$(this).parent().parent().hasClass("tabs")&&($(this).parent().parent().find("li").removeClass("active"),$(this).parent().addClass("active"),$(this).parent().parent().parent().find(".tab-content").css("display","none"),$(this).parent().parent().parent().find("[tab-id="+$(event.target).attr("open-tab")+"]").hasClass("tab-content")&&($(this).parent().parent().parent().find("[tab-id="+$(event.target).attr("open-tab")+"]").css("display","block"),$(this).parent().parent().parent().find("[tab-id="+$(event.target).attr("open-tab")+"]").trigger("tab.open")))}),$(document).on("mouseover",function(){$("[tooltip]").hover(function(){tooltip=$("[tooltip-id='"+$(event.target).attr("tooltip")+"']"),$(event.target).trigger("tooltip.show",[tooltip]),$(tooltip).css("visibility","visible"),$(tooltip).css("opacity","0.8"),$(tooltip).hasClass("tooltip-top")?($(tooltip).css("top",$(event.target).position().top-($(tooltip).outerHeight(!0)-pxtoint($(event.target).css("marginTop")))),$(tooltip).css("left",$(event.target).position().left+($(event.target).outerWidth(!0)/2-$(tooltip).outerWidth(!0)/2))):$(tooltip).hasClass("tooltip-bottom")?($(tooltip).css("top",$(event.target).position().top+($(event.target).outerHeight(!0)-pxtoint($(event.target).css("marginBottom")))),$(tooltip).css("left",$(event.target).position().left+($(event.target).outerWidth(!0)/2-$(tooltip).outerWidth(!0)/2))):$(tooltip).hasClass("tooltip-left")?($(tooltip).css("top",$(event.target).position().top+($(event.target).outerHeight(!0)/2-$(tooltip).outerHeight(!0)/2)),$(tooltip).css("left",$(event.target).position().left+pxtoint($(event.target).css("marginLeft"))-($(tooltip).outerWidth()+pxtoint($(tooltip).css("padding"))))):$(tooltip).hasClass("tooltip-right")&&($(tooltip).css("top",$(event.target).position().top+($(event.target).outerHeight(!0)/2-$(tooltip).outerHeight(!0)/2)),$(tooltip).css("left",$(event.target).position().left+$(event.target).outerWidth(!0)-pxtoint($(event.target).css("marginRight"))+pxtoint($(tooltip).css("padding"))))},function(){tooltip=$("[tooltip-id='"+$(event.target).attr("tooltip")+"']"),$(event.target).trigger("tooltip.hide",[tooltip]),$(tooltip).css("visibility","hidden"),$(tooltip).css("opacity","0")})}); -------------------------------------------------------------------------------- /ServerAuthAccountManager/login.php: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | ServerAuth Account Manager 22 | 23 | getStatus(); 39 | } 40 | ?> 41 | 42 | 51 |
52 |
53 |
54 |
55 |
56 |
57 | Warning
"; 60 | }else{ 61 | if($api_status == ServerAuthWebAPI::ERR_MYSQL){ 62 | echo "
MySQL Error
"; 63 | }elseif($api_status == ServerAuthWebAPI::ERR_OUTDATED_PLUGIN){ 64 | echo "
Outdated Plugin Error
"; 65 | }elseif($api_status == ServerAuthWebAPI::ERR_OUTDATED_WEBAPI){ 66 | echo "
Outdated WebAPI Error
"; 67 | }else{ 68 | echo "
Login
"; 69 | } 70 | } 71 | ?> 72 |
73 |
74 | ServerAuth Account Manager is not configured yet.

Please create a configuration file or rename the existing one.
"; 77 | }else{ 78 | if($api_status == ServerAuthWebAPI::ERR_MYSQL){ 79 | echo "
MySQL Error: " . $api->getDatabase()->connect_error . "
"; 80 | }elseif($api_status == ServerAuthWebAPI::ERR_OUTDATED_PLUGIN){ 81 | echo "
ServerAuth plugin is outdated. Please update it.
"; 82 | }elseif($api_status == ServerAuthWebAPI::ERR_OUTDATED_WEBAPI){ 83 | echo "
ServerAuth Web API is outdated. Please update it.
"; 84 | }else{ 85 | ?> 86 |
87 |
88 |
89 | 90 |
91 |
92 | 93 |
94 |
95 |
96 |
97 | 98 |
99 |
100 | 101 | isPlayerRegistered($_POST["username"]) && $api->getPlayerData($_POST["username"])["password"] == hash($api->getPasswordHash(), $_POST["password"])){ 104 | $_SESSION["login"] = $_POST["username"]; 105 | header("Location: account.php"); 106 | }else{ 107 | echo "

Wrong username or password

"; 108 | } 109 | } 110 | ?> 111 |
112 |
113 |
114 |
115 | 116 |
117 |
118 | 122 |
123 |
124 |
125 |

ServerAuth Account Manager v1.0. Register an account"; } ?>

126 |

© 2015 EvolSoft. Licensed under MIT.

127 |
128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /ServerAuthAccountManager/register.php: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | ServerAuth Account Manager 22 | 23 | getStatus(); 39 | } 40 | ?> 41 | 42 | 49 |
50 |
51 |
52 | 55 |
56 |
57 |
Warning
58 |
59 |
60 |
61 |
62 | 66 |
67 |
68 |
Registration disabled
69 |
70 |
71 |
Registration disabled
72 |
73 |
74 | 77 |
78 |
79 |
MySQL Error
80 |
81 |
82 | MySQL Error: " . $api->getDatabase()->connect_error . "
"; 84 | ?> 85 |
86 |
87 | 90 |
91 |
92 |
Outdated Plugin Error
93 |
94 |
95 |
ServerAuth plugin is outdated. Please update it.
96 |
97 |
98 | 101 |
102 |
103 |
Outdated WebAPI Error
104 |
105 |
106 |
ServerAuth Web API is outdated. Please update it.
107 |
108 |
109 | 112 |
113 |
114 |
Register
115 |
116 |
117 |
118 |
119 |
120 | 121 |
122 |
123 | 124 |
125 |
126 |
127 |
128 |
129 | 130 |
131 |
132 | 133 |
134 |
135 |
136 |
137 | 138 |
139 |
140 | 141 | isPlayerRegistered($_POST["username"])){ 144 | if($_POST["password"] == $_POST["cpassword"]){ 145 | if(preg_match('/\s/', $_POST["password"]) == 0){ 146 | if(strlen($_POST["password"]) <= $config["min-password-length"]){ 147 | echo "
Password too short
"; 148 | }elseif(strlen($_POST["password"]) >= $config["max-password-length"]){ 149 | echo "
Password too long
"; 150 | }else{ 151 | $api->registerPlayer($_POST["username"], $_POST["password"], $_SERVER['REMOTE_ADDR'], time() * 1000, time() * 1000); 152 | $_SESSION["login"] = $_POST["username"]; 153 | header("Location: account.php"); 154 | } 155 | }else{ 156 | echo "
Password can't contain spaces
"; 157 | } 158 | }else{ 159 | echo "
Password doesn't match confirmation
"; 160 | } 161 | }else{ 162 | echo "

Username already registered

"; 163 | } 164 | } 165 | ?> 166 |
167 |
168 |
169 |
170 | 171 |
172 |
173 |
174 |
175 | 179 |
180 |

ServerAuth Account Manager v1.0.

181 |

© 2015 EvolSoft. Licensed under MIT.

182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /ServerAuthWebAPI/ServerAuthWebAPI.php: -------------------------------------------------------------------------------- 1 | host = $host; 74 | $this->port = $port; 75 | $this->username = $username; 76 | $this->password = $password; 77 | $this->dbname = $database; 78 | $this->table_prefix = $table_prefix; 79 | $this->database = @new \mysqli($host, $username, $password, $database, $port); 80 | if($this->database->connect_error){ 81 | $this->status = ServerAuthWebAPI::ERR_MYSQL; 82 | }else{ 83 | $query = "SELECT api_version, version, password_hash FROM " . $table_prefix . "serverauth LIMIT 1"; 84 | if($this->database->query($query)){ 85 | $this->api_version = $this->getDatabase()->query($query)->fetch_assoc()["api_version"]; 86 | $this->version = $this->getDatabase()->query($query)->fetch_assoc()["version"]; 87 | $this->password_hash = $this->getDatabase()->query($query)->fetch_assoc()["password_hash"]; 88 | if($this->api_version > ServerAuthWebAPI::CURRENT_API){ 89 | $this->status = ServerAuthWebAPI::ERR_OUTDATED_WEBAPI; 90 | }elseif($this->api_version < ServerAuthWebAPI::CURRENT_API){ 91 | $this->status = ServerAuthWebAPI::ERR_OUTDATED_PLUGIN; 92 | }else{ 93 | $this->status = ServerAuthWebAPI::SUCCESS; 94 | } 95 | }else{ 96 | $this->status = ServerAuthWebAPI::ERR_MYSQL; 97 | } 98 | } 99 | } 100 | 101 | /** 102 | * Get the current ServerAuthWebAPI instance status 103 | * 104 | * @return int (SUCCESS|ERR_OUTDATED_WEBAPI|ERR_OUTDATED_PLUGIN|ERR_MYSQL) 105 | */ 106 | public function getStatus(){ 107 | return $this->status; 108 | } 109 | 110 | /** 111 | * Get ServerAuth plugin version 112 | * 113 | * @return string|int the current version string on SUCCESS, otherwise the current status 114 | */ 115 | public function getVersion(){ 116 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 117 | return $this->version; 118 | }else{ 119 | return $this->getStatus(); 120 | } 121 | } 122 | 123 | /** 124 | * Get ServerAuth plugin API version 125 | * 126 | * @return string|int the current API version string on SUCCESS, otherwise the current status 127 | */ 128 | public function getAPIVersion(){ 129 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 130 | return $this->api_version; 131 | }else{ 132 | return $this->getStatus(); 133 | } 134 | } 135 | 136 | /** 137 | * Get ServerAuthWebAPI version 138 | * 139 | * @return string 140 | */ 141 | public static function getWebAPIVersion(){ 142 | return ServerAuthWebAPI::WEBAPI_VERSION; 143 | } 144 | 145 | /** 146 | * Get ServerAuth password hash 147 | * 148 | * @return string 149 | */ 150 | public function getPasswordHash(){ 151 | return $this->password_hash; 152 | } 153 | 154 | /** 155 | * Get MySQL host 156 | * 157 | * @return string 158 | */ 159 | public function getHost(){ 160 | return $this->host; 161 | } 162 | 163 | /** 164 | * Get MySQL port 165 | * 166 | * @return int 167 | */ 168 | public function getPort(){ 169 | return $this->port; 170 | } 171 | 172 | /** 173 | * Get MySQL username 174 | * 175 | * @return string 176 | */ 177 | public function getUsername(){ 178 | return $this->username; 179 | } 180 | 181 | /** 182 | * Get MySQL password 183 | * 184 | * @return string 185 | */ 186 | public function getPassword(){ 187 | return $this->password; 188 | } 189 | 190 | /** 191 | * Get MySQL ServerAuth database name 192 | * 193 | * @return string 194 | */ 195 | public function getDatabaseName(){ 196 | return $this->dbname; 197 | } 198 | 199 | /** 200 | * Get ServerAuth MySQL table prefix 201 | * 202 | * @return string 203 | */ 204 | public function getTablePrefix(){ 205 | return $this->table_prefix; 206 | } 207 | 208 | /** 209 | * Get the current MySQL database instance 210 | * 211 | * @return mysqli|boolean 212 | */ 213 | public function getDatabase(){ 214 | if($this->database instanceof \mysqli){ 215 | return $this->database; 216 | }else{ 217 | return false; 218 | } 219 | } 220 | 221 | /** 222 | * Check if a player is registered to ServerAuth 223 | * 224 | * @param string $player 225 | * 226 | * @return boolean|int true or false on SUCCESS, otherwise the current status 227 | */ 228 | public function isPlayerRegistered($player){ 229 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 230 | //Check MySQL connection 231 | if($this->getDatabase() && $this->getDatabase()->ping()){ 232 | $stmt = $this->getDatabase()->prepare("SELECT user, password, ip, firstlogin, lastlogin FROM " . $this->getTablePrefix() . "serverauthdata WHERE user=?"); 233 | $stmt_player = strtolower($player); 234 | $stmt->bind_param("s", $stmt_player); 235 | $stmt->execute(); 236 | $stmt->store_result(); 237 | if($stmt->num_rows == 0){ 238 | $stmt->close(); 239 | return false; 240 | }else{ 241 | $stmt->close(); 242 | return true; 243 | } 244 | }else{ 245 | return ServerAuthWebAPI::ERR_MYSQL; 246 | } 247 | }else{ 248 | return $this->getStatus(); 249 | } 250 | } 251 | 252 | /** 253 | * Get player data 254 | * 255 | * @param string $player 256 | * 257 | * @return array|int the array of player data on SUCCESS, otherwise the current status 258 | */ 259 | public function getPlayerData($player){ 260 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 261 | if($this->isPlayerRegistered($player)){ 262 | //Check MySQL connection 263 | if($this->getDatabase() && $this->getDatabase()->ping()){ 264 | $stmt = $this->getDatabase()->prepare("SELECT user, password, ip, firstlogin, lastlogin FROM " . $this->getTablePrefix() . "serverauthdata WHERE user=?"); 265 | $stmt_player = strtolower($player); 266 | $stmt->bind_param("s", $stmt_player); 267 | if($stmt->execute()){ 268 | $stmt->bind_result($user, $password, $ip, $firstlogin, $lastlogin); 269 | $stmt->fetch(); 270 | $data = array( 271 | "password" => $password, 272 | "ip" => $ip, 273 | "firstlogin" => $firstlogin, 274 | "lastlogin" => $lastlogin 275 | ); 276 | $stmt->close(); 277 | return $data; 278 | }else{ 279 | $stmt->close(); 280 | return ServerAuthWebAPI::ERR_GENERIC; 281 | } 282 | }else{ 283 | return ServerAuthWebAPI::ERR_GENERIC; 284 | } 285 | }else{ 286 | return $this->isPlayerRegistered($player); 287 | } 288 | }else{ 289 | return $this->getStatus(); 290 | } 291 | } 292 | 293 | /** 294 | * Register a player to ServerAuth 295 | * 296 | * @param string $player 297 | * @param string $password 298 | * @param string $ip 299 | * @param int|double $firstlogin (UNIX timestamp) 300 | * @param int|double $lastlogin (UNIX timestamp) 301 | * 302 | * @return int|boolean true on SUCCESS or false if the player is already registered, otherwise the current status 303 | */ 304 | public function registerPlayer($player, $password, $ip, $firstlogin, $lastlogin){ 305 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 306 | if(!$this->isPlayerRegistered($player)){ 307 | //Check MySQL connection 308 | if($this->getDatabase() && $this->getDatabase()->ping()){ 309 | $stmt = $this->getDatabase()->prepare("INSERT INTO " . $this->getTablePrefix() . "serverauthdata (user, password, ip, firstlogin, lastlogin) VALUES (?, ?, ?, ?, ?)"); 310 | $password = hash($this->getPasswordHash(), $password); 311 | $stmt->bind_param("sssss", $player, $password, $ip, $firstlogin, $lastlogin); 312 | if($stmt->execute()){ 313 | $stmt->close(); 314 | return ServerAuthWebAPI::SUCCESS; 315 | }else{ 316 | $stmt->close(); 317 | return ServerAuthWebAPI::ERR_MYSQL; 318 | } 319 | }else{ 320 | return ServerAuthWebAPI::ERR_MYSQL; 321 | } 322 | }else{ 323 | return $this->isPlayerRegistered($player); 324 | } 325 | }else{ 326 | return $this->getStatus(); 327 | } 328 | } 329 | 330 | /** 331 | * Unregister a player 332 | * 333 | * @param string $player 334 | * 335 | * @return int|boolean true on SUCCESS or false if the player is not registered, otherwise the current status 336 | */ 337 | public function unregisterPlayer($player){ 338 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 339 | if($this->isPlayerRegistered($player)){ 340 | //Check MySQL connection 341 | if($this->getDatabase() && $this->getDatabase()->ping()){ 342 | $stmt = $this->getDatabase()->prepare("DELETE FROM " . $this->getTablePrefix() . "serverauthdata WHERE user=?"); 343 | $stmt_player = strtolower($player); 344 | $stmt->bind_param("s", $stmt_player); 345 | if($stmt->execute()){ 346 | $stmt->close(); 347 | return ServerAuthWebAPI::SUCCESS; 348 | }else{ 349 | $stmt->close(); 350 | return ServerAuthWebAPI::ERR_MYSQL; 351 | } 352 | }else{ 353 | return ServerAuthWebAPI::ERR_MYSQL; 354 | } 355 | }else{ 356 | return $this->isPlayerRegistered($player); 357 | } 358 | }else{ 359 | return $this->getStatus(); 360 | } 361 | } 362 | 363 | /** 364 | * Change player password 365 | * 366 | * @param string $player 367 | * @param string $new_password 368 | * 369 | * @return int|boolean true on SUCCESS or false if the player is not registered, otherwise the current status 370 | */ 371 | public function changePlayerPassword($player, $new_password){ 372 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 373 | if($this->isPlayerRegistered($player)){ 374 | //Check MySQL connection 375 | if($this->getDatabase() && $this->getDatabase()->ping()){ 376 | $stmt = $this->getDatabase()->prepare("UPDATE " . $this->getTablePrefix() . "serverauthdata SET password=? WHERE user=?"); 377 | $stmt_password = hash($this->getPasswordHash(), $new_password); 378 | $stmt_player = strtolower($player); 379 | $stmt->bind_param("ss", $stmt_password, $stmt_player); 380 | if($stmt->execute()){ 381 | $stmt->close(); 382 | return ServerAuthWebAPI::SUCCESS; 383 | }else{ 384 | $stmt->close(); 385 | return ServerAuthWebAPI::ERR_MYSQL; 386 | } 387 | } 388 | }else{ 389 | return $this->isPlayerRegistered($player); 390 | } 391 | }else{ 392 | return $this->getStatus(); 393 | } 394 | } 395 | } 396 | --------------------------------------------------------------------------------