I wrote this code for The Tesseract re-release but that never happened, so here we are. I had also originally posted this in the Gaming Squad section, but I figured it could be useful for everyone. You can use this code to either authenticate your app for Elite or using a custom key system - it's all up to you. The example uses Elite auth by default but you can change it pretty easily by just getting rid of the validate_elite_key function call. Follow the steps below for installing this on your server.
- A server
- A web server installed (nginx, apache2, it doesn't matter)
- MySQL installed
- PHP installed
- Root login info for MySQL
How to setup:
- Download zip and extract contents to a location on your PC
- Open up 'autoload.php' and add a name for the DATABASE_NAME constant at the top.
- In the same file, add the credentials for your MySQL login. This user should have permissions to create tables and databases (so ideally use root)
- Save file, and upload all the files to a directory on your server.
- Go to the directory in your browser and load the setup.php script first.
- If you used proper MySQL credentials, it will successfully create both a database and two tables in said database.
- DELETE setup.php from your server
- Create a new MySQL user with only the required permissions (SELECT, INSERT, UPDATE, etc) and replace your root user's credentials inside `autoload.php` with this new MySQL user information (thanks to JB for catching this error)
- To test, access auth.php with a GET request for key using your NGU Elite key (example: You must login or register to view this content.)
- If the setup worked properly, it should output "Some useful information" (hilarious, right?) and if you check your log and users table, you should see your Elite key there.
It's a basic system for getting your app up and running. However this does do automatic banning for users who share multiple keys under so many different IPs in a certain period of time (like 24 hrs I think). The ban check is done each time the auth script executes, so unless your app gets little to no traffic, it should do just fine. If you really want you can setup a cron job to run the unban/ban process every so often.
You must login or register to view this content.
Enjoy and let me know if you have any issues or just need help with it.