ULX

Author Topic: ULib SQLite Authentication  (Read 5128 times)

0 Members and 1 Guest are viewing this topic.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
ULib SQLite Authentication
« on: July 17, 2018, 04:26:10 PM »
What This Is
This is a replacement for ULib's UCL storage system. The current system saves and reads all stored users and their accesses from a single text file. This works fine, unless you a LOT of users, at which point you will start to experience some lag.

What This Does
This overrides the Save and Load functions in UCL. Instead of loading and saving your users to the users.txt file, it will instead load and save them from a SQLite database.


What This Doesn't Do
This only handles users. It doesn't store groups or group permissions. Those are still going to be stored in the groups.txt
This doesn't handle banning. Bans are already saved to the SQLite database by default in the newer versions of ULX.

What Is Modified
You will need to *replace* your ucl.lua file in addons\ULib\lua\ulib\server\ucl.lua
We typically NEVER recommend that you replace any of our stock files as this could cause issues or the changes will be reverted the next time you update ULib.. However, due to the nature of this kind of modification simply writing it into an addon wouldn't work because of the way modules are loaded. If you choose to install this, I HIGHLY recommend making a backup of your ULib addon first.
Inside the ucl.lua file I added some SQLite functions. I also modified the SaveFile function as well as completely commented out the LoadFromFile function. I also slightly modified addUser and removeUser functions.

How To Install
1. Download the copy of ucl.lua from this post (YOU NEED TO BE LOGGED IN TO SEE IT)
2. Replace Addons\ULib\lua\server\ucl.lua with the one I provided.
3. (optional) From your server console or in game (if you are a superadmin) run ulib_loadlegacy to load your users from your users.txt and load them into your database.

Upgrading from my MySQL module addon
If you decided you want to use the SQLite version instead of the MySQL version (because maybe you only have 1 server and don't need to access the data from outside of gmod) I've made it quite easy to import your existing MySQL users into this new SQLite system. Follow these directions EXACTLY:

1. BEFORE uninstalling the old module and installing this module, you will need to download the UCL MySQL to SQLite Backup file below.
2. Install it as an addon.
3. Launch your server and run the command: ulib_backupmysql
4. Verify that it wrote a file entitled: garrysmod/data/sql_ucl_backup.txt
5. Stop server and uninstall the addon you just installed. You won't need it anymore.
6. Download the latest version of ULib and overwrite the current version you have (This resets your ucl.lua file back to default)
7. Proceed to install this SQLite version as normal.
8. Once you've launched your server with the SQLite version installed, run the following command from the server to import your backed up users: ulib_loadfrommysql

WARNING/CAUTION
If you update ULib this modification will be lost and you'll have to reinstall it.
This comes as-is and while I did to testing, there is no way for me to know if it'll work in every situation. Please make a backup of your ULib files before installing this.

Help/Support
Post questions here, and I will do my best to help you. I've tested this with ULX/ULib version:
ULib v2.63d (05/12/18)
ULX v3.73d (05/20/18)

Please let me know how this works for you. :)
« Last Edit: July 20, 2018, 08:04:38 AM by MrPresident »

Offline FunServer

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Re: ULib SQLite Authentication
« Reply #1 on: July 18, 2018, 01:27:55 PM »
Thank you.
M8

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: ULib SQLite Authentication
« Reply #2 on: July 20, 2018, 08:05:16 AM »
Updated the ucl.lua replacement file. I had left out a VERY important line of code... lol

Should be working 100% now.