user.db

Discussion Forum for Jaymod
Post Reply
Michaelangelo
Server n00b
Posts: 2
Joined: Sat Dec 31, 2011 9:37 pm

user.db

Post by Michaelangelo » Sat Dec 31, 2011 9:39 pm

I'm looking to delete the user.db file from my server to clear out bans and every time I delete it via ftp it comes back. Any ideas?

Thanks

panthro
Server n00b
Posts: 12
Joined: Mon Apr 04, 2011 8:07 pm

Re: user.db

Post by panthro » Sun Jan 01, 2012 11:54 pm

try
!dbload
!dbsave
Image

Ligustah
Panzer n00b
Posts: 66
Joined: Wed Apr 13, 2011 9:03 am

Re: user.db

Post by Ligustah » Mon Jan 02, 2012 10:35 am

I once wrote a tiny program that would scan a user.db and create a file like "unban.cfg" that you could exec on your server to clear all the bans.
I'll see if I can find it somewhere and post back later.

Ligustah
Panzer n00b
Posts: 66
Joined: Wed Apr 13, 2011 9:03 am

Re: user.db

Post by Ligustah » Mon Jan 02, 2012 5:17 pm

Here you go.
Source code written in D programming language, but after all, it's very simple.

Code: Select all

module main;

import tango.io.device.File;
import Text = tango.text.Util;
import tango.io.stream.Lines;
import tango.io.Stdout;
import tango.io.stream.Format;

import tango.time.Time;
import tango.time.Clock;

import tango.stdc.string;

void unban(char[] inFileName, char[] outFileName)
{
	File inFile = new File(inFileName, File.ReadExisting);
	scope(exit)
		inFile.close();
	
	File outFile = new File(outFileName, File.ReadWriteCreate);
	scope(exit)
		outFile.close();
	
	auto fmt = new FormatOutput!(char)(outFile);
	
	auto lines = new Lines!(char)(inFile);
	
	char[32] guid;
	char[] guidLine = "guid = ";
	char[] bannedLine = "banned";
	
	foreach(line; lines)
	{
		if(!line.length || line[0] == '#')
			continue;

		if(!memcmp(line.ptr, guidLine.ptr, guidLine.length))
		{
			//always save the last seen GUID for later use
			memcpy(guid.ptr, line.ptr + 7, 32);
		}
		else if(!memcmp(line.ptr, bannedLine.ptr, bannedLine.length))
		{
			//guid holds the last seen GUID, since every 'banned' entry has to be preceded by a GUID
			outFile.write("!unban ");
			outFile.write(guid);
			fmt.newline;
		}
	}
}

void main()
{
	unban("user.db", "unban.cfg");
}
I attached the compiled version.
Attachments
unbanhammer.zip
(97.55 KiB) Downloaded 215 times

Michaelangelo
Server n00b
Posts: 2
Joined: Sat Dec 31, 2011 9:37 pm

Re: user.db

Post by Michaelangelo » Tue Jan 03, 2012 4:09 pm

Not familiar with the "D" programming language, perhaps a typo?

Anyway the script looks useful, but what ended up happening is the server had to be stopped before I could delete the file.

All good now.

Thanks for the quick replies!

Ligustah
Panzer n00b
Posts: 66
Joined: Wed Apr 13, 2011 9:03 am

Re: user.db

Post by Ligustah » Tue Jan 03, 2012 6:28 pm

Yea, I wrote it because I wanted to clear the bans without losing the user records.

As for the programming language: http://en.wikipedia.org/wiki/D_%28progr ... anguage%29
:P

Post Reply